From 8f9b9411ca279670bd85fcfa7763987295ed9abf Mon Sep 17 00:00:00 2001
From: zhanghonglin <zhanghonglin@hnkhzn.com>
Date: 星期五, 10 四月 2026 10:55:38 +0800
Subject: [PATCH] 空桶入出扩展开发

---
 项目代码/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs |  198 ++++++++++++++-----------------------------------
 1 files changed, 56 insertions(+), 142 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs"
index 85698b5..98cf7f5 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WCS/WIDESEAWCS_Server/WIDESEAWCS_Tasks/Job/ConveyorLineJob.cs"
@@ -12,6 +12,7 @@
 using WIDESEAWCS_Common.TaskEnum;
 using WIDESEAWCS_Core.BaseRepository;
 using WIDESEAWCS_Core.Helper;
+using WIDESEAWCS_Core.LogHelper;
 using WIDESEAWCS_DTO.MES;
 using WIDESEAWCS_DTO.Stock;
 using WIDESEAWCS_ITaskInfoService;
@@ -55,6 +56,8 @@
 
         public Task Execute(IJobExecutionContext context)
         {
+            //鍫嗗灈鏈鸿澶囩姸鎬�
+            int sc = comm.GETR_TaskStatus();
             //杩炴帴璁惧
             bool flag = context.JobDetail.JobDataMap.TryGetValue("JobParams", out object? value);
             if (flag && value != null)
@@ -62,29 +65,30 @@
                 OtherDevice device = (OtherDevice)value;
                 List<string> deviceStations = device.DeviceProDTOs.Select(x => x.DeviceChildCode).Distinct().ToList();
                 List<Dt_StationManger> stationMangers = _stationMangerRepository.QueryData(x => x.StationDeviceCode == device.DeviceCode);
-                //鍏蜂綋璁惧
-                foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
+                try
                 {
-                    i++;
-                    //璇诲彇淇″彿
-                    DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
-                    //DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode ).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
-                    if (deviceProRead != null)
+                    //鍏蜂綋璁惧
+                    foreach (var item in stationMangers.Where(x => deviceStations.Contains(x.StationCode)))
                     {
-                        ConveyorLineCommand conveyorLineInfoRead = device.Communicator.ReadCustomer<ConveyorLineCommand>(deviceProRead.DeviceProAddress);
-                        //绌烘《鍏ュ簱浠诲姟
-                        if (item.StationName == "绌烘《鍏�")
+                        i++;
+                        //璇诲彇淇″彿
+                        DeviceProDTO? deviceProRead = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+                        //DeviceProDTO? deviceProWrite = device.DeviceProDTOs.Where(x => x.DeviceChildCode == item.StationCode ).OrderBy(x => x.DeviceProOffset).FirstOrDefault();
+                        if (deviceProRead != null)
                         {
-                            comm.R_StatusA((short)conveyorLineInfoRead.R_State);
-                            comm.R_PickA((short)conveyorLineInfoRead.R_Pick);
-                            if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+                            ConveyorLineCommand conveyorLineInfoRead = device.Communicator.ReadCustomer<ConveyorLineCommand>(deviceProRead.DeviceProAddress);
+                            //绌烘《鍏ュ簱浠诲姟
+                            if (item.StationName == "绌烘《鍏�")
                             {
-                                try
+                                comm.R_StatusA((short)conveyorLineInfoRead.R_State);
+                                comm.R_PickA((short)conveyorLineInfoRead.R_Pick);
+                                if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1 && sc == 2)
                                 {
                                     //鍒ゆ柇浠诲姟鏄惁閲嶅
                                     Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.InEmpty);
                                     if (task == null)
                                     {
+                                        LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"绌烘《鍏ュ簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State}" });
                                         //WMS鐢熸垚浠诲姟
                                         string address = AppSettings.Get("WMSApiAddress");
                                         if (!string.IsNullOrEmpty(address))
@@ -93,21 +97,13 @@
                                         }
                                     }
                                 }
-                                catch (Exception ex)
-                                {
-                                    //鍐欏叆鏃ュ織
-                                    WriteInfo(device.DeviceCode, $"{ex.Message}");
-                                }
                             }
