From af42a9904d1d3939da7fa0a00c3a7a2ced78258e Mon Sep 17 00:00:00 2001
From: lss <Lss@HanInfo>
Date: 星期三, 21 五月 2025 17:26:18 +0800
Subject: [PATCH] 佳通问题优化

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs |  440 ++++++++++++++++++++++++++++++++++++------------------
 1 files changed, 289 insertions(+), 151 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
index a658aa4..13161c9 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -6,6 +6,7 @@
 using HH.WCS.JiaTong.wms;
 using Newtonsoft.Json;
 using NLog.Fluent;
+using S7.Net;
 using SqlSugar;
 using System;
 using System.Collections.Generic;
@@ -52,62 +53,61 @@
             try
             {
                 var db = new SqlHelper<object>().GetInstance();
+                string CntrCode = "";//鎵樼洏缂栫爜
+                string ItemCode = "";//鐗╂枡缂栫爜
+                if (partData != null)
+                {
+                    CntrCode = partData.rfid;//鎵樼洏缂栫爜
+                    ItemCode = partData.partNumber;//鐗╂枡缂栫爜
+                }
                 string Start = ""; //鍙栬揣鐐�-                string CntrCode = partData.rfid;//鎵樼洏缂栫爜
-                string ItemCode = partData.partNumber;//鐗╂枡缂栫爜
                 string End = "";
-                string areacode = "";
                 string note = ""; //绔嬪簱涓嬪彂浠诲姟闇�閫氱煡mes鎺ュ彛鐗╂枡鍒颁綅锛岀敤澶囨敞鑷姩杩涜鍖哄垎
                                   //鏍规嵁鐗╂枡鑾峰彇瀵瑰簲搴撳尯
-                #region 鏍规嵁鐗╂枡纭鍑哄簱鏉ユ簮
-                var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == ItemCode).First();
-                if (iteminfo != null)
-                {
-                    //LogHelper.Info($"Createtask==>鐗╂枡鏁版嵁:{JsonConvert.SerializeObject(iteminfo)}");
-                    areacode = iteminfo.S_WH_CODE;
-                }
-
-                if (string.IsNullOrEmpty(areacode))
-                {
-                    LogHelper.Info($"Createtask==>鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁");
-                    result.code = "1";
-                    result.msg = $"鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁";
-                    AddErrorInfo("瀵绘壘鍑哄簱鍖哄け璐�, result.msg);
-                    return result;
-                }
-                //var task = db.Queryable<WCSTask>().Where(a => a.S_EQ_NO.Trim() == taskData.taskNum).First();
-                //if (task != null)
+                #region 鏍规嵁浠诲姟鏉ユ簮瀛楁鍒ゆ柇搴撳尯鏉ユ簮鏉ユ簮
+                //var iteminfo = db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE.Trim() == ItemCode).First();
+                //if (iteminfo != null)
                 //{
-                //    LogHelper.Info($"Createtask==> 浠诲姟鍙穥taskData.taskNum},璇ヤ换鍔″凡缁忓瓨鍦紝涓嶅厑璁稿垱寤轰换鍔�);
+                //    //LogHelper.Info($"Createtask==>鐗╂枡鏁版嵁:{JsonConvert.SerializeObject(iteminfo)}");
+                //    areacode = iteminfo.S_WH_CODE;
+                //}
+
+                //if (string.IsNullOrEmpty(areacode))
+                //{
+                //    LogHelper.Info($"Createtask==>鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁");
                 //    result.code = "1";
-                //    result.msg = $"浠诲姟鍙穥taskData.taskNum},璇ヤ换鍔″凡缁忓瓨鍦紝涓嶅厑璁稿垱寤轰换鍔�;
+                //    result.msg = $"鏍规嵁鐗╂枡缂栫爜:{ItemCode}鏈兘鎵惧埌鐗╂枡鏉ユ簮锛岄渶鍚屾鐗╂枡鏁版嵁";
+                //    AddErrorInfo("瀵绘壘鍑哄簱鍖哄け璐�, result.msg);
                 //    return result;
                 //}
-                int n_type = 0;  //浠诲姟鏉ユ簮 1.閽笣绔嬪簱  2.鑳剁墖搴� 3.棰勫搴�,4.鍘熸潗鏂欏簱,閫氳繃鐗╂枡纭浠诲姟鏉ユ簮
-
-                switch (areacode)
+              
+                int n_type = 0;  //浠诲姟鏉ユ簮 1.瀵嗙偧绔嬪簱  3.棰勫搴�,4.鍘熸潗鏂欏簱
+                string Source = "";
+                switch (taskData.source)
                 {
                     case "ML":
                         n_type = 1;
-                        break;
-                    case "JP":
-                        n_type = 2;
+                        Source = "瀵嗙偧";
                         break;
                     case "YBK":
                         n_type = 3;
+                        Source = "棰勫搴�;
                         break;
-                    case "wmwhse1":
+                    case "YCL":
                         n_type = 4;
+                        Source = "鍘熸潗鏂�;
                         break;
                 }
-                LogHelper.Info($"Createtask==>浠诲姟绫诲瀷:{n_type}");
+                Console.WriteLine($"Createtask==>浠诲姟鏉ユ簮:{n_type}");
                 if (n_type == 0)
                 {
                     result.code = "1";
-                    result.msg = $"鐗╂枡搴撳尯:{areacode}灞炰簬鏈畾涔夊簱鍖猴紝璇锋鏌ョ墿鏂欒〃閲嶆柊瀹氫箟鐗╂枡搴撳尯";
-                    AddErrorInfo("鐗╂枡搴撳尯鏈畾涔�, result.msg);
+                    result.msg = $"浠诲姟鏉ユ簮:{taskData.source}灞炰簬鏈畾涔夊簱鍖猴紝璇锋鏌ョ墿鏂欐潵婧愭槸鍚﹀睘浜庣害瀹氬瓧娈�;
+                    AddErrorInfo("浠诲姟鏉ユ簮鏈畾涔�, result.msg);
                     return result;
                 }
+
+
                 #endregion
 
                 Location endloc = new Location();
@@ -121,7 +121,7 @@
                     {
                         //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅
                         Start = taskData.pickStation;
-                        if (CreateCntrIteminfo(Start, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade))
+                        if (CreateCntrIteminfo(partData, taskData))
                         {
                             endloc = Computeloc(CntrCode, taskData.dropStation, taskData.carrierType);
                             if (endloc != null)
@@ -132,7 +132,7 @@
                             {
                                 result.code = "1";
                                 result.msg = $"鏈哄彴缂栫爜:{taskData.dropStation}锛屾湭鎵惧埌鍙敤璐т綅";
-                                AddErrorInfo("瀵绘壘鍑哄簱璐т綅澶辫触", result.msg);
+                                AddErrorInfo("瀵绘壘鍑哄簱璐т綅澶辫触", result.msg, Source);
                                 return result;
                             }
                         }
@@ -140,19 +140,20 @@
                         {
                             result.code = "1";
                             result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触";
-                            AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg);
+                            AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source);
                             return result;
                         }
                     }
                     else
                     {
-                        LogHelper.Info($"Putin==> 浠诲姟璧风偣:{taskData.pickStation}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃");
+
                         result.code = "1";
                         result.msg = $"Putin==> 浠诲姟璧风偣:{taskData.pickStation}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg);
+                        LogHelper.Info($"Putin==> {result.msg}");
+                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
                     }
                 }
