This commit is contained in:
2024-06-13 10:28:22 +08:00
parent 89cfac6564
commit dd86185625
7 changed files with 1120 additions and 698 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -111,7 +111,7 @@ namespace Tnb.WarehouseMgr.Interfaces
/// // 二楼机械臂 /// // 二楼机械臂
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
Task<bool> Floor2MechanicalComplete(WmsDistaskH disTask, string action); Task Floor2MechanicalComplete(WmsDistaskH disTask, string action);
/// <summary> /// <summary>
/// 二楼kiva把料架送到下升降机后生成中储仓入库任务 /// 二楼kiva把料架送到下升降机后生成中储仓入库任务

View File

@@ -50,25 +50,39 @@ namespace Tnb.WarehouseMgr
protected IEventPublisher? EventPublisher { set; get; } protected IEventPublisher? EventPublisher { set; get; }
protected ILogger Logger => LoggerFactory.Create(builder => builder.AddFile($"{AppContext.BaseDirectory}/logs/custom{DateTime.Now:yyyyMMdd}.log", cfgOpts => protected string _LoggerFileName = "";
protected ILogger _Logger;
protected ILogger Logger
{ {
get
//cfgOpts.DateFormat = "yyyy-MM-dd HH:mm:ss.fff";
cfgOpts.MessageFormat = (logMsg) =>
{ {
var logLevel = s_logLevelMap[logMsg.LogLevel]; string newFileName = $"{AppContext.BaseDirectory}/logs/custom{DateTime.Now:yyyyMMdd}.log";
var sb = new StringBuilder(); if (_LoggerFileName != newFileName)
_ = sb.Append($"[{logLevel}] "); {
_ = sb.Append($"{logMsg.LogName} "); ILoggerFactory loggerFactory = LoggerFactory.Create(builder => builder.AddFile(newFileName, cfgOpts =>
_ = 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();
};
})).CreateLogger(this.GetType()); //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();
};
}));
_Logger = loggerFactory.CreateLogger(this.GetType());
_LoggerFileName = newFileName;
}
return _Logger;
}
}
static BaseWareHouseService() static BaseWareHouseService()
{ {

View File

@@ -427,11 +427,10 @@ namespace Tnb.WarehouseMgr
[HttpPost, NonUnify, AllowAnonymous] [HttpPost, NonUnify, AllowAnonymous]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> TaskCallback(TaskCallBackInput input) public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> TaskCallback(TaskCallBackInput input)
{ {
var disTask = await _db.Queryable<WmsDistaskH>().FirstAsync(it => it.bill_code == input.taskCode);
Logger.Information($"【TaskCallback】 接收WCS信号 任务状态上报->接收参数:{JsonConvert.SerializeObject(input)}"); Logger.Information($"【TaskCallback】 接收】{input.taskCode} WCS信号 任务状态上报->接收参数:{JsonConvert.SerializeObject(input)}");
try try
{ {
var disTask = await _db.Queryable<WmsDistaskH>().FirstAsync(it => it.bill_code == input.taskCode);
List<WmsDistaskH> disTasks = new() { disTask }; List<WmsDistaskH> disTasks = new() { disTask };
if (input.action == "LOAD") if (input.action == "LOAD")
{ {
@@ -513,7 +512,9 @@ namespace Tnb.WarehouseMgr
await _wareHouseService.SsxControl(disTask, "UNLOAD"); await _wareHouseService.SsxControl(disTask, "UNLOAD");
// 二楼机械臂 // 二楼机械臂
await _wareHouseService.Floor2MechanicalComplete(disTask, "UNLOAD"); await _wareHouseService.Floor2MechanicalComplete(disTask, "UNLOAD");
Logger.Information($"【TaskCallback】 Agv放货完成,任务编号:{string.Join(",", disTasks.Select(x => x.bill_code))}");
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -526,6 +527,7 @@ namespace Tnb.WarehouseMgr
{ {
_ = InvokeGenPretaskExcute(); _ = InvokeGenPretaskExcute();
} }
Logger.Information($"【TaskCallback】 【成功】{input.taskCode} WCS信号 任务状态上报->接收参数:{JsonConvert.SerializeObject(input)}");
return await ToApiResult(HttpStatusCode.OK, "成功"); return await ToApiResult(HttpStatusCode.OK, "成功");
} }

View File

@@ -76,6 +76,7 @@ namespace Tnb.WarehouseMgr
private readonly IRunService _runService; private readonly IRunService _runService;
public static SemaphoreSlim s_floor2CreatePretask = new(1); public static SemaphoreSlim s_floor2CreatePretask = new(1);
public SemaphoreSlim s_taskCommonCreatePretask = new(1);
public Func<string, int, Task> AddUnExecuteTask { get; set; } public Func<string, int, Task> AddUnExecuteTask { get; set; }
@@ -418,12 +419,13 @@ namespace Tnb.WarehouseMgr
getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01" }); getdic.Add("ZSSSXCTU01", new string[] { "YTCS", "AllowAgvEmptyOut_CS01" });
getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03" }); getdic.Add("ZSSSXCTU02", new string[] { "YTCS", "AllowAgvEmptyOut_CS03" });
#region
putdic.Add("ZS-C01-1", new string[] { "hxjC", "A2允许入空箱", }); putdic.Add("ZS-C01-1", new string[] { "hxjC", "A2允许入空箱", });
getdic.Add("ZS-C01-2", new string[] { "hxjC", "A2允许取满箱" }); getdic.Add("ZS-C01-2", new string[] { "hxjC", "A2允许取满箱" });
putdic.Add("ZS-C02-1", new string[] { "hxjC", "A3允许入空箱", }); putdic.Add("ZS-C02-1", new string[] { "hxjC", "A3允许入空箱", });
getdic.Add("ZS-C02-2", new string[] { "hxjC", "A3允许取满箱" }); getdic.Add("ZS-C02-2", new string[] { "hxjC", "A3允许取满箱" });
putdic.Add("ZS-C03-1", new string[] { "hxjC", "A4允许入空箱", }); putdic.Add("ZS-C03-1", new string[] { "hxjC", "A4允许入空箱", });
getdic.Add("ZS-C03-2", new string[] { "hxjC", "A4允许取满箱" }); getdic.Add("ZS-C03-2", new string[] { "hxjC", "A4允许取满箱" });
@@ -435,6 +437,69 @@ namespace Tnb.WarehouseMgr
putdic.Add("ZS-C06-1", new string[] { "hxjC", "A7允许入空箱", }); putdic.Add("ZS-C06-1", new string[] { "hxjC", "A7允许入空箱", });
getdic.Add("ZS-C06-2", new string[] { "hxjC", "A7允许取满箱" }); getdic.Add("ZS-C06-2", new string[] { "hxjC", "A7允许取满箱" });
putdic.Add("ZS-C07-1", new string[] { "hxjC", "A8允许入空箱", });
getdic.Add("ZS-C07-2", new string[] { "hxjC", "A8允许取满箱" });
putdic.Add("ZS-C08-1", new string[] { "hxjC", "A9允许入空箱", });
getdic.Add("ZS-C08-2", new string[] { "hxjC", "A9允许取满箱" });
putdic.Add("ZS-C09-1", new string[] { "hxjC", "A10允许入空箱", });
getdic.Add("ZS-C09-2", new string[] { "hxjC", "A10允许取满箱" });
putdic.Add("ZS-C10-1", new string[] { "hxjC", "A11允许入空箱", });
getdic.Add("ZS-C10-2", new string[] { "hxjC", "A11允许取满箱" });
putdic.Add("ZS-C11-1", new string[] { "hxjC", "A12允许入空箱", });
getdic.Add("ZS-C11-2", new string[] { "hxjC", "A12允许取满箱" });
putdic.Add("ZS-C12-1", new string[] { "hxjC", "A13允许入空箱", });
getdic.Add("ZS-C12-2", new string[] { "hxjC", "A13允许取满箱" });
putdic.Add("ZS-C13-1", new string[] { "hxjC", "A14允许入空箱", });
getdic.Add("ZS-C13-2", new string[] { "hxjC", "A14允许取满箱" });
putdic.Add("ZS-C14-1", new string[] { "hxjC", "A1允许入空箱", });
getdic.Add("ZS-C14-2", new string[] { "hxjC", "A1允许取满箱" });
putdic.Add("ZS-A01-1", new string[] { "hxjA", "A3允许入空箱", });
getdic.Add("ZS-A01-2", new string[] { "hxjA", "A3允许取满箱" });
putdic.Add("ZS-A02-1", new string[] { "hxjA", "A4允许入空箱", });
getdic.Add("ZS-A02-2", new string[] { "hxjA", "A4允许取满箱" });
putdic.Add("ZS-A03-1", new string[] { "hxjA", "A5允许入空箱", });
getdic.Add("ZS-A03-2", new string[] { "hxjA", "A5允许取满箱" });
putdic.Add("ZS-A04-1", new string[] { "hxjA", "A6允许入空箱", });
getdic.Add("ZS-A04-2", new string[] { "hxjA", "A6允许取满箱" });
putdic.Add("ZS-A05-1", new string[] { "hxjA", "A7允许入空箱", });
getdic.Add("ZS-A05-2", new string[] { "hxjA", "A7允许取满箱" });
putdic.Add("ZS-A06-1", new string[] { "hxjA", "A8允许入空箱", });
getdic.Add("ZS-A06-2", new string[] { "hxjA", "A8允许取满箱" });
putdic.Add("ZS-A07-1", new string[] { "hxjA", "A9允许入空箱", });
getdic.Add("ZS-A07-2", new string[] { "hxjA", "A9允许取满箱" });
putdic.Add("ZS-A08-1", new string[] { "hxjA", "A10允许入空箱", });
getdic.Add("ZS-A08-2", new string[] { "hxjA", "A10允许取满箱" });
putdic.Add("ZS-A09-1", new string[] { "hxjA", "A11允许入空箱", });
getdic.Add("ZS-A09-2", new string[] { "hxjA", "A11允许取满箱" });
putdic.Add("ZS-A10-1", new string[] { "hxjA", "A12允许入空箱", });
getdic.Add("ZS-A10-2", new string[] { "hxjA", "A12允许取满箱" });
putdic.Add("ZS-A11-1", new string[] { "hxjA", "A13允许入空箱", });
getdic.Add("ZS-A11-2", new string[] { "hxjA", "A13允许取满箱" });
putdic.Add("ZS-A12-1", new string[] { "hxjA", "A14允许入空箱", });
getdic.Add("ZS-A12-2", new string[] { "hxjA", "A14允许取满箱" });
#endregion
var strs = new string[] { }; var strs = new string[] { };
if (action == "LOAD")//取货 if (action == "LOAD")//取货
@@ -548,7 +613,7 @@ namespace Tnb.WarehouseMgr
["TagName"] = strarr[1], ["TagName"] = strarr[1],
["Value"] = strarr[2], ["Value"] = strarr[2],
}; };
Logger.Information($"SsxControlUNLOAD:{dicCommand}"); Logger.Information($"SsxControlUNLOAD:{JsonConvert.SerializeObject(dicCommand)}");
var str = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand); var str = await HttpClientHelper.GetRequestAsync(_eleCtlCfg.WriteTagUrl, dicCommand);
Logger.Information($"SsxControlUNLOAD:{str}"); Logger.Information($"SsxControlUNLOAD:{str}");
} }
@@ -560,7 +625,7 @@ namespace Tnb.WarehouseMgr
/// 二楼机械臂 /// 二楼机械臂
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public async Task<bool> Floor2MechanicalComplete(WmsDistaskH disTask, string action) public async Task Floor2MechanicalComplete(WmsDistaskH disTask, string action)
{ {
List<string> rackAreaPointsUp = new List<string>(); List<string> rackAreaPointsUp = new List<string>();
List<string> rackAreaPointsDown = new List<string>(); List<string> rackAreaPointsDown = new List<string>();
@@ -573,10 +638,10 @@ namespace Tnb.WarehouseMgr
try { try {
await _db.Ado.BeginTranAsync();
if (disTask.area_code == "E") if (disTask.area_code == "E")
{ {
await _db.Ado.BeginTranAsync();
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】收到到货完成信号 传入参数: {disTask.bill_code} {action}"); Logger.Information($"【二楼机械臂Floor2MechanicalComplete】收到到货完成信号 传入参数: {disTask.bill_code} {action}");
SqlSugarClient db = _db.CopyNew(); SqlSugarClient db = _db.CopyNew();
@@ -589,7 +654,7 @@ namespace Tnb.WarehouseMgr
if (WmsMechanicalArmHs.Count() == 0) if (WmsMechanicalArmHs.Count() == 0)
{ {
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】 任务执行终点{disTask.endpoint_code} 与料架区的点位不匹配"); Logger.Information($"【二楼机械臂Floor2MechanicalComplete】 任务执行终点{disTask.endpoint_code} 与料架区的点位不匹配");
return false; throw new Exception($"【二楼机械臂Floor2MechanicalComplete】 任务执行终点{disTask.endpoint_code} 与料架区的点位不匹配");
} }
WmsMechanicalArmH target = WmsMechanicalArmHs.First(); WmsMechanicalArmH target = WmsMechanicalArmHs.First();
@@ -611,7 +676,7 @@ namespace Tnb.WarehouseMgr
Logger.LogInformation($@"【送满托到下升降区】设定下升降机满托{target.stackingposition}满托数量为 {LXCount} 结果为 {result}"); Logger.LogInformation($@"【送满托到下升降区】设定下升降机满托{target.stackingposition}满托数量为 {LXCount} 结果为 {result}");
if (!result) if (!result)
{ {
return false; throw new Exception($"下升降机满托{target.stackingposition}数量 写入失败");
} }
// 尝试写入满托送到信号 // 尝试写入满托送到信号
@@ -619,7 +684,7 @@ namespace Tnb.WarehouseMgr
Logger.LogInformation($@"【送满托到下升降区】回写 下升降机满托{target.stackingposition}送到 结果为{result下升降机空托送到}"); Logger.LogInformation($@"【送满托到下升降区】回写 下升降机满托{target.stackingposition}送到 结果为{result下升降机空托送到}");
if (!result下升降机空托送到) if (!result下升降机空托送到)
{ {
return false; throw new Exception($"下升降机满托{target.stackingposition}送到 写入失败");
} }
// 绑定料架 // 绑定料架
@@ -671,7 +736,7 @@ namespace Tnb.WarehouseMgr
if (WmsMechanicalArmHs.Count() == 0) if (WmsMechanicalArmHs.Count() == 0)
{ {
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】 任务执行起点{disTask.endpoint_code} 与料架区的点位不匹配"); Logger.Information($"【二楼机械臂Floor2MechanicalComplete】 任务执行起点{disTask.endpoint_code} 与料架区的点位不匹配");
return false; throw new Exception($"【二楼机械臂Floor2MechanicalComplete】 任务执行起点{disTask.endpoint_code} 与料架区的点位不匹配");
} }
WmsMechanicalArmH target = WmsMechanicalArmHs.First(); WmsMechanicalArmH target = WmsMechanicalArmHs.First();
@@ -719,17 +784,15 @@ namespace Tnb.WarehouseMgr
Logger.Information($"【二楼机械臂Floor2MechanicalComplete】{disTask.bill_code} AGV在料架区取货完成"); Logger.Information($"【二楼机械臂Floor2MechanicalComplete】{disTask.bill_code} AGV在料架区取货完成");
} }
} }
await _db.Ado.CommitTranAsync();
} }
await _db.Ado.CommitTranAsync();
return true;
} }
catch(Exception ex) catch(Exception ex)
{ {
Logger.LogError("【Floor2MechanicalComplete】" + ex.ToString());
await _db.Ado.RollbackTranAsync(); await _db.Ado.RollbackTranAsync();
return false; throw;
} }
return false;
} }
private async Task<bool> Floor2UpDownMachinecode_SetTag(string tag, string value) private async Task<bool> Floor2UpDownMachinecode_SetTag(string tag, string value)
@@ -1808,8 +1871,6 @@ namespace Tnb.WarehouseMgr
locIts.Add(loc); locIts.Add(loc);
} }
Logger.Information($@"TaskComplate 更新carryIts: {JsonConvert.SerializeObject(carryIts)}");
Logger.Information($@"TaskComplate 更新carryCodeIts: {JsonConvert.SerializeObject(carryCodeIts)}");
_ = await _db.Updateable(carryIts).UpdateColumns(it => new { it.is_lock, it.location_id, it.location_code }).ExecuteCommandAsync(); _ = await _db.Updateable(carryIts).UpdateColumns(it => new { it.is_lock, it.location_id, it.location_code }).ExecuteCommandAsync();
//更新条码的库位和仓库信息 //更新条码的库位和仓库信息
_ = await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).Where(it => multiList.Select(x => x.carry_id).Contains(it.carry_id)).ExecuteCommandAsync(); _ = await _db.Updateable(carryCodeIts).UpdateColumns(it => new { it.warehouse_id, it.location_id, it.location_code }).Where(it => multiList.Select(x => x.carry_id).Contains(it.carry_id)).ExecuteCommandAsync();
@@ -1869,9 +1930,10 @@ namespace Tnb.WarehouseMgr
} }
} }
} }
Logger.Information($"【TaskComplate】 任务操作完成提交事务 {string.Join(",", input.disTaskIds)}");
await _db.Ado.CommitTranAsync(); await _db.Ado.CommitTranAsync();
Logger.Information("任务操作完成"); Logger.Information($"【TaskComplate】 任务操作完成 {string.Join(",", input.disTaskIds)}");
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -2470,8 +2532,9 @@ namespace Tnb.WarehouseMgr
[HttpPost, NonUnify, AllowAnonymous] [HttpPost, NonUnify, AllowAnonymous]
public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> CommonCreatePretask(CommonCreatePretaskInput input) public async Task<Tnb.WarehouseMgr.Entities.Dto.Outputs.Result> CommonCreatePretask(CommonCreatePretaskInput input)
{ {
using (var db = _db.CopyNew()) //using (var db = _db.CopyNew())
{ {
await s_taskCommonCreatePretask.WaitAsync();
Logger.LogInformation($"【createPretask】 接收到请求 参数:{JsonConvert.SerializeObject(input)}"); Logger.LogInformation($"【createPretask】 接收到请求 参数:{JsonConvert.SerializeObject(input)}");
try try
{ {
@@ -2481,11 +2544,11 @@ namespace Tnb.WarehouseMgr
if (!string.IsNullOrEmpty(input.startlocation_id)) if (!string.IsNullOrEmpty(input.startlocation_id))
{ {
sPoint = await db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.startlocation_id); sPoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.startlocation_id);
} }
if (!string.IsNullOrEmpty(input.endlocation_id)) if (!string.IsNullOrEmpty(input.endlocation_id))
{ {
ePoint = await db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.endlocation_id); ePoint = await _db.Queryable<WmsPointH>().FirstAsync(it => it.location_id == input.endlocation_id);
} }
List<WmsPointH> points = new List<WmsPointH>(); List<WmsPointH> points = new List<WmsPointH>();
@@ -2520,14 +2583,14 @@ namespace Tnb.WarehouseMgr
// 如果指定了carry_id // 如果指定了carry_id
else if (!string.IsNullOrEmpty(input.carry_id)) else if (!string.IsNullOrEmpty(input.carry_id))
{ {
wmsCarryH = db.Queryable<WmsCarryH>().Where(r => r.id == input.carry_id).First(); wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.id == input.carry_id).First();
carry_id = wmsCarryH.id; carry_id = wmsCarryH.id;
carry_code = wmsCarryH.carry_code; carry_code = wmsCarryH.carry_code;
} }
// carry_code // carry_code
else if (!string.IsNullOrEmpty(input.carry_code)) else if (!string.IsNullOrEmpty(input.carry_code))
{ {
wmsCarryH = db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).First(); wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).First();
carry_id = wmsCarryH.id; carry_id = wmsCarryH.id;
carry_code = wmsCarryH.carry_code; carry_code = wmsCarryH.carry_code;
} }
@@ -2596,7 +2659,7 @@ namespace Tnb.WarehouseMgr
}; };
//根据载具移入Id回更单据状态 //根据载具移入Id回更单据状态
_ = await db.Updateable<WmsMoveInstock>().SetColumns(it => new WmsMoveInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync(); _ = await _db.Updateable<WmsMoveInstock>().SetColumns(it => new WmsMoveInstock { status = WmsWareHouseConst.BILLSTATUS_ON_ID }).Where(it => it.id == preTaskUpInput.RquireId).ExecuteCommandAsync();
Expression<Func<WmsCarryH, WmsCarryH>> wmsCarryHChangeExp = a => new WmsCarryH { is_lock = 1 }; Expression<Func<WmsCarryH, WmsCarryH>> wmsCarryHChangeExp = a => new WmsCarryH { is_lock = 1 };
@@ -2625,6 +2688,7 @@ namespace Tnb.WarehouseMgr
} }
finally finally
{ {
s_taskCommonCreatePretask.Release();
if (input.isExcuteMission) if (input.isExcuteMission)
{ {
GenTaskExecute(); GenTaskExecute();

View File

@@ -13,6 +13,7 @@ using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json; using Newtonsoft.Json;
using Npgsql;
using Senparc.Weixin.MP.AdvancedAPIs.Card; using Senparc.Weixin.MP.AdvancedAPIs.Card;
using SqlSugar; using SqlSugar;
using Tnb.WarehouseMgr.Entities; using Tnb.WarehouseMgr.Entities;
@@ -165,14 +166,25 @@ namespace Tnb.WarehouseMgr
WmsCarryCode.is_out = 0; WmsCarryCode.is_out = 0;
WmsCarryCodes.Add(WmsCarryCode); WmsCarryCodes.Add(WmsCarryCode);
} }
int rows = 0;
if (WmsCarryCodes.Count > 0) if (WmsCarryCodes.Count > 0)
await _db.Insertable(WmsCarryCodes).ExecuteCommandAsync(); rows = await _db.Insertable(WmsCarryCodes).ExecuteCommandAsync();
if (rows == 0)
{
throw new Exception($"接收到{input.details.Count}个条码 但是成功绑定的条码数量为0个");
}
}
catch (PostgresException ex)
{
Logger.LogError(ex.Message);
Logger.LogError(ex.StackTrace);
throw new AppFriendlyException($"绑定失败(1.可能是存在已被绑定的条码 2.存在与此载具编号相同的载具 3.存在字段传了空值) {ex.Message}", 500);
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogError(ex.Message); Logger.LogError(ex.Message);
Logger.LogError(ex.StackTrace); Logger.LogError(ex.StackTrace);
throw new AppFriendlyException("绑定失败", 500); throw new AppFriendlyException($"绑定失败 {ex.Message}", 500);
} }
} }

