Procházet zdrojové kódy

承保规则复制、机构新增修改

Qchen před 1 rokem
rodič
revize
5f2ff8cb18

+ 1 - 1
src/main/java/com/ydtech/modules/admin/dao/SysDeptMapper.java

@@ -16,7 +16,7 @@ public interface SysDeptMapper extends BaseMapper<SysDept> {
      * @param deptType 类型
      * @return
      */
-    String getMaxId(@Param(value = "deptId") String deptId, @Param(value = "deptType")String deptType);
+    String getMaxId(@Param(value = "deptId") String deptId, @Param(value = "deptType")String deptType,@Param(value = "comlevel")String comlevel);
     /**
      *  @version
      *  @author: hxl

+ 18 - 2
src/main/java/com/ydtech/modules/admin/service/impl/SysDeptServiceImpl.java

@@ -217,11 +217,27 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
         } else if (comlevel.equals("3")) {
             AssertionUtils.isStringEmpty(sysDept.getCity(), "三级机构市必填");
             number = sysDept.getCity().substring(0, 4);
+            String maxId = baseMapper.getMaxId(parentId, sysDeptVo.getDeptType(), comlevel);
+            if (!maxId.equals("0")) {
+                String substring = maxId.substring(sysDept.getParentId().length() + 1);
+                int i = Integer.parseInt("1" + substring) + 1;
+                number = String.valueOf(i);
+            } else {
+                number = "101";
+            }
         } else if (comlevel.equals("4")) {
             AssertionUtils.isStringEmpty(sysDept.getArea(), "四级机构区必填");
             number = sysDept.getArea().substring(0, 6);
+            String maxId = baseMapper.getMaxId(parentId, sysDeptVo.getDeptType(), comlevel);
+            if (!maxId.equals("0")) {
+                String substring = maxId.substring(sysDept.getParentId().length() + 1);
+                int i = Integer.parseInt("1" + substring) + 1;
+                number = String.valueOf(i);
+            } else {
+                number = "101";
+            }
         } else {
-            String deptType = "";
+            String deptType = sysDeptVo.getDeptType();
 
             if ("C".equals(sysDept.getDeptType()) && comlevel.equals("5")) {
                 sysDeptVo.setDeptType("M");
@@ -230,7 +246,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept>
                 deptType = "M";
             }
 
-            String maxId = baseMapper.getMaxId(sysDept.getParentId(), deptType);
+            String maxId = baseMapper.getMaxId(parentId, deptType, comlevel);
             if (!maxId.equals("0")) {
                 String substring = maxId.substring(sysDept.getParentId().length() + 1);
                 int i = Integer.parseInt("1" + substring) + 1;

+ 14 - 0
src/main/java/com/ydtech/modules/protocols/controller/PtlNewAgreementController.java

@@ -223,4 +223,18 @@ public class PtlNewAgreementController extends BaseController {
     public HttpResult getProductId(@RequestBody ProductQueryVo productQueryVo){
         return HttpResult.ok("",InsuranceRisk.determineInsuranceInformation(productQueryVo.getKindList(), productQueryVo.getRiskList()).getCode());
     }
+
+    @ApiOperation("复制承保规则")
+    @PostMapping("/undwrt/copyRules")
+    public HttpResult copyRules(@RequestBody AgreementUndwrtRules agreementUndwrtRules){
+        return ptlAgreementUndwrtRulesNewService.copyRules(agreementUndwrtRules) ? HttpResult.ok("复制承保规则成功") : HttpResult.error("复制承保规则失败");
+    }
+
+
+    @ApiOperation("复制承保规则查询同保险公司协议")
+    @GetMapping("/getAllAgreement")
+    public HttpResult<List<PtlAgreement>> getAllAgreement(String companyCode){
+        return HttpResult.ok(ptlAgreementService.getByCompanyCode(companyCode));
+    }
+
 }

+ 2 - 0
src/main/java/com/ydtech/modules/protocols/entity/vo/AgreementUndwrtRules.java

@@ -42,5 +42,7 @@ public class AgreementUndwrtRules {
     @ApiModelProperty(value = "规则属性")
     private List<PtlAgreementUndwrtRulesAttrLink> rulesAttrList;
 
+    @ApiModelProperty(value = "ids列表")
+    private String[] ids;
 
 }

+ 8 - 4
src/main/java/com/ydtech/modules/protocols/service/PtlAgreementUndwrtRulesNewService.java

@@ -7,10 +7,7 @@ import com.ydtech.core.page.PageResult;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementProductCostsAttrLink;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesAttr;
 import com.ydtech.modules.protocols.entity.po.PtlAgreementUndwrtRulesNew;
-import com.ydtech.modules.protocols.entity.vo.AgreementProductCosts;
-import com.ydtech.modules.protocols.entity.vo.AgreementProductCostsSave;
-import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRules;
-import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRulesSave;
+import com.ydtech.modules.protocols.entity.vo.*;
 
 import java.util.List;
 
@@ -42,4 +39,11 @@ public interface PtlAgreementUndwrtRulesNewService extends IService<PtlAgreement
 
 
     boolean rulesDelete(String rulesId);
+
+    /**
+     * 复制协议承保规则
+     * @param agreementUndwrtRules
+     * @return
+     */
+    boolean copyRules(AgreementUndwrtRules agreementUndwrtRules);
 }