-                else if (taskData.taskType == 2)//鍏ュ簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟
+                else if (taskData.taskType == 2)//鍏ュ簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛岃捣鐐归渶瑕佹湁鎵樼洏
                 {
                     startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                     if (startloc != null)
@@ -167,10 +168,16 @@
                         {
                             result.code = "1";
                             result.msg = $"鏍规嵁璧风偣{Start},鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�;
-                            AddErrorInfo("鎵樼洏鏌ユ壘澶辫触", result.msg);
+                            AddErrorInfo("鎵樼洏鏌ユ壘澶辫触", result.msg, Source);
                             return result;
                         }
 
+                    }
+                    //鍒ゆ柇鏄惁鏄┖鎵樺洖搴�+                    var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == CntrCode).First();
+                    if (CntrItem == null)
+                    {
+                        note = "绌烘墭鍥炲簱";//浜曟澗绌烘墭鍥炲簱锛岄渶瑕佷笌鍙犵洏鏈哄畨鍏ㄤ氦浜�                     }
                     endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.dropStation).First();
                     if (endloc != null)
@@ -181,7 +188,7 @@
                     {
                         result.code = "1";
                         result.msg = $"鏍规嵁缁堢偣{End},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg);
+                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
                         return result;
                     }
                 }
@@ -194,10 +201,24 @@
                     {
                         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 if (taskData.taskType == 4)//鍘熸潗鏂欏簱闇�鍒ゆ柇鏄惁闇�鍒嗛厤鐢垫浠诲姟,鍒涘缓鍒嗘。浠诲姟
@@ -222,7 +243,7 @@
                         {
                             result.code = "1";
                             result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{startloc.S_AREA_CODE},缁堢偣锛歿endloc.S_AREA_CODE}鏈壘鍒板搴斿簱鍖�;
-                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg);
+                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
                             return result;
                         }
                         if (startArea.N_FLOOR == endArea.N_FLOOR)
@@ -322,27 +343,41 @@
                         return result;
                     }
                 }
-                else if (taskData.taskType == 5)//绉诲簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛�+                else if (taskData.taskType == 5)//绉诲簱娴佺▼锛岀洿鎺ヤ娇鐢ㄨ捣鐐硅揣浣嶅拰缁堢偣璐т綅鐢熸垚浠诲姟锛屽苟缁戝畾鎵樼洏
                 {
                     //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅
-                    if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade))
+                    if (CreateCntrIteminfo(partData, taskData))
                     {
                         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
                     {
                         result.code = "1";
                         result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触";
-                        AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg);
+                        AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source);
                         return result;
                     }
 
