From 753e24741be1ec243eb211b0ea31869850720aeb Mon Sep 17 00:00:00 2001 From: zhoukeda <1315948824@qq.com> Date: Thu, 9 Nov 2023 16:00:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=96=B7=E7=A0=81=E8=B4=B4?= =?UTF-8?q?=E6=A0=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BasMaterial.cs | 10 +++ .../Entity/PrdMoTask.cs | 5 ++ .../Entity/PrdOutPackMarkLabel.cs | 4 +- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 71 ++++++++++++++----- .../Tnb.ProductionMgr/PrdPackReportService.cs | 14 ++-- 5 files changed, 77 insertions(+), 27 deletions(-) diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs index 847f2e4d..77335163 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs @@ -253,5 +253,15 @@ public partial class BasMaterial : BaseEntity /// 是否创建子工单 /// public string? is_create_sub_work_order { get; set; } + + /// + /// 保质期 + /// + public int? quality_guarantee_period { get; set; } + + /// + /// DI编码 + /// + public string? di { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs index cdeb3123..905d73a0 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMoTask.cs @@ -197,5 +197,10 @@ public partial class PrdMoTask : BaseEntity /// 物料清单id /// public string? ebom_id { get; set; } + + /// + /// 批号 + /// + public string? batch { get; set; } } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutPackMarkLabel.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutPackMarkLabel.cs index 0da7ab0c..8098b7b9 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutPackMarkLabel.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdOutPackMarkLabel.cs @@ -17,12 +17,12 @@ public partial class PrdOutPackMarkLabel : BaseEntity /// /// 是否喷码 0 否 1 是 /// - public int is_mark { get; set; } + public int? is_mark { get; set; } /// /// 是否贴标 0 否 1 是 /// - public int is_label { get; set; } + public int? is_label { get; set; } /// /// 任务单号 diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index aff6e4fe..ad0bbe82 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -2753,18 +2753,35 @@ namespace Tnb.ProductionMgr }); if (prdMoTask == null) throw Oops.Bah("没找到对应任务单"); - PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel() + if (await _db.Queryable().Where(x => + x.mo_task_code == prdMoTask.mo_task_code && x.status == "0" && x.is_label == 0 && x.is_mark==null).AnyAsync()) { - is_mark = 0, - is_label = 0, - mo_task_code = prdMoTask.mo_task_code, - material_code = prdMoTask.material_code, - create_time = DateTime.Now, - }; + await _db.Updateable() + .SetColumns(x => x.is_mark == 0) + .Where(x => x.mo_task_code == prdMoTask.mo_task_code && x.status == "0" && x.is_label == 0 && + x.is_mark == null) + .ExecuteCommandAsync(); + } + else + { + PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel() + { + is_mark = 0, + is_label = null, + mo_task_code = prdMoTask.mo_task_code, + material_code = prdMoTask.material_code, + create_time = DateTime.Now, + }; - await _db.Insertable(prdOutPackMarkLabel).ExecuteCommandAsync(); + await _db.Insertable(prdOutPackMarkLabel).ExecuteCommandAsync(); + } + + PrdMoTask parent = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.parent_id); + BasMaterial basMaterial = await _db.Queryable().SingleAsync(x=>x.id==parent.material_id); + + string code = $"(01){basMaterial.di ?? ""}\\n(11){DateTime.Now.ToString("yyMMdd")}\\n(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}\\n(10){parent.batch??""}"; - return prdMoTask.mo_task_code + "/" + prdMoTask.material_code; + return code; } /// @@ -2781,19 +2798,35 @@ namespace Tnb.ProductionMgr }); if (prdMoTask == null) throw Oops.Bah("没找到对应任务单"); - PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel() + if (await _db.Queryable().Where(x => + x.mo_task_code == prdMoTask.mo_task_code && x.status == "0" && x.is_label == null && x.is_mark==0).AnyAsync()) { - is_mark = 0, - is_label = 0, - mo_task_code = prdMoTask.mo_task_code, - material_code = prdMoTask.material_code, - create_time = DateTime.Now, - station_id = input.station_id, - }; + await _db.Updateable() + .SetColumns(x => x.is_label == 0) + .Where(x => x.mo_task_code == prdMoTask.mo_task_code && x.status == "0" && x.is_label == null && + x.is_mark == 0) + .ExecuteCommandAsync(); + } + else + { + PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel() + { + is_mark = null, + is_label = 0, + mo_task_code = prdMoTask.mo_task_code, + material_code = prdMoTask.material_code, + create_time = DateTime.Now, + }; - await _db.Insertable(prdOutPackMarkLabel).ExecuteCommandAsync(); + await _db.Insertable(prdOutPackMarkLabel).ExecuteCommandAsync(); + } - return prdMoTask.mo_task_code + "/" + prdMoTask.material_code; + PrdMoTask parent = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.parent_id); + BasMaterial basMaterial = await _db.Queryable().SingleAsync(x=>x.id==parent.material_id); + + string code = $"(01){basMaterial.di ?? ""}\\n(11){DateTime.Now.ToString("yyMMdd")}\\n(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}\\n(10){parent.batch??""}"; + + return code; } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index 9ea6e5f3..28c0ada2 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -498,11 +498,12 @@ namespace Tnb.ProductionMgr /// public async Task OutPackMarkCheck(MarkingLabelInput input) { - string[] arr = input.mark_code.Split("/"); + string[] arr = input.mark_code.Split("(10)"); if (arr.Length > 1) { - string mo_task_code = arr[0]; - PrdMoTask prdMoTask = await _db.Queryable().Where(x => x.mo_task_code == mo_task_code).FirstAsync(); + string batch = arr[1]; + PrdMoTask prdMoTask = await _db.Queryable().Where(x => x.batch == batch).FirstAsync(); + string mo_task_code = prdMoTask.mo_task_code; if (prdMoTask == null) throw Oops.Bah("未找到对应任务单"); BasMaterial basMaterial = await _db.Queryable().Where(x => x.id == prdMoTask.material_id).FirstAsync(); DictionaryDataEntity unit = await _db.Queryable() @@ -567,11 +568,12 @@ namespace Tnb.ProductionMgr /// public async Task OutPackLabelCheck(MarkingLabelInput input) { - string[] arr = input.mark_code.Split("/"); + string[] arr = input.label_code.Split("(10)"); if (arr.Length > 1) { - string mo_task_code = arr[0]; - PrdMoTask prdMoTask = await _db.Queryable().Where(x => x.mo_task_code == mo_task_code).FirstAsync(); + string batch = arr[1]; + PrdMoTask prdMoTask = await _db.Queryable().Where(x => x.batch == batch).FirstAsync(); + string mo_task_code = prdMoTask.mo_task_code; if (prdMoTask == null) throw Oops.Bah("未找到对应任务单"); BasMaterial basMaterial = await _db.Queryable().Where(x => x.id == prdMoTask.material_id).FirstAsync(); DictionaryDataEntity unit = await _db.Queryable()