1
z8018
2025-06-10 e46aa927d231af83724683c7286d9db503e24cf7
ÏîÄ¿´úÂë/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/ConveyorLineJob/CommonConveyorLineStationJob.cs
@@ -37,6 +37,18 @@
namespace WIDESEAWCS_Tasks
{
    /// <summary>
    /// é€šç”¨è¾“送线站台任务类,用于处理输送线站台的PLC信号交互和任务管理
    /// </summary>
    /// <remarks>
    /// 1. å®žçްIJob接口,作为Quartz.NET的定时任务 <br/>
    /// 2. é€šè¿‡DisallowConcurrentExecution特性防止并发执行 <br/>
    /// 3. ä¸»è¦åŠŸèƒ½ï¼š <br/>
    ///    - ç›‘控PLC站台请求信号 <br/>
    ///    - å¤„理任务重新生成逻辑 <br/>
    ///    - æ›´æ–°ä»»åŠ¡çŠ¶æ€ <br/>
    ///    - è®¾ç½®PLC响应信号
    /// </remarks>
    [DisallowConcurrentExecution]
    public class CommonConveyorLineStationJob : JobBase, IJob
    {
@@ -44,19 +56,21 @@
        private readonly ITaskRepository _taskRepository;
        public CommonConveyorLineStationJob(IMapper mapper, ITaskRepository taskRepository)
        private readonly ITaskService _taskService;
        public CommonConveyorLineStationJob(IMapper mapper, ITaskRepository taskRepository, ITaskService taskService)
        {
            _mapper = mapper;
            _taskRepository = taskRepository;
            _taskService = taskService;
        }
        public Task Execute(IJobExecutionContext context)
        {
            bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
            if (flag && value != null && value is OtherDevice)
            if (flag && value != null && value is OtherDevice otherDevice)
            {
                OtherDevice otherDevice = (OtherDevice)value;
                try
                {
                    List<string> deviceChildCodes = otherDevice.DeviceProDTOs.GroupBy(x => x.DeviceChildCode).Select(x => x.Key).ToList();
@@ -64,7 +78,6 @@
                    {
                        bool request = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.PLCStationRequest, deviceChildCodes[i]);   //申请
                        bool response = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.PLCStationResponse, deviceChildCodes[i]);    //应答
                        bool wcsResponse = otherDevice.GetValue<ConveyorLineStationDBName, bool>(ConveyorLineStationDBName.WCSStationResponse, deviceChildCodes[i]);    //应答
                        if (request && !response && !wcsResponse)
@@ -75,8 +88,22 @@
                                Dt_Task task = _taskRepository.QueryFirst(x => x.TaskNum == taskNum);
                                if (task != null)
                                {
                                    task.TaskState = TaskStatusEnum.Gantry_New.ObjToInt();
                                    _taskRepository.UpdateData(task);
                                    if (task.TaskState == TaskStatusEnum.Gantry_BeReassign.ObjToInt())
                                    {
                                        var (taskFlag, gTask, message) = _taskService.RegenerateTask(task, deviceChildCodes[i]);
                                        if (!taskFlag || gTask == null)
                                        {
                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, 8, deviceChildCodes[i]);
                                            otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true, deviceChildCodes[i]);
                                            continue;
                                        }
                                    }
                                    else
                                    {
                                        task.TaskState = TaskStatusEnum.Gantry_New.ObjToInt();
                                        _taskRepository.UpdateData(task);
                                    }
                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationTarget, 0, deviceChildCodes[i]);
                                    otherDevice.SetValue(ConveyorLineStationDBName.WCSStationResponse, true, deviceChildCodes[i]);
                                }