erp转库单的同步,签收逻辑修改

This commit is contained in:
2024-07-04 16:34:04 +08:00
parent 7d9abfd6c8
commit 9ea9b4378d
11 changed files with 285 additions and 80 deletions

View File

@@ -18,6 +18,16 @@
/// 成品仓库ID /// 成品仓库ID
/// </summary> /// </summary>
public const string WAREHOUSE_CP_ID = "26103372441637"; public const string WAREHOUSE_CP_ID = "26103372441637";
/// <summary>
/// 成品出入库仓库ID
/// </summary>
public const string WAREHOUSE_CPCRK_ID = "35302142874901";
/// <summary>
/// 暂存仓仓库ID
/// </summary>
public const string WAREHOUSE_ZCC_ID = "33780009364245";
/// <summary> /// <summary>
/// 四楼解析库 /// 四楼解析库
/// </summary> /// </summary>
@@ -31,6 +41,22 @@
/// </summary> /// </summary>
public const string WAREHOUSE_ZZXBK_ID = "26257716248101"; public const string WAREHOUSE_ZZXBK_ID = "26257716248101";
/// <summary>
/// 长管出库
/// </summary>
public const string MATERIALTRANSFER_CGCK_CODE = "longWarehouse";
/// <summary>
/// 外协调拨入库
/// </summary>
public const string MATERIALTRANSFER_WXDBRK_CODE = "wxdbWarehouse";
/// <summary>
/// 集中供料入库
/// </summary>
public const string MATERIALTRANSFER_JZGLRK_CODE = "materielWarehouse";
/// <summary>
/// 齐套出入库
/// </summary>
public const string MATERIALTRANSFER_QTCRK_CODE = "assortWarehouse";
/// <summary> /// <summary>
/// 出入库单据状态TypeID /// 出入库单据状态TypeID

View File

@@ -63,6 +63,11 @@ namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
/// </summary> /// </summary>
public DateTime arrival_date { get; set; } public DateTime arrival_date { get; set; }
/// <summary>
/// 主表主键
/// </summary>
public string erp_pk { get; set; }
public List<MaterialTransferDetail> details { get; set; } public List<MaterialTransferDetail> details { get; set; }
} }
public class MaterialTransferDetail public class MaterialTransferDetail
@@ -96,5 +101,10 @@ namespace Tnb.WarehouseMgr.Entities.Dto.ErpInputs
/// 应转主数量 /// 应转主数量
/// </summary> /// </summary>
public decimal? qty { get; set; } public decimal? qty { get; set; }
/// <summary>
/// 子表主键
/// </summary>
public string erp_line_pk { get; set; }
} }
} }

View File

@@ -6,8 +6,8 @@
public class FinishproductOutstockSignInput public class FinishproductOutstockSignInput
{ {
/// <summary> /// <summary>
/// 起点 /// 载具编号
/// </summary> /// </summary>
public string? location_id { get; set; } public string? carry_code { get; set; }
} }
} }

View File

@@ -133,5 +133,9 @@ public partial class WmsMaterialTransfer : BaseEntity<string>
/// 转库类型 /// 转库类型
/// </summary> /// </summary>
public string? transfer_type { get; set; } public string? transfer_type { get; set; }
/// <summary>
/// 主表主键
/// </summary>
public string erp_pk { get; set; }
} }

View File

@@ -92,5 +92,8 @@ public partial class WmsMaterialTransferD : BaseEntity<string>
/// </summary> /// </summary>
public string? material_ex { get; set; } public string? material_ex { get; set; }
/// <summary>
/// 子表主键
/// </summary>
public string erp_line_pk { get; set; }
} }

View File

@@ -11,6 +11,6 @@ namespace Tnb.WarehouseMgr.Interfaces
public interface IWmsCarryUnbindService public interface IWmsCarryUnbindService
{ {
Task<Result> CarryUnbind(CarryBindInput input, ISqlSugarClient dbConn = null); Task<Result> CarryUnbind(CarryBindInput input, ISqlSugarClient dbConn = null);
Task<Result> CarryCodeUnbind(CarryCodeUnbindInput input); Task<Result> CarryCodeUnbind(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null);
} }
} }

View File