@@ -364,7 +399,7 @@
                         {
                             result.code = "1";
                             result.msg = $"鏍规嵁鎵樼洏{partData.rfid},鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�;
-                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg);
+                            AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
                             return result;
                         }
                     }
@@ -377,7 +412,7 @@
                     {
                         result.code = "1";
                         result.msg = $"鏍规嵁缁堢偣{End},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg);
+                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
                         return result;
                     }
                 }
@@ -386,7 +421,7 @@
                 {
                     note = "寮傚父搴撳尯鍏ュ簱";
                     //鍒涘缓鎵樼洏鐗╂枡缁戝畾淇℃伅锛屽苟璁$畻缁堢偣璐т綅
-                    if (CreateCntrIteminfo(taskData.pickStation, CntrCode, ItemCode, partData.partDesc, partData.partType, partData.lotNumber, partData.unit, partData.weight, taskData.carrierType, taskData.grade))
+                    if (CreateCntrIteminfo(partData, taskData))
                     {
                         startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
                         if (startloc != null)
@@ -405,7 +440,7 @@
                             {
                                 result.code = "1";
                                 result.msg = $"缁堢偣搴撳尯锛歿taskData.dropStation}鏃犲彲鐢ㄨ揣浣�;
-                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                                 return result;
                             }
 
@@ -414,7 +449,7 @@
                         {
                             result.code = "1";
                             result.msg = $"鏍规嵁缁堢偣搴撳尯锛歿taskData.dropStation},鏈壘鍒板搴旇揣浣�;
-                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                             return result;
                         }
                     }
@@ -422,7 +457,35 @@
                     {
                         result.code = "1";
                         result.msg = "鍒涘缓鎵樼洏鐗╂枡淇℃伅澶辫触";
-                        AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg);
+                        AddErrorInfo("鍒涘缓鎵樼洏澶辫触", result.msg, Source);
+                        return result;
+                    }
+                }
+                else if (taskData.taskType == 8)//鍙犵洏鏈虹┖鎵樺洖搴�+                {
+                    note = "绌烘墭鍥炲簱";//浜曟澗绌烘墭鍥炲簱锛岄渶瑕佷笌鍙犵洏鏈哄畨鍏ㄤ氦浜�+                    startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == taskData.pickStation).First();
+                    if (startloc != null)
+                    {
+                        Start = startloc.S_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;
                     }
                 }
@@ -431,7 +494,7 @@
                     LogHelper.Info($"Createtask==> 浠诲姟绫诲瀷鏈夎");
                     result.code = "1";
                     result.msg = "浠诲姟绫诲瀷锛歿taskData.taskType}涓嶅湪瑙勫畾鑼冨洿鍐�;
-                    AddErrorInfo("浠诲姟绫诲瀷閿欒", result.msg);
+                    AddErrorInfo("浠诲姟绫诲瀷閿欒", result.msg, Source);
                 }
                 if (taskData.taskType != 4)
                 {
@@ -565,7 +628,7 @@
                 LogHelper.Info($"AllowThrough==> 鍙傛暟涓簄ull");
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull鍊硷紝璇锋鏌ュ弬鏁版牸寮�;
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, "", model.task_no);
                 return result;
             }
 
