Przeglądaj źródła

内部协议复制到内部协议功能开发

wanghao 2 tygodni temu
rodzic
commit
4acd34d76e

+ 6 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementCopyParam.java

@@ -18,4 +18,10 @@ public class AgreementCopyParam {
 //    @NotEmpty(message = "费用id不能为空")
     @Schema(description = "费用id数组")
     private List<String> costIds;
+
+    @Schema(description = "对接人")
+    private String dockingPerson;
+
+    @Schema(description = "对接人电话")
+    private String dockingPhone;
 }

+ 2 - 0
commons/src/main/java/com/jzg/commons/entity/scheme/vo/PtlSchemeVo.java

@@ -39,6 +39,8 @@ public class PtlSchemeVo extends PageRequest {
 
     @Schema(description = "规则描述")
     private String ruleDesc;
+    @Schema(description = "排序")
+    private String sort;
 
 
 }

+ 12 - 0
tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java

@@ -217,6 +217,18 @@ public class AgreementController extends BaseController {
         return HttpResult.ok("复制成功");
     }
 
+    /**
+     * 协议外部协议复制内部协议
+     * @param param
+     * @return
+     */
+    @Operation(summary = "外部协议复制内部协议")
+    @PostMapping("/agreementCopyOutToIn")
+    public HttpResult agreementCopyOutToIn(@Validated @RequestBody AgreementCopyParam param) {
+        agreementService.agreementCopyOutToIn(param);
+        return HttpResult.ok("复制成功");
+    }
+
     /**
      * 批量修改协议费用有效期
      * @param param 参数

+ 2 - 0
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementService.java

@@ -166,4 +166,6 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      * @date 2026/7/28 9:14
      */
     List<ContractVO> queryContractVos();
+
+    void agreementCopyOutToIn(AgreementCopyParam param);
 }

+ 120 - 0
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementServiceImpl.java

@@ -19,6 +19,7 @@ import com.jzg.commons.util.MinioUtils;
 import com.jzg.commons.util.StringUtils;
 import com.jzg.commons.util.idgen.IdGenerate;
 import com.jzg.organization.client.EsmInsCompanyClient;
+import com.jzg.organization.mapper.PtlAgreementCostExternalMapper;
 import com.jzg.organization.mapper.PtlAgreementMapper;
 import com.jzg.organization.mapper.SysUploadFilesMapper;
 import com.jzg.organization.mapper.SysUserMapper;
@@ -83,6 +84,8 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
 
     @Autowired
     private PtlAgreementCostExternalService ptlAgreementCostExternalService;