View File

@@ -15,6 +15,7 @@ using Mapster;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Npgsql;
using SqlSugar; using SqlSugar;
using Tnb.BasicData.Entities; using Tnb.BasicData.Entities;
using Tnb.Common.Utils; using Tnb.Common.Utils;
@@ -305,7 +306,7 @@ namespace Tnb.WarehouseMgr
/// <summary> /// <summary>
/// 载具绑定物料 /// 载具绑定物料(MES用)
/// </summary> /// </summary>
/// <param name="input"></param> /// <param name="input"></param>
/// <exception cref="ArgumentNullException"></exception> /// <exception cref="ArgumentNullException"></exception>
@@ -314,7 +315,7 @@ namespace Tnb.WarehouseMgr
{ {
try try
{ {
WmsCarryCode wmsCarryCode = new WmsCarryCode(); WmsCarryCode wmsCarryCode = input.Adapt<WmsCarryCode>();
wmsCarryCode.org_id = WmsWareHouseConst.AdministratorOrgId; wmsCarryCode.org_id = WmsWareHouseConst.AdministratorOrgId;
wmsCarryCode.create_time = DateTime.Now; wmsCarryCode.create_time = DateTime.Now;
wmsCarryCode.carry_id = input.carry_id; wmsCarryCode.carry_id = input.carry_id;
@@ -329,13 +330,23 @@ namespace Tnb.WarehouseMgr
wmsCarryCode.unit_id = input.unit_id; wmsCarryCode.unit_id = input.unit_id;
wmsCarryCode.unit_code = input.unit_code; wmsCarryCode.unit_code = input.unit_code;
wmsCarryCode.create_id = input.create_id; wmsCarryCode.create_id = input.create_id;
await _db.Insertable<WmsCarryCode>(wmsCarryCode).ExecuteCommandAsync(); int rows = await _db.Insertable<WmsCarryCode>(wmsCarryCode).ExecuteCommandAsync();
if (rows == 0)
{
throw new Exception($"接收到1个条码 但是成功绑定的条码数量为0个");
}
await _db.Updateable<WmsCarryH>().SetColumns(r => r.carry_status == ((int)EnumCarryStatus.).ToString()).Where(r => r.id == input.carry_id).ExecuteCommandAsync();
// todo 绑定记录表 // todo 绑定记录表
return await ToApiResult(HttpStatusCode.OK, "成功"); return await ToApiResult(HttpStatusCode.OK, "成功");
} }
catch (PostgresException ex)
{
Logger.LogError(ex.Message);
Logger.LogError(ex.StackTrace);
throw new AppFriendlyException($"绑定失败(1.可能是存在已被绑定的条码 2.存在与此载具编号相同的载具 3.存在字段传了空值) {ex.Message}", 500);
}
catch (Exception ex) catch (Exception ex)
{ {
Logger.LogInformation(ex.Message); Logger.LogInformation(ex.Message);