|
|
|
@ -108,6 +108,7 @@ import static com.spring.modules.part.task.PartRelatedTask.convertToSQLString; |
|
|
|
public class PartInformationServiceImpl extends ServiceImpl<PartInformationMapper, PartInformationEntity> implements PartInformationService { |
|
|
|
|
|
|
|
private static final int DRAWING_NO_SYNC_PART_PREFIX_LENGTH = 8; |
|
|
|
private static final List<String> PROJECT_PART_PRODUCT_CATEGORIES = Arrays.asList("Label", "Diecut", "Decoration", "Material"); |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private ProcedureDao procedureDao; |
|
|
|
@ -742,6 +743,7 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
data.setBaseNo(data.getPartNo().substring(0, a)); |
|
|
|
data.setRevNo(data.getPartNo().substring(a)); |
|
|
|
data.setVirtualPartNo(data.getPartNo()); |
|
|
|
validateProjectPartRequiredFields(data.getApplicationDesc(), data.getProductCategory(), null); |
|
|
|
partInformationMapper.saveProjectPart(data); |
|
|
|
// 新增客户料号信息 |
|
|
|
partInformationMapper.saveCustomerPartInfo(data); |
|
|
|
@ -1247,10 +1249,8 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
partInformationMapper.update(data, updateInformationWrapper); |
|
|
|
syncDrawingNoByPartPrefix(data); |
|
|
|
recordChangeRemark(data.getSite(), data.getPartNo(), data.getUpdateBy(), "用户编辑物料(项目页面)"); |
|
|
|
// 判断是否需要修改项目物料的BU |
|
|
|
if (StringUtils.hasText(data.getBuNo())) { |
|
|
|
partInformationMapper.updateProjectPartBuNo(data); |
|
|
|
} |
|
|
|
validateProjectPartRequiredFields(data.getApplicationDesc(), data.getProductCategory(), null); |
|
|
|
partInformationMapper.updateProjectPartBuNo(data); |
|
|
|
if (StringUtils.hasText(data.getCustomerPartNo())) { |
|
|
|
// 检查是否存在客户料号 |
|
|
|
List<PartInformationVo> customerPartNos = partInformationMapper.getProjectCustomerPartNo(data); |
|
|
|
@ -2900,6 +2900,7 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
a.setCreateBy(data.getCreateBy()); |
|
|
|
return a; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
validateProjectPartRequiredFields(partList); |
|
|
|
partInformationMapper.addProjectPart(partList); |
|
|
|
String site = resolveProjectPartSite(data, partList); |
|
|
|
resetCompletedProjectIfTemporaryPartAdded(site, data.getProjectId(), data.getCreateBy(), containsTemporaryPart(site, partList)); |
|
|
|
@ -2926,6 +2927,7 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
a.setVirtualPartNo(a.getFinalPartNo() == null ? a.getPlmPartNo() : a.getFinalPartNo()); |
|
|
|
return a; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
validateProjectPartRequiredFields(partList); |
|
|
|
partInformationMapper.addProjectPart(partList); |
|
|
|
String site = resolveProjectPartSite(data, partList); |
|
|
|
resetCompletedProjectIfTemporaryPartAdded(site, data.getProjectId(), data.getCreateBy(), containsTemporaryPart(site, partList)); |
|
|
|
@ -4421,6 +4423,15 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
task.setProductGroupId4(getCellValueAsString(row.getCell(4))); |
|
|
|
task.setUmId(getCellValueAsString(row.getCell(5))); |
|
|
|
task.setCodeNo(getCellValueAsString(row.getCell(6))); |
|
|
|
task.setApplicationDesc(getCellValueAsString(row.getCell(7))); |
|
|
|
if (!StringUtils.hasText(task.getApplicationDesc())) { |
|
|
|
throw new RuntimeException("第" + (j + 1) + "行应用描述不能为空"); |
|
|
|
} |
|
|
|
String productCategory = getCellValueAsString(row.getCell(8)); |
|
|
|
if (!StringUtils.hasText(productCategory)) { |
|
|
|
throw new RuntimeException("第" + (j + 1) + "行产品类别不能为空"); |
|
|
|
} |
|
|
|
task.setProductCategory(parseProjectPartProductCategory(productCategory, j + 1)); |
|
|
|
task.setUomForWeightNet("kg"); |
|
|
|
task.setUomForVolumeNet("m3"); |
|
|
|
task.setActive("Y"); |
|
|
|
@ -5503,6 +5514,9 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
List<Integer> repeatPartNoRows = new ArrayList<>(); |
|
|
|
List<Integer> wrongBuNoRows = new ArrayList<>(); |
|
|
|
List<Integer> wrongIfsPartNoRows = new ArrayList<>(); |
|
|
|
List<Integer> wrongProductCategoryRows = new ArrayList<>(); |
|
|
|
List<Integer> emptyApplicationDescRows = new ArrayList<>(); |
|
|
|
List<Integer> emptyProductCategoryRows = new ArrayList<>(); |
|
|
|
List<PlmProjectPartData> partList = new ArrayList<>(); |
|
|
|
BuData buData = new BuData(); |
|
|
|
buData.setSite(data.getOrderRef1()); |
|
|
|
@ -5553,6 +5567,19 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
} |
|
|
|
} |
|
|
|
part.setCustomerPartNo(getStringCellValue(row, 2)); |
|
|
|
part.setApplicationDesc(getStringCellValue(row, 3)); |
|
|
|
part.setProductCategory(getStringCellValue(row, 4)); |
|
|
|
if (!StringUtils.hasText(part.getApplicationDesc())) { |
|
|
|
flag = false; |
|
|
|
emptyApplicationDescRows.add(j + 1); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(part.getProductCategory())) { |
|
|
|
flag = false; |
|
|
|
emptyProductCategoryRows.add(j + 1); |
|
|
|
} else if (!isValidProjectPartProductCategory(part.getProductCategory())) { |
|
|
|
flag = false; |
|
|
|
wrongProductCategoryRows.add(j + 1); |
|
|
|
} |
|
|
|
part.setSite(data.getOrderRef1()); |
|
|
|
part.setProjectId(data.getOrderRef2()); |
|
|
|
part.setCustomerNo(data.getOrderRef3()); |
|
|
|
@ -5583,6 +5610,8 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
vo.setBuNo(part.getBuNo()); |
|
|
|
vo.setBuDesc(buMap.get(part.getBuNo())); |
|
|
|
vo.setCustomerPartNo(part.getCustomerPartNo()); |
|
|
|
vo.setApplicationDesc(part.getApplicationDesc()); |
|
|
|
vo.setProductCategory(StringUtils.hasText(part.getProductCategory()) ? part.getProductCategory().trim() : null); |
|
|
|
list1.add(vo); |
|
|
|
} |
|
|
|
if (flag){ |
|
|
|
@ -5604,17 +5633,19 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
exceptionList.add(wrongBuNoRowsStr); |
|
|
|
} |
|
|
|
if (!wrongIfsPartNoRows.isEmpty()){ |
|
|
|
/* String wrongIfsPartNosStr = null; |
|
|
|
if ("N".equals(searchType)){ |
|
|
|
// Inventory Part |
|
|
|
wrongIfsPartNosStr = "IFS物料编码在Inventory Part中不存在: 第"+ wrongIfsPartNoRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行"; |
|
|
|
} else { |
|
|
|
// Project Part |
|
|
|
wrongIfsPartNosStr = "IFS物料编码在Project Part中不存在: 第"+ wrongIfsPartNoRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行"; |
|
|
|
}*/ |
|
|
|
String wrongIfsPartNosStr = "IFS物料编码不存在或不可导入: 第"+ wrongIfsPartNoRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行"; |
|
|
|
exceptionList.add(wrongIfsPartNosStr); |
|
|
|
} |
|
|
|
if (!emptyApplicationDescRows.isEmpty()){ |
|
|
|
exceptionList.add("应用描述不能为空: 第" + emptyApplicationDescRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行"); |
|
|
|
} |
|
|
|
if (!emptyProductCategoryRows.isEmpty()){ |
|
|
|
exceptionList.add("产品类别不能为空: 第" + emptyProductCategoryRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行"); |
|
|
|
} |
|
|
|
if (!wrongProductCategoryRows.isEmpty()){ |
|
|
|
String wrongProductCategoryRowsStr = "产品类别无效(仅支持 Label/Diecut/Decoration/Material): 第" + wrongProductCategoryRows.stream().map(Object::toString).collect(Collectors.joining("/")) + "行"; |
|
|
|
exceptionList.add(wrongProductCategoryRowsStr); |
|
|
|
} |
|
|
|
list.setRecords(exceptionList); |
|
|
|
return new PageUtils(list); |
|
|
|
} |
|
|
|
@ -5713,6 +5744,47 @@ public class PartInformationServiceImpl extends ServiceImpl<PartInformationMappe |
|
|
|
projectDao.resetCompletedProjectToDraft(site, projectId, updateBy); |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isValidProjectPartProductCategory(String value) { |
|
|
|
return StringUtils.hasText(value) && PROJECT_PART_PRODUCT_CATEGORIES.contains(value.trim()); |
|
|
|
} |
|
|
|
|
|
|
|
private void validateProjectPartRequiredFields(List<PartInformationVo> partList) { |
|
|
|
if (partList == null || partList.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
for (int i = 0; i < partList.size(); i++) { |
|
|
|
PartInformationVo part = partList.get(i); |
|
|
|
String partNo = part == null ? null : (StringUtils.hasText(part.getPartNo()) ? part.getPartNo() : part.getPlmPartNo()); |
|
|
|
String prefix = StringUtils.hasText(partNo) ? "物料[" + partNo + "]:" : "第" + (i + 1) + "条物料:"; |
|
|
|
validateProjectPartRequiredFields(part == null ? null : part.getApplicationDesc(), |
|
|
|
part == null ? null : part.getProductCategory(), prefix); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void validateProjectPartRequiredFields(String applicationDesc, String productCategory, String prefix) { |
|
|
|
String p = StringUtils.hasText(prefix) ? prefix : ""; |
|
|
|
if (!StringUtils.hasText(applicationDesc)) { |
|
|
|
throw new RuntimeException(p + "应用描述不能为空"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(productCategory)) { |
|
|
|
throw new RuntimeException(p + "产品类别不能为空"); |
|
|
|
} |
|
|
|
if (!isValidProjectPartProductCategory(productCategory)) { |
|
|
|
throw new RuntimeException(p + "产品类别无效,仅支持 Label/Diecut/Decoration/Material"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String parseProjectPartProductCategory(String value, int excelRowNumber) { |
|
|
|
if (!StringUtils.hasText(value)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
String trimmed = value.trim(); |
|
|
|
if (!PROJECT_PART_PRODUCT_CATEGORIES.contains(trimmed)) { |
|
|
|
throw new RuntimeException("第" + excelRowNumber + "行产品类别无效,仅支持 Label/Diecut/Decoration/Material"); |
|
|
|
} |
|
|
|
return trimmed; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|