Commit 87fc18e2047148d5478c021347b695133edbb6e2
1 parent
966a5b27
update判断
Showing
7 changed files
with
63 additions
and
25 deletions
src/main/java/com/huaheng/api/wcs/service/overrideHandle/OverrideHandleServiceImpl.java
... | ... | @@ -166,7 +166,9 @@ public class OverrideHandleServiceImpl implements OverrideHandleService { |
166 | 166 | if (StringUtils.isEmpty(newLocationCode)) { |
167 | 167 | return AjaxResult.error("没有库位可以分配"); |
168 | 168 | } |
169 | - locationService.updateStatus(newLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
169 | + if (!locationService.updateStatus(newLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode)) { | |
170 | + throw new ServiceException("更新库位状态失败"); | |
171 | + } | |
170 | 172 | String toLocationCode = taskHeader.getToLocation(); |
171 | 173 | |
172 | 174 | //修改任务 |
... | ... |
src/main/java/com/huaheng/api/wcs/service/warecellAllocation/WarecellAllocationServiceImpl.java
... | ... | @@ -106,7 +106,7 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
106 | 106 | * @return |
107 | 107 | */ |
108 | 108 | @Override |
109 | - @Transactional(rollbackFor = Exception.class) | |
109 | + @Transactional | |
110 | 110 | public AjaxResult warecellAllocation(WcsTask wcsTask) { |
111 | 111 | //1、判断非空字段 |
112 | 112 | if (StringUtils.isEmpty(wcsTask.getTaskNo())) { |
... | ... | @@ -211,13 +211,14 @@ public class WarecellAllocationServiceImpl implements WarecellAllocationService |
211 | 211 | if (StringUtils.isEmpty(locationCode)) { |
212 | 212 | return AjaxResult.error("没有库位可分配"); |
213 | 213 | } |
214 | - | |
215 | - locationService.updateStatus(locationCode, | |
216 | - QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
217 | - if (StringUtils.isNotEmpty(taskHeader.getToLocation()) && | |
218 | - !locationCode.equals(taskHeader.getToLocation())) { | |
219 | - locationService.updateStatus(taskHeader.getToLocation(), | |
220 | - QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); | |
214 | + | |
215 | + if (!locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode)) { | |
216 | + throw new ServiceException("更新库位状态失败"); | |
217 | + } | |
218 | + if (StringUtils.isNotEmpty(taskHeader.getToLocation()) && !locationCode.equals(taskHeader.getToLocation())) { | |
219 | + if (!locationService.updateStatus(taskHeader.getToLocation(), QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode)) { | |
220 | + throw new ServiceException("更新库位状态失败"); | |
221 | + } | |
221 | 222 | } |
222 | 223 | |
223 | 224 | if (receiptContainerDetailList != null && receiptContainerDetailList.size() > 0) { |
... | ... |
src/main/java/com/huaheng/pc/config/location/service/LocationService.java
... | ... | @@ -40,7 +40,7 @@ public interface LocationService extends IService<Location>{ |
40 | 40 | */ |
41 | 41 | void updateStatus(String locationCode, String status); |
42 | 42 | |
43 | - void updateStatus(String locationCode, String status, String warehouseCode); | |
43 | + boolean updateStatus(String locationCode, String status, String warehouseCode); | |
44 | 44 | |
45 | 45 | /** |
46 | 46 | * 通过定位规则查找库位 |
... | ... |
src/main/java/com/huaheng/pc/config/location/service/LocationServiceImpl.java
... | ... | @@ -20,6 +20,7 @@ import com.huaheng.pc.config.zone.domain.Zone; |
20 | 20 | import com.huaheng.pc.config.zone.service.ZoneService; |
21 | 21 | import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; |
22 | 22 | import org.springframework.stereotype.Service; |
23 | +import org.springframework.transaction.annotation.Transactional; | |
23 | 24 | |
24 | 25 | import javax.annotation.Resource; |
25 | 26 | import java.text.MessageFormat; |
... | ... | @@ -322,17 +323,36 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i |
322 | 323 | * @param status |
323 | 324 | */ |
324 | 325 | @Override |
326 | + @Transactional | |
325 | 327 | public void updateStatus(String locationCode, String status) { |
326 | 328 | if (StringUtils.isNotEmpty(locationCode)) { |
327 | - locationMapper.updateStatus("CS0001", locationCode, status); | |
329 | +// locationMapper.updateStatus("CS0001", locationCode, status); | |
330 | + LambdaUpdateWrapper<Location> locationLambdaUpdateWrapper=Wrappers.lambdaUpdate(); | |
331 | + locationLambdaUpdateWrapper | |
332 | + .ne(Location::getStatus,status) | |
333 | + .eq(Location::getCode,locationCode) | |
334 | + .eq(Location::getWarehouseCode,"CS0001") | |
335 | + .set(Location::getStatus,status); | |
336 | + if (!locationService.update(locationLambdaUpdateWrapper)) { | |
337 | + throw new ServiceException("更新库位状态失败"); | |
338 | + } | |
328 | 339 | } |
329 | 340 | } |
330 | 341 | |
331 | 342 | @Override |
332 | - public void updateStatus(String locationCode, String status, String warehouseCode) { | |
343 | + @Transactional | |
344 | + public boolean updateStatus(String locationCode, String status, String warehouseCode) { | |
333 | 345 | if (StringUtils.isNotEmpty(locationCode)) { |
334 | - locationMapper.updateStatus(warehouseCode, locationCode, status); | |
346 | +// locationMapper.updateStatus(warehouseCode, locationCode, status); | |
347 | + LambdaUpdateWrapper<Location> locationLambdaUpdateWrapper=Wrappers.lambdaUpdate(); | |
348 | + locationLambdaUpdateWrapper | |
349 | + .ne(Location::getStatus,status) | |
350 | + .eq(Location::getCode,locationCode) | |
351 | + .eq(Location::getWarehouseCode,warehouseCode) | |
352 | + .set(Location::getStatus,status); | |
353 | + return locationService.update(locationLambdaUpdateWrapper); | |
335 | 354 | } |
355 | + return false; | |
336 | 356 | } |
337 | 357 | |
338 | 358 | /** |
... | ... | @@ -356,8 +376,9 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i |
356 | 376 | updateWrapper.set(Location::getContainerCode, containerCode) |
357 | 377 | .set(Location::getStatus, status) |
358 | 378 | .eq(Location::getWarehouseCode, "CS0001") |
359 | - .eq(Location::getCode, locationCode); | |
360 | - this.update(updateWrapper); | |
379 | + .eq(Location::getCode, locationCode) | |
380 | + .ne(Location::getStatus,status); | |
381 | + locationService.update(updateWrapper); | |
361 | 382 | } |
362 | 383 | } |
363 | 384 | |
... | ... | @@ -369,8 +390,9 @@ public class LocationServiceImpl extends ServiceImpl<LocationMapper, Location> i |
369 | 390 | updateWrapper.set(Location::getContainerCode, containerCode) |
370 | 391 | .set(Location::getStatus, status) |
371 | 392 | .eq(Location::getWarehouseCode, warehouseCode) |
372 | - .eq(Location::getCode, locationCode); | |
373 | - this.update(updateWrapper); | |
393 | + .eq(Location::getCode, locationCode) | |
394 | + .ne(Location::getStatus,status); | |
395 | + locationService.update(updateWrapper); | |
374 | 396 | } |
375 | 397 | } public LocationInfo getAllLocation(String type) { |
376 | 398 | if (StringUtils.isNotEmpty(type)) { |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/CycleCountTaskService.java
... | ... | @@ -344,8 +344,9 @@ public class CycleCountTaskService { |
344 | 344 | //更新主单状态 |
345 | 345 | cycleCountHeaderService.updataHeaderStatus(cycleCountDetail.getCycleCountHeadCode()); |
346 | 346 | //释放库位 |
347 | - locationService.updateStatus(cycleCountDetail.getLocationCode(), | |
348 | - QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode); | |
347 | + if (!locationService.updateStatus(cycleCountDetail.getLocationCode(), QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode)) { | |
348 | + throw new ServiceException("更新库位状态失败"); | |
349 | + } | |
349 | 350 | |
350 | 351 | return AjaxResult.success("完成盘点任务成功!"); |
351 | 352 | |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/TransferTaskService.java
... | ... | @@ -155,8 +155,12 @@ public class TransferTaskService { |
155 | 155 | |
156 | 156 | |
157 | 157 | if (taskHeaderService.save(taskHeader)) { |
158 | - locationService.updateStatus(sourceLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
159 | - locationService.updateStatus(desLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
158 | + if (!locationService.updateStatus(sourceLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode)) { | |
159 | + throw new ServiceException("更新库位状态失败"); | |
160 | + } | |
161 | + if (!locationService.updateStatus(desLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode)) { | |
162 | + throw new ServiceException("更新库位状态失败"); | |
163 | + } | |
160 | 164 | containerService.updateLocationCodeAndStatus(sourceLocation.getContainerCode(), |
161 | 165 | sourceLocationCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); |
162 | 166 | } else { |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/WorkTaskService.java
... | ... | @@ -234,7 +234,9 @@ public class WorkTaskService { |
234 | 234 | } |
235 | 235 | //锁库位 |
236 | 236 | if (StringUtils.isNotEmpty(destinationLocation)) { |
237 | - locationService.updateStatus(destinationLocation, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
237 | + if (!locationService.updateStatus(destinationLocation, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode)) { | |
238 | + throw new ServiceException("更新库位状态失败!"); | |
239 | + } | |
238 | 240 | } |
239 | 241 | WcsTask wcsTask = new WcsTask(); |
240 | 242 | wcsTask.setTaskType(taskHeader.getTaskType()); |
... | ... | @@ -394,7 +396,9 @@ public class WorkTaskService { |
394 | 396 | taskHeader.setPort(port); |
395 | 397 | if(taskHeaderService.save(taskHeader)){ |
396 | 398 | //锁定库位状态 |
397 | - locationService.updateStatus(locationCode,QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
399 | + if (!locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode)) { | |
400 | + throw new ServiceException("更新库位状态失败!"); | |
401 | + } | |
398 | 402 | LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery(); |
399 | 403 | containerLambdaQueryWrapper.eq(Container::getCode, conCode); |
400 | 404 | Container container = containerService.getOne(containerLambdaQueryWrapper); |
... | ... | @@ -580,7 +584,9 @@ public class WorkTaskService { |
580 | 584 | throw new ServiceException("空托出库主表生成失败!"); |
581 | 585 | } |
582 | 586 | //锁定库位状态 |
583 | - locationService.updateStatus(locationCode,QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
587 | + if (!locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode)) { | |
588 | + throw new ServiceException("更新库位状态失败!"); | |
589 | + } | |
584 | 590 | Container container = containerService.getContainerByCode(containerCode, warehouseCode); |
585 | 591 | container.setStatus(QuantityConstant.STATUS_CONTAINER_LOCK); |
586 | 592 | containerService.updateById(container); |
... | ... | @@ -904,7 +910,9 @@ public class WorkTaskService { |
904 | 910 | throw new ServiceException("空托出库主表生成失败!"); |
905 | 911 | } |
906 | 912 | //锁定库位状态 |
907 | - locationService.updateStatus(locationCode,QuantityConstant.STATUS_LOCATION_LOCK, ShiroUtils.getWarehouseCode()); | |
913 | + if (!locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK, ShiroUtils.getWarehouseCode())) { | |
914 | + throw new ServiceException("更新库位状态失败!"); | |
915 | + } | |
908 | 916 | containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, ShiroUtils.getWarehouseCode()); |
909 | 917 | |
910 | 918 | return AjaxResult.success(taskHeader.getId()); |
... | ... |