TvController.java
7.41 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
package com.huaheng.api.tv.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.google.common.collect.Lists;
import com.huaheng.api.tv.domain.*;
import com.huaheng.api.wcs.domain.WcsTask;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.framework.web.controller.BaseController;
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.config.material.domain.Material;
import com.huaheng.pc.config.material.service.MaterialService;
import com.huaheng.pc.config.zone.domain.Zone;
import com.huaheng.pc.config.zone.service.ZoneService;
import com.huaheng.pc.inventory.InventoryMaterialSummary.domain.InventoryMaterialSummary;
import com.huaheng.pc.inventory.InventoryMaterialSummary.service.InventoryMaterialSummaryService;
import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail;
import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService;
import com.huaheng.pc.inventory.inventoryTransaction.service.InventoryTransactionService;
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.beans.BeanUtils;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/tv")
public class TvController extends BaseController {
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private TaskDetailService taskDetailService;
@GetMapping("/taskOfstation")
@ApiOperation("获取电视信息")
public AjaxResult taskOfStation() {
// 获取状态为到达拣选台状态的分拣任务
LambdaQueryWrapper<TaskHeader> taskHeaderQueryWrapper = Wrappers.lambdaQuery();
taskHeaderQueryWrapper
.eq(TaskHeader::getTaskType, QuantityConstant.TASK_TYPE_SORTINGSHIPMENT)
.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();
taskOfStationVo.setTaskHeader(taskHeader);
LambdaQueryWrapper<TaskDetail> taskDetailQueryWrapper = Wrappers.lambdaQuery();
taskDetailQueryWrapper
.eq(TaskDetail::getTaskId, taskHeader.getId());
List<TaskDetail> taskDetailList = taskDetailService.list(taskDetailQueryWrapper);
taskOfStationVo.setTaskDetailList(taskDetailList);
taskOfStationVoList.add(taskOfStationVo);
});
return AjaxResult.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);
}*/
}