|
|
|
|
@ -6,11 +6,13 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.qinan.safetyeval.client.co.IndustryProfessionalPersonCo;
|
|
|
|
|
import org.qinan.safetyeval.client.co.OrgPersonnelCertCapabilityComplianceCheckCO;
|
|
|
|
|
import org.qinan.safetyeval.client.co.QualFilingComplianceCheckResultCO;
|
|
|
|
|
import org.qinan.safetyeval.client.dto.*;
|
|
|
|
|
import org.qinan.safetyeval.domain.constant.*;
|
|
|
|
|
import org.qinan.safetyeval.domain.exception.BizException;
|
|
|
|
|
import org.qinan.safetyeval.infrastructure.convertor.QualFilingPersonnelCoConvertor;
|
|
|
|
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelCertMapper;
|
|
|
|
|
import org.qinan.safetyeval.infrastructure.mapper.OrgPersonnelMapper;
|
|
|
|
|
import org.qinan.safetyeval.infrastructure.persistence.domainobject.IndustryProfessionalStandardsDO;
|
|
|
|
|
import org.qinan.safetyeval.infrastructure.persistence.domainobject.OrgPersonnelLeaderCountDO;
|
|
|
|
|
@ -40,6 +42,10 @@ public class ComplianceCheckUtil {
|
|
|
|
|
|
|
|
|
|
List<QualFilingComplianceCheckResultCO> results = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 0. 查询人员证书专业能力信息
|
|
|
|
|
List<OrgPersonnelCertCapabilityComplianceCheckCO>
|
|
|
|
|
certCapabilityList = queryOrgPersonnelCertCapability(personnelList);
|
|
|
|
|
|
|
|
|
|
// 1. 独立法人资格
|
|
|
|
|
results.add(checkMainQualification(filing));
|
|
|
|
|
|
|
|
|
|
@ -57,7 +63,7 @@ public class ComplianceCheckUtil {
|
|
|
|
|
results.add(checkPersonnelCount(filing, personnelList));
|
|
|
|
|
|
|
|
|
|
// 6. 人员比例
|
|
|
|
|
results.add(checkPersonnelRatio(filing.getBusinessScope(), personnelList));
|
|
|
|
|
results.add(checkPersonnelRatio(filing.getBusinessScope(), personnelList, certCapabilityList));
|
|
|
|
|
|
|
|
|
|
// 7. 负责人配备
|
|
|
|
|
results.add(checkKeyPosition(filing, personnelList));
|
|
|
|
|
@ -79,6 +85,31 @@ public class ComplianceCheckUtil {
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询人员证书专业能力信息
|
|
|
|
|
* <p>
|
|
|
|
|
* 根据备案人员列表中的 sourcePersonnelId(对应 org_personnel_cert.personnel_id),
|
|
|
|
|
* 查询 org_personnel_cert 表的 business_scope、professional_capability_code、professional_capability_id。
|
|
|
|
|
*
|
|
|
|
|
* @param personnelList 备案人员列表
|
|
|
|
|
* @return 人员证书专业能力信息列表
|
|
|
|
|
*/
|
|
|
|
|
private List<OrgPersonnelCertCapabilityComplianceCheckCO> queryOrgPersonnelCertCapability(List<QualFilingPersonnelAddCmd> personnelList) {
|
|
|
|
|
if (CollectionUtils.isEmpty(personnelList)) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
List<Long> sourcePersonnelIds = personnelList.stream()
|
|
|
|
|
.map(QualFilingPersonnelAddCmd::getSourcePersonnelId)
|
|
|
|
|
.filter(Objects::nonNull)
|
|
|
|
|
.distinct()
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
if (sourcePersonnelIds.isEmpty()) {
|
|
|
|
|
return Collections.emptyList();
|
|
|
|
|
}
|
|
|
|
|
OrgPersonnelCertMapper mapper = SpringUtil.getBean(OrgPersonnelCertMapper.class);
|
|
|
|
|
return mapper.selectCapabilityByPersonnelIds(sourcePersonnelIds);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 独立法人资格(暂默认通过,标记警告)
|
|
|
|
|
*/
|
|
|
|
|
@ -132,7 +163,7 @@ public class ComplianceCheckUtil {
|
|
|
|
|
* 人员比例:中级注安师 >= 30%,高级职称 >= 30%,合计 >= 60%
|
|
|
|
|
*/
|
|
|
|
|
private QualFilingComplianceCheckResultCO checkPersonnelRatio(List<String> businessScope
|
|
|
|
|
, List<QualFilingPersonnelAddCmd> personnelList) {
|
|
|
|
|
, List<QualFilingPersonnelAddCmd> personnelList, List<OrgPersonnelCertCapabilityComplianceCheckCO> personnelCertCoList) {
|
|
|
|
|
if (personnelList == null || personnelList.isEmpty()) {
|
|
|
|
|
return buildResult(QualFilingComplianceCheckEnum.PERSONNEL_RATIO,
|
|
|
|
|
QualFilingComplianceCheckEnum.STATUS_FAIL, "无人员数据");
|
|
|
|
|
@ -153,9 +184,10 @@ public class ComplianceCheckUtil {
|
|
|
|
|
String currentValue = "注册安全工程师 " + engineerRate + "%,高级职称 " + seniorTitleRate + "%,合计 " + sumRate + "%";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<IndustryProfessionalPersonCo> industryProfessionalPersonCos = SpringUtil.getBean(QualFilingPersonnelCoConvertor.class)
|
|
|
|
|
List<IndustryProfessionalPersonCo> personnelCoList = SpringUtil.getBean(QualFilingPersonnelCoConvertor.class)
|
|
|
|
|
.convertCmdsToCos(personnelList);
|
|
|
|
|
Pair<Boolean, String> booleanStringPair = industryProfessionalStandardsValid(businessScope, industryProfessionalPersonCos);
|
|
|
|
|
Pair<Boolean, String> booleanStringPair = industryProfessionalStandardsValid(
|
|
|
|
|
businessScope, personnelCoList, personnelCertCoList);
|
|
|
|
|
if (Boolean.FALSE.equals(booleanStringPair.getKey())) {
|
|
|
|
|
throw new BizException(PERSON_NOT_ENOUGH, booleanStringPair.getValue());
|
|
|
|
|
}
|
|
|
|
|
@ -267,11 +299,13 @@ public class ComplianceCheckUtil {
|
|
|
|
|
* industryProfessionalStandardsValid
|
|
|
|
|
*
|
|
|
|
|
* @param industryCodeList industryCodeList
|
|
|
|
|
* @param industryProfessionalPersonCos industryProfessionalPersonCos
|
|
|
|
|
* @param personnelCoList industryProfessionalPersonCos
|
|
|
|
|
* @param personnelCertCoList certCapabilityList
|
|
|
|
|
* @return Pair<Boolean, String> key 是否通过 ,value 失败消息(通过时为 null)
|
|
|
|
|
*/
|
|
|
|
|
public static Pair<Boolean, String> industryProfessionalStandardsValid(List<String> industryCodeList
|
|
|
|
|
, List<IndustryProfessionalPersonCo> industryProfessionalPersonCos) {
|
|
|
|
|
, List<IndustryProfessionalPersonCo> personnelCoList
|
|
|
|
|
, List<OrgPersonnelCertCapabilityComplianceCheckCO> personnelCertCoList) {
|
|
|
|
|
if (CollectionUtils.isEmpty(industryCodeList)) {
|
|
|
|
|
return Pair.of(false, "没有业务范围");
|
|
|
|
|
}
|
|
|
|
|
@ -290,10 +324,16 @@ public class ComplianceCheckUtil {
|
|
|
|
|
// 按 industryCode 分组后循环调用 doIndustryProfessionalStandardsValid
|
|
|
|
|
Map<String, List<IndustryProfessionalStandardsDO>> standardsGroupByIndustry = standardsDOList.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(IndustryProfessionalStandardsDO::getIndustryCode));
|
|
|
|
|
Map<String, List<IndustryProfessionalPersonCo>> personnelCoGroupByIndustry = personnelCoList.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(IndustryProfessionalPersonCo::getIndustryCode));
|
|
|
|
|
Map<String, List<OrgPersonnelCertCapabilityComplianceCheckCO>> personnelCertCoGroupByIndustry = personnelCertCoList.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(OrgPersonnelCertCapabilityComplianceCheckCO::getBusinessScope));
|
|
|
|
|
|
|
|
|
|
StringJoiner failureMsg = new StringJoiner(";");
|
|
|
|
|
for (Map.Entry<String, List<IndustryProfessionalStandardsDO>> entry : standardsGroupByIndustry.entrySet()) {
|
|
|
|
|
Pair<Boolean, String> result = doIndustryProfessionalStandardsValid(entry.getValue(), industryProfessionalPersonCos);
|
|
|
|
|
Pair<Boolean, String> result = doIndustryProfessionalStandardsValid(
|
|
|
|
|
entry.getValue(), personnelCoGroupByIndustry.getOrDefault(entry.getKey(), new ArrayList<>())
|
|
|
|
|
, personnelCertCoGroupByIndustry.getOrDefault(entry.getKey(), new ArrayList<>()));
|
|
|
|
|
if (Boolean.FALSE.equals(result.getKey()) && result.getValue() != null) {
|
|
|
|
|
failureMsg.add(result.getValue());
|
|
|
|
|
}
|
|
|
|
|
@ -306,18 +346,17 @@ public class ComplianceCheckUtil {
|
|
|
|
|
*
|
|
|
|
|
* @param standardsDOList 人员要求标准(按 行业code + 专业能力code 分类的人数要求)
|
|
|
|
|
* @param industryProfessionalPersonCos 当前实际人员数(按 行业code + 专业能力code 分类汇总)
|
|
|
|
|
* @param certCapabilityList certCapabilityList
|
|
|
|
|
* @return Pair<Boolean, String> key 是否通过 ,value 失败消息(通过时为 null)
|
|
|
|
|
*/
|
|
|
|
|
public static Pair<Boolean, String> doIndustryProfessionalStandardsValid(List<IndustryProfessionalStandardsDO> standardsDOList
|
|
|
|
|
, List<IndustryProfessionalPersonCo> industryProfessionalPersonCos) {
|
|
|
|
|
, List<IndustryProfessionalPersonCo> industryProfessionalPersonCos, List<OrgPersonnelCertCapabilityComplianceCheckCO> certCapabilityList) {
|
|
|
|
|
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()
|
|
|
|
|
Map<String, Long> currentCountMap = industryProfessionalPersonCos.stream()
|
|
|
|
|
.collect(Collectors.groupingBy(
|
|
|
|
|
c -> groupKey(c.getIndustryCode(), c.getProfessionalCapabilityCode()),
|
|
|
|
|
Collectors.summingLong(c -> c.getPersonNum() == null ? 0L : c.getPersonNum())));
|
|
|
|
|
|