Merge remote-tracking branch 'origin/SecondStage' into SecondStage

This commit is contained in:
sunzheng
2024-09-25 14:49:01 +08:00
@@ -75,6 +75,7 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
if(Objects.isNull(lawsPartRelevance)){
throw new JeroBootException(ResultCommon.NO_CORRESPONDING_DATA_FOUND);
}
lawsPartRelevance.setRegPartNameCn(lawsPartRelevance.getFndGpc());
return lawsPartRelevance;
}
@@ -106,7 +107,6 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
List<String> formType = Arrays.asList(lawsPartRelevance.getFormType().split(","));
if(formType.contains("1")){
if(StringUtils.isBlank(lawsPartRelevance.getSystemCode())){
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"功能系统码 cannot be empty" : "功能系统码不能为空"));
}
@@ -138,10 +138,12 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
List<String> formType = Arrays.asList(lawsPartRelevance.getFormType().split(","));
if(formType.contains("1")){
if(StringUtils.isBlank(lawsPartRelevance.getSystemCode())){
throw new JeroBootException(ResultCommon.EMPTY_COMMON,"systemCode");
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"功能系统码 cannot be empty" : "功能系统码不能为空"));
}
if(StringUtils.isBlank(lawsPartRelevance.getDecisionRequirement())){
throw new JeroBootException(ResultCommon.EMPTY_COMMON,"decisionRequirement");
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"技术特性判定要求 cannot be empty" : "技术特性判定要求不能为空"));
}
}
// 需要做名称+功能系统码唯一性校验
@@ -183,21 +185,35 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
throw new JeroBootException(ResultCommon.IMPORT_DATA_CANNOT_BE_EMPTY);
}
StringBuilder m = new StringBuilder();
for (LawsPartRelevance lawsPartRelevance : listLawsPartRelevance) {
List<String> list = Arrays.asList(lawsPartRelevance.getRegPartNameCn().split(","));
list.sort(null);
String fndGpc = String.join(",", list);
lawsPartRelevance.setRegPartNameCn(fndGpc);
lawsPartRelevance.setFndGpc(fndGpc);
}
List<String> listCode = listLawsPartRelevance.stream().map(o->o.getFndGpc() + "_" +o.getSystemCode()).collect(Collectors.toList());
QueryWrapper<LawsPartRelevance> queryLawsPartRelevance = new QueryWrapper<>();
queryLawsPartRelevance.select("CONCAT(fnd_gpc,'_',system_code) as fnd_gpc");
queryLawsPartRelevance.in("CONCAT(fnd_gpc,'_',system_code)",listCode);
List<LawsPartRelevance> listOld = list(queryLawsPartRelevance);
List<LawsPartPmmPartitionInfo> lawsPartPmmPartitionInfoList = lawsPartPmmPartitionInfoService.list();
Set<String> setAlready = new HashSet<>();
// 校验数据
for (int i = 0; i < listLawsPartRelevance.size(); i++) {
LawsPartRelevance lawsPartRelevance = listLawsPartRelevance.get(i);
StringBuilder s = new StringBuilder();
// 校验必填项
StringBuilder g = ValidUtil.validateReturnBuilder(lawsPartRelevance);
StringBuilder g = ValidUtil.validateReturnBuilderIsNotBlank(lawsPartRelevance);
if(!StringUtils.isEmpty(g.toString())){
s.append(g.toString());
}
if(!StringUtils.isBlank(lawsPartRelevance.getRegPartNameCn())){
// 验证关键零部件名称是否正确
if(CollectionUtils.isEmpty(lawsPartPmmPartitionInfoList)){
s.append("关键零部件名称不存在");
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"关键零部件名称 does not exist" : "关键零部件名称不存在");
}else{
List<LawsPartPmmPartitionInfo> lawsPartPmmPartitionInfoListSub = lawsPartPmmPartitionInfoList
.stream().filter(o->Objects.equals(o.getRegPartNameCn(),
@@ -205,21 +221,42 @@ public class LawsPartRelevanceServiceImpl extends ServiceImpl<LawsPartRelevanceM
if(!CollectionUtils.isEmpty(lawsPartPmmPartitionInfoListSub)){
lawsPartRelevance.setFndGpc(lawsPartPmmPartitionInfoListSub.get(0).getFndGpc());
}else{
s.append("关键零部件名称不存在");
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"关键零部件名称 does not exist" : "关键零部件名称不存在");
}
}
}
// todo 型号型式为奇瑞型号,功能系统码+技术特性判定要求 必填
if(StringUtils.isBlank(lawsPartRelevance.getFormType()) &&
Objects.equals(lawsPartRelevance.getFormType(),"")){
List<String> formType = Arrays.asList(lawsPartRelevance.getFormType().split(","));
if(formType.contains("1")){
if(StringUtils.isBlank(lawsPartRelevance.getSystemCode())){
s.append("功能系统码不能为空,");
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"功能系统码 cannot be empty" : "功能系统码不能为空");
}
if(StringUtils.isBlank(lawsPartRelevance.getDecisionRequirement())){
s.append("技术特性判定要求不能为空,");
s.append(Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"技术特性判定要求 cannot be empty" : "技术特性判定要求不能为空");
}
}
// 校验是否存在
String code = lawsPartRelevance.getFndGpc() + "_" + lawsPartRelevance.getSystemCode();
if(!CollectionUtils.isEmpty(listOld)){
long l = listOld.stream().filter(o->Objects.equals(o.getFndGpc() + "_" + o.getSystemCode(),
code)).count();
if(l > 0){
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"名称与功能系统码 already exists" : "名称与功能系统码已存在"));
}
}
// 校验重复
if(!CollectionUtils.isEmpty(setAlready) && !StringUtils.isBlank(code)){
long l = setAlready.stream().filter(o->Objects.equals(o,code)).count();
if(l > 0){
throw new JeroBootException((Objects.equals(LocaleContextHolder.getLocale(),Locale.ENGLISH) ?
"名称与功能系统码 duplicate" : "名称与功能系统码重复"));
}
}
setAlready.add(code);
if(!StringUtils.isBlank(s.toString())){
m.append(MessageUtils.getMessage(ResultCommon.ROW_N_IMPORT,i + 4)).append(",")
.append(s.toString(), 0, s.toString().length() - 1).append("<br>");