From 5729bfa51a9e8a4781755233324d7e9d002295c0 Mon Sep 17 00:00:00 2001
From: qinchulong <qinchulong@hnkhzn.com>
Date: 星期日, 02 三月 2025 18:58:35 +0800
Subject: [PATCH] 1

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs |   98 +++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 83 insertions(+), 15 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs"
index 507f500..03eda49 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/GZJ/GZJJob.cs"
@@ -15,8 +15,11 @@
 using System.Reflection;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Communicator;
+using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_ISystemServices;
 using WIDESEAWCS_ITaskInfoService;
 using WIDESEAWCS_Model.Models;
 using WIDESEAWCS_QuartzJob;
@@ -30,11 +33,21 @@
     public class GZJJob : JobBase, IJob
     {
         private readonly ITaskService _taskService;
+        private readonly Idt_ErrormsginfoService _ErrormsginfoService;
+        private readonly IRepository<dt_stationInfo> _dt_stationInfoRepository;
+        private readonly IRepository<Dt_Task> _dt_taskRepositiry;
+
         WebSocketServer _webSocketServer;
-        public GZJJob(ITaskService taskService, WebSocketServer webSocketServer)
+        public GZJJob(ITaskService taskService, WebSocketServer webSocketServer, Idt_ErrormsginfoService errormsginfoService,
+            Idt_StationinfoService stationinfoService,
+            IRepository<dt_stationInfo> dt_stationInfoRepository,
+            IRepository<Dt_Task> dt_taskRepositiry)
         {
             _taskService = taskService;//娉ㄥ叆
             _webSocketServer = webSocketServer;
+            _ErrormsginfoService = errormsginfoService;
+            _dt_stationInfoRepository = dt_stationInfoRepository;
+            _dt_taskRepositiry = dt_taskRepositiry;
         }
 
         public Task Execute(IJobExecutionContext context)
@@ -46,25 +59,80 @@
                 OtherDevice device = (OtherDevice)value;
                 try
                 {
-                    //Example
-                    //device.GetValue  璇诲彇
-                    //device.SetValue  鍐欏叆
-                    //_taskService.Repository; //浠撳偍灞傦紝杩涜鏁版嵁搴撹闂�
-                    OHTReadData oHTReadData = new OHTReadData();
-                    //todo:璇诲彇璁惧鏁版嵁锛�
-
-
-                    //todo:璁惧鐘舵�佹暟鎹彂閫佺粰鍓嶇
-                  
-
+                    #region 鐢熸垚鍏ュ簱浠诲姟
+                    if (!OHTJob.oHTReadData.R_GZJ_isWork)
+                    {
+                        throw new Exception($"瑙勬暣鏈烘姇鍏ヤ娇鐢ㄤ俊鍙蜂负false");
+                    }
+                    Dt_Task task = new Dt_Task();
                     
-                    //WriteInfo(device.DeviceName, "infoLog");
+                    if (OHTJob.oHTReadData.R_RGVMode && OHTJob.oHTReadData.R_DK_isready)//RGV涓婃枡妯″紡锛屼笖涓滆法鏋跺瓙鏈変笂鏂欎俊鍙�
+                    {
+                        var station=_dt_stationInfoRepository.QueryFirst(v=>v.msg== "涓滆法鏋跺瓙");
+                        task.SourceAddress = station.Row + "-" + station.Column + "-1";
+                        task.TargetAddress = "";
+                        task.Grade = 1;
+                        task.Remark = (int)MateTypeEnum.ZiChan;
+                    }
+                    else if (OHTJob.oHTReadData.R_RGVMode && OHTJob.oHTReadData.R_XK_isready)//RGV涓婃枡妯″紡锛屼笖瑗胯法鏋跺瓙鏈変笂鏂欎俊鍙�
+                    {
+                        var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "瑗胯法鏋跺瓙");
+                        task.SourceAddress = station.Row + "-" + station.Column + "-1";
+                        task.TargetAddress = "";
+                        var DKstation = _dt_stationInfoRepository.QueryFirst(v => v.msg == "涓滆法鏋跺瓙");
+                        string address= DKstation.Row + "-" + DKstation.Column + "-1";
+                        var oldtask = _dt_taskRepositiry.QueryFirst(v=>v.SourceAddress== address);
+                        if (oldtask!=null && oldtask.TaskState== (int)TaskInStatusEnum.InNew)
+                        {
+                            task.Grade = 2;
+                        }
+                        else
+                        {
+                            task.Grade = 1;
+                        }
+                        task.Remark = (int)MateTypeEnum.ZiChan;
+                    }
+                    else if (OHTJob.oHTReadData.R_CCMode && OHTJob.oHTReadData.R_XK_isready)//浜哄伐鍙夎溅涓婃枡妯″紡锛屼笖瑗胯法鏋跺瓙鏈変笂鏂欎俊鍙�
+                    {
+                        var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "瑗胯法鏋跺瓙");
+                        task.SourceAddress = station.Row + "-" + station.Column + "-1";
+                        task.TargetAddress = "";
+                        task.Grade = 1;
+                        task.Remark = (int)MateTypeEnum.WaiGou;
+                    }
+                    else if (OHTJob.oHTReadData.R_CCMode && OHTJob.oHTReadData.R_DK_isready)//浜哄伐鍙夎溅涓婃枡妯″紡锛屼笖涓滆法鏋跺瓙鏈変笂鏂欎俊鍙�
+                    {
+                        var station = _dt_stationInfoRepository.QueryFirst(v => v.msg == "涓滆法鏋跺瓙");
+                        task.SourceAddress = station.Row + "-" + station.Column + "-1";
+                        task.TargetAddress = "";
+                        var XKstation = _dt_stationInfoRepository.QueryFirst(v => v.msg == "瑗胯法鏋跺瓙");
+                        string address= XKstation.Row + "-" + XKstation.Column + "-1";
+                        var oldtask = _dt_taskRepositiry.QueryFirst(v => v.SourceAddress == address);
+                        if (oldtask != null && oldtask.TaskState == (int)TaskInStatusEnum.InNew)
+                        {
+                            task.Grade = 2;
+                        }
+                        else
+                        {
+                            task.Grade = 1;
+                        }
+                        task.Remark = (int)MateTypeEnum.WaiGou;
+                    }
+                    else
+                    {
+                        throw new Exception($"瑙勬暣鏈哄綋鍓嶄俊鍙蜂笉婊¤冻鍏ュ簱浠诲姟鐢熸垚鏉′欢");
+                    }
+                    task.Roadway = "TC01";
+                    task.TaskType = (int)TaskInboundTypeEnum.Inbound;
+                    task.TaskState = (int)TaskInStatusEnum.InNew;
 
-                    //WriteDebug(device.DeviceName, "debugLog");
+                    _dt_taskRepositiry.AddData(task);
+
+                    #endregion
                 }
                 catch (Exception ex)
                 {
-                    WriteError(device.DeviceName, "閿欒", ex);
+                    _ErrormsginfoService.UpdateErrorMsg(ex.Message, 2);
                 }
             }
 

--
Gitblit v1.9.3