diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnD.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnD.cs index 72ae739a..cbec78bc 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnD.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnD.cs @@ -69,4 +69,18 @@ public partial class WmsPrdReturnD : BaseEntity /// public string? unit_id { get; set; } + /// + /// 子表主键 + /// + public string erp_line_pk { get; set; } + + /// + /// 行号 + /// + public string? lineno { get; set; } + /// + /// 批号 + /// + public string? code_batch { get; set; } + } diff --git a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnH.cs b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnH.cs index 65a73231..55b4acaf 100644 --- a/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnH.cs +++ b/ProductionMgr/Tnb.ProductionMgr.Entities/Entity/WmsPrdReturnH.cs @@ -64,4 +64,19 @@ public partial class WmsPrdReturnH : BaseEntity /// public string? status { get; set; } + /// + /// erp转库单号 + /// + public string? erp_bill_code { get; set; } + + /// + /// 转库类型 + /// + public string? transfer_type { get; set; } + + /// + /// 主表主键 + /// + public string erp_pk { get; set; } + } diff --git a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs index 77ef7fc3..fa133181 100644 --- a/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs +++ b/ProductionMgr/Tnb.ProductionMgr/RedisBackGround.cs @@ -1964,6 +1964,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA { wmsDistaskHs[0].device_id = e.device_id; } + LoggerElevatorTask.Information($"【GenTaskExecute】呼叫电梯"); await _wareHouseService.ExecuteTargetFloorTask(wmsDistaskHs); } } @@ -2257,7 +2258,6 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA /// private async void Floor4MJX2MJC(object? args) { - BasLocation startlocation = await db_Floor4MJX2MJC.Queryable().Where(r => r.location_code == "MJQ-QU02").FirstAsync(); if (s_taskFloor4MJX2MJCService.CurrentCount == 0) return; await s_taskFloor4MJX2MJCService.WaitAsync(); @@ -2296,7 +2296,7 @@ where carry_code = '{coderesult}' and status = '{WmsWareHouseConst.TASK_BILL_STA var endlocation = items.First(); await db_Floor4MJX2MJC.Ado.BeginTranAsync(); - startlocation = await db_Floor4MJX2MJC.Queryable().Where(r => r.location_code == key).FirstAsync(); + BasLocation startlocation = await db_Floor4MJX2MJC.Queryable().Where(r => r.location_code == key).FirstAsync(); if (startlocation.is_lock == 1) { diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs index e803826c..305b27cd 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/PrdReturnInput.cs @@ -30,9 +30,14 @@ public string source_id { get; set; } /// - /// 空料箱 + /// /// public List details { get; set; } + + /// + /// + /// + public List matdetails { get; set; } } public class PrdReturnDetail @@ -42,4 +47,15 @@ /// public string? carry_code { get; set; } } + public class PrdReturnMatDetail + { + /// + /// + /// + public string? barcode { get; set; } + /// + /// + /// + public decimal qty { get; set; } + } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs index 687d5519..0dcf65b7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs @@ -24,11 +24,6 @@ public partial class WmsMaterialTransferD : BaseEntity /// public string? f_flowid { get; set; } - /// - /// 行号 - /// - public string? lineno { get; set; } - /// /// 物品ID /// @@ -105,4 +100,9 @@ public partial class WmsMaterialTransferD : BaseEntity /// 子表主键 /// public string erp_line_pk { get; set; } + + /// + /// 行号 + /// + public string? lineno { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs index a6180dbb..063f118f 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/DeviceProviderService.cs @@ -402,9 +402,6 @@ namespace Tnb.WarehouseMgr string sno = devName.Match(@"\d+"); List elevatorTasks = _db.Queryable() .Where(r => r.startlocation_code == $"DT-3-{sno}" && r.endlocation_code == $"DT-1-{sno}" && r.act_start_date == null && r.act_end_date == null - && r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList(); - List elevatorTasks2 = _db.Queryable() - .Where(r => r.startlocation_code.Contains($"DT-3") && r.endlocation_code.Contains($"DT-1") && r.act_start_date == null && r.act_end_date == null && r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList(); if (elevatorTasks.Count >= 2) { @@ -877,25 +874,23 @@ namespace Tnb.WarehouseMgr await _db.Updateable().SetColumns(r => new WmsElevatorH { is_use = (int)EnumElevatorUseStatus.空闲, - use_tasks = "" + use_tasks = "", + task_nums = 0 }) .Where(it => it.elevator_id == wmsElevatorH.elevator_id).ExecuteCommandAsync(); - if (input.elevator_code == "Elevator3" || input.elevator_code == "Elevator4") - { - // 成品出库解锁电梯 - string number = input.elevator_code.Replace("Elevator", ""); - List elevatorTasks = _db.Queryable() - .Where(r => r.startlocation_code.Contains($"DT-3-{number}") && r.endlocation_code.Contains($"DT-1-{number}") && r.act_start_date == null && r.act_end_date == null - && r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList(); - foreach (var item in elevatorTasks) - { - item.status = WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID; - } - int row = await _db.Updateable(elevatorTasks).ExecuteCommandAsync(); - Logger.Information($"【WmsElevatorUnlock】操作电梯{input.elevator_code}重置电梯任务{row}条 {string.Join(',', elevatorTasks.Select(r => r.bill_code))}"); + List elevatorTasks = _db.Queryable() + .Where(r => r.startlocation_code.Contains($"DT") && r.endlocation_code.Contains($"DT") && r.act_start_date == null && r.act_end_date == null + && r.status != WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID && r.status != WmsWareHouseConst.TASK_BILL_STATUS_COMPLE_ID).ToList(); + + foreach (var item in elevatorTasks) + { + item.status = WmsWareHouseConst.TASK_BILL_STATUS_CANCEL_ID; } + int row = await _db.Updateable(elevatorTasks).ExecuteCommandAsync(); + + Logger.Information($"【WmsElevatorUnlock】操作电梯{input.elevator_code}重置电梯任务{row}条 {string.Join(',', elevatorTasks.Select(r => r.bill_code))}"); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs index b40687b5..593e1c6a 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs @@ -660,8 +660,25 @@ namespace Tnb.WarehouseMgr try { - BasWarehouse warehouse_outstock = await db.Queryable().Where(r => r.whcode == input.warehouse_outstock).FirstAsync(); - BasWarehouse warehouse_instock = await db.Queryable().Where(r => r.whcode == input.warehouse_instock).FirstAsync(); + WmsErpWarehouserelaH wmsErpWarehouserelaHout = await db.Queryable().Where(r => r.erp_warehousecode == input.warehouse_outstock).FirstAsync(); + if (wmsErpWarehouserelaHout == null) + { + _LoggerErp2Mes.LogWarning($@"【TransferOrder】不存在erp仓库类型{input.warehouse_outstock}对应wms系统的映射关系!"); + throw new AppFriendlyException($@"不存在erp仓库类型{input.warehouse_outstock}对应wms系统的映射关系!", 500); + } + + WmsErpWarehouserelaH wmsErpWarehouserelaHin = await db.Queryable().Where(r => r.erp_warehousecode == input.warehouse_instock).FirstAsync(); + if (wmsErpWarehouserelaHin == null) + { + _LoggerErp2Mes.LogWarning($@"【TransferOrder】不存在erp仓库类型{input.warehouse_outstock}对应wms系统的映射关系!"); + throw new AppFriendlyException($@"不存在erp仓库类型{input.warehouse_outstock}对应wms系统的映射关系!", 500); + } + + string warehouse_outstock_code = wmsErpWarehouserelaHout.wms_warehousecode; + string warehouse_instock_code = wmsErpWarehouserelaHin.wms_warehousecode; + + BasWarehouse warehouse_outstock = await db.Queryable().Where(r => r.whcode == warehouse_outstock_code).FirstAsync(); + BasWarehouse warehouse_instock = await db.Queryable().Where(r => r.whcode == warehouse_instock_code).FirstAsync(); if (warehouse_outstock == null) { _LoggerErp2Mes.LogWarning($"【MaterialTransfer】无法查询到出库仓库{input.warehouse_outstock}的档案记录!"); @@ -804,67 +821,56 @@ namespace Tnb.WarehouseMgr if (details_return.Count > 0) { - //WmsPrdReturnH wmsPrdReturnH = new WmsPrdReturnH(); - //string Code = await _billRuleService.GetBillNumber("WMSPRDRETURN"); - //wmsPrdReturnH.bill_code = Code; - //wmsPrdReturnH.status = WmsWareHouseConst.BILLSTATUS_ADD_ID; - //wmsPrdReturnH.bill_date = DateTime.Now; - //wmsPrdReturnH.warehouse_outstock = warehouse_outstock.id; - //wmsPrdReturnH.warehouse_instock = warehouse_instock.id; - //wmsPrdReturnH.biller_out = input.biller_out; - //wmsPrdReturnH.depart_out = input.depart_out; - //wmsPrdReturnH.biller_in = input.biller_in; - //wmsPrdReturnH.depart_in = input.depart_in; - //wmsPrdReturnH.deliver_date = input.deliver_date; - //wmsPrdReturnH.arrival_date = input.arrival_date; - //wmsPrdReturnH.create_id = WmsWareHouseConst.ErpUserId; - //wmsPrdReturnH.create_time = DateTime.Now; - //wmsPrdReturnH.org_id = WmsWareHouseConst.AdministratorOrgId; - //wmsPrdReturnH.erp_bill_code = input.bill_code; - //wmsPrdReturnH.transfer_type = transfer_type; - //wmsPrdReturnH.erp_pk = input.erp_pk; + WmsPrdReturnH wmsPrdReturnH = new WmsPrdReturnH(); + string Code = await _billRuleService.GetBillNumber("WMSPRDRETURN"); + wmsPrdReturnH.bill_code = Code; + wmsPrdReturnH.status = WmsWareHouseConst.BILLSTATUS_ADD_ID; + wmsPrdReturnH.warehouse_id = warehouse_instock.id; + wmsPrdReturnH.create_id = WmsWareHouseConst.ErpUserId; + wmsPrdReturnH.create_time = DateTime.Now; + wmsPrdReturnH.erp_bill_code = input.bill_code; + wmsPrdReturnH.transfer_type = transfer_type; + wmsPrdReturnH.erp_pk = input.erp_pk; - //await db.Insertable(wmsPrdReturnH).ExecuteCommandAsync(); + await db.Insertable(wmsPrdReturnH).ExecuteCommandAsync(); - //List wmsPrdReturnDs = new List(); - //foreach (var detail in input.details) - //{ - // WmsPrdReturnD wmsPrdReturnD = new WmsPrdReturnD(); - // wmsPrdReturnD.lineno = detail.lineno; - // wmsPrdReturnD.material_code = detail.material_code; - // wmsPrdReturnD.code_batch = detail.code_batch; - // wmsPrdReturnD.station_code = detail.station_code; - // wmsPrdReturnD.qty = detail.qty; - // wmsPrdReturnD.bill_id = wmsMaterialTransfer.id; + List wmsPrdReturnDs = new List(); + foreach (var detail in input.details) + { + WmsPrdReturnD wmsPrdReturnD = new WmsPrdReturnD(); + wmsPrdReturnD.lineno = detail.lineno; + wmsPrdReturnD.material_code = detail.material_code; + wmsPrdReturnD.code_batch = detail.code_batch; + wmsPrdReturnD.qty = -detail.qty; + wmsPrdReturnD.bill_id = wmsPrdReturnH.id; - // wmsPrdReturnD.yxfqty = 0; - // wmsPrdReturnD.yzqty = 0; - // wmsPrdReturnD.erp_line_pk = detail.erp_line_pk; + wmsPrdReturnD.ytqty = 0; + wmsPrdReturnD.erp_line_pk = detail.erp_line_pk; - // var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); - // if (material != null) - // { - // wmsPrdReturnD.material_id = material.id; - // wmsPrdReturnD.material_code = material.code; - // wmsPrdReturnD.material_name = material.name; - // } + var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); + if (material != null) + { + wmsPrdReturnD.material_id = material.id; + wmsPrdReturnD.material_code = material.code; + wmsPrdReturnD.material_name = material.name; + } - // var erpExtendField = await db.Queryable().InnerJoin((a, b) => a.table_id == b.Id).Where((a, b) => b.EnCode == detail.unit_code).Select((a, b) => b).FirstAsync(); - // if (erpExtendField != null) - // { - // wmsPrdReturnD.unit_id = erpExtendField.Id; - // } - // else - // { - // _LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体明细中单位{detail.unit_code}在wms系统中未找到!"); - // throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500); - // } + var erpExtendField = await db.Queryable().InnerJoin((a, b) => a.table_id == b.Id).Where((a, b) => b.EnCode == detail.unit_code).Select((a, b) => b).FirstAsync(); + if (erpExtendField != null) + { + wmsPrdReturnD.unit_id = erpExtendField.Id; + } + else + { + _LoggerErp2Mes.LogWarning($@"【MaterialTransfer】表体明细中单位{detail.unit_code}在wms系统中未找到!"); + throw new AppFriendlyException($@"表体明细中单位{detail.unit_code}在wms系统中未找到!", 500); + } - // wmsPrdReturnDs.Add(wmsPrdReturnD); - //} + wmsPrdReturnDs.Add(wmsPrdReturnD); + } - //await db.Insertable(wmsPrdReturnDs).ExecuteCommandAsync(); - //LoggerErp2Mes.LogInformation($"【MaterialTransfer】成功生成单据:{Code}"); + await db.Insertable(wmsPrdReturnDs).ExecuteCommandAsync(); + LoggerErp2Mes.LogInformation($"【MaterialTransfer】成功生成单据:{Code}"); } await db.Ado.CommitTranAsync(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs index 050733ff..e3bb0ad7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryBindService.cs @@ -219,7 +219,7 @@ namespace Tnb.WarehouseMgr } case WmsWareHouseConst.BILLTYPE_OUTSOURCE_ID: { - decimal? sum = group.Select(r => r.codeqty).Sum(); + decimal? sum = input.details.Where(r => group.Select(r => r.barcode).Contains(r.barcode)).Select(r => r.codeqty).Sum(); WmsOutsourceD wmsOutsourceD = await _db.Queryable().Where(r => r.id == group.Key.require_id).FirstAsync(); decimal? bind_qty = wmsOutsourceD.bind_qty ?? 0; if (sum + bind_qty > wmsOutsourceD.outsource_quantity) @@ -232,9 +232,10 @@ namespace Tnb.WarehouseMgr } case WmsWareHouseConst.BILLTYPE_RAWMATTRANSFERINSTOCK_ID: { - decimal? sum = group.Select(r => r.codeqty).Sum(); + decimal? sum = input.details.Where(r => group.Select(r => r.barcode).Contains(r.barcode)).Select(r => r.codeqty).Sum(); WmsRawmatTransferinstockD wmsRawmatTransferinstockD = await _db.Queryable().Where(r => r.id == group.Key.require_id).FirstAsync(); decimal? bind_qty = wmsRawmatTransferinstockD.bind_qty ?? 0; + if (sum + bind_qty > wmsRawmatTransferinstockD.qty) { throw new Exception($"托盘{input.carrycode} 物料{wmsRawmatTransferinstockD.matcode} 当前绑定数量为{sum} 剩余可绑定数量为{wmsRawmatTransferinstockD.actual_qty - bind_qty}!"); @@ -332,6 +333,13 @@ namespace Tnb.WarehouseMgr throw new Exception($"托盘{carry.carry_code}不存在!"); } + List repeat_wmsCarryCodes = await db.Queryable().Where(r => input.details.Select(x=>x.barcode).Contains(r.barcode)).ToListAsync(); + if (repeat_wmsCarryCodes.Count > 0) + { + throw new Exception($"以下条码已被绑定:{string.Join(',', repeat_wmsCarryCodes.Select(r => r.barcode))}"); + } + + List WmsCarryCodes = new List(); WmsCarrybindH wmsCarrybindH = new WmsCarrybindH(); diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs index 3bd72eb8..8eef3a01 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPrdReturnService.cs @@ -90,6 +90,10 @@ namespace Tnb.WarehouseMgr { return await Return_到缓存仓(input, wmsCarryH, wmsPrdReturnH); } + else if (wmsCarryH.carrystd_id == "26032423715365") + { + return await Return_到原材料仓(input, wmsCarryH, wmsPrdReturnH); + } else { Logger.LogError($"【PrdReturn】当前载具的规格id是{wmsCarryH.carrystd_id} 无法处理此类型的载具!"); @@ -340,6 +344,145 @@ namespace Tnb.WarehouseMgr return await ToApiResult(HttpStatusCode.OK, "成功"); } + async Task Return_到原材料仓(PrdReturnInput input, WmsCarryH wmsCarryH, WmsPrdReturnH wmsPrdReturnH) + { + try + { + await _wareHouseService.s_taskExecuteSemaphore_YCLInstock.WaitAsync(); + BasLocation startlocation = _db.Queryable().Where(r => r.id == input.startlocation_id).First(); + if (startlocation == null) + { + Logger.LogWarning($"【PrdReturn】不存在id为{input.startlocation_id}的库位!"); + throw new AppFriendlyException($"【PrdReturn】不存在id为{input.startlocation_id}的库位!", 500); + } + if (string.IsNullOrEmpty(input.carry_code)) + { + Logger.LogWarning($"【PrdReturn】托盘不能为空!{input.carry_code}"); + throw new AppFriendlyException($"【PrdReturn】托盘不能为空!{input.carry_code}!", 500); + } + + InStockStrategyQuery inStockStrategyInput = new() { warehouse_id = "1", Size = 1, AvoidBusyPassage = true, Region_id = WmsWareHouseConst.REGION_YCLCache_ID }; + List endLocations = await _wareHouseService.InStockStrategy(inStockStrategyInput); + if (endLocations.Count == 0) + { + throw new AppFriendlyException("没有可以回库的库位", 500); + } + + if (endLocations.Count() == 0) + { + Logger.LogWarning($"【PrdReturn】没有可用的终点库位"); + throw new AppFriendlyException($"【PrdReturn】没有可用的终点库位!", 500); + } + + BasLocation endlocation = endLocations.First(); + + CarryMaterialBindInput carryMaterialBindInput = new CarryMaterialBindInput(); + carryMaterialBindInput.carrycode = wmsCarryH.carry_code; + carryMaterialBindInput.create_id = input.create_id; + + List carryMaterialDetails = new List(); + + + List wmsTempCodes = await _db.Queryable().Where(r => input.matdetails.Select(x => x.barcode).Contains(r.barcode)).ToListAsync(); + + await _db.Ado.BeginTranAsync(); + + foreach (PrdReturnMatDetail prdReturnMatDetail in input.matdetails) + { + WmsTempCode wmsTempCode = _db.Queryable().Where(r => r.barcode == prdReturnMatDetail.barcode).First(); + if (wmsTempCode == null) + { + throw new AppFriendlyException($"【PrdReturn】条码{prdReturnMatDetail.barcode}!", 500); + } + CarryMaterialDetail carryMaterialDetail = new CarryMaterialDetail(); + carryMaterialDetail.material_id = wmsTempCode.material_id; + carryMaterialDetail.material_code = wmsTempCode.material_code; + carryMaterialDetail.codeqty = prdReturnMatDetail.qty; + wmsTempCode.codeqty = prdReturnMatDetail.qty; + carryMaterialDetail.code_batch = wmsTempCode.code_batch; + carryMaterialDetail.barcode = wmsTempCode.barcode; + carryMaterialDetail.unit_id = wmsTempCode.unit_id; + carryMaterialDetails.Add(carryMaterialDetail); + } + carryMaterialBindInput.details = carryMaterialDetails; + await _wmsCarryBindService.CarryMaterialBind(carryMaterialBindInput, _db); + + await _db.Updateable(wmsTempCodes).ExecuteCommandAsync(); + + var memberCarryCodes = _db.Queryable() + .InnerJoin((a, b) => a.id == b.carry_id) + .Where((a, b) => a.id == wmsCarryH.id).Select((a, b) => new + { + carry_code = a.carry_code, + barcode = b.barcode, + material_id = b.material_id, + material_code = b.material_code, + }).ToList(); + + List matIds = memberCarryCodes.Select(r => r.material_id).Distinct().ToList(); + + // 匹配生产退料单明细的物料种类 + List existsMatIds = _db.Queryable().Where(r => r.bill_id == input.source_id).Select(r => r.material_id).Distinct().ToList(); + List notExistsMatIds = matIds.Where(r => !existsMatIds.Contains(r)).ToList(); + + if (notExistsMatIds.Count() > 0) + { + var existsMat = memberCarryCodes.Where(r => notExistsMatIds.Contains(r.material_id)).Select(r => new + { + carry_code = r.carry_code, + barcode = r.barcode, + }); + + string msg = ""; + foreach (var row in existsMat) + { + msg += $",托盘{row.carry_code} 条码{row.barcode}"; + } + Logger.LogWarning($"【PrdReturn】存在装有与生产退料单明细不匹配物料的托盘,请检查! {msg.Trim(',')}"); + throw new AppFriendlyException($"存在装有与生产退料单明细不匹配物料的托盘,请检查!{msg.Trim(',')}", 500); + } + + WmsPretaskH wmsPretaskH = _db.Queryable().Where(r => r.carry_code == wmsCarryH.carry_code && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_COMPLE_ID && r.status != WmsWareHouseConst.PRETASK_BILL_STATUS_CANCEL_ID).First(); + if (wmsPretaskH != null) + { + Logger.LogWarning($"【PrdReturn】此托盘{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}!"); + throw new AppFriendlyException($"此托盘{wmsCarryH.carry_code}存在未完成的预任务{wmsPretaskH.bill_code}!", 500); + } + + + Logger.LogInformation($"【PrdReturn】开始生成预任务"); + CommonCreatePretaskInput commonCreatePretaskInput = new(); + commonCreatePretaskInput.startlocation_id = startlocation.id; + commonCreatePretaskInput.endlocation_id = endlocation.id; + commonCreatePretaskInput.source_id = input.source_id; + commonCreatePretaskInput.carry_id = wmsCarryH.id; + commonCreatePretaskInput.carry_code = input.carry_code; + commonCreatePretaskInput.task_type = ""; + commonCreatePretaskInput.biz_type = WmsWareHouseConst.BIZTYPE_PRDRETURN_ID; + + var res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput); + if (res.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + Logger.LogInformation($"【PrdReturn】生成预任务失败 载具 {input.carry_code}"); + throw new AppFriendlyException($"生成预任务失败 载具 {input.carry_code}", 500); + } + Logger.LogWarning($"【PrdReturn】生成预任务成功"); + await _db.Ado.CommitTranAsync(); + } + catch (Exception ex) + { + Logger.LogError("【PrdReturn】" + ex.Message); + Logger.LogError("【PrdReturn】" + ex.StackTrace); + await _db.Ado.RollbackTranAsync(); + return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); + } + finally + { + _wareHouseService.s_taskExecuteSemaphore_YCLInstock.Release(); + } + return await ToApiResult(HttpStatusCode.OK, "成功"); + } + public override async Task ModifyAsync(WareHouseUpInput input) { if (input == null) diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferinstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferinstockService.cs index 37991887..db678d41 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferinstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsRawmatTransferinstockService.cs @@ -32,6 +32,7 @@ using Tnb.WarehouseMgr.Entities.Enums; using Tnb.WarehouseMgr.Interfaces; using Tnb.BasicData; using Tnb.ProductionMgr.Entities.Entity; +using Tnb.WarehouseMgr.Entities.Attributes; namespace Tnb.WarehouseMgr { @@ -39,8 +40,10 @@ namespace Tnb.WarehouseMgr /// 原材料调拨入库单 /// [OverideVisualDev(ModuleConsts.MODULE_WMSRAWMATTRANSFERINSTOCK_ID)] + [ServiceModule(BizTypeId)] public class WmsRawmatTransferinstockService : BaseWareHouseService { + private const string BizTypeId = WmsWareHouseConst.BIZTYPE_RAWMATTRANSFERINSTOCK_ID; private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; private readonly IBillRullService _billRullService; @@ -67,6 +70,7 @@ namespace Tnb.WarehouseMgr throw new ArgumentNullException(nameof(input)); } + Logger.Information($"进入原材料调拨入库单上传BIP逻辑"); WmsInstockH instock = await _db.Queryable().SingleAsync(x => x.id == input.requireId); List allInstockDetails = await _db.Queryable().Where(it => it.bill_id == input.requireId).ToListAsync(); @@ -177,6 +181,7 @@ namespace Tnb.WarehouseMgr thirdWebapiRecord.request_data = JsonConvert.SerializeObject(requestData); thirdWebapiRecord.create_time = DateTime.Now; await _db.Insertable(thirdWebapiRecord).ExecuteCommandAsync(); + Logger.Information($"完成原材料调拨入库单上传BIP逻辑"); } [HttpPost] diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs index f7ccbcd9..f0a56d27 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsTransferInstockService.cs @@ -17,6 +17,7 @@ using Microsoft.Extensions.Logging; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; +using Tnb.WarehouseMgr.Entities.Attributes; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto.Inputs; using Tnb.WarehouseMgr.Entities.Entity; @@ -28,8 +29,11 @@ namespace Tnb.WarehouseMgr /// 调拨入库单(成品) /// [OverideVisualDev(ModuleConsts.MODULE_WmsTransferInstock_ID)] + [ServiceModule(BizTypeId)] + public class WmsTransferInstockService : BaseWareHouseService { + private const string BizTypeId = WmsWareHouseConst.BIZTYPE_WMSTRANSFERINSTOCK_ID; private readonly ISqlSugarClient _db; private readonly IUserManager _userManager; private readonly IBillRullService _billRullService;