liurunyu
2024-04-26 bb7ba94195bb3a28d77085e3958a97d3d69ad79f
1、web分布式文件系统文件下载路径生成逻辑不正确,进行修改
9个文件已修改
119 ■■■■ 已修改文件
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileRestVo.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/global/WebFileCtrl.java 44 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFile.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/application-global.yml 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/resources/mapper/OthFileMapper.xml 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFileSvConf.java 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFmListener.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/FileRestVo.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/RestHashDeal.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/dyFile/FileRestVo.java
@@ -14,7 +14,7 @@
    public String fileSysRestUrl; //文件名称的哈希值对应的文件系统的restful URL,在配置文件中配置
    public String fileWebPath; //文件名称的哈希值对应的文件系统的显示及下载文件的web path,动态生成
    public String fileWebUrl; //文件名称的哈希值对应的文件系统的显示文件的web URL,在配置文件中配置
    public String fileWebDownloadUrl; //文件名称的哈希值对应的文件系统的Action下载文件的web URL,在配置文件中配置
    public String fileWebDownloadPath; //下载文档的Controller的相对路径
    public String toString(){
        return "fileName=" + fileName + "\n"
@@ -25,7 +25,7 @@
                + "fileSysRestUrl=" + fileSysRestUrl + "\n"
                + "fileWebPath=" + fileWebPath + "\n"
                + "fileWebUrl=" + fileWebUrl + "\n"
                + "fileWebDownloadUrl=" + fileWebDownloadUrl;
                + "fileWebDownloadPath=" + fileWebDownloadPath;
    }
    /**
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/global/WebFileCtrl.java
@@ -17,6 +17,8 @@
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.util.Date;
/**
 * web文件上传示例
 */
@@ -35,6 +37,11 @@
    @Value("${dy.webFile.fmUrl}")
    private String fmUrl ;
    /**
     * 上传照片图片文件 (当前只对png jpg格式图片支持缩略图)
     * @param file
     * @return
     */
    @PostMapping("/upPhoto")
    @SsoPowerAop(power = "-1") //登录与权限同时验证
    //https://blog.zhengru.top/posts/33486.html#%E5%8D%95%E6%96%87%E4%BB%B6%E4%B8%8A%E4%BC%A0
