From 9ea9b4378db42d5aa85b58f3d77606f1c5ac9bc4 Mon Sep 17 00:00:00 2001 From: majian <780924089@qq.com> Date: Thu, 4 Jul 2024 16:34:04 +0800 Subject: [PATCH] =?UTF-8?q?erp=E8=BD=AC=E5=BA=93=E5=8D=95=E7=9A=84?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=EF=BC=8C=E7=AD=BE=E6=94=B6=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Consts/WmsWareHouseConst.cs | 26 ++ .../Dto/ErpInputs/MaterialTransferInput.cs | 10 + .../Inputs/FinishproductOutstockSortInput.cs | 4 +- .../Entity/WmsMaterialTransfer.cs | 6 +- .../Entity/WmsMaterialTransferD.cs | 5 +- .../IWmsCarryUnbindService.cs | 2 +- .../Tnb.WarehouseMgr/ErpToWmsService.cs | 239 ++++++++++++++---- .../Tnb.WarehouseMgr/WareHouseService.cs | 2 +- .../Tnb.WarehouseMgr/WmsCarryUnbindService.cs | 20 +- .../WmsPDACarryBindService.cs | 44 +++- .../WmsPDAScanInStockService.cs | 7 +- 11 files changed, 285 insertions(+), 80 deletions(-) diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs index beedd9b8..ad01cda7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Consts/WmsWareHouseConst.cs @@ -18,6 +18,16 @@ /// 成品仓库ID /// public const string WAREHOUSE_CP_ID = "26103372441637"; + /// + /// 成品出入库仓库ID + /// + public const string WAREHOUSE_CPCRK_ID = "35302142874901"; + /// + /// 暂存仓仓库ID + /// + public const string WAREHOUSE_ZCC_ID = "33780009364245"; + + /// /// 四楼解析库 /// @@ -31,6 +41,22 @@ /// public const string WAREHOUSE_ZZXBK_ID = "26257716248101"; + /// + /// 长管出库 + /// + public const string MATERIALTRANSFER_CGCK_CODE = "longWarehouse"; + /// + /// 外协调拨入库 + /// + public const string MATERIALTRANSFER_WXDBRK_CODE = "wxdbWarehouse"; + /// + /// 集中供料入库 + /// + public const string MATERIALTRANSFER_JZGLRK_CODE = "materielWarehouse"; + /// + /// 齐套出入库 + /// + public const string MATERIALTRANSFER_QTCRK_CODE = "assortWarehouse"; /// /// 出入库单据状态TypeID diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/MaterialTransferInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/MaterialTransferInput.cs index f34e5b4e..433b7465 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/MaterialTransferInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/ErpInputs/MaterialTransferInput.cs @@ -63,6 +63,11 @@ namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs /// public DateTime arrival_date { get; set; } + /// + /// 主表主键 + /// + public string erp_pk { get; set; } + public List details { get; set; } } public class MaterialTransferDetail @@ -96,5 +101,10 @@ namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs /// 应转主数量 /// public decimal? qty { get; set; } + + /// + /// 子表主键 + /// + public string erp_line_pk { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs index 4d6d14c2..9e964929 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Dto/Inputs/FinishproductOutstockSortInput.cs @@ -6,8 +6,8 @@ public class FinishproductOutstockSignInput { /// - /// 起点 + /// 载具编号 /// - public string? location_id { get; set; } + public string? carry_code { get; set; } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransfer.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransfer.cs index 9aa556cb..96500bdf 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransfer.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransfer.cs @@ -133,5 +133,9 @@ public partial class WmsMaterialTransfer : BaseEntity /// 转库类型 /// public string? transfer_type { get; set; } - + + /// + /// 主表主键 + /// + public string erp_pk { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs index 2a51b331..ccfcfe42 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Entities/Entity/WmsMaterialTransferD.cs @@ -92,5 +92,8 @@ public partial class WmsMaterialTransferD : BaseEntity /// public string? material_ex { get; set; } - + /// + /// 子表主键 + /// + public string erp_line_pk { get; set; } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs index 504396a1..767b00c7 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr.Interfaces/IWmsCarryUnbindService.cs @@ -11,6 +11,6 @@ namespace Tnb.WarehouseMgr.Interfaces public interface IWmsCarryUnbindService { Task CarryUnbind(CarryBindInput input, ISqlSugarClient dbConn = null); - Task CarryCodeUnbind(CarryCodeUnbindInput input); + Task CarryCodeUnbind(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null); } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs index a1475505..d4062db9 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/ErpToWmsService.cs @@ -1,12 +1,19 @@ -using JNPF.DependencyInjection; +using System.Text; +using JNPF.Common.Enums; +using JNPF.DependencyInjection; using JNPF.DynamicApiController; +using JNPF.FriendlyException; using JNPF.Systems.Interfaces.System; +using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; +using Newtonsoft.Json; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Dto.ErpInputs; +using Tnb.WarehouseMgr.Entities.Dto.Outputs; using Tnb.WarehouseMgr.Entities.Entity; using Top.Api; @@ -285,73 +292,193 @@ namespace Tnb.WarehouseMgr /// /// 转库单 /// - public async Task MaterialTransfer(MaterialTransferInput input) + [HttpPost, NonUnify, AllowAnonymous] + public async Task MaterialTransfer(MaterialTransferInput input) { + LoggerErp2Mes.LogInformation($"【MaterialTransfer】ERP传入数据:{JsonConvert.SerializeObject(input)}"); var db = _repository.AsSugarClient(); - try - { - - } - catch (Exception ex) - { - - } - - 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(); if (warehouse_outstock == null) { - + _LoggerErp2Mes.LogWarning($"【MaterialTransfer】无法查询到出库仓库{input.warehouse_outstock}的档案记录!"); + return await ToApiResult(HttpStatusCode.InternalServerError, $"无法查询到出库仓库{input.warehouse_outstock}的档案记录!"); } - - - - WmsMaterialTransfer wmsMaterialTransfer = new WmsMaterialTransfer(); - string Code = await _billRuleService.GetBillNumber("MaterialTransfer"); - wmsMaterialTransfer.bill_code = Code; - wmsMaterialTransfer.status = WmsWareHouseConst.BILLSTATUS_ADD_ID; - wmsMaterialTransfer.bill_date = input.bill_date; - wmsMaterialTransfer.warehouse_outstock = input.warehouse_outstock; - wmsMaterialTransfer.warehouse_instock = input.warehouse_instock; - wmsMaterialTransfer.biller_out = input.biller_out; - wmsMaterialTransfer.depart_out = input.depart_out; - wmsMaterialTransfer.biller_in = input.biller_in; - wmsMaterialTransfer.depart_in = input.depart_in; - wmsMaterialTransfer.deliver_date = input.deliver_date; - wmsMaterialTransfer.arrival_date = input.arrival_date; - wmsMaterialTransfer.create_id = WmsWareHouseConst.ErpUserId; - wmsMaterialTransfer.create_time = DateTime.Now; - wmsMaterialTransfer.org_id = WmsWareHouseConst.AdministratorOrgId; - wmsMaterialTransfer.erp_bill_code = input.bill_code; - - await db.Insertable(wmsMaterialTransfer).ExecuteCommandAsync(); - - List wmsMaterialTransferDs = new List(); - foreach (var detail in input.details) + if (warehouse_instock == null) { - WmsMaterialTransferD wmsMaterialTransferD = new WmsMaterialTransferD(); - wmsMaterialTransferD.lineno = detail.lineno; - wmsMaterialTransferD.material_code = detail.material_code; - wmsMaterialTransferD.unit_code = detail.unit_code; - wmsMaterialTransferD.code_batch = detail.code_batch; - wmsMaterialTransferD.station_code = detail.station_code; - wmsMaterialTransferD.qty = detail.qty; - wmsMaterialTransferD.bill_id = ""; - - var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); - if (material != null) - { - //wmsPurchased.material_id = material.id; - //// wmsPurchased.material_name = material.name; - //wmsPurchased.unit_id = material.unit_id; - } - wmsMaterialTransferDs.Add(wmsMaterialTransferD); + _LoggerErp2Mes.LogWarning($"【MaterialTransfer】无法查询到入库仓库{input.warehouse_instock}的档案记录!"); + return await ToApiResult(HttpStatusCode.InternalServerError, $"无法查询到入库仓库{input.warehouse_instock}的档案记录!"); } - await db.Insertable(wmsMaterialTransferDs).ExecuteCommandAsync(); + if (string.IsNullOrEmpty(input.erp_pk)) + { + _LoggerErp2Mes.LogWarning($"【MaterialTransfer】主表主键不能为空!"); + return await ToApiResult(HttpStatusCode.InternalServerError, $"主表主键不能为空!"); + } + int count_erp_line_pk = input.details.Where(r => string.IsNullOrEmpty(r.erp_line_pk)).Count(); + if (count_erp_line_pk > 0) + { + _LoggerErp2Mes.LogWarning($@"【MaterialTransfer】子表主键不能为空!"); + throw new AppFriendlyException($@"子表主键不能为空!", 500); + } + + string transfer_type = ""; + // 中储仓到暂存仓 + if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_ZC_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_ZCC_ID) + { + int count = input.details.Where(r => string.IsNullOrEmpty(r.station_code)).Count(); + if (count > 0) + { + _LoggerErp2Mes.LogWarning($@"表体存在未填写工位的明细!"); + throw new AppFriendlyException($@"表体存在未填写工位的明细!", 500); + } + + transfer_type = WmsWareHouseConst.MATERIALTRANSFER_CGCK_CODE; + } + else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_CPCRK_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_CP_ID) + { + transfer_type = WmsWareHouseConst.MATERIALTRANSFER_WXDBRK_CODE; + } + else if (warehouse_outstock.id == WmsWareHouseConst.WAREHOUSE_YCL_ID && warehouse_instock.id == WmsWareHouseConst.WAREHOUSE_JZGL_ID) + { + transfer_type = WmsWareHouseConst.MATERIALTRANSFER_JZGLRK_CODE; + } + // 暂时其他情况都算齐套出入库类型(未定) + else + { + int count = input.details.Where(r => string.IsNullOrEmpty(r.station_code)).Count(); + if (count > 0) + { + _LoggerErp2Mes.LogWarning($@"表体存在未填写工位的明细!"); + throw new AppFriendlyException($@"表体存在未填写工位的明细!", 500); + } + + transfer_type = WmsWareHouseConst.MATERIALTRANSFER_QTCRK_CODE; + } + + try + { + await db.Ado.BeginTranAsync(); + WmsMaterialTransfer wmsMaterialTransfer = new WmsMaterialTransfer(); + string Code = await _billRuleService.GetBillNumber("MaterialTransfer"); + wmsMaterialTransfer.bill_code = Code; + wmsMaterialTransfer.status = WmsWareHouseConst.BILLSTATUS_ADD_ID; + wmsMaterialTransfer.bill_date = input.bill_date; + wmsMaterialTransfer.warehouse_outstock = warehouse_outstock.id; + wmsMaterialTransfer.warehouse_instock = warehouse_instock.id; + wmsMaterialTransfer.biller_out = input.biller_out; + wmsMaterialTransfer.depart_out = input.depart_out; + wmsMaterialTransfer.biller_in = input.biller_in; + wmsMaterialTransfer.depart_in = input.depart_in; + wmsMaterialTransfer.deliver_date = input.deliver_date; + wmsMaterialTransfer.arrival_date = input.arrival_date; + wmsMaterialTransfer.create_id = WmsWareHouseConst.ErpUserId; + wmsMaterialTransfer.create_time = DateTime.Now; + wmsMaterialTransfer.org_id = WmsWareHouseConst.AdministratorOrgId; + wmsMaterialTransfer.erp_bill_code = input.bill_code; + wmsMaterialTransfer.transfer_type = transfer_type; + wmsMaterialTransfer.erp_pk = input.erp_pk; + + await db.Insertable(wmsMaterialTransfer).ExecuteCommandAsync(); + + List wmsMaterialTransferDs = new List(); + foreach (var detail in input.details) + { + WmsMaterialTransferD wmsMaterialTransferD = new WmsMaterialTransferD(); + wmsMaterialTransferD.lineno = detail.lineno; + wmsMaterialTransferD.material_code = detail.material_code; + wmsMaterialTransferD.unit_code = detail.unit_code; + wmsMaterialTransferD.code_batch = detail.code_batch; + wmsMaterialTransferD.station_code = detail.station_code; + wmsMaterialTransferD.qty = detail.qty; + wmsMaterialTransferD.bill_id = wmsMaterialTransfer.id; + + wmsMaterialTransferD.yxfqty = 0; + wmsMaterialTransferD.yzqty = 0; + wmsMaterialTransferD.erp_line_pk = detail.erp_line_pk; + + var material = await db.Queryable().Where(p => p.code == detail.material_code).FirstAsync(); + if (material != null) + { + wmsMaterialTransferD.material_id = material.id; + wmsMaterialTransferD.material_specification = material.material_specification; + wmsMaterialTransferD.unit_id = detail.unit_code; + } + wmsMaterialTransferDs.Add(wmsMaterialTransferD); + } + + await db.Insertable(wmsMaterialTransferDs).ExecuteCommandAsync(); + + await db.Ado.CommitTranAsync(); + + LoggerErp2Mes.LogInformation($"【MaterialTransfer】成功生成单据:{Code}"); + return await ToApiResult(HttpStatusCode.OK, "成功"); + } + catch (Exception ex) + { + LoggerErp2Mes.LogError($"【MaterialTransfer】{ex.Message}"); + LoggerErp2Mes.LogError($"【MaterialTransfer】{ex.StackTrace}"); + await db.Ado.RollbackTranAsync(); + return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); + } + finally + { + + } + } + + protected Task ToApiResult(HttpStatusCode statusCode, string msg) + { + Result result = new() + { + code = statusCode, + msg = msg + }; + return Task.FromResult(result); + } + + private static readonly Dictionary s_logLevelMap = new() + { + [LogLevel.Debug] = "DBG", + [LogLevel.Information] = "INF", + [LogLevel.Warning] = "WRN", + [LogLevel.Error] = "ERR", + }; + + protected string _LoggerErp2MesFileName = ""; + protected ILogger _LoggerErp2Mes; + protected ILogger LoggerErp2Mes + { + get + { + string newFileName = $"{AppContext.BaseDirectory}/logs/Erp2Mes{DateTime.Now:yyyyMMdd}.log"; + if (_LoggerErp2MesFileName != newFileName) + { + ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts => + { + + //cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff"; + cfgOpts.MessageFormat = (logMsg) => + { + var logLevel = s_logLevelMap[logMsg.LogLevel]; + var sb = new StringBuilder(); + _ = sb.Append($"[{logLevel}] "); + _ = sb.Append($"{logMsg.LogName} "); + _ = sb.Append($"{DateTime.Now:yyyy-MM-dd HH:mm:ss.fff} "); + _ = sb.Append($"#{logMsg.EventId.Id} "); + _ = sb.Append(logMsg.Message + " "); + _ = sb.Append(logMsg.Exception?.ToString()); + return sb.ToString(); + }; + + })); + _LoggerErp2Mes = loggerFactory.CreateLogger(this.GetType()); + _LoggerErp2MesFileName = newFileName; + } + return _LoggerErp2Mes; + } } } } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs index 16511721..7d93a525 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WareHouseService.cs @@ -2194,7 +2194,7 @@ namespace Tnb.WarehouseMgr CarryCodeUnbindInput carryCodeUnbindInput = new CarryCodeUnbindInput(); carryCodeUnbindInput.carry_id = dt.carry_id; - await _wmsCarryUnbindService.CarryCodeUnbind(carryCodeUnbindInput); + await _wmsCarryUnbindService.CarryCodeUnbind(carryCodeUnbindInput, _db); } } // 成品调拨入库 diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs index c1f3bf19..7719a691 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsCarryUnbindService.cs @@ -204,9 +204,14 @@ namespace Tnb.WarehouseMgr /// /// [NonAction] - public async Task CarryCodeUnbind(CarryCodeUnbindInput input) + public async Task CarryCodeUnbind(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null) { bool isOk = false; + + var db = _db; + if (dbConn != null) + db = dbConn; + try { if (input == null) @@ -214,16 +219,17 @@ namespace Tnb.WarehouseMgr throw new ArgumentNullException(nameof(input)); } - WmsCarryH? carry = await _db.Queryable().SingleAsync(it => it.id == input.carry_id); + WmsCarryH? carry = await db.Queryable().SingleAsync(it => it.id == input.carry_id); if (carry != null) { - int row = await _db.Deleteable().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); + int row = await db.Deleteable().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); isOk = row > 0; - if (!isOk) - { - throw Oops.Oh(ErrorCode.COM1001); - } + Logger.LogInformation($"【CarryCodeUnbind】载具{carry.carry_code}已解绑,解绑条数{row}"); + //if (!isOk) + //{ + // throw Oops.Oh(ErrorCode.COM1001); + //} } else { diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs index ab216e5d..429f4798 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDACarryBindService.cs @@ -1,4 +1,5 @@ -using JNPF.Common.Core.Manager; +using Aop.Api.Domain; +using JNPF.Common.Core.Manager; using JNPF.Common.Dtos.VisualDev; using JNPF.Common.Enums; using JNPF.Common.Extension; @@ -10,6 +11,7 @@ using JNPF.VisualDev.Entitys; using JNPF.VisualDev.Interfaces; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; using SqlSugar; using Tnb.BasicData.Entities; using Tnb.WarehouseMgr.Entities; @@ -377,9 +379,10 @@ namespace Tnb.WarehouseMgr [HttpPost, NonUnify, AllowAnonymous] public async Task FinishproductOutstockSign(FinishproductOutstockSignInput input) { - if (string.IsNullOrEmpty(input.location_id)) + Logger.LogInformation($"【FinishproductOutstockSign】载具签收 {input.carry_code}"); + if (string.IsNullOrEmpty(input.carry_code)) { - throw new AppFriendlyException("起点id不可为空", 500); + throw new AppFriendlyException("请扫描载具", 500); } //if (!_wareHouseService.GetFloor1OutstockLocation().Contains(input.location_id)) @@ -390,26 +393,51 @@ namespace Tnb.WarehouseMgr await _db.Ado.BeginTranAsync(); try { + WmsCarryH wmsCarryH = _db.Queryable().Where(r => r.carry_code == input.carry_code).First(); + + if (string.IsNullOrEmpty(wmsCarryH.location_id)) + { + Logger.Error($"【FinishproductOutstockSign】载具 {input.carry_code}没有当前库位 不能签收!"); + throw new AppFriendlyException("FinishproductOutstockSign】载具 {input.carry_code}没有当前库位 不能签收!", 500); + } + + await _db.Updateable().SetColumns(r => new WmsCarryH + { + is_lock = 0, + carry_status = "0" + }).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync(); + await _db.Updateable().SetColumns(r => new BasLocation { is_lock = 0, is_use = "0" - }).Where(r => r.id == input.location_id).ExecuteCommandAsync(); + }).Where(r => r.id == wmsCarryH.location_id).ExecuteCommandAsync(); + BasLocation location = _db.Queryable().Where(r => r.id == wmsCarryH.location_id).First(); + if (string.IsNullOrEmpty(location.location_code)) + { + Logger.Error($"【FinishproductOutstockSign】库位id {wmsCarryH.location_id}没有对应的库位基础资料!"); + throw new AppFriendlyException("【FinishproductOutstockSign】库位id {wmsCarryH.location_id}没有对应的库位基础资料!", 500); + } await _db.Updateable().SetColumns(r => new WmsPointH { is_lock = 0 - }).Where(r => r.location_id == input.location_id).ExecuteCommandAsync(); + }).Where(r => r.location_id == location.id).ExecuteCommandAsync(); - WmsCarryH wmsCarryH = _db.Queryable().Where(r => r.location_id == input.location_id).First(); CarryCodeUnbindInput carryCodeUnbindInput = new CarryCodeUnbindInput(); carryCodeUnbindInput.carry_id = wmsCarryH.id; - await _wmsCarryUnbindService.CarryCodeUnbind(carryCodeUnbindInput); - + Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result = await _wmsCarryUnbindService.CarryCodeUnbind(carryCodeUnbindInput, _db); + if (result.code != JNPF.Common.Enums.HttpStatusCode.OK) + { + Logger.Error($"【FinishproductOutstockSign】载具 {input.carry_code}解绑失败!"); + throw new AppFriendlyException("【FinishproductOutstockSign】载具 {input.carry_code}解绑失败!", 500); + } await _db.Ado.CommitTranAsync(); } catch (Exception ex) { + Logger.Error($"【FinishproductOutstockSign】 {ex.Message}"); + Logger.Error($"【FinishproductOutstockSign】 {ex.StackTrace}"); await _db.Ado.RollbackTranAsync(); return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); } diff --git a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs index fae9cec3..707587ea 100644 --- a/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs +++ b/WarehouseMgr/Tnb.WarehouseMgr/WmsPDAScanInStockService.cs @@ -574,7 +574,7 @@ namespace Tnb.WarehouseMgr ptc.code_batch = instockCode.code_batch; pretaskCodes.Add(ptc); } - bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes); + bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes, _dbScanInStockByRedis); if (isOk) { @@ -616,7 +616,7 @@ namespace Tnb.WarehouseMgr //回更状态 await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, it => new WmsCarryH { carry_code = instock!.carry_code!, is_lock = 1, carry_status = ((int)EnumCarryStatus.占用).ToString(), location_id = preTaskUpInput.CarryStartLocationId, location_code = preTaskUpInput.CarryStartLocationCode }, - it => new BasLocation { is_lock = 1 }); + it => new BasLocation { is_lock = 1 }, _dbScanInStockByRedis); _ = await _dbScanInStockByRedis.Updateable().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync(); _ = await _dbScanInStockByRedis.Updateable().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync(); @@ -625,6 +625,7 @@ namespace Tnb.WarehouseMgr } await _dbScanInStockByRedis.Ado.CommitTranAsync(); } + // 测试代码 后期删 catch (AggregateException ex) { Console.WriteLine("【ScanInStockByRedis】 AggregateException" + ex.Message); @@ -637,7 +638,7 @@ namespace Tnb.WarehouseMgr { Logger.LogInformation($"【ScanInStockByRedis】 八工位扫到码发送入库请求发生异常:{ex.Message}"); - // 测试代码 + // 测试代码 后期删 if (ex.Message.Contains("Connection is busy")) _dbScanInStockByRedis = _dbScanInStockByRedis.CopyNew();