UpstreamSendCalendar.cs
10.4 KB
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
using System;
using System.Collections.Generic;
using System.Linq;
using AutoMapper;
using Hh.Mes.Common.Json;
using Hh.Mes.Common.log;
using Hh.Mes.Pojo.System;
using Hh.Mes.POJO.ApiEntity;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using NPOI.POIFS.FileSystem;
using Ubiety.Dns.Core;
namespace Hh.Mes.Service.ApiService
{
public partial class UpstreamService
{
public dynamic SendCalendar(CalendarEntity entity)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
var response = new ResponseUpstream<string>(entity.plmeid);
var calendar = new base_calendar
{
keys = Guid.NewGuid(),
plmeId = entity.plmeid,
workShopCode = entity.work_code,
currentDate = entity.current_date,
shift = entity.shift,
startTime = entity.start_time,
endTime = entity.end_time,
timeFlag = entity.time,
isDelete = AddOrUpdateFlag
};
int resultCount = 0;
if (entity.type == EnumAction.I.ToString())
{
if (Context.Queryable<base_calendar>().Any(t => t.plmeId == calendar.plmeId && t.isDelete == AddOrUpdateFlag))
{
return response.ResponseError($"【MOM】【plmeid】日历信息[{entity.plmeid}]已经存在,请勿重复添加!");
}
calendar.createTime = DateTime.Now;
resultCount = Context.Insertable(calendar).ExecuteCommand();
}
else if (entity.type == EnumAction.U.ToString())
{
calendar.updateTime = DateTime.Now;
resultCount = Context.Updateable(calendar).IgnoreColumns(it => new { it.keys, it.createBy, it.createTime })
.Where(x => x.plmeId == entity.plmeid && x.isDelete == AddOrUpdateFlag)
.ExecuteCommand();
}
else if (entity.type == EnumAction.D.ToString())
{
calendar.updateTime = DateTime.Now;
resultCount = Context.Updateable<base_calendar>()
.SetColumns(t => t.isDelete == DeleteFlag)
.Where(x => x.plmeId.Equals(entity.plmeid) && x.isDelete == AddOrUpdateFlag)
.ExecuteCommand();
}
return resultCount > 0 ? response.ResponseSuccess() : response.ResponseError();
});
}
/// <summary>
/// ep3d订单推送接收
/// </summary>
/// <returns></returns>
public dynamic ep3dDataPush(productionOrderList list)
{
var response = new POJO.Response.Response();
try
{
var importbachnumber = DateTime.Now.ToString("yyyyMMddhhmmss");
//重复数据去除
var dBList = Context.Queryable<base_productionOrder_EP3D>().ToList();
if (dBList.Count > 0)
{
list.details = list.details.Where(x=> !dBList.Exists(y=>y.pipelineNo==x.pipelineNo && y.pipeSectionNo==x.pipeSectionNo)).ToList();
}
foreach (var model in list.details)
{
model.keys = Guid.NewGuid();
model.state = 0;
model.createTime = DateTime.Now;
model.updateTime = DateTime.Now;
model.batchNo = importbachnumber;
}
int inI = Context.Insertable(list.details).ExecuteCommand();
if (inI > 0)
{
return response;
}
else
{
return response.ResponseError($"数据接收失败,新增数据数量为0!");
}
}
catch (Exception ex)
{
return response.ResponseError($"{ex.Message}");
}
}
public dynamic SendWorkSeverYZJ(base_work_order work_order)
{
var response = new POJO.Response.Response();
string errMsg = "";
if (string.IsNullOrEmpty(work_order.workOrderCode ))
{
errMsg += "生产订单号不能为空;";
}
if (string.IsNullOrEmpty(work_order.lineCode))
{
errMsg += "生产线不能为空;";
}
if (string.IsNullOrEmpty(work_order.workPieceNo))
{
errMsg += "工件编码不能为空;";
}
if (work_order.bends == null)
{
errMsg += "弯管信息不能为空;";
}
if (work_order.Cuts == null )
{
errMsg += "火焰切割信息不能为空;";
}
//if (work_order.flameCut == null)
//{
// errMsg += "火焰切割信息不能为空;";
//}
if (work_order.mounting == null)
{
errMsg += "装配信息不能为空;";
}
if (errMsg.Length>0)
{
return response.ResponseError(errMsg);
}
Context.Ado.BeginTran();
try
{
Guid keys = Guid.NewGuid();
base_work_order_head order_head = GetWorkOrderModel(work_order);
order_head.keys = keys;
int inI = Context.Insertable(order_head).ExecuteCommand();
//弯管信息
List<base_work_order_bends> bends = work_order.bends;
foreach (var item in bends)
{
item.headKeys = keys;
item.createBy = "sys";
item.createTime = DateTime.Now;
}
Context.Insertable(bends).ExecuteCommand();
//火焰切割
List<Work_Order_FlameCut> flameCuts = work_order.Cuts;
List<base_work_order_flameCut_d> flameCut_d = new List<base_work_order_flameCut_d>();
foreach (var item in flameCuts)
{
Guid guid = Guid.NewGuid();
item.headKeys = keys;
item.createBy = "sys";
item.createTime = DateTime.Now;
item.headKeys = keys;
item.Keys = guid;
if (item.Cut_D.Count > 0)
{
foreach (var FlameCut_D_Item in item.Cut_D)
{
base_work_order_flameCut_d flameCut_d1 = FlameCut_D_Item;
flameCut_d1.headKeys = guid;
flameCut_d1.createBy = "sys";
flameCut_d1.createTime = DateTime.Now;
flameCut_d.Add(flameCut_d1);
}
}
}
Mapper.Initialize(x => x.CreateMap<Work_Order_FlameCut, base_work_order_flameCut>());
List<base_work_order_flameCut> flameCuts2 = new List<base_work_order_flameCut>();
foreach (Work_Order_FlameCut item in flameCuts)
{
base_work_order_flameCut f = Mapper.Map<base_work_order_flameCut>(item);
flameCuts2.Add(f);
}
Context.Insertable(flameCuts2).ExecuteCommand();
Context.Insertable(flameCut_d).ExecuteCommand();
//装配信息
List<base_work_order_mounting> mounting = work_order.mounting;
foreach (var item in mounting)
{
item.headKeys = keys;
item.createBy = "sys";
item.createTime = DateTime.Now;
}
Context.Insertable(mounting).ExecuteCommand();
Context.Ado.CommitTran();
return response.ResponseSuccess();
}
catch (Exception ex)
{
Context.Ado.RollbackTran();
return response.ResponseError($"{ex.Message}");
}
}
public base_work_order_head GetWorkOrderModel(base_work_order work_order)
{
base_work_order_head head = new base_work_order_head();
head.assemblageInfo = work_order.assemblageInfo;
head.attachment1 = work_order.attachment1;
head.attachment2 = work_order.attachment2;
head.bevels1 = work_order.bevels1;
head.bevels2 = work_order.bevels2;
head.cutLength = work_order.cutLength;
head.diameter = work_order.diameter;
head.extend1 = work_order.extend1;
head.extend2 = work_order.extend2;
head.extend3 = work_order.extend3;
head.extend4 = work_order.extend4;
head.flowOrientation1 = work_order.flowOrientation1;
head.flowOrientation2 = work_order.flowOrientation2;
head.instructions1 = work_order.instructions1;
head.instructions2 = work_order.instructions2;
head.level = work_order.level;
head.lineCode =work_order.lineCode;
head.materielCode = work_order.materielCode;
head.paintCode = work_order.paintCode;
head.pipePartsCode = work_order.pipePartsCode;
head.pipePartsNo = work_order.pipePartsNo;
head.projectNo = work_order.projectNo;
head.range = work_order.range;
head.startWorkDate = work_order.startWorkDate;
head.thickness = work_order.thickness;
head.turningAngle = work_order.turningAngle;
head.workOrderCode = work_order.workOrderCode;
head.workPieceNo = work_order.workPieceNo;
if (!string.IsNullOrEmpty(sysUserApi?.Account))
{
head.createBy = sysUserApi?.Account;
head.updateby = sysUserApi?.Account;
}
else
{
head.createBy = "system";
head.updateby = "system";
}
head.createTime = DateTime.Now;
return head;
}
}
}