瀏覽代碼

Merge branch 'dev_jzg_lipf_v20260423'

lipf 4 月之前
父節點
當前提交
b8f037221c

+ 78 - 0
commons/src/main/java/com/jzg/commons/entity/quote/vo/SalespersonInfoVo.java

@@ -0,0 +1,78 @@
+package com.jzg.commons.entity.quote.vo;
+
+
+import com.jzg.commons.entity.orders.po.InsOrdersCarUserInfo;
+import com.jzg.commons.util.AssertionUtils;
+import com.jzg.commons.util.IDCardUtils;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.format.DateTimeFormatter;
+import java.util.Objects;
+
+/**
+ * @description: 业务员信息
+ * @author: wenks
+ * @date: 2025/2/18 10:56
+ **/
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+public class SalespersonInfoVo implements Serializable {
+
+    @Schema(description = "ID")
+    private String id;
+
+    @Schema(description = "用户ID")
+    private String userId;
+
+    @Schema(description = "用户名")
+    private String username;
+
+    @Schema(description = "姓名")
+    private String name;
+
+    @Schema(description = "手机号")
+    private String mobile;
+
+    @Schema(description = "部门ID")
+    private String deptId;
+
+    @Schema(description = "部门名称")
+    private String deptName;
+
+    @Schema(description = "类型属性")
+    private String typeAttr;
+
+    @Schema(description = "状态")
+    private String status;
+
+    @Schema(description = "负责人ID")
+    private String leaderId;
+
+    @Schema(description = "负责人名称")
+    private String leaderName;
+
+    @Schema(description = "推荐人ID")
+    private String referrerId;
+
+    @Schema(description = "推荐人名称")
+    private String referrerName;
+
+    @Schema(description = "工号")
+    private String workNumber;
+
+    @Schema(description = "角色名称")
+    private String roleName;
+
+    @Schema(description = "组织ID")
+    private String organizationId;
+
+    @Schema(description = "组织名称")
+    private String organizationName;
+
+}

+ 4 - 0
commons/src/main/java/com/jzg/commons/entity/scheme/vo/SchemeRuleFilterVo.java

@@ -2,6 +2,7 @@ package com.jzg.commons.entity.scheme.vo;
 
 
 import com.jzg.commons.entity.quote.vo.CarInfoVo;
 import com.jzg.commons.entity.quote.vo.CarInfoVo;
 import com.jzg.commons.entity.quote.vo.CustomerInfoVo;
 import com.jzg.commons.entity.quote.vo.CustomerInfoVo;
+import com.jzg.commons.entity.quote.vo.SalespersonInfoVo;
 import io.swagger.v3.oas.annotations.media.Schema;
 import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.Valid;
 import jakarta.validation.Valid;
 import lombok.Data;
 import lombok.Data;
@@ -29,6 +30,9 @@ public class SchemeRuleFilterVo {
     @Schema(description =  "被保人信息")
     @Schema(description =  "被保人信息")
     private CustomerInfoVo insureInfo;
     private CustomerInfoVo insureInfo;
 
 
+    @Schema(description =  "业务员信息")
+    private SalespersonInfoVo salespersonInfo;
+
     @Schema(description =  "用户id")
     @Schema(description =  "用户id")
     private String userId;
     private String userId;
 
 

+ 78 - 2
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlSchemeServiceImpl.java

@@ -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;
+    }
 }
 }