TvController.java
9.7 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
package com.huaheng.api.tv.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.tv.domain.TaskHeaderOfStationVo;
import com.huaheng.api.tv.domain.TaskOfStationVo;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.exception.service.ServiceException;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxTvResult;
import com.huaheng.framework.web.service.DictService;
import com.huaheng.pc.system.dict.domain.DictData;
import com.huaheng.pc.system.dict.domain.DictType;
import com.huaheng.pc.system.dict.service.IDictTypeService;
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 io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
@RestController
@RequestMapping("/api/tv")
public class TvController extends BaseController {
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private TaskDetailService taskDetailService;
@Resource
private DictService dictService;
@Resource
private IDictTypeService dictTypeService;
@GetMapping("/taskOfStation")
@ApiOperation("获取电视信息")
@CrossOrigin
public AjaxTvResult taskOfStation() {
// 获取状态为到达拣选台状态的分拣任务
LambdaQueryWrapper<TaskHeader> taskHeaderQueryWrapper = Wrappers.lambdaQuery();
taskHeaderQueryWrapper
.in(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT,
QuantityConstant.TASK_TYPE_CYCLECOUNT,
QuantityConstant.TASK_TYPE_VIEW)
.eq(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_ARRIVED_STATION);
List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderQueryWrapper);
List<TaskOfStationVo> taskOfStationVoList = new ArrayList<>();
taskHeaderList.forEach(taskHeader -> {
TaskOfStationVo taskOfStationVo = new TaskOfStationVo();
TaskHeaderOfStationVo taskHeaderOfStationVo = new TaskHeaderOfStationVo();
taskHeaderOfStationVo.setContainerCode(taskHeader.getContainerCode());
taskHeaderOfStationVo.setFromLocationCode(taskHeader.getFromLocation());
taskHeaderOfStationVo.setToLocationCode(taskHeader.getToLocation());
taskHeaderOfStationVo.setFromPortCode(taskHeader.getPort());
taskHeaderOfStationVo.setToPortCode(taskHeader.getPort());
DictType taskTypeDictType = dictTypeService.selectDictTypeByType("taskType");
if (taskTypeDictType == null) {
throw new ServiceException("字典库存状态:taskType 不存在");
}
List<DictData> taskTypeDataList = dictService.getType(taskTypeDictType.getDictType());
DictData dictData = taskTypeDataList.stream()
.filter(data -> data.getDictValue().equals(taskHeader.getTaskType().toString()))
.findFirst().orElse(null);
if (dictData == null) {
taskHeaderOfStationVo.setUserdef1("类型异常");
} else {
taskHeaderOfStationVo.setUserdef1(dictData.getDictLabel());
}
DictType taskStatusDictType = dictTypeService.selectDictTypeByType("taskStatus");
if (taskStatusDictType == null) {
throw new ServiceException("字典库存状态:taskStatus 不存在");
}
List<DictData> taskStatusDataList = dictService.getType(taskStatusDictType.getDictType());
dictData = taskStatusDataList.stream()
.filter(data -> data.getDictValue().equals(taskHeader.getStatus().toString()))
.findFirst().orElse(null);
if (dictData == null) {
taskHeaderOfStationVo.setUserdef2("状态异常");
} else {
taskHeaderOfStationVo.setUserdef2(dictData.getDictLabel());
}
taskOfStationVo.setTaskHeader(taskHeaderOfStationVo);
LambdaQueryWrapper<TaskDetail> taskDetailQueryWrapper = Wrappers.lambdaQuery();
taskDetailQueryWrapper
.eq(TaskDetail::getTaskId, taskHeader.getId());
List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailQueryWrapper);
DictType dictType = dictTypeService.selectDictTypeByType("inventorySts");
if (dictType == null) {
throw new ServiceException("字典库存状态:inventory 不存在");
}
List<DictData> dictDataList = dictService.getType(dictType.getDictType());
taskDetailList.forEach(taskDetail -> {
DictData dictData2 = dictDataList.stream()
.filter(data -> data.getDictValue().equals(taskDetail.getInventorySts()))
.findFirst().orElse(null);
if (dictData2 == null) {
taskDetail.setUserDef1("状态异常");
} else {
taskDetail.setUserDef1(dictData2.getDictLabel());
}
});
taskOfStationVo.setTaskDetailList(taskDetailList);
taskOfStationVoList.add(taskOfStationVo);
});
return AjaxTvResult.success(taskOfStationVoList);
}
/*@GetMapping("/getTvView")
@ApiOperation("获取电视信息")
public AjaxResult getTvView(@RequestParam(name = "station") String station) {
LambdaQueryWrapper<TaskHeader> headerLambdaQuery = Wrappers.lambdaQuery();
LambdaQueryWrapper<TaskDetail> detailLambdaQuery = Wrappers.lambdaQuery();
//查询入库任务,状态不为为完成(<100)的站台
ArrayList<Integer> taskType = new ArrayList<>();
taskType.add(QuantityConstant.TASK_TYPE_WHOLERECEIPT);//整盘入库---100
taskType.add(QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT);
taskType.add(QuantityConstant.TASK_TYPE_EMPTYRECEIPT);//空托盘入库---500
taskType.add(QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT);//空托盘组入库---1100
taskType.add(QuantityConstant.TASK_TYPE_WHOLESHIPMENT);//整盘出库---300
taskType.add(QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT);//空托盘组出库库---1200
taskType.add(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT);//分拣出库---400
headerLambdaQuery.in(TaskHeader::getTaskType,taskType);
headerLambdaQuery.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);//小于任务完成状态的
if(station==null || "P1001".equals(station)){//异常口入库,没有站台号
headerLambdaQuery.isNull(TaskHeader::getPort)
.or()
.eq(TaskHeader::getPort, "P1001")
.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);//小于任务完成状态的
}else{
headerLambdaQuery.eq(TaskHeader::getPort, "P1010");
}
List<TaskHeader> allHeader = taskHeaderService.list(headerLambdaQuery);
if (ObjectUtils.isEmpty(allHeader)) {
return AjaxResult.success().setData(Lists.newArrayList());
}
List<Integer> ids = allHeader.stream().map(TaskHeader::getId).collect(Collectors.toList());//获取任务ID
detailLambdaQuery.in(TaskDetail::getTaskId, ids);
List<TaskDetail> allDetail = taskDetailService.list(detailLambdaQuery);//详情列表
//详情map,以任务头id分组
Map<Integer, List<TaskDetail>> map = allDetail.stream().collect(Collectors.groupingBy(TaskDetail::getTaskId));
//显示列表
List<PortViewVO> portViewVOs = new ArrayList<>();
for (TaskHeader taskHeader : allHeader) {
PortViewVO portViewVO = new PortViewVO();//返回对象
TaskHeaderVO header = new TaskHeaderVO();//返回头任务VO
BeanUtils.copyProperties(taskHeader, header);
header.setType(taskHeader.getTaskType());
header.setSourceLocation(taskHeader.getFromLocation());
header.setDestinationLocation(taskHeader.getToLocation());
List<TaskDetail> tempDetails = map.get(taskHeader.getId());//通过id,获取详细
List<TaskDetailsVO> list = new ArrayList<>();
BigDecimal sum = BigDecimal.valueOf(0);//每个返回头任务VO的总数量
if(tempDetails != null) {
for (TaskDetail tempDetail : tempDetails) {
TaskDetailsVO taskDetailsVO = new TaskDetailsVO();//任务详情vo
BeanUtils.copyProperties(tempDetail, taskDetailsVO);
taskDetailsVO.setSourceLocation(taskHeader.getFromLocation());
taskDetailsVO.setDestinationLocation(taskHeader.getToLocation());
list.add(taskDetailsVO);
if (taskDetailsVO.getQty() != null){//统计总数量
BigDecimal add = sum.add(taskDetailsVO.getQty());
sum = add;
}
}
}
header.setQty(sum);//总数量
portViewVO.setTaskHeader(header);//头
portViewVO.setTaskDetails(list);//详情
portViewVOs.add(portViewVO);
}
return AjaxResult.success(portViewVOs);
}*/
}