dev
liuwf 1 year ago
parent 50c15c9346
commit a44845ea19

@ -90,6 +90,8 @@ namespace Admin.Core.Tasks
private string storeCode = Appsettings.app("StoreInfo", "BeforeStoreCode");//泡前库code
private List<BaseSpaceInfo> allSpaces = null;
private List<SpaceAddress> spaceAddresses = new List<SpaceAddress>();
private SemaphoreSlim _lock = new SemaphoreSlim(1);
public Job_BoxFoamInStoreTask_Quartz(ISysTasksQzService SysTasksQzService, ISysJobLogService sysJobLogService,
IBaseSpaceInfoServices baseSpaceInfoServices, IRealTaskInfoServices realTaskInfoService,
IProductPlanInfoServices productPlanInfoServices, IRecordInStoreServices recordInstoreServices,
@ -119,7 +121,7 @@ namespace Admin.Core.Tasks
public async Task Execute(IJobExecutionContext context)
{
// 获取任务下发plc
// await ExecuteJob(context, async () => await PassDown(context));
await ExecuteJob(context, async () => await PassDown(context));
// 监测入库,出库完成信号
// await ExecuteJob(context, async () => await RealInstoreFinish(context));
}
@ -140,7 +142,7 @@ namespace Admin.Core.Tasks
if (obj.plc.ReadInt16(spaceAddress.outStoreFinish) == 1)
{
obj.plc.WriteInt16(spaceAddress.outStoreFinish, "0");
// 减货道明细
// 减货道明细
}
}
}
@ -152,39 +154,50 @@ namespace Admin.Core.Tasks
/// <returns></returns>
public async Task PassDown(IJobExecutionContext context)
{
RealTaskInfo taskInfo = await GetAwaitSendTask(storeCode);
if (taskInfo != null)
try
{
logHelper.Info($"下发泡后入库任务:{taskInfo.TaskCode};仓库{taskInfo.StoreCode};货道:{taskInfo.SpaceCode}");
if (SendFoamTask_InStore(taskInfo))
RealTaskInfo taskInfo = await GetAwaitSendTask(storeCode);
if (taskInfo != null)
{
logHelper.Info($"泡后入库任务:{taskInfo.TaskCode}下发成功等待PLC执行反馈");
semaphore.Wait(); //一直堵塞直到信号量释放
logHelper.Info($"箱壳入库任务:{taskInfo.TaskCode};开始执行");
taskInfo.TaskStatus = 2;
await _realTaskInfoService.UpdateAsync(taskInfo);
#region 更新在途数
BaseSpaceInfo spaceInfo = await _baseSpaceInfoServices.GetSpaceInfoBySpaceCode(taskInfo.StoreCode, taskInfo.SpaceCode);
spaceInfo.OnRouteAmount += 1;
_baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo);
#endregion
RefreshInStoreTaskEvent?.Invoke(taskInfo);//刷新datagrid 列表
// logHelper.Info($"泡后入库任务:{taskInfo.TaskCode};执行完成");
// 刷新入库任务列表
logHelper.Info($"下发泡后入库任务:{taskInfo.TaskCode};仓库{taskInfo.StoreCode};货道:{taskInfo.SpaceCode}");
if (SendFoamTask_InStore(taskInfo))
{
logHelper.Info($"泡后入库任务:{taskInfo.TaskCode}下发成功等待PLC执行反馈");
semaphore.Wait(); //一直堵塞直到信号量释放
logHelper.Info($"箱壳入库任务:{taskInfo.TaskCode};开始执行");
taskInfo.TaskStatus = 2;
await _realTaskInfoService.UpdateAsync(taskInfo);
#region 更新在途数
BaseSpaceInfo spaceInfo = await _baseSpaceInfoServices.GetSpaceInfoBySpaceCode(taskInfo.StoreCode, taskInfo.SpaceCode);
spaceInfo.OnRouteAmount += 1;
_baseSpaceInfoServices.UpdateSpaceInfo(spaceInfo);
#endregion
RefreshInStoreTaskEvent?.Invoke(taskInfo);//刷新datagrid 列表
// logHelper.Info($"泡后入库任务:{taskInfo.TaskCode};执行完成");
// 刷新入库任务列表
}
else
{
logHelper.Info($"泡后入库任务:{taskInfo.TaskCode}下发失败请排除PLC连接");
}
}
else
{
logHelper.Info($"泡后入库任务:{taskInfo.TaskCode}下发失败请排除PLC连接");
logHelper.Info("未获取到需要下发的泡后入库任务");
}
}
else
catch (Exception ex)
{
logHelper.Info("未获取到需要下发的泡后入库任务");
logHelper.Info("下发任务异常");
}
}
/// <summary>
/// 获取待执行的入库任务

Loading…
Cancel
Save