Commit f6706f579860e3608b014096e3df4ada0d3fb7f9

Authored by 谭毅彬
1 parent 7d881f7c

托盘库位service方法优化

Signed-off-by: TanYibin <5491541@qq.com>
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java
... ... @@ -6,6 +6,7 @@ import java.util.Calendar;
6 6 import java.util.List;
7 7  
8 8 import javax.annotation.Resource;
  9 +import javax.transaction.Transactional;
9 10  
10 11 import org.jeecg.common.api.vo.Result;
11 12 import org.jeecg.common.exception.JeecgBootException;
... ... @@ -15,6 +16,7 @@ import org.jeecg.modules.wms.config.container.service.IContainerService;
15 16 import org.jeecg.modules.wms.config.containerType.service.IContainerTypeService;
16 17 import org.jeecg.utils.StringUtils;
17 18 import org.jeecg.utils.constant.QuantityConstant;
  19 +import org.springframework.beans.factory.annotation.Autowired;
18 20 import org.springframework.stereotype.Service;
19 21  
20 22 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
... ... @@ -33,10 +35,15 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
33 35  
34 36 @Resource
35 37 IContainerTypeService containerTypeService;
  38 +
36 39 @Resource
37 40 ContainerMapper containerMapper;
38 41  
  42 + @Autowired
  43 + IContainerService containerService;
  44 +
39 45 @Override
  46 + @Transactional
40 47 public Result<?> batchAddContainers(Container container, int number) {
41 48 String containerTypeCode = container.getContainerTypeCode();
42 49 String warehouseCode = container.getWarehouseCode();
... ... @@ -44,16 +51,16 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
44 51 List<Container> containerList = new ArrayList<>();
45 52 for (int i = 0; i < number; i++) {
46 53 startNumber++;
47   - Container container1 = new Container();
48   - container1.setContainerTypeCode(containerTypeCode);
  54 + Container addcontainer = new Container();
  55 + addcontainer.setContainerTypeCode(containerTypeCode);
49 56 String code = String.format("%s%05d", containerTypeCode, startNumber);
50   - container1.setCode(code);
51   - container1.setStatus(QuantityConstant.STATUS_CONTAINER_EMPTY);
52   - container1.setFillStatus(QuantityConstant.STATUS_CONTAINER_FILL_EMPTY);
53   - container1.setWarehouseCode(warehouseCode);
54   - containerList.add(container1);
  57 + addcontainer.setCode(code);
  58 + addcontainer.setStatus(QuantityConstant.STATUS_CONTAINER_EMPTY);
  59 + addcontainer.setFillStatus(QuantityConstant.STATUS_CONTAINER_FILL_EMPTY);
  60 + addcontainer.setWarehouseCode(warehouseCode);
  61 + containerList.add(addcontainer);
55 62 }
56   - boolean success = saveBatch(containerList);
  63 + boolean success = containerService.saveBatch(containerList);
57 64 if (success) {
58 65 return Result.OK("添加成功!");
59 66 }
... ... @@ -67,19 +74,21 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
67 74 }
68 75 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
69 76 containerLambdaQueryWrapper.eq(Container::getCode, containCode).eq(Container::getWarehouseCode, warehouseCode);
70   - Container container = this.getOne(containerLambdaQueryWrapper);
  77 + Container container = containerService.getOne(containerLambdaQueryWrapper);
71 78 return container;
72 79 }
73 80  
74 81 @Override
  82 + @Transactional
75 83 public boolean updateStatus(String containerCode, String status, String warehouseCode) {
76 84 LambdaUpdateWrapper<Container> updateWrapper = Wrappers.lambdaUpdate();
77 85 updateWrapper.ne(Container::getStatus, status).eq(Container::getCode, containerCode).eq(Container::getWarehouseCode, warehouseCode).set(Container::getStatus,
78 86 status);
79   - return update(updateWrapper);
  87 + return containerService.update(updateWrapper);
80 88 }
81 89  
82 90 @Override
  91 + @Transactional
