Переглянути джерело

上传和协议上传的优化

dongxin 1 рік тому
батько
коміт
b3dba0f81c
19 змінених файлів з 122 додано та 25 видалено
  1. 16 0
      commons/src/main/java/com/jzg/commons/entity/dto/AgreementCopyParam.java
  2. 18 0
      commons/src/main/java/com/jzg/commons/entity/dto/AgreementFileParam.java
  3. 4 4
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCost.java
  4. 4 4
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostRule.java
  5. 2 2
      commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostType.java
  6. 2 0
      commons/src/main/java/com/jzg/commons/entity/po/SysUploadFiles.java
  7. 4 0
      commons/src/main/java/com/jzg/commons/entity/vo/AgreementVo.java
  8. 1 1
      commons/src/main/java/com/jzg/commons/util/MinioUtils.java
  9. 1 0
      platform/src/main/java/com/jzg/controller/FileUploadController.java
  10. 29 4
      tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java
  11. 1 1
      tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostRuleMapper.java
  12. 1 1
      tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostTypeMapper.java
  13. 1 1
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostRuleService.java
  14. 2 2
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostTypeService.java
  15. 7 0
      tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementService.java
  16. 1 1
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostRuleServiceImpl.java
  17. 2 2
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostTypeServiceImpl.java
  18. 25 1
      tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementServiceImpl.java
  19. 1 1
      tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml

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

@@ -0,0 +1,16 @@
+package com.jzg.commons.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotEmpty;
+import lombok.Data;
+
+import java.util.List;
+
+@Schema(description = "协议表复制dto")
+@Data
+public class AgreementCopyParam {
+
+    @NotEmpty(message = "费用id不能为空")
+    @Schema(description = "费用id数组")
+    private List<String> costIds;
+}

+ 18 - 0
commons/src/main/java/com/jzg/commons/entity/dto/AgreementFileParam.java

@@ -0,0 +1,18 @@
+package com.jzg.commons.entity.dto;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+
+@Schema(description = "协议表文件上传dto")
+@Data
+public class AgreementFileParam {
+
+    @NotNull(message = "协议id不能为空")
+    @Schema(description = "协议id")
+    private String id;
+
+    @NotNull(message = "协议文件不能为空")
+    @Schema(description = "协议文件")
+    private String fileId;
+}

+ 4 - 4
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCost.java

