TvControllerV1.java
7.48 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
package com.huaheng.api.tv.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.huaheng.api.acs.domain.AgvTaskCS;
import com.huaheng.api.acs.service.AgvTaskCSService;
import com.huaheng.api.tv.domain.TvForJLKTaskResponse;
import com.huaheng.api.tv.domain.TvRequstDomain;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.*;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
import com.huaheng.mobile.task.TaskDomain;
import com.huaheng.pc.config.container.domain.Container;
import com.huaheng.pc.config.container.service.ContainerService;
import com.huaheng.pc.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
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.service.TaskHeaderService;
import com.huaheng.pc.task.taskHeader.service.TaskHeaderTvService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
/**
* @ClassName TVController
* @Description TODO
* @Author Administrator
* @Date 2020/2/2217:16
*/
@RestController
@RequestMapping("/api/TV")
@Api(tags = {"TV"}, description = "TV接口")
public class TvControllerV1 extends BaseController {
@Resource
private MaterialService materialService;
@Resource
private TaskHeaderTvService taskHeaderTvService;
@Resource
private TaskDetailService taskDetailService;
@Resource
private ContainerService containerService;
@Resource
private AgvTaskCSService agvTaskCSService;
@PostMapping("/gettvView")
public AjaxResult<List<TaskDomain>> getTvView(String port){
List<TaskDomain> taskDomainList = new ArrayList<>();
//port多个站台用,分隔,查出所有头表
List<TaskHeader> taskList = new ArrayList<>();
for(String p : port.split(",")) {
List<TaskHeader> tmpTaskList = taskHeaderTvService.getTaskByTvPort(p);
taskList.addAll(tmpTaskList);
}
for(TaskHeader task : taskList){
TaskDomain taskDomain = new TaskDomain();
List<TaskDetail> taskDetails = taskDetailService.findByTaskId(task.getId());
taskDomain.setTaskHeader(task);
checkSpec(taskDetails);
taskDomain.setTaskDetails(taskDetails);
taskDomainList.add(taskDomain);
}
taskDomainList.sort(new Comparator<TaskDomain>() {
@Override
public int compare(TaskDomain o1, TaskDomain o2) {
TaskHeader task1 = o1.getTaskHeader();
TaskHeader task2 = o2.getTaskHeader();
int ret = task2.getStatus() - task1.getStatus();
if(ret == 0){
ret = (int) (task2.getLastUpdated().getTime() - task1.getLastUpdated().getTime());
}
return ret;
}
});
return AjaxResult.success(taskDomainList);
}
/**
* 查检任务明细中是否有规格型号,没有的话主动查一下
* @param taskDetails
*/
public void checkSpec(List<TaskDetail> taskDetails){
try {
for (TaskDetail detail : taskDetails) {
if (StringUtils.isEmpty(detail.getMaterialSpec())) {
Material material = materialService.getMaterialByCode(detail.getMaterialCode());
detail.setMaterialSpec(material.getSpec());
}
}
}catch (Exception e){
}
}
@PostMapping("/getStatusByContainer")
public AjaxResult getStatusByContainer(String containerCode,String warehouseCode){
Container container=containerService.getContainerByCode(containerCode,warehouseCode);
if(container==null){
return AjaxResult.error("未找到对应的容器");
}
return AjaxResult.success().setData(container.getStatus());
}
/**
* 用仓库,库区查询该库区当前立库任务
* @return
*/
@PostMapping("/taskNow")
public AjaxResult taskNow(@RequestBody TvRequstDomain domain){
if(StringUtils.isEmpty(domain.getZoneCode())||StringUtils.isEmpty(domain.getWarehouseCode())){
return AjaxResult.error("传参:库区zoneCode或仓库warehouseCode为空");
}
String zoneCode=domain.getZoneCode();
String warehouseCode=domain.getWarehouseCode();
LambdaQueryWrapper<TaskHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(TaskHeader::getZoneCode, zoneCode);
lambdaQueryWrapper.eq(TaskHeader::getWarehouseCode,warehouseCode);
lambdaQueryWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
lambdaQueryWrapper.ne(TaskHeader::getTaskType,QuantityConstant.TASK_TYPE_OVER_STATION);
lambdaQueryWrapper.orderByDesc(TaskHeader::getStatus);
List<TaskHeader> list= taskHeaderTvService.list(lambdaQueryWrapper);
List<TvForJLKTaskResponse> resultlist=new ArrayList<>();
for(TaskHeader task:list){
TvForJLKTaskResponse taskResponse=new TvForJLKTaskResponse();
taskResponse.setId(task.getId());
taskResponse.setPort(task.getPort());
taskResponse.setToLocation(task.getToLocation());
taskResponse.setFromLocation(task.getFromLocation());
taskResponse.setContainerCode(task.getContainerCode());
taskResponse.setTaskType(TaskTypeEnum.getTaskTypeCode(task.getTaskType()));
taskResponse.setStatusStr(TaskStatusEnum.getTaskStatusCode(task.getStatus()));
resultlist.add(taskResponse);
}
return AjaxResult.success().setData(resultlist);
}
/**
* 用仓库,库区查询该库区当前立库任务
* @return
*/
@PostMapping("/agvTaskNow")
public AjaxResult agvTaskNow(@RequestBody TvRequstDomain domain){
if(StringUtils.isEmpty(domain.getZoneCode())||StringUtils.isEmpty(domain.getWarehouseCode())){
return AjaxResult.error("传参:库区zoneCode或仓库warehouseCode为空");
}
String zoneCode=domain.getZoneCode();
String warehouseCode=domain.getWarehouseCode();
LambdaQueryWrapper<AgvTaskCS> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(AgvTaskCS::getZoneCode, zoneCode);
lambdaQueryWrapper.eq(AgvTaskCS::getWarehouseCode,warehouseCode);
lambdaQueryWrapper.lt(AgvTaskCS::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
lambdaQueryWrapper.orderByDesc(AgvTaskCS::getStatus);
List<AgvTaskCS> list= agvTaskCSService.list(lambdaQueryWrapper);
List<TvForJLKTaskResponse> resultlist=new ArrayList<>();
for(AgvTaskCS task:list){
TvForJLKTaskResponse taskResponse=new TvForJLKTaskResponse();
taskResponse.setId(task.getId());
taskResponse.setFromPort(task.getFromPort());
taskResponse.setToPort(task.getToPort());
taskResponse.setContainerCode(task.getContainerCode());
taskResponse.setStatusStr(TaskStatusAgvEnum.getTaskStatusCode(task.getStatus()));
resultlist.add(taskResponse);
}
return AjaxResult.success().setData(resultlist);
}
}