basic
parent
132b50a874
commit
8b09ae9d1e
|
|
@ -0,0 +1,23 @@
|
||||||
|
package org.qinan.safetyeval.client.co;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IndustryProfessionalPersonCo {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行业code
|
||||||
|
*/
|
||||||
|
private String industryCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专业能力 code
|
||||||
|
*/
|
||||||
|
private String professionalCapabilityCode;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 人员数量
|
||||||
|
*/
|
||||||
|
private Long personNum;
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,23 @@
|
||||||
package org.qinan.safetyeval.infrastructure.utils;
|
package org.qinan.safetyeval.infrastructure.utils;
|
||||||
|
|
||||||
|
import cn.hutool.core.lang.Pair;
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
import org.qinan.safetyeval.client.co.IndustryProfessionalPersonCo;
|
||||||
import org.qinan.safetyeval.client.co.QualFilingComplianceCheckResultCO;
|
import org.qinan.safetyeval.client.co.QualFilingComplianceCheckResultCO;
|
||||||
import org.qinan.safetyeval.client.dto.*;
|
import org.qinan.safetyeval.client.dto.*;
|
||||||
import org.qinan.safetyeval.domain.constant.MaterialTypeEnum;
|
import org.qinan.safetyeval.domain.constant.MaterialTypeEnum;
|
||||||
import org.qinan.safetyeval.domain.constant.QualFilingComplianceCheckEnum;
|
import org.qinan.safetyeval.domain.constant.QualFilingComplianceCheckEnum;
|
||||||
import org.qinan.safetyeval.domain.constant.QualFilingMaterialUploadStatusEnum;
|
import org.qinan.safetyeval.domain.constant.QualFilingMaterialUploadStatusEnum;
|
||||||
import org.qinan.safetyeval.domain.constant.QualificationLevelEnum;
|
import org.qinan.safetyeval.domain.constant.QualificationLevelEnum;
|
||||||
|
import org.qinan.safetyeval.infrastructure.persistence.domainobject.IndustryProfessionalStandardsDO;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 资质备案合规检查工具类
|
* 资质备案合规检查工具类
|
||||||
|
|
@ -110,7 +117,7 @@ public class ComplianceCheckUtil {
|
||||||
private QualFilingComplianceCheckResultCO checkPersonnelCount(QualFilingAddCmd filing, List<QualFilingPersonnelAddCmd> personnelList) {
|
private QualFilingComplianceCheckResultCO checkPersonnelCount(QualFilingAddCmd filing, List<QualFilingPersonnelAddCmd> personnelList) {
|
||||||
int scopeCount = filing.getBusinessScope() != null ? filing.getBusinessScope().size() : 0;
|
int scopeCount = filing.getBusinessScope() != null ? filing.getBusinessScope().size() : 0;
|
||||||
int total = personnelList == null ? 0 : personnelList.size();
|
int total = personnelList == null ? 0 : personnelList.size();
|
||||||
boolean pass = total >= QualFilingComplianceCheckEnum.PERSONNEL_COUNT_LOWER;
|
boolean pass = total >= QualFilingComplianceCheckEnum.PERSONNEL_COUNT_LOWER + (scopeCount - 1) * 5;
|
||||||
String currentValue = scopeCount + " 个业务范围," + total + " 人";
|
String currentValue = scopeCount + " 个业务范围," + total + " 人";
|
||||||
return buildResult(QualFilingComplianceCheckEnum.PERSONNEL_COUNT,
|
return buildResult(QualFilingComplianceCheckEnum.PERSONNEL_COUNT,
|
||||||
pass ? QualFilingComplianceCheckEnum.STATUS_PASS : QualFilingComplianceCheckEnum.STATUS_FAIL,
|
pass ? QualFilingComplianceCheckEnum.STATUS_PASS : QualFilingComplianceCheckEnum.STATUS_FAIL,
|
||||||
|
|
@ -194,4 +201,59 @@ public class ComplianceCheckUtil {
|
||||||
co.setCurrentValue(currentValued);
|
co.setCurrentValue(currentValued);
|
||||||
return co;
|
return co;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行业专业能力人员要求校验
|
||||||
|
*
|
||||||
|
* @param standardsDOList 人员要求标准(按 行业code + 专业能力code 分类的人数要求)
|
||||||
|
* @param industryProfessionalPersonCos 当前实际人员数(按 行业code + 专业能力code 分类汇总)
|
||||||
|
* @return Pair<Boolean, String> key 是否通过 ,value 失败消息(通过时为 null)
|
||||||
|
*/
|
||||||
|
public static Pair<Boolean, String> industryProfessionalStandardsValid(List<IndustryProfessionalStandardsDO> standardsDOList
|
||||||
|
, List<IndustryProfessionalPersonCo> industryProfessionalPersonCos) {
|
||||||
|
if (CollectionUtils.isEmpty(standardsDOList)) {
|
||||||
|
return Pair.of(true, null);
|
||||||
|
}
|
||||||
|
List<IndustryProfessionalPersonCo> currentList =
|
||||||
|
industryProfessionalPersonCos == null ? Collections.emptyList() : industryProfessionalPersonCos;
|
||||||
|
|
||||||
|
// 当前人员数按 行业code + 专业能力code 分类汇总
|
||||||
|
Map<String, Long> currentCountMap = currentList.stream()
|
||||||
|
.collect(Collectors.groupingBy(
|
||||||
|
c -> groupKey(c.getIndustryCode(), c.getProfessionalCapabilityCode()),
|
||||||
|
Collectors.summingLong(c -> c.getPersonNum() == null ? 0L : c.getPersonNum())));
|
||||||
|
|
||||||
|
// 要求按 行业code + 专业能力code 分类汇总,并记录专业能力名称
|
||||||
|
StringBuilder failureMsg = new StringBuilder();
|
||||||
|
for (IndustryProfessionalStandardsDO s : standardsDOList) {
|
||||||
|
String key = groupKey(s.getIndustryCode(), s.getProfessionalCapabilityCode());
|
||||||
|
Long currentPerson = currentCountMap.getOrDefault(key, 0L);
|
||||||
|
requireNameMap.putIfAbsent(key, s.getProfessionalCapabilityName());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
for (Map.Entry<String, Long> entry : requireCountMap.entrySet()) {
|
||||||
|
long require = entry.getValue();
|
||||||
|
long current = currentCountMap.getOrDefault(entry.getKey(), 0L);
|
||||||
|
if (current < require) {
|
||||||
|
if (failureMsg.length() > 0) {
|
||||||
|
failureMsg.append(";");
|
||||||
|
}
|
||||||
|
String name = requireNameMap.get(entry.getKey());
|
||||||
|
failureMsg.append(name != null ? name : entry.getKey())
|
||||||
|
.append(" 需要").append(require).append("人,当前").append(current).append("人");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return failureMsg.length() > 0 ? Pair.of(false, failureMsg.toString()) : Pair.of(true, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 行业code + 专业能力code 分组键
|
||||||
|
*/
|
||||||
|
private static String groupKey(String industryCode, String professionalCapabilityCode) {
|
||||||
|
return (industryCode == null ? "" : industryCode) + "_"
|
||||||
|
+ (professionalCapabilityCode == null ? "" : professionalCapabilityCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue