Commit 3fe568e7fb69cc0cb016e2880c705f1ec255668e

Authored by 肖超群
1 parent 80eba915

修复库位监控的问题

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