TaskHeaderSiXiangCheService.java
12.6 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
package com.huaheng.pc.task.taskHeader.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.huaheng.api.SSP.service.OrderAssignApiService;
import com.huaheng.api.acs.domain.AgvTaskCS;
import com.huaheng.api.acs.service.AcsService;
import com.huaheng.api.acs.service.AgvTaskCSCreateService;
import com.huaheng.api.acs.service.AgvTaskCSService;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.api.wcs.service.taskAssignService.TaskAssignService;
import com.huaheng.api.wcs.service.taskCancel.TaskCancelService;
import com.huaheng.common.constant.HttpConstant;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.Assert;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.common.utils.Wrappers;
import com.huaheng.common.utils.restful.RestUtil;
import com.huaheng.common.utils.security.ShiroUtils;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.pc.config.address.service.AddressService;
import com.huaheng.pc.config.company.domain.Company;
import com.huaheng.pc.config.company.service.CompanyService;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.containerType.domain.ContainerType;
import com.huaheng.pc.config.containerType.service.ContainerTypeService;
import com.huaheng.pc.config.cycleCountPreference.domain.CycleCountPreference;
import com.huaheng.pc.config.cycleCountPreference.service.CycleCountPreferenceService;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.service.LocationService;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.station.domain.Station;
import com.huaheng.pc.config.station.service.StationService;
import com.huaheng.pc.inventory.cycleCountDetail.domain.CycleCountDetail;
import com.huaheng.pc.inventory.cycleCountDetail.service.CycleCountDetailService;
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.inventoryHeader.service.InventoryTransferService;
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.shipmentContainerAdvice.service.ShipmentContainerAdviceService;
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.shipmentDetail.domain.ShipmentDetail;
import com.huaheng.pc.shipment.shipmentDetail.service.ShipmentDetailService;
import com.huaheng.pc.shipment.shipmentHeader.domain.ShipmentHeader;
import com.huaheng.pc.shipment.shipmentHeader.service.ShipmentHeaderService;
import com.huaheng.pc.system.dict.service.IDictDataService;
import com.huaheng.pc.task.taskDetail.domain.TaskDetail;
import com.huaheng.pc.task.taskDetail.service.TaskDetailService;
import com.huaheng.pc.task.taskHeader.domain.MobileTask;
import com.huaheng.pc.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.mapper.TaskHeaderMapper;
import javafx.concurrent.Task;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.ui.ModelMap;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class TaskHeaderSiXiangCheService extends ServiceImpl<TaskHeaderMapper, TaskHeader> {
private static final Logger logger = LoggerFactory.getLogger(TaskHeaderSiXiangCheService.class);
@Resource
private StationService stationService;
@Resource
private TaskHeaderService taskHeaderService;
/**
* 第一段任务
* @param taskHeader
* @return
*/
public TaskHeader siXiangCheTask(TaskHeader taskHeader) {
//lkPort是立库站台,taskHeader.setPort是四向车站台
String lkPort=taskHeader.getPort();
TaskHeader task=new TaskHeader();
TaskHeader task2=new TaskHeader();
switch (taskHeader.getTaskType()){
case QuantityConstant.TASK_TYPE_WHOLERECEIPT:
case QuantityConstant.TASK_TYPE_EMPTYRECEIPT:
taskHeader.setPort(QuantityConstant.FOUR_WHEEL_RECEIPT_PORT);
taskHeader.setToPort(lkPort);
//生成换站任务;
task=saveTaskSiXiangCheOne(taskHeader);
if(task!=null){
//入库任务的前置任务时换站任务
taskHeader.setPreTaskNo(task.getId());
task2 = new TaskHeader();
task2.setPreTaskNo(task.getId());
task2.setId(taskHeader.getId());
if(!taskHeaderService.updateById(task2)){
throw new ServiceException("任务下发,设置前置任务失败");
}
}
break;
case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT:
case QuantityConstant.TASK_TYPE_WHOLESHIPMENT:
taskHeader.setPort(QuantityConstant.FOUR_WHEEL_SHIPMENT_PORT);
taskHeader.setToPort(lkPort);
//生成换站任务;
task= saveTaskSiXiangCheOne(taskHeader);
if(task!=null){
//出库任务,换站任务的前置任务是出库任务
task2 = new TaskHeader();
task2.setId(task.getId());
task2.setPreTaskNo(taskHeader.getId());
if(!taskHeaderService.updateById(task2)){
throw new ServiceException("任务下发,设置前置任务失败");
}
}
break;
case QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT:
case QuantityConstant.TASK_TYPE_SORTINGSHIPMENT:
case QuantityConstant.TASK_TYPE_VIEW:
taskHeader.setPort(QuantityConstant.FOUR_WHEEL_SHIPMENT_PORT);
taskHeader.setToPort(lkPort);
//生成出库的换站任务;
task= saveTaskSiXiangCheOne(taskHeader);
if(task!=null){
//设置前置任务,第一个taskheader,第2个task,第3个Task2
TaskHeader task3 = new TaskHeader();
task3.setId(task.getId());
task3.setPreTaskNo(taskHeader.getId());
if(!taskHeaderService.updateById(task3)){
throw new ServiceException("任务下发,设置前置任务失败");
}
//生成回库的换站任务;
task2 = saveTaskSiXiangCheTwo(taskHeader);
TaskHeader task4 = new TaskHeader();
task4.setId(task2.getId());
task4.setPreTaskNo(task.getId());
if(!taskHeaderService.updateById(task4)){
throw new ServiceException("任务下发,设置前置任务失败");
}
}
break;
default:
break;
}
return taskHeader;
}
/**
* 四向车库第1段换站任务
* @param taskHeader
* @return
*/
public TaskHeader saveTaskSiXiangCheOne(TaskHeader taskHeader) {
String lkport=taskHeader.getToPort();
TaskHeader task = new TaskHeader();
task.setWarehouseCode(taskHeader.getWarehouseCode());
task.setZoneCode(QuantityConstant.ZONE_CODE_TYPE_LK);
task.setCompanyCode(taskHeader.getCompanyCode());
task.setContainerCode(taskHeader.getContainerCode());
task.setTaskType(QuantityConstant.TASK_TYPE_OVER_STATION);
switch (taskHeader.getTaskType()) {
case QuantityConstant.TASK_TYPE_WHOLERECEIPT:
case QuantityConstant.TASK_TYPE_EMPTYRECEIPT:
task.setFromLocation(lkport);
task.setToLocation(taskHeader.getPort());
break;
case QuantityConstant.TASK_TYPE_WHOLESHIPMENT:
case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT:
case QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT:
case QuantityConstant.TASK_TYPE_SORTINGSHIPMENT:
case QuantityConstant.TASK_TYPE_VIEW:
task.setFromLocation(taskHeader.getPort());
task.setToLocation(lkport);
break;
}
if(task.getFromLocation().equals(task.getToLocation())){
return null;
}
//有任务则不重复生成
TaskHeader taskNew=this.checkTranskTask(task);
if(taskNew != null){
return null;
}
if(!taskHeaderService.save( task)){
throw new ServiceException("生成换站任务失败");
}
return task;
}
/**
*
* 四向车库第2段换站任务
* @param taskHeader
* @return
*/
public TaskHeader saveTaskSiXiangCheTwo(TaskHeader taskHeader) {
String lkport=taskHeader.getToPort();
TaskHeader task = new TaskHeader();
task.setWarehouseCode(taskHeader.getWarehouseCode());
task.setZoneCode(QuantityConstant.ZONE_CODE_TYPE_LK);
task.setCompanyCode(taskHeader.getCompanyCode());
task.setContainerCode(taskHeader.getContainerCode());
task.setTaskType(QuantityConstant.TASK_TYPE_OVER_STATION);
switch (taskHeader.getTaskType()) {
case QuantityConstant.TASK_TYPE_WHOLERECEIPT:
case QuantityConstant.TASK_TYPE_EMPTYRECEIPT:
case QuantityConstant.TASK_TYPE_WHOLESHIPMENT:
case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT:
break;
case QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT:
case QuantityConstant.TASK_TYPE_SORTINGSHIPMENT:
case QuantityConstant.TASK_TYPE_VIEW:
//回库的换站任务
task.setFromLocation(lkport);
task.setToLocation(taskHeader.getPort());
break;
}
TaskHeader taskNew=this.checkTranskTask(task);
if(taskNew != null){
return taskNew;
}
if(!taskHeaderService.save( task)){
throw new ServiceException("生成换站任务失败");
}
return task;
}
public TaskHeader checkTranskTask(TaskHeader task){
//有任务则不重复生成
LambdaQueryWrapper<TaskHeader> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(TaskHeader::getContainerCode,task.getContainerCode())
.eq(TaskHeader::getTaskType,task.getTaskType())
.eq(TaskHeader::getFromLocation,task.getFromLocation())
.eq(TaskHeader::getToLocation,task.getToLocation());
queryWrapper.eq(TaskHeader::getWarehouseCode,task.getWarehouseCode());
queryWrapper.eq(TaskHeader::getZoneCode,task.getZoneCode());
queryWrapper.lt(TaskHeader::getStatus,QuantityConstant.TASK_STATUS_COMPLETED);
List<TaskHeader> list=taskHeaderService.list(queryWrapper);
if(list.size()>0){
return list.get(0);
}
return null;
}
}