From 9ddec4808631025d36d3c5a816d55ef77a29d4c7 Mon Sep 17 00:00:00 2001
From: lss <2538410689@qq.com>
Date: 星期三, 16 七月 2025 17:30:30 +0800
Subject: [PATCH] 111

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs |  184 ++++++++++++++++++++++-----------------------
 1 files changed, 89 insertions(+), 95 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 04c62d7..68fe676 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -799,16 +799,15 @@
 
         public static object _Point = new object();
         /// <summary>
-        /// 鍏ュ钩搴�+        /// 鐐瑰鐐规帴鍙�         /// </summary>
         /// <param name="model"></param>
-        /// <param name="n_type">0:pda涓嬪彂浠诲姟锛�:mes涓嬪彂浠诲姟</param>
         /// <returns></returns>
         internal static Result Point(PointModel model)
         {
             Result result = new Result() { code = "200", msg = "鍏ュ钩搴撲换鍔′笅鍙戞垚鍔� };
             string Source = "Mes";
-          
+
             if (model == null)
             {
                 result.code = "1";
@@ -816,104 +815,85 @@
                 AddErrorInfo("鍙傛暟涓虹┖", result.msg, Source);
                 return result;
             }
+            //1.鍑哄钩搴擄紝2鍏ュ钩搴擄紝3骞冲簱绌哄伐瑁呭懠鍙紝4骞冲簱浣欐枡鍥炲簱锛�绮夋枡绌烘墭杩斿洖銆�             var db = new SqlHelper<object>().GetInstance();
-            Location loc = null;
+            string type = "";
+            Location startloc = null;
+            Location endloc = null;
+            switch (model.Status)
+            {
+                case "1":
+                    type = "鍑哄钩搴�;
+                    break;
+                case "2":
+                    type = "鍏ュ钩搴�;
+                    break;
+                case "3":
+                    type = "骞冲簱绌哄伐瑁呭懠鍙�;
+                    break;
+                case "4":
+                    type = "骞冲簱浣欐枡鍥炲簱";
+                    break;
+                case "5":
+                    type = "绮夋枡绌烘墭杩斿洖";
+                    break;
+            }
+            if (string.IsNullOrEmpty(type))
+            {
+                result.code = "1";
+                result.msg = $"浠诲姟绫诲瀷{model.Status},涓嶅湪瑙勫畾鑼冨洿";
+                AddErrorInfo("浠诲姟绫诲瀷閿欒", result.msg, Source);
+                return result;
+            }
 
-            string Start = model.InitialLocation;  //璧风偣璐т綅
-            string itemcode = model.PartNumber;    //鐗╂枡缂栫爜
-            string areacode = "";
             try
             {
-                lock (_Putin)
+                lock (_Point)
                 {
-                    #region 鍏ュ簱妫�煡鎵樼洏鐗╂枡琛ㄦ湁鏃犳暟鎹�-                    var cntritem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First();
-                    if (cntritem == null)
+                    startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.InitialLocation).First();
+                    if (startloc == null)
                     {
                         result.code = "1";
-                        result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}鏃犵粦瀹氱墿鏂欐暟鎹�;
-                        LogHelper.Info($"ItemBack锛歿result.msg}");
-                        AddErrorInfo("鎵樼洏缁戝畾鐗╂枡鏁版嵁涓虹┖", result.msg, Source);
+                        result.msg = $"鏍规嵁璧风偣{model.InitialLocation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
+                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
                         return result;
-                    }
-                    #endregion
-
-                    #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)
-                        {
-
-                            result.code = "1";
-                            result.msg = $"鍒涘缓浠诲姟澶辫触锛屾墭鐩�{model.Rfid}缁戝畾浣嶇疆涓嶆槸璧风偣锛歿Start}";
-                            LogHelper.Info($"ItemBack锛歿result.msg}");
-                            AddErrorInfo("鎵樼洏缁戝畾浣嶇疆涓嶅悓", result.msg, Source);
-                            return result;
-                        }
                     }
                     else
                     {
-                        LocationHelper.BindingLoc(Start, new List<string> { model.Rfid });
-                    }
-                   
-                    #endregion
-
-                    #region 鏍规嵁璧风偣璐т綅鐨勪粨搴撶紪鐮�鑾峰彇骞冲簱缂栫爜,骞惰绠楀叆搴撹揣浣�-                    string End = "";
-                    var startloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == Start).First();
-                    if (startloc != null)
-                    {
-                        //鏍规嵁浠撳簱 璁$畻搴撳尯
-                        var whcode = Settings.wareLoc.Where(a => a.AreaCode == startloc.S_WH_CODE).FirstOrDefault();
-                        if (whcode != null)
+                        //鍒ゆ柇璧风偣鏄惁缁戝畾鍏朵粬鎵樼洏
+                        var CntrRel = LocationHelper.GetLocCntrRel(startloc.S_CODE).OrderBy(a => a.T_CREATE).FirstOrDefault();
+                        if (CntrRel != null)
                         {
-                            areacode = whcode.PMK;
+                            if (CntrRel.S_CNTR_CODE != model.Rfid)
+                            {
+                                result.code = "1";
+                                result.msg = $"鏍规嵁璧风偣锛歿model.InitialLocation}鑾峰彇鎵樼洏:{CntrRel.S_CNTR_CODE}涓庝笅鍙戞墭鐩橈細{model.Rfid}涓嶄竴鑷达紝璇锋鏌ユ墭鐩樼爜鏄惁姝g‘";
+                                AddErrorInfo("鎵樼洏鐮佹牎妫�け璐�, result.msg, Source);
+                                return result;
+                            }
                         }
                         else
                         {
-                            result.code = "1";
-                            result.msg = $"鏍规嵁璧风偣浠撳簱缂栫爜锛歿startloc.S_WH_CODE}鏈壘鍒板搴旈厤缃枃浠�;
-                            LogHelper.Info($"Putin==> {result.msg}");
-                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
-                            return result;
-                        }
-
-
-                        loc = StorageCompute(itemcode, areacode);
-
-                        if (loc != null)
-                        {
-                            End = loc.S_CODE;
-                        }
-                        else
-                        {
-
-                            result.code = "1";
-                            result.msg = $"搴撳尯:{areacode}鏃犲彲鐢ㄨ揣浣�;
-                            LogHelper.Info($"Putin==> {result.msg}");
-                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
-                            return result;
+                            LocationHelper.BindingLoc(startloc.S_CODE, new List<string> { model.Rfid });
                         }
                     }
-                    else
+                    endloc = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == model.TargetLocation).First();
+                    if (endloc == null)
                     {
-
                         result.code = "1";
-                        result.msg = $"浠诲姟璧风偣:{Start}鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
-                        LogHelper.Info($"Putin==> {result.msg}");
-                        AddErrorInfo("鏌ユ壘璐т綅澶辫触", result.msg, Source);
+                        result.msg = $"鏍规嵁缁堢偣{model.TargetLocation},鎵句笉鍒板搴旇揣浣嶏紝璇锋鏌ヨ揣浣嶈〃";
+                        AddErrorInfo("璐т綅鏌ユ壘澶辫触", result.msg, Source);
                         return result;
                     }
