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 { public partial class ToMesServer { /// /// 添加工单信息 /// /// /// public static WebResponseContent AddWorkinfo(dt_Workinfo requestTemp) { WebResponseContent content = new WebResponseContent(); return content; } /// /// 添加工单详情 /// /// /// public static WebResponseContent AddActualProduction(dt_ActualProduction requestTemp) { WebResponseContent content = new WebResponseContent(); return content; } /// /// MES下发WMS工单接口 /// /// /// 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(json.ToString()); if (workInfo == null) { //return content.Error("工单信息数据为空"); throw new Exception("工单信息数据为空"); } var mesinfo = freeDB.Select().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, }; 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_id = 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 = 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); content.Error(ex.Message); } WritePCSLog.LogAdd("", content.Status ? "成功 " : "失败", "PCS", "MES", JsonConvert.SerializeObject(mes_Head), JsonConvert.SerializeObject(content), $"MES下发工单", "AddMes_Info", content.Message); return content; } } }