-                        }
-                        //婊℃《鍏ュ簱浠诲姟
-                        if (item.StationName == "婊℃《鍏�")
-                        {
-                            comm.R_StatusC((short)conveyorLineInfoRead.R_State);
-                            comm.R_PickC((short)conveyorLineInfoRead.R_Pick);
-                            if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+                            //婊℃《鍏ュ簱浠诲姟
+                            if (item.StationName == "婊℃《鍏�")
                             {
-                                try
+                                comm.R_StatusC((short)conveyorLineInfoRead.R_State);
+                                comm.R_PickC((short)conveyorLineInfoRead.R_Pick);
+                                if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1 && sc == 2)
                                 {
                                     //娓呯┖鐗╂枡缂栧彿
                                     if (k)
@@ -125,9 +121,10 @@
                                     Stock.MaterialCode4 = conveyorLineInfoRead.R_NumberD;
 
                                     //鍒ゆ柇浠诲姟鏄惁閲嶅
-                                    Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.Infull);
+                                    Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.Infull || x.TaskType == (int)TaskTypeEnum.OutDirect);
                                     if (task == null)
                                     {
+                                        LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"婊℃《鍏ュ簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State + "//" + conveyorLineInfoRead.R_NumberA + "/" + conveyorLineInfoRead.R_NumberB + "/" + conveyorLineInfoRead.R_NumberC + "/" + conveyorLineInfoRead.R_NumberD}" });
                                         Stock.location = item.location;
                                         //WMS鐢熸垚浠诲姟
                                         string address = AppSettings.Get("WMSApiAddress");
@@ -138,134 +135,51 @@
                                             //鍙戦�佹敹鍒扮紪鍙蜂俊鍙�
                                             device.SetValue(ConveyorLineName.W_ReceivedD, 1, item.StationCode);
                                             k = true;
-
-                                            //鍚慚ES鍙戦�佹姤宸ュ崟
-                                            if (Stock.MaterialCode1 != null && !Stock.MaterialCode1.Equals(""))
-                                            {
-                                                MESReport(Stock.MaterialCode1);
-                                            }
-                                            if (Stock.MaterialCode2 != null && !Stock.MaterialCode2.Equals(""))
-                                            {
-                                                MESReport(Stock.MaterialCode2);
-                                            }
-                                            if (Stock.MaterialCode3 != null && !Stock.MaterialCode3.Equals(""))
-                                            {
-                                                MESReport(Stock.MaterialCode3);
-                                            }
-                                            if (Stock.MaterialCode4 != null && !Stock.MaterialCode4.Equals(""))
-                                            {
-                                                MESReport(Stock.MaterialCode4);
-                                            }
                                         }
 
                                     }
                                 }
-                                catch (Exception ex)
-                                {
-                                    //鍐欏叆鏃ュ織
-                                    WriteInfo(device.DeviceCode, $"{ex.Message}");
-                                }
                             }
-                        }
-                        //绌烘《鍑�
-                        if (item.StationName == "绌烘《鍑�")
-                        {
-                            comm.R_StatusB((short)conveyorLineInfoRead.R_State);
-                            comm.R_PickB((short)conveyorLineInfoRead.R_Pick);
-                            if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+                            //绌烘《鍑�
+                            if (item.StationName == "绌烘《鍑�")
                             {
-                                try
-                                {
-                                    //鍒ゆ柇浠诲姟鏄惁閲嶅
-                                    Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.OutEmpty);
-                                    if (task == null)
-                                    {
-                                        //WMS鐢熸垚浠诲姟
-                                        string address = AppSettings.Get("WMSApiAddress");
-                                        if (!string.IsNullOrEmpty(address))
-                                        {
-                                            HttpHelper.Post($"{address}/api/Task/addOutEmptyTask/?location={item.location}", "");
-                                        }
-                                    }
-                                }
-                                catch (Exception ex)
-                                {
-                                    //鍐欏叆鏃ュ織
-                                    WriteInfo(device.DeviceCode, $"{ex.Message}");
-                                }
+                                comm.R_StatusB((short)conveyorLineInfoRead.R_State);
+                                comm.R_PickB((short)conveyorLineInfoRead.R_Pick);
+                                //if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1 && sc == 2)
+                                //{
+
+                                //    //鍒ゆ柇浠诲姟鏄惁閲嶅
+                                //    Dt_Task task = _TaskRepository.QueryFirst(x => x.TaskType == (int)TaskTypeEnum.OutEmpty);
+                                //    if (task == null)
+                                //    {
+                                //        LogLock.OutLogAOP("杈撻�佺嚎浠诲姟鏃ュ織", new string[] { device.DeviceCode, $"{"绌烘《鍑哄簱浠诲姟鐢熸垚" + "鐢宠鍙�(鏀�)鏂欙細" + conveyorLineInfoRead.R_Pick + "璁惧鐘舵�侊細" + conveyorLineInfoRead.R_State}" });
+                                //        //WMS鐢熸垚浠诲姟
+                                //        string address = AppSettings.Get("WMSApiAddress");
+                                //        if (!string.IsNullOrEmpty(address))
+                                //        {
+                                //            HttpHelper.Post($"{address}/api/Task/addOutEmptyTask/?location={item.location}", "");
+                                //        }
+                                //    }
+
+                                //}
                             }
