TvController.java
6.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
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.TvBean;
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.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.Collections;
import java.util.List;
@RestController
@RequestMapping("/API/WMS/v2")
public class TvController extends BaseController {
@Resource
private TaskHeaderService taskHeaderService;
@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;
@PostMapping("/getTvView")
@ApiOperation("获取电视信息")
@ResponseBody
public AjaxResult getTvView(@RequestBody WcsTask wcsTask) {
String area = wcsTask.getArea();
LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
taskHeaderLambdaQueryWrapper.eq(TaskHeader::getArea, area)
.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.findAllByCode(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);
}
}