Procházet zdrojové kódy

1.保险公司判断修改
2.连接池配置修改

wks před 2 roky
rodič
revize
4df335d44e
35 změnil soubory, kde provedl 837 přidání a 329 odebrání
  1. 23 12
      src/main/java/com/ydtech/config/resttemplate/RestTemplateConfig.java
  2. 3 3
      src/main/java/com/ydtech/modules/admin/controller/SysQuotationController.java
  3. 11 8
      src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java
  4. 1 0
      src/main/java/com/ydtech/modules/order/entity/api/zijin/constants/enums/ResultEnum.java
  5. 3 0
      src/main/java/com/ydtech/modules/order/entity/vo/BaseQuoteVo.java
  6. 2 7
      src/main/java/com/ydtech/modules/order/service/impl/InsCrawlerOrderServiceImpl.java
  7. 19 17
      src/main/java/com/ydtech/modules/order/service/impl/InsDrivingIntentionInsuranceServiceImpl.java
  8. 1 0
      src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java
  9. 62 0
      src/main/java/com/ydtech/modules/protocol/controller/PtlSchedulingController.java
  10. 42 25
      src/main/java/com/ydtech/modules/protocol/controller/TaxSourceController.java
  11. 18 0
      src/main/java/com/ydtech/modules/protocol/dao/PtlAgreementSchedulingConfigMapper.java
  12. 14 1
      src/main/java/com/ydtech/modules/protocol/dao/TaxSourceMapper.java
  13. 38 0
      src/main/java/com/ydtech/modules/protocol/entity/dto/PtlAgreementSchedulingDto.java
  14. 7 4
      src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreement.java
  15. 121 0
      src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreementSchedulingConfig.java
  16. 37 0
      src/main/java/com/ydtech/modules/protocol/entity/vo/PtlAgreementSchedulingConfigSaveVo.java
  17. 33 0
      src/main/java/com/ydtech/modules/protocol/entity/vo/QuoteAgreementVo.java
  18. 19 0
      src/main/java/com/ydtech/modules/protocol/entity/vo/SubstituteRecordingAgreementVo.java
  19. 32 9
      src/main/java/com/ydtech/modules/protocol/service/ITaxSourceService.java
  20. 0 5
      src/main/java/com/ydtech/modules/protocol/service/PtlAgreementAttributionHistoryService.java
  21. 37 0
      src/main/java/com/ydtech/modules/protocol/service/PtlAgreementSchedulingConfigService.java
  22. 13 3
      src/main/java/com/ydtech/modules/protocol/service/PtlAgreementService.java
  23. 1 1
      src/main/java/com/ydtech/modules/protocol/service/PtlTaxSourceNewService.java
  24. 53 0
      src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementSchedulingConfigServiceImpl.java
  25. 40 43
      src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java
  26. 1 1
      src/main/java/com/ydtech/modules/protocol/service/impl/PtlTaxSourceServiceImpl.java
  27. 105 182
      src/main/java/com/ydtech/modules/protocol/service/impl/TaxSourceServiceImpl.java
  28. 12 0
      src/main/java/com/ydtech/modules/protocol/utils/AssertionUtils.java
  29. 19 0
      src/main/java/com/ydtech/modules/protocol/utils/EnableUtils.java
  30. 5 0
      src/main/resources/application-pre.yml
  31. 5 0
      src/main/resources/application-prod.yml
  32. 5 0
      src/main/resources/application-test.yml
  33. 2 1
      src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml
  34. 20 0
      src/main/resources/mapper/modules/protocol/PtlAgreementSchedulingConfigMapper.xml
  35. 33 7
      src/main/resources/mapper/modules/protocol/TaxSourceMapper.xml

+ 23 - 12
src/main/java/com/ydtech/config/resttemplate/RestTemplateConfig.java

@@ -1,10 +1,11 @@
 package com.ydtech.config.resttemplate;
 
-
+import java.util.concurrent.TimeUnit;
 import org.apache.http.client.HttpClient;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.config.Registry;
 import org.apache.http.config.RegistryBuilder;
+import org.apache.http.conn.HttpClientConnectionManager;
 import org.apache.http.conn.socket.ConnectionSocketFactory;
 import org.apache.http.conn.socket.PlainConnectionSocketFactory;
 import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
