Commit 3fe568e7fb69cc0cb016e2880c705f1ec255668e

Authored by 肖超群
1 parent 80eba915

修复库位监控的问题

ant-design-vue-jeecg/src/views/system/monitor/locationStatus.vue
... ... @@ -201,10 +201,10 @@
201 201 loadFrom() {
202 202 getLocationTypeList().then((res) => {
203 203 if (res.success) {
204   - this.locationTypeList = res.result
  204 + this.locationTypeList = res.result;
205 205 this.zoneCode = this.locationTypeList[0].code;
206 206 let _this=this;
207   - this.resetAjax("L");
  207 + this.resetAjax(this.zoneCode);
208 208 }
209 209 })
210 210 },
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/controller/LocationController.java
1 1 package org.jeecg.modules.wms.config.location.controller;
2 2  
3   -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
4   -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5   -import com.baomidou.mybatisplus.core.metadata.IPage;
6   -import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7   -import io.swagger.annotations.Api;
8   -import io.swagger.annotations.ApiOperation;
9   -import lombok.extern.slf4j.Slf4j;
  3 +import java.util.Arrays;
  4 +import java.util.List;
  5 +
  6 +import javax.servlet.http.HttpServletRequest;
  7 +import javax.servlet.http.HttpServletResponse;
  8 +
10 9 import org.apache.shiro.authz.annotation.RequiresPermissions;
11 10 import org.jeecg.common.api.vo.Result;
12 11 import org.jeecg.common.aspect.annotation.AutoLog;
13 12 import org.jeecg.common.system.base.controller.JeecgController;
14 13 import org.jeecg.common.system.query.QueryGenerator;
15   -import org.jeecg.utils.HuahengJwtUtil;
16 14 import org.jeecg.modules.wms.config.location.entity.BatchLocation;
17 15 import org.jeecg.modules.wms.config.location.entity.Location;
18 16 import org.jeecg.modules.wms.config.location.service.ILocationService;
  17 +import org.jeecg.utils.HuahengJwtUtil;
19 18 import org.jeecg.utils.StringUtils;
20 19 import org.jeecg.utils.constant.QuantityConstant;
21 20 import org.springframework.beans.factory.annotation.Autowired;
22 21 import org.springframework.web.bind.annotation.*;
23 22 import org.springframework.web.servlet.ModelAndView;
24 23  
25   -import javax.servlet.http.HttpServletRequest;
26   -import javax.servlet.http.HttpServletResponse;
27   -import java.util.Arrays;
28   -import java.util.List;
  24 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  25 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  26 +import com.baomidou.mybatisplus.core.metadata.IPage;
  27 +import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  28 +
  29 +import io.swagger.annotations.Api;
  30 +import io.swagger.annotations.ApiOperation;
  31 +import lombok.extern.slf4j.Slf4j;