+ 53 - 6
src/main/java/com/ydtech/modules/protocols/service/impl/PtlAgreementUndwrtRulesNewServiceImpl.java

@@ -3,16 +3,13 @@ package com.ydtech.modules.protocols.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.ydtech.core.page.PageRequest;
-import com.ydtech.core.page.PageResult;
+import com.ydtech.core.page.HttpResult;
+import com.ydtech.exception.SystemException;
 import com.ydtech.modules.base.controller.BaseController;
-import com.ydtech.modules.protocol.entity.po.PtlAgreement;
 import com.ydtech.modules.protocol.entity.po.PtlAreaLicense;
 import com.ydtech.modules.protocol.service.PtlAreaLicenseService;
-import com.ydtech.modules.protocols.dao.PtlAgreementProductCostsAttrLinkMapper;
 import com.ydtech.modules.protocols.dao.PtlAgreementUndwrtRulesNewMapper;
 import com.ydtech.modules.protocols.entity.po.*;
-import com.ydtech.modules.protocols.entity.vo.AgreementProductCostsSave;
 import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRules;
 import com.ydtech.modules.protocols.entity.vo.AgreementUndwrtRulesSave;
 import com.ydtech.modules.protocols.service.*;
@@ -22,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.crypto.spec.PSource;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -136,6 +134,9 @@ public class PtlAgreementUndwrtRulesNewServiceImpl extends ServiceImpl<PtlAgreem
 
         //获取费用属性
         List<PtlAgreementUndwrtRulesAttr> undwrtRulesAttrList = ptlAgreementUndwrtRulesAttrService.getUndwrtRulesAttrList();
+        if (ids.isEmpty()) {
+            throw new SystemException("该协议暂无承保规则");
+        }
         List<PtlAgreementUndwrtRulesAttrLink> list = ptlAgreementUndwrtRulesAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>()
                 .in(PtlAgreementUndwrtRulesAttrLink::getRulesId, ids));
 
@@ -225,7 +226,7 @@ public class PtlAgreementUndwrtRulesNewServiceImpl extends ServiceImpl<PtlAgreem
         BeanUtils.copyProperties(agreementUndwrtRules, ptlAgreementUndwrtRulesNew);
         ptlAgreementUndwrtRulesNew.setId(null);
         int insert = baseMapper.insert(ptlAgreementUndwrtRulesNew);
-
+        agreementUndwrtRules.setId(ptlAgreementUndwrtRulesNew.getId());
         //保存承包规则历史记录
         PtlAgreementUndwrtRulesNewHistory ptlAgreementUndwrtRulesNewHistory = new PtlAgreementUndwrtRulesNewHistory();
         BeanUtils.copyProperties(agreementUndwrtRules, ptlAgreementUndwrtRulesNewHistory);