@@ -23,10 +24,15 @@ import java.util.Collections;
 public class RestTemplateConfig {
 
     // 连接池最大连接数
-    private static final int MAX_TOTAL = 3200;
+    private static final int MAX_TOTAL = 6400;
 
     // 默认每条路线的最大值
-    private static final int DEFAULT_MAX_PER_ROUTE = 40;
+    private static final int DEFAULT_MAX_PER_ROUTE = 3200;
+
+    // 每个主机的并发
+    private static final int VALIDATE_AFTER_INACTIVITY = 30000;
+
+    private static final int IDLE_CONNECTIONS = 30;
 
     // 返回数据的超时时间
     private static final int SOCKET_TIMEOUT = 60 * 1000;
@@ -52,14 +58,6 @@ public class RestTemplateConfig {
 
     @Bean
     public HttpClient httpClient() {
-        Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("http",
-                PlainConnectionSocketFactory.getSocketFactory()).register("https", SSLConnectionSocketFactory.getSocketFactory()).build();
-        PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(registry);
-        //设置整个连接池最大连接数
-        connectionManager.setMaxTotal(MAX_TOTAL);
-
-        //路由是对maxTotal的细分
-        connectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE);
         RequestConfig requestConfig = RequestConfig.custom()
                 .setSocketTimeout(SOCKET_TIMEOUT)  //返回数据的超时时间
                 .setConnectTimeout(CONNECT_TIMEOUT) //连接上服务器的超时时间
@@ -68,11 +66,24 @@ public class RestTemplateConfig {
 
         return HttpClientBuilder.create()
                 .setDefaultRequestConfig(requestConfig)
-                .setConnectionManager(connectionManager)
+                .setConnectionManager(poolingConnectionManager())
                 // 设置重试策略和重试次数
                 .setServiceUnavailableRetryStrategy(new RestTemplateServiceUnavailableRetryStrategy())
                 .setRetryHandler(new DefaultHttpRequestRetryHandler(3, true))
                 .build();
     }
 
+
+    private HttpClientConnectionManager poolingConnectionManager() {
+        Registry<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create().register("http",
+                PlainConnectionSocketFactory.getSocketFactory()).register("https", SSLConnectionSocketFactory.getSocketFactory()).build();
+        PoolingHttpClientConnectionManager poolingConnectionManager = new PoolingHttpClientConnectionManager(registry);
+        poolingConnectionManager.setMaxTotal(MAX_TOTAL);
+        poolingConnectionManager.setDefaultMaxPerRoute(DEFAULT_MAX_PER_ROUTE);
+        poolingConnectionManager.setValidateAfterInactivity(VALIDATE_AFTER_INACTIVITY);
+        poolingConnectionManager.closeIdleConnections(IDLE_CONNECTIONS, TimeUnit.SECONDS);
+        poolingConnectionManager.closeExpiredConnections();
+        return poolingConnectionManager;
+    }
+
 }

+ 3 - 3
src/main/java/com/ydtech/modules/admin/controller/SysQuotationController.java

@@ -106,7 +106,7 @@ public class SysQuotationController extends BaseController {
             pageDto.getDto().setDeptId(baseController.getDeptId());
         }
         IPage<SysUserBaseVO> userList = sysUserService.findAllUserList(pageDto);
-        if (userList.getRecords().size() != 0) {
+        if (!userList.getRecords().isEmpty()) {
              sysOrganizationQuotationService.findUserList(userList);
         }
         return HttpResult.ok(userList);
@@ -116,7 +116,7 @@ public class SysQuotationController extends BaseController {
     @ApiOperation(value = "报价单配置")
     @PostMapping(value = "/config")
     public HttpResult<SysOrganizationQuotation> config(@RequestBody SysOrganizationQuotation sysOrganizationQuotation) {
-        if (sysOrganizationQuotation.getAuthorizationIds().size() == 0) {
+        if (sysOrganizationQuotation.getAuthorizationIds().isEmpty()) {
             return HttpResult.error("配置失败,未选中用户");
         }
         // 构造查询条件,根据提供的用户ID集合查询出对应的报价单授权信息,然后进行删除
@@ -155,7 +155,7 @@ public class SysQuotationController extends BaseController {
         oQueryWrapper.eq(SysOrganizationQuotation::getAuthorizationId, userId);
         List<SysOrganizationQuotation> list = sysOrganizationQuotationService.list(oQueryWrapper);
         List<String> themeCodes = new ArrayList<>();
-        if (list == null || list.size() == 0) {
+        if (list == null || list.isEmpty()) {
             themeCodes.add("QD");
         } else {
             for (SysOrganizationQuotation quotation : list) {

+ 11 - 8
src/main/java/com/ydtech/modules/order/aop/aspect/QuoteVerificationAspect.java

@@ -34,12 +34,11 @@ import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
 import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
 import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
 import com.ydtech.modules.protocol.entity.po.PtlAgreement;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig;
 import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
-import com.ydtech.modules.protocol.service.ITaxSourceExcludeService;
-import com.ydtech.modules.protocol.service.PtlAgreementDeptService;
-import com.ydtech.modules.protocol.service.PtlAgreementService;
-import com.ydtech.modules.protocol.service.PtlTaxSourceNewService;
+import com.ydtech.modules.protocol.service.*;
 import com.ydtech.modules.protocol.service.impl.TaxSourceServiceImpl;
+import com.ydtech.modules.protocol.utils.EnableUtils;
 import com.ydtech.modules.protocols.entity.po.InsFeeOrderNew;
 import com.ydtech.modules.protocols.service.InsFeeOrderNewService;
 import com.ydtech.utils.StringUtils;
@@ -69,8 +68,6 @@ public class QuoteVerificationAspect {
 
     private final InsOrdersComponents insOrdersComponents;
 
-    private final TaxSourceServiceImpl taxSourceService;
-
     private final EsmInsCompanyService esmInsCompanyService;
 
     private final InsAreaCompanyService insAreaCompanyService;
@@ -98,6 +95,8 @@ public class QuoteVerificationAspect {
 
     private final PtlAgreementService ptlAgreementService;
 
+    private final PtlAgreementSchedulingConfigService ptlAgreementSchedulingConfigService;
+
     @AfterReturning(pointcut = "@annotation(com.ydtech.modules.order.aop.QuoteVerification)", returning = "result")
     public void doAfter(HttpResult<QuoteRespVo> result) {
         //计算费用因子
@@ -151,6 +150,7 @@ public class QuoteVerificationAspect {
                 String companyId = ((BaseQuoteVo<?>) arg).getCompanyId();
                 String agreementId = ((BaseQuoteVo<?>) arg).getAgreementId();
                 String orderno = ((BaseQuoteVo<?>) arg).getOrderNo();
+                int systemType = ((BaseQuoteVo<?>) arg).getSystemType();
                 //由于前台未传userid判断不了,从主订单表获取用户id和机构id保证待客录单和录单员录单的信息一致
                 /**
                 String deptId = ((BaseQuoteVo<?>) arg).getDeptId();
@@ -215,12 +215,15 @@ public class QuoteVerificationAspect {
                      //throw new SystemException("订单号"+orderno+"走默认协议判断逻辑!匹配协议为:"+taxAgreementId);
                }else{
                     //不在排除部门内进行默认判断
-                    if(isExclude){
+                    PtlAgreementSchedulingConfig config = ptlAgreementSchedulingConfigService.getByCompanyId(companyId);
+                    boolean enable = EnableUtils.isEnable(systemType, config.getPcStart(), config.getAppStart());
+
+                    if(enable && isExclude){
                         //走正常协议判断是错误的   判断是否有默认配置,如果有不可能进来,前台报错
                         List<PtlTaxSourceNew> taxSourceDtoList = ptlTaxSourceNewMapper.selectList(new LambdaQueryWrapper<PtlTaxSourceNew>()
                                 .eq(PtlTaxSourceNew::getInsCompanyId, companyId)
                                 .eq(PtlTaxSourceNew::getDefaultFlag,"1"));
-                        if(taxSourceDtoList!=null && taxSourceDtoList.size()>0){
+                        if(taxSourceDtoList!=null && !taxSourceDtoList.isEmpty()){
                             //throw new SystemException("配置默认协议且部门未排除应走默认逻辑,操作错误,请联系管理员!!");
                           //强制走默认状态
                             String taxAgreementId = ptlTaxSourceNewService.getAgreementId(deptId, userId, companyId, quoteInfo,insuranceRisk.getCode(),orderno);

+ 1 - 0
src/main/java/com/ydtech/modules/order/entity/api/zijin/constants/enums/ResultEnum.java

@@ -23,6 +23,7 @@ public enum ResultEnum {
     R_1557("1557", "车型不一致"),
     R_9999("9999", "系统异常"),
     R_ZGD_001("001", "保单状态为待支付"),
+    R_ZGD_002("002", "保单号为"),
     R_999("999", "中保信异常");
 
     private final String code;

+ 3 - 0
src/main/java/com/ydtech/modules/order/entity/vo/BaseQuoteVo.java

@@ -21,6 +21,9 @@ public class BaseQuoteVo<T> {
     @ApiModelProperty(value = "协议id", required = true)
     private String agreementId;
 
+    @ApiModelProperty("系统类型 1 pc 2 app")
+    private int systemType;
+
     @ApiModelProperty("驾意险")
     private T accidentalDrivingVo;
 

+ 2 - 7
src/main/java/com/ydtech/modules/order/service/impl/InsCrawlerOrderServiceImpl.java

@@ -6,7 +6,6 @@ import com.ydtech.constants.enums.InsurKind;
 import com.ydtech.constants.enums.dict.InsOrderStatusEnum;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
-import com.ydtech.modules.fee.service.FeeRuleSchemeService;
 import com.ydtech.modules.ins.model.vo.*;
 import com.ydtech.modules.order.components.InsCrawlerOrderComponents;
 import com.ydtech.modules.order.components.InsImagesUploadCacheComponents;
@@ -30,7 +29,6 @@ import com.ydtech.modules.protocol.entity.constants.PtlCrawlerApiType;
 import com.ydtech.modules.protocol.entity.dto.PtlAgreementAttributionDto;
 import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
 import com.ydtech.modules.protocol.service.PtlAgreementAttributionService;
-import com.ydtech.modules.protocol.service.PtlAgreementService;
 import com.ydtech.modules.protocol.service.PtlCrawlerApiService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.utils.CalculateUtils;
@@ -69,9 +67,6 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
 
     private final InsOrdersService insOrdersService;
 
-    private final FeeRuleSchemeService feeRuleSchemeService;
-
-    private final PtlAgreementService ptlAgreementService;
 
     private final InsImagesUploadCacheComponents insImagesUploadCacheComponents;
 
@@ -133,7 +128,7 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
         InsAreaCompanyAccidentalDriving insAreaCompanyAccidentalDriving = new InsAreaCompanyAccidentalDriving();
         insAreaCompanyAccidentalDriving.convertCrawler(t);
         //如果是太平 将id 设置为 riskcode
-        if(t.getAccidentalDrivingVo() != null && t.getCompanyId().equals("TPIC1000000")){
+        if (t.getAccidentalDrivingVo() != null && t.getCompanyId().equals("TPIC1000000")) {
             JSONObject jsonObject = JSON.parseObject(t.getAccidentalDrivingVo().toString());
             insAreaCompanyAccidentalDriving.setRideRiskCode(jsonObject.get("id").toString());
         }
@@ -146,7 +141,7 @@ public class InsCrawlerOrderServiceImpl implements InsCrawlerOrderService {
     @Override
     public HttpResult<Object> submitImage(String subOrderNo) {
         InsAreaCompany insAreaCompany = insAreaCompanyService.getById(subOrderNo);
-        if(insAreaCompany.getCompanyId().equals("TKIC1000000")){
+        if (insAreaCompany.getCompanyId().equals("TKIC1000000")) {
             //泰康
             return HttpResult.ok("上传成功");
         }

+ 19 - 17
src/main/java/com/ydtech/modules/order/service/impl/InsDrivingIntentionInsuranceServiceImpl.java

@@ -49,6 +49,7 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
 
     /**
      * 根据查询条件获取驾意险信息
+     *
      * @param insuranceVo
      * @return
      */
@@ -56,20 +57,20 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
     public List<InsDrivingIntentionInsuranceVo> getInsDrivingIntentionInsuranceVo(NoCarInsuranceQueryVo insuranceVo, Integer apiType) {
         LambdaQueryWrapper<InsDrivingIntentionInsurance> query = new LambdaQueryWrapper<>();
         String companyId = "";
-        if(insuranceVo.getAgreementId() != null){
+        if (insuranceVo.getAgreementId() != null) {
             PtlAgreement byAgreementIdNew = ptlAgreementService.getByAgreementIdNew(insuranceVo.getAgreementId());
             query.eq(InsDrivingIntentionInsurance::getCompanyId, byAgreementIdNew.getInsuranceCompanyId());
             companyId = byAgreementIdNew.getInsuranceCompanyId();
-        }else{
+        } else {
             query.eq(InsDrivingIntentionInsurance::getCompanyId, insuranceVo.getCompanyCode());
         }
-        if(insuranceVo.getSeatNum() != null) {
+        if (insuranceVo.getSeatNum() != null) {
             query.eq(InsDrivingIntentionInsurance::getSeatNum, insuranceVo.getSeatNum());
         }
         query.eq(InsDrivingIntentionInsurance::getApiType, apiType);
         List<InsDrivingIntentionInsurance> insDrivingIntentionInsurances = baseMapper.selectList(query);
         List<String> collect = insDrivingIntentionInsurances.stream().map(InsDrivingIntentionInsurance::getProjectCode).collect(Collectors.toList());
-        if(collect.isEmpty()){
+        if (collect.isEmpty()) {
             return new ArrayList<>();
         }
         List<InsDrivingIntentionInsuranceSon> insDrivingIntentionInsuranceSons = sonMapper.selectList(new LambdaQueryWrapper<InsDrivingIntentionInsuranceSon>()
@@ -81,7 +82,7 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
         List<InsDrivingIntentionInsuranceVo> insDrivingIntentionInsuranceVo = baseDriving.stream()
                 .map(InsDrivingIntentionInsuranceVo::new)
                 .collect(Collectors.toList());
-        insDrivingIntentionInsuranceVo.forEach(x ->x.setQuantity(1));
+        insDrivingIntentionInsuranceVo.forEach(x -> x.setQuantity(1));
         insDrivingIntentionInsuranceVo.forEach(x -> {
             x.setSon(insDrivingIntentionInsuranceSons.stream().filter(y -> y.getDrivingCodeId().equals(x.getProjectCode())).collect(Collectors.toList()));
             List<InsDrivingIntentionInsurance> children = insDrivingIntentionInsurances.stream().filter(y -> y.getParentId().equals(x.getId())).collect(Collectors.toList());
@@ -91,7 +92,7 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
             childrenVo.forEach(y -> {
                 y.setSon(insDrivingIntentionInsuranceSons.stream().filter(z -> z.getDrivingCodeId().equals(y.getProjectCode())).collect(Collectors.toList()));
             });
-            childrenVo.forEach(k-> k.setQuantity(1));
+            childrenVo.forEach(k -> k.setQuantity(1));
             x.setChildren(childrenVo);
         });
 
@@ -100,28 +101,29 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
 
     /**
      * 根据规则获取驾意险信息
+     *
      * @param insuranceVo
      * @return
      */
     @Override
     public List<InsDrivingIntentionInsuranceVo> getInsDrivingIntentionInsuranceRule(NoCarInsuranceQueryVo insuranceVo) {
-        LambdaQueryWrapper<PtlAgreementNonCarProductRule> query = new LambdaQueryWrapper<PtlAgreementNonCarProductRule>();
+        LambdaQueryWrapper<PtlAgreementNonCarProductRule> query = new LambdaQueryWrapper<>();
         ProductsType productType = InsuranceRisk.determineInsuranceInformation(insuranceVo.getKind(), insuranceVo.getRisk());
-        if(insuranceVo.getCompanyCode() != null){
+        if (insuranceVo.getCompanyCode() != null) {
             List<PtlAgreement> byCompanyCode = ptlAgreementService.getByCompanyCode(insuranceVo.getCompanyCode());
-            List<String> collect = byCompanyCode.stream().map(x -> x.getId()).collect(Collectors.toList());
-            query.in(PtlAgreementNonCarProductRule::getAgreementId, collect);
-        }else {
+            List<String> collect = byCompanyCode.stream().map(PtlAgreement::getId).collect(Collectors.toList());
+            query.in(!collect.isEmpty(), PtlAgreementNonCarProductRule::getAgreementId, collect);
+        } else {
             PtlAgreement byAgreementIdNew = ptlAgreementService.getByAgreementIdNew(insuranceVo.getAgreementId());
             List<PtlAgreement> byCompanyCode = ptlAgreementService.getByCompanyCode(byAgreementIdNew.getInsuranceCompanyId());
-            List<String> collect = byCompanyCode.stream().map(x -> x.getId()).collect(Collectors.toList());
-            query.in(PtlAgreementNonCarProductRule::getAgreementId, collect);
+            List<String> collect = byCompanyCode.stream().map(PtlAgreement::getId).collect(Collectors.toList());
+            query.in(!collect.isEmpty(), PtlAgreementNonCarProductRule::getAgreementId, collect);
         }
         query.le(PtlAgreementNonCarProductRule::getSeatNumMin, insuranceVo.getRuleSeatNum());
         query.ge(PtlAgreementNonCarProductRule::getSeatNumMax, insuranceVo.getRuleSeatNum());
         query.eq(PtlAgreementNonCarProductRule::getUseNature, insuranceVo.getRuleUseNature());
         query.eq(PtlAgreementNonCarProductRule::getProductCode, productType.getCode());
-        if(insuranceVo.getRuleThirdPartyInsurance() != null) {
+        if (insuranceVo.getRuleThirdPartyInsurance() != null) {
             query.ge(PtlAgreementNonCarProductRule::getThirdPartyLnsuranceMin, insuranceVo.getRuleThirdPartyInsurance());
             query.le(PtlAgreementNonCarProductRule::getThirdPartyLnsuranceMax, insuranceVo.getRuleThirdPartyInsurance());
         }
@@ -132,7 +134,7 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
         Integer apiType = ptlAgreementAttribution.getApiType();
 
         List<InsDrivingIntentionInsuranceVo> insDrivingIntentionInsuranceVo = getInsDrivingIntentionInsuranceVo(insuranceVo, apiType);
-        if(!list.isEmpty()){
+        if (!list.isEmpty()) {
             //遍历顶级
             insDrivingIntentionInsuranceVo.stream()
                     .filter(item -> item.getProjectCode().toString().equals(list.get(0).getParentId()))
@@ -171,8 +173,8 @@ public class InsDrivingIntentionInsuranceServiceImpl extends ServiceImpl<InsDriv
         List<InsDrivingIntentionInsuranceSon> insDrivingIntentionInsuranceSons = sonMapper.selectList(new LambdaQueryWrapper<InsDrivingIntentionInsuranceSon>()
                 .eq(InsDrivingIntentionInsuranceSon::getCompanyId, companyId)
                 .and(wrapper -> wrapper.eq(InsDrivingIntentionInsuranceSon::getCode, drivingCodeId)
-                .or()
-                .eq(InsDrivingIntentionInsuranceSon::getDrivingCodeId, drivingCodeId)));
+                        .or()
+                        .eq(InsDrivingIntentionInsuranceSon::getDrivingCodeId, drivingCodeId)));
         return insDrivingIntentionInsuranceSons;
     }
 }

+ 1 - 0
src/main/java/com/ydtech/modules/order/service/impl/InsOrdersServiceImpl.java

@@ -214,6 +214,7 @@ public class InsOrdersServiceImpl extends ServiceImpl<InsOrdersMapper, InsOrders
 
         List<PtlAgreementInsCompanyDto> agreementCompany = ptlAgreementService.getAgreementCompany(deptId);
         return HttpResult.ok(agreementCompany);
+
     }
 
     @Override

+ 62 - 0
src/main/java/com/ydtech/modules/protocol/controller/PtlSchedulingController.java

@@ -0,0 +1,62 @@
+package com.ydtech.modules.protocol.controller;
+
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.esm.service.EsmInsCompanyService;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig;
+import com.ydtech.modules.protocol.entity.vo.PtlAgreementSchedulingConfigSaveVo;
+import com.ydtech.modules.protocol.service.PtlAgreementSchedulingConfigService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.Arrays;
+
+@Api(tags = "协议调度配置")
+@RestController
+@RequestMapping("/ptl/scheduling")
+@RequiredArgsConstructor
+public class PtlSchedulingController {
+
+    private final PtlAgreementSchedulingConfigService ptlAgreementSchedulingConfigService;
+
+    private final EsmInsCompanyService esmInsCompanyService;
+
+    @PostMapping
+    @ApiOperation("新增/修改 协议调度")
+    public HttpResult<Object> save(@RequestBody PtlAgreementSchedulingConfigSaveVo ptlAgreementSchedulingConfigSaveVo) {
+        ptlAgreementSchedulingConfigService.allocation(ptlAgreementSchedulingConfigSaveVo);
+        return HttpResult.ok("操作成功");
+    }
+
+    @GetMapping("/{companyId}")
+    @ApiOperation("获取配置信息")
+    public HttpResult<PtlAgreementSchedulingConfigSaveVo> get(@PathVariable String companyId) {
+        EsmInsCompany esmInsCompany = esmInsCompanyService.getById(companyId);
+
+        // 空数据加入保险公司
+        PtlAgreementSchedulingConfig ptlAgreementSchedulingConfig = ptlAgreementSchedulingConfigService.getByCompanyId(companyId);
+        if (ObjectUtils.isEmpty(ptlAgreementSchedulingConfig)) {
+            ptlAgreementSchedulingConfig = new PtlAgreementSchedulingConfig();
+            ptlAgreementSchedulingConfig.setCompanyId(esmInsCompany.getId());
+            ptlAgreementSchedulingConfig.setCompanyName(esmInsCompany.getName());
+        }
+
+        // 重新处理数据
+        PtlAgreementSchedulingConfigSaveVo ptlAgreementSchedulingConfigSaveVo = new PtlAgreementSchedulingConfigSaveVo();
+        BeanUtils.copyProperties(ptlAgreementSchedulingConfig, ptlAgreementSchedulingConfigSaveVo);
+
+        if (StringUtils.isNotEmpty(ptlAgreementSchedulingConfig.getProductsCode())) {
+            String[] split = ptlAgreementSchedulingConfig.getProductsCode().split(",");
+            ptlAgreementSchedulingConfigSaveVo.setProductsCode(Arrays.asList(split));
+        }
+
+        return HttpResult.ok(ptlAgreementSchedulingConfigSaveVo);
+    }
+
+
+}

+ 42 - 25
src/main/java/com/ydtech/modules/protocol/controller/TaxSourceController.java

@@ -5,30 +5,38 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageRequest;
 import com.ydtech.core.page.PageResult;
+import com.ydtech.modules.admin.model.SysUser;
+import com.ydtech.modules.admin.service.SysUserService;
 import com.ydtech.modules.base.controller.BaseController;
-import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto;
+import com.ydtech.modules.protocol.entity.dto.PtlAgreementSchedulingDto;
+import com.ydtech.modules.protocol.entity.vo.QuoteAgreementVo;
+import com.ydtech.modules.protocol.entity.vo.SubstituteRecordingAgreementVo;
 import com.ydtech.modules.protocol.entity.vo.TaxSourceVo;
 import com.ydtech.modules.protocol.service.ITaxSourceService;
 import com.ydtech.modules.protocol.service.PtlAgreementService;
 import com.ydtech.modules.protocol.service.PtlAreaLicenseService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
-import org.springframework.beans.factory.annotation.Autowired;
+import lombok.RequiredArgsConstructor;
+import org.springframework.beans.BeanUtils;
 import org.springframework.web.bind.annotation.*;
 
-@Api(tags = "税源管理")
+import java.util.List;
+
+@Api(tags = "协议调度管理")
 @RequestMapping("/tax/manager")
 @RestController
+@RequiredArgsConstructor
 public class TaxSourceController extends BaseController {
-    @Autowired
-    private PtlAreaLicenseService ptlAreaLicenseService;
 
-    @Autowired
-    private ITaxSourceService taxSourceService;
+    private final PtlAreaLicenseService ptlAreaLicenseService;
+
+    private final ITaxSourceService taxSourceService;
 
-    @Autowired
-    private PtlAgreementService ptlAgreementService;
+    private final PtlAgreementService ptlAgreementService;
 
+    private final SysUserService sysUserService;
 
     @GetMapping("/license")
     @ApiOperation("车牌信息")
@@ -39,13 +47,14 @@ public class TaxSourceController extends BaseController {
 
     @GetMapping("/insureCompany")
     @ApiOperation("获取保险公司")
-    public HttpResult insureCompany(Integer pageNum,Integer pageSize) {
+    public HttpResult<PageResult<PtlAgreementSchedulingDto>> insureCompany(Integer pageNum, Integer pageSize, String companyId) {
         PageRequest pageRequest = new PageRequest();
         pageRequest.setPageNum(pageNum);
         pageRequest.setPageSize(pageSize);
-        Page page = PageRequest.buildPageRequest(pageRequest);
-        IPage<EsmInsCompany> insureCompany = taxSourceService.getInsureCompany(page);
-        PageResult pageResult = PageResult.buildPageResult(insureCompany);
+
+        Page<PtlAgreementSchedulingDto> page = PageRequest.buildPageRequest(pageRequest);
+        IPage<PtlAgreementSchedulingDto> insureCompany = taxSourceService.getInsureCompany(page, companyId);
+        PageResult<PtlAgreementSchedulingDto> pageResult = PageResult.buildPageResult(insureCompany);
         return HttpResult.ok(pageResult);
     }
 
@@ -54,27 +63,29 @@ public class TaxSourceController extends BaseController {
     public HttpResult agreement(String companyId) {
         String deptId = getDeptId();
         String userId = getUserId();
-        return HttpResult.ok(taxSourceService.getAgreementByCompanyId(companyId,deptId,userId));
+        return HttpResult.ok(taxSourceService.getAgreementByCompanyId(companyId, deptId, userId));
     }
 
     @GetMapping("/getTaxSource")
     @ApiOperation("获取税源")
-    public HttpResult getTaxSource(String companyId){
+    public HttpResult getTaxSource(String companyId) {
         TaxSourceVo taxSourceVos = taxSourceService.getTaxSource(companyId);
         return HttpResult.ok(taxSourceVos);
     }
 
-    @GetMapping("/getAllAgreement")
-    @ApiOperation("获取所有协议")
-    public HttpResult getAllAgreement(){
+    @PostMapping("/getAllAgreement")
+    @ApiOperation("获取保险公司协议列表(车险录单)")
+    public HttpResult<List<PtlAgreementInsCompanyDto>> getAllAgreement(@RequestBody QuoteAgreementVo quoteAgreementVo) {
         String deptId = getDeptId();
         String userId = getUserId();
-        return HttpResult.ok(taxSourceService.getAllAgreement(deptId,userId));
+        List<PtlAgreementSchedulingDto> ptlAgreementScheduling = taxSourceService.getPtlAgreementScheduling();
+        List<PtlAgreementInsCompanyDto> allAgreement = taxSourceService.getAllAgreement(deptId, userId, quoteAgreementVo, ptlAgreementScheduling);
+        return HttpResult.ok(allAgreement);
     }
 
     @GetMapping("/getExternalAgreement")
     @ApiOperation("获取外部协议")
-    public HttpResult getExternalAgreement(){
+    public HttpResult getExternalAgreement() {
         return HttpResult.ok(ptlAgreementService.getExternalAgreement());
     }
 
@@ -82,12 +93,18 @@ public class TaxSourceController extends BaseController {
     @ApiOperation("保存税源")
     public HttpResult saveTaxSource(@RequestBody TaxSourceVo taxSourceVo) {
         boolean result = taxSourceService.saveTaxSource(taxSourceVo);
-        return result? HttpResult.ok("保存税源成功"):HttpResult.error("保存税源失败");
+        return result ? HttpResult.ok("保存税源成功") : HttpResult.error("保存税源失败");
     }
 
-    @GetMapping("/getAllAgreementByUserId")
-    @ApiOperation("通过用户id获取所有协议")
-    public HttpResult getAllAgreementByUserId(String userId){
-        return HttpResult.ok(taxSourceService.getAllAgreementByUserId(userId));
+    @PostMapping("/getAllAgreementByUserId")
+    @ApiOperation("获取保险公司协议列表(代课录单)")
+    public HttpResult<List<PtlAgreementInsCompanyDto>> getAllAgreementByUserId(@RequestBody SubstituteRecordingAgreementVo substituteRecordingAgreementVo) {
+        QuoteAgreementVo quoteAgreementVo = new QuoteAgreementVo();
+        BeanUtils.copyProperties(substituteRecordingAgreementVo, quoteAgreementVo);
+        SysUser user = sysUserService.getById(substituteRecordingAgreementVo.getUserId());
+        List<PtlAgreementSchedulingDto> ptlAgreementScheduling = taxSourceService.getPtlAgreementScheduling();
+        List<PtlAgreementInsCompanyDto> allAgreement = taxSourceService.getAllAgreement(user.getDeptId(), user.getId(), quoteAgreementVo, ptlAgreementScheduling);
+        return HttpResult.ok(allAgreement);
     }
+
 }

+ 18 - 0
src/main/java/com/ydtech/modules/protocol/dao/PtlAgreementSchedulingConfigMapper.java

@@ -0,0 +1,18 @@
+package com.ydtech.modules.protocol.dao;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig;
+
+/**
+* @author Administrator
+* @description 针对表【ptl_agreement_scheduling_config(协议调度配置(过滤保险公司))】的数据库操作Mapper
+* @createDate 2024-07-22 11:32:12
+* @Entity com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig
+*/
+public interface PtlAgreementSchedulingConfigMapper extends BaseMapper<PtlAgreementSchedulingConfig> {
+
+}
+
+
+
+

+ 14 - 1
src/main/java/com/ydtech/modules/protocol/dao/TaxSourceMapper.java

@@ -5,17 +5,30 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.ydtech.core.page.PageRequest;
 import com.ydtech.modules.esm.model.EsmInsCompany;
+import com.ydtech.modules.protocol.entity.dto.PtlAgreementSchedulingDto;
 import com.ydtech.modules.protocol.entity.dto.TaxSourceDto;
 import com.ydtech.modules.protocol.entity.po.PtlAgreement;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
 
 @Mapper
 public interface TaxSourceMapper extends BaseMapper<TaxSourceDto> {
 
-    IPage<EsmInsCompany> getInsureCompany(Page page);
+    /**
+     * 获取协议调度保险公司
+     *
+     * @param page 分页信息
+     * @return 协议调度保险公司列表
+     */
+    IPage<PtlAgreementSchedulingDto> getInsureCompany(Page<PtlAgreementSchedulingDto> page, @Param("companyId") String companyId);
 
     List<PtlAgreement> getAgreementByCompanyId(String companyId);
 
+    /**
+     * 获取全部协议调度保险公司
+     * @return 协议调度保险公司列表
+     */
+    List<PtlAgreementSchedulingDto> getPtlAgreementScheduling();
 }

+ 38 - 0
src/main/java/com/ydtech/modules/protocol/entity/dto/PtlAgreementSchedulingDto.java

@@ -0,0 +1,38 @@
+package com.ydtech.modules.protocol.entity.dto;
+
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
+
+@AllArgsConstructor
+@NoArgsConstructor
+@Data
+public class PtlAgreementSchedulingDto {
+
+    @ApiModelProperty("保险公司id")
+    private String id;
+
+    @ApiModelProperty("保险公司名称")
+    private String name;
+
+    @ApiModelProperty("pc是否启动")
+    private Integer pcStart;
+
+    @ApiModelProperty("app是否启动")
+    private Integer appStart;
+
+    @ApiModelProperty("险种")
+    private String productsCode;
+
+    public Integer getAppStart() {
+        return appStart == null ? 0 : appStart;
+    }
+
+    public Integer getPcStart() {
+        return pcStart == null ? 0 : pcStart;
+    }
+
+}

+ 7 - 4
src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreement.java

@@ -1,9 +1,6 @@
 package com.ydtech.modules.protocol.entity.po;
 
-import com.baomidou.mybatisplus.annotation.IdType;
-import com.baomidou.mybatisplus.annotation.TableField;
-import com.baomidou.mybatisplus.annotation.TableId;
-import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.*;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
 import com.ydtech.utils.StringUtils;
 import io.swagger.annotations.ApiModelProperty;
@@ -260,6 +257,12 @@ public class PtlAgreement implements Serializable {
     @TableField(exist = false)
     private String partnerCompaniesName;
 
+    /**
+     * 逻辑删除
+     */
+    @TableLogic
+    private Integer deleted;
+
     public void generateTheProtocolCode() {
         AssertionUtils.isFail(StringUtils.isNullOrEmpty(this.getPartnerCompaniesId()), "请检查合作保险公司是否选择");
         String string = LocalDate.now().format(DateTimeFormatter.BASIC_ISO_DATE);

+ 121 - 0
src/main/java/com/ydtech/modules/protocol/entity/po/PtlAgreementSchedulingConfig.java

@@ -0,0 +1,121 @@
+package com.ydtech.modules.protocol.entity.po;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import java.io.Serializable;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.apache.commons.lang3.ObjectUtils;
+
+/**
+ * 协议调度配置(过滤保险公司)
+ *
+ * @TableName ptl_agreement_scheduling_config
+ */
+@TableName(value = "ptl_agreement_scheduling_config")
+@Data
+@ApiModel("协议调度配置")
+public class PtlAgreementSchedulingConfig implements Serializable {
+
+    /**
+     * 主键 id
+     */
+    @TableId(value = "id", type = IdType.AUTO)
+    private Integer id;
+
+    /**
+     * 保险公司id
+     */
+    @TableField(value = "company_id")
+    private String companyId;
+
+    /**
+     * 保险公司名称
+     */
+    @TableField(value = "company_name")
+    private String companyName;
+
+    /**
+     * APP是否启动(0不启动 1启动)
+     */
+    @TableField(value = "app_start")
+    private Integer appStart;
+
+    /**
+     * PC是否启动(0不启动 1启动)
+     */
+    @TableField(value = "pc_start")
+    private Integer pcStart;
+
+    /**
+     * 单交0330、单商034001、单三034002、交三0330034002、交商0330034001
+     */
+    @TableField(value = "products_code")
+    private String productsCode;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    public Integer getAppStart() {
+        return appStart == null ? 0 : appStart;
+    }
+
+    public Integer getPcStart() {
+        return pcStart == null ? 0 : pcStart;
+    }
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        PtlAgreementSchedulingConfig other = (PtlAgreementSchedulingConfig) that;
+        return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
+                && (this.getCompanyId() == null ? other.getCompanyId() == null : this.getCompanyId().equals(other.getCompanyId()))
+                && (this.getCompanyName() == null ? other.getCompanyName() == null : this.getCompanyName().equals(other.getCompanyName()))
+                && (this.getAppStart() == null ? other.getAppStart() == null : this.getAppStart().equals(other.getAppStart()))
+                && (this.getPcStart() == null ? other.getPcStart() == null : this.getPcStart().equals(other.getPcStart()))
+                && (this.getProductsCode() == null ? other.getProductsCode() == null : this.getProductsCode().equals(other.getProductsCode()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
+        result = prime * result + ((getCompanyId() == null) ? 0 : getCompanyId().hashCode());
+        result = prime * result + ((getCompanyName() == null) ? 0 : getCompanyName().hashCode());
+        result = prime * result + ((getAppStart() == null) ? 0 : getAppStart().hashCode());
+        result = prime * result + ((getPcStart() == null) ? 0 : getPcStart().hashCode());
+        result = prime * result + ((getProductsCode() == null) ? 0 : getProductsCode().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", id=").append(id);
+        sb.append(", companyId=").append(companyId);
+        sb.append(", companyName=").append(companyName);
+        sb.append(", appStart=").append(appStart);
+        sb.append(", pcStart=").append(pcStart);
+        sb.append(", productsCode=").append(productsCode);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 37 - 0
src/main/java/com/ydtech/modules/protocol/entity/vo/PtlAgreementSchedulingConfigSaveVo.java

@@ -0,0 +1,37 @@
+package com.ydtech.modules.protocol.entity.vo;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.util.List;
+
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@ApiModel("配置信息")
+public class PtlAgreementSchedulingConfigSaveVo {
+
+    @ApiModelProperty("主键id")
+    private Integer id;
+
+    @ApiModelProperty("保险公司id")
+    private String companyId;
+
+    @ApiModelProperty("保险公司名称")
+    private String companyName;
+
+    @ApiModelProperty("APP是否启动(0不启动 1启动)")
+    private Integer appStart;
+
+    @ApiModelProperty("PC是否启动(0不启动 1启动)")
+    private Integer pcStart;
+
+    @ApiModelProperty("单交0330、单商034001、单三034002、交三0330034002、交商0330034001")
+    private List<String> productsCode;
+
+
+}

+ 33 - 0
src/main/java/com/ydtech/modules/protocol/entity/vo/QuoteAgreementVo.java

@@ -0,0 +1,33 @@
+package com.ydtech.modules.protocol.entity.vo;
+
+
+import com.ydtech.modules.ins.model.vo.KindInfoVo;
+import com.ydtech.modules.ins.model.vo.RiskInfoVo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import java.io.Serializable;
+import java.util.List;
+
+
+@Data
+@ApiModel("车险录单协议获取实体")
+@AllArgsConstructor
+@NoArgsConstructor
+public class QuoteAgreementVo implements Serializable {
+
+    private static final long serialVersionUID = -3246967636374112126L;
+
+    @ApiModelProperty("系统类型 1 pc 2 app")
+    private int systemType;
+
+    @ApiModelProperty("险种列表")
+    private List<RiskInfoVo> riskList;
+
+    @ApiModelProperty("商业险险种列表")
+    private List<KindInfoVo> kindList;
+
+}

+ 19 - 0
src/main/java/com/ydtech/modules/protocol/entity/vo/SubstituteRecordingAgreementVo.java

@@ -0,0 +1,19 @@
+package com.ydtech.modules.protocol.entity.vo;
+
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.NoArgsConstructor;
+
+@NoArgsConstructor
+@EqualsAndHashCode(callSuper = true)
+@AllArgsConstructor
+@Data
+public class SubstituteRecordingAgreementVo extends QuoteAgreementVo{
+
+    private static final long serialVersionUID = 7564602257117457870L;
+
+    private String userId;
+
+}

+ 32 - 9
src/main/java/com/ydtech/modules/protocol/service/ITaxSourceService.java

@@ -5,15 +5,30 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.ydtech.modules.esm.model.EsmInsCompany;
 import com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto;
+import com.ydtech.modules.protocol.entity.dto.PtlAgreementSchedulingDto;
 import com.ydtech.modules.protocol.entity.dto.TaxSourceDto;
 import com.ydtech.modules.protocol.entity.po.PtlAgreement;
+import com.ydtech.modules.protocol.entity.vo.QuoteAgreementVo;
+import com.ydtech.modules.protocol.entity.vo.SubstituteRecordingAgreementVo;
 import com.ydtech.modules.protocol.entity.vo.TaxSourceVo;
 
 import java.util.List;
 
 public interface ITaxSourceService extends IService<TaxSourceDto> {
 
-    IPage<EsmInsCompany> getInsureCompany(Page page);
+    /**
+     * 协议调度获取保险公司列表
+     * @param page 分页信息
+     * @return 分页结果
+     */
+    IPage<PtlAgreementSchedulingDto> getInsureCompany(Page<PtlAgreementSchedulingDto> page, String companyId);
+
+    /**
+     * 协议调度获取全部保险公司列表
+     * @return
+     */
+    List<PtlAgreementSchedulingDto> getPtlAgreementScheduling();
+
 
     List<PtlAgreement> getAgreementByCompanyId(String companyId,String deptId,String userId);
 
@@ -22,14 +37,22 @@ public interface ITaxSourceService extends IService<TaxSourceDto> {
     TaxSourceVo getTaxSource(String companyId);
 //    List<PtlAgreementInsCompanyDto> getAgreementInsCompany(String deptId, String userId,String license,String volume);
 
-    List<PtlAgreementInsCompanyDto> getAllAgreement(String deptId, String userId);
-
-    String getAgreementId(String deptId, String userId, String companyId, String license, String volume, String productid);
     /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/4/18 10:17
-     *  @Description: 通过用户id查询关联的协议
+     * 车险录单获取保险公司协议
+     * @param deptId 机构id
+     * @param userId 用户id
+     * @param quoteAgreementVo 险种信息
+     * @return 协议列表
      */
-    List<PtlAgreementInsCompanyDto> getAllAgreementByUserId(String userId);
+    List<PtlAgreementInsCompanyDto> getAllAgreement(String deptId, String userId, QuoteAgreementVo quoteAgreementVo, List<PtlAgreementSchedulingDto> ptlAgreementScheduling);
+
+    String getAgreementId(String deptId, String userId, String companyId, String license, String volume, String productid);
+
+//    /**
+//     *  @version
+//     *  @author: hxl
+//     *  @Date: 2024/4/18 10:17
+//     *  @Description: 通过用户id查询关联的协议
+//     */
+//    List<PtlAgreementInsCompanyDto> getAllAgreementByUserId(SubstituteRecordingAgreementVo quoteAgreementVo);
 }

+ 0 - 5
src/main/java/com/ydtech/modules/protocol/service/PtlAgreementAttributionHistoryService.java

@@ -1,13 +1,8 @@
 package com.ydtech.modules.protocol.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
-import com.ydtech.modules.esm.model.EsmInsCompany;
-import com.ydtech.modules.protocol.entity.dto.PtlAgreementAttributionDto;
-import com.ydtech.modules.protocol.entity.po.PtlAgreementAttribution;
 import com.ydtech.modules.protocol.entity.po.PtlAgreementAttributionHistory;
 
-import java.util.List;
-
 
 /**
  * @author wenks

+ 37 - 0
src/main/java/com/ydtech/modules/protocol/service/PtlAgreementSchedulingConfigService.java

@@ -0,0 +1,37 @@
+package com.ydtech.modules.protocol.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig;
+import com.ydtech.modules.protocol.entity.vo.PtlAgreementSchedulingConfigSaveVo;
+
+import java.util.List;
+
+/**
+ * @author wks
+ * @description 针对表【ptl_agreement_scheduling_config(协议调度配置(过滤保险公司))】的数据库操作Service
+ * @createDate 2024-07-22 11:32:12
+ */
+public interface PtlAgreementSchedulingConfigService extends IService<PtlAgreementSchedulingConfig> {
+
+    /**
+     * 新增协议调度配置信息
+     *
+     * @param ptlAgreementSchedulingConfigSaveVo 调度协议配置信息
+     * @return 成功 失败
+     */
+    void allocation(PtlAgreementSchedulingConfigSaveVo ptlAgreementSchedulingConfigSaveVo);
+
+    /**
+     * 通过保险公司id获取配置信息
+     * @param companyId 保险公司id
+     * @return 配置信息
+     */
+    default PtlAgreementSchedulingConfig getByCompanyId(String companyId) {
+        return lambdaQuery()
+                .eq(PtlAgreementSchedulingConfig::getCompanyId, companyId)
+                .one();
+
+    }
+
+
+}

+ 13 - 3
src/main/java/com/ydtech/modules/protocol/service/PtlAgreementService.java

@@ -2,6 +2,7 @@ package com.ydtech.modules.protocol.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.core.page.PageResult;
 import com.ydtech.modules.esm.model.EsmInsCompany;
@@ -15,6 +16,7 @@ import com.ydtech.modules.protocol.entity.vo.*;
 
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 /**
  * @author wenks
@@ -30,6 +32,7 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      */
     List<PtlAgreementInsCompanyDto> getAgreementCompany(String deptId);
 
+
     /**
      * 获取可以报价的 可录入外部订单的协议
      *
@@ -38,9 +41,6 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      */
     List<PtlAgreementInsCompanyDto> getAgreementCompanyExternal(String deptId);
 
-    PtlAgreementInsCompanyDto getAgreementCompany(String deptId, String companyId);
-
-
     /**
      * 通过协议id 判断是否存在
      *
@@ -269,4 +269,14 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      */
     List<PtlAgreement> getAllAgreement(String agreementId);
 
+    /**
+     * 获取保险公司
+     *
+     * @param deptId       机构id
+     * @param companyMap  保险公司列表
+     * @param productsType 险种信息
+     * @return
+     */
+    List<PtlAgreementInsCompanyDto> getAgreementCompany(String deptId, Map<String, Boolean> companyMap, ProductsType productsType);
+
 }

+ 1 - 1
src/main/java/com/ydtech/modules/protocol/service/PtlTaxSourceNewService.java

@@ -65,7 +65,7 @@ public interface PtlTaxSourceNewService extends IService<PtlTaxSourceNew> {
      *  @Date: 2024/5/24 15:33
      *  @Description:  校验车牌、排量、排除部门
      */
-    public String getAgreementId(String deptId, String userId, String companyId, BaseQuoteInfoVo quoteInfo,String riskCode,String orderno);
+     String getAgreementId(String deptId, String userId, String companyId, BaseQuoteInfoVo quoteInfo,String riskCode,String orderno);
     /**
      *  @version
      *  @author: hxl

+ 53 - 0
src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementSchedulingConfigServiceImpl.java

@@ -0,0 +1,53 @@
+package com.ydtech.modules.protocol.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.modules.protocol.dao.PtlAgreementSchedulingConfigMapper;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig;
+import com.ydtech.modules.protocol.entity.vo.PtlAgreementSchedulingConfigSaveVo;
+import com.ydtech.modules.protocol.service.PtlAgreementSchedulingConfigService;
+import com.ydtech.modules.protocol.utils.AssertionUtils;
+import org.apache.commons.lang3.ObjectUtils;
+import org.springframework.beans.BeanUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author wks
+ * @description 针对表【ptl_agreement_scheduling_config(协议调度配置(过滤保险公司))】的数据库操作Service实现
+ * @createDate 2024-07-22 11:32:12
+ */
+@Service
+public class PtlAgreementSchedulingConfigServiceImpl extends ServiceImpl<PtlAgreementSchedulingConfigMapper, PtlAgreementSchedulingConfig>
+        implements PtlAgreementSchedulingConfigService {
+
+    @Override
+    public void allocation(PtlAgreementSchedulingConfigSaveVo ptlAgreementSchedulingConfigSaveVo) {
+        // 拼接字符串
+        PtlAgreementSchedulingConfig ptlAgreementSchedulingConfig = new PtlAgreementSchedulingConfig();
+        BeanUtils.copyProperties(ptlAgreementSchedulingConfigSaveVo, ptlAgreementSchedulingConfig);
+        List<String> productsCode = ptlAgreementSchedulingConfigSaveVo.getProductsCode();
+        String s = String.join(",", productsCode);
+        ptlAgreementSchedulingConfig.setProductsCode(s);
+
+        // 修改
+        Integer id = ptlAgreementSchedulingConfig.getId();
+        if (ObjectUtils.isNotEmpty(id)) {
+            int updateResult = this.baseMapper.updateById(ptlAgreementSchedulingConfig);
+            AssertionUtils.isSucceed(updateResult > 0, "修改配置失败");
+        } else {
+            // 新增
+            PtlAgreementSchedulingConfig config = this.getByCompanyId(ptlAgreementSchedulingConfig.getCompanyId());
+            AssertionUtils.isNotEmpty(config, "修改配置失败");
+            int insertResult = this.baseMapper.insert(ptlAgreementSchedulingConfig);
+            AssertionUtils.isSucceed(insertResult > 0, "新增配置失败");
+        }
+
+    }
+
+}
+
+
+
+

+ 40 - 43
src/main/java/com/ydtech/modules/protocol/service/impl/PtlAgreementServiceImpl.java

@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ydtech.config.DictEnumConfig;
 import com.ydtech.constants.enums.dict.DictionaryData;
 import com.ydtech.constants.enums.dict.DictionaryManagement;
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
 import com.ydtech.core.page.HttpResult;
 import com.ydtech.exception.SystemException;
 import com.ydtech.modules.base.controller.BaseController;
@@ -30,7 +31,6 @@ import com.ydtech.utils.idgen.IdGenerate;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -77,12 +77,9 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
 
     private final PtlAgreementAttributionHistoryService ptlAgreementAttributionHistoryService;
 
-    @Autowired
-    private PtlAgreementDeptHistoryService ptlAgreementDeptHistoryService;
+    private final PtlAgreementDeptHistoryService ptlAgreementDeptHistoryService;
 
-
-    @Autowired
-    private PtlAgreementMapper ptlAgreementMapper;
+    private final PtlAgreementMapper ptlAgreementMapper;
 
     public PtlAgreementServiceImpl(PtlAgreementProductCostsService ptlAgreementProductCostsService,
                                    PtlAgreementAttributionService ptlAgreementAttributionService,
@@ -95,7 +92,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
                                    PtlAgreementHistoryService ptlAgreementHistoryService,
                                    PtlAgreementProductCostsHistoryService ptlAgreementProductCostsHistoryService,
                                    PtlAgreementUndwrtRulesHistoryService ptlAgreementUndwrtRulesHistoryService,
-                                   PtlAgreementAttributionHistoryService ptlAgreementAttributionHistoryService) {
+                                   PtlAgreementAttributionHistoryService ptlAgreementAttributionHistoryService, PtlAgreementDeptHistoryService ptlAgreementDeptHistoryService, PtlAgreementMapper ptlAgreementMapper) {
         this.ptlAgreementProductCostsService = ptlAgreementProductCostsService;
         this.ptlAgreementAttributionService = ptlAgreementAttributionService;
         this.ptlAgreementDeptService = ptlAgreementDeptService;
@@ -109,6 +106,8 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         this.ptlAgreementProductCostsHistoryService = ptlAgreementProductCostsHistoryService;
         this.ptlAgreementUndwrtRulesHistoryService = ptlAgreementUndwrtRulesHistoryService;
         this.ptlAgreementAttributionHistoryService = ptlAgreementAttributionHistoryService;
+        this.ptlAgreementDeptHistoryService = ptlAgreementDeptHistoryService;
+        this.ptlAgreementMapper = ptlAgreementMapper;
     }
 
 
@@ -127,16 +126,6 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
             }
         }
 
-        List<String> agreementIdList = agreementCompany.stream()
-                .flatMap(x -> x.getAgreement().stream().map(PtlAgreementDto::getId))
-                .collect(Collectors.toList());
-
-        /*Map<String, List<String>> licenseNoList = ptlAgreementUndwrtRulesService.getByLicenseNo(agreementIdList);
-
-        agreementCompany.forEach(
-                x -> x.getAgreement().forEach(a -> a.setLicenseNo(licenseNoList.get(a.getId())))
-        );*/
-
         return agreementCompany;
     }
 
@@ -148,31 +137,13 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         for (PtlAgreementInsCompanyDto ptlAgreementInsCompanyDto : agreementCompany) {
             List<PtlAgreementDto> agreement = ptlAgreementInsCompanyDto.getAgreement();
             for (PtlAgreementDto ptlAgreementDto : agreement) {
-                if (ptlAgreementDto.getProductsCode() != null && !ptlAgreementDto.getProductsCode().equals("")) {
+                if (ptlAgreementDto.getProductsCode() != null && !ptlAgreementDto.getProductsCode().isEmpty()) {
                     String[] split = ptlAgreementDto.getProductsCode().split(",");
                     ptlAgreementDto.setProductsCodes(split);
                 }
             }
         }
 
-        List<String> agreementIdList = agreementCompany.stream()
-                .flatMap(x -> x.getAgreement().stream().map(PtlAgreementDto::getId))
-                .collect(Collectors.toList());
-
-        /*Map<String, List<String>> licenseNoList = ptlAgreementUndwrtRulesService.getByLicenseNo(agreementIdList);
-
-        agreementCompany.forEach(
-                x -> x.getAgreement().forEach(a -> a.setLicenseNo(licenseNoList.get(a.getId())))
-        );*/
-
-        return agreementCompany;
-    }
-
-
-    @Override
-    public PtlAgreementInsCompanyDto getAgreementCompany(String deptId, String companyId) {
-        LocalDate localDate = LocalDate.now();
-        PtlAgreementInsCompanyDto agreementCompany = baseMapper.getAgreementCompanyByCompanyId(localDate, deptId, companyId);
         return agreementCompany;
     }
 
@@ -303,14 +274,14 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
     @Transactional
     public HttpResult<Object> saveAgreementNonCarProductCosts(PtlAgreementNonVehicleProductCostsVo agreement, String userName) {
         //同步刷新其他协议非车产品费用信息(有待同步协议时,进行同步)
-        if (agreement.getSyncAgreementIds() != null && agreement.getSyncAgreementIds().size() > 0) {
+        if (agreement.getSyncAgreementIds() != null && !agreement.getSyncAgreementIds().isEmpty()) {
             for (int i = 0; i < agreement.getSyncAgreementIds().size(); i++) {
                 String tempAgreementId = agreement.getSyncAgreementIds().get(i);
                 PtlAgreement destAgreement = getById(tempAgreementId);
                 //根据归属保司,找出本级和上级 所有产品代码
                 //先获取相关保险公司列表
                 String companyId = destAgreement.getPartnerCompaniesId();
-                if (destAgreement.getAssociationCompaniesId() != null && !"".equals(destAgreement.getAssociationCompaniesId())) {
+                if (destAgreement.getAssociationCompaniesId() != null && !destAgreement.getAssociationCompaniesId().isEmpty()) {
                     companyId = destAgreement.getAssociationCompaniesId();
                 }
                 List<String> companyIdList = esmInsCompanyService.getAllRelationCompanyId(companyId);
@@ -547,11 +518,12 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         boolean b = removeById(agreementId);
         AssertionUtils.isSucceed(b, "协议信息删除失败");
         // 关联表删除
-        proxyObject.deleteAssociationInformation(agreementId);
+        // proxyObject.deleteAssociationInformation(agreementId);
         // 添加 历史记录表
         //生成批次号
         String batchNo = IdGenerate.nextId();
         List<PtlAgreementDept> dept = byAgreementId.getData().getDept();
+
         ArrayList<PtlAgreementDeptHistory> histories = new ArrayList<>();
         for (PtlAgreementDept ptlAgreementDept : dept) {
             PtlAgreementDeptHistory deptHistory = new PtlAgreementDeptHistory();
@@ -560,6 +532,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
             deptHistory.setBatch(batchNo);
         }
         ptlAgreementDeptHistoryService.saveBatch(histories);
+
         PtlAgreementHistory ptlAgreementHistory = new PtlAgreementHistory(batchNo, userName, HistoryStatusConstants.HISTORY_TYPE_ADD,
                 byAgreementId.getData().getAgreement());
         ptlAgreementHistory.setStartDate(byAgreementId.getData().getAgreement().getStartDate().format(DateTimeFormatter.ofPattern("yyyy" +
@@ -570,6 +543,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         ptlAgreementHistory.setId(IdGenerate.nextId());
         ptlAgreementHistory.setOperatorType("delete");
         ptlAgreementHistoryService.saveAgreementHistory(ptlAgreementHistory);
+
         PtlAgreementAttributionHistory ptlAgreementAttributionHistory = new PtlAgreementAttributionHistory(batchNo, agreementId,
                 byAgreementId.getData().getAgreement().getInsuranceCompanyId(),
                 byAgreementId.getData().getAgreement().getInsuranceCompany(),
@@ -579,6 +553,7 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         if (StringUtils.isNotEmpty(ptlAgreementAttributionHistory.getTemplateId())) {
             ptlAgreementAttributionHistoryService.save(ptlAgreementAttributionHistory);
         }
+
         return HttpResult.ok("删除成功");
     }
 
@@ -701,14 +676,13 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
     public HttpResult<List<PtlAgreementNonCarProductCostsVo>> getNonCarCostsInfo(String agreementId, String companyId) {
         List<PtlAgreementNonCarProductCostsVo> result = new ArrayList<>();
         //先根据传过来的保险公司代码,找上下级所有机构层级对应的非车产品列表
-        if (companyId != null && !"".equals(companyId)) {
+        if (companyId != null && !companyId.isEmpty()) {
             //先获取相关保险公司列表
             List<String> companyIdList = esmInsCompanyService.getAllRelationCompanyId(companyId);
             //再根据保险公司列表获取所有非车产品列表
             List<PtlNonCarInsuranceProduct> productList = ptlNonCarInsuranceProductService.findProductListByCompangIds(companyIdList);
-            if (productList != null && productList.size() > 0) {
-                for (int i = 0; i < productList.size(); i++) {
-                    PtlNonCarInsuranceProduct tempProductDto = productList.get(i);
+            if (productList != null && !productList.isEmpty()) {
+                for (PtlNonCarInsuranceProduct tempProductDto : productList) {
                     PtlAgreementNonCarProductCostsVo costsVo = new PtlAgreementNonCarProductCostsVo();
                     costsVo.setProductId(tempProductDto.getProductCode());
                     costsVo.setProductName(tempProductDto.getProductName());
@@ -870,4 +844,27 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
                 .eq(PtlAgreement::getInsuranceCompanyId, ptlAgreement.getInsuranceCompanyId()));
     }
 
+    @Override
+    public List<PtlAgreementInsCompanyDto> getAgreementCompany(String deptId, Map<String, Boolean> companyMap, ProductsType productsType) {
+        LocalDate localDate = LocalDate.now();
+        List<PtlAgreementInsCompanyDto> agreementCompany = baseMapper.getAgreementCompany(localDate, deptId);
+        return agreementCompany.stream()
+                // 过滤协议
+                .peek(x -> {
+                    if (companyMap.get(x.getId()) != null && companyMap.get(x.getId())) {
+                        List<PtlAgreementDto> agreementDtoList = x.getAgreement().stream().filter(agreement -> {
+                            if (ObjectUtils.isNotEmpty(productsType) && StringUtils.isNotEmpty(agreement.getProductsCode())) {
+                                String[] split = agreement.getProductsCode().split(",");
+                                return Arrays.stream(split).anyMatch(element -> productsType.getCode().equals(element));
+                            }
+                            return true;
+                        }).collect(Collectors.toList());
+                        x.setAgreement(agreementDtoList);
+                    }
+                })
+                // 过滤保险公司
+                .filter(x -> companyMap.get(x.getId()) != null && companyMap.get(x.getId()) && x.getAgreement() != null && !x.getAgreement().isEmpty())
+                .collect(Collectors.toList());
+
+    }
 }

+ 1 - 1
src/main/java/com/ydtech/modules/protocol/service/impl/PtlTaxSourceServiceImpl.java

@@ -539,7 +539,7 @@ public class PtlTaxSourceServiceImpl extends ServiceImpl<PtlTaxSourceNewMapper,
        // if (excludeDepts.stream().anyMatch(taxSourceDto -> taxSourceDto.getExcludeInfo().equals(deptId))) {
         //    isExclude = false;
        // }
-        if(prioritySortList!=null && prioritySortList.size()>0){
+        if(prioritySortList!=null && !prioritySortList.isEmpty()){
             int size = prioritySortList.size();
             for (int i = 0; i < size; i++) {
                 //判断是否为空,如果不为空直接跳出

+ 105 - 182
src/main/java/com/ydtech/modules/protocol/service/impl/TaxSourceServiceImpl.java

@@ -5,70 +5,60 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.ydtech.constants.enums.InsuranceRisk;
+import com.ydtech.constants.enums.dict.agreement.ProductsType;
 import com.ydtech.constants.sys.SystemConstant;
 import com.ydtech.modules.admin.constants.RoleConstants;
 import com.ydtech.modules.admin.model.SysUser;
 import com.ydtech.modules.admin.model.SysUserRole;
 import com.ydtech.modules.admin.service.SysUserRoleService;
 import com.ydtech.modules.admin.service.SysUserService;
-import com.ydtech.modules.esm.model.EsmInsCompany;
-import com.ydtech.modules.esm.service.EsmInsCompanyService;
-import com.ydtech.modules.order.service.InsOrdersService;
 import com.ydtech.modules.protocol.constants.TaxSourceStatusConstants;
 import com.ydtech.modules.protocol.dao.PtlTaxSourceNewMapper;
 import com.ydtech.modules.protocol.dao.TaxSourceMapper;
-import com.ydtech.modules.protocol.entity.dto.PtlAgreementDto;
-import com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto;
-import com.ydtech.modules.protocol.entity.dto.TaxSourceDto;
-import com.ydtech.modules.protocol.entity.dto.TaxSourceExcludeDto;
+import com.ydtech.modules.protocol.entity.dto.*;
 import com.ydtech.modules.protocol.entity.po.PtlAgreement;
+import com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig;
 import com.ydtech.modules.protocol.entity.po.PtlTaxSourceNew;
+import com.ydtech.modules.protocol.entity.vo.QuoteAgreementVo;
+import com.ydtech.modules.protocol.entity.vo.SubstituteRecordingAgreementVo;
 import com.ydtech.modules.protocol.entity.vo.TaxSourceVo;
 import com.ydtech.modules.protocol.service.ITaxSourceExcludeService;
 import com.ydtech.modules.protocol.service.ITaxSourceService;
+import com.ydtech.modules.protocol.service.PtlAgreementSchedulingConfigService;
 import com.ydtech.modules.protocol.service.PtlAgreementService;
 import com.ydtech.modules.protocol.utils.AssertionUtils;
+import com.ydtech.modules.protocol.utils.EnableUtils;
 import com.ydtech.utils.idgen.IdGenerate;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @Service
+@RequiredArgsConstructor
 public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSourceDto> implements ITaxSourceService {
 
-    @Autowired
-    PtlAgreementService ptlAgreementService;
+    private final PtlAgreementService ptlAgreementService;
 
-    @Autowired
-    ITaxSourceExcludeService taxSourceExcludeService;
-
-    @Autowired
-    InsOrdersService insOrdersService;
-
-    @Autowired
-    SysUserRoleService sysUserRoleService;
-
-    @Autowired
-    EsmInsCompanyService esmInsCompanyService;
-
-    @Autowired
-    SysUserService sysUserService;
-
-    @Autowired
-    private PtlTaxSourceNewMapper ptlTaxSourceNewMapper;
+    private final ITaxSourceExcludeService taxSourceExcludeService;
 
+    private final SysUserRoleService sysUserRoleService;
 
+    private final PtlTaxSourceNewMapper ptlTaxSourceNewMapper;
 
+    @Override
+    public IPage<PtlAgreementSchedulingDto> getInsureCompany(Page<PtlAgreementSchedulingDto> page, String companyId) {
+        return baseMapper.getInsureCompany(page, companyId);
+    }
 
     @Override
-    public IPage<EsmInsCompany> getInsureCompany(Page page) {
-        return baseMapper.getInsureCompany(page);
+    public List<PtlAgreementSchedulingDto> getPtlAgreementScheduling() {
+        return baseMapper.getPtlAgreementScheduling();
     }
 
     @Override
@@ -198,7 +188,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSource
         // 领导标志
         SysUserRole userRole = sysUserRoleService.selectByUserId(userId);
 
-        if (userRole!=null && Arrays.asList(SystemConstant.getSysRoleTeamLeader()).contains(userRole.getRoleId().toString()) && !RoleConstants.R21.getCode().equals(userRole.getRoleId().toString())) { //团队长可查询下面所有人员订单
+        if (userRole != null && Arrays.asList(SystemConstant.getSysRoleTeamLeader()).contains(userRole.getRoleId().toString()) && !RoleConstants.R21.getCode().equals(userRole.getRoleId().toString())) { //团队长可查询下面所有人员订单
             deptId = null;
         }
 
@@ -206,95 +196,6 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSource
         return agreementCompany;
     }
 
-    public PtlAgreementInsCompanyDto getAgreementInsCompany(String deptId, String userId, String companyId) {
-        // 领导标志
-        SysUserRole userRole = sysUserRoleService.selectByUserId(userId);
-
-        if (Arrays.asList(SystemConstant.getSysRoleTeamLeader()).contains(userRole.getRoleId().toString()) && !RoleConstants.R21.getCode().equals(userRole.getRoleId().toString())) { //团队长可查询下面所有人员订单
-            deptId = null;
-        }
-
-        PtlAgreementInsCompanyDto agreementCompany = ptlAgreementService.getAgreementCompany(deptId, companyId);
-        return agreementCompany;
-    }
-
-//    @Override
-//    public List<PtlAgreementInsCompanyDto> getAgreementInsCompany(String deptId, String userId, String license,
-//    String volume) {
-//        //查出所有协议
-//        List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId);
-//        if(license != null && volume != null) {
-//            //排除的部门信息
-//            List<TaxSourceExcludeDto> excludeDepts = taxSourceExcludeService.list(new
-//            LambdaQueryWrapper<TaxSourceExcludeDto>().eq
-//            (TaxSourceExcludeDto::getExcludeInfo, deptId)
-//                    .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_DEPT));
-//
-//            agreementInsCompany.forEach(item ->
-//                    excludeDepts.stream()
-//                            .filter(taxSourceDto -> item.getId().equals(taxSourceDto.getInsCompanyId()) &&
-//                            taxSourceDto.getExcludeInfo
-//                            ().equals(deptId))
-//                            .findFirst()
-//                            .ifPresent(taxSourceDto -> item.setIsExclude(TaxSourceStatusConstants.TAX_SOURCE_START))
-//            );
-//            //查找排除的车牌号
-//            List<TaxSourceExcludeDto> licenseExclude = taxSourceExcludeService.list(new
-//            LambdaQueryWrapper<TaxSourceExcludeDto>().eq
-//            (TaxSourceExcludeDto::getExcludeInfo, license)
-//                    .eq(TaxSourceExcludeDto::getType, TaxSourceStatusConstants.EXCLUDE_TYPE_LICENSE));
-//            agreementInsCompany.forEach(item -> {
-//                licenseExclude.forEach(taxSourceDto -> {
-//                    if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
-//                        if (license.equals(taxSourceDto.getExcludeInfo())) {
-//                            //排除
-//                            item.setIsExclude(TaxSourceStatusConstants.TAX_SOURCE_START);
-//                        }
-//                    }
-//                });
-//            });
-//
-//            //查找配置的默认项
-//            List<TaxSourceDto> taxSourceDefaultDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>()
-//                    .eq(TaxSourceDto::getLicense, license));
-//            //设置协议的默认项
-//            agreementInsCompany.forEach(item -> {
-//                taxSourceDefaultDtos.forEach(taxSourceDto -> {
-//                    if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
-//                        item.getAgreement().forEach(agreement -> {
-//                            if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
-//                                agreement.setIsAllocation(TaxSourceStatusConstants.TAX_SOURCE_START);
-//                            }
-//                        });
-//                    }
-//                });
-//            });
-//            //判断汽车排量是否大于1升
-//            if (Float.parseFloat(volume) >= 1) {
-//                //查找是否配置税源
-//                List<TaxSourceDto> taxSourceDtos = baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq
-//                (TaxSourceDto::getIsTaxSource, "1"));
-//                //设置税源参数
-//                agreementInsCompany.forEach(item -> {
-//                    if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
-//                        taxSourceDtos.forEach(taxSourceDto -> {
-//                            if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
-//                                item.getAgreement().forEach(agreement -> {
-//                                    if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
-//                                        agreement.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
-//                                        item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
-//                                        item.setTaxSourceAgreementId(taxSourceDto.getAgreementId());
-//                                    }
-//                                });
-//                            }
-//                        });
-//                    }
-//                });
-//            }
-//        }
-//        return agreementInsCompany;
-//    }
-
     /**
      * 返回是否是税源
      *
@@ -303,34 +204,53 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSource
      * @return
      */
     @Override
-    public List<PtlAgreementInsCompanyDto> getAllAgreement(String deptId, String userId) {
-        //查出所有协议
-        List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId);
+    public List<PtlAgreementInsCompanyDto> getAllAgreement(String deptId, String userId, QuoteAgreementVo quoteAgreementVo, List<PtlAgreementSchedulingDto> ptlAgreementScheduling) {
 
-        //查找是否配置税源    原逻辑注释掉
-        //List<TaxSourceDto> taxSourceDtos =
-        //        baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource, "1"));
-        //修改协议的默认   add by hxl   2024-05-27
-        List<PtlTaxSourceNew> taxSourceDtos = ptlTaxSourceNewMapper.findDefaultAllAttrLink();
-        //设置税源参数
-        agreementInsCompany.forEach(item -> {
-            if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
-                taxSourceDtos.forEach(taxSourceDto -> {
-                    if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
-                        item.getAgreement().forEach(agreement -> {
-                            if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
-                                agreement.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
-                                item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
-                                item.setTaxSourceAgreementId(taxSourceDto.getAgreementId());
-                            }
-                        });
+        // 获取险种配置信息
+        ProductsType productsType = InsuranceRisk.determineInsuranceInformation(quoteAgreementVo.getKindList(), quoteAgreementVo.getRiskList());
+
+        // 险种过滤map
+        Map<String, Boolean> collectMap = ptlAgreementScheduling.stream().collect(
+                Collectors.toMap(PtlAgreementSchedulingDto::getId, x -> {
+                    if (ObjectUtils.isNotEmpty(productsType) && StringUtils.isNotEmpty(x.getProductsCode())) {
+                        String[] split = x.getProductsCode().split(",");
+                        return Arrays.stream(split).anyMatch(element -> productsType.getCode().equals(element));
                     }
-                });
+                    return true;
+                }));
+
+        //查出所有协议
+        List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(deptId, userId, collectMap, productsType);
+        List<PtlTaxSourceNew> taxSourceDtos = ptlTaxSourceNewMapper.findDefaultAllAttrLink();
+
+        // 默认协议的协议编码
+        Map<String, String> map = taxSourceDtos.stream()
+                .collect(Collectors.toMap(PtlTaxSourceNew::getInsCompanyId, PtlTaxSourceNew::getAgreementId));
+
+        // 是否启用Map
+        Map<String, Boolean> systemTypeMap = ptlAgreementScheduling.stream().collect(
+                Collectors.toMap(PtlAgreementSchedulingDto::getId, x -> EnableUtils.isEnable(quoteAgreementVo.getSystemType(), x.getPcStart(), x.getAppStart())));
+
+        //设置协议调度
+        return agreementInsCompany.stream().peek(item -> {
+            String agreementId = map.get(item.getId());
+            if (systemTypeMap.get(item.getId()) != null && systemTypeMap.get(item.getId()) && StringUtils.isNotEmpty(agreementId)) {
+                item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
+                item.setTaxSourceAgreementId(agreementId);
             }
-        });
-        return agreementInsCompany;
+        }).collect(Collectors.toList());
+    }
+
+    private List<PtlAgreementInsCompanyDto> getAgreementInsCompany(String deptId, String userId, Map<String, Boolean> companyMap, ProductsType productsType) {
+        // 领导标志
+        SysUserRole userRole = sysUserRoleService.selectByUserId(userId);
+        if (userRole != null && Arrays.asList(SystemConstant.getSysRoleTeamLeader()).contains(userRole.getRoleId().toString()) && !RoleConstants.R21.getCode().equals(userRole.getRoleId().toString())) { //团队长可查询下面所有人员订单
+            deptId = null;
+        }
+        return ptlAgreementService.getAgreementCompany(deptId, companyMap, productsType);
     }
 
+
     /**
      * 根据税源获取协议id
      *
@@ -353,7 +273,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSource
                 baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getInsCompanyId,
                         companyId));
 
-        if(taxSourceDtoList.isEmpty()){
+        if (taxSourceDtoList.isEmpty()) {
             return resultId;
         }
 
@@ -385,7 +305,7 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSource
         // 税源
         List<TaxSourceDto> collect = taxSourceDtoList.stream().filter(x -> x.getIsTaxSource().equals("1")).collect(Collectors.toList());
         TaxSourceDto taxSourceDtos = null;
-        if(!collect.isEmpty()){
+        if (!collect.isEmpty()) {
             taxSourceDtos = collect.get(0);
         }
 
@@ -397,46 +317,49 @@ public class TaxSourceServiceImpl extends ServiceImpl<TaxSourceMapper, TaxSource
 
         // 不包含险种 随机其他保险公司
 
-        if (taxSourceDtos != null && taxSourceDtos.getAgreementId().equals(resultId) && taxSourceDtos.getInsuranceRepertoire().contains(productid+",")) {
+        if (taxSourceDtos != null && taxSourceDtos.getAgreementId().equals(resultId) && taxSourceDtos.getInsuranceRepertoire().contains(productid + ",")) {
             resultId = taxSourceDtos.getBanishAgreementId();
         }
 
         return resultId;
     }
-    /**
-     *  @version
-     *  @author: hxl
-     *  @Date: 2024/4/18 10:18
-     *  @Description: 通过用户id查询关联的协议
-     */
-    @Override
-    public List<PtlAgreementInsCompanyDto> getAllAgreementByUserId(String userId) {
-        SysUser user = sysUserService.getById(userId);
-        //查出当前用户管理所有协议
-        List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(user.getDeptId(), userId);
-        //查找是否配置税源   注释掉原先的逻辑
-       // List<TaxSourceDto> taxSourceDtos =
-           //     baseMapper.selectList(new LambdaQueryWrapper<TaxSourceDto>().eq(TaxSourceDto::getIsTaxSource, "1"));
-        //修改协议的默认   add by hxl   2024-05-27
-        List<PtlTaxSourceNew> taxSourceDtos = ptlTaxSourceNewMapper.findDefaultAllAttrLink();
-        //设置税源参数
-        agreementInsCompany.forEach(item -> {
-            if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
-                taxSourceDtos.forEach(taxSourceDto -> {
-                    if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
-                        item.getAgreement().forEach(agreement -> {
-                            if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
-                                agreement.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
-                                item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
-                                item.setTaxSourceAgreementId(taxSourceDto.getAgreementId());
-                            }
-                        });
-                    }
-                });
-            }
-        });
-        return agreementInsCompany;
-    }
+
+//    /**
+//     * @version
+//     * @author: hxl
+//     * @Date: 2024/4/18 10:18
+//     * @Description: 通过用户id查询关联的协议
+//     */
+//    @Override
+//    public List<PtlAgreementInsCompanyDto> getAllAgreementByUserId(SubstituteRecordingAgreementVo quoteAgreementVo) {
+//        String userId = quoteAgreementVo.getUserId();
+//        SysUser user = sysUserService.getById(userId);
+//        //查出当前用户管理所有协议
+//
+//        List<PtlAgreementInsCompanyDto> agreementInsCompany = this.getAgreementInsCompany(user.getDeptId(), userId);
+//        //查找是否配置税源   注释掉原先的逻辑
+//
+//        //修改协议的默认   add by hxl   2024-05-27
+//        List<PtlTaxSourceNew> taxSourceDtos = ptlTaxSourceNewMapper.findDefaultAllAttrLink();
+//        //设置税源参数
+//        agreementInsCompany.forEach(item -> {
+//            if (!TaxSourceStatusConstants.TAX_SOURCE_START.equals(item.getIsExclude())) {
+//                taxSourceDtos.forEach(taxSourceDto -> {
+//                    if (item.getId().equals(taxSourceDto.getInsCompanyId())) {
+//                        item.getAgreement().forEach(agreement -> {
+//                            if (agreement.getId().equals(taxSourceDto.getAgreementId())) {
+//                                agreement.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
+//                                item.setIsTaxSource(TaxSourceStatusConstants.TAX_SOURCE_START);
+//                                item.setTaxSourceAgreementId(taxSourceDto.getAgreementId());
+//                            }
+//                        });
+//                    }
+//                });
+//            }
+//        });
+//
+//        return agreementInsCompany;
+//    }
 
 
 }

+ 12 - 0
src/main/java/com/ydtech/modules/protocol/utils/AssertionUtils.java

@@ -54,6 +54,18 @@ public class AssertionUtils {
         assertion(ObjectUtils.isEmpty(o), message);
     }
 
+    /**
+     * 判断对象是否为空 并报错
+     * 不为空-> 报错
+     *
+     * @param o       java.lang.Object
+     * @param message 报错内容
+     */
+    public static void isNotEmpty(Object o, String message) {
+        assertion(!ObjectUtils.isEmpty(o), message);
+    }
+
+
     /**
      * 判断字符串是否为空 并报错
      * 空->报错

+ 19 - 0
src/main/java/com/ydtech/modules/protocol/utils/EnableUtils.java

@@ -0,0 +1,19 @@
+package com.ydtech.modules.protocol.utils;
+
+
+public class EnableUtils {
+
+    private EnableUtils() {
+        throw new IllegalStateException("AssertionUtils class");
+    }
+
+    public static boolean isEnable(int systemType, int pcStart, int appStart) {
+        if (pcStart > 0 && systemType == 1) {
+            return true;
+        } else {
+            return appStart > 0 && systemType == 2;
+        }
+    }
+
+}
+

+ 5 - 0
src/main/resources/application-pre.yml

@@ -75,6 +75,11 @@ mybatis:
   mapper-locations: classpath:mapper/**/*.xml
   type-aliases-package: com.ydtech.modules.*.model
 mybatis-plus:
+  global-config:
+    db-config:
+      logic-delete-field: deleted # 全局逻辑删除字段名
+      logic-delete-value: 1 # 逻辑已删除值
+      logic-not-delete-value: 0 # 逻辑未删除值
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 netUrl: http://baoxianzhanggui.com:8080/

+ 5 - 0
src/main/resources/application-prod.yml

@@ -75,6 +75,11 @@ mybatis:
   mapper-locations: classpath:mapper/**/*.xml
   type-aliases-package: com.ydtech.modules.*.model
 mybatis-plus:
+  global-config:
+    db-config:
+      logic-delete-field: deleted # 全局逻辑删除字段名
+      logic-delete-value: 1 # 逻辑已删除值
+      logic-not-delete-value: 0 # 逻辑未删除值
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 netUrl: http://baoxianzhanggui.com:8080/

+ 5 - 0
src/main/resources/application-test.yml

@@ -87,6 +87,11 @@ mybatis:
   mapper-locations: classpath:mapper/**/*.xml
   type-aliases-package: com.ydtech.modules.*.model
 mybatis-plus:
+  global-config:
+    db-config:
+      logic-delete-field: deleted # 全局逻辑删除字段名
+      logic-delete-value: 1 # 逻辑已删除值
+      logic-not-delete-value: 0 # 逻辑未删除值
   configuration:
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 ##测试地址

+ 2 - 1
src/main/resources/mapper/modules/protocol/PtlAgreementMapper.xml

@@ -31,6 +31,7 @@
         <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
         <result property="modifiedBy" column="modified_by" jdbcType="VARCHAR"/>
         <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
+        <result property="deleted" column="deleted" jdbcType="TINYINT"/>
     </resultMap>
 
     <resultMap id="AgreementCompanyResultMap" type="com.ydtech.modules.protocol.entity.dto.PtlAgreementInsCompanyDto">
@@ -70,7 +71,7 @@
     </sql>
 
     <select id="getAgreementCompany" resultMap="AgreementCompanyResultMap">
-        select eic.*, pa.id as agreement_id, pa.agreement_name,pa.products_code, paa.api_type, pa.underwriting_description,
+        select eic.*, pa.id as agreement_id, pa.agreement_name, pa.products_code, paa.api_type, pa.underwriting_description,
                pa.business_description,pa.job_description
         from esm_ins_company as eic
                  left join ptl_agreement as pa on pa.insurance_company_id = eic.id

+ 20 - 0
src/main/resources/mapper/modules/protocol/PtlAgreementSchedulingConfigMapper.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.ydtech.modules.protocol.dao.PtlAgreementSchedulingConfigMapper">
+
+    <resultMap id="BaseResultMap" type="com.ydtech.modules.protocol.entity.po.PtlAgreementSchedulingConfig">
+            <id property="id" column="id" jdbcType="INTEGER"/>
+            <result property="companyId" column="company_id" jdbcType="VARCHAR"/>
+            <result property="companyName" column="company_name" jdbcType="VARCHAR"/>
+            <result property="appStart" column="app_start" jdbcType="TINYINT"/>
+            <result property="pcStart" column="pc_start" jdbcType="TINYINT"/>
+            <result property="productsCode" column="products_code" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,company_id,company_name,
+        app_start,pc_start,products_code
+    </sql>
+</mapper>

+ 33 - 7
src/main/resources/mapper/modules/protocol/TaxSourceMapper.xml

@@ -27,16 +27,29 @@
         <result property="insuranceCompany" column="insurance_company" jdbcType="VARCHAR"/>
     </resultMap>
 
-    <select id="getInsureCompany" resultMap="CompanyResultMap">
+    <resultMap id="SchedulingCompanyResultMap" type="com.ydtech.modules.protocol.entity.dto.PtlAgreementSchedulingDto">
+        <id property="id" column="id" jdbcType="VARCHAR"/>
+        <result property="name" column="name" jdbcType="VARCHAR"/>
+        <result property="pcStart" column="pc_start" jdbcType="INTEGER"/>
+        <result property="appStart" column="app_start" jdbcType="INTEGER"/>
+        <result property="productsCode" column="products_code" jdbcType="VARCHAR"/>
+    </resultMap>
+
+    <select id="getInsureCompany" resultMap="SchedulingCompanyResultMap">
         SELECT
-            eic.*
+        eic.id, eic.name, pasc.pc_start, pasc.app_start, pasc.products_code
         FROM
-            esm_ins_company eic,
-            ptl_agreement pa
-        WHERE
-            eic.id = pa.insurance_company_id
+        esm_ins_company eic
+        left join ptl_agreement pa on pa.insurance_company_id = eic.id
+        left join ptl_agreement_scheduling_config pasc on pasc.company_id = eic.id
+        where eic.parent_id = '0' and pa.insurance_company_id = eic.id
+        <if test="companyId != '' and companyId  != null ">
+            and eic.id = #{companyId}
+        </if>
+
         GROUP BY
-            eic.id
+        eic.id,
+        pasc.id
     </select>
 
     <select id="getAgreementByCompanyId" resultMap="AgreementResultMap">
@@ -48,6 +61,19 @@
             insurance_company_id = #{companyId}
     </select>
 
+    <select id="getPtlAgreementScheduling"
+            resultType="com.ydtech.modules.protocol.entity.dto.PtlAgreementSchedulingDto">
+        SELECT
+        eic.id, eic.name, pasc.pc_start, pasc.app_start, pasc.products_code
+        FROM
+        esm_ins_company eic
+        left join ptl_agreement pa on pa.insurance_company_id = eic.id
+        left join ptl_agreement_scheduling_config pasc on pasc.company_id = eic.id
+        where eic.parent_id = '0' and pa.insurance_company_id = eic.id
+        GROUP BY
+        eic.id,
+        pasc.id
+    </select>
 
 
 </mapper>