MobileController.java
10.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
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
package com.huaheng.api.tv.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.common.constant.QuantityConstant;
import com.huaheng.common.utils.DateUtils;
import com.huaheng.common.utils.StringUtils;
import com.huaheng.framework.web.controller.BaseController;
import com.huaheng.framework.web.domain.AjaxResult;
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 io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/API/WMS/v2")
public class MobileController extends BaseController {
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private LocationService locationService;
/**
* 当天出入库量
*
* @param warehouseCode 仓库编码
* @return
*/
@GetMapping("tvTaskNum")
@ApiOperation("获取电视信息")
@ResponseBody
@CrossOrigin
public AjaxResult tvTaskNum(String warehouseCode) {
if (StringUtils.isEmpty(warehouseCode)) {
return AjaxResult.error("请填写仓库");
}
ArrayList<Object> result = new ArrayList<>();
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getWarehouseCode, warehouseCode);
taskHeaderLambdaQueryWrapper.ge(TaskHeader::getCreated, DateUtils.getNowPreDays("yyyy-MM-dd 00:00:00", 0));
taskHeaderLambdaQueryWrapper.in(TaskHeader::getInternalTaskType, QuantityConstant.TASK_INTENERTYPE_RECEIPT, QuantityConstant.TASK_INTENERTYPE_SHIPMENT);
List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
Map<Integer, List<TaskHeader>> taskTypeMap = taskHeaderList.stream().collect(Collectors.groupingBy(TaskHeader::getInternalTaskType));
List<TaskHeader> receiptTaskList = taskTypeMap.get(QuantityConstant.TASK_INTENERTYPE_RECEIPT);
List<TaskHeader> shipmentTaskList = taskTypeMap.get(QuantityConstant.TASK_INTENERTYPE_SHIPMENT);
HashMap<String, Integer> resultMap = new HashMap<>();
int receiptNum = 0;
int shipmentNum = 0;
if (CollectionUtils.isNotEmpty(receiptTaskList)) {
receiptNum = receiptTaskList.size();
resultMap.put("receiptNum", receiptNum);
} else {
resultMap.put("receiptNum", 0);
}
if (CollectionUtils.isNotEmpty(shipmentTaskList)) {
shipmentNum = shipmentTaskList.size();
resultMap.put("shipmentNum", shipmentNum);
} else {
resultMap.put("shipmentNum", 0);
}
if (shipmentNum != 0) {
float proportion =0;
if(receiptNum!=0&&shipmentNum!=0){
proportion = (Math.round(receiptTaskList.size() / (float) shipmentTaskList.size() * 100)) / 100f;
}
resultMap.put("proportion", (int) (proportion * 100));
} else {
resultMap.put("proportion", 100);
}
LambdaQueryWrapper<TaskHeader> monthLambdaQueryWrapper = Wrappers.lambdaQuery();
monthLambdaQueryWrapper.eq(TaskHeader::getWarehouseCode, warehouseCode);
monthLambdaQueryWrapper.ge(TaskHeader::getCreated, DateUtils.getNowPreDays("yyyy-MM-dd", 30));
monthLambdaQueryWrapper.in(TaskHeader::getInternalTaskType, QuantityConstant.TASK_INTENERTYPE_RECEIPT, QuantityConstant.TASK_INTENERTYPE_SHIPMENT);
List<TaskHeader> taskHeaderList2 = taskHeaderService.list(monthLambdaQueryWrapper);
Map<Integer, List<TaskHeader>> taskTypeMap2 = taskHeaderList2.stream().collect(Collectors.groupingBy(TaskHeader::getInternalTaskType));
List<TaskHeader> receiptTaskList2 = taskTypeMap2.get(QuantityConstant.TASK_INTENERTYPE_RECEIPT);
List<TaskHeader> shipmentTaskList2 = taskTypeMap2.get(QuantityConstant.TASK_INTENERTYPE_SHIPMENT);
int receiptNumMonth = 0;
int shipmentNumMonth = 0;
if (CollectionUtils.isNotEmpty(receiptTaskList2)) {
receiptNumMonth = receiptTaskList2.size();
resultMap.put("receiptNumMonth", receiptNumMonth);
} else {
resultMap.put("receiptNumMonth", 0);
}
if (CollectionUtils.isNotEmpty(shipmentTaskList2)) {
shipmentNumMonth = shipmentTaskList2.size();
resultMap.put("shipmentNumMonth", shipmentNumMonth);
} else {
resultMap.put("shipmentNumMonth", 0);
}
if (shipmentNum != 0) {
float proportion =0;
if(receiptNumMonth!=0&&shipmentNumMonth!=0){
proportion = (Math.round(receiptTaskList2.size() / (float) shipmentTaskList2.size() * 100)) / 100f;
}
resultMap.put("proportionMonth", (int) (proportion * 100));
} else {
resultMap.put("proportionMonth", 100);
}
result.add(resultMap);
return AjaxResult.success(result);
}
/**
* 库位使用情况(按巷道来)
*
* @param warehouseCode
* @return
*/
@GetMapping("roadWayLocation")
@ApiOperation("获取电视信息")
@ResponseBody
@CrossOrigin
public AjaxResult roadWayLocation(String warehouseCode) {
if (StringUtils.isEmpty(warehouseCode)) {
return AjaxResult.error("请填写仓库");
}
ArrayList<Object> result = new ArrayList<>();
LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
locationLambdaQueryWrapper.eq(Location::getWarehouseCode, warehouseCode);
locationLambdaQueryWrapper.eq(Location::getZoneCode, "LK");
List<Location> locationList = locationService.list(locationLambdaQueryWrapper);
Map<String, List<Location>> locationMap = locationList.stream().collect(Collectors.groupingBy(Location::getRoadway));
for (Map.Entry<String, List<Location>> entry : locationMap.entrySet()) {
HashMap<String, String> resultMap = new HashMap<>();
String roadWay = entry.getKey();
List<Location> sumLocationList = entry.getValue();
int sumNum = sumLocationList.size();
int haveContainerNum = (int) sumLocationList.stream().filter(l -> StringUtils.isNotEmpty(l.getContainerCode())).count();
int unHaveContainerNum = sumLocationList.size() - haveContainerNum;
resultMap.put("roadWay", roadWay + "号巷道");
resultMap.put("sumNum", String.valueOf(sumNum));
resultMap.put("haveContainerNum", String.valueOf(haveContainerNum));
resultMap.put("unHaveContainerNum", String.valueOf(unHaveContainerNum));
float usagerate = (Math.round(haveContainerNum / (float) sumNum * 100)) / 100f;
resultMap.put("usagerate", (int) (usagerate * 100) + "%");
result.add(resultMap);
}
return AjaxResult.success(result);
}
/**
* 任务趋势(一周)
*
* @param warehouseCode
* @return
*/
@GetMapping("taskOfWeek")
@ApiOperation("获取电视信息")
@ResponseBody
@CrossOrigin
public AjaxResult taskOfWeek(String warehouseCode) {
if (StringUtils.isEmpty(warehouseCode)) {
return AjaxResult.error("请填写仓库");
}
HashMap<String, Integer> resultMap = new HashMap<>();
ArrayList<Object> result = new ArrayList<>();
String times = DateUtils.getNowPreDays("yyyy-MM-dd 00:00:00", 7);
List<Map<String, Object>> list = taskHeaderService.selectTaskInWeek(times, warehouseCode);
if (list != null && list.size() > 0) {
}
return AjaxResult.success(list);
}
/**
* 24小时任务趋势()
*
* @param warehouseCode
* @return
*/
@GetMapping("taskOfDay")
@ApiOperation("获取电视信息")
@ResponseBody
@CrossOrigin
public AjaxResult taskOfDay(String warehouseCode) {
if (StringUtils.isEmpty(warehouseCode)) {
return AjaxResult.error("请填写仓库");
}
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getWarehouseCode, warehouseCode);
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getZoneCode, "LK");
taskHeaderLambdaQueryWrapper.ge(TaskHeader::getCreated, DateUtils.getNowPreDays("yyyy-MM-dd 00:00:00", 1));
taskHeaderLambdaQueryWrapper.in(TaskHeader::getInternalTaskType, QuantityConstant.TASK_INTENERTYPE_RECEIPT, QuantityConstant.TASK_INTENERTYPE_SHIPMENT, QuantityConstant.TASK_INTENERTYPE_WORK);
// taskHeaderLambdaQueryWrapper.ne(TaskHeader::getFromLocation, "");
// taskHeaderLambdaQueryWrapper.ne(TaskHeader::getToLocation, "");
taskHeaderLambdaQueryWrapper.apply("(fromLocation!='' or toLocation!='' )");
taskHeaderLambdaQueryWrapper.orderByDesc(TaskHeader::getId);
taskHeaderLambdaQueryWrapper.last("limit 20");
List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
List<Map<String, Object>> resultList = new ArrayList<>();
for (TaskHeader task : taskHeaderList) {
Map map = new HashMap();
if (task.getInternalTaskType().equals(QuantityConstant.TASK_INTENERTYPE_RECEIPT)) {
map.put("type", "入库");
} else if (task.getInternalTaskType().equals(QuantityConstant.TASK_INTENERTYPE_SHIPMENT)) {
map.put("type", "出库");
} else {
map.put("type", "工作");
}
if (task.getStatus() == 100) {
map.put("status", "任务完成");
} else if (task.getStatus() == 1) {
map.put("status", "任务生成");
} else if (task.getStatus() == 10) {
map.put("status", "下达任务");
} else if (task.getStatus() == 20) {
map.put("status", "开始执行");
} else if (task.getStatus() == 30) {
map.put("status", "到达拣选台");
} else {
map.put("status", "开始执行");
}
map.put("fromLocation", task.getFromLocation());
map.put("toLocation", task.getToLocation());
resultList.add(map);
}
return AjaxResult.success(resultList);
}
}