From f46e8e10c579b92a807b10fa00f5076f33198ce8 Mon Sep 17 00:00:00 2001
From: lss <2538410689@qq.com>
Date: 星期三, 23 七月 2025 14:04:09 +0800
Subject: [PATCH] 大车间

---
 HH.WCS.Mobox3 - 大车间/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs |  322 +++++++++++++++++------------------------------------
 1 files changed, 104 insertions(+), 218 deletions(-)

diff --git "a/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs" "b/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs"
index 5acf75e..4cdb138 100644
--- "a/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs"
+++ "b/HH.WCS.Mobox3 - \345\244\247\350\275\246\351\227\264/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs"
@@ -1,9 +1,9 @@
-锘縰sing HH.WCS.JiaTong.device;
-using HH.WCS.JiaTong.dispatch;
-using HH.WCS.JiaTong.LISTA.models;
-using HH.WCS.JiaTong.process;
-using HH.WCS.JiaTong.util;
-using HH.WCS.JiaTong.wms;
+锘縰sing HH.WCS.JiaTong_DCJ.device;
+using HH.WCS.JiaTong_DCJ.dispatch;
+using HH.WCS.JiaTong_DCJ.LISTA.models;
+using HH.WCS.JiaTong_DCJ.process;
+using HH.WCS.JiaTong_DCJ.util;
+using HH.WCS.JiaTong_DCJ.wms;
 using Newtonsoft.Json;
 using NLog.Fluent;
 using S7.Net;
@@ -17,12 +17,12 @@
 using System.Threading;
 using System.Threading.Tasks;
 using System.Web.UI.WebControls;
-using static HH.WCS.JiaTong.api.ApiModel;
-using static HH.WCS.JiaTong.api.OtherModel;
-using static HH.WCS.JiaTong.LISTA.process.HttpModel;
-using static HH.WCS.JiaTong.util.Settings;
+using static HH.WCS.JiaTong_DCJ.api.ApiModel;
+using static HH.WCS.JiaTong_DCJ.api.OtherModel;
+using static HH.WCS.JiaTong_DCJ.LISTA.process.HttpModel;
+using static HH.WCS.JiaTong_DCJ.util.Settings;
 
-namespace HH.WCS.JiaTong.api
+namespace HH.WCS.JiaTong_DCJ.api
 {
     /// <summary>
     /// api鎺ュ彛杈呭姪绫�@@ -105,7 +105,7 @@
                         n_type = 2;
                         Source = "棰勫搴�;
                         break;
-                 
+
                 }
                 Console.WriteLine($"Createtask==>浠诲姟鏉ユ簮:{n_type}");
                 if (n_type == 0)
@@ -123,222 +123,108 @@
                 Location startloc = null;
                 lock (_lockCreateTask)
                 {
-                    if (taskData.taskType == 1) //鍑哄簱娴佺▼锛岄�杩囩墿鏂欐満鍙拌绠楃嚎杈硅揣浣�+                    note = "鍑哄簱";
+                    //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅
+                    startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
+                    if (startloc != null)
                     {
-                        note = "鍑哄簱";
-                        startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
-                        if (startloc != null)
-                        {
-                            //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅
-                            Start = taskData.pickStation;
-                            if (CreateCntrIteminfo(partData, taskData))
-                            {
-                                endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType);
-                                if (endloc != null)
-                                {
-                                    End = endloc.S_CODE;
-                                }
-                                else
-                                {
-                                    result.code = "1";
-                                    result.msg = $"鏈哄彴缂栫爜:{taskData.dropStation}锛屾湭鎵惧埌鍙敤璐т綅";
-                                    AddErrorInfo("瀵绘壘鍑哄簱璐т綅澶辫触", result.msg, Source);
-                                    return result;
-                                }
-
-                                //endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First();
-                                //if (endloc != null)
-                                //{
-                                //    End = taskData.dropStation;
-                                //}
-                                //else
-                                //{
-                                //    result.code = "1";
-                                //    result.msg = $"鏍规嵁缁堢偣{End},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                                //    AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
-                                //    return result;
-                                //}
-                            }
-                            else
-                            {
-                                result.code = "1";
-                                result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触";
-                                AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source);
-                                return result;
-                            }
-
-
-                        }
-                        else
-                        {
-
-                            result.code = "1";
-                            result.msg = $"Putin==> 浠诲姟璧风偣:{taskData.pickStation}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                            LogHelper.Info($"Putin==> {result.msg}");
-                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
-                            return result;
-                        }
+                        Start = taskData.pickStation;
                     }
