分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-07-19 7a4c218909936721fe281737491d10efc7378e09
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
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
    {
 
        /// <summary>
        /// 添加工单信息
        /// </summary>
        /// <param name="requestTemp"></param>
        /// <returns></returns>
        public static WebResponseContent AddWorkinfo(dt_Workinfo requestTemp)
        {
            WebResponseContent content = new WebResponseContent();
            return content;
        }
        /// <summary>
        /// 添加工单详情
        /// </summary>
        /// <param name="requestTemp"></param>
        /// <returns></returns>
        public static WebResponseContent AddActualProduction(dt_ActualProduction requestTemp)
        {
            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,
                };
                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;
        }
    }
}