Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
@@ -2063,7 +2063,7 @@ namespace Tnb.ProductionMgr
|
||||
});
|
||||
|
||||
Log.Information($"生产入库参数:${JsonConvert.SerializeObject(wmsPrdInstockInput)}");
|
||||
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsPrdInstockHService.PrdInstock(wmsPrdInstockInput);
|
||||
Tnb.WarehouseMgr.Entities.Dto.Outputs.Result result2 = await _wmsPrdInstockHService.PrdInstock(wmsPrdInstockInput, _db);
|
||||
if (result2 != null)
|
||||
{
|
||||
Log.Information($"生产入库接口返回参数:${JsonConvert.SerializeObject(result2)}");
|
||||
|
||||
@@ -23,5 +23,10 @@
|
||||
/// 终点库位
|
||||
/// </summary>
|
||||
public string? endlocation_id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 载具
|
||||
/// </summary>
|
||||
public string? carry_code { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,9 +76,9 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IRunService _runService;
|
||||
|
||||
public static SemaphoreSlim s_floor2CreatePretask = new(1);
|
||||
public SemaphoreSlim s_taskCommonCreatePretask = new(1);
|
||||
public SemaphoreSlim s_taskGenPreTask = new(1);
|
||||
public SemaphoreSlim s_GenTaskExecute = new(1);
|
||||
public static SemaphoreSlim s_taskCommonCreatePretask = new(1);
|
||||
public static SemaphoreSlim s_taskGenPreTask = new(1);
|
||||
public static SemaphoreSlim s_GenTaskExecute = new(1);
|
||||
|
||||
public Func<string, int, Task> AddUnExecuteTask { get; set; }
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@ using Aop.Api.Domain;
|
||||
using Senparc.Weixin.Work.AdvancedAPIs.OaDataOpen;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Org.BouncyCastle.Asn1.X509;
|
||||
using Tnb.ProductionMgr.Entities;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
@@ -548,12 +549,48 @@ namespace Tnb.WarehouseMgr
|
||||
Logger.LogWarning($"【CallRackToProductionLine】不存在工位id为{input.workstation_id}的工位!");
|
||||
throw new AppFriendlyException($"不存在工位id为{input.workstation_id}的工位!", 500);
|
||||
}
|
||||
WmsCarryH wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.work_station == organizeEntity.EnCode).First();
|
||||
//WmsCarryH wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.work_station == organizeEntity.EnCode).First();
|
||||
//if (wmsCarryH == null)
|
||||
//{
|
||||
// Logger.LogWarning($"【CallRackToProductionLine】不存在工位为{organizeEntity.EnCode}的料架号!");
|
||||
// throw new AppFriendlyException($"不存在工位为{organizeEntity.EnCode}的料架号!", 500);
|
||||
//}
|
||||
|
||||
WmsCarryH wmsCarryH = _db.Queryable<WmsCarryH>().Where(r => r.carry_code == input.carry_code).First();
|
||||
if (wmsCarryH == null)
|
||||
{
|
||||
Logger.LogWarning($"【CallRackToProductionLine】不存在工位为{organizeEntity.EnCode}的料架号!");
|
||||
throw new AppFriendlyException($"不存在编码为{organizeEntity.EnCode}的料架号!", 500);
|
||||
Logger.LogWarning($"【CallRackToProductionLine】不存在料架号为{input.carry_code}的料架!");
|
||||
throw new AppFriendlyException($"【CallRackToProductionLine】不存在料架号为{input.carry_code}的料架!", 500);
|
||||
}
|
||||
|
||||
// 获取产线
|
||||
OrganizeEntity organizeEntityCX = _db.Queryable<OrganizeEntity>().Where(r => r.Id == organizeEntity.ParentId).First();
|
||||
if (organizeEntityCX == null)
|
||||
{
|
||||
Logger.LogWarning($"【CallRackToProductionLine】基础资料错误!工位{organizeEntity.EnCode}的上级产线不存在,请检查!");
|
||||
throw new AppFriendlyException($"【CallRackToProductionLine】基础资料错误!工位{organizeEntity.EnCode}的上级产线不存在,请检查!", 500);
|
||||
}
|
||||
|
||||
if (organizeEntityCX.Category != "workline")
|
||||
{
|
||||
Logger.LogWarning($"【CallRackToProductionLine】基础资料错误!工位{organizeEntity.EnCode}的上级{organizeEntityCX.EnCode}不属于产线类型,请检查!");
|
||||
throw new AppFriendlyException($"【CallRackToProductionLine】基础资料错误!工位{organizeEntity.EnCode}的上级{organizeEntityCX.EnCode}不属于产线类型,请检查!", 500);
|
||||
}
|
||||
|
||||
// 获取任务单
|
||||
|
||||
List<PrdMoTask> organizeEntityCXs = _db.Queryable<PrdMoTask>().Where(r => r.workline_code == organizeEntityCX.EnCode).ToList();
|
||||
if (organizeEntityCXs.Count > 1)
|
||||
{
|
||||
Logger.LogWarning($"【CallRackToProductionLine】工位{organizeEntity.EnCode}的上级{organizeEntityCX.EnCode}对应的进行中的任务单不唯一,请检查!");
|
||||
throw new AppFriendlyException($"【CallRackToProductionLine】工位{organizeEntity.EnCode}的上级{organizeEntityCX.EnCode}对应的进行中的任务单不唯一,请检查!", 500);
|
||||
}
|
||||
if (organizeEntityCXs.Count == 0)
|
||||
{
|
||||
Logger.LogWarning($"【CallRackToProductionLine】未找到工位{organizeEntity.EnCode}的上级{organizeEntityCX.EnCode}对应的进行中的任务单,请检查!");
|
||||
throw new AppFriendlyException($"【CallRackToProductionLine】未找到工位{organizeEntity.EnCode}的上级{organizeEntityCX.EnCode}对应的进行中的任务单,请检查!", 500);
|
||||
}
|
||||
PrdMoTask prdMoTask = organizeEntityCXs.First();
|
||||
//if (string.IsNullOrEmpty(wmsCarryH.work_station))
|
||||
//{
|
||||
// Logger.LogWarning($"【CallRackToProductionLine】此料架目标工位为空!{input.carry_code}");
|
||||
@@ -588,6 +625,8 @@ namespace Tnb.WarehouseMgr
|
||||
commonCreatePretaskInput.carry_code = wmsCarryH.carry_code;
|
||||
commonCreatePretaskInput.task_type = "";
|
||||
commonCreatePretaskInput.biz_type = "FloorCallMaterial";
|
||||
commonCreatePretaskInput.require_id = prdMoTask.id;
|
||||
commonCreatePretaskInput.require_code = prdMoTask.mo_task_code;
|
||||
|
||||
var res = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput);
|
||||
if (res.code != JNPF.Common.Enums.HttpStatusCode.OK)
|
||||
|
||||
@@ -628,12 +628,17 @@ namespace Tnb.WarehouseMgr
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
Console.WriteLine("【ScanInStockByRedis】 AggregateException" + ex.Message);
|
||||
Logger.LogInformation($"【ScanInStockByRedis】 AggregateException" + ex.Message);
|
||||
_dbScanInStockByRedis = _dbScanInStockByRedis.CopyNew();
|
||||
await _dbScanInStockByRedis.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.LogInformation($"【ScanInStockByRedis】 八工位扫到码发送入库请求发生异常:{ex.Message}");
|
||||
if (ex.Message.Contains("Connection is busy"))
|
||||
_dbScanInStockByRedis = _dbScanInStockByRedis.CopyNew();
|
||||
|
||||
await _dbScanInStockByRedis.Ado.RollbackTranAsync();
|
||||
throw;
|
||||
}
|
||||
|
||||
@@ -54,14 +54,17 @@ namespace Tnb.WarehouseMgr
|
||||
/// </summary>
|
||||
/// <param name="input"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<Entities.Dto.Outputs.Result> PrdInstock(WmsPrdInstockInput input)
|
||||
public async Task<Entities.Dto.Outputs.Result> PrdInstock(WmsPrdInstockInput input, ISqlSugarClient dbConn = null)
|
||||
{
|
||||
Logger.LogInformation($"【PrdInstock】传入参数 {JsonConvert.SerializeObject(input)}");
|
||||
var db = _db;
|
||||
if (dbConn != null)
|
||||
db = dbConn;
|
||||
try
|
||||
{
|
||||
await _db.Ado.BeginTranAsync();
|
||||
await db.Ado.BeginTranAsync();
|
||||
|
||||
WmsPrdInstockH prdInstockH = _db.Queryable<WmsPrdInstockH>().Where(r => r.prd_bill_code == input.prd_bill_code).First();
|
||||
WmsPrdInstockH prdInstockH = db.Queryable<WmsPrdInstockH>().Where(r => r.prd_bill_code == input.prd_bill_code).First();
|
||||
|
||||
string prd_instock_code_id = "";
|
||||
string type = "";
|
||||
@@ -85,7 +88,7 @@ namespace Tnb.WarehouseMgr
|
||||
wmsPrdInstockH.type = input.type;
|
||||
//wmsPrdInstockH.status = WmsWareHouseConst.BILLSTATUS_ADD_ID;
|
||||
|
||||
await _db.Insertable(wmsPrdInstockH).ExecuteCommandAsync();
|
||||
await db.Insertable(wmsPrdInstockH).ExecuteCommandAsync();
|
||||
|
||||
prd_instock_code_id = wmsPrdInstockH.id;
|
||||
type = input.type;
|
||||
@@ -94,7 +97,7 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
prd_instock_code_id = prdInstockH.id;
|
||||
|
||||
await _db.Updateable<WmsPrdInstockH>(r => new WmsPrdInstockH
|
||||
await db.Updateable<WmsPrdInstockH>(r => new WmsPrdInstockH
|
||||
{
|
||||
pqty = input.pqty,
|
||||
rqty = input.rqty
|
||||
@@ -135,9 +138,9 @@ namespace Tnb.WarehouseMgr
|
||||
});
|
||||
}
|
||||
|
||||
await _db.Insertable(WmsPrdInstockDs).ExecuteCommandAsync();
|
||||
await db.Insertable(WmsPrdInstockDs).ExecuteCommandAsync();
|
||||
|
||||
await _db.Insertable(WmsPrdInstockCodes).ExecuteCommandAsync();
|
||||
await db.Insertable(WmsPrdInstockCodes).ExecuteCommandAsync();
|
||||
|
||||
foreach (WmsPrdInstockD wmsPrdInstockD in WmsPrdInstockDs)
|
||||
{
|
||||
@@ -150,7 +153,7 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
BasLocation endLocation = endLocations[0];
|
||||
|
||||
BasLocation startLocation = _db.Queryable<BasLocation>().Where(r => r.id == wmsPrdInstockD.startlocation_id).First();
|
||||
BasLocation startLocation = db.Queryable<BasLocation>().Where(r => r.id == wmsPrdInstockD.startlocation_id).First();
|
||||
if (startLocation == null)
|
||||
{
|
||||
throw new AppFriendlyException("系统中找不到起点ID的库位信息", 500);
|
||||
@@ -165,8 +168,8 @@ namespace Tnb.WarehouseMgr
|
||||
Logger.LogInformation($"【PrdInstock】注塑车间生产提报");
|
||||
// 注塑线边库到2,4输送线
|
||||
// 根据ZSSSXCTU01 ZSSSXCTU02任务数平均分配任务
|
||||
endlocation_ssx = await _db.Queryable<BasLocation>().Where(r => new string[2] { "32624148726549", "32624157608981" }.Contains(r.id)).OrderBy("is_lock, task_nums, location_code").FirstAsync();
|
||||
await _db.Updateable<BasLocation>().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => endlocation_ssx.id == it.id).ExecuteCommandAsync();
|
||||
endlocation_ssx = await db.Queryable<BasLocation>().Where(r => new string[2] { "32624148726549", "32624157608981" }.Contains(r.id)).OrderBy("is_lock, task_nums, location_code").FirstAsync();
|
||||
await db.Updateable<BasLocation>().SetColumns(it => it.task_nums == it.task_nums + 1).Where(it => endlocation_ssx.id == it.id).ExecuteCommandAsync();
|
||||
|
||||
// ZSSSXCTU01 对应 SSX-011-002
|
||||
if (endlocation_ssx.location_code == "ZSSSXCTU01")
|
||||
@@ -179,7 +182,7 @@ namespace Tnb.WarehouseMgr
|
||||
startlocation_id_ssx = "32609093546005";
|
||||
}
|
||||
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
|
||||
WmsCarryH wmsCarryH = await db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
|
||||
|
||||
// 生成到输送线任务
|
||||
CommonCreatePretaskInput commonCreatePretaskInput1 = new CommonCreatePretaskInput();
|
||||
@@ -191,7 +194,7 @@ namespace Tnb.WarehouseMgr
|
||||
commonCreatePretaskInput1.biz_type = "";
|
||||
commonCreatePretaskInput1.require_id = wmsPrdInstockD.id;
|
||||
commonCreatePretaskInput1.isExcuteMission = false;
|
||||
Entities.Dto.Outputs.Result res1 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput1);
|
||||
Entities.Dto.Outputs.Result res1 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput1, db);
|
||||
if (res1.code != HttpStatusCode.OK)
|
||||
{
|
||||
throw new Exception($"注塑车间生成到输送线的任务失败 {res1.msg}");
|
||||
@@ -208,7 +211,7 @@ namespace Tnb.WarehouseMgr
|
||||
commonCreatePretaskInput2.require_id = wmsPrdInstockD.id;
|
||||
commonCreatePretaskInput2.isChangeCarryLoc2StartLoc = false;
|
||||
|
||||
Entities.Dto.Outputs.Result res2 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput2);
|
||||
Entities.Dto.Outputs.Result res2 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput2, db);
|
||||
if (res2.code != HttpStatusCode.OK)
|
||||
{
|
||||
throw new Exception($"注塑车间生成到中储仓的任务失败 {res2.msg}");
|
||||
@@ -217,7 +220,7 @@ namespace Tnb.WarehouseMgr
|
||||
else if (type == "25019172714005")
|
||||
{
|
||||
Logger.LogInformation($"【PrdInstock】挤出车间生产提报");
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
|
||||
WmsCarryH wmsCarryH = await db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
|
||||
|
||||
// 生成到中储仓任务
|
||||
CommonCreatePretaskInput commonCreatePretaskInput2 = new CommonCreatePretaskInput();
|
||||
@@ -230,7 +233,7 @@ namespace Tnb.WarehouseMgr
|
||||
commonCreatePretaskInput2.require_id = wmsPrdInstockD.id;
|
||||
commonCreatePretaskInput2.isChangeCarryLoc2StartLoc = false;
|
||||
|
||||
Entities.Dto.Outputs.Result res2 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput2);
|
||||
Entities.Dto.Outputs.Result res2 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput2, db);
|
||||
if (res2.code != HttpStatusCode.OK)
|
||||
{
|
||||
throw new Exception($"挤出车间生成到中储仓的任务失败 {res2.msg}");
|
||||
@@ -239,7 +242,7 @@ namespace Tnb.WarehouseMgr
|
||||
else if (type == "25019191681045")
|
||||
{
|
||||
Logger.LogInformation($"【PrdInstock】包装车间生产提报");
|
||||
WmsCarryH wmsCarryH = await _db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
|
||||
WmsCarryH wmsCarryH = await db.Queryable<WmsCarryH>().Where(r => r.id == wmsPrdInstockD.carry_id).FirstAsync();
|
||||
|
||||
// 生成到中储仓任务
|
||||
CommonCreatePretaskInput commonCreatePretaskInput2 = new CommonCreatePretaskInput();
|
||||
@@ -252,7 +255,7 @@ namespace Tnb.WarehouseMgr
|
||||
commonCreatePretaskInput2.require_id = wmsPrdInstockD.id;
|
||||
commonCreatePretaskInput2.isChangeCarryLoc2StartLoc = false;
|
||||
|
||||
Entities.Dto.Outputs.Result res2 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput2);
|
||||
Entities.Dto.Outputs.Result res2 = await _wareHouseService.CommonCreatePretask(commonCreatePretaskInput2, db);
|
||||
if (res2.code != HttpStatusCode.OK)
|
||||
{
|
||||
throw new Exception($"包装车间生成到中储仓的任务失败 {res2.msg}");
|
||||
@@ -262,13 +265,13 @@ namespace Tnb.WarehouseMgr
|
||||
}
|
||||
|
||||
|
||||
await _db.Ado.CommitTranAsync();
|
||||
await db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Error(ex.Message);
|
||||
Logger.Error(ex.StackTrace);
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
await db.Ado.RollbackTranAsync();
|
||||
return await ToApiResult(HttpStatusCode.InternalServerError, ex.Message);
|
||||
}
|
||||
finally
|
||||
|
||||
Reference in New Issue
Block a user