From c378b390c2b98c00135d055de6896d2d5a8ccdd3 Mon Sep 17 00:00:00 2001
From: lss <Lss@HanInfo>
Date: 星期一, 19 五月 2025 17:21:54 +0800
Subject: [PATCH] 大洋原材料库业务开发

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/api/ApiHelper.cs |  252 ++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 210 insertions(+), 42 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/api/ApiHelper.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/api/ApiHelper.cs
index 46fa97f..5f0163d 100644
--- a/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/api/ApiHelper.cs
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.DaYang/api/ApiHelper.cs
@@ -140,7 +140,7 @@
             return result;
         }
 
-      
+
 
         private static object lockObj = new object();
         /// <summary>
@@ -148,13 +148,13 @@
         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
-        internal static Result createtask(CreateTaskModel model)
+        internal static Result<Empty> createtask(CreateTaskModel model)
         {
-            Result result = new Result { resultCode = 0, resultMsg = "鍒涘缓鎴愬姛" };
+            Result<Empty> result = new Result<Empty> { Code = 0, Msg = "鍒涘缓鎴愬姛" };
             if (model == null)
             {
-                result.resultCode = -1;
-                result.resultMsg = "鍏ュ弬涓虹┖";
+                result.Code = -1;
+                result.Msg = "鍏ュ弬涓虹┖";
                 return result;
             }
             var db = new SqlHelper<object>().GetInstance();
@@ -177,9 +177,9 @@
                         startloc = LocationHelper.GetLoc(model.startBit);
                         if (startloc == null)
                         {
-                            result.resultCode = -1;
-                            result.resultMsg = $"鏍规嵁璧风偣:{model.startBit}鏈壘鍒拌揣浣嶄俊鎭�;
-                            LogHelper.Info($"creattask:鏍规嵁璧风偣:{model.startBit}鏈壘鍒拌揣浣嶄俊鎭�);
+                            result.Code = -1;
+                            result.Msg = $"鏍规嵁璧风偣:{model.startBit}鏈壘鍒拌揣浣嶄俊鎭�;
+                            LogHelper.Info($"creattask:{result.Msg}");
                             return result;
                         }
                         else
@@ -187,9 +187,9 @@
                             var cntr = LocationHelper.GetLocCntrRel(endloc.S_CODE).FirstOrDefault();
                             if (cntr == null)
                             {
-                                result.resultCode = -1;
-                                result.resultMsg = $"鏍规嵁璧风偣:{model.startBit}鏈壘鍒扮粦瀹氭墭鐩�;
-                                LogHelper.Info($"creattask:鏍规嵁璧风偣:{model.startBit}鏈壘鍒扮粦瀹氭墭鐩�);
+                                result.Code = -1;
+                                result.Msg = $"鏍规嵁璧风偣:{model.startBit}鏈壘鍒扮粦瀹氭墭鐩�;
+                                LogHelper.Info($"creattask:{result.Msg}");
                                 return result;
                             }
                             else
@@ -203,9 +203,9 @@
                         endloc = LocationHelper.InStorage(startloc);
                         if (endloc == null)
                         {
-                            result.resultCode = -1;
-                            result.resultMsg = $"鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌";
-                            LogHelper.Info($"creattask:鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌");
+                            result.Code = -1;
+                            result.Msg = $"鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌";
+                            LogHelper.Info($"creattask:{result.Msg}");
                             return result;
                         }
                         #endregion
@@ -241,9 +241,9 @@
                     }
                     else
                     {
-                        result.resultCode = -1;
-                        result.resultMsg = $"浠诲姟绫诲瀷鏈夎锛寋model.TaskType}浠诲姟绫诲瀷涓嶆槸瑙勫畾浠诲姟绫诲瀷";
-                        LogHelper.Info($"creattask:浠诲姟绫诲瀷鏈夎锛寋model.TaskType}浠诲姟绫诲瀷涓嶆槸瑙勫畾浠诲姟绫诲瀷");
+                        result.Code = -1;
+                        result.Msg = $"浠诲姟绫诲瀷鏈夎锛寋model.TaskType}浠诲姟绫诲瀷涓嶆槸瑙勫畾浠诲姟绫诲瀷";
+                        LogHelper.Info($"creattask:{result.Msg}");
                         return result;
                     }
 
@@ -253,8 +253,8 @@
                 }
                 catch (Exception ex)
                 {
-                    result.resultCode = -1;
-                    result.resultMsg = $"{ex.ToString()}";
+                    result.Code = -1;
+                    result.Msg = $"{ex.ToString()}";
                     return result;
 
                 }
@@ -268,13 +268,13 @@
         /// </summary>
         /// <param name="model"></param>
         /// <returns></returns>
-        internal static Result EquipmentInfo(EquipmentInfoModel model)
+        internal static Result<Empty> NotifyDeviceSignal(NotifyDeviceSignalModel model)
         {
-            Result result = new Result { resultCode = 0, resultMsg = "鍒涘缓鎴愬姛" };
+            Result<Empty> result = new Result<Empty> { Code = 0, Msg = "鍒涘缓鎴愬姛" };
             if (model == null)
             {
-                result.resultCode = -1;
-                result.resultMsg = "鍏ュ弬涓虹┖";
+                result.Code = -1;
+                result.Msg = "鍏ュ弬涓虹┖";
                 return result;
             }
             Location endloc = new Location();
@@ -282,28 +282,29 @@
             string cntrcode = model.CntrNo;
             var db = new SqlHelper<object>().GetInstance();
 
-            if (model.DeviceNo=="1")//鍙犵洏鏈�+            if (model.DeviceNo == "1")//鍙犵洏鏈�             {
-
-            }
-            else //鍏ュ簱绌�-            {
-                #region 鑾峰彇璧风偣淇℃伅
-                //鏍规嵁鎵樼洏鑾峰彇璧风偣淇℃伅
-                var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == cntrcode).First();
-                if (CntrLoc == null)
+                #region 鑾峰彇璧风偣淇℃伅锛屽苟鍒ゆ柇绌烘墭鏄惁鍙犳弧
+                //鏍规嵁璧风偣 鑾峰彇缁戝畾鎵樼洏鏁伴噺
+                var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_LOC_CODE == model.Loc).ToList();
+                if (CntrLoc.Count < 4)
                 {
-                    result.resultCode = -1;
-                    result.resultMsg = $"鏍规嵁鎵樼洏:{cntrcode}鏈壘鍒扮粦瀹氭墭鐩�;
-                    LogHelper.Info($"creattask:鏍规嵁鎵樼洏:{cntrcode}鏈壘鍒扮粦瀹氭墭鐩�);
+                    result.Code = -1;
+                    result.Msg = $"鏍规嵁璐т綅:{model.Loc}鑾峰彇鎵樼洏鏁伴噺灏忎簬4";
+                    LogHelper.Info($"EquipmentInfo:{result.Msg}");
                     return result;
                 }
-                startloc = LocationHelper.GetLoc(CntrLoc.S_LOC_CODE);
+                else
+                {
+                    //鎷兼帴鎵樼洏鍙�+                    cntrcode = CntrLoc.Select(a => a.S_CNTR_CODE).ToString();
+                }
+                startloc = LocationHelper.GetLoc(model.Loc);
                 if (startloc == null)
                 {
-                    result.resultCode = -1;
-                    result.resultMsg = $"鏍规嵁璧风偣:{CntrLoc.S_LOC_CODE}鏈壘鍒拌揣浣嶄俊鎭�;
-                    LogHelper.Info($"creattask:鏍规嵁璧风偣:{CntrLoc.S_LOC_CODE}鏈壘鍒拌揣浣嶄俊鎭�);
+                    result.Code = -1;
+                    result.Msg = $"鏍规嵁璧风偣:{model.Loc}鏈壘鍒拌揣浣嶄俊鎭�;
+                    LogHelper.Info($"EquipmentInfo:{result.Msg}");
                     return result;
                 }
 
@@ -313,11 +314,12 @@
                 endloc = LocationHelper.InStorage(startloc);
                 if (endloc == null)
                 {
-                    result.resultCode = -1;
-                    result.resultMsg = $"鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌";
-                    LogHelper.Info($"creattask:鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌");
+                    result.Code = -1;
+                    result.Msg = $"鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌";
+                    LogHelper.Info($"EquipmentInfo:{result.Msg}");
                     return result;
                 }
+
                 #endregion
 
                 #region 鍒涘缓浠诲姟
@@ -347,13 +349,179 @@
                 }
                 #endregion
             }
