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

Loading…
Cancel
Save