|
@@ -2,6 +2,8 @@ package com.jzg.organization.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -16,8 +18,8 @@ import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchQuery;
|
|
|
import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchVo;
|
|
import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchVo;
|
|
|
import com.jzg.commons.entity.agreement.dispatch.vo.ValidateDispatchRuleVo;
|
|
import com.jzg.commons.entity.agreement.dispatch.vo.ValidateDispatchRuleVo;
|
|
|
import com.jzg.commons.entity.costs.vo.ValidateSchemeRuleVo;
|
|
import com.jzg.commons.entity.costs.vo.ValidateSchemeRuleVo;
|
|
|
-import com.jzg.commons.entity.po.EsmInsCompany;
|
|
|
|
|
-import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
|
|
|
|
|
|
|
+import com.jzg.commons.entity.po.*;
|
|
|
|
|
+import com.jzg.commons.entity.quote.vo.SalespersonInfoVo;
|
|
|
import com.jzg.commons.entity.scheme.po.*;
|
|
import com.jzg.commons.entity.scheme.po.*;
|
|
|
import com.jzg.commons.entity.scheme.vo.*;
|
|
import com.jzg.commons.entity.scheme.vo.*;
|
|
|
import com.jzg.commons.entity.vo.EsmInsCompanyResVo;
|
|
import com.jzg.commons.entity.vo.EsmInsCompanyResVo;
|
|
@@ -29,6 +31,7 @@ import com.jzg.organization.client.EsmInsCompanyClient;
|
|
|
import com.jzg.organization.client.OrgClient;
|
|
import com.jzg.organization.client.OrgClient;
|
|
|
import com.jzg.organization.mapper.*;
|
|
import com.jzg.organization.mapper.*;
|
|
|
import com.jzg.organization.service.*;
|
|
import com.jzg.organization.service.*;
|
|
|
|
|
+import org.jetbrains.annotations.Nullable;
|
|
|
import org.redisson.api.RedissonClient;
|
|
import org.redisson.api.RedissonClient;
|
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -78,9 +81,15 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
@Autowired
|
|
@Autowired
|
|
|
PtlAgreementDispatchService ptlAgreementDispatchService;
|
|
PtlAgreementDispatchService ptlAgreementDispatchService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ PtlAgreementDeptService ptlAgreementDeptService;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
OrgClient orgClient;
|
|
OrgClient orgClient;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ SysUserJzgInfoService sysUserJzgInfoService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 添加方案
|
|
* 添加方案
|
|
|
* @param ptlSchemeSaveVo 车险报价的方案
|
|
* @param ptlSchemeSaveVo 车险报价的方案
|
|
@@ -353,6 +362,9 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
log.info("租户[{}]有权限的保司有[{}]个", systemCode, CollUtil.size(companyListResult.getData()));
|
|
log.info("租户[{}]有权限的保司有[{}]个", systemCode, CollUtil.size(companyListResult.getData()));
|
|
|
AssertionUtils.isFail(companyListResult.getCode() != 200, companyListResult.getMsg());
|
|
AssertionUtils.isFail(companyListResult.getCode() != 200, companyListResult.getMsg());
|
|
|
List<EsmInsCompany> companyList = companyListResult.getData();
|
|
List<EsmInsCompany> companyList = companyListResult.getData();
|
|
|
|
|
+ // 业务员的归属权限是可选参数,不选的话不进行过滤
|
|
|
|
|
+ companyList = salespersonFilterCompanyList(schemeRuleFilterVo, companyList);
|
|
|
|
|
+
|
|
|
log.info("根据权限获取到的保司个数是[{}].systemCode=[{}]", CollUtil.size(companyList),systemCode);
|
|
log.info("根据权限获取到的保司个数是[{}].systemCode=[{}]", CollUtil.size(companyList),systemCode);
|
|
|
if(CollUtil.isEmpty(companyList)){
|
|
if(CollUtil.isEmpty(companyList)){
|
|
|
log.info("租户[{}]没有可报价的保险公司,请到平台系统的【租户管理】-【功能配置】页面进行配置并且查看对应公司的协议,费用是否维护好",systemCode);
|
|
log.info("租户[{}]没有可报价的保险公司,请到平台系统的【租户管理】-【功能配置】页面进行配置并且查看对应公司的协议,费用是否维护好",systemCode);
|
|
@@ -550,4 +562,68 @@ public class PtlSchemeServiceImpl extends ServiceImpl<PtlSchemeMapper, PtlScheme
|
|
|
public List<InsBusinessInsuranceVo> getBusinessInsuranceListByKindType(String kindCode) {
|
|
public List<InsBusinessInsuranceVo> getBusinessInsuranceListByKindType(String kindCode) {
|
|
|
return insBusinessInsuranceMapper.getBusinessInsuranceListByKindType(kindCode);
|
|
return insBusinessInsuranceMapper.getBusinessInsuranceListByKindType(kindCode);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据业务员的deptId过滤保险公司列表
|
|
|
|
|
+ * @param schemeRuleFilterVo
|
|
|
|
|
+ * @param companyList
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<EsmInsCompany> salespersonFilterCompanyList(SchemeRuleFilterVo schemeRuleFilterVo, List<EsmInsCompany> companyList) {
|
|
|
|
|
+ SalespersonInfoVo salespersonInfo = schemeRuleFilterVo.getSalespersonInfo();
|
|
|
|
|
+ if (CollUtil.isNotEmpty(companyList) &&
|
|
|
|
|
+ ObjectUtil.isNotEmpty(salespersonInfo) && StrUtil.isNotBlank(salespersonInfo.getId())){
|
|
|
|
|
+ // 根据业务员ID获取业务员信息(含部门ID)
|
|
|
|
|
+ SysUserJzgInfo sysUserJzgInfo = sysUserJzgInfoService.getUserById(salespersonInfo.getId());
|
|
|
|
|
+ String userDeptId = sysUserJzgInfo.getDeptId(); // 业务员所属部门ID
|
|
|
|
|
+
|
|
|
|
|
+ // ========== 核心逻辑开始 ==========
|
|
|
|
|
+ // 1. 拿到所有协议ID(来自有权限的保司)
|
|
|
|
|
+ List<String> allAgreementIds = companyList.stream()
|
|
|
|
|
+ .flatMap(company -> Optional.ofNullable(company.getAgreements()).orElse(Collections.emptyList()).stream())
|
|
|
|
|
+ .map(PtlAgreement::getId)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ if (CollUtil.isNotEmpty(allAgreementIds)) {
|
|
|
|
|
+ // 2. 查询【协议-部门】关联表中,协议在 allAgreementIds 范围内的记录
|
|
|
|
|
+ LambdaQueryWrapper<PtlAgreementDept> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.in(PtlAgreementDept::getAgreementId, allAgreementIds);
|
|
|
|
|
+ List<PtlAgreementDept> agreementDepts = ptlAgreementDeptService.list(wrapper);
|
|
|
|
|
+
|
|
|
|
|
+ // 3. 筛选:只保留部门ID = 业务员部门ID 的关联记录
|
|
|
|
|
+ List<PtlAgreementDept> userValidAgreementDepts = agreementDepts.stream()
|
|
|
|
|
+ .filter(ad -> StrUtil.equals(ad.getDeptId(), userDeptId))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 4. 提取出:当前业务员【有权限的协议ID】
|
|
|
|
|
+ Set<String> validAgreementIds = userValidAgreementDepts.stream()
|
|
|
|
|
+ .map(PtlAgreementDept::getAgreementId)
|
|
|
|
|
+ .collect(Collectors.toSet());
|
|
|
|
|
+
|
|
|
|
|
+ // 5. 过滤保司列表:只保留【包含有效协议】的保司
|
|
|
|
|
+ companyList = companyList.stream()
|
|
|
|
|
+ .filter(company -> {
|
|
|
|
|
+ List<PtlAgreement> agreements = company.getAgreements();
|
|
|
|
|
+ if (CollUtil.isEmpty(agreements)) {
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ // 只要保司下有一个协议在 validAgreementIds 里,就保留
|
|
|
|
|
+ return agreements.stream()
|
|
|
|
|
+ .anyMatch(agreement -> validAgreementIds.contains(agreement.getId()));
|
|
|
|
|
+ })
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ // 6. 每个保司只保留【业务员有权限的协议】
|
|
|
|
|
+ companyList.forEach(company -> {
|
|
|
|
|
+ List<PtlAgreement> filteredAgreements = company.getAgreements().stream()
|
|
|
|
|
+ .filter(agreement -> validAgreementIds.contains(agreement.getId()))
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ company.setAgreements(filteredAgreements);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ log.info("根据业务员部门权限过滤后,剩余保司数量:{}", companyList.size());
|
|
|
|
|
+ }
|
|
|
|
|
+ return companyList;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|