83 92 public boolean updateLocationCodeAndStatus(String containerCode, String locationCode, String status, String warehouseCode) {
84 93 if (StringUtils.isNotEmpty(locationCode)) {
85 94 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
... ... @@ -93,15 +102,16 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
93 102 LambdaUpdateWrapper<Container> updateWrapper = Wrappers.lambdaUpdate();
94 103 updateWrapper.ne(Container::getStatus, status).eq(Container::getCode, containerCode).eq(Container::getWarehouseCode, warehouseCode)
95 104 .set(Container::getLocationCode, locationCode).set(Container::getStatus, status);
96   - return update(updateWrapper);
  105 + return containerService.update(updateWrapper);
97 106 }
98 107  
99 108 @Override
  109 + @Transactional
100 110 public boolean updateLocationCodeAndStatus(String containerCode, String locationCode, String status, String fillStatus, String warehouseCode) {
101 111 LambdaUpdateWrapper<Container> updateWrapper = Wrappers.lambdaUpdate();
102 112 updateWrapper.ne(Container::getStatus, status).eq(Container::getCode, containerCode).eq(Container::getWarehouseCode, warehouseCode)
103 113 .set(Container::getLocationCode, locationCode).set(Container::getStatus, status).set(Container::getFillStatus, fillStatus);
104   - return update(updateWrapper);
  114 + return containerService.update(updateWrapper);
105 115 }
106 116  
107 117 @Override
... ... @@ -122,16 +132,14 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
122 132 public List<Container> getContainerListByStatus(String status, String warehouseCode) {
123 133 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
124 134 containerLambdaQueryWrapper.eq(Container::getStatus, status).eq(Container::getWarehouseCode, warehouseCode);
125   - List<Container> containerList = list(containerLambdaQueryWrapper);
126   - return containerList;
  135 + return list(containerLambdaQueryWrapper);
127 136 }
128 137  
129 138 @Override
130 139 public List<Container> getContainerListByCodeList(List<String> containerCodeList, String warehouseCode) {
131 140 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
132 141 containerLambdaQueryWrapper.in(Container::getCode, containerCodeList).eq(Container::getWarehouseCode, warehouseCode);
133   - List<Container> containerList = list(containerLambdaQueryWrapper);
134   - return containerList;
  142 + return list(containerLambdaQueryWrapper);
135 143 }
136 144  
137 145 private int getStartNumber(String containerTypeCode, String warehouseCode) {
... ... @@ -141,11 +149,9 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
141 149 Container container = this.getOne(containerLambdaQueryWrapper);
142 150 // 如果指定类型的最后的code存在,那么 code = 容器类型 + (排序号 + 1)
143 151 if (container != null && container.getCode() != null) {
144   - Integer number = Integer.valueOf(container.getCode().substring(container.getCode().length() - 5, container.getCode().length()));
145   - return number;
146   - } else {
147   - return 0;
  152 + return Integer.valueOf(container.getCode().substring(container.getCode().length() - 5, container.getCode().length()));
148 153 }
  154 + return 0;
149 155 }
150 156  
151 157 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java
1 1 package org.jeecg.modules.wms.config.location.service.impl;
2 2  
3 3 import java.text.MessageFormat;
4   -import java.util.*;
  4 +import java.util.ArrayList;
  5 +import java.util.Collections;
  6 +import java.util.Comparator;
  7 +import java.util.HashMap;
  8 +import java.util.HashSet;
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +import java.util.Set;
5 12 import java.util.function.Function;
6 13 import java.util.stream.Collectors;
7 14  
... ... @@ -13,7 +20,15 @@ import org.jeecg.common.exception.JeecgBootException;
13 20 import org.jeecg.modules.wms.config.address.service.IAddressService;
14 21 import org.jeecg.modules.wms.config.container.entity.Container;
15 22 import org.jeecg.modules.wms.config.container.service.IContainerService;
16   -import org.jeecg.modules.wms.config.location.dto.*;
  23 +import org.jeecg.modules.wms.config.location.dto.CompareContainerTaskDto;
  24 +import org.jeecg.modules.wms.config.location.dto.CompareLocationDto;
  25 +import org.jeecg.modules.wms.config.location.dto.CompareLocationTaskDto;
  26 +import org.jeecg.modules.wms.config.location.dto.QueryCompareContainerTaskDto;
  27 +import org.jeecg.modules.wms.config.location.dto.QueryCompareLocationDto;
  28 +import org.jeecg.modules.wms.config.location.dto.QueryCompareLocationTaskDto;
  29 +import org.jeecg.modules.wms.config.location.dto.WcsLocationDto;
  30 +import org.jeecg.modules.wms.config.location.dto.WcsResultDto;
  31 +import org.jeecg.modules.wms.config.location.dto.WcsTaskDto;
17 32 import org.jeecg.modules.wms.config.location.entity.BatchLocation;
18 33 import org.jeecg.modules.wms.config.location.entity.Location;
19 34 import org.jeecg.modules.wms.config.location.entity.LocationInfo;
... ... @@ -31,6 +46,7 @@ import org.jeecg.utils.OkHttpUtils;
31 46 import org.jeecg.utils.PageUtil;
32 47 import org.jeecg.utils.StringUtils;
33 48 import org.jeecg.utils.constant.QuantityConstant;
  49 +import org.springframework.beans.factory.annotation.Autowired;
34 50 import org.springframework.stereotype.Service;
35 51 import org.springframework.transaction.annotation.Transactional;
36 52  
... ... @@ -76,6 +92,9 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
76 92  
77 93 @Resource
78 94 private IInventoryDetailService inventoryDetailService;
  95 +
  96 + @Autowired
  97 + private ILocationService locationService;
79 98  
80 99 @Override
81 100 public Location getLocationByCode(String locationCode, String warehouseCode) {
... ... @@ -85,8 +104,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
85 104 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
86 105 locationLambdaQueryWrapper.eq(Location::getCode, locationCode).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE).eq(Location::getWarehouseCode,
87 106 warehouseCode);
88   - Location location = this.getOne(locationLambdaQueryWrapper);
89   - return location;
  107 + return locationService.getOne(locationLambdaQueryWrapper);
90 108 }
91 109  
92 110 @Override
... ... @@ -94,8 +112,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
94 112 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
95 113 locationLambdaQueryWrapper.eq(Location::getRow, row).eq(Location::getIcolumn, column).eq(Location::getLayer, layer)
96 114 .eq(Location::getEnable, QuantityConstant.STATUS_ENABLE).eq(Location::getWarehouseCode, warehouseCode);
97   - Location location = this.getOne(locationLambdaQueryWrapper);
98   - return location;
  115 + return locationService.getOne(locationLambdaQueryWrapper);