@@ -431,4 +432,50 @@ public class PtlAgreementUndwrtRulesNewServiceImpl extends ServiceImpl<PtlAgreem
 
         return true;
     }
+
+    @Transactional
+    @Override
+    public boolean copyRules(AgreementUndwrtRules agreementUndwrtRules) {
+        List<PtlAgreementUndwrtRulesNew> list = baseMapper.selectBatchIds(Arrays.asList(agreementUndwrtRules.getIds()));
+        for (PtlAgreementUndwrtRulesNew originalRule  : list) {
+            PtlAgreementUndwrtRulesNew clonedRule = new PtlAgreementUndwrtRulesNew();
+            BeanUtils.copyProperties(originalRule, clonedRule, "id","agreementId");
+
+            clonedRule.setId(null);
+            clonedRule.setAgreementId(agreementUndwrtRules.getAgreementId());
+
+            AgreementUndwrtRules convertedAgreementUndwrtRules = convertToAgreementUndwrtRules(clonedRule);
+
+            convertedAgreementUndwrtRules.setRulesAttrList(agreementUndwrtRules.getRulesAttrList());
+
+            //调用承保规则新增方法
+            rulesAdd(convertedAgreementUndwrtRules);
+            List<PtlAgreementUndwrtRulesAttrLink> attrLinks =
+                    ptlAgreementUndwrtRulesAttrLinkService.list(new LambdaQueryWrapper<PtlAgreementUndwrtRulesAttrLink>().eq(PtlAgreementUndwrtRulesAttrLink::getRulesId, originalRule.getId()));
+
+            List<PtlAgreementUndwrtRulesAttrLinkHistory> undwrtRulesAttrLinkHistories = new ArrayList<>();
+            String uuid = IdGenerate.nextId();
+            attrLinks.forEach(x -> {
+                x.setId(null);
+                x.setRulesId(convertedAgreementUndwrtRules.getId());
+                PtlAgreementUndwrtRulesAttrLinkHistory costsAttrLinkHistory = new PtlAgreementUndwrtRulesAttrLinkHistory();
+                BeanUtils.copyProperties(x, costsAttrLinkHistory);
+                //设置承包规则费用因子历史记录
+                costsAttrLinkHistory.setBatch(uuid);
+                costsAttrLinkHistory.setId(null);
+                costsAttrLinkHistory.setOperatorType("add");
+                costsAttrLinkHistory.setModifier(BaseController.getUser().getId());
+                costsAttrLinkHistory.setOperatorTime(LocalDateTime.now());
+                undwrtRulesAttrLinkHistories.add(costsAttrLinkHistory);
+            });
+            ptlAgreementUndwrtRulesAttrLinkHistoryService.saveBatch(undwrtRulesAttrLinkHistories);
+            ptlAgreementUndwrtRulesAttrLinkService.saveBatch(attrLinks);
+        }
+        return true;
+    }
+    private AgreementUndwrtRules convertToAgreementUndwrtRules(PtlAgreementUndwrtRulesNew rule) {
+        AgreementUndwrtRules agreementUndwrtRules = new AgreementUndwrtRules();
+        BeanUtils.copyProperties(rule, agreementUndwrtRules,"ids");
+        return agreementUndwrtRules;
+    }
 }

+ 5 - 2
src/main/resources/mapper/modules/admin/SysDeptMapper.xml

@@ -45,9 +45,12 @@
         SELECT IFNULL(MAX(id), 0) maxid
         FROM `sys_dept`
         WHERE parent_id = #{deptId}
-        <if test='deptType != null and deptType != ""'>
-            and id NOT LIKE '%M%'
+        <if test='comlevel != null and comlevel != ""'>
+            and comlevel = #{comlevel}
         </if>
+<!--        <if test='deptType != null and deptType != ""'>-->
+<!--            and id NOT LIKE '%M%'-->
+<!--        </if>-->
 
     </select>