分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-07-19 7a4c218909936721fe281737491d10efc7378e09
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/ToMES/ToMesServer.cs
@@ -1,14 +1,19 @@
using 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
@@ -46,23 +51,26 @@
        {
            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("工单信息数据为空");
                    //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}已存在,请核实后重新发送!");
                    //return content.Error($"工单编号{mesinfo.jobID}已存在,请核实后重新发送!");
                    throw new Exception($"工单编号{mesinfo.jobID}已存在,请核实后重新发送!");
                }
                Guid head = Guid.NewGuid();
                dt_mes_head mes_Head = new dt_mes_head
                mes_Head = new dt_mes_head
                {
                    mes_id = head,
                    CreateTime = DateTime.Now,
@@ -79,11 +87,11 @@
                    quantity = workInfo.quantity,
                    reqID = workInfo.reqID,
                    reqIDLineNo = workInfo.reqIDLineNo,
                    stackNoRange = workInfo.stackNoRange,
                    //stackNoRange = workInfo.stackNoRange,
                    typeID = workInfo.typeID,
                    workOrder = workInfo.workOrder,
                    processCode = workInfo.processCode,
                    finishNum = 0
                    finishNum = 0,
                };
                freeDB.Add(mes_Head);
@@ -92,7 +100,7 @@
                    dt_mes_detail mes_Detail = new dt_mes_detail
                    {
                        mes_detail_id = Guid.NewGuid(),
                        mes_headID = head,
                        mes_id = head,
                        jobID = item.jobID,
                        billetID = item.billetID,
                        heatBatchID = item.heatBatchID,
@@ -101,12 +109,27 @@
                    };
                    freeDB.Add(mes_Detail);
                }
                return content.OK();
                #region æŸ¥è¯¢å½“前工单的图号信息是否存在
                var dt_Geometry_Data = Pipeline.QueryMateriel(workInfo.drawingNo);
                //var dt_Geometry_Data1 = Pipeline.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);
                //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;
        }
    }
}