Commit f2fde46a authored by tianyiming's avatar tianyiming

refactor: 更新单位类型判断逻辑并优化空列表检查

parent 5ed1a444
......@@ -23,10 +23,14 @@ public class RefreshCmService {
if (oldUnitType == null || oldUnitType.isEmpty()) {
return oldUnitType;
}
// 如果单位类型中包含检验检测机构、检测单位、检验单位,且有资质信息,则更新单位类型
if ((oldUnitType.contains(jyjcjg) || oldUnitType.contains(jyjg) || oldUnitType.contains(jcjg)) && !ListUtils.isEmpty(unitLicences)) {
long jydwCount = unitLicences.stream().filter(e -> jyjgCode.equals(e.getCertTypeCode()) || jyjg.equals(e.getCertType())).count();
long jcdwCount = unitLicences.stream().filter(e -> jcjgCode.equals(e.getCertTypeCode()) || jcjg.equals(e.getCertType())).count();
// 如果单位类型中包含检验检测机构、检测单位、检验单位,则需要更新单位类型
if (oldUnitType.contains(jyjcjg) || oldUnitType.contains(jyjg) || oldUnitType.contains(jcjg)) {
long jydwCount = 0L;
long jcdwCount = 0L;
if (!ListUtils.isEmpty(unitLicences)) {
jydwCount = unitLicences.stream().filter(e -> jyjgCode.equals(e.getCertTypeCode()) || jyjg.equals(e.getCertType())).count();
jcdwCount = unitLicences.stream().filter(e -> jcjgCode.equals(e.getCertTypeCode()) || jcjg.equals(e.getCertType())).count();
}
// 如果资质中不包含检测机构但历史的单位类型中包含检验检测机构,将此单位类型修改为检测机构
if (jcdwCount == 0 && oldUnitType.contains(jyjcjg)) {
jydwCount += 1;
......@@ -53,15 +57,15 @@ public class RefreshCmService {
}
public static LocalDate getMinDateFromLicensesEp(List<EsBaseEnterpriseInfo.License> licenses) {
if(licenses == null || licenses.isEmpty()) {
return null;
if (licenses == null || licenses.isEmpty()) {
return null;
}
return licenses.stream().map(EsBaseEnterpriseInfo.License::getExpiryDate).filter(Objects::nonNull).min(LocalDate::compareTo).orElse(null);
}
public static LocalDate getMinDateFromLicensesUser(List<EsUserInfo.License> licenses) {
if(licenses == null || licenses.isEmpty()) {
return null;
if (licenses == null || licenses.isEmpty()) {
return null;
}
return licenses.stream().map(EsUserInfo.License::getExpiryDate).filter(Objects::nonNull).min(LocalDate::compareTo).orElse(null);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment