BUG-erp库位重复编码优化异常抛出
This commit is contained in:
@@ -22,10 +22,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static com.zt.plat.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
@@ -56,18 +53,18 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
|||||||
// 插入
|
// 插入
|
||||||
ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class);
|
ErpWarehouseDO warehouse = BeanUtils.toBean(createReqVO, ErpWarehouseDO.class);
|
||||||
// 库位编码自动生成,格式 KW-0001,依次新增
|
// 库位编码自动生成,格式 KW-0001,依次新增
|
||||||
if (warehouse.getNumber() == null) {
|
// if (warehouse.getNumber() == null) {
|
||||||
String maxCode = erpWarehouseMapper.selectMaxCode();
|
// String maxCode = erpWarehouseMapper.selectMaxCode();
|
||||||
if (maxCode == null) {
|
// if (maxCode == null) {
|
||||||
warehouse.setNumber("KW-0001");
|
// warehouse.setNumber("KW-0001");
|
||||||
} else {
|
// } else {
|
||||||
String prefix = "KW-";
|
// String prefix = "KW-";
|
||||||
String numberPart = maxCode.substring(prefix.length());
|
// String numberPart = maxCode.substring(prefix.length());
|
||||||
int nextNumber = Integer.parseInt(numberPart) + 1;
|
// int nextNumber = Integer.parseInt(numberPart) + 1;
|
||||||
String nextCode = prefix + String.format("%04d", nextNumber);
|
// String nextCode = prefix + String.format("%04d", nextNumber);
|
||||||
warehouse.setNumber(nextCode);
|
// warehouse.setNumber(nextCode);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
warehouse.setType("SPLY");
|
warehouse.setType("SPLY");
|
||||||
warehouse.setIsEnable("1");
|
warehouse.setIsEnable("1");
|
||||||
erpWarehouseMapper.insert(warehouse);
|
erpWarehouseMapper.insert(warehouse);
|
||||||
@@ -120,7 +117,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
|||||||
private void validateErpFactoryExistsNumber(String number, String factoryNumber) {
|
private void validateErpFactoryExistsNumber(String number, String factoryNumber) {
|
||||||
List<ErpWarehouseDO> list = erpWarehouseMapper.selectList(new LambdaQueryWrapperX<ErpWarehouseDO>()).stream()
|
List<ErpWarehouseDO> list = erpWarehouseMapper.selectList(new LambdaQueryWrapperX<ErpWarehouseDO>()).stream()
|
||||||
.filter(erpWarehouseDO -> erpWarehouseDO.getNumber().equals(number))
|
.filter(erpWarehouseDO -> erpWarehouseDO.getNumber().equals(number))
|
||||||
.filter(erpWarehouseDO -> erpWarehouseDO.getFactoryNumber().equals(factoryNumber))
|
.filter(erpWarehouseDO -> Objects.equals(erpWarehouseDO.getFactoryNumber(), factoryNumber))
|
||||||
.toList();
|
.toList();
|
||||||
if (!list.isEmpty()) {
|
if (!list.isEmpty()) {
|
||||||
throw exception(ERP_WAREHOUSE_EXISTS);
|
throw exception(ERP_WAREHOUSE_EXISTS);
|
||||||
|
|||||||
Reference in New Issue
Block a user