@@ -1,12 +1,19 @@
using JNPF.DependencyInjection; using System.Text;
using JNPF.Common.Enums;
using JNPF.DependencyInjection;
using JNPF.DynamicApiController; using JNPF.DynamicApiController;
using JNPF.FriendlyException;
using JNPF.Systems.Interfaces.System; using JNPF.Systems.Interfaces.System;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using SqlSugar; using SqlSugar;
using Tnb.BasicData.Entities; using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities;
using Tnb.WarehouseMgr.Entities.Consts; using Tnb.WarehouseMgr.Entities.Consts;
using Tnb.WarehouseMgr.Entities.Dto.ErpInputs; using Tnb.WarehouseMgr.Entities.Dto.ErpInputs;
using Tnb.WarehouseMgr.Entities.Dto.Outputs;
using Tnb.WarehouseMgr.Entities.Entity; using Tnb.WarehouseMgr.Entities.Entity;
using Top.Api; using Top.Api;
@@ -285,73 +292,193 @@ namespace Tnb.WarehouseMgr
/// <summary> /// <summary>
/// 转库单 /// 转库单
/// </summary> /// </summary>
public async Task MaterialTransfer(MaterialTransferInput input) [HttpPost, NonUnify, AllowAnonymous]
public async Task<Result> MaterialTransfer(MaterialTransferInput input)
{ {
LoggerErp2Mes.LogInformation($"【MaterialTransfer】ERP传入数据:{JsonConvert.SerializeObject(input)}");
var db = _repository.AsSugarClient(); var db = _repository.AsSugarClient();
try
{
}
catch (Exception ex)
{
}
BasWarehouse warehouse_outstock = await db.Queryable<BasWarehouse>().Where(r => r.whcode == input.warehouse_outstock).FirstAsync(); BasWarehouse warehouse_outstock = await db.Queryable<BasWarehouse>().Where(r => r.whcode == input.warehouse_outstock).FirstAsync();
BasWarehouse warehouse_instock = await db.Queryable<BasWarehouse>().Where(r => r.whcode == input.warehouse_instock).FirstAsync(); BasWarehouse warehouse_instock = await db.Queryable<BasWarehouse>().Where(r => r.whcode == input.warehouse_instock).FirstAsync();
if (warehouse_outstock == null) if (warehouse_outstock == null)
{ {
_LoggerErp2Mes.LogWarning($"【MaterialTransfer】无法查询到出库仓库{input.warehouse_outstock}的档案记录!");
return await ToApiResult(HttpStatusCode.InternalServerError, $"无法查询到出库仓库{input.warehouse_outstock}的档案记录!");
} }
if (warehouse_instock == null)
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<WmsMaterialTransferD> wmsMaterialTransferDs = new List<WmsMaterialTransferD>();
foreach (var detail in input.details)
{ {
WmsMaterialTransferD wmsMaterialTransferD = new WmsMaterialTransferD(); _LoggerErp2Mes.LogWarning($"【MaterialTransfer】无法查询到入库仓库{input.warehouse_instock}的档案记录!");
wmsMaterialTransferD.lineno = detail.lineno; return await ToApiResult(HttpStatusCode.InternalServerError, $"无法查询到入库仓库{input.warehouse_instock}的档案记录!");
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<BasMaterial>().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);
} }
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<WmsMaterialTransferD> wmsMaterialTransferDs = new List<WmsMaterialTransferD>();
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<BasMaterial>().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<Result> ToApiResult(HttpStatusCode statusCode, string msg)
{
Result result = new()
{
code = statusCode,
msg = msg
};
return Task.FromResult(result);
}
private static readonly Dictionary<LogLevel, string> 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;
}
} }
} }
} }

View File

@@ -2194,7 +2194,7 @@ namespace Tnb.WarehouseMgr
CarryCodeUnbindInput carryCodeUnbindInput = new CarryCodeUnbindInput(); CarryCodeUnbindInput carryCodeUnbindInput = new CarryCodeUnbindInput();
carryCodeUnbindInput.carry_id = dt.carry_id; carryCodeUnbindInput.carry_id = dt.carry_id;
await _wmsCarryUnbindService.CarryCodeUnbind(carryCodeUnbindInput); await _wmsCarryUnbindService.CarryCodeUnbind(carryCodeUnbindInput, _db);
} }
} }
// 成品调拨入库 // 成品调拨入库

View File