-                        }
-                        //婊℃《鍑�
-                        if (item.StationName == "婊℃《鍑�")
-                        {
-                            comm.R_StatusD((short)conveyorLineInfoRead.R_State);
-                            comm.R_PickD((short)conveyorLineInfoRead.R_Pick);
-                            //鍛婅瘔WMS鍙互鍑哄簱
-                            if (conveyorLineInfoRead.R_Pick == 1 && conveyorLineInfoRead.R_State == 1)
+                            //婊℃《鍑�
+                            if (item.StationName == "婊℃《鍑�")
                             {
-                                if (m)
-                                {
-                                    //WMS鐢熸垚浠诲姟
-                                    string address = AppSettings.Get("WMSApiAddress");
-                                    if (!string.IsNullOrEmpty(address))
-                                    {
-                                        HttpHelper.Post($"{address}/api/Task/WCSSignal/?k=1", "");
-                                    }
-                                    m = false;
-                                    n = true;
-                                }
-                            }
-                            //鍛婅瘔WMS涓嶅彲浠ュ嚭搴�
-                            else
-                            {
-                                if (n)
-                                {
-                                    //WMS鐢熸垚浠诲姟
-                                    string address = AppSettings.Get("WMSApiAddress");
-                                    if (!string.IsNullOrEmpty(address))
-                                    {
-                                        HttpHelper.Post($"{address}/api/Task/WCSSignal/?k=0", "");
-                                    }
-                                    n = false;
-                                    m = true;
-                                }
+                                comm.R_StatusD((short)conveyorLineInfoRead.R_State);
+                                comm.R_PickD((short)conveyorLineInfoRead.R_Pick);
                             }
                         }
                     }
+                    i = 0;
                 }
-                i = 0;
+                catch (Exception ex)
+                {
+                    //鍐欏叆鏃ュ織
+                    WriteInfo(device.DeviceCode, $"{ex.Message}");
+                }
             }
             return Task.CompletedTask;
-        }
-
-        //MES鎶ュ伐
-        public void MESReport(string MaterialCode)
-        {
-            try
-            {
-                Reports reports = new Reports();
-
-                //鏌ヨ浜岀淮鐮�
-                Dt_FillingOrder FillingOrder = _FillingOrderRepository.QueryFirst(x => x.BarCode == MaterialCode);
-
-                reports.report.Qty = FillingOrder.BarNum;
-                reports.report.DispatchID = FillingOrder.WorkID + "";
-                reports.barcodeSN[0].Barcode = FillingOrder.BarCode;
-                reports.barcodeSN[0].BatchNum = int.Parse(FillingOrder.batchNum);
-                reports.barcodeSN[0].Id = FillingOrder.BarCodeID;
-                reports.barcodeSN[0].MaterialId = FillingOrder.ArticleNumID;
-                reports.barcodeSN[0].Quantity = (int)FillingOrder.BarNum;
-                reports.barcodeSN[0].DispatchId = FillingOrder.WorkID;
-
-                string mes = AppSettings.Get("WMSApiAddress");
-                if (!string.IsNullOrEmpty(mes))
-                {
-                    HttpHelper.Post($"{mes}/Task/SaveReportRaw/", reports.Serialize());
-                }
-            }
-            catch (Exception ex) {
-                WriteInfo( "MES鎶ュ伐閿欒", $"{ex.Message}");
-            }
         }
     }
 }

--
Gitblit v1.9.3