+            else //鍏ュ簱绌�+            {
+                //鍏ュ簱鍙g敵璇峰叆搴�+                if (model.SignalType == 1)
+                {
+                    #region 鑾峰彇璧风偣淇℃伅
+                    //鏍规嵁鎵樼洏鑾峰彇璧风偣淇℃伅
+                    var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == cntrcode).First();
+                    if (CntrLoc == null)
+                    {
+                        result.Code = -1;
+                        result.Msg = $"鏍规嵁鎵樼洏:{cntrcode}鏈壘鍒扮粦瀹氭墭鐩�;
+                        LogHelper.Info($"EquipmentInfo:{result.Msg}");
+                        return result;
+                    }
+                    startloc = LocationHelper.GetLoc(CntrLoc.S_LOC_CODE);
+                    if (startloc == null)
+                    {
+                        result.Code = -1;
+                        result.Msg = $"鏍规嵁璧风偣:{CntrLoc.S_LOC_CODE}鏈壘鍒拌揣浣嶄俊鎭�;
+                        LogHelper.Info($"EquipmentInfo:{result.Msg}");
+                        return result;
+                    }
+
+                    #endregion
+
+                    #region 璁$畻绔嬪簱缁堢偣
+                    endloc = LocationHelper.InStorage(startloc);
+                    if (endloc == null)
+                    {
+                        result.Code = -1;
+                        result.Msg = $"鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌";
+                        LogHelper.Info($"EquipmentInfo:鏈绠楀埌绔嬪簱缁堢偣璐т綅锛岃妫�煡璐т綅鎯呭喌");
+                        return result;
+                    }
+                    #endregion
+
+                    #region 鍒涘缓浠诲姟
+                    if (startloc != null && endloc != null)
+                    {
+                        var wcsTask = new WCSTask
+                        {
+                            S_CODE = WCSHelper.GenerateTaskNo(),
+                            S_TYPE = "鍏ュ簱",
+                            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 = endloc.S_WH_CODE,
+                            S_END_AREA = endloc.S_AREA_CODE,
+                            N_CNTR_COUNT = 1,
+                            N_SCHEDULE_TYPE = 2,
+                            S_CNTR_CODE = cntrcode
+                        };
+                        LogHelper.Info("鍒涘缓鍏ュ钩搴撲换鍔★細" + JsonConvert.SerializeObject(wcsTask));
+                        if (WCSHelper.CreateTask(wcsTask))
+                        {
+                            LocationHelper.LockLoc(startloc.S_CODE, 2);
+                            LocationHelper.LockLoc(endloc.S_CODE, 1);
+                            LogHelper.Info("鍒涘缓浠诲姟鎴愬姛");
+                        }
+                    }
+                    #endregion
+                }
+                //鍏ュ簱绌虹敵璇峰彔鐩�+                else
+                {
+                    //鍒ゆ柇璁惧鐘舵�鏄惁灞炰簬鍙犵洏鐘舵�
+                    var DeviceStatu = db.Queryable<EquipmentStatus>().Where(a => a.deviceNo == model.DeviceNo).First();
+                    if (DeviceStatu != null && DeviceStatu.Status == "1")
+                    {
+                        #region 鑾峰彇璧风偣淇℃伅
+                        //鏍规嵁鎵樼洏鑾峰彇璧风偣淇℃伅
+                        var CntrLoc = db.Queryable<LocCntrRel>().Where(a => a.S_CNTR_CODE == cntrcode).First();
+                        if (CntrLoc == null)
+                        {
+                            result.Code = -1;
+                            result.Msg = $"鏍规嵁鎵樼洏:{cntrcode}鏈壘鍒扮粦瀹氭墭鐩�;
+                            LogHelper.Info($"EquipmentInfo:{result.Msg}");
+                            return result;
+                        }
+                        startloc = LocationHelper.GetLoc(CntrLoc.S_LOC_CODE);
+                        if (startloc == null)
+                        {
+                            result.Code = -1;
+                            result.Msg = $"鏍规嵁璧风偣:{CntrLoc.S_LOC_CODE}鏈壘鍒拌揣浣嶄俊鎭�;
+                            LogHelper.Info($"EquipmentInfo:{result.Msg}");
+                            return result;
+                        }
+
+                        #endregion
+
+                        #region 鑾峰彇缁堢偣淇℃伅
+                        string DiePanLoc = "";
+                        //鏍规嵁鎵樼洏鑾峰彇璧风偣淇℃伅
+                        endloc = db.Queryable<Location>().Where(a => a.S_CODE == DiePanLoc).First();
+                        if (endloc == null)
+                        {
+                            result.Code = -1;
+                            result.Msg = $"鏍规嵁璐т綅缂栫爜锛歿DiePanLoc}鏈壘鍒板彔鐩樿揣浣�;
+                            LogHelper.Info($"EquipmentInfo:{result.Msg}");
+                            return result;
+                        }
+                        #endregion
+
+                        #region 鍒涘缓浠诲姟
+                        if (startloc != null && endloc != null)
+                        {
+                            var wcsTask = new WCSTask
+                            {
+                                S_CODE = WCSHelper.GenerateTaskNo(),
+                                S_TYPE = "鍏ュ簱",
+                                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 = endloc.S_WH_CODE,
+                                S_END_AREA = endloc.S_AREA_CODE,
+                                N_CNTR_COUNT = 1,
+                                N_SCHEDULE_TYPE = 2,
+                                S_CNTR_CODE = cntrcode
+                            };
+                            LogHelper.Info("鍒涘缓鍏ュ钩搴撲换鍔★細" + JsonConvert.SerializeObject(wcsTask));
+                            if (WCSHelper.CreateTask(wcsTask))
+                            {
+                                LocationHelper.LockLoc(startloc.S_CODE, 2);
+                                LocationHelper.LockLoc(endloc.S_CODE, 1);
+                                LogHelper.Info("鍒涘缓浠诲姟鎴愬姛");
+                            }
+                        }
+
+                        #endregion
+                    }
+                    else
+                    {
+                        result.Code = -1;
+                        result.Msg = $"褰撳墠鍙犵洏鏈虹姸鎬佷笉灞炰簬鍙犵洏鐘舵�锛屼笉鍏佽绌烘墭鍙犳墭";
+                        LogHelper.Info($"EquipmentInfo:{result.Msg}");
+                        return result;
+                    }
+                }
+            }
 
 
             return result;
         }
 
+        /// <summary>
+        /// 鑾峰彇鎵樼洏鐗╂枡淇℃伅
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        internal static Result<Empty> GetCntrInfo(GetCntrInfoModel model)
+        {
+            Result<Empty> result = new Result<Empty> { Code = 0, Msg = "鍒涘缓鎴愬姛" };
+            if (model == null)
+            {
+                result.Code = -1;
+                result.Msg = "鍏ュ弬涓虹┖";
+                return result;
+            }
 
+            var db = new SqlHelper<object>().GetInstance();
+            string cntrCode = model.CntrNo;
 
+            var CntrItem = db.Queryable<CntrItemDetail>().Where(a => a.S_CNTR_CODE == cntrCode).ToList();
+            if (CntrItem.Count > 0)
+            {
+
+            }
+
+            return result;
+        }
 
         /// <summary>
         /// 缁戝畾鎵樼洏鐗╂枡  

--
Gitblit v1.9.1