-                    else if (taskData.taskType == 2)//鍏ュ簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛岃捣鐐归渶瑕佹湁鎵樼洏
-                    {
-                        note = "鍏ュ簱";
-                        startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
-                        if (startloc != null)
-                        {
-                            Start = startloc.S_CODE;
-                            var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault();
-                            if (CntrRel != null)
-                            {
-                                if (CntrRel.S_CNTR_CODE != partData.rfid)
-                                {
-                                    result.code = "1";
-                                    result.msg = $"鏍规嵁璧风偣锛歿Start}鑾峰彇鎵樼洏:{CntrRel.S_CNTR_CODE}涓庝笅鍙戞墭鐩橈細{partData.rfid}涓嶄竴鑷达紝璇锋鏌ユ墭鐩樼爜鏄惁姝g‘";
-                                    AddErrorInfo("鎵樼洏鐮佹牎妫�け璐�, result.msg, Source);
-                                    return result;
-                                }
-                                else
-                                {
-                                    CntrCode = CntrRel.S_CNTR_CODE;
-                                }
-
-                            }
-
-                        }
-                        else
-                        {
-                            result.code = "1";
-                            result.msg = $"鏍规嵁璧风偣{taskData.pickStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
-                            return result;
-                        }
-
-                        endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First();
-                        if (endloc != null)
-                        {
-                            End = taskData.dropStation;
-                        }
-                        else
-                        {
-                            result.code = "1";
-                            result.msg = $"鏍规嵁缁堢偣{End},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
-                            return result;
-                        }
-                    }
-                    else if (taskData.taskType == 3)//绉诲簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛�-                    {
-                        note = "鍑哄簱";
-                        //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅
-                        startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
-                        if (startloc != null)
-                        {
-                            Start = taskData.pickStation;
-                        }
-                        else
-                        {
-                            result.code = "1";
-                            result.msg = $"鏍规嵁璧风偣{taskData.pickStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
-                            return result;
-                        }
-                        endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First();
-                        if (endloc != null)
-                        {
-                            End = taskData.dropStation;
-                        }
-                        else
-                        {
-                            result.code = "1";
-                            result.msg = $"鏍规嵁缁堢偣{taskData.dropStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
-                            return result;
-                        }
-                    }
-           
                     else
                     {
-                        LogHelper.Info($"Createtask==> 浠诲姟绫诲瀷鏈夎");
                         result.code = "1";
-                        result.msg = "浠诲姟绫诲瀷锛歿taskData.taskType}涓嶅湪瑙勫畾鑼冨洿鍐�;
-                        AddErrorInfo("浠诲姟绫诲瀷閿欒", result.msg, Source);
+                        result.msg = $"鏍规嵁璧风偣{taskData.pickStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
+                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
+                        return result;
                     }