@@ -204,9 +204,14 @@ namespace Tnb.WarehouseMgr
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
/// <exception cref="AppFriendlyException"></exception> /// <exception cref="AppFriendlyException"></exception>
[NonAction] [NonAction]
public async Task<Result> CarryCodeUnbind(CarryCodeUnbindInput input) public async Task<Result> CarryCodeUnbind(CarryCodeUnbindInput input, ISqlSugarClient dbConn = null)
{ {
bool isOk = false; bool isOk = false;
var db = _db;
if (dbConn != null)
db = dbConn;
try try
{ {
if (input == null) if (input == null)
@@ -214,16 +219,17 @@ namespace Tnb.WarehouseMgr
throw new ArgumentNullException(nameof(input)); throw new ArgumentNullException(nameof(input));
} }
WmsCarryH? carry = await _db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id); WmsCarryH? carry = await db.Queryable<WmsCarryH>().SingleAsync(it => it.id == input.carry_id);
if (carry != null) if (carry != null)
{ {
int row = await _db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync(); int row = await db.Deleteable<WmsCarryCode>().Where(r => r.carry_id == input.carry_id).ExecuteCommandAsync();
isOk = row > 0; isOk = row > 0;
if (!isOk) Logger.LogInformation($"【CarryCodeUnbind】载具{carry.carry_code}已解绑,解绑条数{row}");
{ //if (!isOk)
throw Oops.Oh(ErrorCode.COM1001); //{
} // throw Oops.Oh(ErrorCode.COM1001);
//}
} }
else else
{ {

View File

@@ -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.Dtos.VisualDev;
using JNPF.Common.Enums; using JNPF.Common.Enums;
using JNPF.Common.Extension; using JNPF.Common.Extension;
@@ -10,6 +11,7 @@ using JNPF.VisualDev.Entitys;
using JNPF.VisualDev.Interfaces; using JNPF.VisualDev.Interfaces;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using SqlSugar; using SqlSugar;
using Tnb.BasicData.Entities; using Tnb.BasicData.Entities;
using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities;
@@ -377,9 +379,10 @@ namespace Tnb.WarehouseMgr
[HttpPost, NonUnify, AllowAnonymous] [HttpPost, NonUnify, AllowAnonymous]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> FinishproductOutstockSign(FinishproductOutstockSignInput input) public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> 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)) //if (!_wareHouseService.GetFloor1OutstockLocation().Contains(input.location_id))
@@ -390,26 +393,51 @@ namespace Tnb.WarehouseMgr
await _db.Ado.BeginTranAsync(); await _db.Ado.BeginTranAsync();
try try
{ {
WmsCarryH wmsCarryH = _db.Queryable<WmsCarryH>().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<WmsCarryH>().SetColumns(r => new WmsCarryH
{
is_lock = 0,
carry_status = "0"
}).Where(r => r.id == wmsCarryH.id).ExecuteCommandAsync();
await _db.Updateable<BasLocation>().SetColumns(r => new BasLocation await _db.Updateable<BasLocation>().SetColumns(r => new BasLocation
{ {
is_lock = 0, is_lock = 0,
is_use = "0" is_use = "0"
}).Where(r => r.id == input.location_id).ExecuteCommandAsync(); }).Where(r => r.id == wmsCarryH.location_id).ExecuteCommandAsync();
BasLocation location = _db.Queryable<BasLocation>().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<WmsPointH>().SetColumns(r => new WmsPointH await _db.Updateable<WmsPointH>().SetColumns(r => new WmsPointH
{ {
is_lock = 0 is_lock = 0
}).Where(r => r.location_id == input.location_id).ExecuteCommandAsync(); }).Where(r => r.location_id == location.id).ExecuteCommandAsync();
WmsCarryH wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.location_id == input.location_id).First();
CarryCodeUnbindInput carryCodeUnbindInput = new CarryCodeUnbindInput(); CarryCodeUnbindInput carryCodeUnbindInput = new CarryCodeUnbindInput();
carryCodeUnbindInput.carry_id = wmsCarryH.id; 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(); await _db.Ado.CommitTranAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Error($"【FinishproductOutstockSign】 {ex.Message}");
Logger.Error($"【FinishproductOutstockSign】 {ex.StackTrace}");
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message); return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
} }

View File

@@ -574,7 +574,7 @@ namespace Tnb.WarehouseMgr
ptc.code_batch = instockCode.code_batch; ptc.code_batch = instockCode.code_batch;
pretaskCodes.Add(ptc); pretaskCodes.Add(ptc);
} }
bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes); bool isOk = await _wareHouseService.GenPreTask(preTasks, pretaskCodes, _dbScanInStockByRedis);
if (isOk) if (isOk)
{ {
@@ -616,7 +616,7 @@ namespace Tnb.WarehouseMgr
//回更状态 //回更状态
await _wareHouseService.GenInStockTaskHandleAfter(preTaskUpInput, 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 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<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync(); _ = await _dbScanInStockByRedis.Updateable<WmsInstockD>().SetColumns(it => new WmsInstockD { line_status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => instockCode.bill_d_id == it.id).ExecuteCommandAsync();
_ = await _dbScanInStockByRedis.Updateable<WmsInstockH>().SetColumns(it => new WmsInstockH { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == instock!.id).ExecuteCommandAsync(); _ = await _dbScanInStockByRedis.Updateable<WmsInstockH>().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(); await _dbScanInStockByRedis.Ado.CommitTranAsync();
} }
// 测试代码 后期删
catch (AggregateException ex) catch (AggregateException ex)
{ {
Console.WriteLine("【ScanInStockByRedis】 AggregateException" + ex.Message); Console.WriteLine("【ScanInStockByRedis】 AggregateException" + ex.Message);
@@ -637,7 +638,7 @@ namespace Tnb.WarehouseMgr
{ {
Logger.LogInformation($"【ScanInStockByRedis】 八工位扫到码发送入库请求发生异常:{ex.Message}"); Logger.LogInformation($"【ScanInStockByRedis】 八工位扫到码发送入库请求发生异常:{ex.Message}");
// 测试代码 // 测试代码 后期删
if (ex.Message.Contains("Connection is busy")) if (ex.Message.Contains("Connection is busy"))
_dbScanInStockByRedis = _dbScanInStockByRedis.CopyNew(); _dbScanInStockByRedis = _dbScanInStockByRedis.CopyNew();