#region << 版 本 注 释 >>
|
|
/*----------------------------------------------------------------
|
* 命名空间:WIDESEAWCS_Tasks.ConveyorLineJob
|
* 创建者:胡童庆
|
* 创建时间:2024/8/2 16:13:36
|
* 版本:V1.0.0
|
* 描述:
|
*
|
* ----------------------------------------------------------------
|
* 修改人:
|
* 修改时间:
|
* 版本:V1.0.1
|
* 修改说明:
|
*
|
*----------------------------------------------------------------*/
|
|
#endregion << 版 本 注 释 >>
|
|
using AutoMapper;
|
using HslCommunication;
|
using Newtonsoft.Json;
|
using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
|
using Quartz;
|
using SqlSugar;
|
using System.Net;
|
using System.Reflection;
|
using System.Threading.Tasks;
|
using WIDESEA_Common;
|
using WIDESEAWCS_BasicInfoRepository;
|
using WIDESEAWCS_BasicInfoService;
|
using WIDESEAWCS_Common;
|
using WIDESEAWCS_Common.TaskEnum;
|
using WIDESEAWCS_Core;
|
using WIDESEAWCS_Core.Helper;
|
using WIDESEAWCS_Core.HttpContextUser;
|
using WIDESEAWCS_DTO.TaskInfo;
|
using WIDESEAWCS_ISystemServices;
|
using WIDESEAWCS_ITaskInfoRepository;
|
using WIDESEAWCS_ITaskInfoService;
|
using WIDESEAWCS_Model.Models;
|
using WIDESEAWCS_QuartzJob;
|
using WIDESEAWCS_QuartzJob.DTO;
|
using WIDESEAWCS_QuartzJob.Service;
|
using WIDESEAWCS_SignalR;
|
using WIDESEAWCS_Tasks.ConveyorLineJob;
|
using WIDESEAWCS_Tasks.StackerCraneJob;
|
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
|
using ICacheService = WIDESEAWCS_Core.Caches.ICacheService;
|
|
namespace WIDESEAWCS_Tasks
|
{
|
[DisallowConcurrentExecution]
|
public class CommonConveyorLineTTJob : JobBase, IJob
|
{
|
private readonly ITaskService _taskService;
|
private readonly ITaskRepository _taskRepository;
|
private readonly ITaskExecuteDetailService _taskExecuteDetailService;
|
private readonly IRouterService _routerService;
|
private readonly IMapper _mapper;
|
private readonly IDt_StationManagerService _stationManagerService;
|
private readonly ISys_ConfigService _sys_ConfigService;
|
private readonly ICacheService _cacheService;
|
private readonly INoticeService _noticeService;
|
private readonly IDt_needBarcodeRepository _needBarcodeRepository;
|
private readonly IDt_StationManagerRepository _stationManagerRepository;
|
private static List<string>? userTokenIds;
|
private static List<int>? userIds;
|
|
public CommonConveyorLineTTJob(ITaskService taskService, ITaskExecuteDetailService taskExecuteDetailService, IRouterService routerService, IMapper mapper, ITaskRepository taskRepository, IDt_StationManagerService stationManagerService, ISys_ConfigService sys_ConfigService, ICacheService cacheService, INoticeService noticeService, IDt_needBarcodeRepository needBarcodeRepository, IDt_StationManagerRepository stationManagerRepository)
|
{
|
_taskService = taskService;
|
_taskExecuteDetailService = taskExecuteDetailService;
|
_routerService = routerService;
|
_mapper = mapper;
|
_taskRepository = taskRepository;
|
_stationManagerService = stationManagerService;
|
_sys_ConfigService = sys_ConfigService;
|
_cacheService = cacheService;
|
_noticeService = noticeService;
|
_needBarcodeRepository = needBarcodeRepository;
|
_stationManagerRepository = stationManagerRepository;
|
}
|
|
//static Dictionary<string, string> TCRoadWay = new Dictionary<string, string>()
|
//{
|
// { "TC05", "SC02-SC04" },
|
// { "TC06", "SC06-SC08" },
|
//};
|
|
public async Task Execute(IJobExecutionContext context)
|
{
|
try
|
{
|
CommonConveyorLineTT conveyorLine = (CommonConveyorLineTT)context.JobDetail.JobDataMap.Get("JobParams");
|
if (conveyorLine != null)
|
{
|
List<Dt_StationManager> stationManagers = _stationManagerService.GetAllStationByDeviceCode(conveyorLine.DeviceCode);
|
|
foreach (var station in stationManagers)
|
{
|
var Getrequest = conveyorLine.GetValue<ConveyorLineDBName, bool>(ConveyorLineDBName.Spare1, station.stationChildCode);//横移机空车取料信号
|
if (Getrequest)
|
{
|
Dt_Task task = null;
|
if (station.stationChildCode == "TC05")
|
{
|
//var executeTaks = _taskRepository.QueryData(x => (x.Roadway == "SC02" || x.Roadway == "SC04") && x.TaskState <= (int)TaskOutStatusEnum.SC_OutFinish).OrderBy(x => x.CreateDate).FirstOrDefault();
|
|
var leftTask = _taskRepository.QueryData(x => (x.Roadway == "SC02" || x.Roadway == "SC04") && x.TaskState <= (int)TaskOutStatusEnum.SC_OutFinish).OrderBy(x => x.CreateDate).FirstOrDefault();
|
|
if (leftTask != null && leftTask.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
|
{
|
task = leftTask;
|
}
|
|
if (task != null)
|
{
|
_taskService.UpdateTaskStatusToNext(task.TaskNum, (int)TaskOutStatusEnum.SC_OutFinish);
|
|
var sattion = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress);
|
WriteDebug("CommonConveyorLineTTJob任务", $"任务:{task.Serialize()},站台信息:{sattion.Serialize()}");
|
conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.GetConvNo, Convert.ToInt16(sattion.stationTCLocation), station.stationChildCode);
|
conveyorLine.SetValue<ConveyorLineDBName, string>(ConveyorLineDBName.PVI_W, task.PVI, station.stationChildCode);
|
//conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode);
|
}
|
}
|
else if (station.stationChildCode == "TC06")
|
{
|
var rightTask = _taskRepository.QueryData(x => (x.Roadway == "SC06" || x.Roadway == "SC08") && x.TaskState <= (int)TaskOutStatusEnum.SC_OutFinish).OrderBy(x => x.CreateDate).FirstOrDefault();
|
|
if (rightTask != null && rightTask.TaskState == (int)TaskOutStatusEnum.SC_OutFinish)
|
{
|
task = rightTask;
|
}
|
|
if (task != null)
|
{
|
_taskService.UpdateTaskStatusToNext(task.TaskNum, (int)TaskOutStatusEnum.SC_OutFinish);
|
|
var sattion = _stationManagerRepository.QueryFirst(x => x.stationChildCode == task.CurrentAddress);
|
WriteDebug("CommonConveyorLineTTJob任务", $"任务:{task.Serialize()},站台信息:{sattion.Serialize()}");
|
conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.GetConvNo, Convert.ToInt16(sattion.stationTCLocation), station.stationChildCode);
|
conveyorLine.SetValue<ConveyorLineDBName, string>(ConveyorLineDBName.PVI_W, task.PVI, station.stationChildCode);
|
//conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode);
|
}
|
}
|
}
|
|
var Putrequest = conveyorLine.GetValue<ConveyorLineDBName, bool>(ConveyorLineDBName.Spare2, station.stationChildCode);//横移机载货放车信号
|
if (Putrequest)
|
{
|
//conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode);
|
//todo:请求WMS是否是精排队列首辆车 如不是 不可放行
|
string fristPVI = conveyorLine.GetValue<ConveyorLineDBName, string>(ConveyorLineDBName.PVI_W, station.stationChildCode);
|
if (!String.IsNullOrEmpty(fristPVI))
|
{
|
if (station.stationChildCode == "TC05")
|
{
|
var task = _taskRepository.QueryData(X => X.TargetAddress == "RB043" && (X.NextAddress == station.stationChildCode && X.TaskState == (int)TaskOutStatusEnum.Line_OutExecuting/*|| X.CurrentAddress == station.stationChildCode*/)).OrderBy(x => x.CreateDate).FirstOrDefault();
|
|
if (task != null)
|
{
|
_taskService.UpdatePosition(task.TaskNum, station.stationChildCode);
|
conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode);
|
}
|
}
|
else
|
{
|
var task = _taskRepository.QueryData(X => X.TargetAddress == "RB043").OrderBy(x => x.CreateDate).FirstOrDefault();
|
if (task != null && task.PVI == fristPVI)
|
{
|
_taskService.UpdatePosition(task.TaskNum, station.stationChildCode);
|
conveyorLine.SetValue<ConveyorLineDBName, Int16>(ConveyorLineDBName.AllowRelease, 1, station.stationChildCode);
|
}
|
}
|
}
|
}
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
Console.Out.WriteLine(nameof(CommonConveyorLineTTJob) + ":" + ex.ToString());
|
}
|
finally
|
{
|
//WriteDebug("CommonConveyorLineTTJob", "test");
|
//Console.Out.WriteLine(DateTime.Now);
|
}
|
return;
|
}
|
}
|
}
|