@@ -587,7 +650,7 @@
                 {
                     result.code = "1";
                     result.msg = $"鏍规嵁涓嬪彂浠诲姟鍙穥model.task_no}鏈壘鍒板搴斾换鍔�;
-                    AddErrorInfo("鏈壘鍒颁换鍔�, result.msg);
+                    AddErrorInfo("鏈壘鍒颁换鍔�, result.msg, "", model.task_no);
                     return result;
                 }
                 return result;
@@ -620,7 +683,7 @@
             try
             {
                 //鍒涘缓鎵樼洏鏁版嵁缁戝畾鍏崇郴
-                if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight))
+                if (ContainerHelper.CreateCntrItem(model.Rfid, model.PartNumber, model.PartDesc, model.LotNumber, model.Weight, model.Qty))
                 {
                     //鍒涘缓鎴愬姛娴佺▼
                 }
@@ -628,7 +691,7 @@
                 {
                     result.code = "1";
                     result.msg = "浜у嚭淇℃伅涓嬪彂澶辫触锛屾墭鐩樼墿鏂欑粦瀹氬叧绯诲垱寤哄け璐�;
-                    AddErrorInfo("鍒涘缓缁戝畾鍏崇郴澶辫触", result.msg);
+                    AddErrorInfo("鍒涘缓缁戝畾鍏崇郴澶辫触", result.msg, "Mes");
                     return result;
                 }
                 return result;
@@ -653,40 +716,49 @@
         internal static Result Putin(Putin model, int n_type)
         {
             Result result = new Result() { code = "200", msg = "鍏ュ钩搴撲换鍔′笅鍙戞垚鍔� };
+            string Source = "Mes";
+            if (n_type == 0)
+            {
+                Source = "PDA";
+            }
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
             var db = new SqlHelper<object>().GetInstance();
             Location loc = new Location();
+
             string Start = model.InitialLocation;  //璧风偣璐т綅
             string itemcode = model.PartNumber;    //鐗╂枡缂栫爜
             string areacode = "";
             try
             {
-                #region 鍒ゆ柇鎵樼洏缁戝畾璐т綅鏄惁鍜屼笅鍙戠粦瀹氳捣鐐圭浉鍚�+
+                #region 鍒ゆ柇鎵樼洏缁戝畾璐т綅鏄惁鍜屼笅鍙戠粦瀹氳捣鐐圭浉鍚�濡傛灉娌$粦瀹氭墭鐩樺垯缁戝畾鎵樼洏
                 var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First();
                 if (CntrLoc != null)
                 {
                     if (CntrLoc.S_LOC_CODE != Start)
                     {
-                        LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}");
+
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}";
-                        AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg);
+                        LogHelper.Info($"ItemBack锛歿result.msg}");
+                        AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg, Source);
                         return result;
                     }
                 }
                 else
                 {
-                    LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�);
-                    result.code = "1";
-                    result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�;
-                    AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg);
-                    return result;
+                    LocationHelper.BindingLoc(Start, new List<string> { model.Rfid });
+                    //LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�);
+                    //result.code = "1";
+                    //result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�;
+                    //AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg);
+                    //return result;
                 }
                 // Console.WriteLine("鏌ヨ璐т綅缁戝畾鍏崇郴");
                 //鍒ゆ柇鎵樼洏涓庤揣浣嶆槸鍚︽湁缁戝畾鍏崇郴锛屽鏋滄病鏈夊垯杩涜缁戝畾
@@ -712,7 +784,6 @@
 
                 //}
                 #endregion
-
 
                 #region 鏍规嵁璧风偣璐т綅鐨勪粨搴撶紪鐮�鑾峰彇骞冲簱缂栫爜,骞惰绠楀叆搴撹揣浣�                 string End = "";
@@ -743,18 +814,20 @@
                     }
                     else
                     {
-                        LogHelper.Info($"Putin==>搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�);
+
                         result.code = "1";
                         result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�;
-                        AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                        LogHelper.Info($"Putin==> {result.msg}");
+                        AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                     }
                 }
                 else
                 {
-                    LogHelper.Info($"Putin==> 浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃");
+
                     result.code = "1";
                     result.msg = $"浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                    LogHelper.Info($"Putin==> {result.msg}");
+                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                 }
                 #endregion
 
@@ -765,7 +838,7 @@
                     {
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{Start}鏈夐攣";
-                        AddErrorInfo("璐т綅鏈夐攣", result.msg);
+                        AddErrorInfo("璐т綅鏈夐攣", result.msg, Source);
                         return result;
                     }
                     //鍒涘缓wcs浠诲姟
@@ -802,6 +875,7 @@
                     return result;
                 }
                 #endregion
+
                 return result;
             }
             catch (Exception ex)
@@ -823,11 +897,16 @@
         internal static Result PutOut(PutOut model, int n_type)
         {
             Result result = new Result() { code = "200", msg = "鍑哄钩搴撲换鍔′笅鍙戞垚鍔� };
+            string Source = "Mes";
+            if (n_type == 0)
+            {
+                Source = "PDA";
+            }
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
 
@@ -835,6 +914,7 @@
             string Start = "";
             string End = "";
             string CntrCode = "";
+
             string itemcode = model.PartNumber;
             string cntrType = "";
             string areacode = "";
@@ -861,10 +941,11 @@
                     }
                     else
                     {
-                        LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鐗╂枡鍙穥model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�);
+
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛岀墿鏂欏彿{model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�;
-                        AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg);
+                        LogHelper.Info($"ItemBack锛歿result.msg}");
+                        AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg, Source);
                         return result;
                     }
                 }
@@ -906,10 +987,11 @@
                 }
                 else
                 {
-                    LogHelper.Info($"PutOut==> 浠诲姟鐗╂枡:{itemcode}鎵句笉鍒板搴斿簱瀛�);
+
                     result.code = "1";
                     result.msg = $"浠诲姟鐗╂枡:{itemcode}鎵句笉鍒板搴斿簱瀛�;
-                    AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                    LogHelper.Info($"ItemBack锛歿result.msg}");
+                    AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                 }
                 #endregion
 
@@ -920,7 +1002,7 @@
                     {
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋Start}鏈夐攣";
-                        AddErrorInfo("璐т綅鏈夐攣", result.msg);
+                        AddErrorInfo("璐т綅鏈夐攣", result.msg, Source);
                         return result;
                     }
                     //鍒涘缓wcs浠诲姟
