分支自 SuZhouGuanHong/TaiYuanTaiZhong

陈勇
2024-03-12 388c43ee7b741eebafa98cd8ef992005f1aa56f4
´úÂë¹ÜÀí/PCS/WCS_Server/WIDESEA_WCS/ToMES/ToMesServer.cs
@@ -1,15 +1,21 @@
using System;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Common;
using WIDESEA_Core.FreeDB;
using WIDESEA_Core.Utilities;
using WIDESEA_Entity.DomainModels;
using static FreeSql.Internal.GlobalFilter;
namespace WIDESEA_WCS
{
    public partial class ToMesServer
    {
        /// <summary>
        /// æ·»åŠ å·¥å•ä¿¡æ¯
        /// </summary>
@@ -30,5 +36,80 @@
            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();
            try
            {
                Mes_WorkInfo workInfo = JsonConvert.DeserializeObject<Mes_WorkInfo>(json.ToString());
                if (workInfo == null)
                {
                    return content.Error("工单信息数据为空");
                }
                var mesinfo = freeDB.Select<dt_mes_head>().Where(x => x.jobID == workInfo.jobID).First();
                if (mesinfo != null)
                {
                    return content.Error($"工单号{mesinfo.jobID}已存在,请核实后重新发送!");
                }
                Guid head = Guid.NewGuid();
                dt_mes_head 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);
                }
                return content.OK();
            }
            catch (Exception ex)
            {
                return content.Error(ex.Message);
            }
        }
    }
}