UpstreamSendWorkOrder.cs
32.7 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
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
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.Request;
using Hh.Mes.POJO.Response;
using Hh.Mes.POJO.WebEntity.bus;
using Hh.Mes.Service.Logs;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
namespace Hh.Mes.Service.ApiService
{
public partial class UpstreamService
{
#region 属性
/// <summary>
/// 产品表
/// </summary>
private base_product_header Sys_ProductHeader { get; set; }
/// <summary>
/// 工作中心映射华恒线体code
/// </summary>
private string Sys_LineCode { get; set; }
/// <summary>
/// 工艺路线头
/// </summary>
private base_process_route_head Sys_ProcessHead { get; set; }
/// <summary>
/// 工艺路线明细
/// </summary>
private List<base_process_route_detail> Sys_ProcessDetail { get; set; }
/// <summary>
/// 输出返回实体
/// </summary>
private ResponseUpstream<string> ResponseOrder { get; set; }
/// <summary>
/// Json 接受实体
/// </summary>
private MomWorkOrderHead MomEntity { get; set; }
#region 切割、组队、焊接工序
/// <summary>
/// 切割工序
/// </summary>
private base_process_route_detail Sys_process_cut { get; set; }
/// <summary>
/// 组队工序
/// </summary>
private base_process_route_detail Sys_process_fitUp { get; set; }
/// <summary>
/// 焊接工序
/// </summary>
private base_process_route_detail Sys_process_weld { get; set; }
#endregion
//工序任务 管段号 同一组工序明细的值 一样
private string Part_Code { get; set; }
/// <summary>
/// 更新数据使用 缓存工序任务头变量
/// </summary>
private bus_workOrder_head busWkHead { get; set; }
#endregion
public dynamic SendWorkOrder(MomWorkOrderHead requestData)
{
return ExceptionsHelp.Instance.ExecuteT(() =>
{
this.MomEntity = requestData;
MomWorkOrderHead entity = requestData;
var plmeid = entity == null ? "" : entity.plmeid;
ResponseOrder = new ResponseUpstream<string>(plmeid);
ResponseOrder = HandleAcceptOrderBefore();
if (!ResponseOrder.Status)
{
QueueInterLog.GetInstance.EnqueueInterLog(null, null, EnumLog.MOM订单下发失败.ToString(), ResponseOrder.Message, 0, user: "AOP", sysTitle: EnumLog.MOM业务问题.ToString());
return ResponseOrder;
}
//新增生产清单记录
AddApiWorkOrder(entity);
//生成订单数据
var orderDataResult = HandleAcceptOrderData();
//设置 BarCode 管段条码
ResponseOrder=SetBarCode(orderDataResult.Item2, ResponseOrder);
if (!ResponseOrder.Status)
{
QueueInterLog.GetInstance.EnqueueInterLog(null, null, EnumLog.MOM订单下发失败.ToString(), ResponseOrder.Message, 0, user: "AOP", sysTitle: EnumLog.MOM业务问题.ToString());
return ResponseOrder;
}
//保存数据
var saveResult = SaveHandleAcceptOrderData(orderDataResult.Item1, orderDataResult.Item2);
return saveResult;
});
}
/// <summary>
/// 订单下发接受数据处理 校验
/// </summary>
public ResponseUpstream<string> HandleAcceptOrderBefore()
{
if (MomEntity == null)
{
ResponseOrder.ResponseError("【上位系统】生产订单下发:工单数据为空,请检查!");
return ResponseOrder;
}
if (!typeValidation(MomEntity.type, ResponseOrder).Status) return ResponseOrder;
#region plmeid 判断逻辑
if (MomEntity.type == EnumAction.I.ToString())
{
if (Context.Queryable<bus_workOrder_head>().Any(t => t.plmeId == MomEntity.plmeid && t.isDelete == AddOrUpdateFlag))
{
ResponseOrder.ResponseError($"【上位系统】生产订单【plmeId、{MomEntity.plmeid}】信息已存在,请勿重复添加!");
return ResponseOrder;
}
} //更新
else if (MomEntity.type == EnumAction.U.ToString())
{
busWkHead = Context.Queryable<bus_workOrder_head>().First(t => t.plmeId == MomEntity.plmeid && t.isDelete == AddOrUpdateFlag);
if (busWkHead == null)
{
ResponseOrder.ResponseError($"【上位系统】生产订单【plmeId、{MomEntity.plmeid}】信息更新,订单不存在或已删除!");
return ResponseOrder;
}
else if (busWkHead.state != (int)EnumOrderHeadStatus.初始化)
{
ResponseOrder.ResponseError($"【上位系统】生产订单【plmeId、{MomEntity.plmeid}】信息更新,只能更新“初始化”状态的订单!");
return ResponseOrder;
}
}
#endregion
#region 空值检查
if (string.IsNullOrWhiteSpace(MomEntity.pro_order_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发:订单号【pro_order_code】不能为空值,请检查!");
return ResponseOrder;
}
if (string.IsNullOrWhiteSpace(MomEntity.plan_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发:生产计划号【plan_code】不能为空值,请检查!");
return ResponseOrder;
}
if (string.IsNullOrWhiteSpace(MomEntity.product_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发:产品编码【product_code】不能为空值,请检查!");
return ResponseOrder;
}
if (string.IsNullOrEmpty(MomEntity.factory_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发:工厂编码【factory_code】不能为空值,请检查!");
return ResponseOrder;
}
if (string.IsNullOrEmpty(MomEntity.line_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发:产线编码【line_code】不能为空值,请检查!");
return ResponseOrder;
}
#endregion
#region 生产订单的产品号要先存在工艺路线的产品表中
Sys_ProductHeader = base.Context.Queryable<base_product_header>().First(x => x.productCode == MomEntity.product_code && x.isDelete == AddOrUpdateFlag);
if (Sys_ProductHeader == null)
{
ResponseOrder.ResponseError($"【上位系统】工艺路线产品表【产品编码productCode、isDelete】[{MomEntity.product_code}、{AddOrUpdateFlag}]不存在,请【上位系统】先发送工艺线路基础数据!");
return ResponseOrder;
}
#endregion
#region 线体映射
var line = base.Context.Queryable<base_line>().First(x => x.otherCode == MomEntity.line_code);
if (line == null || string.IsNullOrEmpty(line.lineCode))
{
ResponseOrder.ResponseError($"订单下发:没有查询到线体【line_code】和华恒线体一致的数据,请通知管理员在【工厂模型->线体设置】维护外部编码!");
return ResponseOrder;
}
Sys_LineCode = line.lineCode;
#endregion
#region 生产订单查询工艺路线基础信息
var pp = base.Context.Queryable<base_process_product_rel>().First(x => x.productCode == MomEntity.product_code);
if (pp == null || string.IsNullOrEmpty(pp.lineCode))
{
ResponseOrder.ResponseError($"【上位系统】订单下发:没有查询到工艺产品关系productCode【{MomEntity.product_code}】对应的数据,请先发送工艺路线接口数据!");
return ResponseOrder;
}
Sys_ProcessHead = base.Context.Queryable<base_process_route_head>().First(x => x.keys == pp.processHeadKeys && x.edition == MomEntity.edition);
if (Sys_ProcessHead == null || string.IsNullOrEmpty(Sys_ProcessHead.lineCode))
{
ResponseOrder.ResponseError($"【上位系统】订单下发:没有查询到工艺路线lineCode【{Sys_LineCode}】【processCode】【{MomEntity.product_code}】版本【{MomEntity.edition}】对应的工艺路线,请先发送工艺路线接口数据!");
return ResponseOrder;
}
Sys_ProcessDetail = Context.Queryable<base_process_route_detail>().Where(x => x.headkeys == Sys_ProcessHead.keys && x.isDelete == AddOrUpdateFlag).OrderBy(t => t.oprSequence).ToList();
if (Sys_ProcessDetail.Count == 0)
{
ResponseOrder.ResponseError($"订单下发:没有查询到工艺路线明细【headkeys】【{Sys_ProcessHead.keys}】,反复出现请联系管理员!!");
return ResponseOrder;
}
#endregion
#region 切割、组队、焊接工序是否为空
Sys_process_cut = GetNowBaseprocessRouteDetail(Sys_ProcessHead.keys, EnumoprSequenceCode.切割坡口);
if (Sys_process_cut == null)
{
ResponseOrder.ResponseError($"【MOM】订单下发:工艺路线【{Sys_ProcessHead.keys}、{Sys_ProcessHead.processName}】不存在切割工序【{EnumoprSequenceCode.切割坡口},请核实该产品【{MomEntity.product_code}】的工艺路线工序!");
return ResponseOrder;
}
Sys_process_fitUp = GetNowBaseprocessRouteDetail(Sys_ProcessHead.keys, EnumoprSequenceCode.组对);
if (Sys_process_fitUp == null)
{
ResponseOrder.ResponseError($"【MOM】订单下发:工艺路线【{Sys_ProcessHead.keys}、{Sys_ProcessHead.processName}】不存在组队工序【{EnumoprSequenceCode.组对},请核实该产品【{MomEntity.product_code}】的工艺路线工序!");
return ResponseOrder;
}
Sys_process_weld = GetNowBaseprocessRouteDetail(Sys_ProcessHead.keys, EnumoprSequenceCode.焊接);
if (Sys_process_weld == null)
{
ResponseOrder.ResponseError($"【MOM】订单下发:工艺路线【{Sys_ProcessHead.keys}、{Sys_ProcessHead.processName}】不存在焊接工序【{EnumoprSequenceCode.焊接},请核实该产品【{MomEntity.product_code}】的工艺路线工序!");
return ResponseOrder;
}
#endregion
#region 生产订单工序是否在工艺路线中、 切割工序物料不能为空、是否存在物料表信息
if (MomEntity.details.Count < Sys_ProcessDetail.Count)
{
ResponseOrder.ResponseError($"【MOM】订单下发:子表明细details行数【{MomEntity.details.Count}】小于工艺路线行数【{Sys_ProcessDetail.Count}】不一致,请核实订单计划数据明细数据!");
return ResponseOrder;
}
foreach (var item in MomEntity.details)
{
var isOk = Sys_ProcessDetail.Any(x => x.oprSequenceCode == item.proced_code);
if (!isOk)
{
ResponseOrder.ResponseError($"【MOM】订单下发:子表明细工序编码proced_code【{item.proced_code}】不存在工艺路线工序集合中,请核实订单计划数据明细工序编码数据!");
return ResponseOrder;
}
if (item.proced_code == Sys_process_cut.oprSequenceCode)
{
foreach (var itemComponent in item.componentDetails)
{
if (string.IsNullOrEmpty(itemComponent.cut_mater_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发-切割工序:物料编码【cut_mater_code】不能为空值,请检查!");
return ResponseOrder;
}
else
{
var isExt = base.Context.Queryable<base_material>().Any(x => x.materialCode == itemComponent.cut_mater_code && x.isDelete == AddOrUpdateFlag);
if (isExt) continue;
ResponseOrder.ResponseError($"【上位系统】订单下发-切割工序:没有查询到物料主数据cut_mater_code【{itemComponent.cut_mater_code}】对应的信息,请先发送物料主数据接口数据,或者在物料管理模块点击按钮【同步信科物料 】!");
return ResponseOrder;
}
}
}else if (item.proced_code == Sys_process_weld.oprSequenceCode)
{
foreach (var itemComponent in item.componentDetails)
{
if (string.IsNullOrEmpty(itemComponent.weld_mater_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发-焊接工序:焊口物料编码【weld_mater_code】不能为空值,请检查!");
return ResponseOrder;
}
else if (string.IsNullOrEmpty(itemComponent.cut_mater_code))
{
ResponseOrder.ResponseError($"【上位系统】订单下发-焊接工序:管段物料编码【cut_mater_code】不能为空值,请检查!");
return ResponseOrder;
}
else
{
var weldMaterCodeList = itemComponent.weld_mater_code.Split(',', StringSplitOptions.RemoveEmptyEntries);
for (int xp = 0; xp < weldMaterCodeList.Length; xp++)
{
var tempMaterCode = weldMaterCodeList[xp];
var isExt = base.Context.Queryable<base_material>().Any(x => x.materialCode == tempMaterCode && x.isDelete == AddOrUpdateFlag);
if (isExt) continue;
ResponseOrder.ResponseError($"【上位系统】订单下发-焊接工序:没有查询到物料主数据weld_mater_code【{tempMaterCode}】对应的信息,请先发送物料主数据接口数据,或者在物料管理模块点击按钮【同步信科物料 】!");
return ResponseOrder;
}
}
}
}
}
#endregion
return ResponseOrder;
}
/// <summary>
/// 新增 生产清单记录
/// </summary>
private void AddApiWorkOrder(MomWorkOrderHead entity)
{
var head = new api_workOrder_head
{
keys = Guid.NewGuid(),
plmeId = entity.plmeid,
workOrderCode = entity.pro_order_code,
planCode = entity.plan_code,
productCode = entity.product_code,
productName = entity.product_name,
factoryCode = entity.factory_code,
lineCode = entity.line_code,
orderType = entity.order_type,
edition = entity.edition,
projectCode = entity.project_code,
projectName = entity.project_name,
lineNo = entity.line_no,
planStartTime = entity.oprplan_start_time,
planEndTime = entity.oprplan_end_time,
extend1 = entity.extend1,
extend2 = entity.extend2,
extend3 = entity.extend3,
extend4 = entity.extend4,
isDelete = AddOrUpdateFlag,
createTime = DateTime.Now,
createBy = SystemVariable.DefaultCreated
};
var details = new List<api_workOrder_detail>();
foreach (var item in entity.details)
{
foreach (var itemCom in item.componentDetails)
{
var detail = new api_workOrder_detail();
detail.headKeys = head.keys;
detail.oprSequenceCode = item.proced_code;
detail.isEndProduct = item.isend_product;
detail.extend1 = item.extend1;
detail.extend2 = item.extend2;
detail.createTime = DateTime.Now;
detail.createBy = SystemVariable.DefaultCreated;
if (string.IsNullOrEmpty(Part_Code)) Part_Code = itemCom.part_code;
detail.cutMaterCode = itemCom.cut_mater_code;
detail.cuttingLength = itemCom.cutting_len;
detail.weldType = itemCom.weld_type;
detail.weldNo = itemCom.weld_no;
detail.weldMaterCode = itemCom.weld_mater_code;
detail.extendComp1 = itemCom.extendComp1;
detail.extendComp2 = itemCom.extendComp2;
detail.extendComp3= itemCom.extendComp3;
detail.extendComp4 = itemCom.extendComp4;
details.Add(detail);
}
}
Context.Insertable(head).AddQueue();
Context.Insertable(details).AddQueue();
}
/// <summary>
/// 生成数据
/// </summary>
private ValueTuple<bus_workOrder_head, List<bus_workOrder_detail>> HandleAcceptOrderData()
{
#region 生成工序任务头 bus_workOrder_head
var busWorkOrderHead = new bus_workOrder_head
{
keys = Guid.NewGuid(),
plmeId = MomEntity.plmeid,
workOrderCode = MomEntity.pro_order_code,
workOrderName= MomEntity.pro_order_code+ "_订单名称",
planCode = MomEntity.plan_code,
processHeadKeys = Sys_ProcessHead.keys,//工艺路线keys
processCode = Sys_ProductHeader.processCode, //工艺路线编码
productHeaderCode = MomEntity.product_code, //产品编码
productName = MomEntity.product_name,
factoryCode = MomEntity.factory_code,
lineCode = Sys_LineCode,
orderType = MomEntity.order_type,
edition= MomEntity.edition,
projectCode = MomEntity.project_code, //项目编码
projectName = MomEntity.project_name,
lineNo=MomEntity.line_no, //管线号/图纸号
planStartTime = MomEntity.oprplan_start_time,
planEndTime = MomEntity.oprplan_end_time,
extend1=MomEntity.extend1,
extend2=MomEntity.extend2,
extend3 = MomEntity.extend3,
extend4 = MomEntity.extend4,
otherOrderCode = MomEntity.plan_code,
state = (int)EnumOrderHeadStatus.初始化,
isDelete = AddOrUpdateFlag,
createTime = DateTime.Now,
createBy = SystemVariable.DefaultCreated
};
#endregion
#region 生成工序任务明细 busWorkOrderDetailList
var busWorkOrderDetailList = new List<bus_workOrder_detail>();
foreach (var item in Sys_ProcessDetail)
{
if (item.oprSequenceCode == Sys_process_cut.oprSequenceCode)
{
SetWorkOrderDetailCut(busWorkOrderDetailList, item,busWorkOrderHead);
}
else if (item.oprSequenceCode == Sys_process_fitUp.oprSequenceCode)
{
SetWorkOrderDetailFitUpOrWeld(busWorkOrderDetailList, item,busWorkOrderHead);
}
else if (item.oprSequenceCode == Sys_process_weld.oprSequenceCode)
{
SetWorkOrderDetailFitUpOrWeld(busWorkOrderDetailList, item,busWorkOrderHead);
}
else
{
var jsonMomItem = MomEntity.details.FirstOrDefault(x => x.proced_code == item.oprSequenceCode);
for(int i = 0; i < jsonMomItem.componentDetails.Count; i++)
{
var nowWorkDetail = new bus_workOrder_detail
{
headKeys = busWorkOrderHead.keys,
productHeaderCode = busWorkOrderHead.productHeaderCode,
workOrderCode = busWorkOrderHead.workOrderCode,
cutMaterCode = jsonMomItem.componentDetails[i].cut_mater_code,
cuttingLength = (decimal)jsonMomItem.componentDetails[i].cutting_len,
lineCode = Sys_LineCode,
designNo = jsonMomItem.componentDetails[i].design_no,
designUrl = jsonMomItem.componentDetails[i].design_url,
partCode = Part_Code,
serialNumber = item.oprSequence,
oprSequenceCode = item.oprSequenceCode,
oprSequenceName = item.oprSequenceName,
workCenterCode = item.workCenterCode,
planStartTime = jsonMomItem.oprplan_start_time,
planEndTime = jsonMomItem.oprplan_end_time,
isEndProduct = jsonMomItem.isend_product,
isDelete = AddOrUpdateFlag,
state = (int)EnumOrderBodyStatus.初始化,
workReportStatus = (int)EnumWorkReportStatus.未报工,
createTime = DateTime.Now,
createBy = SystemVariable.DefaultCreated
};
nowWorkDetail.bodyKeys = Guid.NewGuid();
nowWorkDetail.serialNumberName = nowWorkDetail.serialNumber + "_1";
busWorkOrderDetailList.Add(nowWorkDetail);
}
}
}
#endregion
// 设置工序任务头的当前工序,为第一个工序任务明细的工序
if (busWorkOrderDetailList.Count > 0)
{
busWorkOrderHead.nowOprSequenceCode = busWorkOrderDetailList[0].oprSequenceCode;
}
return (busWorkOrderHead, busWorkOrderDetailList);
}
//生成管段条码
public ResponseUpstream<string> SetBarCode(List<bus_workOrder_detail> details, ResponseUpstream<string> response)
{
var barCodeList = new List<string>();
for (int i = 0; i < Sys_ProcessDetail.Count; i++)
{
var oprSequenceCode = Sys_ProcessDetail[i].oprSequenceCode;
var oprList = details.Where(x => x.oprSequenceCode == oprSequenceCode).ToList();
//第一个工序
if (i == 0)
{
for (int j = 0; j < oprList.Count; j++)
{
details[j].barCode = base.GetWorkOrderBarCode();
barCodeList.Add(details[j].barCode);
}
}
else
{
if (barCodeList.Count != oprList.Count)
{
response.ResponseError($"【上位系统】订单下发:工艺路线工序【{oprSequenceCode}】个数【{barCodeList.Count}】和工序任务明细个数【{oprList.Count}】不一致,请检查!");
return ResponseOrder;
}
for (int j = 0; j < oprList.Count; j++)
{
var index = details.FindIndex(x => x.bodyKeys == oprList[j].bodyKeys);
details[index].barCode = barCodeList[j];
}
}
}
return response;
}
/// <summary>
/// 切割工序 工序任务设置值
/// </summary>
public void SetWorkOrderDetailCut(List<bus_workOrder_detail> busWorkOrderDetailList, base_process_route_detail oprDetail, bus_workOrder_head head)
{
var cutOprList = MomEntity.details.Where(x => x.proced_code == oprDetail.oprSequenceCode).ToList();
var serialNumberNameIndex = 1;
foreach (var itemCut in cutOprList)
{
for (int i = 0; i < itemCut.componentDetails.Count; i++)
{
var nowWorkDetail = new bus_workOrder_detail
{
headKeys = head.keys,
bodyKeys = Guid.NewGuid(),
productHeaderCode = head.productHeaderCode,
workOrderCode = head.workOrderCode,
lineCode = Sys_LineCode,
designNo= itemCut.componentDetails[i].design_no,
designUrl= itemCut.componentDetails[i].design_url,
partCode = Part_Code,
serialNumber = oprDetail.oprSequence,
oprSequenceCode = oprDetail.oprSequenceCode,
oprSequenceName = oprDetail.oprSequenceName,
workCenterCode = oprDetail.workCenterCode,
planStartTime = itemCut.oprplan_start_time,
planEndTime = itemCut.oprplan_end_time,
isDelete = AddOrUpdateFlag,
state = (int)EnumOrderBodyStatus.初始化,
workReportStatus = (int)EnumWorkReportStatus.未报工,
createTime = DateTime.Now,
createBy = SystemVariable.DefaultCreated
};
nowWorkDetail.isEndProduct = itemCut.isend_product;
nowWorkDetail.serialNumberName = oprDetail.oprSequence + "_" + serialNumberNameIndex++;
nowWorkDetail.cutMaterCode = itemCut.componentDetails[i].cut_mater_code;
nowWorkDetail.cuttingLength = (decimal)itemCut.componentDetails[i].cutting_len;
nowWorkDetail.extend1 = itemCut.componentDetails[i].extend1;
nowWorkDetail.extend2 = itemCut.componentDetails[i].extend2;
nowWorkDetail.extendComp1 = itemCut.componentDetails[i].extendComp1;
nowWorkDetail.extendComp2 = itemCut.componentDetails[i].extendComp2;
nowWorkDetail.extendComp3 = itemCut.componentDetails[i].extendComp3;
nowWorkDetail.extendComp4 = itemCut.componentDetails[i].extendComp4;
busWorkOrderDetailList.Add(nowWorkDetail);
}
}
}
/// <summary>
/// 组队或者焊接工序 工序任务设置值
/// </summary>
public void SetWorkOrderDetailFitUpOrWeld(List<bus_workOrder_detail> busWorkOrderDetailList, base_process_route_detail oprDetail, bus_workOrder_head head)
{
var oprList = MomEntity.details.Where(x => x.proced_code == oprDetail.oprSequenceCode).ToList();
foreach (var item in oprList)
{
for (int i = 0; i < item.componentDetails.Count; i++)
{
//焊接工序物料
var weldNoList = item.componentDetails[i].weld_no.Split(',', StringSplitOptions.RemoveEmptyEntries);
var weldMaterCodeList = item.componentDetails[i].weld_mater_code.Split(',', StringSplitOptions.RemoveEmptyEntries);
for (int xp = 0; xp < weldNoList.Length; xp++)
{
var nowWorkDetail = new bus_workOrder_detail
{
headKeys = head.keys,
bodyKeys = Guid.NewGuid(),
productHeaderCode = head.productHeaderCode,
workOrderCode = head.workOrderCode,
lineCode = Sys_LineCode,
designNo = item.componentDetails[i].design_no,
designUrl = item.componentDetails[i].design_url,
partCode = Part_Code,
serialNumber = oprDetail.oprSequence,
oprSequenceCode = oprDetail.oprSequenceCode,
oprSequenceName = oprDetail.oprSequenceName,
workCenterCode = oprDetail.workCenterCode,
planStartTime = item.oprplan_start_time,
planEndTime = item.oprplan_end_time,
isEndProduct = item.isend_product,
isDelete = AddOrUpdateFlag,
state = (int)EnumOrderBodyStatus.初始化,
workReportStatus = (int)EnumWorkReportStatus.未报工,
createTime = DateTime.Now,
createBy = SystemVariable.DefaultCreated,
weldType = item.componentDetails[i].weld_type
};
nowWorkDetail.serialNumberName = oprDetail.oprSequence + "_" +(xp+1);
nowWorkDetail.weldNo = weldNoList[xp];
nowWorkDetail.weldMaterCode = weldMaterCodeList[xp];
nowWorkDetail.cutMaterCode = item.componentDetails[i].cut_mater_code;
nowWorkDetail.extend1 = item.componentDetails[i].extend1;
nowWorkDetail.extend2 = item.componentDetails[i].extend2;
nowWorkDetail.extendComp1 = item.componentDetails[i].extendComp1;
nowWorkDetail.extendComp2 = item.componentDetails[i].extendComp2;
nowWorkDetail.extendComp3 = item.componentDetails[i].extendComp3;
nowWorkDetail.extendComp4 = item.componentDetails[i].extendComp4;
busWorkOrderDetailList.Add(nowWorkDetail);
}
}
}
}
/// <summary>
/// 保存数据
/// </summary>
private ResponseUpstream<string> SaveHandleAcceptOrderData(bus_workOrder_head busWorkOrderHead, List<bus_workOrder_detail> busWorkOrderDetailList)
{
int resultCount = 0;
if (busWorkOrderDetailList == null || busWorkOrderDetailList.Count == 0)
{
ResponseOrder.ResponseError($"【上位系统】订单下发:工序任务明细生成失败,请确认请先发送工艺路线接口数据,反复出现请联系管理员!");
return ResponseOrder;
}
//新增
if (MomEntity.type == EnumAction.I.ToString())
{
Context.Insertable(busWorkOrderHead).AddQueue();
Context.Insertable(busWorkOrderDetailList).AddQueue();
}
//更新
else if (MomEntity.type == EnumAction.U.ToString())
{
busWorkOrderHead.keys = busWkHead.keys;
busWorkOrderHead.updateTime = DateTime.Now;
busWorkOrderDetailList.ForEach(x =>
{
x.headKeys = busWkHead.keys;
x.updateTime = DateTime.Now;
});
Context.Updateable(busWorkOrderHead)
.IgnoreColumns(x => new { x.createBy, x.createTime, x.keys })
.Where(x => x.keys == busWorkOrderHead.keys && x.isDelete == AddOrUpdateFlag).AddQueue();
Context.Updateable(busWorkOrderDetailList)
.IgnoreColumns(x => new { x.createBy, x.createTime, x.bodyKeys, x.headKeys })
.Where(x => x.bodyKeys == busWorkOrderHead.keys && x.isDelete == AddOrUpdateFlag).AddQueue();
}
resultCount = ExecuteQueues(base.Context);
return (ResponseUpstream<string>)(resultCount > 0 ? ResponseOrder.ResponseSuccess() : ResponseOrder.ResponseError());
}
}
}