@@ -978,11 +1060,12 @@
         internal static Result Empty(Empty model)
         {
             Result result = new Result() { code = "200", msg = "绌哄伐瑁呭洖搴撲换鍔′笅鍙戞垚鍔� };
+            string Source = "MES";
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
 
@@ -1032,13 +1115,13 @@
                         var dploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "鍙犵洏" && a.N_LAYER == startloc.N_LAYER && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList();
                         if (dploc.Count > 0)
                         {
-                            LogHelper.Info($"鑾峰彇鍙犵洏璐т綅:{JsonConvert.SerializeObject(dploc)}");
+                            // LogHelper.Info($"鑾峰彇鍙犵洏璐т綅:{JsonConvert.SerializeObject(dploc)}");
                             loc = dploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault();
                             if (loc == null)
                             {
                                 result.code = "1";
                                 result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�;
-                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                                 return result;
                             }
                             else
@@ -1048,10 +1131,39 @@
                         }
                         else
                         {
-                            LogHelper.Info($"鏍规嵁璐т綅澶囨敞锛氬彔鐩橈紝璐т綅妤煎眰:{startloc.N_LAYER},璐т綅浠撳簱:{startloc.S_WH_CODE}锛屾壘涓嶅埌鍙犵洏璐т綅");
+
                             result.code = "1";
                             result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�;
-                            AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                            LogHelper.Info($"鏍规嵁璐т綅澶囨敞锛氬彔鐩橈紝璐т綅妤煎眰:{startloc.N_LAYER},璐т綅浠撳簱:{startloc.S_WH_CODE}锛屾壘涓嶅埌鍙犵洏璐т綅");
+                            AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
+                            return result;
+                        }
+                    }
+                    else if (startloc.S_NOTE == "PM")
+                    {
+                        //鎵惧潡鑳跺爢鍙犲尯
+                        var KjDploc = db.Queryable<Location>().Where(a => a.S_NOTE.Trim() == "鐗囪兌鍫嗗彔浣� && a.S_WH_CODE.Trim() == startloc.S_WH_CODE).ToList();
+                        if (KjDploc.Count > 0)
+                        {
+                            loc = KjDploc.FindAll(a => a.N_LOCK_STATE == 0 && a.N_CURRENT_NUM < 6).OrderByDescending(a => a.N_CURRENT_NUM).FirstOrDefault();
+                            if (loc == null)
+                            {
+                                result.code = "1";
+                                result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�;
+                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
+                                return result;
+                            }
+                            else
+                            {
+                                endlayer = loc.N_CURRENT_NUM + 1;
+                            }
+                        }
+                        else
+                        {
+                            LogHelper.Info($"鏍规嵁璐т綅澶囨敞锛氱墖鑳跺爢鍙犱綅,璐т綅浠撳簱:{startloc.S_WH_CODE}锛屾壘涓嶅埌鍙犵洏璐т綅");
+                            result.code = "1";
+                            result.msg = $"鍙犵洏璐т綅涓嶅彲鐢�;
+                            AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                             return result;
                         }
                     }
@@ -1071,18 +1183,20 @@
                         }
                         else
                         {
-                            LogHelper.Info($"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鏈壘鍒版墭鐩樺嚭搴撲换鍔�);
+
                             result.code = "1";
                             result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鏈壘鍒版墭鐩樺嚭搴撲换鍔�;
-                            AddErrorInfo("鏌ユ壘浠诲姟澶辫触", result.msg);
+                            LogHelper.Info($"{result.msg}");
+                            AddErrorInfo("鏌ユ壘浠诲姟澶辫触", result.msg, Source);
                             return result;
                         }
                         if (string.IsNullOrEmpty(areacode))
                         {
-                            LogHelper.Info($"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鎵惧埌鍑哄簱浠诲姟{mst.S_CODE}鐨勮捣鐐瑰簱鍖轰负绌�);
+
                             result.code = "1";
                             result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹墭鐩樼紪鐮亄model.Rfid}鎵惧埌鍑哄簱浠诲姟{mst.S_CODE}鐨勮捣鐐瑰簱鍖轰负绌�;
-                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                            LogHelper.Info($"{result.msg}");
+                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                             return result;
                         }
                         #endregion
@@ -1099,10 +1213,11 @@
                         }
                         else
                         {
-                            LogHelper.Info($"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�);
+
                             result.code = "1";
                             result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�;
-                            AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                            LogHelper.Info($"{result.msg}");
+                            AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                             return result;
                         }
                     }
@@ -1110,10 +1225,11 @@
                 }
                 else
                 {
-                    LogHelper.Info($"Empty==> 浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃");
+
                     result.code = "1";
                     result.msg = $"Empty==> 浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                    LogHelper.Info($"{result.msg}");
+                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                     return result;
                 }
                 #endregion
@@ -1186,11 +1302,12 @@
         {
             var db = new SqlHelper<object>().GetInstance();
             Result result = new Result() { code = "200", msg = "绌哄伐瑁呭懠鍙换鍔′笅鍙戞垚鍔� };
+            string Source = "MES";
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
 
@@ -1232,10 +1349,10 @@
                         }
                         else
                         {
-                            LogHelper.Info($"callfixture:鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>鏍规嵁璐т綅{endloc.S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�);
                             result.code = "1";
                             result.msg = $"鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>鏍规嵁璐т綅{endloc.S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�;
-                            AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg);
+                            LogHelper.Info($"callfixture:{result.msg}");
+                            AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg, Source);
                             return result;
                         }
 
