diff --git a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
index 5d7c2bd..3788b24 100644
--- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
+++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml
@@ -572,6 +572,11 @@
创建时间
+
+
+ 生产计划Id
+
+
名 称 :工单拆分
@@ -654,6 +659,11 @@
工单Id
+
+
+ 设备Id
+
+
工艺Id
@@ -1145,6 +1155,31 @@
描 述 :
+
+
+ 工单所属设备保存
+
+
+
+
+ 工单Id
+
+
+
+
+ 产线Id
+
+
+
+
+ 产线工序Id
+
+
+
+
+ 设备Id
+
+
工艺流程库
@@ -9050,6 +9085,11 @@
工单名称
+
+
+ 生产计划Id
+
+
产线Id
@@ -9085,6 +9125,21 @@
增加
+
+
+ 产线工序Id
+
+
+
+
+ 产线工序Id
+
+
+
+
+ 设备
+
+
更新
@@ -9095,6 +9150,11 @@
主键
+
+
+ 产线工序Id
+
+
删除
@@ -9240,6 +9300,37 @@
物料信息
+
+
+ 编辑页面
+
+
+
+
+
+ 生产计划Id
+
+
+
+
+ 成品名称
+
+
+
+
+ 数量
+
+
+
+
+ 产线Id
+
+
+
+
+ 产线工序Id
+
+
名 称 :工单产量
@@ -9916,6 +10007,13 @@
+
+
+ 获取编辑详情
+
+
+
+
名 称 :
diff --git a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs
index d43dbd6..67fa3ce 100644
--- a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs
+++ b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_WorkInfoEntity.cs
@@ -44,5 +44,9 @@
/// 创建时间
///
public DateTime CreateTime { get; set; }
+ ///
+ /// 生产计划Id
+ ///
+ public string PlanId { get; set; }
}
}
diff --git a/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs
index 41b2192..694311f 100644
--- a/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs
+++ b/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs
@@ -14,6 +14,10 @@
///
public string WorkId { get; set; }
///
+ /// 设备Id
+ ///
+ public string DeviceId { get; set; }
+ ///
/// 工艺Id
///
public string CraftId { get; set; }
diff --git a/backend/BPA.MES.Base.Application/Entitys/Base/WorkDeviceRecordEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Base/WorkDeviceRecordEntity.cs
new file mode 100644
index 0000000..8afb501
--- /dev/null
+++ b/backend/BPA.MES.Base.Application/Entitys/Base/WorkDeviceRecordEntity.cs
@@ -0,0 +1,26 @@
+namespace BPA.MES.Base.Application.Entitys.Base
+{
+ ///
+ /// 工单所属设备保存
+ ///
+ [SugarTable("work_device_record")]
+ public class WorkDeviceRecordEntity : DEntityBase
+ {
+ ///
+ /// 工单Id
+ ///
+ public string WorkId { get; set; }
+ ///
+ /// 产线Id
+ ///
+ public string LineId { get; set; }
+ ///
+ /// 产线工序Id
+ ///
+ public string ProcessId { get; set; }
+ ///
+ /// 设备Id
+ ///
+ public string DeviceId { get; set; }
+ }
+}
diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoDto.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoDto.cs
index 8504f49..52a92b7 100644
--- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoDto.cs
+++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoDto.cs
@@ -13,6 +13,10 @@
///
public string Name { get; set; }
///
+ /// 生产计划Id
+ ///
+ public string PlanId { get; set; }
+ ///
/// 产线Id
///
public string LineId { get; set; }
@@ -45,8 +49,24 @@
///
public class WorkInfoAddInput : WorkInfoDto
{
+ ///
+ /// 产线工序Id
+ ///
+ public List WorkDevices { get; set; } = new();
}
+
+ public class WorkDeviceAddInput
+ {
+ ///
+ /// 产线工序Id
+ ///
+ public string ProcessId { get; set; }
+ ///
+ /// 设备
+ ///
+ public string DeviceId { get; set; }
+ }
///
/// 更新
///
@@ -56,6 +76,10 @@
/// 主键
///
public string Id { get; set; }
+ ///
+ /// 产线工序Id
+ ///
+ public List WorkDevices { get; set; } = new();
}
///
/// 删除
@@ -166,7 +190,7 @@
///
public WorkOrderStatusEnum? Status { get; set; }
-
+
}
///
@@ -191,13 +215,38 @@
///
/// 工艺步骤
///
- public List CraftList { get; set; }
+ public List CraftList { get; set; }
///
/// 物料信息
///
- public List MaterialList { get; set; }
+ public List MaterialList { get; set; }
}
-
-
+ ///
+ /// 编辑页面
+ ///
+ ///
+ public class WorkInfoEditDetailOutput
+ {
+ ///
+ /// 生产计划Id
+ ///
+ public string PlanId { get; set; }
+ ///
+ /// 成品名称
+ ///
+ public string FinalName { get; set; }
+ ///
+ /// 数量
+ ///
+ public string Quantity { get; set; }
+ ///
+ /// 产线Id
+ ///
+ public string LineId { get; set; }
+ ///
+ /// 产线工序Id
+ ///
+ public List WorkDevices { get; set; } = new();
+ }
}
diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkInfoService.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkInfoService.cs
index 4fbedd3..7cfb034 100644
--- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkInfoService.cs
+++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/IWorkInfoService.cs
@@ -23,6 +23,8 @@
///
///
Task Update(WorkInfoUpdateInput input);
+
+ Task EditDetail(string Id);
///
/// 不分页列表
///
diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs
index f7a4379..4404e5f 100644
--- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs
+++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs
@@ -1,4 +1,6 @@
-using Furion.EventBus;
+using BPA.MES.Base.Application.Entitys.Base;
+using Furion.EventBus;
+using System.Security.Cryptography;
using Yitter.IdGenerator;
namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
@@ -29,20 +31,36 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
{
bool result = false;
Pztj_WorkInfoEntity entity = input.Adapt();
+ List workDeviceRecordEntities = new();
+ foreach (var item in input.WorkDevices)
+ {
+ WorkDeviceRecordEntity workDeviceRecordEntity = new()
+ {
+ DeviceId = item.DeviceId,
+ WorkId = entity.Id,
+ ProcessId = item.ProcessId,
+ LineId = input.LineId,
+ };
+ workDeviceRecordEntities.Add(workDeviceRecordEntity);
+ }
+ Pztj_WorkInfoStatusEntity pztj_WorkInfoStatusEntity = new()
+ {
+ Status = WorkOrderStatusEnum.Draft,
+ WorkId = entity.Id
+ };
try
{
_dbContext.Ado.BeginTran();
await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync();
- Pztj_WorkInfoStatusEntity pztj_WorkInfoStatusEntity = new()
+ if (workDeviceRecordEntities.Count>1)
{
- Status = WorkOrderStatusEnum.Draft,
- WorkId = entity.Id
- };
+ await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync();
+ }
await _dbContext.Insertable(pztj_WorkInfoStatusEntity).IgnoreColumns(true).ExecuteCommandAsync();
_dbContext.Ado.CommitTran();
result = true;
}
- catch
+ catch (Exception ex)
{
_dbContext.Ado.RollbackTran();
throw Oops.Bah("添加失败!");
@@ -74,7 +92,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
.LeftJoin((a, b) => a.FinalId == b.Id)
.LeftJoin((a, b, c) => a.LineId == c.Id)
.LeftJoin((a, b, c, d) => d.Id == SqlFunc.Subqueryable().Where(s => s.WorkId == a.Id).OrderByDesc(s => s.CreateTime).Select(s => s.Id))
- .LeftJoin((a,b,c,d,e)=>a.DeviceId==e.Id)
+ .LeftJoin((a, b, c, d, e) => a.DeviceId==e.Id)
.Where((a, b, c, d) => a.Id == Id)
.Select((a, b, c, d, e) => new WorkInfoDetailOutput
{
@@ -100,10 +118,10 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
var craftlist = await _dbContext.Queryable().Where(x => x.WorkId == Id).ToListAsync();
//获取物料信息
var materiallist = await _dbContext.Queryable()
- .LeftJoin((a,b)=>a.MaterialId==b.Id)
- .LeftJoin((a,b,c) => b.Type == c.Id)
+ .LeftJoin((a, b) => a.MaterialId==b.Id)
+ .LeftJoin((a, b, c) => b.Type == c.Id)
.Where((a, b) => a.WorkId == Id)
- .Select((a, b,c) =>
+ .Select((a, b, c) =>
new WorkInfoMaterialsRecordOutput
{
Id = a.Id.SelectAll(),
@@ -154,7 +172,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
var entity = await _dbContext.Queryable()
.LeftJoin((a, b) => a.FinalId == b.Id)
.LeftJoin((a, b, c) => a.LineId == c.Id)
- .LeftJoin((a, b, c, d) =>a.DeviceId==d.Id)
+ .LeftJoin((a, b, c, d) => a.DeviceId==d.Id)
.WhereIF(!string.IsNullOrEmpty(input.Name), (a, b, c, d) => b.Name.Contains(input.Name))
.WhereIF(!string.IsNullOrEmpty(input.Id), (a, b, c, d) => a.Id.Contains(input.Id))
.WhereIF(!string.IsNullOrEmpty(input.BatchId), (a, b, c, d) => a.BatchId == input.BatchId)
@@ -247,7 +265,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
string userId = App.User?.FindFirst(ClaimConst.CLAINM_USERID)?.Value;
string userName = App.User?.FindFirst(ClaimConst.CLAINM_NAME)?.Value;
var workentitys = await _dbContext.Queryable().Where(x => x.BatchId == input.BatchId).ToListAsync();
-
+
foreach (var item in workentitys)
{
var res = await UpdateStatus(
@@ -283,7 +301,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
var materiallist = await _dbContext.Queryable()
.LeftJoin((a, b) => a.MaterialId == b.Id)
.LeftJoin((a, b, c) => a.RecipesId == c.Id)
- //.Where((a, b, c) => a.RecipesId == finainfo.RecipeId)
+ //.Where((a, b, c) => a.RecipesId == finainfo.RecipeId)
.Select((a, b, c) => new WorkInfoMaterialsRecordEntity
{
MaterialId = a.MaterialId,
@@ -397,9 +415,9 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
Remark = $"[{userId}]{userName}"
});
var workentity = await _dbContext.Queryable()
- .LeftJoin((a,b)=>a.DeviceId==b.Id)
+ .LeftJoin((a, b) => a.DeviceId==b.Id)
.Where((a, b) => a.Id == input.WorkId)
- .Select((a,b)=>new WorkInfoOutput
+ .Select((a, b) => new WorkInfoOutput
{
Id=a.Id.SelectAll(),
DeviceCode = b.Code,
@@ -421,8 +439,8 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
var materiallist = await _dbContext.Queryable()
.LeftJoin((a, b) => a.MaterialId == b.Id)
- .LeftJoin((a,b,c)=>a.RecipesId==c.Id)
- //.Where((a, b, c) => a.RecipesId == finainfo.RecipeId)
+ .LeftJoin((a, b, c) => a.RecipesId==c.Id)
+ //.Where((a, b, c) => a.RecipesId == finainfo.RecipeId)
.Select((a, b, c) => new WorkInfoMaterialsRecordEntity
{
MaterialId = a.MaterialId,
@@ -498,7 +516,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
_dbContext.Ado.BeginTran();
await _dbContext.Deleteable().Where(x => x.WorkId == input.WorkId).ExecuteCommandAsync();
await _dbContext.Deleteable().Where(x => x.WorkId == input.WorkId).ExecuteCommandAsync();
-
+
await _dbContext.Insertable(newcraftslist).ExecuteCommandAsync();
await _dbContext.Insertable(newmateriallist).ExecuteCommandAsync();
_dbContext.Ado.CommitTran();
@@ -536,10 +554,43 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
[HttpPost]
public async Task Update(WorkInfoUpdateInput input)
{
+ bool result = false;
Pztj_WorkInfoEntity entity = input.Adapt();
- entity.CreateTime = DateTime.Now;
- var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync();
- return res;
+ List workDeviceRecordEntities = new();
+ foreach (var item in input.WorkDevices)
+ {
+ WorkDeviceRecordEntity workDeviceRecordEntity = new()
+ {
+ DeviceId = item.DeviceId,
+ WorkId = entity.Id,
+ ProcessId = item.ProcessId,
+ LineId = input.LineId,
+ };
+ workDeviceRecordEntities.Add(workDeviceRecordEntity);
+ }
+ Pztj_WorkInfoStatusEntity pztj_WorkInfoStatusEntity = new()
+ {
+ Status = WorkOrderStatusEnum.Draft,
+ WorkId = entity.Id
+ };
+ try
+ {
+ _dbContext.Ado.BeginTran();
+ await _dbContext.Updateable(entity).Where(x=>x.Id==input.Id).IgnoreColumns(true).ExecuteCommandAsync();
+ await _dbContext.Deleteable().Where(x => x.WorkId==input.Id).ExecuteCommandAsync();
+ if (workDeviceRecordEntities.Count>1)
+ {
+ await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync();
+ }
+ _dbContext.Ado.CommitTran();
+ result = true;
+ }
+ catch (Exception ex)
+ {
+ _dbContext.Ado.RollbackTran();
+ throw Oops.Bah("添加失败!");
+ }
+ return result;
}
///
/// 修改工单状态
@@ -661,10 +712,39 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services
[HttpGet]
public async Task> StatusList(string workId)
{
- var entitys = await _dbContext.Queryable().Where(x => x.WorkId == workId).OrderByDescending(x=>x.CreateTime).ToListAsync();
+ var entitys = await _dbContext.Queryable().Where(x => x.WorkId == workId).OrderByDescending(x => x.CreateTime).ToListAsync();
List list = entitys.Adapt>();
-
+
return list;
}
+ ///
+ /// 获取编辑详情
+ ///
+ ///
+ ///
+ [HttpGet]
+ public async Task EditDetail(string Id)
+ {
+ var entity = await _dbContext.Queryable()
+ .LeftJoin((a, b) => a.PlanId == b.Id)
+ .LeftJoin((a, b, c) => a.FinalId == c.Id)
+ .Where((a, b, c) => a.Id == Id)
+ .Select((a, b, c) => new WorkInfoEditDetailOutput
+ {
+ PlanId = a.PlanId,
+ FinalName = c.Name,
+ LineId = a.LineId,
+ Quantity = b.Quantity
+ }).FirstAsync();
+ var devicelist = await _dbContext.Queryable().Where(x => x.WorkId==Id)
+ .Select(x => new WorkDeviceAddInput
+ {
+ DeviceId = x.DeviceId,
+ ProcessId = x.ProcessId,
+ })
+ .ToListAsync();
+ entity.WorkDevices = devicelist;
+ return entity;
+ }
}
}