From 5b6a0b390fc0ca7a5519ad6fb9a27bbca80e3cad Mon Sep 17 00:00:00 2001
From: 海波 张 <2956280567@qq.com>
Date: 星期四, 29 五月 2025 17:29:28 +0800
Subject: [PATCH] 空托修改

---
 wms/TaskHelper.cs |  145 ++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 127 insertions(+), 18 deletions(-)

diff --git a/wms/TaskHelper.cs b/wms/TaskHelper.cs
index 7b16b6d..bd314c6 100644
--- a/wms/TaskHelper.cs
+++ b/wms/TaskHelper.cs
@@ -49,6 +49,21 @@
             return task;
         }
 
+        //鏌ユ壘WCS绔嬪簱浠诲姟 鍙傛暟浣滀笟缂栫爜,璋冨害绫诲瀷 agv/wcs
+        internal static WMSTask GetTaskByWorkNo(string no,string type)
+        {
+            var db = new SqlHelper<WMSTask>().GetInstance();
+            var task = db.Queryable<WMSTask>().Where(a => a.S_OP_CODE == no && a.S_SCHEDULE_TYPE== type).First();
+            return task;
+        }
+
+
+        internal static WmsWork GetWmsWork(string no) {
+            var db = new SqlHelper<WmsWork>().GetInstance();
+            return db.Queryable<WmsWork>().Where(it => it.S_CODE == no).First();
+        }
+      
+
 
         internal static WMSTask GetTaskByCntrCode(string cntrCode)
         {
@@ -235,13 +250,15 @@
         {
             var tasks = new List<Task>();
 
+            
+
             // 浠诲姟1
             var task1 = new WMSTask()
             {
                 // 浣滀笟缂栫爜
                 S_OP_CODE = operation.S_CODE,
                 // 浠诲姟鍙�-                S_CODE = GenerateTaskNo(),
+                S_CODE = operation.S_CODE + "_1",
                 // 浠诲姟绫诲瀷
                 N_TYPE = operation.N_TYPE,
                 // 浠诲姟绫诲瀷
@@ -250,6 +267,10 @@
                 S_START_LOC = operation.S_START_LOC,
                 // 璧风偣搴撳尯
                 S_START_AREA = operation.S_START_AREA,
+                //璧风偣搴撳尯鍚嶇О
+                S_START_AREA_NAME = operation.S_START_AREA_NAME,
+                //缁堢偣搴撳尯鍚嶇О
+                S_END_AREA_NAME = operation.S_END_AREA_NAME,
                 // 缁堢偣璐т綅
                 S_END_LOC = operation.S_END_LOC,
                 // 缁堢偣搴撳尯
@@ -266,6 +287,10 @@
                 N_PRIORITY = operation.N_PRIORITY,
                 //宸ヨ绫诲瀷
                 TOOLSTYPE = operation.TOOLSTYPE,
+
+               
+
+
             };
 
             try
@@ -335,6 +360,10 @@
                 N_PRIORITY = operation.N_PRIORITY,
                 //宸ヨ绫诲瀷
                 TOOLSTYPE = operation.TOOLSTYPE,
+                //璧风偣搴撳尯鍚嶇О
+                S_START_AREA_NAME = operation.S_START_AREA_NAME,
+                //缁堢偣搴撳尯鍚嶇О
+                S_END_AREA_NAME = operation.CONNECTION_AREA,
 
             };
 
@@ -369,6 +398,10 @@
                 N_PRIORITY = operation.N_PRIORITY,
                 //宸ヨ绫诲瀷
                 TOOLSTYPE = operation.TOOLSTYPE,
+                //璧风偣搴撳尯鍚嶇О
+                S_START_AREA_NAME = operation.CONNECTION_AREA,
+                //缁堢偣搴撳尯鍚嶇О
+                S_END_AREA_NAME = operation.S_END_AREA_NAME,
             };
 
             try
@@ -411,7 +444,7 @@
                 // 浣滀笟缂栫爜
                 S_OP_CODE = operation.S_CODE,
                 // 浠诲姟鍙�-                S_CODE = operation.S_CODE + "_2",
+                S_CODE = operation.S_CODE + "_1",
                 // 浠诲姟绫诲瀷
                 N_TYPE = operation.N_TYPE,
                 // 浠诲姟绫诲瀷
@@ -436,6 +469,10 @@
                 N_PRIORITY = operation.N_PRIORITY,
                 //宸ヨ绫诲瀷
                 TOOLSTYPE = operation.TOOLSTYPE,
+                //璧风偣搴撳尯鍚嶇О
+                S_START_AREA_NAME = operation.S_START_AREA_NAME,
+                //缁堢偣搴撳尯鍚嶇О
+                S_END_AREA_NAME = operation.CONNECTION_AREA,
             };
 
             // 浠诲姟2
@@ -444,7 +481,7 @@
                 // 浣滀笟缂栫爜
                 S_OP_CODE = operation.S_CODE,
                 // 浠诲姟鍙�-                S_CODE = operation.S_CODE + "_1",
+                S_CODE = operation.S_CODE + "_2",
                 // 浠诲姟绫诲瀷
                 N_TYPE = operation.N_TYPE,
                 // 浠诲姟绫诲瀷
@@ -469,6 +506,10 @@
                 N_PRIORITY = operation.N_PRIORITY,
                 //宸ヨ绫诲瀷
                 TOOLSTYPE = operation.TOOLSTYPE,
+                //璧风偣搴撳尯鍚嶇О
+                S_START_AREA_NAME = operation.CONNECTION_AREA,
+                //缁堢偣搴撳尯鍚嶇О
+                S_END_AREA_NAME = operation.S_END_AREA_NAME,
             };
 
             try
