UpstreamController.cs
13.1 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
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
using Hh.Mes.POJO.ApiEntity;
using Hh.Mes.POJO.Entity;
using Hh.Mes.POJO.EnumEntitys;
using Hh.Mes.POJO.Response;
using Hh.Mes.POJO.ViewModel;
using Hh.Mes.POJO.WebEntity.api;
using Hh.Mes.Service;
using Hh.Mes.Service.ApiService;
using Hh.Mes.Service.WebService.Wo;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using NPOI.SS.Formula.Functions;
using NPOI.XWPF.UserModel;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace Hh.Mes.Api.Controllers
{
/// <summary>
/// 上游系统接口
/// ps:新增方法需要在SystemVariable 注册 APIList、EnumLog 新增枚举 ,方便接口日志定位查询
/// </summary>
[Route("api/[controller]/[action]")]
[ApiController]
public class UpstreamController : BaseController
{
private readonly UpstreamService service;
private readonly CutWeldService cutWeldService;
public UpstreamController(UpstreamService service, CutWeldService cutweldService, IHttpContextAccessor accessor, IWebHostEnvironment env)
{
this.service = service;
context = accessor.HttpContext;
this.cutWeldService = cutweldService;
}
/// <summary>
/// 物料主数据 MOM_HH_001
/// http://127.0.0.1:10008/api/Upstream/Mes/V1/SendMaterial
/// </summary>
[HttpPost]
[ActionName("Mes/V1/SendMaterial")]
public string SendMaterial(MaterialEntity requestData)
{
var result = service.SendMaterial(requestData);
return Serialize(result);
}
/// <summary>
/// 工艺路线 MOM_HH_002
/// http://127.0.0.1:10008/api/Upstream/Mes/V1/SendProcessRoute
/// </summary>
[HttpPost]
[ActionName("Mes/V1/SendProcessRoute")]
public string SendProcessRoute(MomProcessRouteHeadEntity requestData)
{
var result = service.SendProcessRoute(requestData);
return Serialize(result);
}
/// <summary>
/// 人员信息 MOM_HH_003
/// http://127.0.0.1:10008/api/Upstream/Mes/V1/SendUser
/// </summary>
[HttpPost]
[ActionName("Mes/V1/SendUser")]
public string SendUser(SysUserEntity requestData)
{
return Serialize(service.SendUser(requestData));
}
/// <summary>
/// 供应商信息 MOM_HH_004
/// </summary>
[HttpPost]
[ActionName("Mes/V1/SendSupplier")]
public string SendSupplier(SupplierEntity requestData)
{
return Serialize(service.SendSupplier(requestData));
}
/// <summary>
/// 生产订单 MOM_HH_005
/// </summary>
[HttpPost]
[ActionName("Mes/V1/SendWorkOrder")]
public string SendWorkOrder(MomWorkOrderHead requestData)
{
return Serialize(service.SendWorkOrder(requestData));
}
/// <summary>
/// 工作日历
/// </summary>
[HttpPost]
[ActionName("Mes/V1/SendCalendar")]
public string SendCalendar(CalendarEntity requestData)
{
return Serialize(service.SendCalendar(requestData));
}
/// <summary>
/// 质量问题状态
/// </summary>
[HttpPost]
[ActionName("Mes/V1/SendCheck")]
public string SendCheck(QualityFeedbackEntity requestData)
{
return Serialize(service.SendCheck(requestData));
}
/// <summary>
/// 产线中控将工序执行信息反馈MOM
/// </summary>
[HttpPost]
[ActionName("Mes/V1/ProcessRouteUpMom")]
public string ProcessRouteUpMom(ProcessRouteUpMomEntity routeUpMomEntity)
{
return Serialize(service.ProcessRouteUpMom(routeUpMomEntity));
}
/// <summary>
/// ANDON报警
/// </summary>
[HttpPost]
[ActionName("Mes/V1/AndonUpMom")]
public string AndonUpMom(AndonUpMomEntity andonUpMomEntity)
{
return Serialize(service.AndonUpMom(andonUpMomEntity));
}
/// <summary>
/// 获取MOM请求Token
/// </summary>
/// <returns></returns>
[HttpGet]
public string GetMomToken()
{
return Serialize(service.GetMomToken());
}
/// <summary>
/// 信科物料基础信息 同步
/// </summary>
/// <returns></returns>
[HttpGet]
[ActionName("Mes/V1/MaterialUpCict")]
public string MaterialUpCict()
{
return Serialize(service.MaterialUpCict());
}
/// <summary>
/// ECS(切割的开工、完工)工序完工反馈
/// </summary>
[HttpPost]
[ActionName("Mes/V1/ProcedureEndBack")]
public string ProcedureEndBack(ProcedureEndEntity procedureEndEntity)
{
var response = new Response(true);
cutWeldService.SendIWPTechnologylineProcess(procedureEndEntity.barCode, procedureEndEntity.enumCutHeadState);
return Serialize(response);
}
/// <summary>
/// 设备状态查询
/// </summary>
/// <returns></returns>
[HttpGet]
[ActionName("Mes/V1/GetEquipmentType")]
public string GetEquipmentType(string code)
{
return Serialize(service.GetEquipmentType(code));
}
/// <summary>
/// 服务端心跳
/// </summary>
/// <returns></returns>
[HttpGet]
[ActionName("Mes/V1/GetServicesHeartbeat")]
public string GetServicesHeartbeat()
{
return Serialize("ok");
}
#region ep3d相关
/// <summary>
/// ep3d数据推送接收接口
/// </summary>
/// <returns></returns>
[HttpPost]
[ActionName("Mes/V1/ep3dDataPush")]
public string ep3dDataPush(productionOrderList list)
{
return Serialize(service.ep3dDataPush(list));
}
#endregion
#region 扬子江工单接口
[HttpPost]
[ActionName("Mes/V1/SendWorkOrderByYZJ")]
public string SendWorkOrderByYZJ(List<base_work_order> work_orders)
{
return Serialize(service.SendWorkOrderByYZJ(work_orders));
}
[HttpGet]
[ActionName("Mes/V1/DelteteOrder")]
public string DelteteOrder(string workOrderCode)
{
return Serialize(service.DeleteOrder(workOrderCode));
}
[HttpPost]
[ActionName("Mes/V1/CreateOrder")]
public string CreateOrder(List<OrderInfo> orders)
{
return Serialize(service.CreateOrder(orders));
}
[HttpPost]
[ActionName("Mes/V1/strReplace")]
public string strReplace(string workOrderCode)
{
return Serialize(service.strReplace(workOrderCode));
}
[HttpPost]
[ActionName("Mes/V1/OrderCancel")]
public string OrderCancel(List<base_work_order_cancel> work_orders)
{
//string info = HttpContext.Request.Headers["Authorization"];
return Serialize(service.OrderCamcel(work_orders));
}
/// <summary>
/// 工单取消,根据工件编码取消
/// </summary>
/// <param name="pipeParts"></param>
/// <returns></returns>
[HttpPost]
[ActionName("Mes/V1/PipePartsCancel")]
public string PipePartsCancel(List<pipePartsCancel> pipeParts)
{
return Serialize(service.PipePartsCamcel(pipeParts));
}
#endregion
#region 现代套料数据
/// <summary>
/// 现代套料数据接收
/// </summary>
/// <param name="nestingList"></param>
/// <returns></returns>
[HttpPost]
[ActionName("Mes/V1/NestingReceive")]
public string NestingReceive(List<NestingModel> nestingList)
{
return Serialize(service.NestingReceive(nestingList));
}
#endregion
#region 扬子江ecs相关接口
/// <summary>
/// ecs反馈测长数据
/// </summary>
/// <param name="measuring"></param>
/// <returns></returns>
[HttpPost]
[ActionName("Mes/V1/taskMeasuring")]
public string taskMeasuring(Measuring measuring)
{
return Serialize(service.taskMeasuring(measuring));
}
/// <summary>
/// ecs反馈余料
/// </summary>
/// <param name="headID">套料任务ID</param>
/// <returns></returns>
[HttpPost]
[ActionName("Mes/V1/SurplusRecord")]
public string SurplusRecord(SurplusRecordModel surplusRecordModel)
{
return Serialize(service.SurplusRecord(surplusRecordModel.headID));
}
/// <summary>
/// ecs切断下料生成打标任务
/// </summary>
/// <param name="barCode">管段码</param>
/// <param name="equipmentNo">设备PLC编号</param>
/// <returns></returns>
[HttpPost]
[ActionName("Mes/V1/LayingOff")]
public string LayingOff(LayingOffModel layingOffModel)
{
return Serialize(service.LayingOff(layingOffModel.barCode, layingOffModel.equipmentNo));
}
#endregion
#region 扬子江物料数据接口
[HttpPost]
[ActionName("Mes/V1/SendMaterialInfo")]
public string SendMaterialInfo(MaterialCodeInfos materialCodeInfos)
{
return Serialize(service.SendMaterialInfo(materialCodeInfos));
}
#endregion
#region 扬子江弯管机反馈完工接口
[HttpGet]
[ActionName("Mes/V1/synBendLine")]
public string synBendLine(string batchCode)
{
return Serialize(service.synBendLine(batchCode));
}
#endregion
[HttpPost]
[ActionName("Mes/V1/CreateXml")]
public string CreateXml(string barCode)
{
var response = new ResponseUpstream<string>(Guid.NewGuid().ToString());
CutWeldService cutService = new CutWeldService();
cutService.CreateXmlByOrder(barCode);
return Serialize(response);
}
/// <summary>
/// 用工单号批量生成
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
[HttpPost]
[ActionName("Mes/V1/CreateXmlByWorkOrderCode")]
public string CreateXmlByWorkOrderCode(string barCode)
{
var response = new ResponseUpstream<string>(Guid.NewGuid().ToString());
CutWeldService cutService = new CutWeldService();
cutService.CreateXmlByWorkOrder(barCode);
return Serialize(response);
}
#region 扬子江激光切割套料相关接口
/// <summary>
/// 激光切割套料零件推送
/// </summary>
/// <param name="code">工单号</param>
/// <returns></returns>
[HttpGet]
[ActionName("Mes/V1/pushLoft")]
public string pushLoft(string code)
{
LaserCutService laserCutService = new LaserCutService();
var response=laserCutService.pushLoft(code);
return Serialize(response);
}
/// <summary>
/// 激光切割套料需求推送
/// </summary>
/// <param name="barCode"></param>
/// <returns></returns>
[HttpGet]
[ActionName("Mes/V1/pushNestPlan")]
public string pushNestPlan(string line)
{
LaserCutService laserCutService = new LaserCutService();
var response = laserCutService.pushNestPlan(line);
return Serialize(response);
}
/// <summary>
/// 激光切割套料数据接收
/// </summary>
/// <param name="barCode"></param>
/// <returns>http://127.0.0.1:108/api/Upstream/Mes/V1/NestingReceiveYZJ</returns>
[HttpPost]
[ActionName("Mes/V1/NestingReceiveYZJ")]
public string NestingReceiveYZJ(List<Nest> nest)
{
return Serialize(service.NestingReceiveYZJ(nest));
}
#endregion
/// <summary>
/// 用工单号批量生成弯管任务
/// </summary>
/// <param name="order"></param>
/// <returns></returns>
[HttpGet]
[ActionName("Mes/V1/createBendTask")]
public string createBendTask(string code)
{
LaserCutService laserCutService = new LaserCutService();
var response = laserCutService.createBendTask(code);
return Serialize(response);
}
/// <summary>
/// 托盘号
/// </summary>
/// <param name="palletCode"></param>
/// <returns></returns>
[HttpGet]
[ActionName("Mes/V1/GetYZJBendsInfo")]
public string GetYZJBendsInfo(string palletCode)
{
return Serialize(service.GetYZJBendsInfo(palletCode));
}
}
}