Sfoglia il codice sorgente

附件上传功能拆分(多服务随意调用调整到通过feign进行调用。否则无法打包)

user5 1 anno fa
parent
commit
132bb5cc75
15 ha cambiato i file con 307 aggiunte e 12 eliminazioni
  1. 27 0
      jeeplus-api/jeeplus-public-modules-api/pom.xml
  2. 81 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/domain/WorkAttachmentInfo.java
  3. 31 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/factory/WorkAttachmentApiFallbackFactory.java
  4. 28 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/feign/IWorkAttachmentApi.java
  5. 76 0
      jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/service/dto/WorkAttachmentInfoDTO.java
  6. 1 0
      jeeplus-api/pom.xml
  7. 6 1
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/controller/CwProjectReportController.java
  8. 1 1
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/CwProjectInfoMapper.xml
  9. 6 2
      jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/service/CwProjectReportService.java
  10. 6 0
      jeeplus-modules/jeeplus-public-modules/pom.xml
  11. 11 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/controller/OssFileController.java
  12. 23 0
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/feign/WorkAttachmentApiImpl.java
  13. 3 2
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/mapper/OssServiceMapper.java
  14. 3 3
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/mapper/xml/OssServiceMapper.xml
  15. 4 3
      jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/service/OssService.java

+ 27 - 0
jeeplus-api/jeeplus-public-modules-api/pom.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>jeeplus-api</artifactId>
+        <groupId>org.jeeplus</groupId>
+        <version>9.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>jeeplus-public-modules-api</artifactId>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.jeeplus</groupId>
+            <artifactId>jeeplus-common-core</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.jeeplus</groupId>
+            <artifactId>jeeplus-system-api</artifactId>
+            <version>9.0</version>
+            <scope>compile</scope>
+        </dependency>
+    </dependencies>
+</project>

+ 81 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/domain/WorkAttachmentInfo.java

@@ -0,0 +1,81 @@
+/**
+ * Copyright &copy; 2021-2026 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
+ */
+package com.jeeplus.sys.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.jeeplus.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * 用户Entity
+ *
+ * @author jeeplus
+ * @version 2021-12-05
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("work_attachment")
+public class WorkAttachmentInfo extends BaseEntity {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 附件地址
+     */
+    private String url;
+
+    /**
+     * 文件类型(文件后缀名)
+     */
+    private String type;
+
+    /**
+     * 附件对应父节点id(记录是谁的id)
+     */
+    private String attachmentId;
+
+    /**
+     * 文件名
+     */
+    private String attachmentName;
+
+    /**
+     * 文件所属业务模块(数据字典配置)
+     */
+    private String attachmentFlag;
+
+    /**
+     * 所属模块子模块
+     */
+    private String moduleType;
+
+    /**
+     * 附件类型
+     */
+    private String attachmentType;
+
+    /**
+     * 附件大小
+     */
+    private String fileSize;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 文件描述
+     */
+    private String description;
+
+    /**
+     * 附件临时地址
+     *该属性不是实体字段
+     */
+    @TableField(exist = false)
+    private String temporaryUrl;
+}

+ 31 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/factory/WorkAttachmentApiFallbackFactory.java

@@ -0,0 +1,31 @@
+package com.jeeplus.sys.factory;
+
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.cloud.openfeign.FallbackFactory;
+import org.springframework.stereotype.Component;
+
+import java.util.List;
+
+/**
+ * 用户服务降级处理
+ *
+ * @author jeeplus
+ */
+@Slf4j
+@Component
+public class WorkAttachmentApiFallbackFactory implements FallbackFactory <IWorkAttachmentApi> {
+    @Override
+    public IWorkAttachmentApi create(Throwable throwable) {
+        log.error ( "附件服务调用失败:{}", throwable.getMessage ( ) );
+        throwable.printStackTrace ( );
+        return new IWorkAttachmentApi( ) {
+
+            @Override
+            public List<WorkAttachmentInfo> selectWorkAttachmentByAttachmentId(String id) {
+                return null;
+            }
+        };
+    }
+}