@@ -18,15 +18,15 @@ import java.util.Date;
 public class PtlAgreementCost extends BaseModel {
 
     @TableId(type = IdType.ASSIGN_ID)
-    private Long id;
+    private String id;
 
-    private Long ptlAgreementId;
+    private String ptlAgreementId;
 
-    private Long coverRuleId;
+    private String coverRuleId;
 
     private String productName;
 
-    private Long productId;
+    private String productId;
 
     private Date effectiveTime;
 

+ 4 - 4
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostRule.java

@@ -14,13 +14,13 @@ import lombok.Data;
 public class PtlAgreementCostRule extends BaseModel {
 
     @TableId(type = IdType.ASSIGN_ID)
-    private Long id;
+    private String id;
 
-    private Long ptlAgreementCostId;
+    private String ptlAgreementCostId;
 
-    private Long rulesId;
+    private String rulesId;
 
-    private Long attrId;
+    private String attrId;
 
     private String attrCode;
 

+ 2 - 2
commons/src/main/java/com/jzg/commons/entity/po/PtlAgreementCostType.java

@@ -14,9 +14,9 @@ import java.math.BigDecimal;
 public class PtlAgreementCostType extends BaseModel {
 
     @TableId(type = IdType.ASSIGN_ID)
-    private Long id;
+    private String id;
 
-    private Long ptlAgreementCostId;
+    private String ptlAgreementCostId;
 
     private int costType;
 

+ 2 - 0
commons/src/main/java/com/jzg/commons/entity/po/SysUploadFiles.java

@@ -16,6 +16,8 @@ public class SysUploadFiles {
 
     private String fileType;
 
+    private String fileSize;
+
     private String bucketName;
 
     private String etag;

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

@@ -149,6 +149,10 @@ public class AgreementVo extends BaseModel {
     @Schema(description = "附件地址")
     private String fileUrl;
 
+    /** 附件地址 */
+    @Schema(description = "附件大小")
+    private Long fileSize;
+
     /** 关联-保险公司简称 */
     @Schema(description = "关联-保险公司简称")
     private String company;

+ 1 - 1
commons/src/main/java/com/jzg/commons/util/MinioUtils.java

@@ -311,7 +311,7 @@ public class MinioUtils {
      * @return
      */
     @SneakyThrows(Exception.class)
-    public String getFileStatusInfo(String bucketName, String objectName) {
+    public static String getFileStatusInfo(String bucketName, String objectName) {
         return minioClient.statObject(StatObjectArgs.builder().bucket(bucketName).object(objectName).build()).toString();
     }
 

+ 1 - 0
platform/src/main/java/com/jzg/controller/FileUploadController.java

@@ -131,6 +131,7 @@ public class FileUploadController extends BaseController {
         sysUploadFiles.setId(IdGenerate.nextId());
         sysUploadFiles.setFileName(objectName);
         sysUploadFiles.setFileType(extension.substring(1));
+        sysUploadFiles.setFileSize(file.getSize() + "");
         sysUploadFiles.setBucketName(bucketName);
         sysUploadFiles.setEtag(objectWriteResponse.etag());
         sysUploadFiles.setCreateTime(LocalDateTime.now());

+ 29 - 4
tenant/organization/src/main/java/com/jzg/organization/controller/AgreementController.java

@@ -3,11 +3,9 @@ package com.jzg.organization.controller;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
-import com.jzg.commons.entity.dto.AgreementAddParam;
-import com.jzg.commons.entity.dto.AgreementAuthParam;
-import com.jzg.commons.entity.dto.AgreementEditParam;
-import com.jzg.commons.entity.dto.AgreementParam;
+import com.jzg.commons.entity.dto.*;
 import com.jzg.commons.entity.enums.YesNoEnum;
+import com.jzg.commons.entity.po.PtlAgreement;
 import com.jzg.commons.entity.vo.AgreementVo;
 import com.jzg.commons.entity.vo.UpAndDownVo;
 import com.jzg.commons.util.AssertionUtils;
@@ -15,6 +13,7 @@ import com.jzg.organization.service.PtlAgreementDeptService;
 import com.jzg.organization.service.PtlAgreementService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
@@ -100,6 +99,20 @@ public class AgreementController extends BaseController {
         return HttpResult.ok("修改成功");
     }
 
+    /**
+     * 协议上传文件
+     * @param param
+     * @return
+     */
+    @Operation(summary = "协议上传文件")
+    @PostMapping("/agreementEditFile")
+    public HttpResult agreementEditFile(@Validated @RequestBody AgreementFileParam param) {
+        PtlAgreement ptlAgreement = new PtlAgreement();
+        BeanUtils.copyProperties(param,ptlAgreement);
+        agreementService.updateById(ptlAgreement);
+        return HttpResult.ok("上传成功");
+    }
+
     /**
      * 协议授权机构查询
      * @param id
@@ -156,4 +169,16 @@ public class AgreementController extends BaseController {
         agreementService.upAndDown(upAndDownVo);
         return HttpResult.ok(YesNoEnum.YES.equals(upAndDownVo.getOpType())? "禁用成功":"启用成功" );
     }
+
+    /**
+     * 协议复制
+     * @param param
+     * @return
+     */
+    @Operation(summary = "协议复制")
+    @PostMapping("/agreementCopy")
+    public HttpResult agreementCopy(@Validated @RequestBody AgreementCopyParam param) {
+        agreementService.agreementCopy(param);
+        return HttpResult.ok("修改成功");
+    }
 }

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostRuleMapper.java

@@ -9,5 +9,5 @@ import org.apache.ibatis.annotations.Mapper;
 public interface PtlAgreementCostRuleMapper extends BaseMapper<PtlAgreementCostRule> {
 
     @Delete("delete from ptl_agreement_cost_rule where ptl_agreement_cost_id = #{id}")
-    void deleteByPtlAgreementCostId(Long id);
+    void deleteByPtlAgreementCostId(String id);
 }

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/mapper/PtlAgreementCostTypeMapper.java

@@ -12,5 +12,5 @@ import org.apache.ibatis.annotations.Mapper;
 public interface PtlAgreementCostTypeMapper extends BaseMapper<PtlAgreementCostType> {
 
     @Delete("DELETE FROM ptl_agreement_cost_type WHERE ptl_agreement_cost_id = #{id}")
-    void deleteByPtlAgreementCostId(Long id);
+    void deleteByPtlAgreementCostId(String id);
 }

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/service/PtlAgreementCostRuleService.java

@@ -9,6 +9,6 @@ import java.util.List;
 public interface PtlAgreementCostRuleService extends IService<PtlAgreementCostRule> {
 
 
-    void saveOrUpdateCostRule(List<PtlAgreementCostRule> ruleConditions, Long id);
+    void saveOrUpdateCostRule(List<PtlAgreementCostRule> ruleConditions, String id);
 
 }

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

@@ -10,8 +10,8 @@ import java.util.List;
 
 public interface PtlAgreementCostTypeService extends IService<PtlAgreementCostType> {
 
-    List<PtlAgreementCostTypeVo> queryByCostId(Long costId);
+    List<PtlAgreementCostTypeVo> queryByCostId(String costId);
 
-    void saveOrUpdateCostType(List<PtlAgreementCostType> ptlAgreementCostTypeList, Long id);
+    void saveOrUpdateCostType(List<PtlAgreementCostType> ptlAgreementCostTypeList, String id);
 
 }

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

@@ -2,6 +2,7 @@ package com.jzg.organization.service;
 
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jzg.commons.entity.dto.AgreementAddParam;
+import com.jzg.commons.entity.dto.AgreementCopyParam;
 import com.jzg.commons.entity.dto.AgreementEditParam;
 import com.jzg.commons.entity.dto.AgreementParam;
 import com.jzg.commons.entity.po.PtlAgreement;
@@ -94,4 +95,10 @@ public interface PtlAgreementService extends IService<PtlAgreement> {
      * @param id
      */
     void reDeploy(String id);
+
+    /**
+     * 协议复制
+     * @param param
+     */
+    void agreementCopy(AgreementCopyParam param);
 }

+ 1 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementCostRuleServiceImpl.java

@@ -18,7 +18,7 @@ public class PtlAgreementCostRuleServiceImpl extends ServiceImpl<PtlAgreementCos
 
 
     @Override
-    public void saveOrUpdateCostRule(List<PtlAgreementCostRule> ruleConditions, Long id) {
+    public void saveOrUpdateCostRule(List<PtlAgreementCostRule> ruleConditions, String id) {
         baseMapper.deleteByPtlAgreementCostId(id);
         for (PtlAgreementCostRule ptlAgreementCostRule : ruleConditions) {
             ptlAgreementCostRule.setPtlAgreementCostId(id);

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

@@ -18,14 +18,14 @@ public class PtlAgreementCostTypeServiceImpl extends ServiceImpl<PtlAgreementCos
 
 
     @Override
-    public List<PtlAgreementCostTypeVo> queryByCostId(Long costId) {
+    public List<PtlAgreementCostTypeVo> queryByCostId(String costId) {
         return BeanUtil.copyToList(baseMapper.selectList(new LambdaQueryChainWrapper<>(PtlAgreementCostType.class)
                 .eq(PtlAgreementCostType::getPtlAgreementCostId, costId)
                 .eq(PtlAgreementCostType::getIsDelete, Constants.NOT_DELETED)), PtlAgreementCostTypeVo.class);
     }
 
     @Override
-    public void saveOrUpdateCostType(List<PtlAgreementCostType> ptlAgreementCostTypeList, Long id) {
+    public void saveOrUpdateCostType(List<PtlAgreementCostType> ptlAgreementCostTypeList, String id) {
         baseMapper.deleteByPtlAgreementCostId(id);
         for (PtlAgreementCostType ptlAgreementCostType : ptlAgreementCostTypeList) {
             ptlAgreementCostType.setPtlAgreementCostId(id);

+ 25 - 1
tenant/organization/src/main/java/com/jzg/organization/service/impl/PtlAgreementServiceImpl.java

@@ -2,12 +2,15 @@ package com.jzg.organization.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.convert.Convert;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 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.jzg.commons.core.base.BaseController;
 import com.jzg.commons.core.page.HttpResult;
 import com.jzg.commons.entity.dto.AgreementAddParam;
+import com.jzg.commons.entity.dto.AgreementCopyParam;
 import com.jzg.commons.entity.dto.AgreementEditParam;
 import com.jzg.commons.entity.dto.AgreementParam;
 import com.jzg.commons.entity.enums.YesNoEnum;
@@ -34,6 +37,8 @@ import org.springframework.transaction.annotation.Transactional;
 import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
 
 /**
 * @author dongxin
@@ -63,6 +68,9 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
     @Autowired
     private PtlAgreementUndwrtRulesService agreementRulesService;
 
+    @Autowired
+    private PtlAgreementCostService agreementCostService;
+
     @Autowired
     private PtlAgreementUndwrtRulesAttrService agreementUndwrtRulesAttrService;
 
@@ -101,7 +109,8 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
     @Override
     public AgreementInfoVo queryById(String id) {
         AgreementVo agreementVo = this.isExistById(id);
-
+        String fileUrl = MinioUtils.getPresignedObjectUrl(bucketName,agreementVo.getFileName());
+        agreementVo.setFileUrl(fileUrl);
         // 获取协议授权
         List<PtlAgreementDept> deptList = agreementDeptService.getByAgreementId(id);
         AgreementInfoVo agreementInfoVo = new AgreementInfoVo(agreementVo,deptList);
@@ -220,6 +229,21 @@ public class PtlAgreementServiceImpl extends ServiceImpl<PtlAgreementMapper, Ptl
         baseMapper.updateById(agreement);
     }
 
+    @Override
+    public void agreementCopy(AgreementCopyParam param) {
+        List<String> costIds = param.getCostIds();
+        List<PtlAgreementCost> costList = agreementCostService.listByIds(costIds);
+        if(CollUtil.isEmpty(costList)){
+            return;
+        }
+        Set<String> agreementIds = costList.stream().map(PtlAgreementCost::getPtlAgreementId)
+                .collect(Collectors.toSet());
+
+
+
+
+    }
+
 }
 
 

+ 1 - 1
tenant/organization/src/main/resources/mapper/PtlAgreementMapper.xml

@@ -52,7 +52,7 @@
         pa.create_by,pa.create_time,pa.update_by,
         pa.create_by,pa.create_time,pa.update_by,
         pa.update_time,pa.is_delete,paa.username,paa.user_abbr as userAbber,
-        suji.name as managerName,sd.name as managerDeptName,suf.file_name as fileName,
+        suji.name as managerName,sd.name as managerDeptName,suf.file_name as fileName,suf.file_size as fileSize,
         eic.name_simple as company,sdd.name as deptName
     </sql>
     <select id="queryPage" resultType="com.jzg.commons.entity.vo.AgreementVo">