From d0e77bef3ea6248e90d445df137e27ca75bf82c2 Mon Sep 17 00:00:00 2001 From: zhou keda <1315948824@qq.com> Date: Wed, 9 Oct 2024 15:58:38 +0800 Subject: [PATCH] =?UTF-8?q?=E8=87=AA=E5=8A=A8=E7=AD=BE=E6=94=B6=E5=90=8E?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E8=87=AA=E5=8A=A8=E6=8A=95=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Entity/PrdMaterialReceiptD.cs | 2 + .../Tnb.ProductionMgr/ErpInfoService.cs | 1 + .../PrdMaterialReceiptService.cs | 150 +++++++++++++++--- 3 files changed, 135 insertions(+), 18 deletions(-) diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs index a693a3fd..79d9dc49 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/PrdMaterialReceiptD.cs @@ -82,5 +82,7 @@ public partial class PrdMaterialReceiptD : BaseEntity /// 检验结论 /// public string check_conclusion { get; set; } + + public DateTime create_time { get; set; } } \ No newline at end of file diff --git a/ProductionMgr/Tnb.ProductionMgr/ErpInfoService.cs b/ProductionMgr/Tnb.ProductionMgr/ErpInfoService.cs index 900b9f74..87606548 100644 --- a/ProductionMgr/Tnb.ProductionMgr/ErpInfoService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/ErpInfoService.cs @@ -26,6 +26,7 @@ namespace Tnb.ProductionMgr } [HttpPost] + [AllowAnonymous] public async Task GetProjects() { var erpdb = _db.AsTenant().GetConnection("erpdb"); diff --git a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs index 4290dd50..a93695fe 100644 --- a/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs +++ b/ProductionMgr/Tnb.ProductionMgr/PrdMaterialReceiptService.cs @@ -29,6 +29,7 @@ using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Interfaces; using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.BasicData.Interfaces; +using Tnb.WarehouseMgr.Entities.Enums; namespace Tnb.ProductionMgr { @@ -48,6 +49,7 @@ namespace Tnb.ProductionMgr private readonly IPrdMoTaskService _prdMoTaskService; private readonly IWmsCarryQueryService _wmsCarryQueryService; private readonly IBasWorkgroupService _basWorkgroupService; + private readonly IWmsCarryUnbindService _wmsCarryUnbindService; public PrdMaterialReceiptService( ISqlSugarRepository repository, @@ -56,6 +58,7 @@ namespace Tnb.ProductionMgr IPrdMoTaskService prdMoTaskService, IWmsCarryQueryService wmsCarryQueryService, IBasWorkgroupService basWorkgroupService, + IWmsCarryUnbindService wmsCarryUnbindService, IUserManager userManager ) { @@ -66,6 +69,7 @@ namespace Tnb.ProductionMgr _prdMoTaskService = prdMoTaskService; _wmsCarryQueryService = wmsCarryQueryService; _basWorkgroupService = basWorkgroupService; + _wmsCarryUnbindService = wmsCarryUnbindService; } @@ -512,6 +516,7 @@ namespace Tnb.ProductionMgr supplier_id = item.supplier_id, instock_time = item.instock_time, check_conclusion = item.check_conclusion, + create_time = DateTime.Now, }); } } @@ -571,6 +576,13 @@ namespace Tnb.ProductionMgr : !result2.IsSuccess ? throw Oops.Bah(result2.ErrorMessage) : (dynamic)"签收成功"; } + /// + /// 自动签收 + /// + /// + /// + /// + /// public override async Task ModifyAsync(WareHouseUpInput input) { Log.Information($"物料呼叫完成回更参数:{JsonConvert.SerializeObject(input)}"); @@ -590,10 +602,12 @@ namespace Tnb.ProductionMgr { throw Oops.Bah($"未找到来源id为{input.requireId}的生产任务单"); } - string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE); + OrganizeEntity workshop = await _organizeService.GetAnyParentByWorkstationId(moTask.workstation_id, DictConst.RegionCategoryWorkshopCode); List insertHList = new List(); List insertDList = new List(); + List insertFHList = new List(); + List insertFDList = new List(); string orgId = WmsWareHouseConst.AdministratorOrgId; // string userId = moTask.worker_id; string userId = WmsWareHouseConst.AdministratorUserId; @@ -604,7 +618,7 @@ namespace Tnb.ProductionMgr foreach(string carryId in input.carryIds) { WmsCarryH carry = await db.Queryable().SingleAsync(x => x.id == carryId); - + string code = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.MATERIAL_RECEIPT_CODE); PrdMaterialReceiptH prdMaterialReceiptH = new PrdMaterialReceiptH() { code = code, @@ -622,6 +636,26 @@ namespace Tnb.ProductionMgr org_id = orgId }; insertHList.Add(prdMaterialReceiptH); + + string feedCode = await _billRullService.GetBillNumber(Tnb.BasicData.CodeTemplateConst.FEEDING_CODE); + PrdFeedingH prdFeedingH = new PrdFeedingH() + { + code = feedCode, + station_id = moTask.workstation_id, + mo_task_id = moTask.id, + process_id = moTask.process_id, + // equip_id = input.equip_id, + workshop_id = workshop?.Id, + carry_id = carry.id, + workline_id = moTask.workline_id, + carry_code = carry.carry_code, + // remark = input.remark, + mbom_process_id = moTask.mbom_process_id, + create_id = _userManager.UserId, + create_time = DateTime.Now, + org_id = _userManager.GetUserInfo().Result.organizeId + }; + insertFHList.Add(prdFeedingH); List carryCodes = new List(); List memberCarryIds = new List(); @@ -650,17 +684,17 @@ namespace Tnb.ProductionMgr Log.Information($"签收载具信息{JsonConvert.SerializeObject(carryCodes)}"); foreach (var item in carryCodes) { - PrdMaterialReceiptD existD = await db.Queryable() - .LeftJoin((x, y) => x.material_receipt_id == y.id) - .Where((x, y) => x.carry_id == carry.id && y.mo_task_id == moTask.id && x.is_all_feeding == 0) - .Select((x,y)=>x) - .FirstAsync(); - if (existD != null) - { - throw new Exception($"{moTask.mo_task_code}任务单存在未投完的签收物料,物料签收子表id{existD.id}"); - } - - insertDList.Add(new PrdMaterialReceiptD + // 自动签收不校验 + // PrdMaterialReceiptD existD = await db.Queryable() + // .LeftJoin((x, y) => x.material_receipt_id == y.id) + // .Where((x, y) => x.carry_id == carry.id && y.mo_task_id == moTask.id && x.is_all_feeding == 0) + // .Select((x,y)=>x) + // .FirstAsync(); + // if (existD != null) + // { + // throw new Exception($"{moTask.mo_task_code}任务单存在未投完的签收物料,物料签收子表id{existD.id}"); + // } + PrdMaterialReceiptD detail = new PrdMaterialReceiptD { material_receipt_id = prdMaterialReceiptH.id, material_id = item.material_id, @@ -669,14 +703,63 @@ namespace Tnb.ProductionMgr unit_id = item.unit_id, carry_id = carry.id, barcode = item.barcode, - is_all_feeding = 0, + is_all_feeding = 1, member_carry_id = item.carry_id, - member_carry_code = memberCarrys.Find(x=>x.id==item.carry_id)?.carry_code ?? "", - feeding_num = 0, + member_carry_code = memberCarrys.Find(x => x.id == item.carry_id)?.carry_code ?? "", + feeding_num = item.codeqty, supplier_id = item.supplier_id, instock_time = item.instock_time, - check_conclusion = item.check_conclusion+"", + check_conclusion = item.check_conclusion + "", + create_time = DateTime.Now, + }; + + insertDList.Add(detail); + + decimal num = item.codeqty; + insertFDList.Add(new PrdFeedingD + { + feeding_id = prdFeedingH.id, + material_receipt_detail_id = detail?.id, + material_id = item.material_id, + num = num, + batch = item.code_batch, + unit_id = item.unit_id, + carry_id = carry.id, + status = "0", + use_num = 0, }); + + if (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID) + { + } + else + { + 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 (carry.carrystd_id == WmsWareHouseConst.CARRY_ZYXCSTD_ID || carry.carrystd_id == WmsWareHouseConst.CARRY_ZYLJSTD_ID) + { + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(new CarryCodeUnbindInput() + { + carry_id = carry.id + }); + + + if (result.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + throw Oops.Bah(result.msg); + } } } else @@ -684,7 +767,34 @@ namespace Tnb.ProductionMgr throw Oops.Bah("未找到物料明细"); } + + if (carry.carrystd_id==WmsWareHouseConst.CARRY_LXSTD_ID) + { + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsCarryUnbindService.CarryUnbind(new CarryBindInput() + { + org = prdFeedingH.org_id, + create_id = prdFeedingH.create_id, + carry_id = prdMaterialReceiptH.carry_id, + carry_code = prdMaterialReceiptH.carry_code, + carrystd_id = carry.carrystd_id, + membercarry_code = "", + membercarry_id = "", + }); + + if (result2.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + throw Oops.Bah(result2.msg); + } + + } + } + + await db.Updateable() + .SetColumns(x => x.carry_status == ((int)EnumCarryStatus.空闲).ToString()) + .SetColumns(x => x.is_check == ((int)EnumCheckConclusion.待检).ToString()) + .Where(x => input.carryIds.Contains(x.id)) + .ExecuteCommandAsync(); if (insertHList.Count <= 0 || insertDList.Count <= 0) { @@ -693,7 +803,11 @@ namespace Tnb.ProductionMgr int row1 = await db.Insertable(insertHList).ExecuteCommandAsync(); int row2 = await db.Insertable(insertDList).ExecuteCommandAsync(); - if (row1 <= 0 || row2 <= 0) + int row3 = await db.Insertable(insertHList).ExecuteCommandAsync(); + int row4 = await db.Insertable(insertDList).ExecuteCommandAsync(); + + + if (row1 <= 0 || row2 <= 0 || row3<=0 || row4<=0) { throw Oops.Bah(ErrorCode.COM1000); }