TvController.java
14.2 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
package com.huaheng.api.tv.controller;
import java.util.*;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.huaheng.api.general.controller.TokenApiController;
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.controller.LocationController;
import com.huaheng.pc.config.location.domain.Location;
import com.huaheng.pc.config.location.domain.LocationStatus;
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.stacking.domain.Stacking;
import com.huaheng.pc.config.stacking.service.IStackingService;
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.shipment.shipmentDetail.domain.ShipmentDetailTv;
import com.huaheng.pc.shipment.shipmentDetail.mapper.ShipmentDetailMapper;
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;
@RestController
@RequestMapping("/API/WMS/v2")
public class TvController extends BaseController {
@Resource
private TaskHeaderService taskHeaderService;
@Resource
private TaskDetailService taskDetailService;
@Resource
private ContainerService containerService;
@Resource
private LocationService locationService;
@Resource
private InventoryTransactionService inventoryTransactionService;
@Resource
private ZoneService zoneService;
@Resource
private InventoryDetailService inventoryDetailService;
@Resource
private InventoryMaterialSummaryService inventoryMaterialSummaryService;
@Resource
private MaterialService materialService;
@Resource
private ShipmentDetailMapper shipmentDetailMapper;
@Resource
private TokenApiController tokenApiController;
@Resource
private LocationController locationController;
@GetMapping("/getRGVLocation")
@CrossOrigin
@ResponseBody
public AjaxResult getRGVLocation(String type, String row, String line, String layer) {
tokenApiController.getToken("xcq", "123456", "CS0001");
AjaxResult ajaxResult = locationController.getLocationInfo(type, row, line, layer, null);
if (ajaxResult.hasErr()) {
return ajaxResult;
}
List<Location> locations = (List<Location>)ajaxResult.getData();
Map<String, Object> map = new HashMap<>();
Map<Integer, String> keyMap = new HashMap<>();
// 库位数据
map.put("locations", locations);
keyMap.put(LocationStatus.IDLE_EMPTY_LOCATION, "空柜空闲");
keyMap.put(LocationStatus.IDLE_EMPTY_CONTAINER, "空盘空闲");
keyMap.put(LocationStatus.IDLE_FULL_CONTAINER, "满盘空闲");
keyMap.put(LocationStatus.LOCK_EMPTY_LOCATION, "空柜锁定");
keyMap.put(LocationStatus.LOCK_EMPTY_CONTAINER, "空盘锁定");
keyMap.put(LocationStatus.LOCK_FULL_CONTAINER, "满盘锁定");
Map<String, Integer> locationMap = new HashMap<>();
locationMap.put(keyMap.get(LocationStatus.IDLE_EMPTY_LOCATION), 0);
locationMap.put(keyMap.get(LocationStatus.IDLE_EMPTY_CONTAINER), 0);
locationMap.put(keyMap.get(LocationStatus.IDLE_FULL_CONTAINER), 0);
locationMap.put(keyMap.get(LocationStatus.LOCK_EMPTY_LOCATION), 0);
locationMap.put(keyMap.get(LocationStatus.LOCK_EMPTY_CONTAINER), 0);
locationMap.put(keyMap.get(LocationStatus.LOCK_FULL_CONTAINER), 0);
if (locations != null) {
locations.forEach(item -> {
Integer userDef3 = 0;
if (StringUtils.isNotEmpty(item.getUserDef3())) {
userDef3 = Integer.valueOf(item.getUserDef3());
}
if (keyMap.containsKey(userDef3)) {
Integer temp = locationMap.get(keyMap.get(userDef3)) + 1;
locationMap.put(keyMap.get(userDef3), temp);
}
});
}
List<LocationDisplay> locationDisplayList = new ArrayList<>();
keyMap.forEach((key, value) -> {
LocationDisplay display = new LocationDisplay();
display.setText(value);
display.setNumCount(locationMap.get(value));
display.setUserDef3(String.valueOf(key));
locationDisplayList.add(display);
});
// 剩余可用库位
LambdaQueryWrapper<Location> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(Location::getZoneCode, QuantityConstant.RGV_LOCATION_CODE).eq(Location::getStatus, QuantityConstant.STATUS_CONTAINER_EMPTY)
.eq(Location::getContainerCode, "");
Integer availableQty = locationService.count(lambdaQueryWrapper);
map.put("availableQty", availableQty);
// 总库位
LambdaQueryWrapper<Location> query = Wrappers.lambdaQuery();
query.eq(Location::getZoneCode, QuantityConstant.RGV_LOCATION_CODE);
Integer total = locationService.count(query);
map.put("total", total);
map.put("topData", locationDisplayList);
List data = locationService.columnLayerConvert(locations);
map.put("data", data);
ajaxResult.setData(map);
return ajaxResult;
}
@PostMapping("/getTvView")
// @ApiOperation("获取电视信息")
@ResponseBody
public AjaxResult getTvView(@RequestBody WcsTask wcsTask) {
String area = wcsTask.getArea();
String zoneCode = null;
if (StringUtils.isEmpty(area)) {
return AjaxResult.error("区域字段不能为空值!");
}
if (QuantityConstant.STATE_LIBRARY == Integer.valueOf(area)) {
zoneCode = QuantityConstant.L_LOCATION_CODE;
}
if (QuantityConstant.RGV_LIBRARY == Integer.valueOf(area)) {
zoneCode = QuantityConstant.RGV_LOCATION_CODE;
}
if (QuantityConstant.FLAT_LIBRARY == Integer.valueOf(area)) {
zoneCode = QuantityConstant.FLAT_LOCATION_CODE;
}
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getZoneCode, zoneCode).lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED)
.orderByDesc(TaskHeader::getId);
List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper);
if (taskHeaderList != null && taskHeaderList.size() > 0) {
for (TaskHeader taskHeader : taskHeaderList) {
String materialCode = taskHeader.getMaterialCode();
String warehouseCode = taskHeader.getWarehouseCode();
Material material = materialService.getMaterialByCode(materialCode, warehouseCode);
if (material != null) {
taskHeader.setMaterialCode(material.getName());
}
}
}
LambdaQueryWrapper<Container> containerEmptyLambdaQueryWrapper = Wrappers.lambdaQuery();
containerEmptyLambdaQueryWrapper.eq(Container::getArea, area).eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_EMPTY)
.ne(Container::getLocationCode, "");
List<Container> containerEmptyList = containerService.list(containerEmptyLambdaQueryWrapper);
int containerEmptySize = containerEmptyList.size();
LambdaQueryWrapper<Container> containerManyLambdaQueryWrapper = Wrappers.lambdaQuery();
containerManyLambdaQueryWrapper.eq(Container::getArea, area).eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_MANY).ne(Container::getLocationCode,
"");
List<Container> manyEmptyList = containerService.list(containerManyLambdaQueryWrapper);
int manyEmptyListSize = manyEmptyList.size();
containerEmptySize = containerEmptySize + manyEmptyListSize * 6;
LambdaQueryWrapper<Container> containerSomeLambdaQueryWrapper = Wrappers.lambdaQuery();
containerSomeLambdaQueryWrapper.eq(Container::getArea, area).eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_SOME).ne(Container::getLocationCode,
"");
List<Container> containerSomeList = containerService.list(containerSomeLambdaQueryWrapper);
int containerSomeSize = containerSomeList.size();
LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
locationLambdaQueryWrapper.eq(Location::getArea, area);
List<Location> locationList = locationService.list(locationLambdaQueryWrapper);
int totalLocationSize = locationList.size();
LambdaQueryWrapper<Zone> zoneLambdaQueryWrapper = Wrappers.lambdaQuery();
zoneLambdaQueryWrapper.eq(Zone::getArea, area);
Zone zone = zoneService.getOne(zoneLambdaQueryWrapper);
LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getZoneCode, zone.getCode());
List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
int inventorySize = inventoryDetailList.size();
LambdaQueryWrapper<InventoryMaterialSummary> lambdaQueryWrapper = Wrappers.lambdaQuery();
lambdaQueryWrapper.eq(InventoryMaterialSummary::getZoneCode, zone.getCode());
List<InventoryMaterialSummary> list = inventoryMaterialSummaryService.list(lambdaQueryWrapper);
if (list == null) {
list = Collections.emptyList();
}
// 筛选库存汇总数据的专用方法
List<InventoryMaterialSummary> details = inventoryMaterialSummaryService.duplicateRemoval(list);
TvBean tvBean = new TvBean();
tvBean.setDetails(details);
tvBean.setContainerEmptySize(containerEmptySize);
tvBean.setContainerSomeSize(containerSomeSize);
tvBean.setTotalLocationSize(totalLocationSize);
tvBean.setTaskHeaderList(taskHeaderList);
tvBean.setInventorySize(inventorySize);
return AjaxResult.success(tvBean);
}
@PostMapping("/getTvReceiptView")
// @ApiOperation("获取电视入库信息")
@CrossOrigin
@ResponseBody
// @ApiLogger(apiName = "获取电视入库信息", from = "TV")
public AjaxResult getTvReceiptView() {
AllBean allBean = new AllBean();
LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery();
List<String> str = Arrays.asList("100", "200");
queryWrapper.in(TaskDetail::getTaskType, str).last(" and date_format( created, '%Y-%m-%d' )= date_format( now(), '%Y-%m-%d' ) and `status`>=100");
List<TaskDetail> list = taskDetailService.list(queryWrapper);
List<TopBean> topList = new ArrayList<>();
if (list.size() > 0) {
topList = taskDetailService.getTvReceiptView("1");
}
allBean.setTopList(topList);
List<UpBean> upList = taskDetailService.getTvNotReceiptTaskList();
allBean.setUpList(upList);
return AjaxResult.success(allBean);
}
@PostMapping("/getTvShipmentView")
// @ApiOperation("获取电视出库信息")
@CrossOrigin
@ResponseBody
// @ApiLogger(apiName = "获取电视出库信息", from = "TV")
public AjaxResult getTvShipmentView(@RequestBody Map<String, String> map) {
AllBean allBean = new AllBean();
LambdaQueryWrapper<TaskDetail> queryWrapper = Wrappers.lambdaQuery();
List<String> str = Arrays.asList("300", "400");
queryWrapper.in(TaskDetail::getTaskType, str).last(" and date_format( created, '%Y-%m-%d' )= date_format( now(), '%Y-%m-%d' ) and `status`>=100");
List<TaskDetail> list = taskDetailService.list(queryWrapper);
List<TopBean> topList = new ArrayList<>();
if (list.size() > 0) {
topList = taskDetailService.getTvReceiptView("2");
}
allBean.setTopList(topList);
List<UpBean> upList = taskDetailService.getTvNotReceiptList("2");
allBean.setUpList(upList);
String par = map.get("par");
List<ShipmentDetailTv> portList = shipmentDetailMapper.getTvOutList(par);
allBean.setPortList(portList);
return AjaxResult.success(allBean);
}
@PostMapping("/getTvPortShipmentView")
@ApiOperation("获取出站口出库信息")
@CrossOrigin
@ResponseBody
// @ApiLogger(apiName = "获取出站口出库信息", from = "TV")
public AjaxResult getTvPortShipmentView(@RequestBody Map<String, String> map) {
String par = map.get("par");
List<ShipmentDetailTv> upList = shipmentDetailMapper.getTvOutList(par);
return AjaxResult.success(upList);
}
@Resource
private IStackingService stackingService;
@PostMapping("/getTvStackingView")
@CrossOrigin
@ResponseBody
// @ApiLogger(apiName = "获取出站口出库信息", from = "TV")
public AjaxResult getTvStackingView() {
LambdaQueryWrapper<Stacking> query = Wrappers.lambdaQuery();
query.select(Stacking::getPort, Stacking::getCurrentQty, Stacking::getMaxQty, Stacking::getName, Stacking::getOrderCode, Stacking::getContainerCode);
List<Stacking> list = stackingService.list(query);
return AjaxResult.success(list);
}
}