@@ -1244,10 +1361,11 @@
                 }
                 else
                 {
-                    LogHelper.Info($"callfixture==> 浠诲姟璧风偣:{End}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃");
+
                     result.code = "1";
                     result.msg = $"浠诲姟璧风偣:{End}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                    LogHelper.Info($"callfixture:{result.msg}");
+                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
 
                 }
                 #endregion
@@ -1320,11 +1438,12 @@
         internal static Result ItemBack(ItemBack model)
         {
             Result result = new Result() { code = "200", msg = "浣欐枡杩斿洖浠诲姟涓嬪彂鎴愬姛" };
+            string Source = "MES";
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
 
             }
@@ -1348,19 +1467,21 @@
                 {
                     if (CntrLoc.S_LOC_CODE != Start)
                     {
-                        LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}");
+
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}";
-                        AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg);
+                        LogHelper.Info($"ItemBack锛歿result.msg}");
+                        AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg, Source);
                         return result;
                     }
                 }
                 else
                 {
-                    LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鎵樼洏:{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�);
+
                     result.code = "1";
                     result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏈壘鍒扮粦瀹氳揣浣�;
-                    AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg);
+                    LogHelper.Info($"ItemBack锛歿result.msg}");
+                    AddErrorInfo("鏌ユ壘鎵樼洏璐т綅澶辫触", result.msg, Source);
                     return result;
                 }
                 #endregion
@@ -1416,10 +1537,11 @@
                         }
                         else
                         {
-                            LogHelper.Info($"ItemBack锛氬垱寤轰换鍔″け璐ワ紝鐗╂枡鍙穥model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�);
+
                             result.code = "1";
                             result.msg = $"鍒涘缓浠诲姟澶辫触锛岀墿鏂欏彿{model.PartNumber}涓嶅睘浜庤瀹氱墿鏂�;
-                            AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg);
+                            LogHelper.Info($"ItemBack锛歿result.msg}");
+                            AddErrorInfo("鐗╂枡缂栫爜鏍煎紡閿欒", result.msg, Source);
                             return result;
                         }
                         var EndLocs = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == areacode).ToList();
@@ -1434,7 +1556,7 @@
                             {
                                 result.code = "1";
                                 result.msg = $"缁堢偣搴撳尯锛歿areacode}鏃犲彲鐢ㄨ揣浣�;
-                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                                 return result;
                             }
 
@@ -1443,7 +1565,7 @@
                         {
                             result.code = "1";
                             result.msg = $"鏍规嵁缁堢偣搴撳尯锛歿areacode},鏈壘鍒板搴旇揣浣�;
-                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg);
+                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
                             return result;
                         }
                         //loc = StorageCompute(itemcode, areacode);
@@ -1458,19 +1580,19 @@
                     }
                     else
                     {
-                        LogHelper.Info($"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�);
+
                         result.code = "1";
                         result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�;
-                        AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                        AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                         return result;
                     }
                 }
                 else
                 {
-                    LogHelper.Info($"璐т綅:{Start}鎵句笉鍒板搴旇揣浣�);
+
                     result.code = "1";
                     result.msg = $"璐т綅:{Start}鎵句笉鍒板搴旇揣浣�;
-                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                     return result;
                 }
 
@@ -1560,11 +1682,12 @@
                 msg = "绾胯竟搴撳瓨鏌ヨ鎴愬姛"
 
             };
+            string Source = "MES";
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
 
             }
