From 8a13c5d59399dd236f998be2216c000631917426 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 28 Jun 2024 11:09:03 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=9F=E4=BA=A7=E6=8A=95=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PrdManage/PrdFeedingRecordUpListOutPut.cs | 1 + .../Entity/PrdMaterialReceiptH.cs | 5 + .../PrdFeedingRecordUpServicecs.cs | 4 +- .../Tnb.ProductionMgr/PrdFeedingService.cs | 110 +++++++++++++----- 4 files changed, 93 insertions(+), 27 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdFeedingRecordUpListOutPut.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdFeedingRecordUpListOutPut.cs index f372822a..f2b9032a 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdFeedingRecordUpListOutPut.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PrdFeedingRecordUpListOutPut.cs @@ -19,6 +19,7 @@ namespace Tnb.ProductionMgr.Entities.Dto public string code { get; set; } public string carry_code { get; set; } public string create_id { get; set; } + public string station_id { get; set; } public string create_time { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs index 56783a0a..b1faedd6 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs @@ -94,5 +94,10 @@ public partial class PrdMaterialReceiptH : BaseEntity /// 生产bom工序id /// public string? mbom_process_id { get; set; } + + /// + /// 第一次投料 + /// + public bool first_feed { get; set; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingRecordUpServicecs.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingRecordUpServicecs.cs index fccc8c4a..cb882800 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingRecordUpServicecs.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingRecordUpServicecs.cs @@ -95,12 +95,14 @@ namespace Tnb.ProductionMgr act_start_date = a.act_start_date==null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS), tablefield102 = SqlFunc.Subqueryable() .LeftJoin((x,y)=>x.create_id==y.Id) - .Where(x=>x.mo_task_id==a.id).ToList((x,y)=>new PrdFeedingRecordUpListChildOutPut() + .LeftJoin((x,y,z)=>x.station_id==y.Id) + .Where(x=>x.mo_task_id==a.id).ToList((x,y,z)=>new PrdFeedingRecordUpListChildOutPut() { id = x.id, code = x.code, carry_code = x.carry_code, create_id = y.RealName, + station_id = z.FullName, create_time = x.create_time==null ? "" : x.create_time.Value.ToString(DbTimeFormat.SS), }), diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index f4d88bfd..9dc55371 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -4,6 +4,7 @@ using JNPF.Common.Security; using JNPF.DependencyInjection; using JNPF.DynamicApiController; using JNPF.FriendlyException; +using JNPF.Logging; using JNPF.Systems.Entitys.Permission; using JNPF.Systems.Entitys.System; using JNPF.Systems.Interfaces.System; @@ -365,9 +366,11 @@ namespace Tnb.ProductionMgr PrdFeedingH? prdFeedingH = null; List list = new(); - DbResult result2 = new(); - DbResult result = await db.Ado.UseTranAsync(async () => + + try { + await db.Ado.BeginTranAsync(); + PrdMoTask parentMoTask = await db.Queryable().FirstAsync(x => x.id == moTask.parent_id); string worklineId = moTask.workline_id; if (parentMoTask != null && !string.IsNullOrEmpty(parentMoTask.workline_id)) @@ -402,6 +405,7 @@ namespace Tnb.ProductionMgr org_id = _userManager.GetUserInfo().Result.organizeId }; + PrdMaterialReceiptH prdMaterialReceiptH = null; if (input.details != null && input.details.Count > 0) { foreach (var item in input.details) @@ -413,6 +417,17 @@ namespace Tnb.ProductionMgr PrdMaterialReceiptD? detail = await db.Queryable() .Where(x => x.member_carry_code == input.carry_code && x.is_all_feeding == 0).FirstAsync(); + if (prdMaterialReceiptH == null) + { + prdMaterialReceiptH = await db.Queryable() + .SingleAsync(x => x.id == detail.material_receipt_id); + } + WmsCarryCode wmsCarryCode = await db.Queryable().Where(x=>x.carry_id==carry.id).FirstAsync(); + if (wmsCarryCode == null) + { + throw Oops.Bah($"未找到条码信息,载具id{carry.id}"); + } + decimal num = item.codeqty; list.Add(new PrdFeedingD { @@ -420,34 +435,13 @@ namespace Tnb.ProductionMgr material_receipt_detail_id = detail?.id, material_id = item.material_id, num = num, - batch = item.code_batch, + batch = wmsCarryCode.code_batch, unit_id = item.unit_id, carry_id = carry.id, status = "0", use_num = 0, }); - // Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput() - // { - // org = prdFeedingH.org_id, - // create_id = prdFeedingH.create_id, - // carry_id = prdFeedingH.carry_id, - // carry_code = prdFeedingH.carry_code, - // carrystd_id = carry.carrystd_id, - // membercarry_code = detail.member_carry_code, - // membercarry_id = detail.member_carry_id, - // }); - - Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput() - { - carry_id = detail.member_carry_id - }); - - - if (result.code != JNPF.Common.Enums.HttpStatusCode.OK) - { - throw Oops.Bah(result.msg); - } if (detail != null) { @@ -467,6 +461,32 @@ namespace Tnb.ProductionMgr .SetColumns(x => x.feeding_num == x.feeding_num + num) .Where(x => x.id == detail.id) .ExecuteCommandAsync(); + + if (detail.feeding_num + num < detail.num) + { + await db.Updateable() + .SetColumns(x => x.codeqty == x.codeqty - num) + .Where(x => x.carry_id == detail.member_carry_id) + .ExecuteCommandAsync(); + } + else + { + // await db.Updateable() + // .SetColumns(x => x.codeqty == 0) + // .Where(x => x.carry_id == detail.member_carry_id) + // .ExecuteCommandAsync(); + + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput() + { + carry_id = detail.member_carry_id + }); + + + if (result.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + throw Oops.Bah(result.msg); + } + } } } else @@ -475,6 +495,36 @@ namespace Tnb.ProductionMgr } } + + if (prdMaterialReceiptH.first_feed) + { + List dList = await db.Queryable() + .Where(x => x.material_receipt_id == prdMaterialReceiptH.id).ToListAsync(); + + foreach (var item in dList) + { + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput() + { + org = prdFeedingH.org_id, + create_id = prdFeedingH.create_id, + carry_id = prdFeedingH.carry_id, + carry_code = prdFeedingH.carry_code, + carrystd_id = carry.carrystd_id, + membercarry_code = item.member_carry_code, + membercarry_id = item.member_carry_id, + }); + + if (result2.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + throw Oops.Bah(result2.msg); + } + } + + await db.Updateable() + .SetColumns(x => x.first_feed == true) + .Where(x => x.id == prdMaterialReceiptH.id) + .ExecuteCommandAsync(); + } } else { @@ -484,11 +534,19 @@ namespace Tnb.ProductionMgr _ = await db.Insertable(prdFeedingH).ExecuteCommandAsync(); _ = await db.Insertable(list).ExecuteCommandAsync(); + + await db.Ado.CommitTranAsync(); - }); + } + catch (Exception e) + { + Log.Error(e.Message,e); + await db.Ado.RollbackTranAsync(); + throw Oops.Bah(e.Message); + } - return !result.IsSuccess ? throw Oops.Bah(result.ErrorMessage) : (dynamic)(result.IsSuccess ? "投料成功" : result.ErrorMessage); + return "投料成功"; } [HttpPost]