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.validation.annotation.Validated;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
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);
|
||||
// 库位编码自动生成,格式 KW-0001,依次新增
|
||||
if (warehouse.getNumber() == null) {
|
||||
String maxCode = erpWarehouseMapper.selectMaxCode();
|
||||
if (maxCode == null) {
|
||||
warehouse.setNumber("KW-0001");
|
||||
} else {
|
||||
String prefix = "KW-";
|
||||
String numberPart = maxCode.substring(prefix.length());
|
||||
int nextNumber = Integer.parseInt(numberPart) + 1;
|
||||
String nextCode = prefix + String.format("%04d", nextNumber);
|
||||
warehouse.setNumber(nextCode);
|
||||
}
|
||||
}
|
||||
// if (warehouse.getNumber() == null) {
|
||||
// String maxCode = erpWarehouseMapper.selectMaxCode();
|
||||
// if (maxCode == null) {
|
||||
// warehouse.setNumber("KW-0001");
|
||||
// } else {
|
||||
// String prefix = "KW-";
|
||||
// String numberPart = maxCode.substring(prefix.length());
|
||||
// int nextNumber = Integer.parseInt(numberPart) + 1;
|
||||
// String nextCode = prefix + String.format("%04d", nextNumber);
|
||||
// warehouse.setNumber(nextCode);
|
||||
// }
|
||||
// }
|
||||
warehouse.setType("SPLY");
|
||||
warehouse.setIsEnable("1");
|
||||
erpWarehouseMapper.insert(warehouse);
|
||||
@@ -120,7 +117,7 @@ public class ErpWarehouseServiceImpl implements ErpWarehouseService {
|
||||
private void validateErpFactoryExistsNumber(String number, String factoryNumber) {
|
||||
List<ErpWarehouseDO> list = erpWarehouseMapper.selectList(new LambdaQueryWrapperX<ErpWarehouseDO>()).stream()
|
||||
.filter(erpWarehouseDO -> erpWarehouseDO.getNumber().equals(number))
|
||||
.filter(erpWarehouseDO -> erpWarehouseDO.getFactoryNumber().equals(factoryNumber))
|
||||
.filter(erpWarehouseDO -> Objects.equals(erpWarehouseDO.getFactoryNumber(), factoryNumber))
|
||||
.toList();
|
||||
if (!list.isEmpty()) {
|
||||
throw exception(ERP_WAREHOUSE_EXISTS);
|
||||
|
||||
Reference in New Issue
Block a user