-                    #endregion
+
 
                     #region 鍒涘缓浠诲姟
-                    if (!string.IsNullOrEmpty(Start) && !string.IsNullOrEmpty(End))
+                    if (endloc != null && startloc != null)
                     {
                         if (startloc.N_LOCK_STATE != 0)
                         {
                             result.code = "1";
-                            result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{Start}鏈夐攣";
+                            result.msg = $"鍒涘缓浠诲姟澶辫触锛岃捣鐐�{startloc.S_CODE}鏈夐攣";
                             AddErrorInfo("璐т綅鏈夐攣", result.msg, Source);
                             return result;
                         }
@@ -921,27 +901,41 @@
                         var wcsTask = new WCSTask
                         {
                             S_CODE = WCSHelper.GenerateTaskNo(),
-                            S_TYPE = "鍏ュ钩搴�,
+                            S_TYPE = type,
                             S_EQ_NO = model.TaskNumber,
-                            S_START_LOC = Start,
-                            S_END_LOC = End,
+                            S_START_LOC = startloc.S_CODE,
+                            S_END_LOC = endloc.S_CODE,
                             S_START_WH = startloc.S_WH_CODE,
                             S_START_AREA = startloc.S_AREA_CODE,
-                            S_END_WH = loc.S_WH_CODE,
-                            S_END_AREA = loc.S_AREA_CODE,
+                            S_END_WH = endloc.S_WH_CODE,
+                            S_END_AREA = endloc.S_AREA_CODE,
                             N_CNTR_COUNT = 1,
                             N_SCHEDULE_TYPE = 1,
                             S_CNTR_CODE = model.Rfid,
                             N_START_LAYER = 1,
                             N_END_LAYER = 1,
                             N_PRIORITY = 1,
-                            Z_TYPE = n_type
+                            Z_TYPE = 5
                         };
-                        LogHelper.Info("鍒涘缓鍏ュ钩搴撲换鍔★細" + JsonConvert.SerializeObject(wcsTask));
+                        LogHelper.Info("鍒涘缓鐐瑰鐐逛换鍔★細" + JsonConvert.SerializeObject(wcsTask));
                         if (WCSHelper.CreateTask(wcsTask))
                         {
-                            //LocationHelper.LockLoc(Start, 2);
-                            //LocationHelper.LockLoc(End, 1);
+                            if (type == "骞冲簱浣欐枡鍥炲簱")
+                            { //鍒涘缓浠诲姟鎴愬姛 鏇存柊浣欐枡淇℃伅
+                                var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE.Trim() == model.Rfid).First();
+                                if (CntrItem != null)
+                                {
+                                    CntrItem.F_WEIGHT = model.Weight.ToString();
+                                    CntrItem.S_BS_TYPE = "浣欐枡";
+                                    //CntrItem.F_QTY = float.Parse(model.qty);
+                                    //CntrItem.S_ITEM_STATE = model..QualityStatus;
+
+                                    db.Updateable(CntrItem).UpdateColumns(a => new { a.F_WEIGHT, a.S_BS_TYPE }).ExecuteCommand();
+                                }
+                            }
+
+                            LocationHelper.LockLoc(startloc.S_CODE, 2);
+                            LocationHelper.LockLoc(endloc.S_CODE, 1);
                             LogHelper.Info("鍒涘缓浠诲姟鎴愬姛");
                         }
                         else