-                
-                        if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End))
-                        {
-                            if (startloc.N_LOCK_STATE != 0)
-                            {
-                                result.code = "1";
-                                result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣";
-                                AddErrorInfo("璐т綅鏈夐攣", result.msg);
-                                return result;
-                            }
-                            var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE.Trim()).First();
-                            var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE.Trim()).First();
-                            if (startArea == null || endArea == null)
-                            {
-                                LogHelper.Info($"璧风偣锛歿JsonConvert.SerializeObject(startArea)}");
-                                LogHelper.Info($"缁堢偣锛歿JsonConvert.SerializeObject(endArea)}");
-                                result.code = "1";
-                                result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{startloc.S_AREA_CODE},缁堢偣{endloc.S_AREA_CODE}鏈壘鍒板搴斿簱鍖�;
-                                AddErrorInfo("搴撳尯鏌ユ壘澶辫触", result.msg);
-                                return result;
-                            }
-                            int pri = 1;
-                            var area = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).First();
-                            if (area != null)
-                            {
-                                if (area.XbAreaCodes.Contains(endloc.S_AREA_CODE))
-                                {
-                                    pri = 2;
-                                }
-                            }
-                            //鍒涘缓wcs浠诲姟
-                            var wcsTask = new WCSTask
-                            {
-                                S_CODE = WCSHelper.GenerateTaskNo(),
-                                S_TYPE = startArea.S_NAME + "->" + endArea.S_NAME,
-                                S_EQ_NO = taskData.taskNum,
-                                S_START_LOC = Start,
-                                S_END_LOC = End,
-                                N_CNTR_COUNT = 1,
-                                S_START_WH = startloc.S_WH_CODE,
-                                S_END_WH = endloc.S_WH_CODE,
-                                S_END_AREA = endloc.S_AREA_CODE,
-                                N_SCHEDULE_TYPE = 1,
-                                S_CNTR_CODE = CntrCode,
-                                N_PRIORITY = pri,
-                                Z_TYPE = n_type,
-                                N_START_LAYER = 1,
-                                N_END_LAYER = 1,
-                                S_WMS_NO = taskData.wmsTaskNo,
-                                S_NOTE = note,
-                                S_MES_NO = taskData.mesTaskNo
+                    endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First();
+                    if (endloc != null)
+                    {
+                        End = taskData.dropStation;
+                    }
+                    else
+                    {
+                        result.code = "1";
+                        result.msg = $"鏍规嵁缁堢偣{taskData.dropStation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
+                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
+                        return result;
+                    }
 
-                            };
-                            LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask");
-                            if (WCSHelper.CreateTask(wcsTask))
+                    if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End))
+                    {
+                        if (startloc.N_LOCK_STATE != 0)
+                        {
+                            result.code = "1";
+                            result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣";
+                            AddErrorInfo("璐т綅鏈夐攣", result.msg);
+                            return result;
+                        }
+                        var startArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == startloc.S_AREA_CODE.Trim()).First();
+                        var endArea = db.Queryable<Area>().Where(a => a.S_CODE.Trim() == endloc.S_AREA_CODE.Trim()).First();
+                        if (startArea == null || endArea == null)
+                        {
+                            LogHelper.Info($"璧风偣锛歿JsonConvert.SerializeObject(startArea)}");
+                            LogHelper.Info($"缁堢偣锛歿JsonConvert.SerializeObject(endArea)}");
+                            result.code = "1";
+                            result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{startloc.S_AREA_CODE},缁堢偣{endloc.S_AREA_CODE}鏈壘鍒板搴斿簱鍖�;
+                            AddErrorInfo("搴撳尯鏌ユ壘澶辫触", result.msg);
+                            return result;
+                        }
+                        int pri = 1;
+                        var area = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).First();
+                        if (area != null)
+                        {
+                            if (area.XbAreaCodes.Contains(endloc.S_AREA_CODE))
                             {
-                                // LocationHelper.LockLoc(Start, 2);
-                                //LocationHelper.LockLoc(End, 1);
-                                LogHelper.Info("鍒涘缓浠诲姟鎴愬姛");
+                                pri = 2;
                             }
-                            else
-                            {
-                                result.code = "1";
-                                result.msg = $"浠诲姟鍒涘缓澶辫触";
-                                AddErrorInfo("浠诲姟鍒涘缓澶辫触", result.msg, Source);
-                                return result;
-                            }
+                        }
+                        //鍒涘缓wcs浠诲姟
+                        var wcsTask = new WCSTask
+                        {
+                            S_CODE = WCSHelper.GenerateTaskNo(),
+                            S_TYPE = startArea.S_NAME + "->" + endArea.S_NAME,
+                            S_EQ_NO = taskData.taskNum,
+                            S_START_LOC = Start,
+                            S_END_LOC = End,
+                            N_CNTR_COUNT = 1,
+                            S_START_WH = startloc.S_WH_CODE,
+                            S_END_WH = endloc.S_WH_CODE,
+                            S_END_AREA = endloc.S_AREA_CODE,
+                            N_SCHEDULE_TYPE = 1,
+                            S_CNTR_CODE = CntrCode,
+                            N_PRIORITY = pri,
+                            Z_TYPE = n_type,
+                            N_START_LAYER = 1,
+                            N_END_LAYER = 1,
+                            S_WMS_NO = taskData.wmsTaskNo,
+                            S_NOTE = note,
+                            S_MES_NO = taskData.mesTaskNo
+
+                        };
+                        LogHelper.Info("鍒涘缓浠诲姟锛� + JsonConvert.SerializeObject(wcsTask), "CreateTask");
+                        if (WCSHelper.CreateTask(wcsTask))
+                        {
+                            // LocationHelper.LockLoc(Start, 2);
+                            //LocationHelper.LockLoc(End, 1);
+                            LogHelper.Info("鍒涘缓浠诲姟鎴愬姛");
                         }
                         else
                         {
                             result.code = "1";
-                            result.msg = "鍒涘缓浠诲姟澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫彇璐х偣鎴栧嵏璐х偣";
+                            result.msg = $"浠诲姟鍒涘缓澶辫触";
+                            AddErrorInfo("浠诲姟鍒涘缓澶辫触", result.msg, Source);
                             return result;
                         }
-              
-                }
+                    }
+                    else
+                    {
+                        result.code = "1";
+                        result.msg = "鍒涘缓浠诲姟澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫彇璐х偣鎴栧嵏璐х偣";
+                        return result;
+                    }
 