@@ -1611,11 +1734,12 @@
         internal static Result add(add model)
         {
             Result result = new Result() { code = "200", msg = "鐗╂枡涓绘暟鎹垱寤烘垚鍔� };
+            string Source = "MES";
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
             try
@@ -1624,24 +1748,26 @@
                 if (db.Queryable<TN_Material>().Where(a => a.S_ITEM_CODE == model.PartNumber).Count() > 0)
                 {
                     result.code = "1";
-                    result.msg = "鐗╂枡涓绘暟鎹凡瀛樺湪";
-                    AddErrorInfo("鐗╂枡涓绘暟鎹凡瀛樺湪", result.msg);
+                    result.msg = $"鐗╂枡缂栫爜:{model.PartNumber}鐨勭墿鏂欎富鏁版嵁宸插瓨鍦�;
+                    //  AddErrorInfo("鐗╂枡涓绘暟鎹凡瀛樺湪", result.msg, Source);
+                    LogHelper.Info($"add:{result.msg}");
                     return result;
                 }
                 TN_Material itemInfo = new TN_Material();
                 itemInfo.S_ITEM_CODE = model.PartNumber;
                 itemInfo.ITEM_TYPE = model.PartClass;
                 itemInfo.S_ITEM_NAME = model.PartDesc;
-                itemInfo.REMARK1 = model.StewingTime.ToString("yyyy-MM-dd");
-                itemInfo.REMARK2 = model.OverdueTime.ToString("yyyy-MM-dd");
+                itemInfo.REMARK1 = model.StewingTime;
+                itemInfo.REMARK2 = model.OverdueTime;
                 itemInfo.S_MP_TYPE = model.Unit;
-
-                db.Insertable<TN_Material>(itemInfo).ExecuteCommand();
+                if (db.Insertable<TN_Material>(itemInfo).ExecuteCommand()>0)
+                {
+                    LogHelper.Info($"add:鐗╂枡缂栫爜:{model.PartNumber}鐨勭墿鏂欎富鏁版嵁宸插悓姝�);
+                } ;
                 return result;
             }
             catch (Exception ex)
             {
-
                 result.code = "1";
                 result.msg = $"鐗╂枡涓绘暟鎹垱寤哄け璐�閿欒淇℃伅锛歿ex}";
                 LogHelper.Error("add Error锛� + ex.ToString(), ex);
@@ -1657,11 +1783,12 @@
         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);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
             string Start = ""; //鍙栬揣鐐�@@ -1687,7 +1814,7 @@
                     {
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹捣鐐箋model.InitialLocation}鏈壘鍒板搴旇揣浣嶇粦瀹氭墭鐩樻墭鐩�;
-                        AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg);
+                        AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg, Source);
                         return result;
                     }
                 }
@@ -1765,11 +1892,12 @@
         internal static Result CreatelevatorTask(Elevator model)
         {
             Result result = new Result() { code = "200", msg = "鐐瑰鐐逛换鍔″垱寤烘垚鍔� };
+            string Source = "MES";
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
 
@@ -1789,17 +1917,18 @@
                     {
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐箋startloc.S_CODE}鏈夐攣";
-                        AddErrorInfo("璐т綅鏈夐攣", result.msg);
+                        AddErrorInfo("璐т綅鏈夐攣", result.msg, Source);
                         return result;
                     }
 
                     var cntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == startloc.S_CODE).First();
                     if (cntr == null)
                     {
-                        LogHelper.Info($"callfixture:鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>鏍规嵁璐т綅{endloc.S_CODE}鏈壘鍒版墭鐩樿揣浣嶇粦瀹氬叧绯�);
+
                         result.code = "1";
                         result.msg = $"璧风偣{model.Data.start_loc_code}鏈煡璇㈢粦瀹氭墭鐩�;
-                        AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg);
+                        LogHelper.Info($"callfixture:鍒涘缓绌哄伐瑁呭懠鍙换鍔�=>{result.msg}");
+                        AddErrorInfo("鏌ユ壘鎵樼洏澶辫触", result.msg, Source);
                         return result;
                     }
 
@@ -1813,7 +1942,7 @@
                     {
                         result.code = "1";
                         result.msg = $"鍒涘缓浠诲姟澶辫触锛屾牴鎹揣浣嶇紪鐮�{dtcode}鏈壘鍒扮數姊揣浣�;
-                        AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                        AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                         return result;
                     }
 
@@ -1886,8 +2015,6 @@
 
         }
 
-
-
         /// <summary>
         /// 璐т綅淇℃伅涓婁紶
         /// </summary>
@@ -1897,6 +2024,7 @@
         {
 
             Result result = new Result() { code = "200", msg = "璐т綅淇℃伅涓婁紶鎴愬姛" };
+            String Source = "MES";
             RequestList<UploadLoc> result1 = new RequestList<UploadLoc>();
             List<UploadLoc> listuploadloc = new List<UploadLoc>();
             var db = new SqlHelper<object>().GetInstance();
@@ -1920,7 +2048,7 @@
                 {
                     result.code = "1";
                     result.msg = $"璐т綅涓婁紶澶辫触锛屾牴鎹揣浣嶇紪鐮亄item.Location}鏈壘鍒板搴旂殑璐т綅淇℃伅";
-                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg);
+                    AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
                     return result;
                 }
             }
@@ -1951,7 +2079,7 @@
                 LogHelper.Info($"鐗╂枡鍒颁綅鍥炴姤澶辫触=>鍥炴姤鍦板潃娌℃湁閰嶇疆");
                 result.code = "1";
                 result.msg = $"鐗╂枡鍒颁綅鍥炴姤澶辫触=>鍥炴姤鍦板潃娌℃湁閰嶇疆";
-                AddErrorInfo("鍦板潃閿欒", result.msg);
+                AddErrorInfo("鍦板潃閿欒", result.msg, Source);
             }
             return result;
         }