@@ -2748,14 +2742,14 @@
             var db = new SqlHelper<HangChaAGV>().GetInstance();
             DeviceInfoModel device = new DeviceInfoModel();
 
-            List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//鍙犵洏鏈烘姤閿欎俊鎭�+           // List<DeviceInfos> deviceInfos = new List<DeviceInfos>();//鍙犵洏鏈烘姤閿欎俊鎭�                                                                     // List<AgvInfos> agvInfos = new List<AgvInfos>();//agv鎶ラ敊淇℃伅
 
             //鑾峰彇鍐呭瓨涓彔鐩樻満鐨勬姤閿欎俊鎭�-            foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory)
-            {
-                deviceInfos.Add(new DeviceInfos() { Device = dpjInfo.Value.DeviceName, DeviceInfo = dpjInfo.Value.ErrorInfo });
-            }
+            //foreach (var dpjInfo in DeviceProcess.DpjInfoDirectory)
+            //{
+            //    deviceInfos.Add(new DeviceInfos() { Device = dpjInfo.Value.DeviceName, DeviceInfo = dpjInfo.Value.ErrorInfo });
+            //}
             //  device.DeviceInfos = deviceInfos;
             //鑾峰彇杞﹁締鎶ヨ淇℃伅
             var agvDeviceInfo = db.Queryable<HangChaAGV>().ToList();
@@ -2764,14 +2758,14 @@
                 device.AgvQty = agvDeviceInfo.Count;
                 device.AgvErrorQty = agvDeviceInfo.FindAll(a => a.agvErrCode != "0" || int.Parse(a.errCode2) > 1 || int.Parse(a.faildCode) > 1).Count;
                 device.AgvChargeQty = agvDeviceInfo.FindAll(a => a.errCode2 == "1").Count;
-                device.AgvRunQty = agvDeviceInfo.FindAll(a => a.agvErrCode == "0"&& a.errCode2 == "0" && a.faildCode == "1").Count;
-                foreach (var agv in agvDeviceInfo)
-                {
-                    string agvErrorInfo = GetAgvAlarmSendCodeTwo(agv.agvNo, agv.agvErrCode, agv.errCode2, agv.faildCode);
-                    deviceInfos.Add(new DeviceInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo });
-                }
+                device.AgvRunQty = agvDeviceInfo.FindAll(a => a.agvErrCode == "0" && a.errCode2 == "0" && a.faildCode == "1").Count;
+                //foreach (var agv in agvDeviceInfo)
+                //{
+                //    string agvErrorInfo = GetAgvAlarmSendCodeTwo(agv.agvNo, agv.agvErrCode, agv.errCode2, agv.faildCode);
+                //    deviceInfos.Add(new DeviceInfos() { AgvNo = agv.agvNo, AgvInfo = agvErrorInfo });
+                //}
             }
-            device.DeviceInfos = deviceInfos;
+          //  device.DeviceInfos = deviceInfos;
 
             return device;
         }

--
Gitblit v1.9.1