From 79db8fda0f71b65dfe1e1c72f307b29efc565126 Mon Sep 17 00:00:00 2001
From: lss <2538410689@qq.com>
Date: 星期一, 04 八月 2025 17:31:22 +0800
Subject: [PATCH] 111

---
 HH.WCS.Mobox3 - 大车间/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs |  122 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 122 insertions(+), 0 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 325b458..00d8e37 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"
@@ -296,6 +296,128 @@
 
         }
 
+        /// <summary>
+        /// 鐐瑰鐐逛换鍔″垱寤�+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static Result CreatTask(CreatTask model)
+        {
+            Result result = new Result() { code = "200", msg = "鐐瑰鐐逛换鍔″垱寤烘垚鍔� };
+            string Source = "MES";
+            if (model == null)
+            {
+                result.code = "1";
+                result.msg = "鍙傛暟涓簄ull";
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
+                return result;
+            }
+            string Start = ""; //鍙栬揣鐐�+            var db = new SqlHelper<object>().GetInstance();
+            //   string CntrCode = model.partData.rfid;//鎵樼洏缂栫爜
+            // string ItemCode = model.partData.partNumber;//鐗╂枡缂栫爜
+            string End = "";
+            string CntrCode = "";
+            Location endloc = new Location();
+            Location startloc = new Location();
+            try
+            {
+                startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.InitialLocation).First();
+                if (startloc != null)
+                {
+                    Start = model.InitialLocation;
+
+
+                }
+                else
+                {
+
+                    result.code = "1";
+                    result.msg = $"鏍规嵁璧风偣{model.InitialLocation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
+                    AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
+                    return result;
+
+                }
+                endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.TargetLocation).First();
+                if (endloc != null)
+                {
+                    End = model.TargetLocation;
+                }
+                else
+                {
+                    result.code = "1";
+                    result.msg = $"鏍规嵁缁堢偣{model.TargetLocation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
+                    AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
+                    return result;
+                }
+                #region 鍒涘缓浠诲姟
+                if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End))
+                {
+                    if (startloc.N_LOCK_STATE != 0)
+                    {
+                        result.code = "1";
+                        result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣";
+                        AddErrorInfo("璐т綅鏈夐攣", result.msg);
+                        return result;
+                    }
+                    //鍒涘缓wcs浠诲姟
+                    var wcsTask = new WCSTask
+                    {
+                        S_CODE = WCSHelper.GenerateTaskNo(),
+                        // S_TYPE = model.taskData.taskType.ToString(),
+                        //  S_EQ_NO = model.taskData.taskNum,
+                        S_START_LOC = Start,
+                        S_END_LOC = End,
+                        N_CNTR_COUNT = 1,
+                        S_START_WH = startloc.S_WH_CODE,
+                        S_START_AREA = startloc.S_AREA_CODE,
+                        S_END_WH = endloc.S_WH_CODE,
+                        S_END_AREA = endloc.S_AREA_CODE,
+                        N_SCHEDULE_TYPE = 1,
+                        S_CNTR_CODE = CntrCode,
+                        N_START_LAYER = 1,
+                        N_END_LAYER = 1,
+                        N_PRIORITY = 1,
+                        //  N_TYPE = n_type
+
+
+                    };
+                    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 = $"浠诲姟鍒涘缓澶辫触";
+                        AddErrorInfo("浠诲姟鍒涘缓澶辫触", result.msg, Source);
+                        return result;
+                    }
+                }
+                else
+                {
+                    result.code = "1";
+                    result.msg = "鍒涘缓浠诲姟澶辫触锛屾湭鎵惧埌瀵瑰簲鐨勫彇璐х偣鎴栧嵏璐х偣";
+                    return result;
+                }
+                #endregion
+
+                return result;
+
+            }
+            catch (Exception ex)
+            {
+
+                result.code = "1";
+                result.msg = $"鐗╂枡涓绘暟鎹垱寤哄け璐�閿欒淇℃伅锛歿ex}";
+                LogHelper.Error("鐐瑰鐐逛换鍔�Error锛� + ex.ToString(), ex);
+                return result;
+            }
+
+        }
 
         public static object _Point = new object();
         /// <summary>

--
Gitblit v1.9.1