Commit a93fe53d6312d055fb09e115c37059fa12c64f08
1 parent
05270686
库位监控后端移植
Showing
5 changed files
with
276 additions
and
0 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/entity/Location.java
... | ... | @@ -4,7 +4,10 @@ import java.io.Serializable; |
4 | 4 | import java.io.UnsupportedEncodingException; |
5 | 5 | import java.util.Date; |
6 | 6 | import java.math.BigDecimal; |
7 | +import java.util.List; | |
8 | + | |
7 | 9 | import com.baomidou.mybatisplus.annotation.IdType; |
10 | +import com.baomidou.mybatisplus.annotation.TableField; | |
8 | 11 | import com.baomidou.mybatisplus.annotation.TableId; |
9 | 12 | import com.baomidou.mybatisplus.annotation.TableName; |
10 | 13 | import lombok.Data; |
... | ... | @@ -123,4 +126,19 @@ public class Location implements Serializable { |
123 | 126 | /** 更新日期 */ |
124 | 127 | @ApiModelProperty(value = "更新日期") |
125 | 128 | private Date updateTime; |
129 | + /** 物料编码 */ | |
130 | + @TableField(exist = false) | |
131 | + private List<String> materialCode; | |
132 | + /** 物料名称 */ | |
133 | + @TableField(exist = false) | |
134 | + private List<String> materialName; | |
135 | + /** 批次 */ | |
136 | + @TableField(exist = false) | |
137 | + private List<String> batch; | |
138 | + /** 数量 */ | |
139 | + @TableField(exist = false) | |
140 | + private List<BigDecimal> qty; | |
141 | + /** 库存所在库位状态 */ | |
142 | + @TableField(exist = false) | |
143 | + private String locationAttribute; | |
126 | 144 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/locationMonitor/controller/LocationMonitorController.java
0 → 100644
1 | +package org.jeecg.modules.wms.config.locationMonitor.controller; | |
2 | +import java.math.BigDecimal; | |
3 | +import java.util.ArrayList; | |
4 | +import java.util.HashMap; | |
5 | +import java.util.List; | |
6 | +import java.util.stream.Collectors; | |
7 | +import javax.annotation.Resource; | |
8 | +import javax.servlet.http.HttpServletRequest; | |
9 | + | |
10 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
11 | +import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |
12 | +import org.jeecg.common.api.vo.Result; | |
13 | +import org.jeecg.modules.wms.config.container.entity.Container; | |
14 | +import org.jeecg.modules.wms.config.container.service.IContainerService; | |
15 | +import org.jeecg.modules.wms.config.location.entity.Location; | |
16 | +import org.jeecg.modules.wms.config.location.service.ILocationService; | |
17 | +import lombok.extern.slf4j.Slf4j; | |
18 | + | |
19 | +import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail; | |
20 | +import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService; | |
21 | +import org.jeecg.modules.wms.config.locationMonitor.entity.LocationStatus; | |
22 | +import org.jeecg.utils.HuahengJwtUtil; | |
23 | +import org.jeecg.utils.StringUtils; | |
24 | +import org.jeecg.utils.constant.QuantityConstant; | |
25 | +import org.springframework.beans.factory.annotation.Autowired; | |
26 | +import org.springframework.web.bind.annotation.*; | |
27 | +import io.swagger.annotations.Api; | |
28 | + | |
29 | + /** | |
30 | + * @Description: 库存监控 | |
31 | + * @Author: lty | |
32 | + * @Date: 2023/1/29 | |
33 | + */ | |
34 | +@Api(tags="库存监控") | |
35 | +@RestController | |
36 | +@RequestMapping("/location/locationMonitor") | |
37 | +@Slf4j | |
38 | +public class LocationMonitorController{ | |
39 | + @Autowired | |
40 | + private IContainerService containerService; | |
41 | + @Resource | |
42 | + private ILocationService locationService; | |
43 | + @Resource | |
44 | + private IInventoryDetailService inventoryDetailService; | |
45 | + | |
46 | + | |
47 | + /** | |
48 | + * 库存概括 | |
49 | + */ | |
50 | + @GetMapping("/getStatus") | |
51 | + @ResponseBody | |
52 | + public Result getStatus(String zoneCode) { | |
53 | + HashMap<String, Integer> map = new HashMap<>(); | |
54 | + LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery(); | |
55 | + queryWrapper.eq(Location::getZoneCode,zoneCode); | |
56 | + List<Location> locationList = locationService.list(queryWrapper); | |
57 | + map.put("location", locationList.size()); | |
58 | + queryWrapper = Wrappers.lambdaQuery(); | |
59 | + queryWrapper.and(wrapper->wrapper.isNull(Location::getContainerCode).or().eq(Location::getContainerCode,"")) | |
60 | + .eq(Location::getZoneCode,zoneCode); | |
61 | + List<Location> emptyLocationList = locationService.list(queryWrapper); | |
62 | + map.put("emptyLocation", emptyLocationList.size()); | |
63 | + LambdaQueryWrapper<Container> containerLambdaQueryWrapper2 = Wrappers.lambdaQuery(); | |
64 | + containerLambdaQueryWrapper2.eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_EMPTY); | |
65 | + List<Container> containerList2 = containerService.list(containerLambdaQueryWrapper2); | |
66 | + List<String> containerCodeList2 = containerList2.stream().map(Container::getCode).collect(Collectors.toList()); | |
67 | + LambdaQueryWrapper<Location> locationLambdaQueryWrapper2 = Wrappers.lambdaQuery(); | |
68 | + locationLambdaQueryWrapper2.in(Location::getContainerCode, containerCodeList2); | |
69 | + locationLambdaQueryWrapper2.eq(Location::getZoneCode, zoneCode); | |
70 | + List<Location> haveEmptyContainLocation = locationService.list(locationLambdaQueryWrapper2); | |
71 | + map.put("haveContainLocation", haveEmptyContainLocation.size()); | |
72 | + LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
73 | + containerLambdaQueryWrapper.eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_SOME); | |
74 | + List<Container> containerList = containerService.list(containerLambdaQueryWrapper); | |
75 | + int containerListSize = containerList.size(); | |
76 | + List<String> containerCodeList = containerList.stream().map(Container::getCode).collect(Collectors.toList()); | |
77 | + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
78 | + locationLambdaQueryWrapper.in(containerListSize !=0, Location::getContainerCode, containerCodeList); | |
79 | + locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode); | |
80 | + List<Location> haveInventoryLocation = locationService.list(locationLambdaQueryWrapper); | |
81 | + map.put("haveInventoryLocation", haveInventoryLocation.size()); | |
82 | + return Result.ok(map); | |
83 | + } | |
84 | + | |
85 | + /** | |
86 | + * 查询库位列表 | |
87 | + */ | |
88 | + @PostMapping("/getLocationInfo") | |
89 | + @ResponseBody | |
90 | + public Result getLocationInfo (String type, String row, String line, String layer, String grid, HttpServletRequest req) { | |
91 | + if(StringUtils.isEmpty(type)) { | |
92 | + return Result.error("type不能为空"); | |
93 | + } | |
94 | + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); | |
95 | + /* 查询库位信息*/ | |
96 | + LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
97 | + locationLambdaQueryWrapper.eq(StringUtils.isNotEmpty(row), Location::getRow, row) | |
98 | + .eq(StringUtils.isNotEmpty(line), Location::getIcolumn, line) | |
99 | + .eq(StringUtils.isNotEmpty(layer), Location::getLayer, layer) | |
100 | + .eq(StringUtils.isNotEmpty(grid),Location::getGrid, grid) | |
101 | + .eq(Location::getWarehouseCode, warehouseCode) | |
102 | + .eq(StringUtils.isNotEmpty(type), Location::getZoneCode, type); | |
103 | + List<Location> locations = locationService.list(locationLambdaQueryWrapper); | |
104 | + List<Location> locationList = new ArrayList<>(); | |
105 | + | |
106 | + /* 查询库存明细*/ | |
107 | + LambdaQueryWrapper<InventoryDetail> inventoryDetailLambda = Wrappers.lambdaQuery(); | |
108 | + inventoryDetailLambda.eq(InventoryDetail::getWarehouseCode, warehouseCode); | |
109 | + List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambda); | |
110 | + | |
111 | + for (Location location1 : locations) { | |
112 | + InventoryDetail inventoryDetail = null; | |
113 | + String materialName = null; | |
114 | + for (InventoryDetail inventoryDetail2 : inventoryDetailList) { | |
115 | + if(location1.getCode().equals(inventoryDetail2.getLocationCode())) { | |
116 | + inventoryDetail = inventoryDetail2; | |
117 | + } | |
118 | + } | |
119 | + List<InventoryDetail> inventoryDetails = inventoryDetailList.stream().filter(inventoryDetail1 -> | |
120 | + inventoryDetail1.getLocationCode().equals(location1.getCode())).collect(Collectors.toList()); | |
121 | + | |
122 | + int locationAttribute = 0; | |
123 | + String status = location1.getStatus(); | |
124 | + String containerCode = location1.getContainerCode(); | |
125 | + List<String> materialNameList = inventoryDetails.stream().map(InventoryDetail::getMaterialName).collect(Collectors.toList()); | |
126 | + List<String> batchList = inventoryDetails.stream().map(InventoryDetail::getBatch).collect(Collectors.toList()); | |
127 | + List<String> materialCodeList = inventoryDetails.stream().map(InventoryDetail::getMaterialCode).collect(Collectors.toList()); | |
128 | + List<BigDecimal> qtyList = inventoryDetails.stream().map(InventoryDetail::getQty).collect(Collectors.toList()); | |
129 | + if(QuantityConstant.STATUS_LOCATION_EMPTY.equals(status)) { | |
130 | + if(StringUtils.isEmpty(containerCode)) { | |
131 | + locationAttribute = LocationStatus.IDLE_EMPTY_LOCATION; | |
132 | + } else { | |
133 | + if(inventoryDetail == null) { | |
134 | + locationAttribute = LocationStatus.IDLE_EMPTY_CONTAINER; | |
135 | + } else { | |
136 | + location1.setMaterialName(materialNameList); | |
137 | + location1.setMaterialCode(materialCodeList); | |
138 | + location1.setBatch(batchList); | |
139 | + location1.setQty(qtyList); | |
140 | + locationAttribute = LocationStatus.IDLE_FULL_CONTAINER; | |
141 | + } | |
142 | + } | |
143 | + } else if(QuantityConstant.STATUS_LOCATION_LOCK.equals(status)) { | |
144 | + if(StringUtils.isEmpty(containerCode)) { | |
145 | + locationAttribute = LocationStatus.LOCK_EMPTY_LOCATION; | |
146 | + } else { | |
147 | + if(inventoryDetail == null) { | |
148 | + locationAttribute = LocationStatus.LOCK_EMPTY_CONTAINER; | |
149 | + } else { | |
150 | + location1.setMaterialName(materialNameList); | |
151 | + location1.setMaterialCode(materialCodeList); | |
152 | + location1.setBatch(batchList); | |
153 | + location1.setQty(qtyList); | |
154 | + locationAttribute = LocationStatus.LOCK_FULL_CONTAINER; | |
155 | + } | |
156 | + } | |
157 | + } | |
158 | + | |
159 | +// if(location1.getDeleted()) { | |
160 | +// if(StringUtils.isEmpty(containerCode)) { | |
161 | +// locationAttribute = LocationStatus.DISABLE_EMPTY_LOCATION; | |
162 | +// } else { | |
163 | +// if(inventoryDetail == null) { | |
164 | +// locationAttribute = LocationStatus.DISABLE_EMPTY_CONTAINER; | |
165 | +// } else { | |
166 | +// location1.setMaterialName(materialNameList); | |
167 | +// location1.setMaterialCode(materialCodeList); | |
168 | +// location1.setBatch(batchList); | |
169 | +// location1.setQty(qtyList); | |
170 | +// locationAttribute = LocationStatus.DISABLE_FULL_CONTAINER; | |
171 | +// } | |
172 | +// } | |
173 | +// } | |
174 | + | |
175 | + location1.setLocationAttribute(String.valueOf(locationAttribute)); | |
176 | + locationList.add(location1); | |
177 | + } | |
178 | + return Result.ok(locations); | |
179 | + } | |
180 | + | |
181 | + | |
182 | + /** | |
183 | + * 查询库位列表 | |
184 | + */ | |
185 | + @PostMapping("/getAllLocation") | |
186 | + @ResponseBody | |
187 | + public Result getAllLocation (String type) { | |
188 | + if(StringUtils.isEmpty(type)) { | |
189 | + return Result.error("type不能为空"); | |
190 | + } | |
191 | + return Result.ok(locationService.getAllLocation(type)); | |
192 | + } | |
193 | + | |
194 | + } | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/locationMonitor/entity/LocationStatus.java
0 → 100644
1 | +package org.jeecg.modules.wms.config.locationMonitor.entity; | |
2 | + | |
3 | +/** | |
4 | + * | |
5 | + * @author lty | |
6 | + * @date 2023/1/29 | |
7 | + */ | |
8 | +public class LocationStatus { | |
9 | + | |
10 | + /** 空柜丢失 */ | |
11 | + public static final int IDLE_EMPTY_LOST = 0; | |
12 | + /** 空柜空闲 */ | |
13 | + public static final int IDLE_EMPTY_LOCATION = 1; | |
14 | + /** 空盘空闲 */ | |
15 | + public static final int IDLE_EMPTY_CONTAINER = 2; | |
16 | + /** 半盘空闲 */ | |
17 | + public static final int IDLE_HALF_CONTAINER = 3; | |
18 | + /** 满盘空闲 */ | |
19 | + public static final int IDLE_FULL_CONTAINER = 4; | |
20 | + /** 空柜锁定 */ | |
21 | + public static final int LOCK_EMPTY_LOCATION = 5; | |
22 | + /** 空盘锁定 */ | |
23 | + public static final int LOCK_EMPTY_CONTAINER = 6; | |
24 | + /** 半盘锁定 */ | |
25 | + public static final int LOCK_HALF_CONTAINER = 7; | |
26 | + /** 满盘锁定 */ | |
27 | + public static final int LOCK_FULL_CONTAINER = 8; | |
28 | + /** 空柜禁用 */ | |
29 | + public static final int DISABLE_EMPTY_LOCATION = 9; | |
30 | + /** 空盘禁用 */ | |
31 | + public static final int DISABLE_EMPTY_CONTAINER = 10; | |
32 | + /** 半盘禁用 */ | |
33 | + public static final int DISABLE_HALF_CONTAINER = 11; | |
34 | + /** 满盘禁用 */ | |
35 | + public static final int DISABLE_FULL_CONTAINER = 12; | |
36 | +} | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/locationMonitor/service/LocationMonitorService.java
0 → 100644
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/locationMonitor/service/impl/LocationMonitorServiceImpl.java
0 → 100644
1 | +package org.jeecg.modules.wms.config.locationMonitor.service.impl; | |
2 | + | |
3 | + | |
4 | +import org.jeecg.modules.wms.config.locationMonitor.service.LocationMonitorService; | |
5 | +import org.springframework.stereotype.Service; | |
6 | + | |
7 | +/** | |
8 | + * @Description: 库存交易记录 | |
9 | + * @Author: jeecg-boot | |
10 | + * @Date: 2022-11-17 | |
11 | + * @Version: V1.0 | |
12 | + */ | |
13 | +@Service | |
14 | +public class LocationMonitorServiceImpl implements LocationMonitorService { | |
15 | + | |
16 | +} | |
... | ... |