分支自 SuZhouGuanHong/TaiYuanTaiZhong

陈勇
2024-02-23 c9dd47185d603ccd09dd567f7eb5baeaf03b2746
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
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>
        /// <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();
            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
                };
                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);
            }
        }
    }
}