29 32  
30 33 /**
31 34 * @Description: 库位管理
... ... @@ -175,11 +178,12 @@ public class LocationController extends JeecgController<Location, ILocationServi
175 178 */
176 179 @ApiOperation(value = "库位监控-查询库位列表", notes = "库位监控-查询库位列表")
177 180 @GetMapping(value = "/getAllLocation")
178   - public Result getAllLocation(String type) {
  181 + public Result getAllLocation(String type, HttpServletRequest req) {
179 182 if (StringUtils.isEmpty(type)) {
180 183 return Result.error("type不能为空");
181 184 }
182   - return Result.OK(locationService.getAllLocation(type));
  185 + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
  186 + return Result.OK(locationService.getAllLocation(type, warehouseCode));
183 187 }
184 188  
185 189 /**
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java
... ... @@ -45,7 +45,7 @@ public interface ILocationService extends IService<Location> {
45 45  
46 46 Result batchAdd(BatchLocation batchLocation);
47 47  
48   - LocationInfo getAllLocation(String type);
  48 + LocationInfo getAllLocation(String type, String warehouseCode);
49 49  
50 50 IPage<Location> listEmptyContainerInLocation(Page<Location> page, Location location);
51 51  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java
... ... @@ -9,6 +9,7 @@ import java.util.List;
9 9 import javax.annotation.Resource;
10 10  
11 11 import org.jeecg.common.api.vo.Result;
  12 +import org.jeecg.common.exception.JeecgBootException;
12 13 import org.jeecg.modules.wms.config.location.entity.BatchLocation;
13 14 import org.jeecg.modules.wms.config.location.entity.Location;
14 15 import org.jeecg.modules.wms.config.location.entity.LocationInfo;
... ... @@ -24,7 +25,6 @@ import org.jeecg.utils.constant.QuantityConstant;
24 25 import org.springframework.stereotype.Service;
25 26 import org.springframework.transaction.annotation.Transactional;
26 27  
27   -import org.jeecg.common.exception.JeecgBootException;
28 28 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
29 29 import com.baomidou.mybatisplus.core.metadata.IPage;
30 30 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
... ... @@ -336,15 +336,15 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
336 336 }
337 337  
338 338 @Override
339   - public LocationInfo getAllLocation(String type) {
  339 + public LocationInfo getAllLocation(String type, String warehouseCode) {
340 340 if (StringUtils.isNotEmpty(type)) {
341   - Location location = locationMapper.getAllLocation("CS0001", type);
  341 + Location location = locationMapper.getAllLocation(warehouseCode, type);
342 342 LocationInfo locationInfo = new LocationInfo();
343 343 locationInfo.setMaxRow(location.getRow());
344 344 locationInfo.setMaxLine(location.getIcolumn());
345 345 locationInfo.setMaxLayer(location.getLayer());
346   - locationInfo.setMaxGrid(location.getGrid());
347   - int minRow = locationMapper.getFirstRowOfZone("CS0001", type);
  346 +// locationInfo.setMaxGrid(location.getGrid());
  347 + int minRow = locationMapper.getFirstRowOfZone(warehouseCode, type);
348 348 locationInfo.setMinRow(minRow);
349 349 return locationInfo;
350 350 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/locationMonitor/controller/LocationMonitorController.java
... ... @@ -5,33 +5,34 @@ import java.util.ArrayList;
5 5 import java.util.HashMap;
6 6 import java.util.List;
7 7 import java.util.stream.Collectors;
8   -import java.util.stream.Stream;
  8 +
9 9 import javax.annotation.Resource;
10 10 import javax.servlet.http.HttpServletRequest;
11 11  
12   -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
13   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
14 12 import org.jeecg.common.api.vo.Result;
15 13 import org.jeecg.modules.wms.config.container.entity.Container;
16 14 import org.jeecg.modules.wms.config.container.service.IContainerService;
17 15 import org.jeecg.modules.wms.config.location.entity.Location;
18 16 import org.jeecg.modules.wms.config.location.service.ILocationService;
19   -import lombok.extern.slf4j.Slf4j;
20   -
  17 +import org.jeecg.modules.wms.config.locationMonitor.entity.LocationStatus;
21 18 import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail;
22 19 import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService;
23   -import org.jeecg.modules.wms.config.locationMonitor.entity.LocationStatus;
24 20 import org.jeecg.utils.HuahengJwtUtil;
25 21 import org.jeecg.utils.StringUtils;
26 22 import org.jeecg.utils.constant.QuantityConstant;
27 23 import org.springframework.beans.factory.annotation.Autowired;
28 24 import org.springframework.web.bind.annotation.*;
  25 +
  26 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  27 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  28 +
29 29 import io.swagger.annotations.Api;
  30 +import lombok.extern.slf4j.Slf4j;
30 31  
31 32 /**
32 33 * @Description: 库存监控
33   - * @Author: lty
34   - * @Date: 2023/1/29
  34 + * @Author: lty
  35 + * @Date: 2023/1/29
35 36 */
36 37 @Api(tags = "库存监控")
37 38 @RestController
... ... @@ -45,7 +46,6 @@ public class LocationMonitorController {
45 46 @Resource
46 47 private IInventoryDetailService inventoryDetailService;
47 48  
48   -
49 49 /**
50 50 * 库存概括
51 51 */
... ... @@ -54,25 +54,24 @@ public class LocationMonitorController {
54 54 public Result getStatus(String zoneCode) {
55 55 HashMap<String, Integer> map = new HashMap<>();
56 56 LambdaQueryWrapper<Location> queryWrapper = Wrappers.lambdaQuery();
57   - queryWrapper.select(Location::getStatus,Location::getContainerCode).eq(Location::getZoneCode, zoneCode);
  57 + queryWrapper.select(Location::getStatus, Location::getContainerCode).eq(Location::getZoneCode, zoneCode);
58 58 List<Location> locationList = locationService.list(queryWrapper);
59 59 map.put("location", locationList.size());
60   - //换stream进行数据拣选速度更快
61   - List<Location> emptyLocationList = locationList.stream().filter(
62   - t -> StringUtils.isEmpty(t.getContainerCode())).collect(Collectors.toList());
  60 + // 换stream进行数据拣选速度更快
  61 + List<Location> emptyLocationList = locationList.stream().filter(t -> StringUtils.isEmpty(t.getContainerCode())).collect(Collectors.toList());
63 62 map.put("emptyLocation", emptyLocationList.size());
64 63 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
65 64 containerLambdaQueryWrapper.select(Container::getCode, Container::getStatus);
66 65 List<Container> containerList = containerService.list();
67   - List<String> containerCodeList = containerList.stream().filter(t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)).map(Container::getCode).collect(Collectors.toList());
68   - List<Location> haveEmptyContainLocation = locationList.stream().filter(
69   - t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY) && StringUtils.isNotEmpty(t.getContainerCode())
70   - && containerCodeList.contains(t.getContainerCode())).collect(Collectors.toList());
  66 + List<String> containerCodeList =
  67 + containerList.stream().filter(t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)).map(Container::getCode).collect(Collectors.toList());
  68 + List<Location> haveEmptyContainLocation = locationList.stream().filter(t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)
  69 + && StringUtils.isNotEmpty(t.getContainerCode()) && containerCodeList.contains(t.getContainerCode())).collect(Collectors.toList());