+                }
 
                 return result;
             }
@@ -528,7 +414,7 @@
             }
         }
 
-      
+
         /// <summary>
         /// 璐т綅淇℃伅涓婁紶
         /// </summary>
@@ -554,7 +440,7 @@
                     result1.UseToken = "iFQ5fExGrLYLXliHYWzs";
                     upload.LocationNum = loc.S_CODE;
                     upload.Type = loc.S_TYPE;
-                    upload.LockState =loc.S_LOCK_STATE;
+                    upload.LockState = loc.S_LOCK_STATE;
                     upload.WorkCenter = loc.S_AREA_CODE;
                     upload.Warehouse = loc.S_AREA_CODE;
                     listuploadloc.Add(upload);
@@ -609,8 +495,8 @@
             var db = new SqlHelper<HangChaAGV>().GetInstance();
             DeviceInfoModel device = new DeviceInfoModel();
 
-           // List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//鍙犵洏鏈烘姤閿欎俊鎭�-                                                                    // List<AgvInfos> agvInfos = new List<AgvInfos>();//agv鎶ラ敊淇℃伅
+            // List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//鍙犵洏鏈烘姤閿欎俊鎭�+            // List<AgvInfos> agvInfos = new List<AgvInfos>();//agv鎶ラ敊淇℃伅
 
             //鑾峰彇鍐呭瓨涓彔鐩樻満鐨勬姤閿欎俊鎭�             //foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory)
@@ -632,7 +518,7 @@
                 //    deviceInfos.Add(new DeviceInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo });
                 //}
             }
-          //  device.DeviceInfos = deviceInfos;
+            //  device.DeviceInfos = deviceInfos;
 
             return device;
         }
@@ -854,7 +740,7 @@
             return result;
         }
 
-       
+
 
         //internal static bool CreateCntrLoc(taskData taskData)
         //{

--
Gitblit v1.9.1