|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.ydtech.constants.enums.dict.insurance.EnergyType;
|
|
import com.ydtech.constants.enums.dict.insurance.EnergyType;
|
|
|
import com.ydtech.exception.SystemException;
|
|
import com.ydtech.exception.SystemException;
|
|
|
import com.ydtech.modules.admin.service.SysUserService;
|
|
import com.ydtech.modules.admin.service.SysUserService;
|
|
|
|
|
+import com.ydtech.modules.base.controller.BaseController;
|
|
|
import com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto;
|
|
import com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto;
|
|
|
import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
|
|
import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
|
|
|
import com.ydtech.modules.protocol.service.ITaxSourceExcludeService;
|
|
import com.ydtech.modules.protocol.service.ITaxSourceExcludeService;
|
|
@@ -22,10 +23,9 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.StringUtils;
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
-import java.util.Map;
|
|
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
|
|
+import java.util.function.Predicate;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -139,6 +139,11 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
|
|
|
return rulesPage;
|
|
return rulesPage;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
|
|
|
|
|
+ Set<Object> seen = new HashSet<>();
|
|
|
|
|
+ return t -> seen.add(keyExtractor.apply(t)); // 如果id已存在则过滤
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 根据规则过滤保险公司
|
|
* 根据规则过滤保险公司
|
|
|
*
|
|
*
|
|
@@ -147,9 +152,20 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
public List<PtlAgreementInsCompanyDto> ruleFilterCompany(String userId, RuleFilterVo ruleFilterVo) {
|
|
public List<PtlAgreementInsCompanyDto> ruleFilterCompany(String userId, RuleFilterVo ruleFilterVo) {
|
|
|
|
|
+ List<PtlAgreementInsCompanyDto> userAgreementInsCompany = new ArrayList<>();
|
|
|
|
|
+ if(!BaseController.getUserId().equals(userId)){
|
|
|
|
|
+
|
|
|
|
|
+ userAgreementInsCompany = taxSourceService.getAllAgreement(BaseController.getDeptId(),BaseController.getUserId());
|
|
|
|
|
+ }
|
|
|
String deptId = sysUserService.getById(userId).getDeptId();
|
|
String deptId = sysUserService.getById(userId).getDeptId();
|
|
|
//首先获取有权限的保险公司
|
|
//首先获取有权限的保险公司
|
|
|
List<PtlAgreementInsCompanyDto> agreementInsCompany = taxSourceService.getAllAgreement(deptId, userId);
|
|
List<PtlAgreementInsCompanyDto> agreementInsCompany = taxSourceService.getAllAgreement(deptId, userId);
|
|
|
|
|
+ agreementInsCompany.addAll(userAgreementInsCompany);
|
|
|
|
|
+
|
|
|
|
|
+ agreementInsCompany = agreementInsCompany.stream()
|
|
|
|
|
+ .filter(distinctByKey(PtlAgreementInsCompanyDto::getId)) // 核心:按id去重
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
//用户可读取的所有保险公司id
|
|
//用户可读取的所有保险公司id
|
|
|
List<String> companyIds = agreementInsCompany.stream()
|
|
List<String> companyIds = agreementInsCompany.stream()
|
|
|
.map(PtlAgreementInsCompanyDto::getId)
|
|
.map(PtlAgreementInsCompanyDto::getId)
|
|
@@ -176,6 +192,7 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
|
|
|
ruleFilterVo.getInsureInfo(),
|
|
ruleFilterVo.getInsureInfo(),
|
|
|
null);
|
|
null);
|
|
|
//赛选规则
|
|
//赛选规则
|
|
|
|
|
+ List<PtlAgreementInsCompanyDto> finalAgreementInsCompany = agreementInsCompany;
|
|
|
userAllSchemeByCompanyIds.forEach(scheme -> {
|
|
userAllSchemeByCompanyIds.forEach(scheme -> {
|
|
|
List<SchemeRuleResultVo> rulesVo = ptlSchemeRulesAttrLinkService.getSchemeRulesAttrLinks(scheme.getCompanyId(), ruleFilterVo.getProductId());
|
|
List<SchemeRuleResultVo> rulesVo = ptlSchemeRulesAttrLinkService.getSchemeRulesAttrLinks(scheme.getCompanyId(), ruleFilterVo.getProductId());
|
|
|
|
|
|
|
@@ -186,7 +203,7 @@ public class PtlSchemeRulesServiceImpl extends ServiceImpl<PtlSchemeRulesMapper,
|
|
|
ruleFilteringService.judgements(r.getAttrLinks(), rulesAttrList, ruleAttrMappingVoList)
|
|
ruleFilteringService.judgements(r.getAttrLinks(), rulesAttrList, ruleAttrMappingVoList)
|
|
|
);
|
|
);
|
|
|
if (allRulesPassed) {
|
|
if (allRulesPassed) {
|
|
|
- agreementInsCompany.stream()
|
|
|
|
|
|
|
+ finalAgreementInsCompany.stream()
|
|
|
.filter(x -> x.getId().equals(scheme.getCompanyId()))
|
|
.filter(x -> x.getId().equals(scheme.getCompanyId()))
|
|
|
.forEach(item -> {
|
|
.forEach(item -> {
|
|
|
if (ptlAgreementInsCompanyDtos.stream()
|
|
if (ptlAgreementInsCompanyDtos.stream()
|