From c2e9499719f7945f1e13032ca7b5ec68fa00ac5d Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 27 Jun 2024 17:51:18 +0800 Subject: [PATCH 1/6] =?UTF-8?q?pda=E4=BB=BB=E5=8A=A1=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index d33d96b1..3ab705ec 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -427,7 +427,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg") .LeftJoin((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_name.Contains("允许称重"))//注塑空满箱请求 // .Where((a, b) => a.workstation_id == input.stationId) - .Where((a, b) => a.worker_id == _userManager.UserId) + .Where((a, b) => a.worker_id == _userManager.UserId && (a.schedule_type==1 || a.schedule_type==2 && a.parent_id==null)) .WhereIF(!string.IsNullOrEmpty(mo_task_code), a => a.mo_task_code.Contains(mo_task_code)) //.WhereIF(!string.IsNullOrEmpty(mo_task_status),a=>a.mo_task_status==mo_task_status) .WhereIF(statusList.Count > 0, a => statusList.Contains(a.mo_task_status)) From d2596984c816c4de64aafe4f7a6c81fb5967c7a5 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 27 Jun 2024 17:52:29 +0800 Subject: [PATCH 2/6] =?UTF-8?q?pda=E4=BB=BB=E5=8A=A1=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 3ab705ec..16099116 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -427,7 +427,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg") .LeftJoin((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_name.Contains("允许称重"))//注塑空满箱请求 // .Where((a, b) => a.workstation_id == input.stationId) - .Where((a, b) => a.worker_id == _userManager.UserId && (a.schedule_type==1 || a.schedule_type==2 && a.parent_id==null)) + .Where((a, b) => a.worker_id == _userManager.UserId && (a.schedule_type==1 || (a.schedule_type==2 && a.parent_id==null))) .WhereIF(!string.IsNullOrEmpty(mo_task_code), a => a.mo_task_code.Contains(mo_task_code)) //.WhereIF(!string.IsNullOrEmpty(mo_task_status),a=>a.mo_task_status==mo_task_status) .WhereIF(statusList.Count > 0, a => statusList.Contains(a.mo_task_status)) From 42b3352c38ce5e8dfa8980a001d6e8ea85cd987a Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 27 Jun 2024 17:53:06 +0800 Subject: [PATCH 3/6] =?UTF-8?q?pda=E4=BB=BB=E5=8A=A1=E5=8D=95=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 16099116..aceff700 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -427,7 +427,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d, e, f, g, h, i, j, k) => a.material_id == k.material_id && k.auxiliary_unit_id == "kg") .LeftJoin((a, b, c, d, e, f, g, h, i, j, k, l) => a.eqp_id == l.equip_id && l.enabled == 1 && l.label_name.Contains("允许称重"))//注塑空满箱请求 // .Where((a, b) => a.workstation_id == input.stationId) - .Where((a, b) => a.worker_id == _userManager.UserId && (a.schedule_type==1 || (a.schedule_type==2 && a.parent_id==null))) + .Where((a, b) => a.worker_id == _userManager.UserId && (a.schedule_type==1 || (a.schedule_type==2 && a.parent_id!=null))) .WhereIF(!string.IsNullOrEmpty(mo_task_code), a => a.mo_task_code.Contains(mo_task_code)) //.WhereIF(!string.IsNullOrEmpty(mo_task_status),a=>a.mo_task_status==mo_task_status) .WhereIF(statusList.Count > 0, a => statusList.Contains(a.mo_task_status)) From df0be4e15d7bada7d3e31ae20f141411e1eaaa41 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 27 Jun 2024 18:03:07 +0800 Subject: [PATCH 4/6] =?UTF-8?q?=E7=BB=84=E8=A3=85=E4=B8=8B=E5=8F=91?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E4=BC=A0=E5=91=98=E5=B7=A5=E5=B7=A5=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dto/PrdManage/PackSechelToBeIssueListOutput.cs | 1 + ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs index 1f63fced..1cce769e 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Dto/PrdManage/PackSechelToBeIssueListOutput.cs @@ -82,6 +82,7 @@ public string create_time { get; set; } public string workstation_name { get; set; } + public string worker_name { get; set; } } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index bae05527..159ef8b9 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -432,8 +432,9 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b, c, d) => a.mo_id == d.id) .LeftJoin((a, b, c, d, e) => a.process_id == e.id) .LeftJoin((a, b,c,d,e,f) => a.workstation_id == f.Id) + .LeftJoin((a, b,c,d,e,f,g)=>a.worker_id==g.Id) .Where((a, b, c, d) => a.parent_id == mo_task_id) - .Select((a, b, c, d, e,f) => new PackSechelToBeIssueListOutput + .Select((a, b, c, d, e,f,g) => new PackSechelToBeIssueListOutput { mo_task_id = a.id, mo_task_code = a.mo_task_code, @@ -443,6 +444,7 @@ namespace Tnb.ProductionMgr workline_name = c.FullName, mo_task_status = a.mo_task_status, workstation_name = f.FullName, + worker_name = g.RealName, scheduled_qty = a.scheduled_qty, plan_qty = d.plan_qty, process_task_qty = a.process_task_qty, 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 5/6] =?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] From 9ebb37033c7408aa6660055a7f9278433043d89c Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 28 Jun 2024 11:15:17 +0800 Subject: [PATCH 6/6] bug --- .../Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs index b1faedd6..c4830aa1 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptH.cs @@ -94,10 +94,10 @@ public partial class PrdMaterialReceiptH : BaseEntity /// 生产bom工序id /// public string? mbom_process_id { get; set; } - + /// /// 第一次投料 /// - public bool first_feed { get; set; } + public bool first_feed { get; set; } = true; } \ No newline at end of file