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 e8a57ae..e044bd9 100644 --- a/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml +++ b/backend/BPA.MES.Base.Application/BPA.MES.Base.Application.xml @@ -514,7 +514,7 @@ 料仓名称 - + 物料Id @@ -522,7 +522,7 @@ 料仓容积 - + i @@ -669,6 +669,11 @@ 工艺Id + + + 成品Id + + 工艺名称 @@ -737,6 +742,11 @@ 物料id + + + 物料编码 + + 工单id @@ -841,17 +851,17 @@ 描 述 : - + 设备产品Id - + 名称 - + 编码 @@ -1008,7 +1018,7 @@ 成品配方 - + 物料Id @@ -5141,7 +5151,12 @@ - 物料Id + 物料编码 + + + + + 物料编码 @@ -5229,11 +5244,6 @@ 物料名称 - - - 物料编码 - - 名 称 :成品管理 @@ -7786,9 +7796,9 @@ 产线Id - + - 物料Id + 物料编码 @@ -7842,7 +7852,7 @@ 编码 - + 物料信息 @@ -8744,7 +8754,7 @@ 料仓名称 - + 物料Id @@ -9546,6 +9556,16 @@ 每升重量 + + + 物料编码 + + + + + 物料配料方式 + + 名 称 :工单状态 @@ -9629,11 +9649,6 @@ 工单ID - - - 设备ID - - 输出 diff --git a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_StockInfoEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_StockInfoEntity.cs index 60338a1..c84cd24 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/Pztj_StockInfoEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/Pztj_StockInfoEntity.cs @@ -20,10 +20,10 @@ /// /// 物料Id /// - public string MaterialId { get; set; } + public string MaterialCode { get; set; } /// /// 料仓容积 - /// + /// i public string Volume { 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 694311f..908e6c2 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoCraftstepRecordEntity.cs @@ -22,6 +22,10 @@ /// public string CraftId { get; set; } /// + /// 成品Id + /// + public string FinalId { get; set; } + /// /// 工艺名称 /// public string CraftName { get; set; } diff --git a/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs b/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs index b94c2a0..92be6df 100644 --- a/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/App/WorkInfoMaterialsRecordEntity.cs @@ -20,6 +20,10 @@ [SugarColumn(IsNullable = true)] public string MaterialId { get; set; } /// + /// 物料编码 + /// + public string MaterialCode { get; set; } + /// /// 工单id /// [SugarColumn(IsNullable = true)] diff --git a/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductParmEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductParmEntity.cs index dd527fd..bd12874 100644 --- a/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductParmEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/Base/DeviceProductParmEntity.cs @@ -12,15 +12,15 @@ /// /// 设备产品Id /// - public string DeviceProductId { get; set; } + public string FunctionId { get; set; } /// /// 名称 /// - public string Name { get; set; } + public string Code { get; set; } /// /// 编码 /// - public string Code { get; set; } + public string Souce { get; set; } /// /// 描述 /// diff --git a/backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs b/backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs index cedee4e..e40b182 100644 --- a/backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs +++ b/backend/BPA.MES.Base.Application/Entitys/Base/FinalMaterialEntity.cs @@ -16,7 +16,7 @@ namespace BPA.MES.Base.Application.Entitys /// /// 物料Id /// - public string MaterialId { get; set; } + public string MaterialCode { get; set; } /// /// 操作方式 /// diff --git a/backend/BPA.MES.Base.Application/Services/DeviceProductService/Services/DeviceProductParmService.cs b/backend/BPA.MES.Base.Application/Services/DeviceProductService/Services/DeviceProductParmService.cs index 1c0499b..1c72371 100644 --- a/backend/BPA.MES.Base.Application/Services/DeviceProductService/Services/DeviceProductParmService.cs +++ b/backend/BPA.MES.Base.Application/Services/DeviceProductService/Services/DeviceProductParmService.cs @@ -22,7 +22,7 @@ [HttpPost] public async Task Add(DeviceProductParmAddInput input) { - var r_entity = await _dbContext.Queryable().FirstAsync(x => x.Name == input.Name); + var r_entity = await _dbContext.Queryable().FirstAsync(x => x.Code == input.Name); if (r_entity != null) { throw Oops.Bah("名称已存在!"); @@ -76,7 +76,6 @@ public async Task> PagedList(DeviceProductParmQueryPageInput input) { var entity = await _dbContext.Queryable() - .WhereIF(!string.IsNullOrEmpty(input.Name), x => x.Name.Contains(input.Name)) .WhereIF(!string.IsNullOrEmpty(input.Code), x => x.Code.Contains(input.Code)) .ToPagedListAsync(input.PageIndex, input.PageSize); SqlSugarPagedList output = entity.Adapt>(); @@ -93,7 +92,7 @@ var entity = await _dbContext.Queryable().Select(x => new { key = x.Id, - value = x.Name + value = x.Code }).ToListAsync(); return entity; } diff --git a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs index cd70f5a..5afe390 100644 --- a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs +++ b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Dtos/FinalMaterialDto.cs @@ -11,10 +11,14 @@ namespace BPA.MES.Base.Application.Services public class FinalMaterialDto { /// - /// 物料Id + /// 物料编码 /// public string MaterialId { get; set; } /// + /// 物料编码 + /// + public string MaterialCode { get; set; } + /// /// 成品Id /// public string FinalId { get; set; } @@ -96,9 +100,6 @@ namespace BPA.MES.Base.Application.Services /// 物料名称 /// public string MaterialName { get; set; } - /// - /// 物料编码 - /// - public string MaterialCode { get; set; } + } } diff --git a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs index e671924..6e137ba 100644 --- a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs +++ b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalMaterialService.cs @@ -85,7 +85,7 @@ public async Task> List(FinalMaterialQueryInput input) { var output = await _dbContext.Queryable() - .LeftJoin((a,b)=>a.MaterialId==b.Id) + .LeftJoin((a,b)=>a.MaterialCode==b.Code) .WhereIF(!string.IsNullOrEmpty(input.FinalId),(a,b)=>a.FinalId==input.FinalId) .Select((a,b)=>new FinalMaterialOutput { diff --git a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalsInfoService.cs b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalsInfoService.cs index e0fc016..f7f6def 100644 --- a/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalsInfoService.cs +++ b/backend/BPA.MES.Base.Application/Services/FinalsInfoService/Services/FinalsInfoService.cs @@ -41,7 +41,20 @@ namespace BPA.MES.Base.Application.Services [HttpPost] public async Task Del(FinalsInfoDelInput input) { - var res = await _dbContext.Deleteable().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); + bool res =false; + try + { + _dbContext.Ado.BeginTran(); + await _dbContext.Deleteable().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); + await _dbContext.Deleteable().Where(x => x.FinalId == input.Id).ExecuteCommandAsync(); + _dbContext.Ado.CommitTran(); + res = true; + } + catch (Exception) + { + + _dbContext.Ado.RollbackTran(); + } return res; } /// diff --git a/backend/BPA.MES.Base.Application/Services/MaterialService/Services/MaterialsInfoService.cs b/backend/BPA.MES.Base.Application/Services/MaterialService/Services/MaterialsInfoService.cs index 269dfae..55affe9 100644 --- a/backend/BPA.MES.Base.Application/Services/MaterialService/Services/MaterialsInfoService.cs +++ b/backend/BPA.MES.Base.Application/Services/MaterialService/Services/MaterialsInfoService.cs @@ -124,6 +124,11 @@ [HttpPost] public async Task Update(MaterialsInfoUpdateInput input) { + var currentity = await _dbContext.Queryable().FirstAsync(x => x.Id != input.Id && (x.Name == input.Name || x.Code==input.Code)); + if (currentity != null) + { + throw Oops.Bah("名称已存在!"); + } var entity = await _dbContext.Queryable().Where(x => x.Id == input.Id).FirstAsync(); entity = input.Adapt(); var res = await _dbContext.Updateable(entity).IgnoreColumns(true).ExecuteCommandHasChangeAsync(); diff --git a/backend/BPA.MES.Base.Application/Services/ProductLineService/Dtos/ProductLineStockDto.cs b/backend/BPA.MES.Base.Application/Services/ProductLineService/Dtos/ProductLineStockDto.cs index 6876119..dcfaf03 100644 --- a/backend/BPA.MES.Base.Application/Services/ProductLineService/Dtos/ProductLineStockDto.cs +++ b/backend/BPA.MES.Base.Application/Services/ProductLineService/Dtos/ProductLineStockDto.cs @@ -36,9 +36,9 @@ /// public string LineId { get; set; } /// - /// 物料Id + /// 物料编码 /// - public string MaterialId { get; set; } + public string MaterialCode { get; set; } } /// /// 产线设备分页 @@ -89,7 +89,7 @@ /// /// 物料信息 /// - public string MaterialId { get; set; } + public string MaterialCode { get; set; } /// /// 物料名称 /// diff --git a/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs b/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs index aaa8fbc..560bba7 100644 --- a/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs +++ b/backend/BPA.MES.Base.Application/Services/ProductLineService/Services/ProductLineService.cs @@ -263,8 +263,8 @@ namespace BPA.MES.Base.Application.Services { var entity = await _dbContext.Queryable() .LeftJoin((a, b) => a.StockId == b.Id) - .LeftJoin((a, b,c) => b.MaterialId == c.Id) - .WhereIF(!string.IsNullOrEmpty(input.MaterialId), (a, b) => b.MaterialId == input.MaterialId) + .LeftJoin((a, b,c) => b.MaterialCode == c.Code) + .WhereIF(!string.IsNullOrEmpty(input.MaterialCode), (a, b) => b.MaterialCode == input.MaterialCode) .WhereIF(!string.IsNullOrEmpty(input.LineId), (a, b) => a.LineId == input.LineId) .Select((a, b,c) => new ProductLineStockOutput { @@ -273,7 +273,7 @@ namespace BPA.MES.Base.Application.Services StockCode = b.Code, StockId = b.Id, StockName = b.Name, - MaterialId = b.MaterialId, + MaterialCode = b.MaterialCode, MateriaName = c.Name }) .ToListAsync(); diff --git a/backend/BPA.MES.Base.Application/Services/StockInfoService/Dtos/StockInfoDto.cs b/backend/BPA.MES.Base.Application/Services/StockInfoService/Dtos/StockInfoDto.cs index 35c5b20..64ca070 100644 --- a/backend/BPA.MES.Base.Application/Services/StockInfoService/Dtos/StockInfoDto.cs +++ b/backend/BPA.MES.Base.Application/Services/StockInfoService/Dtos/StockInfoDto.cs @@ -19,7 +19,7 @@ /// /// 物料Id /// - public string MaterialId { get; set; } + public string MaterialCode { get; set; } /// /// 料仓容积 /// diff --git a/backend/BPA.MES.Base.Application/Services/StockInfoService/Services/StockInfoService.cs b/backend/BPA.MES.Base.Application/Services/StockInfoService/Services/StockInfoService.cs index d45ce73..e5753da 100644 --- a/backend/BPA.MES.Base.Application/Services/StockInfoService/Services/StockInfoService.cs +++ b/backend/BPA.MES.Base.Application/Services/StockInfoService/Services/StockInfoService.cs @@ -1,4 +1,6 @@ -namespace BPA.MES.Base.Application.Services +using SqlSugar; + +namespace BPA.MES.Base.Application.Services { /// /// 名 称 :料仓服务 @@ -63,7 +65,14 @@ [HttpGet] public async Task> List() { - var entity = await _dbContext.Queryable().ToListAsync(); + var entity = await _dbContext.Queryable() + .LeftJoin((a,b)=>a.MaterialCode==b.Code) + .Select((a, b) =>new StockInfoOutput + { + Id = a.Id.SelectAll(), + MaterialName = b.Name, + }) + .ToListAsync(); List output = entity.Adapt>(); return output; } @@ -76,7 +85,7 @@ public async Task> PagedList(StockInfoQueryPageInput input) { var entity = await _dbContext.Queryable() - .LeftJoin((a,b)=>a.MaterialId==b.Id) + .LeftJoin((a,b)=>a.MaterialCode==b.Code) .WhereIF(!string.IsNullOrEmpty(input.Name),(a,b)=>a.Name.Contains(input.Name)) .WhereIF(!string.IsNullOrEmpty(input.Code), (a, b) => a.Code.Contains(input.Code)) .Select((a,b)=>new StockInfoOutput diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoMaterialsRecordDto.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoMaterialsRecordDto.cs index 6147858..e995c83 100644 --- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoMaterialsRecordDto.cs +++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoMaterialsRecordDto.cs @@ -1,4 +1,6 @@ -namespace BPA.MES.Base.Application.Services +using BPA.MES.Base.Application.Const; + +namespace BPA.MES.Base.Application.Services { /// /// 名 称 : @@ -108,5 +110,13 @@ /// 每升重量 /// public string WeightPerLiter { get; set; } + /// + /// 物料编码 + /// + public string MaterialCode { get; set; } + /// + /// 物料配料方式 + /// + public ModeEnum MaterialMode { get; set; } } } diff --git a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs index 9c6a5a4..d4ee255 100644 --- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs +++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Dtos/WorkInfoStatusDto.cs @@ -87,10 +87,6 @@ /// 工单ID /// public string WorkId { get; set; } - /// - /// 设备ID - /// - public string? DeviceId { get; set; } } /// /// 输出 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 b16a7d4..5beecc2 100644 --- a/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs +++ b/backend/BPA.MES.Base.Application/Services/WorkInfoService/Services/WorkInfoService.cs @@ -55,7 +55,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services { _dbContext.Ado.BeginTran(); await _dbContext.Insertable(entity).IgnoreColumns(ignoreNullColumn: true).ExecuteCommandAsync(); - if (workDeviceRecordEntities.Count>1) + if (workDeviceRecordEntities.Count>0) { await _dbContext.Insertable(workDeviceRecordEntities).ExecuteCommandAsync(); } @@ -79,6 +79,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services [HttpPost] public async Task Del(WorkInfoDelInput input) { + var res = await _dbContext.Deleteable().Where(x => x.Id == input.Id).ExecuteCommandHasChangeAsync(); return res; } @@ -121,16 +122,19 @@ 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.MaterialCode==b.MaterialCode) + .LeftJoin((a, b,c) => a.MaterialCode==c.Code) + .LeftJoin((a, b, c,d) => c.Type == d.Id) .Where((a, b) => a.WorkId == Id) - .Select((a, b, c) => + .Select((a, b, c,d) => new WorkInfoMaterialsRecordOutput { Id = a.Id.SelectAll(), MaterialType = c.Id, - MaterialTypeName = c.Value, - WeightPerLiter = b.WeightPerLiter + MaterialTypeName = d.Value, + MaterialCode = c.Code, + MaterialMode = b.Mode, + WeightPerLiter = c.WeightPerLiter }) .ToListAsync(); entity.CraftList = craftlist; @@ -266,131 +270,10 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services [HttpPost] public async Task Publishs(BatchInput input) { - 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( - new WorkInfoStatusUpdateInput - { - WorkId = item.Id, - Status = WorkOrderStatusEnum.Issued, - Remark = $"[{userId}]{userName}" - }); - var workentity = await _dbContext.Queryable() - .LeftJoin((a, b) => a.DeviceId == b.Id) - .Where((a, b) => a.Id == item.Id) - .Select((a, b) => new WorkInfoOutput - { - Id = a.Id.SelectAll(), - DeviceCode = b.Code, - DeviceName = b.Name - }) - .FirstAsync(); - if (res) - { - WorkInfoMaterialsRecordEntity workInfoMaterialsRecordEntity = new() - { - MaterialId = item.Id, - }; - //获取成品信息 - var finainfo = await _dbContext.Queryable().FirstAsync(x => x.Id == workentity.FinalId); - if (finainfo == null) - { - throw Oops.Bah("没有找到成品信息!"); - } - - 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) - .Select((a, b, c) => new WorkInfoMaterialsRecordEntity - { - MaterialId = a.MaterialId, - MaterialName = b.Name, - MaterialStatus = EBatchingStatus.等待配料, - WorkId = item.Id, - Weight = a.Weight, - RecipeId = a.RecipesId, - RecipeName = c.Name - }) - .ToListAsync(); - - //获取物料信息 - - var craftsteplist = await _dbContext.Queryable() - .LeftJoin((a, b) => a.CraftId == b.Id) - .LeftJoin((a, b, c) => a.DeviceProductFunctionId == c.Id) - //.Where((a, b) => a.CraftId == finainfo.CraftId) - .Select((a, b, c) => new WorkInfoCraftstepRecordEntity - { - CraftId = a.CraftId, - CraftName = b.Name, - CraftstepId = a.Id, - DeviceProductFunctionId = c.Id, - DeviceProductFunctionName = c.Name, - CraftstepParms = a.Params, - Status = RecipeStatus.等待执行, - Step = a.Step, - WorkId = item.Id - }) - .ToListAsync(); - List newmateriallist = new(); - List newcraftslist = new(); - for (int i = 1; i <= Convert.ToInt32(workentity.Number); i++) - { - foreach (var materiaItem in materiallist) - { - WorkInfoMaterialsRecordEntity itementity = new() - { - PotNum = i.ToString(), - MaterialId = materiaItem.MaterialId, - MaterialName = materiaItem.MaterialName, - MaterialStatus = materiaItem.MaterialStatus, - WorkId = materiaItem.WorkId, - Weight = materiaItem.Weight, - RecipeId = materiaItem.RecipeId, - RecipeName = materiaItem.RecipeName, - }; - newmateriallist.Add(itementity); - } - foreach (var craftstepitem in craftsteplist) - { - WorkInfoCraftstepRecordEntity itementity = new() - { - CraftId = craftstepitem.CraftId, - CraftName = craftstepitem.CraftName, - CraftstepId = craftstepitem.CraftstepId, - DeviceProductFunctionId = craftstepitem.DeviceProductFunctionId, - DeviceProductFunctionName = craftstepitem.DeviceProductFunctionName, - CraftstepParms = craftstepitem.CraftstepParms, - Status = craftstepitem.Status, - Step = craftstepitem.Step, - WorkId = craftstepitem.WorkId, - PotNum = i.ToString(), - }; - newcraftslist.Add(itementity); - } - } - try - { - _dbContext.Ado.BeginTran(); - await _dbContext.Deleteable().Where(x => x.WorkId == item.Id).ExecuteCommandAsync(); - await _dbContext.Deleteable().Where(x => x.WorkId == item.Id).ExecuteCommandAsync(); - - await _dbContext.Insertable(newcraftslist).ExecuteCommandAsync(); - await _dbContext.Insertable(newmateriallist).ExecuteCommandAsync(); - _dbContext.Ado.CommitTran(); - } - catch (Exception ex) - { - _dbContext.Ado.RollbackTran(); - throw Oops.Oh("下发失败!"); - } - await _MQTTService.MqttPublish(new MqttPublishDto() { Payload = workentity, Topic = Topics.WorkOrderPush, MessageId = MessageID.WorkOrderIssued }); - } + await Publish(new PublishInput { WorkId = item.Id }); } await _dbContext.Updateable().SetColumns(x => x.Status == WorkOrderStatusEnum.Issued).Where(x => x.Id == input.BatchId).ExecuteCommandAsync(); return true; @@ -407,10 +290,11 @@ 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; - if (!string.IsNullOrEmpty(input.DeviceId)) - { - await _dbContext.Updateable().SetColumns(x => x.DeviceId == input.DeviceId).Where(x => x.Id == input.WorkId).ExecuteCommandAsync(); - } + + //查询有多少个步骤 + + var deviceList = await _dbContext.Queryable().Where(x => x.WorkId==input.WorkId).ToListAsync(); + var res = await UpdateStatus( new WorkInfoStatusUpdateInput { @@ -430,53 +314,50 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services .FirstAsync(); if (res) { - WorkInfoMaterialsRecordEntity workInfoMaterialsRecordEntity = new() - { - MaterialId = input.WorkId, - }; + //获取成品信息 var finainfo = await _dbContext.Queryable().FirstAsync(x => x.Id == workentity.FinalId); if (finainfo == null) { throw Oops.Bah("没有找到成品信息!"); } - - var materiallist = await _dbContext.Queryable() - .LeftJoin((a, b) => a.MaterialId == b.Id) - .LeftJoin((a, b, c) => a.RecipesId==c.Id) + //获取物料信息 + var materiallist = await _dbContext.Queryable() + .LeftJoin((a, b) => a.MaterialCode == b.Code) //.Where((a, b, c) => a.RecipesId == finainfo.RecipeId) - .Select((a, b, c) => new WorkInfoMaterialsRecordEntity + .Select((a, b) => new WorkInfoMaterialsRecordEntity { - MaterialId = a.MaterialId, + MaterialCode = a.MaterialCode, MaterialName = b.Name, MaterialStatus = EBatchingStatus.等待配料, WorkId = input.WorkId, Weight = a.Weight, - RecipeId = a.RecipesId, - RecipeName = c.Name, ErrorWeight = a.ErrorWeight, }) .ToListAsync(); - - //获取物料信息 - - var craftsteplist = await _dbContext.Queryable() - .LeftJoin((a, b) => a.CraftId == b.Id) - .LeftJoin((a, b, c) => a.DeviceProductFunctionId == c.Id) - //.Where((a, b) => a.CraftId == finainfo.CraftId) - .Select((a, b, c) => new WorkInfoCraftstepRecordEntity - { - CraftId = a.CraftId, - CraftName = b.Name, - CraftstepId = a.Id, - DeviceProductFunctionId = c.Id, - DeviceProductFunctionName = c.Name, - CraftstepParms = a.Params, - Status = RecipeStatus.等待执行, - Step = a.Step, - WorkId = input.WorkId - }) - .ToListAsync(); + List ccc = new(); + foreach (var item in deviceList) + { + var craftsteplist = await _dbContext.Queryable() + .LeftJoin((a, b) => a.DeviceProductFunctionId == b.Id) + .Where((a, b) => a.FinalId == finainfo.Id) + .Where((a, b) => a.DeviceId == item.DeviceId) + .Select((a, b) => new WorkInfoCraftstepRecordEntity + { + FinalId = a.FinalId, + CraftName = b.Name, + CraftstepId = a.Id, + DeviceProductFunctionId = b.Id, + DeviceProductFunctionName = b.Name, + CraftstepParms = a.Params, + Status = RecipeStatus.等待执行, + Step = a.Step, + WorkId = input.WorkId + }) + .ToListAsync(); + ccc.AddRange(craftsteplist); + } + List newmateriallist = new(); List newcraftslist = new(); for (int i = 1; i <= Convert.ToInt32(workentity.Number); i++) @@ -487,6 +368,7 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services { PotNum = i.ToString(), MaterialId = item.MaterialId, + MaterialCode = item.MaterialCode, MaterialName = item.MaterialName, MaterialStatus = item.MaterialStatus, WorkId = item.WorkId, @@ -497,11 +379,11 @@ namespace BPA.MES.Base.Application.Services.WorkInfoService.Services }; newmateriallist.Add(itementity); } - foreach (var item in craftsteplist) + foreach (var item in ccc) { WorkInfoCraftstepRecordEntity itementity = new() { - CraftId = item.CraftId, + FinalId = item.FinalId, CraftName = item.CraftName, CraftstepId = item.CraftstepId, DeviceProductFunctionId = item.DeviceProductFunctionId,