@@ -52,8 +59,8 @@
                                fileNameGrp[1],
                                null);
                        String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1], (frVo.getFileWebUrl() + frVo.getFileWebPath()), fileOp.getImgFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath()), frVo.fileWebDownloadUrl) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1], (frVo.getFileWebUrl() + frVo.getFileWebPath()), fileOp.getImgFileZipPath(frVo.getFileWebUrl() + frVo.getFileWebPath()), frVo.fileSysRestUrl + frVo.fileWebDownloadPath + id) ;
                        return  BaseResponseUtils.buildSuccess(fvo) ;
                    }else {
                        return BaseResponseUtils.buildError("未得到上传文件的扩展名");
@@ -70,6 +77,11 @@
        }
    }
    /**
     * 上传录音音频文件
     * @param file
     * @return
     */
    @PostMapping("/upPhone")
    @SsoPowerAop(power = "-1")
    public BaseResponse<?> upPhone(MultipartFile file) {
@@ -86,8 +98,8 @@
                                fileNameGrp[1],
                                null);
                        String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileWebDownloadUrl) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileSysRestUrl + frVo.fileWebDownloadPath + id) ;
                        return  BaseResponseUtils.buildSuccess(fvo) ;
                    }else {
                        return BaseResponseUtils.buildError("未得到上传文件的扩展名");
@@ -105,7 +117,11 @@
    }
    /**
     * 上传录像视频文件
     * @param file
     * @return
     */
    @PostMapping("/upVideo")
    @SsoPowerAop(power = "-1")
    public BaseResponse<?> upVideo(MultipartFile file) {
@@ -122,8 +138,8 @@
                                fileNameGrp[1],
                                null);
                        String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileWebDownloadUrl) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileSysRestUrl + frVo.fileWebDownloadPath + id) ;
                        return  BaseResponseUtils.buildSuccess(fvo) ;
                    }else {
                        return BaseResponseUtils.buildError("未得到上传文件的扩展名");
@@ -141,7 +157,11 @@
    }
    /**
     * 上传文档文件
     * @param file
     * @return
     */
    @PostMapping("/upDocument")
    @SsoPowerAop(power = "-1")
    public BaseResponse<?> upDocument(MultipartFile file) {
@@ -158,8 +178,8 @@
                                fileNameGrp[1],
                                null);
                        String fileMainName = fileOp.getFileMainName(frVo.fileName) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath, frVo.fileWebDownloadUrl);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileWebDownloadUrl) ;
                        Long id = this.saveFileInfo(fileNameGrp[0], fileNameGrp[1], fileMainName, frVo.fileNameHash, frVo.fileWebPath);
                        FileVo fvo = new FileVo(id, frVo.fileNameHash, fileNameGrp[0], fileNameGrp[1],frVo.getFileWebUrl() + frVo.getFileWebPath(), null, frVo.fileSysRestUrl + frVo.fileWebDownloadPath + id) ;
                        return  BaseResponseUtils.buildSuccess(fvo) ;
                    }else {
                        return BaseResponseUtils.buildError("未得到上传文件的扩展名");
@@ -186,14 +206,14 @@
     * @param filePath 文件服务端存储相对路径
     * @return
     */
    private Long saveFileInfo(String orgName, String extName, String newName, Integer hash, String filePath, String downloadPath){
    private Long saveFileInfo(String orgName, String extName, String newName, Integer hash, String filePath){
        OthFile po = new OthFile() ;
        po.orgName = orgName ;
        po.extName = extName ;
        po.newName = newName ;
        po.hash = hash ;
        po.filePath = filePath ;
        po.downloadPath = downloadPath ;
        po.dt = new Date() ;
        return this.sv.save(po) ;
    }
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoOth/OthFile.java
@@ -63,11 +63,6 @@
    public String filePath;
    /**
     * 文件下载路径
     */
    public String downloadPath;
    /**
     * 文件上载日期
     */
    @TableField(value = "dt", fill = FieldFill.INSERT)
pms-parent/pms-global/src/main/resources/application-global.yml
@@ -68,7 +68,6 @@
    other:
        webPort: 12348
        idSuffix: 5
    file:
        idSuffix: 99
    file1:
@@ -109,7 +108,7 @@
            hashEnd: 5461
            restUrl: http://127.0.0.1:${pms.file1.webPort}/file #file是上下文
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/ #nginx服务路径
            webDownloadUrl: http://127.0.0.1:${pms.file1.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=  #实际下载webUrl= restUrl + webDownloadPath
        sv2:
            id: dyFile2
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -118,7 +117,7 @@
            hashEnd: 10923
            restUrl: http://127.0.0.1:${pms.file2.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file2.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv3:
            id: dyFile3
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -127,7 +126,7 @@
            hashEnd: 16385
            restUrl: http://127.0.0.1:${pms.file3.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file3.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv4:
            id: dyFile4
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -136,7 +135,7 @@
            hashEnd: 21847
            restUrl: http://127.0.0.1:${pms.file4.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file4.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv5:
            id: dyFile5
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -145,7 +144,7 @@
            hashEnd: 27309
            restUrl: http://127.0.0.1:${pms.file5.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file5.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv6:
            id: dyFile6
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -154,7 +153,7 @@
            hashEnd: 32767
            restUrl: http://127.0.0.1:${pms.file6.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file6.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv7:
            id: dyFile7
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -163,7 +162,7 @@
            hashEnd: 38229
            restUrl: http://127.0.0.1:${pms.file7.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file7.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv8:
            id: dyFile8
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -172,7 +171,7 @@
            hashEnd: 43691
            restUrl: http://127.0.0.1:${pms.file8.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file8.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv9:
            id: dyFile9
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -181,7 +180,7 @@
            hashEnd: 49153
            restUrl: http://127.0.0.1:${pms.file9.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file9.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv10:
            id: dyFile10
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -190,7 +189,7 @@
            hashEnd: 54615
            restUrl: http://127.0.0.1:${pms.file10.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file10.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv11:
            id: dyFile11
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -199,7 +198,7 @@
            hashEnd: 60077
            restUrl: http://127.0.0.1:${pms.file11.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file11.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
        sv12:
            id: dyFile12
            absolutePath: E:/java/nginx-1.24.0/html/webfiles/
@@ -208,4 +207,4 @@
            hashEnd: 65535
            restUrl: http://127.0.0.1:${pms.file12.webPort}/file
            webUrl: http://127.0.0.1:${pms.nginx.webPort}/webfiles/
            webDownloadUrl: http://127.0.0.1:${pms.file12.webPort}/file/download/down?id=
            webDownloadPath: /download/down?id=
pms-parent/pms-global/src/main/resources/mapper/OthFileMapper.xml
@@ -10,12 +10,11 @@
    <result column="new_name" property="newName" />
    <result column="hash" property="hash" />
    <result column="file_path" property="filePath" />
    <result column="download_path" property="downloadPath" />
    <result column="dt" property="dt" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, org_name, ext_name, new_name, hash, file_path, download_path, dt
    id, org_name, ext_name, new_name, hash, file_path, dt
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
@@ -31,9 +30,9 @@
  </delete>
  <insert id="insert" parameterType="com.dy.pmsGlobal.pojoOth.OthFile">
    <!--@mbg.generated-->
    insert into oth_file (id, org_name, ext_name, new_name, hash, file_path, download_path,
    insert into oth_file (id, org_name, ext_name, new_name, hash, file_path,
      dt)
    values (#{id}, #{orgName}, #{extName}, #{newName}, #{hash}, #{filePath}, #{downloadPath},
    values (#{id}, #{orgName}, #{extName}, #{newName}, #{hash}, #{filePath},
      #{dt})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pmsGlobal.pojoOth.OthFile">
@@ -58,9 +57,6 @@
      <if test="filePath != null">
        file_path,
      </if>
      <if test="downloadPath != null">
        download_path,
      </if>
      <if test="dt != null">
        dt,
      </if>
@@ -83,9 +79,6 @@
      </if>
      <if test="filePath != null">
        #{filePath},
      </if>
      <if test="downloadPath != null">
        #{downloadPath},
      </if>
      <if test="dt != null">
        #{dt},
@@ -111,9 +104,6 @@
      <if test="filePath != null">
        file_path = #{filePath},
      </if>
      <if test="downloadPath != null">
        download_path = #{downloadPath},
      </if>
      <if test="dt != null">
        dt = #{dt},
      </if>
@@ -128,7 +118,6 @@
      new_name = #{newName},
      hash = #{hash},
      file_path = #{filePath},
      download_path = #{downloadPath},
      dt = #{dt}
    where id = #{id}
  </update>
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFileSvConf.java
@@ -51,7 +51,7 @@
        public String fileSysRelativePath; //文件名称的哈希值对应的文件最终存储相对路径的目录,在配置文件中配置
        public String restUrl;//文件系统路径
        public String webUrl ;//下载文档的web路径
        public String webDownloadUrl ;//Action下载文档的web路径
        public String webDownloadPath ;//下载文档的Controller的相对路径
        public Integer hashStart ;//哈希值启始值(包含)
        public Integer hashEnd ;//哈希值截止值(包含)
    
@@ -61,7 +61,7 @@
                String fileSysBasePath,
                String restUrl,
                String webUrl,
                String webDownloadUrl,
                String webDownloadPath,
                Integer hashStart,
                Integer hashEnd)throws Exception{
            this.id = id ;
@@ -69,7 +69,7 @@
            this.fileSysRelativePath = fileSysBasePath ;
            this.restUrl = restUrl ;
            this.webUrl = webUrl ;
            this.webDownloadUrl = webDownloadUrl ;
            this.webDownloadPath = webDownloadPath ;
            this.hashStart = hashStart ;
            this.hashEnd = hashEnd ;
            if(this.id == null || this.id.trim().equals("")){
@@ -99,8 +99,8 @@
                    this.webUrl += "/" ;
                }
            }
            if(this.webDownloadUrl == null || this.webDownloadUrl.trim().equals("")){
                throw new Exception("出错,webDownloadUrl为空了!") ;
            if(this.webDownloadPath == null || this.webDownloadPath.trim().equals("")){
                throw new Exception("出错,webDownloadPath!") ;
            }
            if(this.hashStart == null){
@@ -127,7 +127,7 @@
                    + "fileSysBasePath=" + fileSysRelativePath + "\n"
                    + "restUrl=" + restUrl + "\n"
                    + "webUrl=" + webUrl + "\n" 
                    + "webDownloadUrl=" + webDownloadUrl + "\n"
                    + "webDownloadPath=" + webDownloadPath + "\n"
                    + "hashStart=" + hashStart + "\n" 
                    + "hashEnd=" + hashEnd ;
        }
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/DyFmListener.java
@@ -46,7 +46,7 @@
            String hashEnd = env.getProperty("dy.webFile.sv" + i + ".hashEnd");
            String restUrl = env.getProperty("dy.webFile.sv" + i + ".restUrl");
            String webUrl = env.getProperty("dy.webFile.sv" + i + ".webUrl");
            String webDownloadUrl = env.getProperty("dy.webFile.sv" + i + ".webDownloadUrl");
            String webDownloadPath = env.getProperty("dy.webFile.sv" + i + ".webDownloadPath");
            if(!NumUtil.isPlusIntNumber(hashStart)){
                throw new Exception("配置dy.webFile.sv" + i + ".hashStart 不是整数") ;
            }
@@ -58,7 +58,7 @@
                    relativePath,
                    restUrl,
                    webUrl,
                    webDownloadUrl,
                    webDownloadPath,
                    Integer.parseInt(hashStart),
                    Integer.parseInt(hashEnd))) ;
        }
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/FileRestVo.java
@@ -12,7 +12,7 @@
    public String fileSysRelativePath; //文件名称的哈希值对应的文件最终存储相对路径的目录,在配置文件中配置
    public String fileSysRestUrl; //文件名称的哈希值对应的文件系统的restful URL,在配置文件中配置
    public String fileWebUrl; //文件名称的哈希值对应的文件系统的下载文件的web URL,在配置文件中配置
    public String fileWebDownloadUrl; //文件名称的哈希值对应的文件系统的Action下载文件的web URL,在配置文件中配置
    public String fileWebDownloadPath; //下载文档的Controller的相对路径
    
    public String toString(){
        return "fileName=" + fileName + "\n" 
@@ -22,7 +22,7 @@
                + "fileSysRelativePath=" + fileSysRelativePath + "\n"
                + "restUrl=" + fileSysRestUrl + "\n"
                + "fileWebUrl=" + fileWebUrl + "\n"
                + "fileWebDownloadUrl=" + fileWebDownloadUrl ;
                + "fileWebDownloadPath=" + fileWebDownloadPath ;
    }
}
pms-parent/pms-web-other/src/main/java/com/dy/pmsOther/dyFm/RestHashDeal.java
@@ -42,7 +42,7 @@
                    rvo.fileSysRelativePath = confVo.fileSysRelativePath;
                    rvo.fileSysRestUrl = confVo.restUrl;
                    rvo.fileWebUrl = confVo.webUrl ;
                    rvo.fileWebDownloadUrl = confVo.webDownloadUrl ;
                    rvo.fileWebDownloadPath = confVo.webDownloadPath ;
                }
            }
        }
@@ -85,7 +85,7 @@
                    rvo.fileSysRelativePath = confVo.fileSysRelativePath;
                    rvo.fileSysRestUrl = confVo.restUrl;
                    rvo.fileWebUrl = confVo.webUrl ;
                    rvo.fileWebDownloadUrl = confVo.webDownloadUrl ;
                    rvo.fileWebDownloadPath = confVo.webDownloadPath ;
                }
            }
        }