99 116 }
100 117  
101 118 @Override
... ... @@ -103,16 +120,16 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
103 120 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
104 121 locationLambdaQueryWrapper.eq(Location::getZoneCode, zoneCode).eq(Location::getEnable, QuantityConstant.STATUS_ENABLE).eq(Location::getWarehouseCode,
105 122 warehouseCode);
106   - List<Location> locationList = this.list(locationLambdaQueryWrapper);
107   - return locationList;
  123 + return locationService.list(locationLambdaQueryWrapper);
108 124 }
109 125  
110 126 @Override
  127 + @Transactional
111 128 public boolean updateStatus(String locationCode, String status, String warehouseCode) {
112 129 LambdaUpdateWrapper<Location> updateWrapper = Wrappers.lambdaUpdate();
113 130 updateWrapper.ne(Location::getStatus, status).eq(Location::getCode, locationCode).eq(Location::getWarehouseCode, warehouseCode).set(Location::getStatus,
114 131 status);
115   - return update(updateWrapper);
  132 + return locationService.update(updateWrapper);
116 133 }
117 134  
118 135 /**
... ... @@ -120,6 +137,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
120 137 * 更新库位时,先判断库位状态是不一致的才能更新
121 138 */
122 139 @Override
  140 + @Transactional
123 141 public boolean updateContainerCodeAndStatus(String locationCode, String containerCode, String status, String warehouseCode) {
124 142 if (StringUtils.isNotEmpty(containerCode)) {
125 143 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
... ... @@ -133,19 +151,19 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
133 151 LambdaUpdateWrapper<Location> updateWrapper = Wrappers.lambdaUpdate();
134 152 updateWrapper.ne(Location::getStatus, status).eq(Location::getCode, locationCode).eq(Location::getWarehouseCode, warehouseCode)
135 153 .set(Location::getContainerCode, containerCode).set(Location::getStatus, status);
136   - return update(updateWrapper);
  154 + return locationService.update(updateWrapper);
137 155 }
138 156  
139 157 @Override
140 158 public Location getNear(Location location) {
141 159 int rowFlag = location.getRowFlag();
142   - Location locaiton1 = null;
  160 + Location nearlocaiton = null;
143 161 if (rowFlag == 1) {
144   - locaiton1 = getInsideNear(location);
  162 + nearlocaiton = getInsideNear(location);
145 163 } else {
146   - locaiton1 = getOutSideNear(location);
  164 + nearlocaiton = getOutSideNear(location);
147 165 }
148   - return locaiton1;
  166 + return nearlocaiton;
149 167 }
150 168  
151 169 @Override
... ... @@ -155,10 +173,9 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
155 173 .eq(Location::getRoadWay, location.getRoadWay()).eq(Location::getIcolumn, location.getIcolumn()).eq(Location::getLayer, location.getLayer())
156 174 .eq(Location::getLocationTypeCode, location.getLocationTypeCode()).eq(Location::getRowFlag, QuantityConstant.ROW_IN);
157 175 List<Location> locationList = list(locationLambdaQueryWrapper);
158   - for (Location location1 : locationList) {
159   - int diff = Math.abs(location1.getRow().intValue() - location.getRow().intValue());
160   - if (diff == 1) {
161   - return location1;
  176 + for (Location insideLocation : locationList) {
  177 + if (Math.abs(insideLocation.getRow().intValue() - location.getRow().intValue()) == 1) {
  178 + return insideLocation;
162 179 }
163 180 }
164 181 return null;
... ... @@ -171,10 +188,9 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
171 188 .eq(Location::getRoadWay, location.getRoadWay()).eq(Location::getIcolumn, location.getIcolumn()).eq(Location::getLayer, location.getLayer())
172 189 .eq(Location::getLocationTypeCode, location.getLocationTypeCode()).eq(Location::getRowFlag, QuantityConstant.ROW_OUT);
173 190 List<Location> locationList = list(locationLambdaQueryWrapper);
174   - for (Location location1 : locationList) {
175   - int diff = Math.abs(location1.getRow().intValue() - location.getRow().intValue());
176   - if (diff == 1) {
177   - return location1;
  191 + for (Location outSideLocation : locationList) {
  192 + if (Math.abs(outSideLocation.getRow().intValue() - location.getRow().intValue()) == 1) {
  193 + return outSideLocation;
178 194 }
179 195 }
180 196 return null;
... ... @@ -182,11 +198,11 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
182 198  
183 199 @Override
184 200 public Location getEmptyLocation(Location location) {
185   - Location location1 = getEmptyOutSideLocation(location);
186   - if (location1 == null) {
187   - location1 = getEmptyInsideLocation(location);
  201 + Location emptyLocation = getEmptyOutSideLocation(location);
  202 + if (emptyLocation == null) {
  203 + emptyLocation = getEmptyInsideLocation(location);
188 204 }
189   - return location1;
  205 + return emptyLocation;
190 206 }
191 207  
192 208 @Override
... ... @@ -194,8 +210,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
194 210 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
195 211 locationLambdaQueryWrapper.eq(Location::getRoadWay, roadWay).eq(Location::getWarehouseCode, warehouseCode)
196 212 .eq(Location::getStatus, QuantityConstant.STATUS_LOCATION_EMPTY).eq(Location::getContainerCode, QuantityConstant.EMPTY_STRING);
197   - int count = count(locationLambdaQueryWrapper);
198   - return count;
  213 + return locationService.count(locationLambdaQueryWrapper);
199 214 }
200 215  
201 216 @Override
... ... @@ -231,8 +246,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
231 246 if (locationList == null || locationList.size() <= 0) {
232 247 return null;
233 248 }
234   - Location location1 = locationList.get(0);
235   - return location1;
  249 + return locationList.get(0);
236 250 }
237 251  
238 252 @Override
... ... @@ -271,8 +285,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
271 285 if (locationList == null || locationList.size() <= 0) {
272 286 return null;
273 287 }
274   - Location location1 = locationList.get(0);
275   - return location1;
  288 + return locationList.get(0);
276 289 }
277 290  
278 291 @Override
... ... @@ -365,9 +378,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
365 378 }
366 379 }
367 380 }
368   -
369   - boolean success = saveBatch(locationList);
370   - if (!success) {
  381 + if (!locationService.saveBatch(locationList)) {
371 382 throw new JeecgBootException("批量增加库位失败");
372 383 }
373 384 return Result.ok("批量增加库位成功");
... ...