From 46f7bf1ee45c97b688a370bbe45d149efb403cc1 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期二, 07 五月 2024 17:26:18 +0800
Subject: [PATCH] 检测上料逻辑修改,无有料货位时写入不允许桁架进入信号

---
 代码管理/PCS/WCS_Server/WIDESEA_WCS/ToMES/ToMesServer.cs |  106 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 105 insertions(+), 1 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToMES/ToMesServer.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToMES/ToMesServer.cs"
index 7359fba..8f03fc6 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToMES/ToMesServer.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/PCS/WCS_Server/WIDESEA_WCS/ToMES/ToMesServer.cs"
@@ -1,15 +1,26 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
+using OfficeOpenXml.FormulaParsing.Excel.Functions.Text;
+using System;
 using System.Collections.Generic;
 using System.Linq;
+using System.Runtime.InteropServices;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Comm.LogInfo;
+using WIDESEA_Common;
+using WIDESEA_Core.FreeDB;
 using WIDESEA_Core.Utilities;
 using WIDESEA_Entity.DomainModels;
+using WIDESEA_Entity.ToAGV;
+using static FreeSql.Internal.GlobalFilter;
 
 namespace WIDESEA_WCS
 {
     public partial class ToMesServer
     {
+
         /// <summary>
         /// 娣诲姞宸ュ崟淇℃伅
         /// </summary>
@@ -30,5 +41,98 @@
             WebResponseContent content = new WebResponseContent();
             return content;
         }
+
+        /// <summary>
+        /// MES涓嬪彂WMS宸ュ崟鎺ュ彛
+        /// </summary>
+        /// <param name="json"></param>
+        /// <returns></returns>
+        public static WebResponseContent AddMes_Info(object json)
+        {
+            WebResponseContent content = new WebResponseContent();
+            FreeDB freeDB = new FreeDB();
+            dt_mes_head mes_Head = null;
+            try
+            {
+                Mes_WorkInfo workInfo = JsonConvert.DeserializeObject<Mes_WorkInfo>(json.ToString());
+
+                if (workInfo == null)
+                {
+                    //return content.Error("宸ュ崟淇℃伅鏁版嵁涓虹┖");
+                    throw new Exception("宸ュ崟淇℃伅鏁版嵁涓虹┖");
+                }
+
+                var mesinfo = freeDB.Select<dt_mes_head>().Where(x => x.jobID == workInfo.jobID).First();
+                if (mesinfo != null)
+                {
+                    //return content.Error($"宸ュ崟缂栧彿{mesinfo.jobID}宸插瓨鍦�,璇锋牳瀹炲悗閲嶆柊鍙戦�侊紒");
+                    throw new Exception($"宸ュ崟缂栧彿{mesinfo.jobID}宸插瓨鍦�,璇锋牳瀹炲悗閲嶆柊鍙戦�侊紒");
+                }
+
+                Guid head = Guid.NewGuid();
+                mes_Head = new dt_mes_head
+                {
+                    mes_id = head,
+                    CreateTime = DateTime.Now,
+                    creator = "MES",
+                    drawingNo = workInfo.drawingNo,
+                    drawingNoVer = workInfo.drawingNoVer,
+                    expectedFinishTime = workInfo.expectedFinishTime,
+                    expectedStartTime = workInfo.expectedStartTime,
+                    jobID = workInfo.jobID,
+                    materialCode = workInfo.materialCode,
+                    maxDiameterDiff = workInfo.maxDiameterDiff,
+                    productDesc = workInfo.productDesc,
+                    productName = workInfo.productName,
+                    quantity = workInfo.quantity,
+                    reqID = workInfo.reqID,
+                    reqIDLineNo = workInfo.reqIDLineNo,
+                    stackNoRange = workInfo.stackNoRange,
+                    typeID = workInfo.typeID,
+                    workOrder = workInfo.workOrder,
+                    processCode = workInfo.processCode,
+                    finishNum = 0,
+                    skip_op_1 = false,
+                    skip_op_2 = false,
+                    skip_op_3 = false,
+                };
+                freeDB.Add(mes_Head);
+
+                foreach (var item in workInfo.details)
+                {
+                    dt_mes_detail mes_Detail = new dt_mes_detail
+                    {
+                        mes_detail_id = Guid.NewGuid(),
+                        mes_headID = head,
+                        jobID = item.jobID,
+                        billetID = item.billetID,
+                        heatBatchID = item.heatBatchID,
+                        heatID = item.heatID,
+                        SN = item.SN
+                    };
+                    freeDB.Add(mes_Detail);
+                }
+
+                #region 鏌ヨ褰撳墠宸ュ崟鐨勫浘鍙蜂俊鎭槸鍚﹀瓨鍦�
+                var dt_Geometry_Data = PipelineJob.QueryMateriel(workInfo.drawingNo);
+                var dt_Geometry_Data1 = PipelineJob.QueryMateriel1(workInfo.drawingNo);
+                if (dt_Geometry_Data == null && dt_Geometry_Data1 == null)
+                {
+                    throw new Exception($"鏈壘鍒板浘鍙凤細{workInfo.drawingNo}鐨勮溅杞俊鎭紒宸ュ崟缂栧彿锛歿workInfo.jobID}");
+                }
+                #endregion
+                //WriteWMSLog.LogAdd(requestTask.TASK_NO, "鎴愬姛 ", "AGV", "WMS", postJson, report, "涓嬪彂AGV浠诲姟", "SendAGVTask", respone.Msg);
+                //return content.OK();
+                content.OK();
+            }
+            catch (Exception ex)
+            {
+                //return content.Error(ex.Message);
+                content.Error(ex.Message);
+            }
+
+            WritePCSLog.LogAdd("", content.Status ? "鎴愬姛 " : "澶辫触", "PCS", "MES", JsonConvert.SerializeObject(mes_Head), JsonConvert.SerializeObject(content), $"MES涓嬪彂宸ュ崟", "AddMes_Info", content.Message);
+            return content;
+        }
     }
 }

--
Gitblit v1.9.3