From 00ecab4ee5cec0d04665ca16d0eb30c1ba4ea1f3 Mon Sep 17 00:00:00 2001
From: lss <2538410689@qq.com>
Date: 星期三, 09 七月 2025 17:32:24 +0800
Subject: [PATCH] 111

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs |   80 +++++++++++++++++++++++++++++++--------
 1 files changed, 63 insertions(+), 17 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 9ea6922..b40756c 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.JiaTong/api/ApiHelper.cs
@@ -47,6 +47,7 @@
         /// <returns></returns>
         internal static Result Createtask(CreateTask model)
         {
+           
             Result result = new Result() { code = "0", msg = "鍒涘缓鎴愬姛" };
             if (model == null)
             {
@@ -582,6 +583,15 @@
                                 AddErrorInfo("搴撳尯鏌ユ壘澶辫触", result.msg);
                                 return result;
                             }
+                            int pri = 1;
+                            var area = Settings.wareLoc.Where(a => a.AreaCode == endloc.S_WH_CODE).First();
+                            if (area != null) 
+                            {
+                                if (area.XbAreaCodes.Contains(endloc.S_AREA_CODE))
+                                {
+                                    pri = 2;
+                                }
+                            }   
                             //鍒涘缓wcs浠诲姟
                             var wcsTask = new WCSTask
                             {
@@ -596,7 +606,7 @@
                                 S_END_AREA = endloc.S_AREA_CODE,
                                 N_SCHEDULE_TYPE = 1,
                                 S_CNTR_CODE = CntrCode,
-                                N_PRIORITY = taskData.priority,
+                                N_PRIORITY = pri,
                                 Z_TYPE = n_type,
                                 N_START_LAYER = 1,
                                 N_END_LAYER = 1,
@@ -954,6 +964,7 @@
                             S_CNTR_CODE = model.Rfid,
                             N_START_LAYER = 1,
                             N_END_LAYER = 1,
+                            N_PRIORITY = 1,
                             Z_TYPE = n_type
                         };
                         LogHelper.Info("鍒涘缓鍏ュ钩搴撲换鍔★細" + JsonConvert.SerializeObject(wcsTask));
@@ -1082,27 +1093,51 @@
 
                     #region 鏍规嵁鐗╂枡缂栫爜璁$畻鍑哄簱璐т綅锛岄�寰�嚎杈逛綅缃�                     Location Endloc = null;
+                  
                     //鏍规嵁鐗╂枡缂栫爜璁$畻鍑哄簱璐т綅
                     var loc = airlift(areacode, itemcode, model.PartLevel, model.PowderType);
                     if (loc != null)
                     {
                         Start = loc.S_CODE;
-                        //鏍规嵁鍑哄簱璐т綅鎵惧埌缁戝畾鎵樼洏锛岃幏鍙栧叆鏈哄彴璐т綅
+                      
                         var CntrRel = LocationHelper.GetLocCntrRel(loc.S_CODE).FirstOrDefault();
                         CntrCode = CntrRel.S_CNTR_CODE;
-                        Endloc = Computeloc(CntrCode, model.WorkCenter, cntrType);
-                        if (Endloc != null)
+                        //缁欑粓鐐圭敤缁堢偣锛屾病缁欑粓鐐圭敤鏈哄彴搴撳尯璁$畻璐т綅
+                        if (string.IsNullOrEmpty(model.TargetLocation))
                         {
-                            End = Endloc.S_CODE;
+                                          
+                            Endloc = Computeloc(CntrCode, model.WorkCenter, cntrType);
+                            if (Endloc != null)
+                            {
+                                End = Endloc.S_CODE;
+                            }
+                            else
+                            {
+                                result.code = "1";
+                                result.msg = $"Computeloc==銆嬫牴鎹満鍙扮紪鐮侊細{model.WorkCenter},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�;
+                                LogHelper.Info($"ItemBack锛歿result.msg}");
+                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
+                                return result;
+                            }
                         }
                         else
                         {
-                            result.code = "1";
-                            result.msg = $"Computeloc==銆嬫牴鎹満鍙扮紪鐮侊細{model.WorkCenter},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�;
-                            LogHelper.Info($"ItemBack锛歿result.msg}");
-                            AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
-                            return result;
+                        
+                            Endloc = db.Queryable<Location>().Where(a => a.S_CODE == model.TargetLocation).First();
+                            if (Endloc != null)
+                            {
+                                End = Endloc.S_CODE;
+                            }
+                            else
+                            {
+                                result.code = "1";
+                                result.msg = $"Computeloc==銆嬫牴鎹粓鐐硅揣浣嶏細{model.TargetLocation} 鏈壘鍒拌揣浣嶆暟鎹紝璇锋鏌ヨ揣浣嶈〃";
+                                LogHelper.Info($"ItemBack锛歿result.msg}");
+                                AddErrorInfo("鏌ユ壘搴撳尯澶辫触", result.msg, Source);
+                                return result;
+                            }
                         }
+                       
                     }
                     else
                     {
@@ -1152,6 +1187,7 @@
                         S_CNTR_CODE = CntrCode,
                         N_START_LAYER = 1,
                         N_END_LAYER = 1,
+                        N_PRIORITY = 1,
                         Z_TYPE = n_type
 
                     };
@@ -1411,6 +1447,8 @@
                             S_CNTR_CODE = model.Rfid,
                             N_START_LAYER = 1,
                             N_END_LAYER = endlayer,
+                            N_PRIORITY = 1,
+                            S_B_STATE="绛夊緟鎺ㄩ�",
                             Z_TYPE = 5
                         };
                         LogHelper.Info("鍒涘缓绌烘墭鍥炲簱浠诲姟锛� + JsonConvert.SerializeObject(wcsTask));
@@ -1590,6 +1628,7 @@
                             N_START_LAYER = 1,
                             N_END_LAYER = 1,
                             Z_TYPE = 5,
+                            N_PRIORITY = 1,
                             S_NOTE = "绮夋枡"
                         };
                         LogHelper.Info("鍒涘缓鍛煎彨绌烘墭浠诲姟锛� + JsonConvert.SerializeObject(wcsTask));
@@ -1814,6 +1853,7 @@
                             S_CNTR_CODE = model.Rfid,
                             N_START_LAYER = 1,
                             N_END_LAYER = 1,
+                            N_PRIORITY = 1,
                             Z_TYPE = 5
 
                         };
