From eec9f268552af1d0ce8c95312930770669f1cc18 Mon Sep 17 00:00:00 2001
From: Rodney Chen <rodney.chen@hotmail.com>
Date: 星期五, 16 八月 2024 22:40:16 +0800
Subject: [PATCH] 增加客户端需要的工序信息和短消息

---
 Tiger.Business/MES/WoContext.cs |   67 +++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 1 deletions(-)

diff --git a/Tiger.Business/MES/WoContext.cs b/Tiger.Business/MES/WoContext.cs
index afd8333..78b28b5 100644
--- a/Tiger.Business/MES/WoContext.cs
+++ b/Tiger.Business/MES/WoContext.cs
@@ -4,6 +4,7 @@
 using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Net.WebSockets;
 using System.Text;
 using System.Threading.Tasks;
 using Tiger.IBusiness;
@@ -148,7 +149,71 @@
             catch (Exception ex)
             {
                 //action.CatchExceptionWithLog(ex, $"鑾峰彇鏉$爜[{sn}]鐨勪笅涓�涓伐搴忚妭鐐瑰垪琛ㄥ紓甯�");
-                action.CatchExceptionWithLog(ex, Biz.L("MES.WoContext.GetSnNextNodesException"));
+                action.CatchExceptionWithLog(ex, Biz.L("MES.WoContext.GetSnNextNodesException", sn));
+            }
+            return action;
+        }
+
+        /// <summary>
+        /// 璁剧疆褰撳墠鏉$爜鐨勫伐搴忎俊鎭�
+        /// </summary>
+        public static ApiAction<OperInfo> GetSnOperInfo(string sn)
+        {
+            var action = new ApiAction<OperInfo>(new OperInfo());
+            try
+            {
+                var wipSNs = Biz.Db.Queryable<MES_WIP_DATA>().IncludesAllFirstLayer().Where(q => (q.SN == sn || q.FLOW_SN == sn || q.TRAY_SN == sn || q.INNER_SN == sn || q.CARTON_SN == sn || q.PALLET_SN == sn)).ToList();
+                if (wipSNs.IsNullOrEmpty())
+                {
+                    var woSNs = Biz.Db.Queryable<BIZ_MES_WO_SN>().Where(q => (q.SN == sn || q.TRAY_SN == sn || q.OUTER_SN == sn)).ToList();
+                    //鏌ユ壘鍒版潯鐮佸凡缁戝畾鐨勫伐鍗�
+                    if (!woSNs.IsNullOrEmpty())
+                    {
+                        foreach (var woSN in woSNs)
+                        {
+                            var wipSN = new MES_WIP_DATA()
+                            {
+                                SN = sn,
+                                FLOW_SN = sn,
+                                STATUS = MES_WIP_DATA.STATUSs.Init.GetValue(),
+                                ITEM_CODE = woSN.ITEM_CODE,
+                                WORK_ORDER = woSN.WORK_ORDER,
+                                BATCH_NO = woSN.BATCH_NO,
+                                HOLD_FLAG = "N",
+                                FINISHED_FLAG = "N",
+                                INV_FLAG = "N",
+                                DFT_FLAG = "N",
+                                DFT_COUNT = 0,
+                            };
+                            wipSNs.Add(wipSN);
+                        }
+                    }
+                }
+                if (wipSNs.IsNullOrEmpty())
+                {
+                    action.IsSuccessed = false;
+                    //action.LocaleMsg = new($"鎵句笉鍒版潯鐮乕{sn}]鐨勭敓浜т俊鎭�", sn);
+                    action.LocaleMsg = new("MES.WoContext.SnNotFound", sn);
+                }
+                else
+                {
+                    if (!WoBatchDic.Any(q => q.Value.WO.ORDER_NO == wipSNs.First().WORK_ORDER))
+                    {
+                        var wb = new WorkBatch(wipSNs.First().WORK_ORDER).Init("");
+                        WoBatchDic.Add(wb.Batch.BATCH_NO, wb);
+                    }
+                    var wo = WoBatchDic.FirstOrDefault(q => q.Value.WO.ORDER_NO == wipSNs.First().WORK_ORDER).Value;
+                    action.Data = new()
+                    {
+                        CurNode = wipSNs.First().NODE_NAME,
+                        NextNode = string.Join(",", wo.GetNextNodes(wipSNs.First()).Select(q => q.NODE_NAME)),
+                    };
+                }
+            }
+            catch (Exception ex)
+            {
+                //action.CatchExceptionWithLog(ex, $"鑾峰彇鏉$爜[{sn}]鐨勫伐搴忎俊鎭紓甯�");
+                action.CatchExceptionWithLog(ex, Biz.L("MES.WoContext.GetSnOperInfoException", sn));
             }
             return action;
         }

--
Gitblit v1.9.3