TaskHeaderServiceImpl.java
49.2 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
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
package com.huaheng.pc.task.taskHeader.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.utils.DataUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.inventory.inventoryHeader.domain.InventoryHeader;
import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService;
import com.huaheng.pc.inventory.inventoryTransaction.domain.InventoryTransaction;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService;
import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail;
import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService;
import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader;
import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService;
import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail;
import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService;
import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader;
import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService;
import com.huaheng.pc.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail;
import com.huaheng.pc.shipment.shipmentContainerDetail.service.ShipmentContainerDetailService;
import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.ShipmentTaskCreateModel;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.mapper.TaskHeaderMapper;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
@Service
public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHeader> implements TaskHeaderService {
@Resource
private ShipmentContainerHeaderService shipmentContainerHeaderService;
@Resource
private ShipmentContainerDetailService shipmentContainerDetailService;
@Resource
private LocationService locationService;
@Resource
private ContainerService containerService;
@Resource
private TaskDetailService taskDetailService;
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private InventoryHeaderService inventoryHeaderService;
@Resource
private InventoryDetailService inventoryDetailService;
@Resource
private InventoryTransactionService inventoryTransactionService;
@Resource
private ReceiptHeaderService receiptHeaderService;
@Resource
private ReceiptDetailService receiptDetailService;
@Resource
private ReceiptContainerDetailService receiptContainerDetailService;
@Resource
private ReceiptContainerHeaderService receiptContainerHeaderService;
@Resource
private TaskHeaderMapper taskHeaderMapper;
/**
* 查询容器有无任务
*/
@Override
public Integer UncompleteCount(String ContainerCode) {
return taskHeaderMapper.UncompleteCount(ContainerCode, ShiroUtils.getWarehouseCode());
}
/**
* 生成出库任务
*
* @param shipmentTaskCreateModel
* @return
*/
@Override
@Transactional
public AjaxResult createTaskFromShipmentContainers(ShipmentTaskCreateModel shipmentTaskCreateModel) {
Integer shipmentContainerHeaderId = shipmentTaskCreateModel.getShipmentContainerHeaderIds();
//获取表头
ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderService.getById(shipmentContainerHeaderId);
if (shipmentContainerHeader == null) {
return AjaxResult.error("出库货箱" + shipmentContainerHeaderId + "未找到,操作中止");
}
if (shipmentContainerHeader.getStatus() > 9) {
return AjaxResult.error("出库货箱" + shipmentContainerHeader.getContainerCode() + "已经生成任务,请不要重复生成,操作中止");
}
//获取所有子货箱
LambdaQueryWrapper<ShipmentContainerDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(ShipmentContainerDetail::getShippingContainerId, shipmentContainerHeader.getId());
List<ShipmentContainerDetail> shipmentContainerDetails = shipmentContainerDetailService.list(lambdaQueryWrapper);
if (shipmentContainerDetails == null || shipmentContainerDetails.size() == 0) {
return AjaxResult.error("货箱" + shipmentContainerHeader.getContainerCode() + "没有子任务,操作中止");
}
//检测库位
LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
locationLambdaQueryWrapper.eq(Location::getCode, shipmentContainerHeader.getLocationCode())
.eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(Location::getDeleted, false);
Location location = locationService.getOne(locationLambdaQueryWrapper);
if (location == null) {
return AjaxResult.error("库位禁用或不存在!");
}
//创建任务头
TaskHeader task = new TaskHeader();
//分拣出库
task.setTaskType(400);
task.setFromLocation(shipmentContainerHeader.getLocationCode());
task.setToLocation(shipmentContainerHeader.getLocationCode());
//判断是否整出任务,钱柜和AGV不能整出
if (shipmentContainerHeader.getStatus().intValue() == 300) {
//表示整出优先
//判断当前子货箱所有数量是否等于该托盘对应的所有库存的数量,
//这里必须与库存的在库数量对比,后期可能存在一个配盘在执行任务,后一个配盘又在配这个的情况(这个时候不能整出)
// 如果相等,则说明这个货箱包含了所有的数量,则可以整出,否则,创建拣选任务;
//查询所有库存
InventoryDetail inventoryCondition = new InventoryDetail();
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getLocationCode, shipmentContainerHeader.getLocationCode())
.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode());
List<InventoryDetail> inventories = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
BigDecimal inventoryTotal = new BigDecimal("0");
for (InventoryDetail item : inventories) {
inventoryTotal = inventoryTotal.add(item.getQty());
}
BigDecimal containerTotal = new BigDecimal("0");
for (ShipmentContainerDetail item : shipmentContainerDetails) {
containerTotal = containerTotal.add(item.getQty());
}
if (inventoryTotal.compareTo(containerTotal) == 0) {
task.setTaskType(300);//整盘出库
task.setToLocation("");
}
}
task.setAllocationHeadId(shipmentContainerHeader.getId());
task.setWarehouseCode(shipmentContainerHeader.getWarehouseCode());
task.setCompanyCode(shipmentContainerHeader.getCompanyCode());
task.setInternalTaskType(null);
task.setAssignedUser(ShiroUtils.getLoginName());
task.setConfirmedBy(ShiroUtils.getLoginName());
task.setStatus(0);
task.setContainerCode(shipmentContainerHeader.getContainerCode());
task.setCreatedBy(ShiroUtils.getLoginName());
task.setCreated(new Date());
task.setLastUpdatedBy(ShiroUtils.getLoginName());
task.setLastUpdated(null);
this.save(task);
//遍历子货箱创建子任务
for (ShipmentContainerDetail shipmentContainerDetail : shipmentContainerDetails) {
TaskDetail taskDetail = new TaskDetail();
taskDetail.setTaskId(task.getId());
taskDetail.setWarehouseCode(task.getWarehouseCode());
taskDetail.setCompanyCode(task.getCompanyCode());
taskDetail.setTaskType(task.getTaskType());
taskDetail.setBillCode(shipmentContainerDetail.getShipmentCode());
taskDetail.setBillDetailId(shipmentContainerDetail.getShipmentDetailId());
taskDetail.setMaterialCode(shipmentContainerDetail.getMaterialCode());
taskDetail.setMaterialName(shipmentContainerDetail.getMaterialName());
taskDetail.setMaterialSpec(shipmentContainerDetail.getMaterialSpec());
taskDetail.setMaterialUnit(shipmentContainerDetail.getMaterialUnit());
taskDetail.setFromInventoryId(shipmentContainerDetail.getInventoryId());
taskDetail.setQty(shipmentContainerDetail.getQty());
taskDetail.setContainerCode(task.getContainerCode());
taskDetail.setFromLocation(task.getFromLocation());
taskDetail.setToLocation(task.getToLocation());
taskDetail.setStatus(0);
taskDetail.setTaskType(task.getTaskType());
taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
taskDetail.setLastUpdated(null);
taskDetailService.save(taskDetail);
}
//更新货位状态
ShipmentContainerHeader record = new ShipmentContainerHeader();
record.setId(shipmentContainerHeaderId);
record.setStatus(10);
record.setStatus(task.getTaskType());//实际出库类型
shipmentContainerHeaderService.saveOrUpdate(record);
return AjaxResult.success(task.getId());
}
/**
* 下发WCS执行任务
*/
@Override
public AjaxResult<TaskHeader> sendTaskToWcs(Integer[] taskIds) {
TaskHeader task = null;
for (Integer taskId : taskIds) {
task = taskHeaderService.getById(taskId);
if (task.getStatus() > 9) {
return AjaxResult.error("任务" + taskId + "已经下发,请不要重复下发,操作中止");
}
//修改任务头表
task.setStatus(10);
task.setStartPickDateTime(new Date()); //生成时间
task.setLastUpdated(new Date());
task.setLastUpdatedBy(ShiroUtils.getLoginName());
LambdaUpdateWrapper<TaskHeader> HeaderUpdateWrapper = Wrappers.lambdaUpdate();
HeaderUpdateWrapper.eq(TaskHeader::getId, taskId);
taskHeaderService.update(task, HeaderUpdateWrapper);
//修改任务明细状态
TaskDetail record = new TaskDetail();
record.setStatus(10);
record.setLastUpdated(new Date());
record.setLastUpdatedBy(ShiroUtils.getLoginName());
LambdaUpdateWrapper<TaskDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.eq(TaskDetail::getTaskId, task.getId());
taskDetailService.update(record, lambdaUpdateWrapper);
// if (task.getInternalTaskType().equals("100"))
// {
// List<Map<String, Object>> maps = taskDetailService.selectListMapByEqual("billId, billDetailId", condition);
// for (Map<String, Object> item : maps){
// Integer billDetailId = DataUtils.getInteger(item.get("billDetailId"));
// receiptHeaderService.updateDetailStatus(billDetailId, (short)300);
// }
// maps.stream().map(X -> X.get("billId")).distinct().forEach(X -> receiptHeaderService.receiptStatusUpdate(DataUtils.getInteger(X), (short)300));
// }
// //盘点单执行
// if(task.getType() == 700){
// CyclecountDetail cyclecountDetai = cyclecountDetailService.selectEntityById(
// task.getAllocationHeadId());
// cyclecountDetai.setStatus(10);
// cyclecountDetailService.updateByModel(cyclecountDetai);
// }
//// //如果是单排人工库,那么出入库都是先完成,在下发AGV任务
//// if (task.getType().intValue() == 300 || task.getType().intValue() == 600) {
//// if (task.getSourceLocation().startsWith("L03") == false ) {
//// taskAgvService.createTaskAgv(task);
//// }
//// }
//// else {
//// taskAgvService.createTaskAgv(task);
//// }
// //任务类型是出库,那就完成任务在叫agv
// if (task.getType().intValue() == 100 || task.getType().intValue() == 500) {
// taskAgvService.createTaskAgv(task);
// }
}
return AjaxResult.success("下发任务成功", task);
}
@Override
public AjaxResult completeTaskByWMS(Integer[] taskIds) throws Exception {
for (int taskId : taskIds) {
TaskHeader task = taskHeaderService.getById(taskId);
if (task == null) {
throw new ServiceException("任务" + taskId + "未找到,执行中止");
}
//如果已完成则不管
if (task.getStatus() == 100) {
throw new ServiceException("任务(" + taskId + ")任务已经是完成的!");
}
//如果没有库位不能完成
if (StringUtils.isEmpty(task.getToLocation())) {
throw new ServiceException("任务" + taskId + "没有库位,执行中止");
}
this.completeTask(task);
}
return AjaxResult.success("完成任务成功!");
}
/**
* 完成任务
*
* @param task
* @throws Exception
*/
public void completeTask(TaskHeader task) throws Exception {
//区分任务类型
if (task.getInternalTaskType() == 100 || task.getInternalTaskType() == 200) {
//入库任务
completeReceiptTask(task);
}
if (task.getInternalTaskType() == 300 || task.getInternalTaskType() == 400) {
// //出库任务
// completeShipmentTask(task);
}
// 700 盘点 900 出库查看,包过空托出库查看
if (task.getInternalTaskType() == 700 || task.getInternalTaskType() == 900) {
completeCycleCountOrSeeOutTask(task);
}
if (task.getInternalTaskType() == 800) {
// //移库
completeTransferTask(task);
}
if (task.getInternalTaskType() == 500) {
//空托盘入库
completeEmptyIn(task);
}
if (task.getInternalTaskType() == 600) {
//空托盘出库
completeEmptyOut(task);
}
}
/**
*
*/
@Override
public AjaxResult completeReceiptTask(TaskHeader task) throws Exception {
List<Map<String, Object>> taskReceiptContainerDetail = taskHeaderMapper.getReceiptTask(task.getId());
if (taskReceiptContainerDetail.size() < 1) {
return AjaxResult.success("未找到对应任务的入库单号!!!");
}
for (Map<String, Object> map : taskReceiptContainerDetail) {
//将未完成的任务数量更新到库存表
if (DataUtils.getInteger(map.get("status")) < 100) {
LambdaQueryWrapper<InventoryDetail> inventory = Wrappers.lambdaQuery();
inventory.eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode())
.eq(InventoryDetail::getLocationCode, task.getFromLocation())
.eq(InventoryDetail::getReceiptDetailId, DataUtils.getString(map.get("receiptDetailId")))
.eq(InventoryDetail::getContainerCode, DataUtils.getString(map.get("containerCode")));
InventoryDetail detail = inventoryDetailService.getOne(inventory);
if (detail == null) {
//添加库存单
InventoryHeader header = new InventoryHeader();
header.setWarehouseCode(DataUtils.getString(map.get("warehouseCode")));//仓库
header.setCompanyCode(task.getCompanyCode());//货主
header.setContainerCode(DataUtils.getString(map.get("containerCode")));//容器号
header.setTotalQty(DataUtils.getInteger(map.get("totalQty")));//总数量
header.setLocking(1);
header.setEnable(1);
header.setCreatedBy(ShiroUtils.getLoginName());
header.setCreated(new Date());
header.setLastUpdated(new Date());
inventoryHeaderService.save(header);
//库存明细添加
detail = new InventoryDetail();
detail.setInventoryHeaderId(header.getId());//库存头ID
detail.setWarehouseCode(DataUtils.getString(map.get("warehouseCode")));//仓库
detail.setCompanyCode(task.getCompanyCode());//货主
detail.setLocationCode(task.getToLocation());//库位号
detail.setContainerCode(DataUtils.getString(map.get("containerCode")));//容器号
detail.setMaterialCode(DataUtils.getString(map.get("materialCode")));//物料号
detail.setMaterialName(DataUtils.getString(map.get("materialName")));//物料名称
detail.setMaterialSpec(DataUtils.getString(map.get("materialSpec")));//物料规格
detail.setReceiptCode(DataUtils.getString(map.get("receiptCode")));//入库单编码
detail.setReceiptDetailId(DataUtils.getInteger(map.get("receiptDetailId")));//入库单明细ID
detail.setBatch(DataUtils.getString(map.get("batch")));//批次
detail.setLot(DataUtils.getString(map.get("lot")));//批号
detail.setInventorySts(DataUtils.getString(map.get("inventorySts")));//库存状态
detail.setManufactureDate(DataUtils.getDateTime(map.get("manufactureDate")));//生产日期
detail.setExpirationDate(DataUtils.getDateTime(map.get("expirationDate")));//失效日期
detail.setQty(DataUtils.getBigDecimal(map.get("qty")));//数量
detail.setTaskQty(DataUtils.getBigDecimal(map.get("qty")));
detail.setCreatedBy(ShiroUtils.getLoginName());//创建人
detail.setLastUpdatedBy(ShiroUtils.getLoginName());//创建时间
inventoryDetailService.save(detail);
} else {
detail.setQty(detail.getQty().add(DataUtils.getBigDecimal(map.get("qty"))));
detail.setLastUpdatedBy(ShiroUtils.getLoginName());
LambdaUpdateWrapper<InventoryDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.eq(InventoryDetail::getId, DataUtils.getInteger(map.get("receiptDetailId")));
inventoryDetailService.update(detail, lambdaUpdateWrapper);
}
//记录库存交易记录
InventoryTransaction inventoryTransaction = new InventoryTransaction();
inventoryTransaction.setTransactionType(10);
inventoryTransaction.setWarehouseCode(DataUtils.getString(map.get("warehouseCode")));
inventoryTransaction.setCompanyCode(task.getCompanyCode());
inventoryTransaction.setLocationCode(task.getToLocation());
inventoryTransaction.setContainerCode(DataUtils.getString(map.get("containerCode")));
inventoryTransaction.setMaterialCode(DataUtils.getString(map.get("materialCode")));
inventoryTransaction.setMaterialName(DataUtils.getString(map.get("materialName")));
inventoryTransaction.setBillCode(DataUtils.getString(map.get("receiptCode")));
inventoryTransaction.setBillDetailId(DataUtils.getInteger(map.get("receiptDetailId")));
inventoryTransaction.setBatch(DataUtils.getString(map.get("batch")));
inventoryTransaction.setLot(DataUtils.getString(map.get("lot")));
inventoryTransaction.setManufactureDate(DataUtils.getDateTime(map.get("manufactureDate")));
inventoryTransaction.setExpirationDate(DataUtils.getDateTime(map.get("expirationDate")));
inventoryTransaction.setInventorySts(DataUtils.getString((map.get("inventorySts"))));
inventoryTransaction.setTaskQty(DataUtils.getInteger(map.get("qty")));
inventoryTransaction.setCreated(new Date());
inventoryTransaction.setCreatedBy(ShiroUtils.getLoginName());
inventoryTransactionService.save(inventoryTransaction);
//修改任务明细的状态为完成
TaskDetail taskDetail = new TaskDetail();
taskDetail.setStatus(100);
taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
taskDetail.setAgingDate(new Date()); //入库时间
LambdaUpdateWrapper<TaskDetail> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
lambdaUpdateWrapper.eq(TaskDetail::getTaskId, DataUtils.getInteger(map.get("taskDetailId")));
taskDetailService.update(taskDetail, lambdaUpdateWrapper);
//修改入库单的状态
ReceiptHeader receiptHeader = new ReceiptHeader();
receiptHeader.setFirstStatus(100);
receiptHeader.setLastStatus(100);
LambdaUpdateWrapper<ReceiptHeader> receiptHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate();
receiptHeaderLambdaUpdateWrapper.eq(ReceiptHeader::getId, DataUtils.getInteger(map.get("receiptId")));
receiptHeaderService.update(receiptHeader, receiptHeaderLambdaUpdateWrapper);
//修改任务主表状态,因为立库任务表单头只对应一个货箱,表单详情的任务会同时完成
task.setStatus(100);
task.setLastUpdatedBy(ShiroUtils.getLoginName());
task.setLastUpdated(new Date());
LambdaUpdateWrapper<TaskHeader> taskHeaderLambdaUpdateWrapper = Wrappers.lambdaUpdate();
taskHeaderLambdaUpdateWrapper.eq(TaskHeader::getId, task.getId());
taskHeaderService.update(task, taskHeaderLambdaUpdateWrapper);
//修改库位状态和对应的容器
Location location = new Location();
location.setContainerCode(task.getContainerCode());
location.setStatus("empty");
LambdaUpdateWrapper<Location> locationLambdaUpdateWrapper = Wrappers.lambdaUpdate();
locationLambdaUpdateWrapper.eq(Location::getCode, task.getToLocation());
locationService.update(location, locationLambdaUpdateWrapper);
//修改容器状态和对应的库位
Container container = new Container();
container.setLocationCode(task.getToLocation());
container.setStatus("some");
//修改组盘表状态为20
ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail();
receiptContainerDetail.setStatus(20);
LambdaUpdateWrapper<ReceiptContainerDetail> receiptContainerDetailLambdaUpdateWrapper = Wrappers.lambdaUpdate();
receiptContainerDetailLambdaUpdateWrapper.eq(ReceiptContainerDetail::getReceiptId, DataUtils.getInteger(map.get("receiptId")));
receiptContainerDetailService.update(receiptContainerDetail, receiptContainerDetailLambdaUpdateWrapper);
}
}
return AjaxResult.success("完成入库任务");
}
// @Override
// public List<Map<String, Object>> getReceiptTask(Integer taskId) {
// return taskHeaderMapper.getReceiptTask(taskId) ;
// }
/**
* 生成
* 立库移库
*/
@Transactional
public AjaxResult createTransferTask(String sourceLocation, String destinationLocation) {
//源库位校验
Location temp1 = new Location();
temp1.setCode(sourceLocation);
temp1.setWarehouseCode(ShiroUtils.getWarehouseCode());
LambdaQueryWrapper<Location> lambda1 = Wrappers.lambdaQuery();
Location loc1 = locationService.getOne(lambda1);
if (loc1 == null) {
return AjaxResult.error("源库位:" + sourceLocation + "未找到");
}
if (!loc1.getStatus().equals("empty")) {
return AjaxResult.error("源库位:" + sourceLocation + "状态非空闲");
}
if (StringUtils.isEmpty(loc1.getContainerCode())) {
return AjaxResult.error("源库位:" + sourceLocation + "不存在托盘");
}
//这里增加组盘校验,如果此托盘存在未完成的组盘数据,则不能移库
//校验入库组盘
int count1 = inventoryHeaderService.getUncompleteReceiptContainer(sourceLocation, ShiroUtils.getWarehouseCode());
if (count1 > 0) {
return AjaxResult.error("源库位:" + sourceLocation + "存在入库组盘,不能移库");
}
int count2 = inventoryHeaderService.getUncompleteShipmentContainer(sourceLocation, ShiroUtils.getWarehouseCode());
if (count2 > 0) {
return AjaxResult.error("源库位:" + sourceLocation + "存在出库组盘,不能移库");
}
//目的库位校验
Location temp2 = new Location();
temp2.setWarehouseCode(ShiroUtils.getWarehouseCode());
temp2.setCode(destinationLocation);
LambdaQueryWrapper<Location> lambdaQueryWrapper2 = Wrappers.lambdaQuery(temp2);
Location loc2 = locationService.getOne(lambdaQueryWrapper2);
if (loc2 == null) {
return AjaxResult.error("目标库位:" + destinationLocation + "未找到");
}
if (!loc2.getStatus().equals("empty")) {
return AjaxResult.error("目标库位:" + destinationLocation + "状态非空闲");
}
if (StringUtils.isNotEmpty(loc2.getContainerCode())) {
return AjaxResult.error("目标库位:" + destinationLocation + "已存在托盘");
}
int count3 = inventoryHeaderService.getUncompleteReceiptContainer(destinationLocation, ShiroUtils.getWarehouseCode());
if (count3 > 0) {
return AjaxResult.error("目标库位:" + sourceLocation + "存在入库组盘,不能移库");
}
//写入任务主表和明细表
TaskHeader taskHeader = new TaskHeader();
taskHeader.setWarehouseCode(ShiroUtils.getWarehouseCode());
taskHeader.setCompanyCode(ShiroUtils.getCompanyCodeList().get(0));//获取第一个货主
taskHeader.setInternalTaskType(500);
taskHeader.setTaskType(800);
taskHeader.setContainerCode(loc1.getContainerCode());
taskHeader.setStatus(1);
taskHeader.setFromLocation(sourceLocation);
taskHeader.setToLocation(destinationLocation);
taskHeader.setCreated(new Date());
taskHeader.setCreatedBy(ShiroUtils.getLoginName());
taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
taskHeader.setLastUpdated(new Date());
taskHeaderMapper.insert(taskHeader);
//写入明细表
TaskDetail taskDetail = new TaskDetail();
taskDetail.setTaskId(taskHeader.getId());//主单ID
taskDetail.setTaskType(taskHeader.getTaskType());
taskDetail.setInternalTaskType(taskHeader.getTaskType());
taskDetail.setWarehouseCode(taskHeader.getWarehouseCode());
taskDetail.setCompanyCode(taskDetail.getCompanyCode());
taskDetail.setFromLocation(sourceLocation);
taskDetail.setToLocation(destinationLocation);
taskDetail.setContainerCode(taskHeader.getContainerCode());
taskDetail.setCreated(new Date());
taskDetail.setCreatedBy(ShiroUtils.getLoginName());
taskDetail.setLastUpdated(new Date());
taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
taskDetailService.save(taskDetail);
//更新货位状态为预定
loc1.setStatus("lock");
loc2.setStatus("lock");
locationService.saveOrUpdate(loc1);
locationService.saveOrUpdate(loc2);
return AjaxResult.success(taskHeader.getId());
}
/**
* 完成移库任务
*
* @param task
*/
private void completeTransferTask(TaskHeader task) {
//找到任务明细
TaskDetail taskDetail = new TaskDetail();
taskDetail.setTaskId(task.getId());
taskDetail.setWarehouseCode(task.getWarehouseCode());
taskDetail.setCompanyCode(task.getCompanyCode());
taskDetail.setContainerCode(task.getContainerCode());
LambdaQueryWrapper<TaskDetail> taskDetailLW = Wrappers.lambdaQuery(taskDetail);
taskDetail = taskDetailService.getOne(taskDetailLW);
//更新库存主表和明细的库位,更改更新用户和时间
InventoryHeader inventoryHeader = new InventoryHeader();
//主表
inventoryHeader.setWarehouseCode(taskDetail.getWarehouseCode());
inventoryHeader.setCompanyCode(taskDetail.getCompanyCode());
inventoryHeader.setContainerCode(taskDetail.getContainerCode());
inventoryHeader.setLocationCode(taskDetail.getFromLocation());//通过源库位查找库存
LambdaQueryWrapper<InventoryHeader> inventoryHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(inventoryHeader);
inventoryHeader = inventoryHeaderService.getOne(inventoryHeaderLambdaQueryWrapper);
inventoryHeader.setLocationCode(taskDetail.getToLocation());//把目的库位写入库存
inventoryHeader.setLastUpdated(new Date());
inventoryHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
inventoryHeaderService.saveOrUpdate(inventoryHeader);//修改主表库位
//明细表
List<InventoryDetail> inventoryDetails = new ArrayList<>();
InventoryDetail inventoryDetail = new InventoryDetail();
inventoryDetail.setWarehouseCode(inventoryHeader.getWarehouseCode());
inventoryDetail.setCompanyCode(inventoryHeader.getCompanyCode());
inventoryDetail.setInventoryHeaderId(inventoryHeader.getId());
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery(inventoryDetail);
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
/*同时写入库存交易表*/
List<InventoryTransaction> inventoryTransactionList = new ArrayList<>();
for (InventoryDetail item : inventoryDetailList) {
item.setLocationCode(inventoryHeader.getLocationCode());//修改明细表库位
item.setLastUpdated(new Date());
item.setLastUpdatedBy(ShiroUtils.getLoginName());
inventoryDetails.add(item);
/*----------*/
InventoryTransaction inventoryTransaction = new InventoryTransaction();
inventoryTransaction.setWarehouseCode(task.getWarehouseCode());
inventoryTransaction.setLocationCode(taskDetail.getToLocation());
inventoryTransaction.setContainerCode(taskDetail.getContainerCode());
inventoryTransaction.setTransactionType(50);
inventoryTransaction.setMaterialCode(item.getMaterialCode());
inventoryTransaction.setManufactureDate(item.getManufactureDate());
inventoryTransaction.setMaterialName(item.getMaterialName());
inventoryTransaction.setMaterialSpec(item.getMaterialSpec());
inventoryTransaction.setMaterialUnit(item.getMaterialUnit());
inventoryTransaction.setTaskQty(0);
inventoryTransaction.setInventorySts(item.getInventorySts());
//inventoryTransaction.setReferCode();
//inventoryTransaction.setQcCheck();
inventoryTransaction.setReferDetailId(item.getId().toString());
inventoryTransaction.setBatch(item.getBatch());
inventoryTransaction.setLot(item.getLot());
inventoryTransaction.setProjectNo(item.getProjectNo());
inventoryTransaction.setWeight(item.getWeight());
inventoryTransaction.setManufactureDate(item.getManufactureDate());
inventoryTransaction.setExpirationDate(item.getExpirationDate());
inventoryTransaction.setAgingDate(item.getCreated());
inventoryTransaction.setAttributeId(item.getAttributeId());
inventoryTransaction.setAttribute1(item.getAttribute1());
inventoryTransaction.setAttribute2(item.getAttribute2());
inventoryTransaction.setAttribute3(item.getAttribute3());
inventoryTransaction.setCreated(new Date());
inventoryTransaction.setCreatedBy(ShiroUtils.getLoginName());
//inventoryTransaction.setLockCode();
inventoryTransaction.setBillCode(item.getInventoryHeaderId().toString());
inventoryTransaction.setBillDetailId(item.getId());
inventoryTransaction.setSupplierCode(item.getSupplierCode());
inventoryDetailList.add(inventoryDetail);
}
if (inventoryDetailService.saveOrUpdateBatch(inventoryDetails)) {
//更新库存明细成功后,写入库存交易
inventoryTransactionService.saveBatch(inventoryTransactionList);
} else {
throw new ServiceException("库存明细更新错误!");
}
//更新托盘、库位状态
Location temp1 = new Location(); //源库位
temp1.setCode(taskDetail.getFromLocation());
temp1.setWarehouseCode(ShiroUtils.getWarehouseCode());
LambdaQueryWrapper<Location> lambdaQueryWrapper1 = Wrappers.lambdaQuery(temp1);
Location loc1 = locationService.getOne(lambdaQueryWrapper1);
Location temp2 = new Location();//目的库位
temp2.setCode(taskDetail.getToLocation());
temp2.setWarehouseCode(ShiroUtils.getWarehouseCode());
LambdaQueryWrapper<Location> lambdaQueryWrapper2 = Wrappers.lambdaQuery(temp2);
Location loc2 = locationService.getOne(lambdaQueryWrapper2);
loc2.setContainerCode(loc1.getContainerCode());
loc2.setStatus("empty");
loc1.setContainerCode("");
loc1.setStatus("empty");
locationService.saveOrUpdate(loc1);
locationService.saveOrUpdate(loc2);
//更新taskHeader状态
task.setStatus(100);
task.setLastUpdatedBy(ShiroUtils.getLoginName());
task.setLastUpdated(new Date());
taskHeaderService.saveOrUpdate(task);
//更新taskDetail状态
taskDetail.setStatus(100);
taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
taskDetail.setLastUpdated(new Date());
taskDetailService.saveOrUpdate(taskDetail);
}
/**
* 生成
* 出库查看
* 任务
*/
@Override
@Transactional
public AjaxResult createCheckOutTask(String[] ids) {
for (String id : ids) {
InventoryHeader inventoryHeader = inventoryHeaderService.getById(Integer.parseInt(id));
//检查库位容器
Location temp = new Location();
temp.setCode(inventoryHeader.getLocationCode());
temp.setWarehouseCode(inventoryHeader.getWarehouseCode());
LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery(temp);
Location loc = locationService.getOne(lambdaQueryWrapper);
if (loc == null) {
throw new ServiceException("库存没有库位!");
}
if (!loc.getStatus().equals("empty")) {
throw new ServiceException(inventoryHeader.getLocationCode() + "状态非空闲,操作失败");
}
if (StringUtils.isEmpty(loc.getContainerCode())) {
throw new ServiceException(inventoryHeader.getLocationCode() + "没有容器,操作失败");
}
//通过库存头,找到库存明细
InventoryDetail inventoryDetail = new InventoryDetail();
inventoryDetail.setWarehouseCode(inventoryHeader.getWarehouseCode());
inventoryDetail.setCompanyCode(inventoryHeader.getCompanyCode());
inventoryDetail.setInventoryHeaderId(inventoryHeader.getId());
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery(inventoryDetail);
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
//写入任务主表
TaskHeader taskHeader = new TaskHeader();
taskHeader.setWarehouseCode(inventoryHeader.getWarehouseCode());
taskHeader.setCompanyCode(inventoryHeader.getCompanyCode());//货主
taskHeader.setInternalTaskType(200);
taskHeader.setTaskType(900);
taskHeader.setContainerCode(inventoryHeader.getContainerCode());
taskHeader.setStatus(1);
taskHeader.setFromLocation(inventoryHeader.getLocationCode());
taskHeader.setToLocation(inventoryHeader.getLocationCode());
taskHeader.setCreated(new Date());
taskHeader.setCreatedBy(ShiroUtils.getLoginName());
taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
taskHeader.setLastUpdated(new Date());
taskHeaderMapper.insert(taskHeader);
//分拆库存明细,并写入任务细表
List<TaskDetail> taskDetails = new ArrayList<>();
for (InventoryDetail item : inventoryDetailList) {
TaskDetail taskDetail = new TaskDetail();
taskDetail.setTaskId(taskHeader.getId());//主单ID
taskDetail.setTaskType(taskHeader.getTaskType());
taskDetail.setInternalTaskType(taskHeader.getTaskType());
taskDetail.setWarehouseCode(taskHeader.getWarehouseCode());
taskDetail.setCompanyCode(item.getCompanyCode());
taskDetail.setFromLocation(taskHeader.getFromLocation());
taskDetail.setToLocation(taskHeader.getToLocation());
taskDetail.setContainerCode(taskHeader.getContainerCode());
taskDetail.setCreated(new Date());
taskDetail.setCreatedBy(ShiroUtils.getLoginName());
taskDetail.setLastUpdated(new Date());
taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
taskDetails.add(taskDetail);
}
if (taskDetailService.saveBatch(taskDetails)) {
//锁定库位状态
locationService.updateStatus(loc.getContainerCode(), "lock");
} else {
throw new ServiceException("出库查看任务明细生成失败!");
}
}
return AjaxResult.success("出库查看任务生成成功!");
}
/**
* 完成
* 盘点,出库查看
* 更新状态即可
*/
@Transactional
@Override
public AjaxResult completeCycleCountOrSeeOutTask(TaskHeader taskHeader) {
taskHeader.setStatus(100);
taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName()); //更新用户
taskHeader.setLastUpdated(new Date()); //更新时间
//task更新明细单总的状态
TaskDetail taskDetail = new TaskDetail();
taskDetail.setWarehouseCode(taskHeader.getWarehouseCode());
taskDetail.setTaskType(taskHeader.getTaskType());
taskDetail.setTaskId(taskHeader.getId());
LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(taskDetail);
List<TaskDetail> taskDetailList = taskDetailService.list(lambdaQueryWrapper);//查询子单
for (TaskDetail item : taskDetailList) {
item.setStatus(100);
item.setLastUpdatedBy(ShiroUtils.getLoginName()); //更新用户
item.setLastUpdated(new Date()); //更新时间
taskDetailList.add(item);
}
if (taskDetailService.saveOrUpdateBatch(taskDetailList) == false || taskHeaderService.saveOrUpdate(taskHeader) == false) {
throw new ServiceException("任务单据状态更新失败!");
}
//盘点完成时,修改盘点详细中的状态为100,容器恢复为空
if (taskHeader.getTaskType() == 700) {
/*CyclecountDetail cyclecountDetai = cyclecountDetailService.selectEntityById(
task.getAllocationHeadId());
cyclecountDetai.setStatus(40);
cyclecountDetailService.updateByModel(cyclecountDetai);
containerService.updateStatus(task.getContainerCode(),"empty");*/
}
//释放库位状态
locationService.updateStatus(taskHeader.getFromLocation(), "empty");
return AjaxResult.success("完成出库查看任务");
}
/**
* 完成空托盘入库任务
* @param taskHeader
*/
@Transactional
public void completeEmptyIn(TaskHeader taskHeader) {
//解锁容器,更新库位
containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(),taskHeader.getToLocation(),"empty");
//解锁库位,更新容器
locationService.updateContainerCodeAndStatus(taskHeader.getToLocation(),taskHeader.getContainerCode(),"empty");
//完成任务,修改主单和明细状态
taskHeader.setStatus(100);
taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
taskHeader.setLastUpdated(new Date());
//taskHeaderService.saveOrUpdate(taskHeader);
//taskDetail更新明细单总的状态
TaskDetail taskDetail = new TaskDetail();
taskDetail.setWarehouseCode(taskHeader.getWarehouseCode());
taskDetail.setTaskType(taskHeader.getTaskType());
taskDetail.setTaskId(taskHeader.getId());
LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(taskDetail);
List<TaskDetail> taskDetailList = taskDetailService.list(lambdaQueryWrapper);//查询子单
for (TaskDetail item : taskDetailList) {
item.setStatus(100);
item.setLastUpdatedBy(ShiroUtils.getLoginName()); //更新用户
item.setLastUpdated(new Date()); //更新时间
taskDetailList.add(item);
}
if (taskDetailService.saveOrUpdateBatch(taskDetailList) == false || taskHeaderService.saveOrUpdate(taskHeader) == false) {
throw new ServiceException("任务单据状态更新失败!");
}
}
/**
* 完成空托盘出库任务
* @param taskHeader
*/
@Transactional
public void completeEmptyOut(TaskHeader taskHeader) {
//更新货位
locationService.updateContainerCodeAndStatus(taskHeader.getFromLocation(), "", "empty");
//更新容器信息
containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(), "", "empty");
taskHeader.setStatus(100);
taskHeader.setLastUpdatedBy(ShiroUtils.getLoginName());
taskHeader.setLastUpdated(new Date());
//taskHeaderService.saveOrUpdate(taskHeader);
//taskDetail更新明细单总的状态
TaskDetail taskDetail = new TaskDetail();
taskDetail.setWarehouseCode(taskHeader.getWarehouseCode());
taskDetail.setTaskType(taskHeader.getTaskType());
taskDetail.setTaskId(taskHeader.getId());
LambdaQueryWrapper lambdaQueryWrapper = Wrappers.lambdaQuery(taskDetail);
List<TaskDetail> taskDetailList = taskDetailService.list(lambdaQueryWrapper);//查询子单
for (TaskDetail item : taskDetailList) {
item.setStatus(100);
item.setLastUpdatedBy(ShiroUtils.getLoginName()); //更新用户
item.setLastUpdated(new Date()); //更新时间
taskDetailList.add(item);
}
if (taskDetailService.saveOrUpdateBatch(taskDetailList) == false || taskHeaderService.saveOrUpdate(taskHeader) == false) {
throw new ServiceException("任务单据状态更新失败!");
}
}
/**
* 创建上架任务
*
* @param ids
* @return
*/
@Override
@Transactional
public AjaxResult createReceiptTask(List<Integer> ids) {
for (Integer id : ids) {
ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(id);
if (receiptContainerHeader == null)
throw new ServiceException("任务不存在!");
if (!receiptContainerHeader.getWarehouseCode().equals(ShiroUtils.getWarehouseCode()))
throw new ServiceException("任务不在当前仓库!");
LambdaQueryWrapper<ReceiptContainerDetail> containerDetailLambda = Wrappers.lambdaQuery();
containerDetailLambda.eq(ReceiptContainerDetail::getReceiptId, id);
List<ReceiptContainerDetail> list = receiptContainerDetailService.list(containerDetailLambda);
if (list.size() < 1)
throw new ServiceException("没有组盘明细,请先组盘!");
if (receiptContainerHeader.getStatus() == 0) {
if (receiptContainerHeader.getStatus().intValue() < 10) {
receiptContainerHeader.setStatus((short) 10);
receiptContainerHeaderService.updateById(receiptContainerHeader);
}
//添加任务主表
TaskHeader task = new TaskHeader();
task.setInternalTaskType(100);
task.setWarehouseCode(receiptContainerHeader.getWarehouseCode());
task.setCompanyCode(receiptContainerHeader.getCompanyCode());
task.setFromLocation(receiptContainerHeader.getFromLocation());
task.setTaskType(Integer.valueOf(receiptContainerHeader.getTaskType()));
task.setFromLocation(receiptContainerHeader.getFromLocation());
task.setToLocation(receiptContainerHeader.getToLocation());
task.setContainerCode(receiptContainerHeader.getContainerCode());
task.setCreated(new Date());
task.setCreatedBy(ShiroUtils.getLoginName());
if (this.save(task)){
//添加任务明细表
for(ReceiptContainerDetail item : list) {
TaskDetail taskDetail = new TaskDetail();
taskDetail.setTaskId(task.getId());
taskDetail.setTaskType(Integer.valueOf(receiptContainerHeaderService.getById(item.getReceiptId()).getTaskType()));
taskDetail.setInternalTaskType(100);
taskDetail.setWarehouseCode(task.getWarehouseCode());
taskDetail.setCompanyCode(task.getCompanyCode());
taskDetail.setCompanyCode(task.getCompanyCode());
taskDetail.setMaterialCode(item.getMaterialCode());
taskDetail.setMaterialName(item.getMaterialName());
taskDetail.setBillCode(item.getReceiptCode());
taskDetail.setBillDetailId(item.getReceiptDetailId());
taskDetail.setBillCode(item.getReceiptCode());
taskDetail.setQty(BigDecimal.valueOf(item.getQty()));
taskDetail.setContainerCode(task.getContainerCode());
taskDetail.setFromLocation(task.getFromLocation());
taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName());
taskDetail.setBatch(item.getBatch());
if (!taskDetailService.save(taskDetail)){
throw new ServiceException("生成任务明细失败");
}
//更新入库组盘明细状态
item.setStatus(10);
receiptContainerDetailService.updateById(item);
ReceiptDetail receiptDetail = receiptDetailService.getById(item.getReceiptDetailId());
if ("300".equals(receiptDetail.getProcessStamp())){
ReceiptDetail detail = receiptDetailService.queryflow(receiptDetail);
if (!receiptDetailService.updateById(detail)){
throw new ServiceException("更新入库单详情失败");
}
receiptDetailService.updateReceiptHeaderLastStatus(receiptDetail.getReceiptId());
}
}
} else {
throw new ServiceException("生成任务头表失败");
}
}
}
return AjaxResult.success("生成上架任务成功!");
}
}