+ 28 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/feign/IWorkAttachmentApi.java

@@ -0,0 +1,28 @@
+package com.jeeplus.sys.feign;
+
+import com.baomidou.mybatisplus.annotation.InterceptorIgnore;
+import com.jeeplus.common.constant.AppNameConstants;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
+import com.jeeplus.sys.factory.WorkAttachmentApiFallbackFactory;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+
+import java.util.List;
+
+
+@FeignClient(contextId = "workAttachmentApi", name = AppNameConstants.APP_PUBLIC_MODULES, fallbackFactory = WorkAttachmentApiFallbackFactory.class)
+public interface IWorkAttachmentApi {
+
+
+    /**
+     * 查询电子章文件信息
+     * @param id
+     * @return
+     */
+    @PostMapping("/oss/file/selectWorkAttachmentByAttachmentId")
+    List<WorkAttachmentInfo> selectWorkAttachmentByAttachmentId(@RequestParam(value = "id")String id);
+}
+
+

+ 76 - 0
jeeplus-api/jeeplus-public-modules-api/src/main/java/com/jeeplus/sys/service/dto/WorkAttachmentInfoDTO.java

@@ -0,0 +1,76 @@
+package com.jeeplus.sys.service.dto;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.jeeplus.core.service.dto.BaseDTO;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * @author: 徐滕
+ * @version: 2023-07-10 09:20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+public class WorkAttachmentInfoDTO extends BaseDTO {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 附件地址
+     */
+    private String url;
+
+    /**
+     * 文件类型(文件后缀名)
+     */
+    private String type;
+
+    /**
+     * 附件对应父节点id(记录是谁的id)
+     */
+    private String attachmentId;
+
+    /**
+     * 文件名
+     */
+    private String attachmentName;
+
+    /**
+     * 文件所属业务模块(数据字典配置)
+     */
+    private String attachmentFlag;
+
+    /**
+     * 所属模块子模块
+     */
+    private String moduleType;
+
+    /**
+     * 附件类型
+     */
+    private String attachmentType;
+
+    /**
+     * 附件大小
+     */
+    private String fileSize;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 文件描述
+     */
+    private String description;
+
+    /**
+     * 附件临时地址
+     *该属性不是实体字段
+     */
+    @TableField(exist = false)
+    private String temporaryUrl;
+
+
+}

+ 1 - 0
jeeplus-api/pom.xml

@@ -13,6 +13,7 @@
     <packaging>pom</packaging>
     <modules>
         <module>jeeplus-system-api</module>
+        <module>jeeplus-public-modules-api</module>
         <module>jeeplus-file-api</module>
     </modules>
 

+ 6 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/controller/CwProjectReportController.java

@@ -2,6 +2,7 @@ package com.jeeplus.finance.projectReport.controller;
 
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.jeeplus.common.excel.ExcelOptions;
@@ -22,6 +23,9 @@ import com.jeeplus.flowable.feign.IFlowableApi;
 import com.jeeplus.logging.annotation.ApiLog;
 import com.jeeplus.logging.constant.enums.LogTypeEnum;
 import com.jeeplus.pubmodules.oss.domain.WorkAttachment;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
+import com.jeeplus.sys.feign.IUserApi;
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.DictUtils;
 import com.jeeplus.sys.utils.UserUtils;
