|
@@ -1,88 +0,0 @@
|
|
|
-package com.ydtech.modules.protocol.service.impl;
|
|
|
|
|
-
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
-import com.ydtech.modules.protocol.dao.PtlAgreementUnderwritingRulesMapper;
|
|
|
|
|
-import com.ydtech.modules.protocol.entity.dto.PtlAgreementCostsFactorSaveDto;
|
|
|
|
|
-import com.ydtech.modules.protocol.entity.dto.PtlAgreementUnderwritingRulesSaveDto;
|
|
|
|
|
-import com.ydtech.modules.protocol.entity.dto.PtlFactorDto;
|
|
|
|
|
-import com.ydtech.modules.protocol.entity.po.PtlAgreementUnderwritingRules;
|
|
|
|
|
-import com.ydtech.modules.protocol.service.PtlAgreementUnderwritingRulesService;
|
|
|
|
|
-import com.ydtech.modules.protocol.utils.AssertionUtils;
|
|
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
|
|
-import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
-import org.springframework.util.ObjectUtils;
|
|
|
|
|
-
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
-
|
|
|
|
|
-/**
|
|
|
|
|
- * @author wenks
|
|
|
|
|
- * @description 针对表【ptl_agreement_underwriting_rules(协议承保规则)】的数据库操作Service实现
|
|
|
|
|
- * @createDate 2023-06-05 17:59:52
|
|
|
|
|
- */
|
|
|
|
|
-@Service
|
|
|
|
|
-public class PtlAgreementUnderwritingRulesServiceImpl extends ServiceImpl<PtlAgreementUnderwritingRulesMapper, PtlAgreementUnderwritingRules>
|
|
|
|
|
- implements PtlAgreementUnderwritingRulesService {
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- @Transactional
|
|
|
|
|
- public void saveBatchUnderwritingRules(String agreementId, List<PtlAgreementUnderwritingRulesSaveDto> underwritingRules) {
|
|
|
|
|
- List<PtlAgreementUnderwritingRules> ptlAgreementUnderwritingRulesList = PtlAgreementUnderwritingRulesSaveDto.toPtlAgreementUnderwritingRulesList(agreementId, underwritingRules);
|
|
|
|
|
- boolean b = saveBatch(ptlAgreementUnderwritingRulesList);
|
|
|
|
|
- AssertionUtils.isSucceed(b, "批量添加协议承保规则失败");
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public Map<String, List<String>> getByLicenseNo(List<String> agreementIdList) {
|
|
|
|
|
- Map<String, List<String>> map = new HashMap<>();
|
|
|
|
|
- if (!agreementIdList.isEmpty()) {
|
|
|
|
|
- LambdaQueryWrapper<PtlAgreementUnderwritingRules> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
- wrapper.in(PtlAgreementUnderwritingRules::getAgreementId, agreementIdList)
|
|
|
|
|
- .eq(PtlAgreementUnderwritingRules::getRulesType, 1);
|
|
|
|
|
-
|
|
|
|
|
- List<PtlAgreementUnderwritingRules> ptlAgreementUnderwritingRules = baseMapper.selectList(wrapper);
|
|
|
|
|
-
|
|
|
|
|
- ptlAgreementUnderwritingRules.forEach(x -> {
|
|
|
|
|
- Map<String, PtlFactorDto> mapPtlFactorDto = PtlAgreementCostsFactorSaveDto.toMapPtlFactorDto(x.getRulesFactor());
|
|
|
|
|
- PtlFactorDto ptlFactorDto = mapPtlFactorDto.get("LicenseNo");
|
|
|
|
|
- List<String> licenseNo = ObjectUtils.isEmpty(ptlFactorDto) ? Collections.emptyList() : ptlFactorDto.getParameter();
|
|
|
|
|
- map.put(x.getAgreementId(), licenseNo);
|
|
|
|
|
- });
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- return map;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- @Override
|
|
|
|
|
- public void ruleComparison(Map<String, Object> quoteRules, String agreementId, Integer rulesType) {
|
|
|
|
|
- Map<String, PtlFactorDto> mapPtlFactorDto = getMapPtlFactorDto(agreementId, rulesType);
|
|
|
|
|
- Set<String> strings = mapPtlFactorDto.keySet();
|
|
|
|
|
-
|
|
|
|
|
- for (String s : strings) {
|
|
|
|
|
- Object o = quoteRules.get(s);
|
|
|
|
|
-
|
|
|
|
|
- // 过滤没有的字段
|
|
|
|
|
- if (ObjectUtils.isEmpty(o)) {
|
|
|
|
|
- continue;
|
|
|
|
|
- }
|
|
|
|
|
- PtlFactorDto ptlFactorDto = mapPtlFactorDto.get(s);
|
|
|
|
|
- List<String> parameter = ptlFactorDto.getParameter();
|
|
|
|
|
-
|
|
|
|
|
- // 参数包含校验
|
|
|
|
|
- if (parameter != null && !parameter.isEmpty()) {
|
|
|
|
|
- assert o instanceof String;
|
|
|
|
|
- boolean contains = parameter.contains(o);
|
|
|
|
|
- AssertionUtils.isSucceed(contains, String.format("%s 不在 %s 包含范围内", o, ptlFactorDto.getName()));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- Integer minValue = ptlFactorDto.getMinValue();
|
|
|
|
|
- Integer maxValue = ptlFactorDto.getMaxValue();
|
|
|
|
|
- // 参数最大值最小值校验
|
|
|
|
|
- if (minValue != 0 || maxValue != 0) {
|
|
|
|
|
- AssertionUtils.isSucceed(minValue <= (Integer) o && (Integer) o <= maxValue, String.format("%s 应该在 %d 和 %d 范围内 ", ptlFactorDto.getName(), minValue, maxValue));
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|