修改工厂出入库数据导入校验

This commit is contained in:
furongxin 2024-08-14 17:14:14 +08:00
parent 4e25721d5d
commit 695bec0318

View File

@ -293,7 +293,7 @@ public class FactoryDataServiceImpl implements FactoryDataService {
//校验判断是否有不符合的原因 //校验判断是否有不符合的原因
Long factoryId = null; Long factoryId = null;
try { try {
factoryId = validateFactoryForCreate(data.getFactoryName(), data.getSizeName(), data.getDate(), type); factoryId = validateFactoryForCreate(data, type);
} catch (Exception ex) { } catch (Exception ex) {
respVO.getFailureUsernames().put(data.getFactoryName() + "-" + data.getDate(), ex.getMessage()); respVO.getFailureUsernames().put(data.getFactoryName() + "-" + data.getDate(), ex.getMessage());
@ -377,7 +377,11 @@ public class FactoryDataServiceImpl implements FactoryDataService {
return respVO; return respVO;
} }
private Long validateFactoryForCreate(String factoryName, String sizeName, LocalDate date, Integer type) { private Long validateFactoryForCreate(FactoryDataImportVO data, Integer type) {
String factoryName = data.getFactoryName();
String sizeName = data.getSizeName();
LocalDate date = data.getDate();
if (factoryName == null) { if (factoryName == null) {
throw exception(FACTORY_INFO_NOT_EXISTS); throw exception(FACTORY_INFO_NOT_EXISTS);
@ -390,10 +394,16 @@ public class FactoryDataServiceImpl implements FactoryDataService {
FactoryInfoDO factoryInfoDO = factoryInfoService.getFactoryByName(factoryName); FactoryInfoDO factoryInfoDO = factoryInfoService.getFactoryByName(factoryName);
List<Integer> dataType = new ArrayList<>(); List<Integer> dataType = new ArrayList<>();
if (type == 1) { if (data.getNum() != null && data.getDamageNum() != null) {
dataType = Arrays.asList(1,4); dataType = type == 1 ? Arrays.asList(1,4) : Arrays.asList(2,3);
} else if (type == 2) { }
dataType = Arrays.asList(2,3);
if (data.getNum() != null && data.getDamageNum() == null) {
dataType = type == 1 ? Collections.singletonList(4) : Collections.singletonList(2);
}
if (data.getNum() == null && data.getDamageNum() != null) {
dataType = type == 1 ? Collections.singletonList(1) : Collections.singletonList(3);
} }
// 获取 规格ID // 获取 规格ID