Просмотр исходного кода

Merge remote-tracking branch 'origin/dev_jzg_lipf_v20260518' into dev_jzg_lipf_v20260518

jiakai 4 месяцев назад
Родитель
Сommit
e5c9b9843e

+ 29 - 0
tenant/organization/src/main/java/com/jzg/organization/service/PtlAreaLicenseService.java

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
 import com.jzg.commons.entity.po.PtlAreaLicense;
 
 import java.util.List;
+import java.util.Map;
 
 public interface PtlAreaLicenseService extends IService<PtlAreaLicense> {
 
@@ -15,4 +16,32 @@ public interface PtlAreaLicenseService extends IService<PtlAreaLicense> {
      */
     List<PtlAreaLicense> getByParentNumber(String parentNumber);
 
+    /**
+     * 查看车牌号和所有地区的对应关系
+     *
+     * @return List<PtlAreaLicense> 所有车牌号和地区的对应关系
+     * @author lipf
+     * @date 2026/5/21 9:40
+     */
+    List<PtlAreaLicense> queryAllAreaLicense();
+
+    /**
+     * 查看车牌号和所有地区的对应关系
+     *
+     * @return Map<String,PtlAreaLicense> key是areaNumber, value是地区和车牌前缀的对应关系
+     * @author lipf
+     * @date 2026/5/21 9:45
+     */
+    Map<String,PtlAreaLicense> queryAllAreaLicenseMap();
+
+    /**
+     * 将地区编码转换为对应的车牌号
+     *
+     * @param areaNumbers 地区编码,支持多个拼接,例如1401,1402,1403
+     * @return String 地区车牌号,例如晋A,晋B,晋C
+     * @author lipf
+     * @date 2026/5/21 9:53
+     */
+    String convertAreaNumber2License(Map<String,PtlAreaLicense> areaLicenseMap , String areaNumbers);
+
 }

+ 42 - 47
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementDispatchServiceImpl.java

@@ -12,10 +12,8 @@ import com.jzg.commons.entity.agreement.dispatch.dto.PtlAgreementDispatchRulesAt
 import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchQuery;
 import com.jzg.commons.entity.agreement.dispatch.vo.PtlAgreementDispatchVo;
 import com.jzg.commons.entity.agreement.po.PtlAgreementAttribution;
-import com.jzg.commons.entity.po.PtlAgreement;
-import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesAttr;
-import com.jzg.commons.entity.po.PtlAgreementUndwrtRulesDictLabal;
-import com.jzg.commons.entity.po.SysDict;
+import com.jzg.commons.entity.po.*;
+import com.jzg.commons.util.StringUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.organization.client.EsmInsCompanyClient;
 import com.jzg.organization.mapper.PtlAgreementDispatchActionMapper;
@@ -29,10 +27,7 @@ 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.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -48,27 +43,22 @@ public class PtlAgreementDispatchServiceImpl extends ServiceImpl<PtlAgreementDis
 
     @Autowired
     PtlAgreementDispatchRulesAttrLinkMapper rulesAttrLinkMapper;
-
-    @Autowired
-    PtlAgreementDispatchActionMapper actionMapper;
-
     @Autowired
     PtlAgreementUndwrtRulesAttrService ptlAgreementUndwrtRulesAttrService;
-
     @Autowired
     PtlAgreementUndwrtRulesDictLabalService ptlAgreementUndwrtRulesDictLabalService;
-
+    @Autowired
+    private PtlAreaLicenseService ptlAreaLicenseService;
     @Autowired
     SysDictService sysDictService;
-
     @Autowired
     PtlAgreementService ptlAgreementService;
-
     @Autowired
     EsmInsCompanyClient esmInsCompanyClient;
-
     @Autowired
     PtlAgreementDispatchAfterActionMapper afterActionMapper;
+    @Autowired
+    PtlAgreementDispatchActionMapper actionMapper;
     @Override
     @Transactional
     public String addAgreementDispatch(PtlAgreementDispatchVo.DispatchVo ptlAgreementDispatchVo) {
@@ -134,10 +124,14 @@ public class PtlAgreementDispatchServiceImpl extends ServiceImpl<PtlAgreementDis
             // 查询保司所有的规则属性 然后进行分组
             List<PtlAgreementDispatchRulesAttrLink> ptlAgreementDispatchRulesAttrLinks = rulesAttrLinkMapper.selectList(new LambdaQueryWrapper<PtlAgreementDispatchRulesAttrLink>()
                     .in(PtlAgreementDispatchRulesAttrLink::getDispatchId, dispatchIds));
-
+            ptlAgreementDispatchRulesAttrLinks = ptlAgreementDispatchRulesAttrLinks.stream().peek(action->{
+                String min = action.getMin();
+                if(StringUtils.isNotEmpty(min)){
+                    action.setMinArray(Arrays.asList(min.split(",")));
+                }
+            }).toList();
             // 获取所有保司的动作
             List<PtlAgreementDispatchAction> ptlAgreementDispatchActions = actionMapper.getActions(dispatchIds);
-
             // 获取保司的报价失败之后的动作
             List<PtlAgreementDispatchAfterAction> ptlAgreementDispatchAfterActions = afterActionMapper.getAfterActions(ptlAgreementDispatchQuery.getCompanyId());
             int index = 1;
@@ -145,6 +139,15 @@ public class PtlAgreementDispatchServiceImpl extends ServiceImpl<PtlAgreementDis
             List<PtlAgreementUndwrtRulesDictLabal> ptlAgreementUndwrtRulesDictLabals = baseMapper.queryAllDictLabal();
             Map<String, String> dictLabalId2Name = ptlAgreementUndwrtRulesDictLabals.stream()
                     .collect(Collectors.toMap(PtlAgreementUndwrtRulesDictLabal::getIdStr, PtlAgreementUndwrtRulesDictLabal::getName));
+            Map<String, PtlAreaLicense> areaLicenseMap = ptlAreaLicenseService.queryAllAreaLicenseMap();
+
+            Map<String,String> operatorMap = new HashMap<>();
+            operatorMap.put("1","包含");
+            operatorMap.put("2","小于");
+            operatorMap.put("3","小于等于");
+            operatorMap.put("4","大于");
+            operatorMap.put("5","大于等于");
+            operatorMap.put("","未知");
             for(PtlAgreementDispatch dispatch : ptlAgreementDispatches){
                 if(dispatch.getDispatchName().isEmpty()){
                     dispatch.setDispatchName("规则" + index);
@@ -153,41 +156,33 @@ public class PtlAgreementDispatchServiceImpl extends ServiceImpl<PtlAgreementDis
                 List<PtlAgreementDispatchRulesAttrLink> attrLinks = ptlAgreementDispatchRulesAttrLinks.stream().filter(x -> x.getDispatchId().equals(dispatch.getId())).collect(Collectors.toList());
                 List<PtlAgreementDispatchAction> actions = ptlAgreementDispatchActions.stream().filter(x -> x.getDispatchId().equals(dispatch.getId())).collect(Collectors.toList());
                 for(PtlAgreementDispatchRulesAttrLink attrlink : attrLinks){
-                    if (attrlink.getOperator() != null) {
-                        if (attrlink.getOperator().equals("1")) {
-                            attrlink.setOperatorDesc("包含");
-                        }
-                        if (attrlink.getOperator().equals("2")) {
-                            attrlink.setOperatorDesc("小于");
-                        }
-                        if (attrlink.getOperator().equals("3")) {
-                            attrlink.setOperatorDesc("小于等于");
-                        }
-                        if (attrlink.getOperator().equals("4")) {
-                            attrlink.setOperatorDesc("大于");
-                        }
-                        if (attrlink.getOperator().equals("5")) {
-                            attrlink.setOperatorDesc("大于等于");
-                        }
+                    log.info("attrlink=[{}]", JSONUtil.toJsonStr(attrlink));
+                    attrlink.setOperatorDesc(operatorMap.get(Objects.toString(attrlink.getOperator(),"")));
+                    if("LicenseNo".equals(attrlink.getAttrCode())){
+                        String minName = ptlAreaLicenseService.convertAreaNumber2License(areaLicenseMap, attrlink.getMin());
+                        attrlink.setMinName(minName);
                     }else{
-                        attrlink.setOperatorDesc("未知");
+                        String minName = dictLabalId2Name.getOrDefault(attrlink.getMin(),attrlink.getMin());
+                        String maxName = dictLabalId2Name.getOrDefault(attrlink.getMax(),attrlink.getMax());
+                        attrlink.setMinName(minName);
+                        attrlink.setMaxName(maxName);
                     }
-                    String minName = dictLabalId2Name.getOrDefault(attrlink.getMin(),attrlink.getMin());
-                    String maxName = dictLabalId2Name.getOrDefault(attrlink.getMax(),attrlink.getMax());
-                    attrlink.setMinName(minName);
-                    attrlink.setMaxName(maxName);
                     PtlAgreementUndwrtRulesAttr undwrtRuleAttrByAttrCode = ptlAgreementUndwrtRulesAttrService.getUndwrtRuleAttrByAttrCode(attrlink.getAttrCode());
-                    if(undwrtRuleAttrByAttrCode != null && undwrtRuleAttrByAttrCode.getDictId() != null){
+                    if(undwrtRuleAttrByAttrCode != null){
                         attrlink.setAttrCodeName(undwrtRuleAttrByAttrCode.getAttrName());
-                        List<PtlAgreementUndwrtRulesDictLabal> dictLabelsByTypeCode = ptlAgreementUndwrtRulesDictLabalService.getDictLabelsByTypeCode(undwrtRuleAttrByAttrCode.getDictId());
-                        PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = dictLabelsByTypeCode.stream().filter(x -> x.getCode().equals(attrlink.getMin())).findFirst().orElse(null);
-                        if(ptlAgreementUndwrtRulesDictLabal != null){
-                            if(attrlink.getAttrDesc() == null){
-                                attrlink.setAttrDesc(new ArrayList<>());
+                        if(undwrtRuleAttrByAttrCode.getDictId() != null){
+                            attrlink.setAttrCodeName(undwrtRuleAttrByAttrCode.getAttrName());
+                            List<PtlAgreementUndwrtRulesDictLabal> dictLabelsByTypeCode = ptlAgreementUndwrtRulesDictLabalService.getDictLabelsByTypeCode(undwrtRuleAttrByAttrCode.getDictId());
+                            PtlAgreementUndwrtRulesDictLabal ptlAgreementUndwrtRulesDictLabal = dictLabelsByTypeCode.stream().filter(x -> x.getCode().equals(attrlink.getMin())).findFirst().orElse(null);
+                            if(ptlAgreementUndwrtRulesDictLabal != null){
+                                if(attrlink.getAttrDesc() == null){
+                                    attrlink.setAttrDesc(new ArrayList<>());
+                                }
+                                attrlink.getAttrDesc().add(ptlAgreementUndwrtRulesDictLabal.getName());
                             }
-                            attrlink.getAttrDesc().add(ptlAgreementUndwrtRulesDictLabal.getName());
                         }
                     }
+                    log.info("attrlink数据填充完成:attrlink=[{}]",JSONUtil.toJsonStr(attrlink));
                 }
 
                 for(PtlAgreementDispatchAction action : actions){

+ 76 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAreaLicenseServiceImpl.java

@@ -1,18 +1,26 @@
 package com.jzg.organization.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.jzg.commons.entity.po.PtlAreaLicense;
 import com.jzg.commons.util.StringUtils;
 import com.jzg.organization.mapper.PtlAreaLicenseMapper;
 import com.jzg.organization.service.PtlAreaLicenseService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 @Service
 public class PtlAreaLicenseServiceImpl extends ServiceImpl<PtlAreaLicenseMapper, PtlAreaLicense>
         implements PtlAreaLicenseService {
 
+    private static final Logger log = LoggerFactory.getLogger(PtlAreaLicenseServiceImpl.class);
 
     @Override
     public List<PtlAreaLicense> getByParentNumber(String parentNumber) {
@@ -21,4 +29,72 @@ public class PtlAreaLicenseServiceImpl extends ServiceImpl<PtlAreaLicenseMapper,
         }
         return lambdaQuery().eq(PtlAreaLicense::getParentNumber, parentNumber).list();
     }
+
+    /**
+     * 查看车牌号和所有地区的对应关系
+     *
+     * @return List<PtlAreaLicense> 所有车牌号和地区的对应关系
+     * @author lipf
+     * @date 2026/5/21 9:40
+     */
+    @Override
+    public List<PtlAreaLicense> queryAllAreaLicense() {
+        log.info("查询所有车牌前缀和地区的对应关系: ");
+        List<PtlAreaLicense> ptlAreaLicenses = baseMapper.selectList(null);
+        log.info("查询所有车牌前缀和地区的对应关系。 查询出[{}]条记录", CollUtil.size(ptlAreaLicenses));
+        return ptlAreaLicenses;
+    }
+
+    /**
+     * 查看车牌号和所有地区的对应关系
+     *
+     * @return Map<String,PtlAreaLicense> key是areaNumber, value是地区和车牌前缀的对应关系
+     * @author lipf
+     * @date 2026/5/21 9:45
+     */
+    @Override
+    public Map<String, PtlAreaLicense> queryAllAreaLicenseMap() {
+        List<PtlAreaLicense> ptlAreaLicenses = this.queryAllAreaLicense();
+        if(CollUtil.isEmpty(ptlAreaLicenses)){
+            return Map.of();
+        }
+        return ptlAreaLicenses.stream()
+                .filter(action-> StrUtil.isNotEmpty(action.getAreaNumber()))
+                .collect(Collectors.toMap(PtlAreaLicense::getAreaNumber,
+                        action->action,
+                        (oldItem, newItem)->newItem));
+
+    }
+
+    /**
+     * 将地区编码转换为对应的车牌号
+     *
+     * @param areaLicenseMap 地区编码和车牌对应集
+     * @param areaNumbers    地区编码,支持多个拼接,例如1401,1402,1403
+     * @return String 地区车牌号,例如晋A,晋B,晋C
+     * @author lipf
+     * @date 2026/5/21 9:53
+     */
+    @Override
+    public String convertAreaNumber2License(Map<String, PtlAreaLicense> areaLicenseMap, String areaNumbers) {
+        if(StrUtil.isEmpty(areaNumbers)){
+            return StrUtil.EMPTY;
+        }
+        if(CollUtil.isEmpty(areaLicenseMap)){
+            return areaNumbers;
+        }
+        String[] split = areaNumbers.split(",");
+        List<String> licenses =  new ArrayList<>();
+        for (String s : split) {
+            PtlAreaLicense ptlAreaLicense = areaLicenseMap.getOrDefault(s, null);
+            if(ptlAreaLicense != null){
+                licenses.add(ptlAreaLicense.getLicense());
+            }else{
+                licenses.add(s);
+            }
+        }
+        String collect = String.join(",", licenses);
+        log.info("地区编码[{}]转换后的车牌编码是[{}]",areaNumbers,collect);
+        return collect;
+    }
 }