From f7781420ef5b7406be4945562c6483b7e0d35893 Mon Sep 17 00:00:00 2001
From: czw <selecti@yeah.net>
Date: 星期一, 30 六月 2025 11:51:32 +0800
Subject: [PATCH] 1

---
 2025年6月12日/AuxAllWCS/Build/Project/代码/ViewModel.cs |  263 ----------------------------------------------------
 1 files changed, 2 insertions(+), 261 deletions(-)

diff --git "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs" "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs"
index 3b6c8bb..92da2fb 100644
--- "a/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs"
+++ "b/2025\345\271\2646\346\234\21012\346\227\245/AuxAllWCS/Build/Project/\344\273\243\347\240\201/ViewModel.cs"
@@ -128,267 +128,8 @@
             HaiKangOrderInfo model = (HaiKangOrderInfo)param1;
             if (string.IsNullOrEmpty(model.taskCode))
                 return;
-            // 鏌ヨ浠诲姟锛氭牴鎹换鍔″彿
-            //var wcsTask = WCSHelper.GetTask(model.taskCode);
-            ITaskRepository MainMissionService = new TaskRepository();
-            var wcsTask = MainMissionService.FindEntity(x => model.taskCode == x.S_TASK_NO);
-            if (wcsTask != null)
-            {
-                if (!string.IsNullOrWhiteSpace(model.method))
-                {
-                    ILocRepository locrep = new LocRepository();
-                    var startloc = locrep.FindEntity(x => x.S_LOC_CODE == wcsTask.S_START_LOC);
-                    var endLoc = locrep.FindEntity(x => x.S_LOC_CODE == wcsTask.S_END_LOC);
-
-                    List<string> cntrs = wcsTask.S_CNTRS.Split(',').ToList();
-                    bool bobe = false;
-                    //model.method = model.method?.ToLower();
-                    switch (model.method)
-                    {
-                        case "start":
-                            LogHelper.Info($"娴峰悍杞︿换鍔$姸鎬佸彉鏇翠负鎵ц锛屼换鍔″彿涓猴細{model.taskCode}", "agv鏉弶浜や簰鏃ュ織");
-                            if (wcsTask.S_B_STATE.Trim() == "宸叉帹閫�)
-                            {
-                                wcsTask.S_B_STATE = "鎵ц涓�;
-                                wcsTask.T_START_TIME = DateTime.Now;
-                                MainMissionService.Update(wcsTask);
-                                bobe = true;
-                            }
-                            break;
-                        case "outBin":
-                        case "outbin":
-                            model.method = model.method?.ToLower();
-                            LogHelper.Info($"娴峰悍杞︿换鍔$姸鎬佸彉鏇翠负鍙栬揣瀹屾垚锛屼换鍔″彿涓猴細{model.taskCode}", "agv鏉弶浜や簰鏃ュ織");
-                            wcsTask.S_B_STATE = "鍙栬揣瀹屾垚";
-
-                            startloc.N_CURRENT_NUM = 0;
-                            startloc.S_LOCK_STATE = "鏃�;
-                            startloc.T_MODIFY = DateTime.Now;
-                            //ILocContainerRepository locContainerRepository = new LocContainerRepository();
-                            ////var cnr = locContainerRepository.FindList(x => cntrs.Contains(x.S_CNTR_CODE.Trim()) && x.S_LOC_CODE == wcsTask.S_START_LOC);
-                            //locContainerRepository.Delete(x => cntrs.Contains(x.S_CNTR_CODE.Trim()) && x.S_LOC_CODE == wcsTask.S_START_LOC);
-                            MainMissionService.Update(wcsTask);
-                            locrep.Update(startloc);
-
-                            bobe = true;
-                            var device = Settings.deviceInfos.Find(x => x.location.Contains(wcsTask.S_START_LOC));
-                            if (device != null)
-                            {
-                                if (device.deviceType == 1)
-                                {
-                                    if (device.deviceName.Contains("缁村笇灏旀姄鑷�))
-                                    {  //鍗歌揣杩涜娓呯┖锛岃Е鍙戞壂鐮�-                                        var inde = device.location.ToList().FindIndex(x => x == wcsTask.S_START_LOC) == 0;
-                                        string V = inde ? "R05" : "R06";
-                                        Conn.榛樿Redis.SetValue(device.deviceName + "." + V, "true", device.deviceName + "Queue", false);
-
-                                        TcpServer.TrayIps.Remove(device.deviceNo[inde ? 0 : 1]);
-                                    }
-                                }
-                                else if (device.deviceType == 2)
-                                {
-                                    //Task.Run(() =>
-                                    //{
-                                    //    var inde = device.location.ToList().FindIndex(x => x == wcsTask.S_START_LOC) == 0;
-                                    //    string V = inde ? "D1224" : "D1225";
-                                    //    Conn.榛樿Redis.SetValue(device.deviceName + "." + V, "0", device.deviceName + "Queue");
-                                    //});
-                                }
-                            }
-                            //LocationHelper.UnLockLoc(wcsTask.S_START_LOC);
-                            break;
-                        case "end":
-                            LogHelper.Info($"娴峰悍杞︿换鍔$姸鎬佸彉鏇翠负瀹屾垚锛屼换鍔″彿涓猴細{model.taskCode}", "agv鏉弶浜や簰鏃ュ織");
-                            wcsTask.S_B_STATE = "瀹屾垚";
-                            wcsTask.T_END_TIME = DateTime.Now;
-
-                            bobe = true;
-                            //ILocContainerRepository locContainerRepository2 = new LocContainerRepository();
-                            //List<LocContainerEntity> llls = new List<LocContainerEntity>();
-                            //foreach (var c in cntrs)
-                            //{
-                            //    var action = new LocContainerEntity()
-                            //    {
-                            //        S_ID = Guid.NewGuid().ToString(),
-                            //        S_STATE = "缂栬緫",
-                            //        T_CREATE = DateTime.Now,
-                            //        T_MODIFY = DateTime.Now,
-
-                            //        S_LOC_CODE = endLoc.S_LOC_CODE,
-                            //        S_CNTR_CODE = c,
-                            //        S_TYPE = "",
-                            //    };
-                            //    llls.Add(action);
-                            //}
-
-                            endLoc.S_LOCK_STATE = "鏃�;
-                            endLoc.N_CURRENT_NUM = 1;
-                            endLoc.T_MODIFY = DateTime.Now;
-                            MainMissionService.Update(wcsTask);
-                            if (Settings.deviceInfos.Find(x => x.deviceType == 2 && (/*x.location.Contains(wcsTask.S_END_LOC)||*/x.deviceNo.Contains(wcsTask.S_END_LOC))) != null)
-                                locrep.Update(endLoc);
-                            //locContainerRepository2.Insert(llls);
-
-                            var device2 = Settings.deviceInfos.Find(x => x.location.Contains(wcsTask.S_END_LOC));
-                            if (device2 != null)
-                            {
-                                if (device2.deviceType == 1)
-                                {
-                                    if (device2.deviceName.Contains("缁村笇灏旀姄鑷�))
-                                    {
-                                        //string V = device2.location.ToList().FindIndex(x => x == wcsTask.S_START_LOC) == 0 ? "R10" : "R11";
-                                        //Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "true", device2.deviceName + "Queue");
-                                        //鍗歌揣鍐嶅啓鎵樼洏鍙栬蛋銆�鐒跺悗瑙﹀彂鎵爜杩涜鏍¢獙銆�
-                                        var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0;
-                                        //string V = inde ? "R05" : "R06";
-                                        //Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "true", device2.deviceName + "Queue");
-                                        string V2 = inde ? "R10_LAST" : "R11_LAST";
-                                        //Conn.榛樿Redis.SetValue(device2.deviceName + "." + V2, "true", device2.deviceName + "Queue");
-
-                                        GZ.Modular.Redis.RedisHelper.Add(device2.deviceName + "." + V2, "true", out string msg1);
-                                        TcpServer.TrayIps.Remove(device2.deviceNo[inde ? 0 : 1]);
-                                    }
-                                }
-                                else if (device2.deviceType == 2)
-                                {
-                                    if (device2.deviceName.Contains("Js鎹烽『"))
-                                    {
-                                        Task.Run(() =>
-                                        {
-                                            var inde = device2.location.ToList().FindIndex(x => x == wcsTask.S_END_LOC) == 0;
-                                            string V = inde ? "D1224" : "D1225";
-                                            Conn.榛樿Redis.SetValue(device2.deviceName + "." + V, "1", device2.deviceName + "Queue");
-                                        });
-
-                                        var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/202", JsonConvert.SerializeObject(new
-                                        {
-                                            sceneType = 3,
-                                            cntrCode = cntrs.FirstOrDefault()
-                                        }));
-                                        //if (device2.deviceName.Contains("1"))
-                                        //{
-                                        //    if (inde) tag.Js1.D1224 = 1;
-                                        //    else tag.Js1.D1225 = 1;
-                                        //}else
-                                        //{
-                                        //    if (inde) tag.Js2.D1224 = 1;
-                                        //    else tag.Js2.D1225 = 1;
-                                        //}
-                                    }
-                                    var ssloc = device2.deviceNo[1];
-                                    var endloc = locrep.FindEntity(x => x.S_LOC_CODE == ssloc);
-                                    LogHelper.Info($"鎹烽『鍗歌揣鍚庯紝 鏌ョ湅缂撳瓨浣�{ssloc}-{endloc?.N_CURRENT_NUM}>0? 鍒欑敵璇穖es鎼蛋銆�);
-                                    if (endloc != null && endloc.N_CURRENT_NUM == 1)
-                                    {
-                                        var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/200", JsonConvert.SerializeObject(new
-                                        {
-                                            requestType = 3,
-                                            startBit = ssloc
-                                        }));
-                                        LogHelper.Info($"{ssloc}鐢宠mes浠诲姟缁撴灉{str}");
-                                    }
-                                }
-                            }
-
-                            //LocationMethod.JudgeLocation(wcsTask);
-                            break;
-                        case "cancel":
-                            LogHelper.Info($"娴峰悍杞︿换鍔$姸鎬佸彉鏇翠负鍙栨秷锛屼换鍔″彿涓猴細{model.taskCode}", "agv鏉弶浜や簰鏃ュ織");
-                            wcsTask.S_B_STATE = "鍙栨秷";
-                            //startloc.S_LOCK_STATE = "鏃�;
-                            //endLoc.S_LOCK_STATE = "鏃�;
-                            MainMissionService.Update(wcsTask);
-                            TaskActRepository taskActRepository = new TaskActRepository();
-                            var tare = taskActRepository.FindList(x => x.S_TASK_NO == wcsTask.S_TASK_NO);
-                            if (tare.Any())
-                            {
-                                if (tare.Find(x => x.S_ACTION_CODE == "outbin") == null)
-                                {
-                                    startloc.S_LOCK_STATE = "鏃�;
-                                    endLoc.S_LOCK_STATE = "鏃�;
-                                    locrep.Update(startloc);
-                                    locrep.Update(endLoc);
-                                }
-                                else if (tare.Find(x => x.S_ACTION_CODE == "end") == null)
-                                {
-                                    endLoc.S_LOCK_STATE = "鏃�;
-                                    locrep.Update(endLoc);
-                                }
-                            }
-
-                            //locrep.Update(startloc);
-                            //locrep.Update(endLoc);
-                            //TaskProcess.OperateStatus(wcsTask, 7);
-                            //WCSHelper.Fail(wcsTask);
-                            break;
-                        case "apply":
-                            // 鍒ゆ柇璇ヤ换鍔$殑鎺ラ┏浣嶆槸鍚︽湁鍏朵粬鍏ュ簱鎴栧嚭搴撲换鍔★紝濡傛灉鏈夛紝鍒欏湪绛変綅绛夊緟锛屽鏋滄病鏈夛紝鍒欏叆
-                            TaskisOk(wcsTask);
-                            break;
-                    }
-
-                    if (!string.IsNullOrEmpty(wcsTask.S_SRC_NO))
-                    {
-                        var mestask = MainMissionService.FindEntity(x => x.S_TASK_NO == wcsTask.S_SRC_NO);
-                        if (mestask != null && bobe)
-                        {
-                            if (model.method != "end")
-                            {
-                                if (mestask.S_START_LOC == wcsTask.S_START_LOC && mestask.S_B_STATE == "MES")
-                                    Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
-                                    {
-                                        reqCode = wcsTask.S_SRC_NO,
-                                        model.method
-                                    }));
-                            }
-                            else
-                            {
-                                if (mestask.S_END_LOC != wcsTask.S_END_LOC)
-                                {
-                                    LogHelper.Info($"{wcsTask.S_SRC_NO}-{wcsTask.S_TASK_NO} 涓�樁娈靛畬鎴愶紝閲嶇疆杩涜浜岄樁娈点�");
-                                    mestask.N_PRIORITY = -88;
-                                    MainMissionService.Update(mestask);
-                                }
-                                else if (mestask.S_B_STATE == "MES")
-                                {
-                                    var str = Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
-                                    {
-                                        reqCode = wcsTask.S_SRC_NO,
-                                        model.method
-                                    }));
-                                }
-                            }
-
-                        }
-                        else if (mestask != null && model.method == "cancel")
-                        {
-                            if (mestask.S_B_STATE == "MES")
-                                Settings.apiHelper.Post(Settings.WMSbaseUrl + "mom-basic/dataTransmission/json/service/201", JsonConvert.SerializeObject(new
-                                {
-                                    reqCode = wcsTask.S_SRC_NO,
-                                    model.method
-                                }));
-                            LogHelper.Info($"{wcsTask.S_SRC_NO}-{wcsTask.S_TASK_NO} 涓�樁娈靛彇娑堬紝閲嶇疆鐐癸紝绾跨▼澶勭悊銆�);
-                            mestask.N_PRIORITY = -1;
-                            mestask.S_B_STATE = "MES_鍙栨秷";
-                            MainMissionService.Update(mestask);
-                        }
-                    }
-                    TaskProcess.AddActionRecord(model.taskCode, model.method, model.eqpCode, model.data, wcsTask.S_START_LOC, wcsTask.S_END_LOC);
-                    //璋冪敤绗笁鏂规帴鍙o紙濡傛灉鏈夛級TaskProcess.ReportStatus
-                }
-                else
-                {
-                    // 鏆傛椂璁惧畾涓�
-                    wcsTask.S_B_STATE = "涓婃姤鐘舵�绌�;
-                    //瀹夊叏璇锋眰绛�-                    //TaskProcess.OperateReq(model.taskCode, wcsTask.N_B_STATE, model.eqpCode, model.data);
-                }
-            }
-            else
-            {
-                LogHelper.Info($"褰撳墠浠诲姟鍙蜂换鍔′笉瀛樺湪{model.taskCode} agv鏉弶浜や簰鏃ュ織");
-            }
+            var hkr = AutoThread.InvokeMethod(AutoThread.Instance, "OperateHKTaskStatus", new object[] { model });
+            //return JsonConvert.SerializeObject(hkr);
             #endregion [鑷畾涔夋寚浠[20250324165239206][OperateHKTaskStatus]
         }
         public GZ.DB.Entity.OIDATABASE.TaskEntity Begin(GZ.DB.Entity.OIDATABASE.TaskEntity task)

--
Gitblit v1.9.1