TaskHeaderAgvService.java
5.64 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
package com.huaheng.pc.task.taskHeader.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.DataUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService;
import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader;
import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderAGVService;
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.service.ReceiptHeaderService;
import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader;
import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService;
import com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.mapper.TaskHeaderMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class TaskHeaderAgvService extends ServiceImpl<TaskHeaderMapper, TaskHeader> {
@Resource
private ReceiptHeaderService receiptHeaderService;
@Resource
private TaskDetailService taskDetailService;
@Resource
private ReceiptContainerHeaderService receiptContainerHeaderService;
@Resource
private ShipmentContainerHeaderService shipmentContainerHeaderService;
@Resource
private CycleCountDetailService cycleCountDetailService;
@Resource
private ReceiptContainerHeaderAGVService receiptContainerHeaderAGVService;
/**
* 下发任务
* @param taskIds
* @return
*/
@Transactional
public AjaxResult sendTaskToAGV(Integer[] taskIds,String station) {
for(Integer taskId:taskIds){
TaskHeader task = this.getById(taskId);
//修改任务主表状态
task.setStatus(10);
task.setCreated(new Date()); //生成时间
task.setLastUpdated(new Date());
task.setLastUpdatedBy(ShiroUtils.getLoginName());
task.setPort(station);
if(task.getTaskType() == 100 || task.getTaskType() == 200){
ReceiptContainerHeader receiptContainerHeader =
receiptContainerHeaderService.getById(task.getAllocationHeadId());
if(receiptContainerHeader!=null){
receiptContainerHeader.setStatus(20);
receiptContainerHeaderService.updateById(receiptContainerHeader);
}
}
if(task.getTaskType() == 300 || task.getTaskType() ==400){
ShipmentContainerHeader shipmentContainerHeader =
shipmentContainerHeaderService.getById(task.getAllocationHeadId());
if(shipmentContainerHeader!= null){
shipmentContainerHeader.setStatus(20);
shipmentContainerHeaderService.updateById(shipmentContainerHeader);
}
}
this.updateById(task);
//修改任务明细状态
TaskDetail record = new TaskDetail();
record.setStatus(10);
record.setLastUpdated(new Date());
record.setLastUpdatedBy(ShiroUtils.getLoginName());
LambdaQueryWrapper<TaskDetail> detailLambdaQueryWrapper = Wrappers.lambdaQuery();
detailLambdaQueryWrapper.eq(TaskDetail::getTaskId,taskId);
taskDetailService.update(record, detailLambdaQueryWrapper);
// if(task.getFirstStatus() > 9){
// return AjaxResult.error("任务" + taskId + "已经下发,请不要重复下发,操作中止");
// }
if (task.getTaskType() == 100 || task.getTaskType() == 200)
{
List<TaskDetail> list=taskDetailService.list(detailLambdaQueryWrapper);
for (TaskDetail taskDetail : list){
taskDetail.setStatus(300);
if(taskDetail.getStatus()>=200){
taskDetailService.updateById(taskDetail);
}
}
list.stream().map(X -> X.getBillId()).distinct().forEach(billid ->
receiptContainerHeaderAGVService.receiptStatusUpdate(DataUtils.getInteger(billid),300));
}
//盘点单执行
if(task.getTaskType() == 700){
CycleCountDetail cyclecountDetai = cycleCountDetailService.getById(task.getAllocationHeadId());
cyclecountDetai.setProcessStamp("10");
cycleCountDetailService.updateById(cyclecountDetai);
}
}
return AjaxResult.success("下发任务成功");
}
}