TaskReceiveImpl.java
3.21 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
package com.huaheng.api.erp.server;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.support.Convert;
import com.huaheng.common.utils.StringUtils;
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.task.taskHeader.domain.TaskHeader;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderService;
import com.huaheng.pc.task.taskHeader.service.WorkTaskService;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
public class TaskReceiveImpl implements TaskReceive {
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private WorkTaskService workTaskService;
@Resource
private LocationService locationService;
@Resource
private ContainerService containerService;
@Override
public String assignTask(int taskType, String locationList, String port) {
String[] locations = locationList.split(",");
AjaxResult ajaxResult = new AjaxResult();
List<Integer> executeList= new ArrayList<>();
for(String locationCode : locations) {
String containerCode = null;
if (containerCode == null) {
if (locationCode != null) {
Location location = locationService.findLocationByCode(locationCode);
if (location != null) {
containerCode = location.getContainerCode();
}
}
}
if(StringUtils.isEmpty(port)) {
Location location = locationService.findLocationByCode(locationCode);
String road = location.getRoadway();
int roadWay = Integer.parseInt(road);
if(roadWay == 1) {
port = "P1158";
} else if(roadWay == 2) {
port = "P1139";
}
}
if (taskType == QuantityConstant.TASK_TYPE_EMPTYRECEIPT.intValue()) {
ajaxResult = workTaskService.createEmptyIn(containerCode, locationCode);
} else if (taskType == QuantityConstant.TASK_TYPE_EMPTYSHIPMENT.intValue()) {
ajaxResult = workTaskService.createEmptyOut(containerCode, locationCode);
} else if (taskType == QuantityConstant.TASK_TYPE_VIEW) {
ajaxResult = workTaskService.createEmptyCheckOut(containerCode, locationCode, port);
}
if(ajaxResult.getCode() == 400) {
return "生成任务错误" + locationCode + " " + ajaxResult.getMsg();
}
Integer id = (Integer) ajaxResult.getData();
executeList.add(id);
}
ajaxResult = taskHeaderService.sendTaskToWcs(executeList.toArray(new Integer[0]));
if(ajaxResult.getCode() == 400) {
return "执行错误" + ajaxResult.getMsg();
}
return "成功";
}
}