@@ -2065,6 +2105,7 @@
                         S_CNTR_CODE = CntrCode,
                         N_START_LAYER = 1,
                         N_END_LAYER = 1,
+                        N_PRIORITY = 1,
                         //  N_TYPE = n_type
 
 
@@ -2201,6 +2242,7 @@
                         S_CNTR_CODE = cntr.S_CNTR_CODE,
                         N_END_LAYER = 1,
                         Z_TYPE = 6,
+                        N_PRIORITY = 1,
                         S_B_STATE = "鐢垫鎺ㄩ�"
                     };
 
@@ -2471,10 +2513,9 @@
                     var location = db.Queryable<Location>().Where(a => a.S_CODE.Trim() == loc).First();
                     if (location != null)
                     {
-                        var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc).ToList();
+                        var loccntr = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE.Trim() == loc.Trim()).ToList();
                         if (loccntr.Count > 0)
                         {
-
                             var cntrcodes = loccntr.Select(a => a.S_CNTR_CODE.Trim()).ToList();
                             if (LocationHelper.Clear(loc, cntrcodes))
                             {
@@ -2660,7 +2701,8 @@
         /// <param name="level">鐗╂枡绛夌骇</param>
         /// <param name="powderType">鏈哄瀷</param>
         /// <returns></returns>
-        internal static Location airlift(string areacode, string itemcode, string level, string powderType)
+        internal static Location 
+            airlift(string areacode, string itemcode, string level, string powderType)
         {
             var db = new SqlHelper<object>().GetInstance();
             Location result = null;
@@ -2800,16 +2842,20 @@
 
             lock (_lockLocation)
             {
-                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 && a.S_LOCK_STATE == "鏃�).First();
-                if (loc != null)
+                if (string.IsNullOrEmpty(cntrType))
                 {
-                    End = loc;
+                    End = db.Queryable<Location>().Where(a => a.S_AREA_CODE.Trim() == jtcode.Trim()  && a.N_CURRENT_NUM == 0 && a.N_LOCK_STATE == 0 && a.S_LOCK_STATE == "鏃�).First();
                 }
                 else
                 {
+                    End = 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 && a.S_LOCK_STATE == "鏃�).First();
+                }
+                  
+                if (End == null)
+                {
                     LogHelper.Info($"Computeloc==銆嬫牴鎹満鍙板垎缁勶細{jtcode},宸ヨ绫诲瀷锛歿cntrType} 鏈壘鍒扮┖璐т綅鏁版嵁锛岃妫�煡璐т綅琛�);
                 }
-
+               
             }
             return End;
         }

--
Gitblit v1.9.1