BackInvokeService.java
4.49 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
package com.huaheng.pc.task.taskHeader.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
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.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.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service
public class BackInvokeService {
@Resource
private BackQueue backQueue;
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private ReceiptContainerDetailService receiptContainerDetailService;
@Resource
private ReceiptHeaderService receiptHeaderService;
@Resource
private ShipmentContainerDetailService shipmentContainerDetailService;
@Resource
private ShipmentHeaderService shipmentHeaderService;
public void invokeBack(int taskId){
new Thread(()->{
backQueue.receiveBack(taskId, new CallBack() {
@Override
public void back(Boolean flag, String message,Integer isReturn,Integer receiptOrShipment) {
if(flag){
//回传失败
TaskHeader taskHeader = taskHeaderService.getById(taskId);
taskHeader.setBackQty(taskHeader.getBackQty()+1);
taskHeader.setBackInfo(message);
taskHeader.setIsReturn(isReturn);
taskHeaderService.updateById(taskHeader);
Integer allocationHeadId = taskHeader.getAllocationHeadId();
if(StringUtils.isNotNull(receiptOrShipment)){
if(receiptOrShipment==1){
List<ReceiptContainerDetail> receiptContainerDetails = receiptContainerDetailService.getReceiptContainerDetailByHeaderId(allocationHeadId);
ReceiptContainerDetail receiptContainerDetail = receiptContainerDetails.get(0);
ReceiptHeader receiptHeader = receiptHeaderService.getById(receiptContainerDetail.getReceiptId());
receiptHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_RETURN);
receiptHeaderService.updateById(receiptHeader);
}else if(receiptOrShipment==2){
LambdaQueryWrapper<ShipmentContainerDetail> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(ShipmentContainerDetail::getId,allocationHeadId);
List<ShipmentContainerDetail> shipmentContainerDetails = shipmentContainerDetailService.list(queryWrapper);
ShipmentContainerDetail shipmentContainerDetail = shipmentContainerDetails.get(0);
ShipmentHeader shipmentHeader = shipmentHeaderService.getById(shipmentContainerDetail.getShipmentId());
shipmentHeader.setFirstStatus(QuantityConstant.RECEIPT_HEADER_RETURN);
shipmentHeaderService.updateById(shipmentHeader);
}
}
}else{
//回传成功
TaskHeader taskHeader = taskHeaderService.getById(taskId);
taskHeader.setBackQty(taskHeader.getBackQty()+1);
taskHeader.setBackInfo(message);
taskHeader.setIsReturn(isReturn);
taskHeaderService.updateById(taskHeader);
}
}
});
},"async-thread").start();
}
}