Commit edb4846f4d3cf72981f83983973ed0c6ae376d93

Authored by 肖超群
1 parent 81cf11ad

1. 生成任务,库存容器锁定

huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/IContainerService.java
... ... @@ -33,7 +33,7 @@ public interface IContainerService extends IService<Container> {
33 33 /**
34 34 * 判断系统是否已经有同样的库位号,如果有证明数据混乱了
35 35 */
36   - boolean havaLocationCodeByContainer(String locationCode, String warehouseCode);
  36 + boolean havaLocationCodeByContainer(String locationCode, String containerCode, String warehouseCode);
37 37  
38 38 List<Container> getContainerListByCodeList(List<String> containCodeList, String warehouseCode);
39 39 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java
... ... @@ -100,7 +100,7 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
100 100 }
101 101 boolean success = false;
102 102 if (StringUtils.isNotEmpty(locationCode)) {
103   - success = havaLocationCodeByContainer(locationCode, warehouseCode);
  103 + success = havaLocationCodeByContainer(locationCode, containerCode, warehouseCode);
104 104 if (success) {
105 105 throw new JeecgBootException("容器表已经存在这个库位号,不能再写入");
106 106 }
... ... @@ -133,9 +133,10 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
133 133 }
134 134  
135 135 @Override
136   - public boolean havaLocationCodeByContainer(String locationCode, String warehouseCode) {
  136 + public boolean havaLocationCodeByContainer(String locationCode, String containerCode, String warehouseCode) {
137 137 LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
138   - containerLambdaQueryWrapper.eq(Container::getLocationCode, locationCode).eq(Container::getWarehouseCode, warehouseCode);
  138 + containerLambdaQueryWrapper.eq(Container::getLocationCode, locationCode).ne(Container::getCode, containerCode).eq(Container::getWarehouseCode,
  139 + warehouseCode);
139 140 Container container = getOne(containerLambdaQueryWrapper);
140 141 if (container == null) {
141 142 return false;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/ILocationService.java
... ... @@ -54,7 +54,7 @@ public interface ILocationService extends IService&lt;Location&gt; {
54 54 /**
55 55 * 判断系统是否已经有同样的托盘号,如果有证明数据混乱了
56 56 */
57   - boolean havaContainerCodeInLocation(String containerCode, String warehouseCode);
  57 + boolean havaContainerCodeInLocation(String containerCode, String locationCode, String warehouseCode);
58 58  
59 59 List<Location> getContainerInLocation(String containerCode, String containerStatus, String locationCode, String warehouseCode);
60 60  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/location/service/impl/LocationServiceImpl.java
... ... @@ -114,7 +114,7 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
114 114 boolean success = false;
115 115 // 如果这个托盘号已经在库位表里,那么不能再写入
116 116 if (StringUtils.isNotEmpty(containerCode)) {
117   - success = havaContainerCodeInLocation(containerCode, warehouseCode);
  117 + success = havaContainerCodeInLocation(containerCode, locationCode, warehouseCode);
118 118 if (success) {
119 119 throw new JeecgBootException("库位表已经存在这个容器号,不能再写入");
120 120 }
... ... @@ -359,9 +359,9 @@ public class LocationServiceImpl extends ServiceImpl&lt;LocationMapper, Location&gt; i
359 359 }
360 360  
361 361 @Override
362   - public boolean havaContainerCodeInLocation(String containerCode, String warehouseCode) {
  362 + public boolean havaContainerCodeInLocation(String containerCode, String locationCode, String warehouseCode) {
363 363 LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
364   - locationLambdaQueryWrapper.eq(Location::getContainerCode, containerCode).eq(Location::getWarehouseCode, warehouseCode);
  364 + locationLambdaQueryWrapper.eq(Location::getContainerCode, containerCode).ne(Location::getCode, locationCode).eq(Location::getWarehouseCode, warehouseCode);
365 365 Location location = getOne(locationLambdaQueryWrapper);
366 366 if (location == null) {
367 367 return false;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryHeaderService.java
1 1 package org.jeecg.modules.wms.inventory.inventoryHeader.service;
2 2  
3   -import com.alipay.api.domain.Inventory;
4   -import com.baomidou.mybatisplus.extension.service.IService;
5   -import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryHeader;
6   -import org.springframework.beans.factory.annotation.Autowired;
7 3 import java.io.Serializable;
8 4 import java.util.Collection;
9   -import java.util.List;
  5 +
  6 +import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryHeader;
  7 +
  8 +import com.baomidou.mybatisplus.extension.service.IService;
10 9  
11 10 /**
12 11 * @Description: 库存表
... ... @@ -27,4 +26,6 @@ public interface IInventoryHeaderService extends IService&lt;InventoryHeader&gt; {
27 26 public void delBatchMain(Collection<? extends Serializable> idList);
28 27  
29 28 InventoryHeader getInventoryHeaderByContainerCode(String containerCode, String warehouseCode);
  29 +
  30 + boolean updateInventoryContainerStatusByContainerCode(String containerCode, String warehouseCode);
30 31 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryHeaderServiceImpl.java
1 1 package org.jeecg.modules.wms.inventory.inventoryHeader.service.impl;
2 2  
3   -import com.alipay.api.domain.Inventory;
4   -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
5   -import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  3 +import java.io.Serializable;
  4 +import java.util.Collection;
  5 +
  6 +import javax.annotation.Resource;
  7 +
  8 +import org.jeecg.modules.wms.config.container.entity.Container;
  9 +import org.jeecg.modules.wms.config.container.service.IContainerService;
6 10 import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryHeader;
7 11 import org.jeecg.modules.wms.inventory.inventoryHeader.mapper.InventoryDetailMapper;
8 12 import org.jeecg.modules.wms.inventory.inventoryHeader.mapper.InventoryHeaderMapper;
9 13 import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryHeaderService;
10   -import org.springframework.stereotype.Service;
11   -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
12 14 import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Service;
13 16 import org.springframework.transaction.annotation.Transactional;
14   -import java.io.Serializable;
15   -import java.lang.ref.WeakReference;
16   -import java.util.List;
17   -import java.util.Collection;
  17 +
  18 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  19 +import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  20 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
18 21  
19 22 /**
20 23 * @Description: 库存表
... ... @@ -29,6 +32,10 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
29 32 private InventoryHeaderMapper inventoryHeaderMapper;
30 33 @Autowired
31 34 private InventoryDetailMapper inventoryDetailMapper;
  35 + @Resource
  36 + private IContainerService containerService;
  37 + @Resource
  38 + private IInventoryHeaderService inventoryHeaderService;
32 39  
33 40 @Override
34 41 @Transactional
... ... @@ -54,4 +61,19 @@ public class InventoryHeaderServiceImpl extends ServiceImpl&lt;InventoryHeaderMappe
54 61 return inventoryHeader;
55 62 }
56 63  
  64 + @Override
  65 + public boolean updateInventoryContainerStatusByContainerCode(String containerCode, String warehouseCode) {
  66 + Container container = containerService.getContainerByCode(containerCode, warehouseCode);
  67 + if (container == null) {
  68 + return false;
  69 + }
  70 + InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode);
  71 + if (inventoryHeader != null) {
  72 + inventoryHeader.setContainerStatus(container.getStatus());
  73 + boolean success = inventoryHeaderService.updateById(inventoryHeader);
  74 + return success;
  75 + }
  76 + return false;
  77 + }
  78 +
57 79 }
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/impl/ReceiptContainerHeaderServiceImpl.java
... ... @@ -9,10 +9,12 @@ import java.util.stream.Collectors;
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.container.entity.Container;
13 14 import org.jeecg.modules.wms.config.container.service.IContainerService;
14 15 import org.jeecg.modules.wms.config.location.entity.Location;
15 16 import org.jeecg.modules.wms.config.location.service.ILocationService;
  17 +import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryHeaderService;
16 18 import org.jeecg.modules.wms.receipt.receiptContainerHeader.entity.ReceiptContainerDetail;
17 19 import org.jeecg.modules.wms.receipt.receiptContainerHeader.entity.ReceiptContainerHeader;
18 20 import org.jeecg.modules.wms.receipt.receiptContainerHeader.mapper.ReceiptContainerDetailMapper;
... ... @@ -33,7 +35,6 @@ import org.springframework.stereotype.Service;
33 35 import org.springframework.transaction.annotation.Transactional;
34 36  
35 37 import com.alibaba.fastjson.JSON;
36   -import org.jeecg.common.exception.JeecgBootException;
37 38 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
38 39 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
39 40 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
... ... @@ -70,6 +71,8 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl&lt;ReceiptContai
70 71 private IReceiptDetailService receiptDetailService;
71 72 @Resource
72 73 private IReceiptHeaderService receiptHeaderService;
  74 + @Resource
  75 + private IInventoryHeaderService inventoryHeaderService;
73 76  
74 77 @Override
75 78 @Transactional
... ... @@ -208,6 +211,12 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl&lt;ReceiptContai
208 211 if (!success) {
209 212 throw new JeecgBootException("生成任务时,更新入库组盘头失败");
210 213 }
  214 + if (receiptContainerHeader.getTaskType() == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) {
  215 + success = inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode);
  216 + if (!success) {
  217 + throw new JeecgBootException("生成任务时, 更新库存头失败");
  218 + }
  219 + }
211 220 success = receiptDetailService.updateBatchById(receiptDetailList);
212 221 if (!success) {
213 222 throw new JeecgBootException("更新入库单明细失败");
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
... ... @@ -15,7 +15,6 @@ import org.jeecg.modules.wms.config.material.entity.Material;
15 15 import org.jeecg.modules.wms.config.material.service.IMaterialService;
16 16 import org.jeecg.modules.wms.config.parameterConfiguration.service.IParameterConfigurationService;
17 17 import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryDetail;
18   -import org.jeecg.modules.wms.inventory.inventoryHeader.entity.InventoryHeader;
19 18 import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryDetailService;
20 19 import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryHeaderService;
21 20 import org.jeecg.modules.wms.receipt.receiptContainerHeader.entity.ReceiptContainerHeader;
... ... @@ -41,6 +40,7 @@ import org.springframework.stereotype.Service;
41 40 import org.springframework.transaction.annotation.Transactional;
42 41  
43 42 import com.alibaba.fastjson.JSON;
  43 +import com.aliyun.oss.ServiceException;
44 44 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
45 45 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
46 46  
... ... @@ -342,7 +342,9 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
342 342 if (shipmentContainerHeader != null) {
343 343 if (taskType != shipmentContainerHeader.getTaskType()) {
344 344 shipmentContainerHeader.setTaskType(taskType);
345   - shipmentContainerHeaderService.updateById(shipmentContainerHeader);
  345 + if (!shipmentContainerHeaderService.updateById(shipmentContainerHeader)) {
  346 + throw new ServiceException("更新出库组盘头任务类型失败");
  347 + }
346 348 }
347 349 } else {
348 350 shipmentContainerHeader = new ShipmentContainerHeader();
... ... @@ -560,13 +562,9 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
560 562 if (!success) {
561 563 throw new JeecgBootException("生成出库任务时, 更新出库组盘头失败");
562 564 }
563   - InventoryHeader inventoryHeader = inventoryHeaderService.getInventoryHeaderByContainerCode(containerCode, warehouseCode);
564   - if (inventoryHeader != null) {
565   - inventoryHeader.setContainerStatus(container.getStatus());
566   - success = inventoryHeaderService.updateById(inventoryHeader);
567   - if (!success) {
568   - throw new JeecgBootException("生成出库任务时, 更新库存头失败");
569   - }
  565 + success = inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode);
  566 + if (!success) {
  567 + throw new JeecgBootException("生成出库任务时, 更新库存头失败");
570 568 }
571 569 LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集
572 570 LogRecordContext.putVariable("shipmentContainerDetailList", shipmentContainerDetailList);// 操作日志收集
... ...