生产提报加锁
This commit is contained in:
@@ -76,6 +76,7 @@ namespace Tnb.ProductionMgr
|
||||
private readonly IWmsCarryService _wmsCarryService;
|
||||
private readonly ElevatorControlConfiguration _eleCtlCfg = App.Configuration.Build<ElevatorControlConfiguration>();
|
||||
private readonly RedisData _redisData;
|
||||
private static SemaphoreSlim prdreportSemaphore = new(1);
|
||||
|
||||
public OverideVisualDevFunc OverideFuncs { get; } = new OverideVisualDevFunc();
|
||||
public PrdMoTaskService(
|
||||
@@ -1609,32 +1610,34 @@ namespace Tnb.ProductionMgr
|
||||
[HttpPost]
|
||||
public async Task<dynamic> PrdReport(PrdReportCrInput input)
|
||||
{
|
||||
Log.Information($"生产提报参数:{JsonConvert.SerializeObject(input)}");
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdMoTask? prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
EqpEquipment equip = await db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
|
||||
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdMoTask.material_id);
|
||||
PrdReport report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
|
||||
if (basMaterial == null)
|
||||
{
|
||||
throw Oops.Bah($"未找到物料{prdMoTask.material_id}");
|
||||
}
|
||||
|
||||
Dictionary<String, String> dic = new Dictionary<string, string>()
|
||||
{
|
||||
["30019971917589"] = "外包装箱码垛线"
|
||||
};
|
||||
|
||||
Dictionary<String, String> dic2 = new Dictionary<string, string>()
|
||||
{
|
||||
[WmsWareHouseConst.XUELUGUAN1XIAN] = "WBZX_x1_Enquantity",
|
||||
[WmsWareHouseConst.XUELUGUAN2XIAN] = "WBZX_x2_Enquantity"
|
||||
};
|
||||
string materialBoxCode = input.material_box_code;
|
||||
BasLocation location = null;
|
||||
await prdreportSemaphore.WaitAsync();
|
||||
try
|
||||
{
|
||||
Log.Information($"生产提报参数:{JsonConvert.SerializeObject(input)}");
|
||||
ISqlSugarClient db = _repository.AsSugarClient();
|
||||
PrdMoTask? prdMoTask = await db.Queryable<PrdMoTask>().SingleAsync(x => x.id == input.mo_task_id);
|
||||
EqpEquipment equip = await db.Queryable<EqpEquipment>().SingleAsync(x => x.id == prdMoTask.eqp_id);
|
||||
BasMaterial basMaterial = await db.Queryable<BasMaterial>().SingleAsync(x => x.id == prdMoTask.material_id);
|
||||
PrdReport report = await db.Queryable<PrdReport>().FirstAsync(it => it.mo_task_id == input.mo_task_id);
|
||||
|
||||
if (basMaterial == null)
|
||||
{
|
||||
throw Oops.Bah($"未找到物料{prdMoTask.material_id}");
|
||||
}
|
||||
|
||||
Dictionary<String, String> dic = new Dictionary<string, string>()
|
||||
{
|
||||
["30019971917589"] = "外包装箱码垛线"
|
||||
};
|
||||
|
||||
Dictionary<String, String> dic2 = new Dictionary<string, string>()
|
||||
{
|
||||
[WmsWareHouseConst.XUELUGUAN1XIAN] = "WBZX_x1_Enquantity",
|
||||
[WmsWareHouseConst.XUELUGUAN2XIAN] = "WBZX_x2_Enquantity"
|
||||
};
|
||||
string materialBoxCode = input.material_box_code;
|
||||
BasLocation location = null;
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
int row = -1;
|
||||
PrdMo prdMo = await db.Queryable<PrdMo>().SingleAsync(x => x.id == prdMoTask.mo_id);
|
||||
@@ -2181,6 +2184,9 @@ namespace Tnb.ProductionMgr
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
throw Oops.Bah("提报失败:"+ex.Message);
|
||||
}
|
||||
finally{
|
||||
prdreportSemaphore.Release();
|
||||
}
|
||||
|
||||
// DbResult<bool> result = await _repository.AsSugarClient().Ado.UseTranAsync(async () =>
|
||||
// {
|
||||
|
||||
Reference in New Issue
Block a user