@@ -1965,11 +2093,12 @@
         internal static Result ClearLoc(ClearTask model)
         {
             Result result = new Result() { code = "200", msg = "搴撲綅娓呴櫎鎴愬姛" };
+            string Source = "MES";
             if (model == null)
             {
                 result.code = "1";
                 result.msg = "鍙傛暟涓簄ull";
-                AddErrorInfo("鍙傛暟涓虹┖", result.msg);
+                AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
             string loc = model.LocationNum;
@@ -2009,7 +2138,7 @@
                 {
                     result.code = "1";
                     result.msg = $"鏍规嵁璐т綅:{loc}鎵句笉鍒拌揣浣嶅叧绯�;
-                    AddErrorInfo("璐т綅涓虹┖", result.msg);
+                    AddErrorInfo("璐т綅涓虹┖", result.msg, Source);
                     return result;
                 }
             }
@@ -2151,7 +2280,9 @@
 
             #endregion
             var loc = LocationHelper.GetLocByItemCode(areacode, itemcode, level);
+            LogHelper.Info($"airlift=>鏍规嵁搴撳尯缂栫爜:{areacode}锛岀墿鏂欑紪鐮�{itemcode},鐗╂枡绛夌骇璁$畻鍑烘湁鎵樼洏璐т綅{JsonConvert.SerializeObject(loc)}");
             result = FindStartcolByLoclist(loc);
+            LogHelper.Info($"airlift=>鍙敤璐т綅涓猴細{JsonConvert.SerializeObject(result)}");
             return result;
         }
 
@@ -2175,26 +2306,31 @@
             }
             return result;
         }
+
         /// <summary>
-        /// 鍒涘缓鎵樼洏鐗╂枡缁戝畾鍏崇郴
+        /// 绔嬪簱浠诲姟涓嬪彂鍒涘缓鎵樼洏鐗╂枡缁戝畾鍏崇郴
         /// </summary>
-        /// <param name="loc">璐т綅缂栫爜</param>
-        /// <param name="cntr">鎵樼洏缂栫爜</param>
-        /// <param name="partNumber">鐗╂枡缂栫爜</param>
-        /// <param name="partDesc">鐗╂枡鎻忚堪</param>
-        /// <param name="partType">鐗╂枡绫诲瀷</param>
-        /// <param name="cntrtype">鎵樼洏绫诲瀷</param>
-        /// <param name="unit">鐗╂枡鍗曚綅</param>
-        /// <param name="weight">鐗╂枡閲嶉噺</param>
-        internal static bool CreateCntrIteminfo(string loc, string cntr, string partNumber, string partDesc, string partType, string batch, string unit, string weight, string cntrtype = "1", string level = "")
+        internal static bool CreateCntrIteminfo(partData partData, taskData taskData)
         {
-            return ContainerHelper.CreateCntrItem(loc, cntr, partNumber, partDesc, partType, cntrtype, batch, weight, unit, level);
+            if (partData == null && taskData == null)
+            {
+                LogHelper.Info($"CreateCntrIteminfo==> 绔嬪簱浠诲姟涓嬪彂鍙傛暟鏈夌┖锛屽垱寤虹墿鏂欐墭鐩樼粦瀹氬叧绯诲け璐�);
+                return false;
+            }
+            else
+            {
+                return ContainerHelper.CreateCntrItem(taskData.pickStation, partData.rfid, partData.partNumber, partData.partDesc, partData.partType, taskData.carrierType, partData.lotNumber, taskData.wmsLot, partData.weight, partData.unit,
+                    taskData.tyreType, taskData.supplier, taskData.receiveLot, taskData.subpool, partData.productionTime, partData.maturityTime, taskData.level);
+            }
+
         }
+        private static object _lockLocation = new object();
         /// <summary>
         /// 鏍规嵁鎵樼洏缂栫爜锛屾満鍙扮紪鐮侊紝宸ヨ绫诲瀷璁$畻鏈哄彴绾胯竟鍖哄煙
         /// </summary>
         /// <param name="cntrcode">鎵樼洏缂栫爜</param>
         /// <param name="jtcode">鏈哄彴缂栫爜</param>
+        /// <param name="cntrType">鎵樼洏绫诲瀷</param>
         /// <returns></returns>
         internal static Location Computeloc(string cntrcode, string jtcode, string cntrType)
         {
@@ -2204,17 +2340,19 @@
 
             //  var location = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == cntrcode).First();
 
-
-            var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First();
-            if (loc != null)
+            lock (_lockLocation)
             {
-                End = loc;
-            }
-            else
-            {
-                LogHelper.Info($"Computeloc==銆嬫牴鎹満鍙板垎缁勶細{jtcode},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�);
-            }
+                var loc = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim() && a.S_NOTE == cntrType && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0).First();
+                if (loc != null)
+                {
+                    End = loc;
+                }
+                else
+                {
+                    LogHelper.Info($"Computeloc==銆嬫牴鎹満鍙板垎缁勶細{jtcode},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�);
+                }
 
+            }
             return End;
         }
 
@@ -2234,7 +2372,7 @@
             {
                 var error = new ErrorInfo
                 {
-                    EEEORMESSAGE = errorInfo,
+                    ERRORMESSAGE = errorInfo,
                     TASKNO = taskno,
                     AREACODE = areacode,
                     REMAKE = remake,

--
Gitblit v1.9.1