@@ -518,6 +559,7 @@
             var db = new SqlHelper<WmsTaskAction>().GetInstance();
             var action = new WmsTaskAction() {
                 S_ACTION = state.ToString(),
+                N_ACTION_CODE = state,
                 S_TASK_CODE = no,
                 S_EQ_CODE = forkliftNo,
                 S_EQ_TYPE = "agv",
@@ -534,7 +576,26 @@
             return ac;
         }
 
-      
+        /// <summary>
+        /// 浠诲姟鎷︽埅
+        /// </summary>
+        /// <param name="task"></param>
+        /// <returns></returns>
+        internal static bool Intercept()
+        {
+                var db = new SqlHelper<object>().GetInstance();
+              
+                var model = db.Queryable<ManualTaskSwitch>().First();
+                if (model != null && model.State == "Y")
+                {
+                    return false;
+                }
+                else
+                {
+                    return true;
+                }
+            
+        }
 
 
         internal static bool WcsAddActionRecord(string no, string state, string forkliftNo, string extData = "0")
@@ -543,6 +604,7 @@
             var action = new WmsTaskAction()
             {
                 S_ACTION = state.ToString(),
+                N_ACTION_CODE = int.Parse(state),
                 S_TASK_CODE = no,
                 S_EQ_CODE = forkliftNo,
                 S_EQ_TYPE = "wcs",
@@ -558,18 +620,18 @@
             var db = new SqlHelper<WmsTaskAction>().GetInstance();
             return db.Queryable<WmsTaskAction>().Count(a => a.S_TASK_CODE.Trim() == no.Trim() && a.S_ACTION == code) > 0;
         }
-        internal static void Begin(WMSTask task,string avgNo) {
-            var db = new SqlHelper<WMSTask>().GetInstance();
-            if (task != null) {
-                if (task.S_B_STATE.Trim() == "宸叉帹閫�) {
-                    task.S_B_STATE = "鎵ц涓�;
-                    task.T_START_TIME = DateTime.Now;
-                    task.S_EQ_NO = avgNo;
-                    db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE, it.T_START_TIME,it.S_EQ_NO }).ExecuteCommand();
-                }
+        //internal static void Begin(WMSTask task,string avgNo) {
+        //    var db = new SqlHelper<WMSTask>().GetInstance();
+        //    if (task != null) {
+        //        if (task.S_B_STATE.Trim() == "宸叉帹閫�) {
+        //            task.S_B_STATE = "鎵ц涓�;
+        //            task.T_START_TIME = DateTime.Now;
+        //            task.S_EQ_NO = avgNo;
+        //            db.Updateable(task).UpdateColumns(it => new { it.S_B_STATE, it.T_START_TIME,it.S_EQ_NO }).ExecuteCommand();
+        //        }
 
-            }
-        }
+        //    }
+        //}
 
 
         internal static WcsRfidCheckoutEntitys GetRfid(string TaskCode) {
@@ -581,7 +643,7 @@
 
 
 
-        internal static void Begin(WMSTask task)
+        internal static void Begin(WMSTask task, string avgNo="")
         {
             var db = new SqlHelper<WMSTask>().GetInstance();
             if (task != null)
@@ -590,8 +652,9 @@
                 {
                     task.N_B_STATE = 2;
                     task.S_B_STATE = WMSTask.GetStateStr(task.N_B_STATE);
+                    task.S_EQ_NO = avgNo;
                     task.T_START_TIME = DateTime.Now;
-                    db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_START_TIME }).ExecuteCommand();
+                    db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE, it.T_START_TIME,it.S_EQ_NO }).ExecuteCommand();
                 }
             }
         }
@@ -680,7 +743,8 @@
             {
                 task.N_B_STATE = 5;
                 task.S_B_STATE = WMSTask.GetStateStr(task.N_B_STATE);
-                db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE }).ExecuteCommand();
+                task.T_END_TIME = DateTime.Now;
+                db.Updateable(task).UpdateColumns(it => new { it.N_B_STATE, it.S_B_STATE,it.T_END_TIME}).ExecuteCommand();
             }
         }
 
@@ -796,5 +860,50 @@
             }
 
         }
+
+
+        internal static bool CreateMesKtTask(MesKtTask cntr)
+        {
+            try
+            {
+                var db = new SqlHelper<object>().GetInstance();
+
+                return db.Insertable<MesKtTask>(cntr).ExecuteCommand() > 0;
+            }
+            catch (Exception ex)
+            {
+                Console.WriteLine(ex.Message);
+                LogHelper.Info($"娣诲姞Mes绌烘墭缂撳瓨寮傚父" + ex.Message, "Mes浠诲姟涓嬪彂");
+                throw;
+            }
+        }
+
+        internal static MesKtTask GetMesKtTask(string end)
+        {
+          
+                var db = new SqlHelper<object>().GetInstance();
+
+                return db.Queryable<MesKtTask>().Where(a => a.Location_To==end && a.Status=="N").First();
+        }
+
+        internal static bool ChangeMesKtTask(MesKtTask kt)
+        {
+
+            var db = new SqlHelper<object>().GetInstance();
+            kt.Status = "Y";
+            return db.Updateable(kt).UpdateColumns(it => new {
+                it.Status
+            }).ExecuteCommand()>0;
+
+            
+        }
+
+        internal static List<UnlimitedLoc> GetMesKtLoc()
+        {
+
+            var db = new SqlHelper<object>().GetInstance();
+
+            return db.Queryable<UnlimitedLoc>().ToList();
+        }
     }
 }

--
Gitblit v1.9.1