@@ -309,7 +313,8 @@ public class CwProjectReportController {
             return ResponseUtil.newInstance().add("businessTable", "cw_project_report_signature").add("businessId", signatureId).ok ("操作成功");
         } else {
             //查询报告文件信息(电子章)
-            List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(cwProjectReportData.getId());
+            //List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(cwProjectReportData.getId());
+            List<WorkAttachmentInfo> fileList = SpringUtil.getBean ( IWorkAttachmentApi.class ).selectWorkAttachmentByAttachmentId(cwProjectReportData.getId());
             if (CollectionUtil.isNotEmpty(fileList)) {
                 // 有电子章的附件时,走签章流程
                 Map<String, Object> signatureContractId = projectReportService.createSignatureContractId(cwProjectReportData);

+ 1 - 1
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/mapper/xml/CwProjectInfoMapper.xml

@@ -78,7 +78,7 @@
         <if test="servedUnitId != null and servedUnitId != ''">
             served_unit_id = #{servedUnitId},
         </if>
-        <if test="reportDate != null and reportDate != ''">
+        <if test="reportDate != null">
             report_date = #{reportDate},
         </if>
         <if test="reportType != null and reportType != ''">

+ 6 - 2
jeeplus-modules/jeeplus-finance/src/main/java/com/jeeplus/finance/projectReport/service/CwProjectReportService.java

@@ -3,6 +3,7 @@ package com.jeeplus.finance.projectReport.service;
 import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -37,6 +38,8 @@ import com.jeeplus.pubmodules.oss.service.OssService;
 import com.jeeplus.pubmodules.oss.service.dto.WorkAttachmentDto;
 import com.jeeplus.pubmodules.serialNumTpl.service.SerialnumTplService;
 import com.jeeplus.sys.domain.User;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
 import com.jeeplus.sys.service.UserService;
 import com.jeeplus.sys.mapper.UserMapper;
 import com.jeeplus.sys.service.dto.UserDTO;
@@ -1915,7 +1918,8 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
     public Map<String,Object> createSignatureContractId(CwProjectReportData projectReportData){
         Map<String,Object> map = new HashMap<String,Object>();
         //查询报告文件信息(电子章)
-        List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(projectReportData.getId());
+        //List<WorkAttachment> fileList = attachmentMapper.selectWorkAttachmentByReportId(projectReportData.getId());
+        List<WorkAttachmentInfo> fileList = SpringUtil.getBean ( IWorkAttachmentApi.class ).selectWorkAttachmentByAttachmentId(projectReportData.getId());
         if(fileList.size()>0){
 
             //下载审定单文件
@@ -1931,7 +1935,7 @@ public class CwProjectReportService extends ServiceImpl<CwProjectReportMapper, C
             //获取文件生成的documentId
             List<String> documentList = Lists.newArrayList();
 
-            for (WorkAttachment workattachment : fileList) {
+            for (WorkAttachmentInfo workattachment : fileList) {
                 String deleteFile = null;
                 try{
                     if(StringUtils.isBlank(workattachment.getUrl())){

+ 6 - 0
jeeplus-modules/jeeplus-public-modules/pom.xml

@@ -139,6 +139,12 @@
             <artifactId>aliyun-sdk-oss</artifactId>
             <version>${aliyun-sdk-oss.version}</version>
         </dependency>
+        <dependency>
+            <groupId>org.jeeplus</groupId>
+            <artifactId>jeeplus-public-modules-api</artifactId>
+            <version>9.0</version>
+            <scope>compile</scope>
+        </dependency>
     </dependencies>
 
     <build>

+ 11 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/controller/OssFileController.java

@@ -5,6 +5,7 @@ import com.jeeplus.pubmodules.oss.service.OssService;
 import com.jeeplus.pubmodules.oss.service.dto.AttachmentDTO;
 import com.jeeplus.pubmodules.oss.service.dto.FileDetailDTO;
 import com.jeeplus.pubmodules.oss.service.dto.FileUrlDto;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -127,4 +128,14 @@ public class OssFileController {
         FileUrlDto dto = ossService.webUpload(file,dir);
         return ResponseEntity.ok(dto);
     }
+
+    /**
+     * 根据attachmentId查询附件信息(list)
+     * @param id
+     * @return
+     */
+    @PostMapping("selectWorkAttachmentByAttachmentId")
+    public List<WorkAttachmentInfo> selectWorkAttachmentByAttachmentId(String id){
+        return ossService.selectWorkAttachmentByAttachmentId(id);
+    }
 }

+ 23 - 0
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/feign/WorkAttachmentApiImpl.java

@@ -0,0 +1,23 @@
+package com.jeeplus.pubmodules.oss.feign;
+
+import com.jeeplus.pubmodules.oss.service.OssService;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
+import com.jeeplus.sys.feign.IWorkAttachmentApi;
+import org.springframework.beans.factory.annotation.Autowired;
+
+import java.util.List;
+
+/**
+ * @author: 徐滕
+ * @version: 2023-07-11 15:18
+ */
+public class WorkAttachmentApiImpl implements IWorkAttachmentApi {
+
+    @Autowired
+    private OssService ossService;
+
+    @Override
+    public List<WorkAttachmentInfo> selectWorkAttachmentByAttachmentId(String id) {
+        return ossService.selectWorkAttachmentByAttachmentId(id);
+    }
+}

+ 3 - 2
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/mapper/OssServiceMapper.java

@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.toolkit.Constants;
 import com.jeeplus.pubmodules.oss.domain.WorkAttachment;
 import com.jeeplus.pubmodules.oss.service.dto.AttachmentDTO;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
 import com.jeeplus.sys.service.dto.UserDTO;
 import org.apache.ibatis.annotations.Param;
 
@@ -36,6 +37,6 @@ public interface OssServiceMapper extends BaseMapper<WorkAttachment> {
      * @param id
      * @return
      */
-    /*@InterceptorIgnore(tenantLine = "true")
-    List<com.jeeplus.sys.domain.WorkAttachment> selectWorkAttachmentByReportId(String id);*/
+    @InterceptorIgnore(tenantLine = "true")
+    List<WorkAttachmentInfo> selectWorkAttachmentByAttachmentId(String id);
 }

+ 3 - 3
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/mapper/xml/OssServiceMapper.xml

@@ -94,11 +94,11 @@
          </where>
     </select>
 
-    <!--<select id="selectWorkAttachmentByReportId"
-            resultType="com.jeeplus.sys.domain.WorkAttachment">
+    <select id="selectWorkAttachmentByAttachmentId"
+            resultType="com.jeeplus.sys.domain.WorkAttachmentInfo">
 
         select a.* from work_attachment a
         left join cw_project_report_file cf on cf.report_file_id = a.id
         where a.attachment_id = #{id} and cf.seal_type = 1 and a.del_flag = 0
-    </select>-->
+    </select>
 </mapper>

+ 4 - 3
jeeplus-modules/jeeplus-public-modules/src/main/java/com/jeeplus/pubmodules/oss/service/OssService.java

@@ -16,6 +16,7 @@ import com.jeeplus.pubmodules.oss.service.dto.AttachmentDTO;
 import com.jeeplus.pubmodules.oss.service.dto.FileDetailDTO;
 import com.jeeplus.pubmodules.oss.service.dto.FileUrlDto;
 import com.jeeplus.pubmodules.oss.service.dto.WorkAttachmentDto;
+import com.jeeplus.sys.domain.WorkAttachmentInfo;
 import com.jeeplus.sys.service.dto.UserDTO;
 import com.jeeplus.sys.utils.UserUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -441,9 +442,9 @@ public class OssService extends ServiceImpl<OssServiceMapper, WorkAttachment> {
         return i.getId();
     }
 
-    /*public List<com.jeeplus.sys.domain.WorkAttachment> selectWorkAttachmentByReportId (String id){
-        return ossServiceMapper.selectWorkAttachmentByReportId(id);
-    }*/
+    public List<WorkAttachmentInfo> selectWorkAttachmentByAttachmentId (String id){
+        return ossServiceMapper.selectWorkAttachmentByAttachmentId(id);
+    }
 
 
 }