From c368e24d9e2750bb1fa28775aa83dc6c7fa98025 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 13 Jun 2024 14:39:52 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E6=B3=A8=E5=A1=91=E5=AE=9A=E7=82=B9?= =?UTF-8?q?=E9=85=8D=E9=80=81=E6=8D=A2=E6=88=90=E5=B7=A6=E5=8F=B3=E8=BD=AE?= =?UTF-8?q?=E7=9D=80=E6=9D=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs index 7bb42985..3dc77241 100644 --- a/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/TimeWorkService.cs @@ -267,6 +267,18 @@ namespace Tnb.ProductionMgr bool? cs01 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS01"); bool? cs03 = await _redisData.TryGetValueByKeyField("YTCS", "AllowAgvEmptyOut_CS03"); string startLocationCode = cs01==true ? "ZSSSXCTU01" : cs03==true ? "ZSSSXCTU02" : ""; + if (cs01==true && cs03==true) + { + string last_fixed_point_delivery = _redisData.Exists("last_fixed_point_delivery") ? _redisData.Get("last_fixed_point_delivery") : ""; + if (string.IsNullOrEmpty(last_fixed_point_delivery)) + { + startLocationCode = "ZSSSXCTU01"; + } + else + { + startLocationCode = "ZSSSXCTU01ZSSSXCTU02".Replace(last_fixed_point_delivery, ""); + } + } if (startLocationCode.IsEmpty()) { Log.Error($"输送线无空载具"); @@ -289,6 +301,7 @@ namespace Tnb.ProductionMgr msg += $"{equipment.name}注塑定点配送成功,"; Log.Information($"【FixedPointDelivery】{equipment.name}注塑定点配送成功"); _redisData.Set($"{eqpDaq.equip_code}_{eqpDaq.label_name}_flag", true, TimeSpan.FromMinutes(20)); + _redisData.Set($"last_fixed_point_delivery", startLocationCode); } else { From c5a7e672b644caa0aeef934042e3b7978700a05f Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 13 Jun 2024 17:18:38 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E7=89=A9=E6=96=99=E8=A7=84=E6=A0=BC?= =?UTF-8?q?=E5=9E=8B=E5=8F=B7=E6=94=B9=E6=88=90material=5Fspecification?= =?UTF-8?q?=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/BasMaterial.cs | 2 +- BasicData/Tnb.BasicData/BasMaterialService.cs | 4 +-- BasicData/Tnb.BasicData/BasMbomService.cs | 2 +- .../Tnb.ProductionMgr/PrdFeedingService.cs | 2 +- .../Tnb.ProductionMgr/PrdMoService.cs | 10 +++--- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 36 ++++++++++--------- .../Tnb.ProductionMgr/PrdPackReportService.cs | 2 +- 7 files changed, 30 insertions(+), 28 deletions(-) diff --git a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs index f71010bd..43b5a8a5 100644 --- a/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs +++ b/BasicData/Tnb.BasicData.Entities/Entity/BasMaterial.cs @@ -112,7 +112,7 @@ public partial class BasMaterial : BaseEntity /// /// 物料规格型号 /// - public string? material_standard { get; set; } + // public string? material_standard { get; set; } /// /// 海关编码 diff --git a/BasicData/Tnb.BasicData/BasMaterialService.cs b/BasicData/Tnb.BasicData/BasMaterialService.cs index 386096b8..fcaae107 100644 --- a/BasicData/Tnb.BasicData/BasMaterialService.cs +++ b/BasicData/Tnb.BasicData/BasMaterialService.cs @@ -207,8 +207,8 @@ namespace Tnb.BasicData .Where(x => x.state == "1") .WhereIF(queryJson != null && queryJson.ContainsKey("name"), x => x.name.Contains(queryJson!["name"])) .WhereIF(queryJson != null && queryJson.ContainsKey("code"), x => x.code.Contains(queryJson!["code"])) - .WhereIF(queryJson != null && queryJson.ContainsKey("material_standard"), - x => x.material_standard!.Contains(queryJson!["material_standard"])) + .WhereIF(queryJson != null && queryJson.ContainsKey("material_specification"), + x => x.material_specification!.Contains(queryJson!["material_specification"])) .Select(x => x); List> list = new(); diff --git a/BasicData/Tnb.BasicData/BasMbomService.cs b/BasicData/Tnb.BasicData/BasMbomService.cs index 57e5fe01..f748f7ec 100644 --- a/BasicData/Tnb.BasicData/BasMbomService.cs +++ b/BasicData/Tnb.BasicData/BasMbomService.cs @@ -227,7 +227,7 @@ namespace Tnb.BasicData material_id = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.id), material_code = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.code), material_name = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.name), - material_standard = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.material_standard), + material_standard = SqlFunc.Subqueryable().Where(it => it.id == e.material_id).Select(it => it.material_specification), num = e.num, ordinal = d.ordinal, }) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs index d437363a..0cd621b9 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdFeedingService.cs @@ -152,7 +152,7 @@ namespace Tnb.ProductionMgr eqp_code = (await db.Queryable().FirstAsync(it => it.id == input.equip_id))?.code!, mold_code = "", item_code = material?.code!, - item_standard = material?.material_standard!, + item_standard = material?.material_specification!, status = "生产投料", operator_name = _userManager.RealName, create_id = _userManager.UserId, diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs index 484b2e6b..eb673953 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoService.cs @@ -518,7 +518,7 @@ namespace Tnb.ProductionMgr type = (a.mo_type == DictConst.PrdMoTypeZS || a.mo_type == DictConst.PrdMoTypeJC) ? 1 : 2, material_code = b.code, material_name = b.name, - material_standard = b.material_standard, + material_standard = b.material_specification, act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS), act_end_date = a.act_end_date == null ? "" : a.act_end_date.Value.ToString(DbTimeFormat.SS) }).ToPagedListAsync(input.currentPage, input.pageSize); @@ -560,7 +560,7 @@ namespace Tnb.ProductionMgr material_id = a.material_id, material_code = b.code, material_name = b.name, - material_standard = b.material_standard, + material_standard = b.material_specification, act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS), act_end_date = a.act_end_date == null ? "" : a.act_end_date.Value.ToString(DbTimeFormat.SS), workshop_name = e.FullName, @@ -582,7 +582,7 @@ namespace Tnb.ProductionMgr material_id = a.material_id, material_code = b.code, material_name = b.name, - material_standard = b.material_standard, + material_standard = b.material_specification, act_start_date = a.act_start_date == null ? "" : a.act_start_date.Value.ToString(DbTimeFormat.SS), act_end_date = a.act_end_date == null ? "" : a.act_end_date.Value.ToString(DbTimeFormat.SS), workline_name = c.FullName, @@ -994,7 +994,7 @@ namespace Tnb.ProductionMgr .LeftJoin((a, b) => a.id == b.material_receipt_detail_id) .Where((a, b) => a.barcode == barcode).SumAsync((a, b) => b.num); output.list[0].material_name = basMaterial.name; - output.list[0].material_standard = basMaterial.material_standard; + output.list[0].material_standard = basMaterial.material_specification; output.list[0].supplier_name = basSupplier?.supplier_name ?? ""; output.list[0].unit_name = unit?.FullName ?? ""; @@ -1031,7 +1031,7 @@ namespace Tnb.ProductionMgr mo_code = b.mo_code, material_code = c.code, material_name = c.name, - material_standard = c.material_standard, + material_standard = c.material_specification, children = SqlFunc.Subqueryable() .LeftJoin((x, y) => x.feeding_id == y.id) .LeftJoin((x, y, z) => y.create_id == z.Id) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index b6f0b0d0..7a791359 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -579,7 +579,7 @@ namespace Tnb.ProductionMgr mo_code = a.mo_code, material_code = b.code, material_name = b.name, - material_standard = b.material_standard, + material_standard = b.material_specification, mo_type = c.FullName, mo_status = d.FullName, plan_qty = a.plan_qty.Value.ToString(), @@ -615,7 +615,7 @@ namespace Tnb.ProductionMgr mo_code = h.mo_code, material_code = i.code, material_name = i.name, - material_standard = i.material_standard, + material_standard = i.material_specification, mo_type = j.FullName, mo_status = k.FullName, plan_qty = h.plan_qty.Value.ToString(), @@ -778,7 +778,7 @@ namespace Tnb.ProductionMgr eqp_code = (await db.Queryable().FirstAsync(it => it.id == input.eqp_id))?.code!, mold_code = (await db.Queryable().FirstAsync(it => it.id == input.mold_id))?.mold_code!, item_code = material?.code!, - item_standard = material?.material_standard!, + item_standard = material?.material_specification!, status = DictConst.ToBeScheduledEncode, operator_name = _userManager.RealName, create_id = _userManager.UserId, @@ -894,7 +894,7 @@ namespace Tnb.ProductionMgr id = SnowflakeIdHelper.NextId(), mo_code = (await _db.Queryable().FirstAsync(it => it.id == input.mo_id))?.mo_code!, item_code = material_h?.code!, - item_standard = material_h?.material_standard!, + item_standard = material_h?.material_specification!, status = DictConst.ToBeScheduledEncode, operator_name = _userManager.RealName, create_id = _userManager.UserId, @@ -1019,7 +1019,7 @@ namespace Tnb.ProductionMgr subTaskLog.id = SnowflakeIdHelper.NextId(); subTaskLog.mo_code = (await _db.Queryable().FirstAsync(it => it.id == input.mo_id))?.mo_code!; subTaskLog.item_code = subMaterial?.code!; - subTaskLog.item_standard = subMaterial?.material_standard!; + subTaskLog.item_standard = subMaterial?.material_specification!; subTaskLog.status = DictConst.ToBeScheduledEncode; subTaskLog.operator_name = _userManager.RealName; subTaskLog.create_id = _userManager.UserId; @@ -1159,13 +1159,13 @@ namespace Tnb.ProductionMgr throw Oops.Bah("已开始的不能再开始"); } - if (item.schedule_type == 2) - { - if (await db.Queryable().AnyAsync(x => x.workstation_id == item.workstation_id && x.mo_task_status == DictConst.InProgressEnCode && x.id != item.id)) + // if (item.schedule_type == 2) + // { + if (await db.Queryable().AnyAsync(x => x.workline_id == item.workline_id && x.mo_task_status == DictConst.InProgressEnCode && x.id != item.id)) { - throw Oops.Bah("该工位已有生产中的任务单"); + throw Oops.Bah("该产线已有生产中的任务单"); } - } + // } if (item.mo_task_status is not DictConst.ToBeStartedEnCode and not DictConst.MoStatusPauseCode) { @@ -1283,7 +1283,7 @@ namespace Tnb.ProductionMgr { BasMaterial? material = await db.Queryable().FirstAsync(it => it.id == taskItem.material_id); taskLog.item_code = material?.code!; - taskLog.item_standard = material?.material_standard!; + taskLog.item_standard = material?.material_specification!; } taskLog.operator_name = _userManager.RealName; taskLog.status = status; @@ -1410,7 +1410,7 @@ namespace Tnb.ProductionMgr PrdMoTask parent = await _db.Queryable().SingleAsync(x => x.id == item.parent_id); BasMaterial basMaterial = await _db.Queryable().SingleAsync(x=>x.id==parent.material_id); - string code = $"(01){basMaterial.di ?? ""}(11){DateTime.Now.ToString("yyMMdd")}(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}(10){parent.batch??""}#{basMaterial.material_standard}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}"; + string code = $"(01){basMaterial.di ?? ""}(11){DateTime.Now.ToString("yyMMdd")}(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}(10){parent.batch??""}#{basMaterial.material_specification}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}"; Dictionary dicCommand1 = new(StringComparer.OrdinalIgnoreCase) { ["DevName"] = "外包装箱码垛线", @@ -1907,6 +1907,7 @@ namespace Tnb.ProductionMgr bindCarryCodeInput.location_code = location.location_code; bindCarryCodeInput.code_batch = prdMoTask.batch; + Log.Information($"载具绑定参数:${JsonConvert.SerializeObject(bindCarryCodeInput)}"); Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result1 = await _wmsCarryService.BindCarryMaterial(bindCarryCodeInput); if (result1.code != HttpStatusCode.OK) { @@ -1918,7 +1919,7 @@ namespace Tnb.ProductionMgr wmsPrdInstockInput.material_id = prdMoTask.material_id; wmsPrdInstockInput.material_code = prdMoTask.material_code; wmsPrdInstockInput.material_name = basMaterial.name; - wmsPrdInstockInput.material_spec = basMaterial.material_standard; + wmsPrdInstockInput.material_spec = basMaterial.material_specification; wmsPrdInstockInput.planqty = prdMoTask.scheduled_qty.Value; wmsPrdInstockInput.pqty = input.reported_qty; wmsPrdInstockInput.rqty = 0; @@ -1943,6 +1944,7 @@ namespace Tnb.ProductionMgr carry_id = wmsCarryH.id, }); + Log.Information($"生产入库参数:${JsonConvert.SerializeObject(wmsPrdInstockInput)}"); Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsPrdInstockHService.PrdInstock(wmsPrdInstockInput); if (result2 != null) { @@ -2523,7 +2525,7 @@ namespace Tnb.ProductionMgr eqp_code = (await db.Queryable().FirstAsync(it => it.id == input.equip_id))?.code!, mold_code = "", item_code = material?.code!, - item_standard = material?.material_standard!, + item_standard = material?.material_specification!, status = "更换机台", operator_name = _userManager.RealName, create_id = _userManager.UserId, @@ -2570,7 +2572,7 @@ namespace Tnb.ProductionMgr eqp_code = "", mold_code = mold?.mold_code, item_code = material?.code!, - item_standard = material?.material_standard!, + item_standard = material?.material_specification!, status = "更换模具", operator_name = _userManager.RealName, create_id = _userManager.UserId, @@ -2617,7 +2619,7 @@ namespace Tnb.ProductionMgr eqp_code = "", mold_code = "", item_code = material?.code!, - item_standard = material?.material_standard!, + item_standard = material?.material_specification!, status = "更换产线", operator_name = _userManager.RealName, create_id = _userManager.UserId, @@ -3226,7 +3228,7 @@ namespace Tnb.ProductionMgr 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 ?? ""}*(11){DateTime.Now.ToString("yyMMdd")}*(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}*(10){parent.batch??""}#{basMaterial.material_standard}*{parent.batch??""}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}"; + string code = $"(01){basMaterial.di ?? ""}*(11){DateTime.Now.ToString("yyMMdd")}*(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}*(10){parent.batch??""}#{basMaterial.material_specification}*{parent.batch??""}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}"; return code; } } diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs index df260d9a..83e79e43 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdPackReportService.cs @@ -436,7 +436,7 @@ namespace Tnb.ProductionMgr material_id = a.material_id, material_code = b.code, material_name = b.name, - material_standard = b.material_standard, + material_standard = b.material_specification, container_no = b.container_no, di = b.di, workline_id = a.workline_id, From 726aea8912c42e820de4548e598de658c88aaea4 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Thu, 13 Jun 2024 17:19:24 +0800 Subject: [PATCH 3/5] =?UTF-8?q?erp=E7=94=9F=E4=BA=A7=E5=B7=A5=E5=8D=95?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/CodeTemplateConst.cs | 5 ++ .../Consts/DictConst.cs | 4 + .../Tnb.ProductionMgr/MesForErpService.cs | 80 +++++++++++++++++++ 3 files changed, 89 insertions(+) create mode 100644 ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs diff --git a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs index a758ff30..59b761da 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/CodeTemplateConst.cs @@ -44,6 +44,11 @@ namespace Tnb.BasicData /// 生产入库单 /// public const string PRDINSTOCK_CODE = "PrdInStock"; + + /// + /// 生产工单 + /// + public const string PROMO_CODE = "ProMoCode"; } diff --git a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs index c2e5a7df..ba022ebb 100644 --- a/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs +++ b/BasicData/Tnb.BasicData.Entities/Consts/DictConst.cs @@ -70,6 +70,10 @@ public static class DictConst /// public const string AlreadyId = "26033187948309"; /// + /// 工单状态-待下发Id + /// + public const string ToBeScheduledId = "25019228116501"; + /// /// 工单状态-已下发Id /// public const string ScheduledId = "25019232867093"; diff --git a/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs new file mode 100644 index 00000000..96236403 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr/MesForErpService.cs @@ -0,0 +1,80 @@ +using JNPF.Common.Core.Manager; +using JNPF.Common.Extension; +using JNPF.Common.Security; +using JNPF.DependencyInjection; +using JNPF.DynamicApiController; +using JNPF.FriendlyException; +using JNPF.Message.Service; +using JNPF.Systems.Interfaces.System; +using JNPF.TaskScheduler; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Mvc; +using SqlSugar; +using Tnb.BasicData; +using Tnb.BasicData.Entities; +using Tnb.ProductionMgr.Entities; +using Tnb.WarehouseMgr.Entities.Consts; + +namespace Tnb.ProductionMgr +{ + [ApiDescriptionSettings(Tag = ModuleConst.Tag, Area = ModuleConst.Area, Order = 700)] + [Route("api/[area]/[controller]/[action]")] + public class MesForErpService: IDynamicApiController, ITransient + { + private readonly ISqlSugarClient _db; + private readonly IUserManager _userManager; + private readonly IBillRullService _billRuleService; + + public MesForErpService(ISqlSugarRepository repository, + IBillRullService billRuleService, + IUserManager userManager) + { + _userManager = userManager; + _billRuleService = billRuleService; + _db = repository.AsSugarClient(); + } + + [HttpPost] + [AllowAnonymous] + public async Task SavePrdMo(PrdMo input) + { + if (input == null) + throw Oops.Bah("参数不能为空"); + if(string.IsNullOrEmpty(input.mo_code)) + throw Oops.Bah("工单代码不能为空"); + if(string.IsNullOrEmpty(input.mo_type)) + throw Oops.Bah("工单类型不能为空"); + if(input.plan_start_date==null) + throw Oops.Bah("计划开始日期不能为空"); + if(input.plan_end_date==null) + throw Oops.Bah("计划结束日期不能为空"); + if(string.IsNullOrEmpty(input.material_code)) + throw Oops.Bah("物料编号不能为空"); + if(string.IsNullOrEmpty(input.unit_id)) + throw Oops.Bah("单位不能为空"); + if(input.plan_qty==null || input.plan_qty<=0) + throw Oops.Bah("计划数量不能为空"); + + BasMaterial basMaterial = await _db.Queryable().SingleAsync(x => x.code == input.material_code); + if(basMaterial==null) + throw Oops.Bah($"未找到物料编号为{input.material_code}的物料"); + + List basMaterialUnits = await _db.Queryable().Where(x => x.material_id == basMaterial.id).ToListAsync(); + List units = basMaterialUnits.Select(x => x.auxiliary_unit_id).Distinct().ToList(); + if(units!=null && !string.IsNullOrEmpty(basMaterial.unit_id)) units.Add(basMaterial.unit_id); + + if(!units.Contains(input.unit_id)) + throw Oops.Bah($"{basMaterial.name}不存在{input.unit_id}该单位"); + + input.id = SnowflakeIdHelper.NextId(); + input.mo_source = "1"; + input.mo_code = input.mo_code; + input.create_id = WmsWareHouseConst.AdministratorUserId; + input.create_time = DateTime.Now; + input.mo_status = DictConst.ToBeScheduledId; + await _db.Insertable(input).ExecuteCommandAsync(); + return "true"; + + } + } +} \ No newline at end of file From ab0b4bedf45dd2170e3056c8609f7cdb6454418e Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 14 Jun 2024 09:28:52 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=96=B7=E7=A0=81=E8=B4=B4=E6=A0=87?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=89=B9=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/LableRecord.cs | 16 +++ .../Tnb.ProductionMgr/PrdMoTaskService.cs | 109 ++++++++++++------ 2 files changed, 90 insertions(+), 35 deletions(-) create mode 100644 ProductionMgr/Tnb.ProductionMgr.Entities/Entity/LableRecord.cs diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/LableRecord.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/LableRecord.cs new file mode 100644 index 00000000..c4b4e4e8 --- /dev/null +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/LableRecord.cs @@ -0,0 +1,16 @@ +using JNPF.Common.Contracts; +using JNPF.Common.Security; +using SqlSugar; + +namespace Tnb.ProductionMgr.Entities +{ + [SugarTable("label_record")] + public class LableRecord : BaseEntity + { + public string last_day { get; set; } + + public int num { get; set; } + + + } +} diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index 7a791359..a3bd7c94 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -3039,19 +3039,14 @@ namespace Tnb.ProductionMgr throw Oops.Bah("产线错误"); } - PrdMoTask? prdMoTask = await _db.Queryable().Where(x => x.workline_id == workline_id && x.parent_id == null && x.mo_task_status == DictConst.InProgressEnCode).FirstAsync(); - PrdMoTask? childPrdMoTask = null; + PrdMoTask? prdMoTask = await _db.Queryable().Where(x => x.workline_id == workline_id && x.mo_task_status == DictConst.InProgressEnCode && x.parent_id == null).FirstAsync(); if (prdMoTask != null) { - childPrdMoTask = await _db.Queryable().Where(x => x.parent_id == prdMoTask.id && x.mo_task_status == DictConst.InProgressEnCode).FirstAsync(); - if (childPrdMoTask != null) - { - BasMaterial basMaterial = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id); - childPrdMoTask.material_name = basMaterial.name; - } + BasMaterial basMaterial = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id); + prdMoTask.material_name = basMaterial.name; } - return childPrdMoTask; + return prdMoTask; } /// @@ -3201,34 +3196,78 @@ namespace Tnb.ProductionMgr }); if (prdMoTask == null) throw Oops.Bah("没找到对应任务单"); - 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()) - { - 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 - { - BasMaterial bm = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id); - PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel() - { - is_mark = null, - is_label = 0, - mo_task_code = prdMoTask.mo_task_code, - material_code = bm.code, - create_time = DateTime.Now, - }; - - await _db.Insertable(prdOutPackMarkLabel).ExecuteCommandAsync(); - } + // 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()) + // { + // 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 + // { + // BasMaterial bm = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.material_id); + // PrdOutPackMarkLabel prdOutPackMarkLabel = new PrdOutPackMarkLabel() + // { + // is_mark = null, + // is_label = 0, + // mo_task_code = prdMoTask.mo_task_code, + // material_code = bm.code, + // create_time = DateTime.Now, + // }; + // + // 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); + //PrdMoTask parent = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.parent_id); + BasMaterial basMaterial = await _db.Queryable().SingleAsync(x=>x.id==prdMoTask.material_id); + PrdMo mo = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id); + string batch = ""; + if (mo.mo_type == DictConst.PrdMoTypeZS) + { + EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); + batch = $"{equipment.code}{DateTime.Now.ToString("yyMMdd")}"; + }else if (mo.mo_type == DictConst.PrdMoTypeJC) + { + EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); + ToolMolds toolMolds = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mold_id); + batch = $"{toolMolds.mold_code}{equipment.code}{DateTime.Now.ToString("yyMMdd")}"; + }else + { + LableRecord lableRecord = await _db.Queryable().FirstAsync(); + if (lableRecord == null) + { + batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}"; + await _db.Insertable(new LableRecord() + { + id = SnowflakeIdHelper.NextId(), + last_day = DateTime.Now.ToString("yyyyMMdd"), + num = 1 + }).ExecuteCommandAsync(); + } + else + { + int num = 1; + if(DateTime.Now.ToString("yyyyMMdd") == lableRecord.last_day) + { + num = lableRecord.num+1; + batch = $"{DateTime.Now.ToString("yyMMdd")}5{(lableRecord.num+1).ToString().PadLeft(3,'0')}"; + } + else + { + batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}"; + } - string code = $"(01){basMaterial.di ?? ""}*(11){DateTime.Now.ToString("yyMMdd")}*(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}*(10){parent.batch??""}#{basMaterial.material_specification}*{parent.batch??""}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}"; + await _db.Updateable() + .SetColumns(x=>x.last_day==DateTime.Now.ToString("yyyyMMdd")) + .SetColumns(x=>x.num==num) + .Where(x=>x.id==lableRecord.id) + .ExecuteCommandAsync(); + } + } + + string code = $"(01){basMaterial.di ?? ""}*(11){DateTime.Now.ToString("yyMMdd")}*(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}*(10){batch}#{basMaterial.material_specification}*{batch}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}"; return code; } } From c0d05ef133d72c7d839167c551c4721bae592172 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Fri, 14 Jun 2024 11:51:37 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E6=89=B9=E6=AC=A1=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Tnb.ProductionMgr/PrdMoTaskService.cs | 88 ++++++++++++------- 1 file changed, 54 insertions(+), 34 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs index a3bd7c94..c157d61e 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMoTaskService.cs @@ -1664,12 +1664,30 @@ namespace Tnb.ProductionMgr location = await db.Queryable().SingleAsync(x=>x.id==equip.downmat_location_id); report.location_code = location.location_code; } + + string batch = ""; + + PrdMo mo = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mo_id); + if (mo.mo_type == DictConst.PrdMoTypeZS) + { + EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); + batch = $"{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}"; + }else if (mo.mo_type == DictConst.PrdMoTypeJC) + { + EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); + ToolMolds toolMolds = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mold_id); + batch = $"{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 2, 2)}{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}"; + }else + { + OrganizeEntity organizeEntity = await _db.Queryable().SingleAsync(x => x.Id == prdMoTask.workline_id); + batch = $"{organizeEntity.EnCode.Substring(organizeEntity.EnCode.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}"; + } // report.location_code = input.location_code; report.create_id = _userManager.UserId; report.create_time = DateTime.Now; - // report.batch = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(); + report.batch = batch; report.barcode = input.mo_task_code + DateTimeOffset.Now.ToUnixTimeSeconds().ToString(); report.barqty = mbom.full_qty; // report.barcode = input.mo_task_code+"0001"; @@ -1938,7 +1956,7 @@ namespace Tnb.ProductionMgr { planqty = prdMoTask.scheduled_qty.Value, pqty = input.reported_qty, - code_batch = prdMoTask.batch, + code_batch = batch, code = report.barcode, unit_id = prdMoTask.unit_id, carry_id = wmsCarryH.id, @@ -3227,44 +3245,46 @@ namespace Tnb.ProductionMgr if (mo.mo_type == DictConst.PrdMoTypeZS) { EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); - batch = $"{equipment.code}{DateTime.Now.ToString("yyMMdd")}"; + batch = $"{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}"; }else if (mo.mo_type == DictConst.PrdMoTypeJC) { EqpEquipment equipment = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.eqp_id); ToolMolds toolMolds = await _db.Queryable().SingleAsync(x => x.id == prdMoTask.mold_id); - batch = $"{toolMolds.mold_code}{equipment.code}{DateTime.Now.ToString("yyMMdd")}"; + batch = $"{toolMolds.mold_code.Substring(toolMolds.mold_code.Length - 2, 2)}{equipment.code.Substring(equipment.code.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}"; }else { - LableRecord lableRecord = await _db.Queryable().FirstAsync(); - if (lableRecord == null) - { - batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}"; - await _db.Insertable(new LableRecord() - { - id = SnowflakeIdHelper.NextId(), - last_day = DateTime.Now.ToString("yyyyMMdd"), - num = 1 - }).ExecuteCommandAsync(); - } - else - { - int num = 1; - if(DateTime.Now.ToString("yyyyMMdd") == lableRecord.last_day) - { - num = lableRecord.num+1; - batch = $"{DateTime.Now.ToString("yyMMdd")}5{(lableRecord.num+1).ToString().PadLeft(3,'0')}"; - } - else - { - batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}"; - } - - await _db.Updateable() - .SetColumns(x=>x.last_day==DateTime.Now.ToString("yyyyMMdd")) - .SetColumns(x=>x.num==num) - .Where(x=>x.id==lableRecord.id) - .ExecuteCommandAsync(); - } + // LableRecord lableRecord = await _db.Queryable().FirstAsync(); + // if (lableRecord == null) + // { + // batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}"; + // await _db.Insertable(new LableRecord() + // { + // id = SnowflakeIdHelper.NextId(), + // last_day = DateTime.Now.ToString("yyyyMMdd"), + // num = 1 + // }).ExecuteCommandAsync(); + // } + // else + // { + // int num = 1; + // if(DateTime.Now.ToString("yyyyMMdd") == lableRecord.last_day) + // { + // num = lableRecord.num+1; + // batch = $"{DateTime.Now.ToString("yyMMdd")}5{(lableRecord.num+1).ToString().PadLeft(3,'0')}"; + // } + // else + // { + // batch = $"{DateTime.Now.ToString("yyMMdd")}5{"1".PadLeft(3,'0')}"; + // } + // + // await _db.Updateable() + // .SetColumns(x=>x.last_day==DateTime.Now.ToString("yyyyMMdd")) + // .SetColumns(x=>x.num==num) + // .Where(x=>x.id==lableRecord.id) + // .ExecuteCommandAsync(); + // } + OrganizeEntity organizeEntity = await _db.Queryable().SingleAsync(x => x.Id == prdMoTask.workline_id); + batch = $"{organizeEntity.EnCode.Substring(organizeEntity.EnCode.Length - 2, 2)}{DateTime.Now.ToString("yyMMdd")}"; } string code = $"(01){basMaterial.di ?? ""}*(11){DateTime.Now.ToString("yyMMdd")}*(17){DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyMMdd")}*(10){batch}#{basMaterial.material_specification}*{batch}*{DateTime.Now.ToString("yyyyMMdd")}*{DateTime.Now.AddMonths(basMaterial.quality_guarantee_period ?? 0).ToString("yyyyMMdd")}*{basMaterial.container_no}";