From 0ed390381862dea0c7fd0210d16017eb09f12da4 Mon Sep 17 00:00:00 2001
From: kazelee <1847801760@qq.com>
Date: 星期三, 30 七月 2025 17:27:27 +0800
Subject: [PATCH] 封装插入容器表等业务代码, 修复部分底层旧框架方法问题

---
 wms/WMSHelper.cs |  100 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 100 insertions(+), 0 deletions(-)

diff --git a/wms/WMSHelper.cs b/wms/WMSHelper.cs
index 6591b02..c704164 100644
--- a/wms/WMSHelper.cs
+++ b/wms/WMSHelper.cs
@@ -1,11 +1,111 @@
 锘縰sing System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Security.Cryptography;
 using System.Text;
 using System.Threading.Tasks;
+using HH.WCS.Mobox3.DSZSH.models;
+using HH.WCS.Mobox3.DSZSH.util;
+using Newtonsoft.Json;
+using static HH.WCS.Mobox3.DSZSH.api.ApiModel;
+using static HH.WCS.Mobox3.DSZSH.util.Config;
 
 namespace HH.WCS.Mobox3.DSZSH.wms {
+    /// <summary>
+    /// [ 鍏蜂綋涓氬姟 ] 甯姪绫�+    /// </summary>
     public class WMSHelper {
+        /// <summary>
+        /// 妫�煡瀹瑰櫒绫诲瀷
+        /// </summary>
+        /// <param name="cntrCode"></param>
+        /// <param name="cntrType"></param>
+        /// <param name="cntr"></param>
+        /// <returns></returns>
+        public static (bool, string) CheckCntrType(string cntrCode, string cntrType, out TN_Container cntr) { 
+            var db = new SqlHelper<object>().GetInstance();
 
+            cntr = db.Queryable<TN_Container>().Where(c => c.S_CODE == cntrCode).First();
+            if (cntr == null) {
+                return (false, $"瀹瑰櫒'{cntrCode}'鍦╗瀹瑰櫒琛╙涓笉瀛樺湪,璇峰湪鍓嶅彴椤甸潰涓淮鎶�!");
+            }
+            if (cntr.S_TYPE != cntrType) {
+                return (false, $"瀹瑰櫒'{cntrCode}'鍦╗瀹瑰櫒琛╙涓殑绫诲瀷涓�{cntr.S_TYPE}',涓庡綋鍓嶆祦绋嬫墍闇�鍣ㄧ被鍨�{cntrType}'涓嶅悓!!");
+            }
+            return (true, "妫�煡瀹瑰櫒绫诲瀷鎴愬姛!!");
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        /// <param name="locCode"></param>
+        /// <param name="areas"></param>
+        /// <param name="startLoc"></param>
+        /// <returns></returns>
+        public static (bool, string) FindStartLocUnbind(string locCode, List<string> areas, out TN_Location startLoc) {
+            var db = new SqlHelper<object>().GetInstance();
+            startLoc = db.Queryable<TN_Location>().Where(DbExpr.StartLocUnbind(locCode, areas)).First();
+            if (startLoc == null) {
+                return (false, LogMsg.StartLocUnbindNotFound(locCode, areas));
+            }
+            return (true, "");
+        }
+        /// <summary>
+        /// 鏍规嵁瀹瑰櫒鍙�, 鏌ユ壘鏃х殑璐т綅 / 璐т綅缁戝畾 / 鐗╂枡淇℃伅 ( 灏嗗緟鍒犻櫎 / 鏇存柊鏁版嵁鍐欏叆 obj )
+        /// </summary>
+        /// <remarks><code><![CDATA[obj.Old = oldLocCntrCg;]]></code></remarks>
+        /// <param name="obj"></param>
+        /// <param name="cntrCode"></param>
+        /// <param name="skipCgDetail"></param>
+        /// <returns></returns>
+        public static LocCntrCg FindCntrOldInfo(CreateTaskObj obj, string cntrCode, bool skipCgDetail = true) {
+            var oldLocCntrCg = WCSHelper.GetLocCntrCg(cntrCode, skipCgDetail);
+            obj.Old = oldLocCntrCg;
+            return oldLocCntrCg;
+        }
+        /// <summary>
+        /// 缁戝畾璐т綅瀹瑰櫒 ( 淇敼 [ 璐т綅瀹瑰櫒琛�] [ 璐т綅绫诲瀷 ] = cntrType ; 灏�[ 寰呮彃鍏�] 璐т綅瀹瑰櫒鍏崇郴 鍔犲叆鍒�obj 涓�)
+        /// </summary>
+        /// <remarks><code><![CDATA[obj.New = new LocCntrCg { LocCntrRel = locCntrRel };]]></code></remarks>
+        /// <param name="obj"></param>
+        /// <param name="loc"></param>
+        /// <param name="cntrCode"></param>
+        /// <param name="cntrType"></param>
+        /// <returns></returns>
+        public static TN_Loc_Container BindLocCntr(CreateTaskObj obj, TN_Location loc, string cntrCode, string cntrType = "") {
+            var locCntrRel = WCSHelper.BindLocCntr(loc, cntrCode);
+            if (!string.IsNullOrEmpty(cntrType)) {
+                locCntrRel.S_CNTR_TYPE = cntrType;
+            }
+            obj.New = new LocCntrCg { LocCntrRel = locCntrRel };
+            return locCntrRel;
+        }
+        /// <summary>
+        /// 鍒涘缓浠诲姟 ( 鏋勯�浠诲姟椤�/ 璧风偣缁堢偣涓婇攣 ; 灏�鎻掑叆浠诲姟 / 鏇存柊璐т綅 鐨勫璞″啓鍏�obj )
+        /// </summary>
+        /// <remarks><code><![CDATA[
+        /// obj.TaskToInsert = task;
+        /// obj.StartLocToUpdate = startLoc;
+        /// obj.EndLocToUpdate = endLoc;
+        /// ]]></code></remarks>
+        /// <param name="obj"></param>
+        /// <param name="startLoc"></param>
+        /// <param name="endLoc"></param>
+        /// <param name="cntId"></param>
+        /// <param name="type"></param>
+        /// <param name="pri"></param>
+        /// <param name="agv"></param>
+        public static TN_Task CreateTask(CreateTaskObj obj, TN_Location startLoc, TN_Location endLoc, string cntId, string type,
+            int pri = 3, int agv = 1) {
+
+            var task = WCSHelper.BuildTask(startLoc, endLoc, cntId, type, pri);
+            WCSHelper.LockStartLoc(startLoc, task.S_CODE);
+            WCSHelper.LockEndLoc(endLoc, task.S_CODE);
+
+            obj.TaskToInsert = task;
+            obj.StartLocToUpdate = startLoc;
+            obj.EndLocToUpdate = endLoc;
+
+            return task;
+        }
     }
 }

--
Gitblit v1.9.1