71 70 map.put("haveContainLocation", haveEmptyContainLocation.size());
72   - List<String> containerCodeList1 = containerList.stream().filter(t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_SOME)).map(Container::getCode).collect(Collectors.toList());
73   - List<Location> haveInventoryLocationList = locationList.stream().filter(
74   - t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY) && StringUtils.isNotEmpty(t.getContainerCode())
75   - && containerCodeList1.contains(t.getContainerCode())).collect(Collectors.toList());
  71 + List<String> containerCodeList1 =
  72 + containerList.stream().filter(t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_SOME)).map(Container::getCode).collect(Collectors.toList());
  73 + List<Location> haveInventoryLocationList = locationList.stream().filter(t -> t.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)
  74 + && StringUtils.isNotEmpty(t.getContainerCode()) && containerCodeList1.contains(t.getContainerCode())).collect(Collectors.toList());
76 75 map.put("haveInventoryLocation", haveInventoryLocationList.size());
77 76 return Result.ok(map);
78 77 }
... ... @@ -87,18 +86,15 @@ public class LocationMonitorController {
87 86 return Result.error("type不能为空");
88 87 }
89 88 String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
90   - /* 查询库位信息*/
  89 + /* 查询库位信息 */
91 90 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
92   - locationLambdaQueryWrapper.eq(StringUtils.isNotEmpty(row), Location::getRow, row)
93   - .eq(StringUtils.isNotEmpty(line), Location::getIcolumn, line)
94   - .eq(StringUtils.isNotEmpty(layer), Location::getLayer, layer)
95   - .eq(StringUtils.isNotEmpty(grid), Location::getGrid, grid)
96   - .eq(Location::getWarehouseCode, warehouseCode)
97   - .eq(StringUtils.isNotEmpty(type), Location::getZoneCode, type);
  91 + locationLambdaQueryWrapper.eq(StringUtils.isNotEmpty(row), Location::getRow, row).eq(StringUtils.isNotEmpty(line), Location::getIcolumn, line)
  92 + .eq(StringUtils.isNotEmpty(layer), Location::getLayer, layer).eq(StringUtils.isNotEmpty(grid), Location::getGrid, grid)
  93 + .eq(Location::getWarehouseCode, warehouseCode).eq(StringUtils.isNotEmpty(type), Location::getZoneCode, type);
98 94 List<Location> locations = locationService.list(locationLambdaQueryWrapper);
99 95 List<Location> locationList = new ArrayList<>();
100 96  
101   - /* 查询库存明细*/
  97 + /* 查询库存明细 */
102 98 LambdaQueryWrapper<InventoryDetail> inventoryDetailLambda = Wrappers.lambdaQuery();
103 99 inventoryDetailLambda.eq(InventoryDetail::getWarehouseCode, warehouseCode);
104 100 List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(inventoryDetailLambda);
... ... @@ -111,8 +107,8 @@ public class LocationMonitorController {
111 107 inventoryDetail = inventoryDetail2;
112 108 }
113 109 }
114   - List<InventoryDetail> inventoryDetails = inventoryDetailList.stream().filter(inventoryDetail1 ->
115   - inventoryDetail1.getLocationCode().equals(location1.getCode())).collect(Collectors.toList());
  110 + List<InventoryDetail> inventoryDetails =
  111 + inventoryDetailList.stream().filter(inventoryDetail1 -> inventoryDetail1.getLocationCode().equals(location1.getCode())).collect(Collectors.toList());
116 112  
117 113 int locationAttribute = 0;
118 114 String status = location1.getStatus();
... ... @@ -151,24 +147,23 @@ public class LocationMonitorController {
151 147 }
152 148 }
153 149  
154   -
155 150 location1.setLocationAttribute(String.valueOf(locationAttribute));
156 151 locationList.add(location1);
157 152 }
158 153 return Result.ok(locations);
159 154 }
160 155  
161   -
162 156 /**
163 157 * 查询库位列表
164 158 */
165 159 @PostMapping("/getAllLocation")
166 160 @ResponseBody
167   - public Result getAllLocation(@RequestParam(name = "type") String type) {
  161 + public Result getAllLocation(@RequestParam(name = "type") String type, HttpServletRequest req) {
168 162 if (StringUtils.isEmpty(type)) {
169 163 return Result.error("type不能为空");
170 164 }
171   - return Result.ok(locationService.getAllLocation(type));
  165 + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
  166 + return Result.ok(locationService.getAllLocation(type, warehouseCode));
172 167 }
173 168  
174 169 }
... ...