ICSReceiptAPIService.java
27.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
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
package com.huaheng.api.U8.Service;
import com.alibaba.fastjson.JSON;
import com.huaheng.api.U8.domain.*;
import com.huaheng.api.general.service.ReceiptAPIService;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.http.HttpUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.general.company.domain.CompanyWu;
import com.huaheng.pc.general.company.service.ICompanyService;
import com.huaheng.pc.general.material.domain.Material;
import com.huaheng.pc.general.material.service.IMaterialService;
import com.huaheng.pc.general.warehouse.domain.WarehouseWu;
import com.huaheng.pc.general.warehouse.service.IWarehouseService;
import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.receipt.receiptDetail.service.IReceiptDetailService;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptModel;
import com.huaheng.pc.receipt.receiptHeader.service.IReceiptHeaderService;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.ITaskDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.RequestBody;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
/**
* u8-wms入库下发或回传接口服务层
* @author huaheng
* @date 2019-1-4
*
*/
@Service
public class ICSReceiptAPIService {
@Autowired
private ICompanyService companyService;
@Autowired
private ICSReceiptHeaderService icsReceiptHeaderService;
@Autowired
private ICSReceiptDetailService icsReceiptDetailService;
@Autowired
private IMaterialService materialService;
@Autowired
private ReceiptAPIService receiptAPIservice;
@Autowired
private IReceiptHeaderService receiptHeaderService;
@Autowired
private IReceiptDetailService receiptDetailService;
@Autowired
private IWarehouseService warehouseService;
@Autowired
private ICSShipmentDetailService icsShipmentDetailService;
@Autowired
private ICSShipmentHeaderService icsShipmentHeaderService;
@Autowired
private ITaskDetailService taskDetailService;
//入库单下发
@Transactional
public AjaxResult insertICSReceipt(@RequestBody ICSReceiptModel icsReceiptModel){
ICSReceiptHeader icsReceiptHeader=icsReceiptModel.getIcsReceiptHeader();
List<ICSReceiptDetail> icsReceiptDetails=icsReceiptModel.getIcsReceiptDetails();
//判断系统中有没有该货主
CompanyWu companyWu=new CompanyWu();
companyWu.setuCompanyCode(icsReceiptHeader.getCompanyCode());
companyWu=companyService.selectCompanyWu(companyWu);
if(companyWu==null){
return AjaxResult.error("货主不存在");
}
companyService.checkwarehouseCompany(companyWu.getCompanyCode());
//根据icsReceiptHeader生成receiptHeader
String type=icsReceiptHeader.getType();
ReceiptHeader receiptHeader=new ReceiptHeader();
if(!type.equals("PCI")){
String warehouseCode=null;
if(type.equals("TI")){
warehouseCode=icsReceiptHeader.getiWHCode();
}else {
warehouseCode=icsReceiptHeader.getcWHCode();
}
//通过u8的货主和仓库匹配wms的仓库
WarehouseWu warehouseWu=new WarehouseWu();
warehouseWu.setuCompanyCode(icsReceiptHeader.getCompanyCode());
warehouseWu.setuWarehouseCode(warehouseCode);
warehouseWu=warehouseService.selectWarehouseWu(warehouseWu);
if(warehouseWu==null){
throw new ServiceException("系统没有该仓库");
}
String maker = icsReceiptHeader.getcMaker();
receiptHeader.setType(type);
receiptHeader.setId(null);
receiptHeader.setLastUpdatedBy(maker);
receiptHeader.setCreatedBy(maker);
receiptHeader.setRemark(icsReceiptHeader.getcMemo());
receiptHeader.setSupplierCode(icsReceiptHeader.getcVenCode());
receiptHeader.setSupplierName(icsReceiptHeader.getcVenName());
receiptHeader.setWarehouseCode(warehouseWu.getWarehouseCode());
receiptHeader.setuWarehouseCode(warehouseCode);
receiptHeader.setCompanyCode(companyWu.getCompanyCode());
if (type.equals("TI")) {
receiptHeader.setSourceCode(icsReceiptHeader.getcTVCode());
}else {
receiptHeader.setSourceCode(icsReceiptHeader.getcCode());
}
if(StringUtils.isEmpty(receiptHeader.getSourceCode())){
throw new ServiceException("没有单号");
}
ReceiptHeader receiptHeaderB=new ReceiptHeader();
receiptHeaderB.setSourceCode(receiptHeader.getSourceCode());
if(receiptHeaderService.selectFirstEntity(receiptHeaderB)!=null){
return AjaxResult.success("单号重复,已跳过");
}
//将主表插入到新的接收主表里去
int result=icsReceiptHeaderService.insertModel(icsReceiptHeader);
if(result<1){
throw new ServiceException("入库主单传输失败!");
}
//将子表插入到新的接收子表里去
for(ICSReceiptDetail item : icsReceiptDetails){
if(icsReceiptHeader.getType().equals("TI")){
item.setcCode(icsReceiptHeader.getcTVCode());
}else {
item.setcCode(icsReceiptHeader.getcCode());
}
int result1=icsReceiptDetailService.insertModel(item);
if(result1<1){
throw new ServiceException("入库子单传输失败!");
}
}
//根据icsShipmentDetail生成shipmentAetail
List<ReceiptDetail> receiptDetails=new ArrayList<ReceiptDetail>();
for(ICSReceiptDetail item : icsReceiptDetails) {
//查找物料
Material material = new Material();
material.setCode(item.getcInvCode());
material.setWarehouseCode(warehouseWu.getWarehouseCode());
material=materialService.selectFirstEntity(material);
if(material==null){
throw new ServiceException("该物料不存在:"+item.getcInvCode());
}
ReceiptDetail receiptDetail = new ReceiptDetail();
receiptDetail.setId(null);
receiptDetail.setWarehouseCode(warehouseWu.getWarehouseCode());
receiptDetail.setMaterialCode(item.getcInvCode());
receiptDetail.setZoneCode(material.getZoneCode());
receiptDetail.setCreated(null);
receiptDetail.setUnit(item.getcComUnitName());
receiptDetail.setCreatedBy(maker);
receiptDetail.setLastUpdated(null);
receiptDetail.setLastUpdatedBy(maker);
if(!item.getCompanyCode().equals(icsReceiptHeader.getCompanyCode())){
throw new ServiceException("子单货主与主单不对应");
}
receiptDetail.setCompanyCode(companyWu.getCompanyCode());
receiptDetail.setProject(item.getcItemName());
receiptDetail.setQty(item.getiQuantity().abs());
// receiptDetail.setQtyCompleted(item.getiQuantity());
receiptDetail.setInventoryStatus("good");
if (item.getIrowno()!=null && StringUtils.isNotEmpty(item.getIrowno().toString())) {
receiptDetail.setSourceLine(item.getIrowno().toString());
}
receiptDetails.add(receiptDetail);
}
//调用公共API
ReceiptModel receiptModel=new ReceiptModel();
receiptModel.setReceiptHeader(receiptHeader);
receiptModel.setReceiptDetails(receiptDetails);
return receiptAPIservice.insertReceipt(receiptModel);
}
return AjaxResult.success("入库单下发成功");
}
//采购到货单和销售退货入库单
@Transactional
public AjaxResult insertICSReceipts(ICSReceiptModel icsReceiptModel) {
ICSReceiptHeader icsReceiptHeader = icsReceiptModel.getIcsReceiptHeader();
List<ICSReceiptDetail> icsReceiptDetails = icsReceiptModel.getIcsReceiptDetails();
if (!icsReceiptHeader.getType().equals("SRI") && !icsReceiptHeader.getType().equals("PI")) {
return AjaxResult.error("入库类型不匹配");
}
//判断系统中有没有该货主
CompanyWu companyWu=new CompanyWu();
companyWu.setuCompanyCode(icsReceiptHeader.getCompanyCode());
companyWu=companyService.selectCompanyWu(companyWu);
if(companyWu==null){
return AjaxResult.error("货主不存在");
}
companyService.checkwarehouseCompany(companyWu.getCompanyCode());
String code=null;
if(icsReceiptHeader.getType().equals("SRI")){
code=icsReceiptHeader.getcDLCode();
}else {
code=icsReceiptHeader.getcCode();
}
if(StringUtils.isEmpty(code)){
throw new ServiceException("没有单号");
}
ReceiptHeader receiptHeaderB=new ReceiptHeader();
receiptHeaderB.setSourceCode(code);
if(receiptHeaderService.selectFirstEntity(receiptHeaderB)!=null){
return AjaxResult.success("单号重复,已跳过");
}
//判断仓库是否存在单据的物料编码
WarehouseWu warehouseWu=new WarehouseWu();
ReceiptHeader receiptHeader;
List<ReceiptDetail> receiptDetails;
Set<String> warehouseCodes = new HashSet<>();
Set<String> uwarehouseCodes = new HashSet<>();
for (ICSReceiptDetail item : icsReceiptDetails) {
//通过u8的货主和仓库匹配wms的仓库
warehouseWu.setuCompanyCode(icsReceiptHeader.getCompanyCode());
warehouseWu.setuWarehouseCode(item.getcWHCode());
warehouseWu=warehouseService.selectWarehouseWu(warehouseWu);
if(warehouseWu==null){
throw new ServiceException("系统没有该仓库");
}
uwarehouseCodes.add(item.getcWHCode());
warehouseCodes.add(warehouseWu.getWarehouseCode());
}
//将主表插入到新的接收主表里去
int result = icsReceiptHeaderService.insertModel(icsReceiptHeader);
if (result < 1) {
throw new ServiceException("出库主单传输失败!");
}
//将子表插入到新的接收子表里去
for (ICSReceiptDetail item : icsReceiptDetails) {
item.setcCode(code);
int result1 = icsReceiptDetailService.insertModel(item);
if (result1 < 1) {
throw new ServiceException("出库子单传输失败!");
}
}
String maker=icsReceiptHeader.getcMaker();
for (String warehouseCode : warehouseCodes) {
for (String uwarehouseCode : uwarehouseCodes) {
receiptDetails = new ArrayList<>();
//出库主单
receiptHeader = new ReceiptHeader();
receiptHeader.setType(icsReceiptHeader.getType());
receiptHeader.setId(null);
receiptHeader.setLastUpdatedBy(maker);
receiptHeader.setCreatedBy(maker);
receiptHeader.setSourceCode(code);
receiptHeader.setSupplierCode(icsReceiptHeader.getcVenCode());
receiptHeader.setSupplierName(icsReceiptHeader.getcVenName());
receiptHeader.setWarehouseCode(warehouseCode);
receiptHeader.setuWarehouseCode(uwarehouseCode);
receiptHeader.setCompanyCode(companyWu.getCompanyCode());
//细单
for (ICSReceiptDetail item : icsReceiptDetails) {
//匹配仓库
if (uwarehouseCode.equals(item.getcWHCode())) {
//查找物料
Material material = new Material();
material.setCode(item.getcInvCode());
material.setWarehouseCode(warehouseCode);
material=materialService.selectFirstEntity(material);
if(material==null){
throw new ServiceException("该物料不存在:"+item.getcInvCode());
}
ReceiptDetail receiptDetail = new ReceiptDetail();
receiptDetail.setId(null);
receiptDetail.setWarehouseCode(warehouseCode);
receiptDetail.setMaterialCode(item.getcInvCode());
receiptDetail.setZoneCode(material.getZoneCode());
receiptDetail.setCreated(null);
receiptDetail.setUnit(item.getcComUnitName());
receiptDetail.setCreatedBy(maker);
receiptDetail.setLastUpdated(null);
receiptDetail.setLastUpdatedBy(maker);
if (!item.getCompanyCode().equals(icsReceiptHeader.getCompanyCode())) {
throw new ServiceException("子单货主与主单不对应");
}
receiptDetail.setCompanyCode(companyWu.getCompanyCode());
receiptDetail.setProject(item.getcItemName());
receiptDetail.setQty(item.getiQuantity().abs());
// receiptDetail.setQtyCompleted(item.getiQuantity());
receiptDetail.setInventoryStatus("good");
receiptDetails.add(receiptDetail);
}
}
//调用公共API
ReceiptModel receiptModel = new ReceiptModel();
receiptModel.setReceiptHeader(receiptHeader);
receiptModel.setReceiptDetails(receiptDetails);
receiptAPIservice.insertReceipt(receiptModel);
}
}
return AjaxResult.success("销售入货单下发成功");
}
//入库单回传
public AjaxResult ConfirmICSReceipt(String url) {
AjaxResult ajaxResult=new AjaxResult();
//先找出处于完成状态的taskDetail
TaskDetail taskDetail=new TaskDetail();
taskDetail.setStatus((short)40);
taskDetail=taskDetailService.selectFirstEntity(taskDetail);
if(taskDetail==null){
return AjaxResult.success("没有完成状态的子任务");
}
//根据子任务查找主单
ReceiptHeader receiptHeader = new ReceiptHeader();
receiptHeader.setCode(taskDetail.getBillCode());
receiptHeader = receiptHeaderService.selectFirstEntity(receiptHeader);
if(receiptHeader==null){
return AjaxResult.success("出库单上传中");
}
String type = receiptHeader.getType();
String code = receiptHeader.getSourceCode();
if (!type.equals("SI") && !type.equals("PI") && !type.equals("CI") && !type.equals("QI") && !type.equals("SRI") && !type.equals("TI")) {
taskDetail.setStatus((short) 45);
taskDetailService.updateByModel(taskDetail);
return AjaxResult.success("该子任务所属单据无需上传");
}
//查找相同单号的状态为40的子任务
TaskDetail detail=new TaskDetail();
detail.setStatus((short)40);
detail.setBillCode(receiptHeader.getCode());
List<TaskDetail> taskDetails=taskDetailService.selectListEntityByEqual(detail);
//根据组盘明细查找子单
List<ReceiptDetail> receiptDetails = new ArrayList<>();
for(TaskDetail item:taskDetails) {
ReceiptDetail receiptDetail = receiptDetailService.selectEntityById(item.getBillDetailId());
receiptDetail.setQtyCompleted(item.getQty());
receiptDetails.add(receiptDetail);
}
//u8与wms货主的对应
CompanyWu companyWu = new CompanyWu();
companyWu.setCompanyCode(receiptHeader.getCompanyCode());
companyWu = companyService.selectCompanyWu(companyWu);
ICSReceiptHeader icsReceiptHeader = new ICSReceiptHeader();
List<ICSReceiptDetail> icsReceiptDetails = new ArrayList<ICSReceiptDetail>();
WarehouseWu warehousewu = new WarehouseWu();
Material material = new Material();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
String dt = simpleDateFormat.format(receiptHeader.getLastUpdated());
//入库类型为成品入库单
if (type.equals("SI")) {
icsReceiptHeader.setcCode(receiptHeader.getCode());
icsReceiptHeader.setID(receiptHeader.getId());
icsReceiptHeader.setdPODate(dt);
icsReceiptHeader.setcWHCode("20");
warehousewu.setuWarehouseCode("20");
warehousewu.setuCompanyCode(companyWu.getuCompanyCode());
icsReceiptHeader.setcWHName(warehouseService.selectWarehouseWu(warehousewu).getuWarehouseName());
icsReceiptHeader.setcMemo(receiptHeader.getRemark());
icsReceiptHeader.setcBusType("产成品入库");
icsReceiptHeader.setcMaker(taskDetail.getLastUpdatedBy());
icsReceiptHeader.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptHeader.setcModifyDate(dt);
icsReceiptHeader.setVoucherType("CreateICSRdRecord_10");
for (ReceiptDetail item : receiptDetails) {
ICSReceiptDetail icsReceiptDetail = new ICSReceiptDetail();
icsReceiptDetail.setID(receiptHeader.getId());
icsReceiptDetail.setIrowno(Integer.valueOf(item.getSourceLine()));
icsReceiptDetail.setiMPoIds(item.getId());
icsReceiptDetail.setcItemName(item.getProject());
icsReceiptDetail.setcInvCode(item.getMaterialCode());
material.setCode(item.getMaterialCode());
material = materialService.selectFirstEntity(material);
icsReceiptDetail.setcInvName(material.getName());
icsReceiptDetail.setcInvStd(material.getSpecification());
icsReceiptDetail.setiQuantity(item.getQtyCompleted());
icsReceiptDetail.setcComUnitName(material.getMasterUnit());
icsReceiptDetail.setCompanyCode(item.getCompanyCode());
icsReceiptDetail.setcModifyDate(dt);
icsReceiptDetails.add(icsReceiptDetail);
}
}
//入库类型为采购的主单和子单
if (type.equals("PI")) {
icsReceiptHeader.setcCode(code);
icsReceiptHeader.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptHeader = icsReceiptHeaderService.selectModel(icsReceiptHeader);
icsReceiptHeader.setcWHCode(receiptHeader.getuWarehouseCode());
icsReceiptHeader.setID(receiptHeader.getId());
icsReceiptHeader.setVoucherType("CreateICSRdRecord_01");
icsReceiptHeader.setcMaker(taskDetail.getLastUpdatedBy());
//子单
for (ReceiptDetail item : receiptDetails) {
ICSReceiptDetail icsReceiptDetailA = new ICSReceiptDetail();
icsReceiptDetailA.setcCode(code);
icsReceiptDetailA.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptDetailA.setcInvCode(item.getMaterialCode());
icsReceiptDetailA = icsReceiptDetailService.selectModel(icsReceiptDetailA);
icsReceiptDetailA.setID(item.getId());
icsReceiptDetailA.setiArrsId(icsReceiptDetailA.getAutoID());
icsReceiptDetailA.setiPOsID(icsReceiptDetailA.getPODID());
icsReceiptDetailA.setiQuantity(item.getQtyCompleted());
icsReceiptDetails.add(icsReceiptDetailA);
}
// icsReceiptDetail.setcCode(code);
// icsReceiptDetail.setCompanyCode(companyWu.getuCompanyCode());
// icsReceiptDetails=icsReceiptDetailService.selectList(icsReceiptDetail);
// for(ReceiptDetail item: receiptDetails){
// receiptDetail.setReceiptCode(code);
// receiptDetail.setSourceLine(item.getIrowno().toString());
// receiptDetailService.selectFirstEntity(receiptDetail);
// item.setID(receiptDetail.getId());
// item.setiArrsId(item.getAutoID());
// item.setiPOsID(item.getPODID());
// }
}
//入库类型为材料或其他的主单和子单
if (type.equals("CI") || type.equals("QI")) {
icsReceiptHeader.setcCode(code);
icsReceiptHeader.setcWHCode(receiptHeader.getuWarehouseCode());
icsReceiptHeader.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptHeader = icsReceiptHeaderService.selectModel(icsReceiptHeader);
icsReceiptHeader.setdDate(dt);
icsReceiptHeader.setcMaker(taskDetail.getLastUpdatedBy());
for (ReceiptDetail item : receiptDetails) {
ICSReceiptDetail icsReceiptDetailB = new ICSReceiptDetail();
icsReceiptDetailB.setcCode(code);
icsReceiptDetailB.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptDetailB.setcInvCode(item.getMaterialCode());
icsReceiptDetailB = icsReceiptDetailService.selectModel(icsReceiptDetailB);
icsReceiptDetailB.setiQuantity(item.getQtyCompleted());
icsReceiptDetails.add(icsReceiptDetailB);
}
// icsReceiptDetail.setcCode(code);
// icsReceiptDetail.setCompanyCode(companyWu.getuCompanyCode());
// icsReceiptDetails=icsReceiptDetailService.selectList(icsReceiptDetail);
}
if (type.equals("CI")) {
icsReceiptHeader.setVoucherType("UpdateICSRdRecord_11_Return_Confirm");
}
if (type.equals("QI")) {
icsReceiptHeader.setVoucherType("UpdateICSRdRecord_08_Confirm");
}
//入库类型为销售退货的主单和子单
if (type.equals("SRI")) {
icsReceiptHeader.setcDLCode(code);
icsReceiptHeader.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptHeader = icsReceiptHeaderService.selectModel(icsReceiptHeader);
icsReceiptHeader.setcWHCode(receiptHeader.getuWarehouseCode());
warehousewu.setuWarehouseCode(receiptHeader.getuWarehouseCode());
warehousewu.setuCompanyCode(companyWu.getuCompanyCode());
icsReceiptHeader.setcWHName(warehouseService.selectWarehouseWu(warehousewu).getuWarehouseName());
icsReceiptHeader.setVoucherType("CreateICSRdRecord_32_Return");
icsReceiptHeader.setcCode(receiptHeader.getSourceCode());
icsReceiptHeader.setID(icsReceiptHeader.getDLID());
icsReceiptHeader.setdDate(dt);
icsReceiptHeader.setcMaker(taskDetail.getLastUpdatedBy());
// icsReceiptDetail.setDLID(icsReceiptHeader.getDLID());
// icsReceiptDetail.setcWHCode(receiptHeader.getuWarehouseCode());
// icsReceiptDetail.setCompanyCode(companyWu.getuCompanyCode());
// icsReceiptDetails=icsReceiptDetailService.selectList(icsReceiptDetail);
for (ReceiptDetail item : receiptDetails) {
ICSReceiptDetail icsReceiptDetailC = new ICSReceiptDetail();
icsReceiptDetailC.setcCode(code);
icsReceiptDetailC.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptDetailC.setcInvCode(item.getMaterialCode());
icsReceiptDetailC = icsReceiptDetailService.selectModel(icsReceiptDetailC);
icsReceiptDetailC.setcCode(code);
icsReceiptDetailC.setID(icsReceiptDetailC.getDLID());
icsReceiptDetailC.setAutoID(icsReceiptDetailC.getAutoID());
icsReceiptDetailC.setiQuantity(item.getQtyCompleted());
icsReceiptDetails.add(icsReceiptDetailC);
}
// String materialName=null;
// for(ICSReceiptDetail item :icsReceiptDetails){
// item.setcCode(code);
// item.setID(item.getDLID());
// item.setAutoID(item.getAutoID());
// materialName=item.getcInvName();
// }
}
//入库类型为调拨的主单和子单
if (type.equals("TI")) {
ICSShipmentHeader icsShipmentHeader = new ICSShipmentHeader();
icsShipmentHeader.setcTVCode(code);
icsShipmentHeader.setCompanyCode(receiptHeader.getuWarehouseCode());
icsShipmentHeader = icsShipmentHeaderService.selectModel(icsShipmentHeader);
icsReceiptHeader.setcTVCode(code);
icsReceiptHeader.setiWHCode(receiptHeader.getuWarehouseCode());
icsReceiptHeader.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptHeader = icsReceiptHeaderService.selectModel(icsReceiptHeader);
icsReceiptHeader.setcCode(receiptHeader.getSourceCode());
icsReceiptHeader.setcMaker(taskDetail.getLastUpdatedBy());
icsReceiptHeader.setVoucherType("CreateICSRdRecord_0809");
icsReceiptHeader.setcWHCode(icsShipmentHeader.getoWHCode());
icsReceiptHeader.setcWHName(icsShipmentHeader.getoWHName());
for (ReceiptDetail item : receiptDetails) {
ICSReceiptDetail icsReceiptDetailD = new ICSReceiptDetail();
icsReceiptDetailD.setcCode(code);
icsReceiptDetailD.setCompanyCode(companyWu.getuCompanyCode());
icsReceiptDetailD.setcInvCode(item.getMaterialCode());
icsReceiptDetailD = icsReceiptDetailService.selectModel(icsReceiptDetailD);
icsReceiptDetailD.setiQuantity(item.getQtyCompleted());
icsReceiptDetails.add(icsReceiptDetailD);
}
}
ICSReceiptModel model = new ICSReceiptModel();
model.setIcsReceiptHeader(icsReceiptHeader);
model.setIcsReceiptDetails(icsReceiptDetails);
String JsonParam = JSON.toJSONString(model);
String result = HttpUtils.bodypost(url, JsonParam);
ajaxResult = JSON.parseObject(result, AjaxResult.class);
if (!ajaxResult.hasErr()) {
for(TaskDetail item: taskDetails) {
item.setStatus((short) 50);
taskDetailService.updateByModel(item);
}
if (receiptHeader.getFirstStatus() == 800 && receiptHeader.getLastStatus() != 800) {
receiptHeader.setUploadStatus(15);
receiptHeaderService.updateByModel(receiptHeader);
}
if (receiptHeader.getFirstStatus() == 800 && receiptHeader.getLastStatus() == 800) {
receiptHeader.setFirstStatus((short) 900);
receiptHeader.setLastStatus((short) 900);
receiptHeader.setUploadStatus(20);
receiptHeaderService.updateByModel(receiptHeader);
}
}
return ajaxResult;
}
}