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
{
///
/// 添加工单信息
///
///
///
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();
try
{
Mes_WorkInfo workInfo = JsonConvert.DeserializeObject(json.ToString());
if (workInfo == null)
{
return content.Error("工单信息数据为空");
}
var mesinfo = freeDB.Select().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
};
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);
}
}
}
}