From 3b7569285434bb38736627821f7d7eb34fabca28 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期四, 09 四月 2026 16:32:30 +0800
Subject: [PATCH] 优化海康跨楼层任务,处理设备信息写入失败任务

---
 代码管理/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs |   41 +++++++++++++++++++++++++++++++++++++++--
 1 files changed, 39 insertions(+), 2 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs"
index 21b41a2..8e37567 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Task/TaskJob.cs"
@@ -2,8 +2,10 @@
 using HslCommunication;
 using HslCommunication.Core;
 using Microsoft.VisualBasic.FileIO;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
 using Quartz;
 using SixLabors.ImageSharp.PixelFormats;
+using SqlSugar;
 using System;
 using System.Collections.Generic;
 using System.ComponentModel;
@@ -13,12 +15,15 @@
 using System.Threading.Tasks;
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Communicator;
+using WIDESEAWCS_Core.BaseRepository;
+using WIDESEAWCS_Core.Enums;
 using WIDESEAWCS_Core.Helper;
 using WIDESEAWCS_IBasicInfoService;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
 using WIDESEAWCS_QuartzJob.DeviceBase;
+using WIDESEAWCS_QuartzJob.DTO;
 using WIDESEAWCS_QuartzJob.StackerCrane.Enum;
 
 namespace WIDESEAWCS_Tasks
@@ -29,20 +34,52 @@
         private readonly ITaskService _taskService;
         private readonly IApiInfoService _apiInfoService;
         private readonly IRGVLocationInfoService _rGVLocationInfoService;
-        public TaskJob(ITaskService taskService, IApiInfoService apiInfoService, IRGVLocationInfoService rGVLocationInfoService)
+        private readonly IStationMangerService _stationMangerService;
+        private readonly ITrackloginfoService _trackloginfoService;
+        private readonly IUnitOfWorkManage _unitOfWorkManage;
+        private readonly IAGVCartInfoService _agvcartInfoService;
+
+        public TaskJob(ITaskService taskService, IApiInfoService apiInfoService, IRGVLocationInfoService rGVLocationInfoService, IStationMangerService stationMangerService, ITrackloginfoService trackloginfoService, IUnitOfWorkManage unitOfWorkManage, IAGVCartInfoService agvcartInfoService)
         {
             _taskService = taskService;//娉ㄥ叆
             _apiInfoService = apiInfoService;
             _rGVLocationInfoService = rGVLocationInfoService;
+            _stationMangerService = stationMangerService;
+            _trackloginfoService = trackloginfoService;
+            _unitOfWorkManage = unitOfWorkManage;
+            _agvcartInfoService = agvcartInfoService;
         }
 
         public Task Execute(IJobExecutionContext context)
         {
             try
             {
-                SendTask();
+                SendNewTask();
 
                 SendWaitToTask();
+
+                #region 澶勭悊鍐欏叆璁惧淇″彿寮傚父浠诲姟
+                var tasks = _taskService.Repository.QueryData(x => x.TaskState == TaskStatusEnum.Finish.ObjToInt() && !string.IsNullOrEmpty(x.Remark));
+                if (tasks.Count > 0)
+                {
+                    List<Dt_Task> list = new List<Dt_Task>();
+                    foreach (var item in tasks)
+                    {
+                        var infos = item.Remark.Split("_");
+                        var device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == infos[0]) as OtherDevice;
+                        if (device != null && device.IsConnected)
+                        {
+                            DeviceProDTO? devicePro = device.DeviceProDTOs.FirstOrDefault(x => x.DeviceProParamName == infos[1] && x.DeviceChildCode == infos[3]);
+                            if (devicePro != null)
+                            {
+                                var W = device.Communicator.WriteObj(devicePro.DeviceProAddress, devicePro.DeviceDataType, infos[2]);
+                                if (W) list.Add(item);
+                            }
+                        }
+                    }
+                    _taskService.Repository.DeleteAndMoveIntoHty(list, OperateTypeEnum.鑷姩鍒犻櫎);
+                }
+                #endregion
             }
             catch (Exception ex)
             {

--
Gitblit v1.9.3