+    @Autowired
+    private PtlAgreementCostExternalTypeService ptlAgreementCostExternalTypeService;
 
     /**
      * 协议分页查询
@@ -437,6 +440,123 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         // 复制承保规则和费用
         this.copyRuleAndCost(costGroup, allCostIds, costList, newAgreement);
 
+    }
+
+
+    /**
+     * 内部协议复制到外部协议
+     *
+     */
+    @Override
+    @Transactional(rollbackFor = {Exception.class})
+    public void agreementCopyOutToIn(AgreementCopyParam param) {
+        log.info("内部协议复制到外部协议。 param=[{}]", JSONUtil.toJsonStr(param));
+        if(param.getId().isEmpty()){
+            throw new SystemException("请选择您要复制的协议信息");
+        }
+        if(param.getDockingPerson().isEmpty()){
+            throw new SystemException("请填写对接人信息");
+        }
+        if(param.getDockingPhone().isEmpty()){
+            throw new SystemException("请填写对接人信息");
+        }
+
+        PtlAgreement agreement = getById(param.getId());
+        // 获取保险公司信息
+        HttpResult<EsmInsCompany> result = companyClient.findById(agreement.getCompanyId());
+        String companyCode;
+        if(result.getCode() == 200 && Objects.nonNull(result.getData())){
+            companyCode = result.getData().getCompanyCode();
+        }else{
+            log.info("根据协议agreement[{}]中的companyId[{}]无法获取到保险公司信息", JSONUtil.toJsonStr(agreement), agreement.getId());
+            throw new SystemException("根据公司id"+agreement.getCompanyId()+"无法获取到保险公司信息");
+        }
+        String sysCode = baseController.getUserSystemCode();
+        PtlAgreement newAgreement = new PtlAgreement();
+        BeanUtils.copyProperties(agreement,newAgreement);
+        newAgreement.setId(null);
+        newAgreement.setAgreementTitle(LocalDateTime.now().getSecond() + agreement.getAgreementTitle());
+        newAgreement.setAgreementCode(sysCode + companyCode + System.currentTimeMillis());
+        newAgreement.setAuditStatus(0);
+        newAgreement.setCreateTime(LocalDateTime.now());
+        newAgreement.setUpdateTime(LocalDateTime.now());
+        // 外部协议
+        newAgreement.setIsExternal(1);
+        // 根据测试反馈,复制后的协议,默认应该是停用状态
+        newAgreement.setIsEnable(1);
+        save(newAgreement);
+
+        List<String> costIds = param.getCostIds();
+        if(CollUtil.isEmpty(costIds)){
+            return;
+        }
+        List<PtlAgreementCost> selectedCostList = agreementCostService.listByIds(costIds);
+        if (CollUtil.isEmpty(selectedCostList)) {
+            return;
+        }
+        Set<String> allCostIds = selectedCostList.stream().map(PtlAgreementCost::getId).collect(Collectors.toSet());
+        LambdaQueryWrapper<PtlAgreementCostType> costTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
+        costTypeLambdaQueryWrapper.in(PtlAgreementCostType::getPtlAgreementCostId, allCostIds);
+        List<PtlAgreementCostType> costTypeList = agreementCostTypeService.list(costTypeLambdaQueryWrapper);
+        Map<String, List<PtlAgreementCostType>> costTypeMap = costTypeList.stream().collect(
+                Collectors.groupingBy(PtlAgreementCostType::getPtlAgreementCostId));
+
+        for(PtlAgreementCost cost :selectedCostList){
+            PtlAgreementCostExternal costExternal = new PtlAgreementCostExternal();
+            // 同名同类型字段直接复制
+            // 关联新协议ID:String -> Long
+            costExternal.setPtlAgreementId(Long.valueOf(newAgreement.getId()));
+            costExternal.setProductName(cost.getProductName());
+            costExternal.setProductId(cost.getProductId());
+            costExternal.setEffectiveTime(cost.getEffectiveTime());
+            costExternal.setFailureTime(cost.getFailureTime());
+            costExternal.setAuditMethod(cost.getAuditMethod());
+            costExternal.setCostDescribe(cost.getCostDescribe());
+            costExternal.setReviewDescription(cost.getReviewDescription());
+            costExternal.setIsEnabled(cost.getIsEnabled());
+            costExternal.setAuditTime(cost.getAuditTime());
+            costExternal.setAuditPerson(cost.getAuditPerson());
+            // 默认非现询,非现询为1
+            costExternal.setIsInquiry(1);
+
+            // 类型转换:Integer -> String
+            if (cost.getPriorityLevel() != null) {
+                costExternal.setPriorityLevel(String.valueOf(cost.getPriorityLevel()));
+            }
+            // 复制的费用默认待审核
+            costExternal.setAuditStatus(0);
+            // 复制对接人信息
+            costExternal.setContactPerson(param.getDockingPerson());
+            costExternal.setContactMobile(param.getDockingPhone());
+            ptlAgreementCostExternalService.save(costExternal);
+
+            List<PtlAgreementCostType> costTypes = costTypeMap.get(cost.getId());
+            if (CollUtil.isNotEmpty(costTypes)) {
+                List<PtlAgreementCostExternalType> costExternalTypes = new ArrayList<>();
+                for(PtlAgreementCostType costType :costTypes){
+                    PtlAgreementCostExternalType costExternalType = new PtlAgreementCostExternalType();
+                    // 同名同类型字段直接复制
+                    costExternalType.setCostType(costType.getCostType());
+                    costExternalType.setInlet(costType.getInlet());
+                    costExternalType.setExport(costType.getExport());
+                    costExternalType.setAddThrow(costType.getAddThrow());
+                    costExternalType.setKeepPointRatio(costType.getKeepPointRatio());
+                    // 关联新外部费用ID:String -> Long
+                    costExternalType.setPtlAgreementCostExternalId(costExternal.getId());
+                    costExternalType.setCreateTime(LocalDateTime.now());
+                    costExternalType.setUpdateTime(LocalDateTime.now());
+                    costExternalTypes.add(costExternalType);
+
+                }
+                ptlAgreementCostExternalTypeService.saveBatch(costExternalTypes);
+            }
+
+
+        }
+
+
+
+
     }
 
     @Override