From b7308bba3d7ffad271ce7fc7a93c8c45d76be87d Mon Sep 17 00:00:00 2001
From: 杨前锦 <1010338399@qq.com>
Date: 星期五, 13 六月 2025 17:21:03 +0800
Subject: [PATCH] 优化印尼佳通-硫化胚胎出入库逻辑策略优化

---
 HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/dispatch/WCSDispatch.cs |  326 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 326 insertions(+), 0 deletions(-)

diff --git a/HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/dispatch/WCSDispatch.cs b/HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/dispatch/WCSDispatch.cs
new file mode 100644
index 0000000..e11f48e
--- /dev/null
+++ b/HH.WCS.Mobox3/HH.WCS.Mobox3.FJJT/dispatch/WCSDispatch.cs
@@ -0,0 +1,326 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using HH.WCS.Mobox3.FJJT.util;
+using HH.WCS.Mobox3.FJJT.wms;
+using Newtonsoft.Json;
+using static HH.WCS.Mobox3.FJJT.api.ApiModel;
+using static HH.WCS.Mobox3.FJJT.util.ExcetionHelper;
+
+namespace HH.WCS.Mobox3.FJJT.dispatch
+{
+    internal class WCSDispatch
+    {
+        private static readonly HttpHelper apiHelper = new HttpHelper();
+        private static readonly string baseUrl = "http://10.30.10.8:8100/dev-api";
+
+        internal static string GenerateReqId()
+        {
+            var id = SYSHelper.GetSerialNumber("璇锋眰ID", "RE");
+            var date = DateTime.Now.ToString("yyMMdd");
+            return $"{date}{id.ToString().PadLeft(4, '0')}";
+        }
+
+        /// <summary>
+        /// 浠诲姟涓嬪彂
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public static bool sendTask(SendTaskModel model)
+        {
+            var result = false;
+            model.reqId = GenerateReqId();
+            model.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            var request = JsonConvert.SerializeObject(model);
+            try
+            {
+                var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request);
+                LogHelper.Info($"[WCS-sendTask] request={request} response={response}", "WMS");
+                if (response != null && response != "")
+                {
+
+                    var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response);
+                    if (dataResult.code == 200)
+                    {
+                        result = true;
+                    }
+                    else
+                    {
+                        WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"涓嬪彂WCS浠诲姟澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                        throw new BusinessException($"涓嬪彂WCS浠诲姟澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                    }
+                }
+                else
+                {
+                    WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"涓嬪彂WCS浠诲姟澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                    throw new BusinessException($"涓嬪彂WCS浠诲姟澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                }
+            }
+            catch (BusinessException be) 
+            {
+                throw be;
+            }
+            catch (Exception ex)
+            {
+                WMSHelper.addAlarmRecord("绯荤粺寮傚父", "楂�, $"涓嬪彂WCS浠诲姟閿欒锛岄敊璇師鍥狅細{ex.Message}");
+                throw new BusinessException($"涓嬪彂WCS浠诲姟閿欒锛岄敊璇師鍥狅細{ex.Message}");
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 浠诲姟鍙栨秷锛堜换鍔℃墽琛屼腑涓嶅厑璁稿彇娑堬級
+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public static bool cancelTask(CancelTaskModel model)
+        {
+            var result = false;
+            model.reqId = GenerateReqId();
+            model.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            var request = JsonConvert.SerializeObject(model);
+            try
+            {
+                var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request);
+                LogHelper.Info($"[WCS-cancelTask] request={request} response={response}", "WMS");
+                if (response != null && response != "")
+                {
+
+                    var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response);
+                    if (dataResult.code == 200)
+                    {
+                        result = true;
+                    }
+                    else
+                    {
+                        WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"鍙栨秷WCS浠诲姟澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                        throw new BusinessException($"鍙栨秷WCS浠诲姟澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                    }
+                }
+                else
+                {
+                    WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"鍙栨秷WCS浠诲姟澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                    throw new BusinessException($"鍙栨秷WCS浠诲姟澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                }
+            }
+            catch (BusinessException be)
+            {
+                throw be;
+            }
+            catch (Exception ex)
+            {
+                WMSHelper.addAlarmRecord("绯荤粺寮傚父", "楂�, $"鍙栨秷WCS浠诲姟閿欒锛岄敊璇師鍥狅細{ex.Message}");
+                throw new BusinessException($"鍙栨秷WCS浠诲姟閿欒锛岄敊璇師鍥狅細{ex.Message}");
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// 鑾峰彇璁惧鐘舵�
+        /// </summary>
+        /// <param name="deviceNoList"></param>
+        /// <returns></returns>
+        public static List<DeviceStatusData> getDeviceStatus(List<string> deviceNoList)
+        {
+            List<DeviceStatusData> deviceStatusDatas = new List<DeviceStatusData>();
+
+            DeviceStatusModel model = new DeviceStatusModel() 
+            {
+                reqId = GenerateReqId(),
+                reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
+                deviceNoList = deviceNoList
+            };
+            
+            var request = JsonConvert.SerializeObject(model);
+            try
+            {
+                var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request);
+                LogHelper.Info($"[WCS-getDeviceStatus] request={request} response={response}", "WMS");
+                if (response != null && response != "")
+                {
+
+                    var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response);
+                    if (dataResult.code == 200)
+                    {
+                        deviceStatusDatas = JsonConvert.DeserializeObject<List<DeviceStatusData>>(response);
+                    }
+                    else
+                    {
+                        WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"鑾峰彇璁惧鐘舵�澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                        throw new BusinessException($"鑾峰彇璁惧鐘舵�澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                    }
+                }
+                else
+                {
+                    WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"鑾峰彇璁惧鐘舵�澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                    throw new BusinessException($"鑾峰彇璁惧鐘舵�澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                }
+            }
+            catch (BusinessException be)
+            {
+                throw be;
+            }
+            catch (Exception ex)
+            {
+                WMSHelper.addAlarmRecord("绯荤粺寮傚父", "楂�, $"鑾峰彇璁惧鐘舵�閿欒锛岄敊璇師鍥狅細{ex.Message}");
+                throw new BusinessException($"鑾峰彇璁惧鐘舵�閿欒锛岄敊璇師鍥狅細{ex.Message}");
+            }
+            return deviceStatusDatas;
+        }
+
+        /// <summary>
+        /// 淇敼浠诲姟浼樺厛绾�+        /// </summary>
+        /// <param name="model"></param>
+        /// <returns></returns>
+        public static bool changePriority(ChangePriorityModel model)
+        {
+            var result = false;
+            model.reqId = GenerateReqId();
+            model.reqTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+            var request = JsonConvert.SerializeObject(model);
+            try
+            {
+                var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request);
+                LogHelper.Info($"[WCS-changePriority] request={request} response={response}", "WMS");
+                if (response != null && response != "")
+                {
+
+                    var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response);
+                    if (dataResult.code == 200)
+                    {
+                        result = true;
+                    }
+                    else
+                    {
+                        WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"淇敼浠诲姟浼樺厛绾уけ璐ワ紝WCS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                        throw new BusinessException($"淇敼浠诲姟浼樺厛绾уけ璐ワ紝WCS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                    }
+                }
+                else
+                {
+                    WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"淇敼浠诲姟浼樺厛绾уけ璐ワ紝WCS娌℃湁杩斿洖鏁版嵁");
+                    throw new BusinessException($"淇敼浠诲姟浼樺厛绾уけ璐ワ紝WCS娌℃湁杩斿洖鏁版嵁");
+                }
+            }
+            catch (BusinessException be)
+            {
+                throw be;
+            }
+            catch (Exception ex)
+            {
+                WMSHelper.addAlarmRecord("绯荤粺寮傚父", "楂�, $"淇敼浠诲姟浼樺厛绾ч敊璇紝閿欒鍘熷洜锛歿ex.Message}");
+                throw new BusinessException($"淇敼浠诲姟浼樺厛绾ч敊璇紝閿欒鍘熷洜锛歿ex.Message}");
+            }
+            return result;
+        }
+
+        /// <summary>
+        /// AGV瀹夊叏浜や簰
+        /// </summary>
+        /// <param name="req_no"></param>
+        /// <param name="locCode"></param>
+        /// <param name="type"></param>
+        /// <returns></returns>
+        public static bool safetyInteraction(string req_no, string locCode, string type)
+        {
+            var result = false;
+            LocStateModel model = new LocStateModel() 
+            {
+                req_no = req_no,
+                loc_code = locCode,
+                type = type
+            };
+           
+            var request = JsonConvert.SerializeObject(model);
+            try
+            {
+                var response = apiHelper.Post(baseUrl + "/api/hecWms/produceProcessTracing/trayMaterialUnBind", request);
+                LogHelper.Info($"[WCS-changePriority] request={request} response={response}", "WMS");
+                if (response != null && response != "")
+                {
+
+                    var dataResult = JsonConvert.DeserializeObject<ResponseResult>(response);
+                    if (dataResult.code == 200)
+                    {
+                        result = true;
+                    }
+                    else
+                    {
+                        WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"AGV瀹夊叏浜や簰璇锋眰澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                        throw new BusinessException($"AGV瀹夊叏浜や簰璇锋眰澶辫触锛學CS鍙嶉鍘熷洜锛歿dataResult.msg}");
+                    }
+                }
+                else
+                {
+                    WMSHelper.addAlarmRecord("娴佺▼寮傚父", "楂�, $"AGV瀹夊叏浜や簰璇锋眰澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                    throw new BusinessException($"AGV瀹夊叏浜や簰璇锋眰澶辫触锛學CS娌℃湁杩斿洖鏁版嵁");
+                }
+            }
+            catch (BusinessException be)
+            {
+                throw be;
+            }
+            catch (Exception ex)
+            {
+                WMSHelper.addAlarmRecord("绯荤粺寮傚父", "楂�, $"AGV瀹夊叏浜や簰璇锋眰閿欒锛岄敊璇師鍥狅細{ex.Message}");
+                throw new BusinessException($"AGV瀹夊叏浜や簰璇锋眰閿欒锛岄敊璇師鍥狅細{ex.Message}");
+            }
+            return result;
+        }
+
+        public class LocStateModel 
+        {
+            public string req_no { get; set; } // 璇锋眰id
+            public string loc_code { get; set; } // 璐т綅
+            public string type { get; set; } // 璐т綅 1 璇锋眰鍙栬揣 2 璇锋眰鏀捐揣 3 鍙栬揣瀹屾垚绂诲紑淇″彿 4 鏀捐揣瀹屾垚绂诲紑淇″彿
+        }
+
+        public class ChangePriorityModel 
+        {
+            public string reqId { get; set; } // 璇锋眰id
+            public string reqTime { get; set; } // 璇锋眰鏃堕棿
+            public string taskNo { get; set; } // 浠诲姟鍙�+            public int priority { get; set; } // 浼樺厛绾�+        }
+
+        public class DeviceStatusData 
+        {
+            public string deviceNo { get; set; } // 璁惧鍙�+            public int workStatus { get; set; } // 宸ヤ綔鐘舵�  1鍙敤锛�涓嶅彲鐢�+            public int photoStatus { get; set; } // 鍏夌數鐘舵� 1鏄┖杞�,2鏄湁杞�+            public int manualStatus { get; set; } //鎵嬪姩鐘舵�  0.绂佺敤 1.鍚敤 
+        }
+
+        public class DeviceStatusModel 
+        {
+            public string reqId { get; set; } // 璇锋眰id
+            public string reqTime { get; set; } // 璇锋眰鏃堕棿
+            public List<string> deviceNoList { get; set; } // 璁惧鍙�+        }
+
+        public class CancelTaskModel 
+        {
+            public string reqId { get; set; } // 璇锋眰id
+            public string reqTime { get; set; } // 璇锋眰鏃堕棿
+            public string taskNo { get; set; } // 浠诲姟鍙�+        }
+
+        public class SendTaskModel 
+        {
+            public string reqId { get; set; } // 璇锋眰id
+            public string reqTime { get; set; } // 璇锋眰鏃堕棿
+            public string taskNo { get; set; } // 浠诲姟鍙�+            public int groupNo { get; set; } // 浠诲姟缁�
+            public string taskType { get; set; } // 浠诲姟绫诲瀷  1.鐗╂枡鍏ュ簱 2.鐗╂枡鍑哄簱
+            public string from { get; set; } // 璧风偣
+            public string to { get; set; } // 缁堢偣
+            public string cntrNo { get; set; } // 瀹瑰櫒缂栫爜
+            public string cntrType { get; set; } // 瀹瑰櫒绫诲瀷
+            public List<object> extData { get; set; } // 瀹瑰櫒绫诲瀷
+
+        }
+    }
+}

--
Gitblit v1.9.1