Browse Source

Merge branch 'master' of http://192.168.2.241:3000/linzhiwei/tofly-river into branch-cwf

 Conflicts:
	src/main/java/com/tofly/river/controller/common/FileUploadDownloadController.java
	src/main/java/com/tofly/river/service/data/impl/GovernPointInfoServiceImpl.java
	src/main/resources/application.yml
cwf23 4 years ago
parent
commit
4218389cff
27 changed files with 1437 additions and 37 deletions
  1. 11 0
      pom.xml
  2. 0 1
      src/main/java/com/tofly/river/common/CommonRest.java
  3. 15 0
      src/main/java/com/tofly/river/common/Constants.java
  4. 236 0
      src/main/java/com/tofly/river/common/FileType.java
  5. 35 0
      src/main/java/com/tofly/river/config/MinIoConfig.java
  6. 1 1
      src/main/java/com/tofly/river/controller/BaseController.java
  7. 73 26
      src/main/java/com/tofly/river/controller/common/FileUploadDownloadController.java
  8. 41 0
      src/main/java/com/tofly/river/exception/BusinessException.java
  9. 17 0
      src/main/java/com/tofly/river/mapper/common/FileDataMiddleMapper.java
  10. 16 0
      src/main/java/com/tofly/river/mapper/common/FileInfoMapper.java
  11. 39 0
      src/main/java/com/tofly/river/model/common/dto/FileDataMiddleDto.java
  12. 45 0
      src/main/java/com/tofly/river/model/common/po/FileDataMiddle.java
  13. 90 0
      src/main/java/com/tofly/river/model/common/po/FileInfo.java
  14. 32 0
      src/main/java/com/tofly/river/model/common/vo/FileInfoResultVo.java
  15. 35 1
      src/main/java/com/tofly/river/model/common/vo/special/SpecialGovernPointInfoVo.java
  16. 17 0
      src/main/java/com/tofly/river/service/common/IFileDataMiddleService.java
  17. 60 0
      src/main/java/com/tofly/river/service/common/IFileInfoService.java
  18. 2 2
      src/main/java/com/tofly/river/service/common/IFileUploadDownloadInfoService.java
  19. 21 0
      src/main/java/com/tofly/river/service/common/impl/FileDataMiddleServiceImpl.java
  20. 148 0
      src/main/java/com/tofly/river/service/common/impl/FileInfoServiceImpl.java
  21. 2 1
      src/main/java/com/tofly/river/service/data/IGovernPointInfoService.java
  22. 16 5
      src/main/java/com/tofly/river/service/data/impl/GovernPointInfoServiceImpl.java
  23. 1 0
      src/main/java/com/tofly/river/util/DateTimeUtil.java
  24. 152 0
      src/main/java/com/tofly/river/util/FileTypeJudge.java
  25. 322 0
      src/main/java/com/tofly/river/util/MinIoUtil.java
  26. 5 0
      src/main/resources/mapper/common/FileDataMiddleMapper.xml
  27. 5 0
      src/main/resources/mapper/common/FileInfoMapper.xml

+ 11 - 0
pom.xml

@@ -173,6 +173,17 @@
             <version>0.1.51</version>
         </dependency>
 
+        <dependency>
+            <groupId>io.minio</groupId>
+            <artifactId>minio</artifactId>
+            <version>7.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>net.coobird</groupId>
+            <artifactId>thumbnailator</artifactId>
+            <version>0.4.8</version>
+        </dependency>
 
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 0 - 1
src/main/java/com/tofly/river/common/CommonRest.java

@@ -76,7 +76,6 @@ public final class CommonRest {
     @ApiModelProperty(value = "数据不存在")
     public static final String OBJECT_DOES_NOT_EXIST = "数据不存在";
 
-
     @ApiModelProperty(value = "系统异常CODE")
     public static final Integer SYSTEM_ERROR_CODE = 1020;
     @ApiModelProperty(value = "系统异常")

+ 15 - 0
src/main/java/com/tofly/river/common/Constants.java

@@ -33,4 +33,19 @@ public class Constants {
 
     public static String NO = "0";
 
+    public static String pre_tbl="thumbnail-";
+
+    public static Integer UPLOAD_MAX = 9;
+
+    public static String FJB = "附件包-";
+
+    public static String ZIP = "zip";
+
+    public static String POINT = ".";
+
+    public static final String CSV = ",";
+
+    public static final Integer BUCKET_NEW_MIN = 3;
+
+    public static final Integer IMAGE_TYPE = 1;
 }

+ 236 - 0
src/main/java/com/tofly/river/common/FileType.java

@@ -0,0 +1,236 @@
+package com.tofly.river.common;
+
+
+//文件类型枚取
+public enum FileType {
+    /**
+     * JEPG.
+     */
+    JPEG("FFD8FF"),
+
+    /**
+     * PNG.
+     */
+    PNG("89504E47"),
+
+    /**
+     * GIF.
+     */
+    GIF("47494638"),
+
+    /**
+     * TIFF.
+     */
+    TIFF("49492A00"),
+
+    /**
+     * Windows Bitmap.
+     */
+    BMP("424D"),
+
+    /**
+     * CAD.
+     */
+    DWG("41433130"),
+
+    /**
+     * Adobe Photoshop.
+     */
+    PSD("38425053"),
+
+    /**
+     * Rich Text Format.
+     */
+    RTF("7B5C727466"),
+
+    /**
+     * XML.
+     */
+    XML("3C3F786D6C"),
+
+    /**
+     * HTML.
+     */
+    HTML("68746D6C3E"),
+    /**
+     * CSS.
+     */
+    CSS("48544D4C207B0D0A0942"),
+    /**
+     * JS.
+     */
+    JS("696B2E71623D696B2E71"),
+    /**
+     * Email [thorough only].
+     */
+    EML("44656C69766572792D646174653A"),
+
+    /**
+     * Outlook Express.
+     */
+    DBX("CFAD12FEC5FD746F"),
+
+    /**
+     * Outlook (pst).
+     */
+    PST("2142444E"),
+
+    /**
+     * MS Word/Excel.
+     */
+    XLS_DOC("D0CF11E0"), XLSX_DOCX("504B030414000600080000002100"),
+    /**
+     * Visio
+     */
+    VSD("d0cf11e0a1b11ae10000"),
+    /**
+     * MS Access.
+     */
+    MDB("5374616E64617264204A"),
+    /**
+     * WPS文字wps、表格et、演示dps都是一样的
+     */
+    WPS("d0cf11e0a1b11ae10000"),
+    /**
+     * torrent
+     */
+    TORRENT("6431303A637265617465"),
+    /**
+     * WordPerfect.
+     */
+    WPD("FF575043"),
+
+    /**
+     * Postscript.
+     */
+    EPS("252150532D41646F6265"),
+
+    /**
+     * Adobe Acrobat.
+     */
+    PDF("255044462D312E"),
+
+    /**
+     * Quicken.
+     */
+    QDF("AC9EBD8F"),
+
+    /**
+     * Windows Password.
+     */
+    PWL("E3828596"),
+
+    /**
+     * ZIP Archive.
+     */
+    ZIP("504B0304"),
+
+    /**
+     * RAR Archive.
+     */
+    RAR("52617221"),
+    /**
+     * JSP Archive.
+     */
+    JSP("3C2540207061676520"),
+    /**
+     * JAVA Archive.
+     */
+    JAVA("7061636B61676520"),
+    /**
+     * CLASS Archive.
+     */
+    CLASS("CAFEBABE0000002E00"),
+    /**
+     * JAR Archive.
+     */
+    JAR("504B03040A000000"),
+    /**
+     * MF Archive.
+     */
+    MF("4D616E69666573742D56"),
+    /**
+     *EXE Archive.
+     */
+    EXE("4D5A9000030000000400"),
+    /**
+     *CHM Archive.
+     */
+    CHM("49545346030000006000"),
+    /*
+     * INI("235468697320636F6E66"), SQL("494E5345525420494E54"), BAT(
+     * "406563686F206f66660D"), GZ("1F8B0800000000000000"), PROPERTIES(
+     * "6C6F67346A2E726F6F74"), MXP(
+     * "04000000010000001300"),
+     */
+    /**
+     * Wave.
+     */
+    WAV("57415645"),
+
+    /**
+     * AVI.
+     */
+    AVI("41564920"),
+
+    /**
+     * Real Audio.
+     */
+    RAM("2E7261FD"),
+
+    /**
+     * Real Media.
+     */
+    RM("2E524D46"),
+
+    /**
+     * MPEG (mpg).
+     */
+    MPG("000001BA"),
+
+    /**
+     * Quicktime.
+     */
+    MOV("6D6F6F76"),
+
+    /**
+     * Windows Media.
+     */
+    ASF("3026B2758E66CF11"),
+
+    /**
+     * MIDI.
+     */
+    MID("4D546864"),
+    /**
+     * MP4.
+     */
+    MP4("00000020667479706"),
+    /**
+     * MP3.
+     */
+    MP3("49443303000000002176"),
+    /**
+     * FLV.
+     */
+    FLV("464C5601050000000900");
+    private String value = "";
+
+    /**
+     * Constructor.
+     *
+     * @param value
+     */
+    private FileType(String value) {
+        this.value = value;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public void setValue(String value) {
+        this.value = value;
+    }
+
+}

+ 35 - 0
src/main/java/com/tofly/river/config/MinIoConfig.java

@@ -0,0 +1,35 @@
+package com.tofly.river.config;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * minio 配置
+ * @author BZ-DJJ
+ */
+@Data
+@Configuration
+@ConfigurationProperties(prefix = "minio")
+public class MinIoConfig {
+    /**
+     * minio地址+端口号
+     */
+    private String url;
+
+    /**
+     * minio用户名
+     */
+    private String accessKey;
+
+    /**
+     * minio密码
+     */
+    private String secretKey;
+
+    /**
+     * 文件桶的名称
+     */
+    private String bucketName;
+}
+

+ 1 - 1
src/main/java/com/tofly/river/controller/BaseController.java

@@ -80,7 +80,7 @@ public class BaseController<E, V> {
             iBaseService.indexUpdate(list);
 
             if (iBaseService.save(parDto)) {
-                rest.setData(true);
+                rest.setData(parDto);
             } else {
                 log.info("新增基本信息对象失败:class = {},parDto = {}", model.getName(), parDto);
                 rest.setSuccess(false);

+ 73 - 26
src/main/java/com/tofly/river/controller/common/FileUploadDownloadController.java

@@ -17,7 +17,6 @@ import io.swagger.annotations.ApiOperation;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
-import org.springframework.util.Base64Utils;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -41,53 +40,101 @@ public class FileUploadDownloadController {
 
 
     @Autowired
-    private IFileUploadDownloadInfoService iFileUploadDownloadInfoService;
-
+    private IFileDataMiddleService iFileDataMiddleService;
     /**
      * 文件
      *
-     * @param file 单个上传文件
+     * @param fileList 上传文件/支持单个,多个
      * @return 返回当前存入的文件id
      */
-    @PostMapping(value = "/uploadFile")
-    @ApiOperation(value = "上传单个文件")
-    public Rest<Long> uploadFile(@RequestParam(value = "file", required = false) MultipartFile file) {
-        Rest<Long> rest = new Rest<>();
-        rest.setData(iFileUploadDownloadInfoService.uploadSftp(file, ""));
+    @PostMapping(value = "/uploadFileList")
+    @ApiOperation(value = "上传文件/支持单个,多个")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "fileList", value = "上传文件列表", required = true),
+            @ApiImplicitParam(name = "type", value = "数据类型 00001-公示牌,00002-视点,00003入河口 ", required = true)
+    })
+    public Rest<FileInfoResultVo> uploadFileList(@RequestParam(value = "fileList", required = false) List<MultipartFile> fileList, String type) {
+        Rest<FileInfoResultVo> rest = new Rest<>();
+        try {
+            FileInfoResultVo vo = iFileInfoService.uploadList(fileList, type);
+            rest.setData(vo);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return rest;
+    }
+
+    @ApiOperation(value = "新增数据与文件的关联关系")
+    @PostMapping("/addFileDataRelevance")
+    public Rest<Boolean> addFileDataRelevance(@RequestBody FileDataMiddleDto parDto) {
+        Rest<Boolean> rest = new Rest<>();
+        String dataType = parDto.getDataType();
+        Long dataId = parDto.getDataId();
+        List<Long> fileIdList = parDto.getFileIdList();
+        List<FileDataMiddle> fileDataMiddleList = new ArrayList<>();
+        fileIdList.forEach(fileId ->{
+            FileDataMiddle fileDataMiddle = new FileDataMiddle();
+            fileDataMiddle.setFileId(fileId);
+            fileDataMiddle.setDataType(dataType);
+            fileDataMiddle.setDataId(dataId);
+            fileDataMiddleList.add(fileDataMiddle);
+        });
+        boolean b = iFileDataMiddleService.saveBatch(fileDataMiddleList);
+        rest.setData(b);
         return rest;
     }
 
     @GetMapping(value = "/downloadFile", produces = {MediaType.MULTIPART_FORM_DATA_VALUE})
     @ApiOperation(value = "下载单个文件")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "id", value = "文件ID", required = true)
+            @ApiImplicitParam(name = "id", value = "数据ID", required = true),
+            @ApiImplicitParam(name = "type", value = "数据类型", required = true)
     })
-    public ResponseEntity<byte[]> downloadSftp(Integer id) {
-        ResponseEntity<byte[]> responseEntity = null;
-        try {
-            responseEntity = iFileUploadDownloadInfoService.downloadSftp(id);
-        } catch (JSchException | SftpException | IOException e) {
-            e.printStackTrace();
-        }
-        return responseEntity;
+    public void downloadSftp(Integer id, String type, HttpServletResponse response) {
+        iFileInfoService.downloadFile(Long.valueOf(id), type, response);
     }
 
     @GetMapping(value = "/getFilePathList")
     @ApiOperation(value = "获取对应文件对象列表")
     @ApiImplicitParams({
-            @ApiImplicitParam(name = "ids", value = "文件id列表", required = true)
+            @ApiImplicitParam(name = "ids", value = "数据id,多个以,分隔", required = true),
+            @ApiImplicitParam(name = "type", value = "数据类型", required = true)
     })
-    public Rest<List<FileUploadDownloadInfo>> getFilePathList(@RequestParam("ids")List<Integer> ids) {
-        Rest<List<FileUploadDownloadInfo>> rest = new Rest<>();
-        if(null!=ids && ids.size()>0){
-            QueryWrapper<FileUploadDownloadInfo> queryWrapper = new QueryWrapper<>();
-            queryWrapper.lambda().in(FileUploadDownloadInfo::getId,ids);
-            List<FileUploadDownloadInfo> infoList =  iFileUploadDownloadInfoService.list(queryWrapper);
-            rest.setData(infoList);
+    public Rest<List<FileInfo>> getFilePathList(@RequestParam("ids") String ids, @RequestParam("type") String type) {
+        Rest<List<FileInfo>> rest = new Rest<>();
+        List<String> idList = Arrays.asList(ids.split(Constants.CSV));
+        if (idList.size() > 0) {
+            List<FileInfo> fileInfoList = new ArrayList<>();
+            idList.forEach(info -> {
+                List<FileInfo> fileUrl = iFileInfoService.getFileUrl(Long.valueOf(info), type);
+                fileInfoList.addAll(fileUrl);
+            });
+
+            rest.setData(fileInfoList);
             return rest;
         }
         rest.setErrCode(CommonRest.MISSING_REQUIRED_PARAMETERS_CODE);
         rest.setMessage(CommonRest.MISSING_REQUIRED_PARAMETERS);
         return rest;
     }
+
+    @ApiOperation(value = "删除文件")
+    @DeleteMapping(value = "/delete")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "文件id", required = true),
+    })
+    public Rest<Boolean> delete(@RequestParam("id") Long id) {
+        Rest<Boolean> rest = new Rest<>();
+        // 这里做逻辑数据删除,后续使用定时器去请垃圾
+        // 清空文件信息
+        iFileInfoService.removeById(id);
+        FileDataMiddle fileDataMiddle = iFileDataMiddleService.getOne(new QueryWrapper<FileDataMiddle>().lambda().eq(FileDataMiddle::getFileId, id));
+        if(null!= fileDataMiddle){
+            // 清除关联信息
+            iFileDataMiddleService.removeById(fileDataMiddle.getFileId());
+        }
+
+        return rest;
+    }
+
 }

+ 41 - 0
src/main/java/com/tofly/river/exception/BusinessException.java

@@ -0,0 +1,41 @@
+package com.tofly.river.exception;
+
+/**
+ * 业务逻辑自定义异常
+ *
+ * @author Zev
+ */
+public class BusinessException extends RuntimeException{
+    /**
+     * 异常对应的返回码
+     */
+    private Integer retCd;
+    /**
+     * 异常对应的描述信息
+     */
+    private String msgDes;
+
+    public BusinessException() {
+        super();
+    }
+
+    public BusinessException(String message) {
+        super(message);
+        msgDes = message;
+    }
+
+    public BusinessException(Integer retCd, String msgDes) {
+        super();
+        this.retCd = retCd;
+        this.msgDes = msgDes;
+    }
+
+    public Integer getRetCd() {
+        return retCd;
+    }
+
+    public String getMsgDes() {
+        return msgDes;
+    }
+
+}

+ 17 - 0
src/main/java/com/tofly/river/mapper/common/FileDataMiddleMapper.java

@@ -0,0 +1,17 @@
+package com.tofly.river.mapper.common;
+
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.tofly.river.model.common.po.FileDataMiddle;
+
+/**
+ * <p>
+ * 文件数据中间表 Mapper 接口
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+public interface FileDataMiddleMapper extends BaseMapper<FileDataMiddle> {
+
+}

+ 16 - 0
src/main/java/com/tofly/river/mapper/common/FileInfoMapper.java

@@ -0,0 +1,16 @@
+package com.tofly.river.mapper.common;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.tofly.river.model.common.po.FileInfo;
+
+/**
+ * <p>
+ * 文件信息 Mapper 接口
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+public interface FileInfoMapper extends BaseMapper<FileInfo> {
+
+}

+ 39 - 0
src/main/java/com/tofly/river/model/common/dto/FileDataMiddleDto.java

@@ -0,0 +1,39 @@
+package com.tofly.river.model.common.dto;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * <p>
+ * 文件数据中间表
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+@Data
+@ApiModel(value="FileDataMiddle对象", description="文件数据中间关联请求对象")
+public class FileDataMiddleDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @ApiModelProperty(value = "文件id列表")
+    private List<Long> fileIdList;
+
+    @ApiModelProperty(value = "数据类型")
+    private String dataType;
+
+    @ApiModelProperty(value = "数据id")
+    private Long dataId;
+
+
+}

+ 45 - 0
src/main/java/com/tofly/river/model/common/po/FileDataMiddle.java

@@ -0,0 +1,45 @@
+package com.tofly.river.model.common.po;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 文件数据中间表
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("file_data_middle")
+@ApiModel(value="FileDataMiddle对象", description="文件数据中间表")
+public class FileDataMiddle implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id",type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty(value = "文件id")
+    @TableField("file_id")
+    private Long fileId;
+
+    @ApiModelProperty(value = "数据类型")
+    @TableField("data_type")
+    private String dataType;
+
+    @ApiModelProperty(value = "数据id")
+    @TableField("data_id")
+    private Long dataId;
+
+
+}

+ 90 - 0
src/main/java/com/tofly/river/model/common/po/FileInfo.java

@@ -0,0 +1,90 @@
+package com.tofly.river.model.common.po;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 文件信息
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@TableName("file_info")
+@ApiModel(value="FileInfo对象", description="文件信息")
+public class FileInfo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    @TableId(value = "id",type = IdType.AUTO)
+    private Long id;
+
+    @ApiModelProperty(value = "文件原名称")
+    @TableField("original_name")
+    private String originalName;
+
+    @ApiModelProperty(value = "文件类型 1图片,2文档,3视频,4,种子,5音乐")
+    @TableField("file_type")
+    private String fileType;
+
+    @ApiModelProperty(value = "文件名称")
+    @TableField("file_name")
+    private String fileName;
+
+    @ApiModelProperty(value = "文件路径")
+    @TableField("file_path")
+    private String filePath;
+
+    @ApiModelProperty(value = "文件大小")
+    @TableField("file_size")
+    private Long fileSize;
+
+    @ApiModelProperty(value = "文件备注")
+    @TableField("file_note")
+    private String fileNote;
+
+    @ApiModelProperty(value = "上传设备id")
+    @TableField("upload_equ_id")
+    private Long uploadEquId;
+
+    @ApiModelProperty(value = "上传备注")
+    @TableField("upload_note")
+    private String uploadNote;
+
+    @ApiModelProperty(value = "缩略图名称")
+    @TableField("thumb_name")
+    private String thumbName;
+
+    @ApiModelProperty(value = "缩略图路径")
+    @TableField("thumb_path")
+    private String thumbPath;
+
+    @ApiModelProperty(value = "创建时间")
+    @TableField("create_time")
+    private Date createTime;
+
+    @ApiModelProperty(value = "创建用户")
+    @TableField("create_user_id")
+    private Long createUserId;
+
+    @ApiModelProperty(value = "更新时间")
+    @TableField("update_time")
+    private Date updateTime;
+
+    @ApiModelProperty(value = "更新用户")
+    @TableField("update_user_id")
+    private Long updateUserId;
+
+
+}

+ 32 - 0
src/main/java/com/tofly/river/model/common/vo/FileInfoResultVo.java

@@ -0,0 +1,32 @@
+package com.tofly.river.model.common.vo;
+
+
+import com.tofly.river.model.common.po.FileInfo;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serializable;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 文件信息
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+@Data
+@ApiModel(value="FileInfo对象", description="文件上传信息返回封装")
+public class FileInfoResultVo implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+
+    @ApiModelProperty(value = "文件信息 key 文件类型 1图片,2文档,3视频,4,种子,5音乐 value 详细文件信息列表 ")
+    private Map<String, List<FileInfo>> fileInfoMap;
+
+}

+ 35 - 1
src/main/java/com/tofly/river/model/common/vo/special/SpecialGovernPointInfoVo.java

@@ -1,9 +1,11 @@
 package com.tofly.river.model.common.vo.special;
 
 import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 
 import java.io.Serializable;
+import java.math.BigDecimal;
 
 /**
  * <p>
@@ -14,9 +16,41 @@ import java.io.Serializable;
  * @since 2021-02-25
  */
 @Data
-@ApiModel(description = "专题-治理监测信息列表前端展示对象")
+@ApiModel(description = "专题-管控断面信息列表前端展示对象")
 public class SpecialGovernPointInfoVo implements Serializable {
 
     private static final long serialVersionUID = 1L;
+    @ApiModelProperty(value = "河流编码")
+    private String riverCode;
+
+    @ApiModelProperty(value = "河流名称")
+    private String riverName;
+
+    @ApiModelProperty(value = "管控断面编码")
+    private String code;
+
+    @ApiModelProperty(value = "管控断面名称")
+    private String name;
+
+    @ApiModelProperty(value = "河道宽度")
+    private BigDecimal sectionRiverWidth;
+
+    @ApiModelProperty(value = "经度")
+    private String lon;
+
+    @ApiModelProperty(value = "纬度")
+    private String lat;
+
+    @ApiModelProperty(value = "地址")
+    private String loc;
+
+    @ApiModelProperty(value = "经度纬度")
+    private String lonLat;
+
+    @ApiModelProperty(value = "河道情况")
+    private String sectionSituation;
+
+    @ApiModelProperty(value = "堤岸情况")
+    private String dikeSituation;
 
 }

+ 17 - 0
src/main/java/com/tofly/river/service/common/IFileDataMiddleService.java

@@ -0,0 +1,17 @@
+package com.tofly.river.service.common;
+
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.tofly.river.model.common.po.FileDataMiddle;
+
+/**
+ * <p>
+ * 文件数据中间表 服务类
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+public interface IFileDataMiddleService extends IService<FileDataMiddle> {
+
+}

+ 60 - 0
src/main/java/com/tofly/river/service/common/IFileInfoService.java

@@ -0,0 +1,60 @@
+package com.tofly.river.service.common;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.tofly.river.model.common.po.FileInfo;
+import com.tofly.river.model.common.vo.FileInfoResultVo;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+
+/**
+ * <p>
+ * 文件信息 服务类
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+public interface IFileInfoService extends IService<FileInfo> {
+    /**
+     * 上传附件至固定服务器
+     *
+     * @param fileList 上传多个文件
+     * @param dataType 绑定数据类型
+     * @return 封装返回已经上传的文件信息
+     */
+    FileInfoResultVo uploadList(List<MultipartFile> fileList, String dataType) throws Exception;
+
+
+    /**
+     * 下载单个文件
+     *
+     * @param id
+     * @param type
+     * @param response
+     */
+    void downloadFile(Long id, String type, HttpServletResponse response);
+
+    /**
+     * 获取文件url列表
+     *
+     * @param id
+     * @param type
+     * @return
+     */
+    List<FileInfo> getFileUrl(Long id, String type);
+
+
+    /**
+     * 批量下载文件,并打包
+     *
+     * @param id
+     * @param type
+     * @param request
+     * @param response
+     */
+    void downloadFileList(Long id, String type, HttpServletRequest request, HttpServletResponse response);
+
+}

+ 2 - 2
src/main/java/com/tofly/river/service/common/IFileUploadDownloadInfoService.java

@@ -22,7 +22,7 @@ import java.util.List;
 public interface IFileUploadDownloadInfoService  extends IService<FileUploadDownloadInfo> {
 
     /**
-     * 通过 sftp 上传附件至固定服务器
+     * 通过 minio 上传附件至固定服务器
      *
      * @param file 文件
      * @param dir 文件夹名称
@@ -32,7 +32,7 @@ public interface IFileUploadDownloadInfoService  extends IService<FileUploadDown
 
     /**
      *
-     * 通过 sftp 下载文件
+     * 通过 minio 下载文件
      *
      * @param id 文件id
      * @return

+ 21 - 0
src/main/java/com/tofly/river/service/common/impl/FileDataMiddleServiceImpl.java

@@ -0,0 +1,21 @@
+package com.tofly.river.service.common.impl;
+
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tofly.river.mapper.common.FileDataMiddleMapper;
+import com.tofly.river.model.common.po.FileDataMiddle;
+import com.tofly.river.service.common.IFileDataMiddleService;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 文件数据中间表 服务实现类
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+@Service
+public class FileDataMiddleServiceImpl extends ServiceImpl<FileDataMiddleMapper, FileDataMiddle> implements IFileDataMiddleService {
+
+}

+ 148 - 0
src/main/java/com/tofly/river/service/common/impl/FileInfoServiceImpl.java

@@ -0,0 +1,148 @@
+package com.tofly.river.service.common.impl;
+
+
+import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.tofly.river.common.Constants;
+import com.tofly.river.common.FileType;
+import com.tofly.river.mapper.common.FileInfoMapper;
+import com.tofly.river.model.common.po.FileDataMiddle;
+import com.tofly.river.model.common.po.FileInfo;
+import com.tofly.river.model.common.vo.FileInfoResultVo;
+import com.tofly.river.service.common.IFileDataMiddleService;
+import com.tofly.river.service.common.IFileInfoService;
+import com.tofly.river.util.FileTypeJudge;
+import com.tofly.river.util.MinIoUtil;
+import lombok.SneakyThrows;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+
+/**
+ * <p>
+ * 文件信息 服务实现类
+ * </p>
+ *
+ * @author Zev
+ * @since 2021-04-06
+ */
+@Service
+public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements IFileInfoService {
+
+    @Autowired
+    private IFileDataMiddleService iFileDataMiddleService;
+
+    @Override
+    @SneakyThrows(Exception.class)
+    public FileInfoResultVo uploadList(List<MultipartFile> fileList, String dataType) {
+
+        if (CollectionUtil.isEmpty(fileList)) {
+            throw new Exception("上传的文件列表不能为空!");
+        }
+        if (Constants.UPLOAD_MAX < fileList.size()) {
+            throw new Exception("上传失败,一次最多上传9个文件!");
+        }
+        if (!MinIoUtil.bucketExists(dataType)) {
+            int length = dataType.length();
+            if(Constants.BUCKET_NEW_MIN < length){
+                MinIoUtil.createBucket(dataType);
+            }else {
+                throw new Exception("类型至少3个字符");
+            }
+
+        }
+        FileInfoResultVo fileInfoResultVo =  new FileInfoResultVo();
+        Map<String,List<FileInfo>> fileInfoMap = new HashMap<>(12);
+        fileList.forEach(file -> {
+            // 判断文件类型
+            Integer fileType = 0;
+            try {
+                FileType type = FileTypeJudge.getType(file.getInputStream());
+               fileType = FileTypeJudge.isFileType(type);
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+            String name = file.getOriginalFilename();
+            int lastIndexOf = name.lastIndexOf(Constants.POINT);
+            //获取文件的后缀名 .*
+            String suffix = name.substring(lastIndexOf);
+            // 根据时间戳生成文件名
+            String savaFileName = System.currentTimeMillis() + suffix;
+            String fType = fileType.toString();
+            String filePath = MinIoUtil.upload(dataType, file, savaFileName);
+            FileInfo info = new FileInfo();
+            info.setOriginalName(name.substring(0, lastIndexOf));
+            info.setFileSize(file.getSize());
+            info.setFileType(fType);
+            info.setFileName(savaFileName);
+            info.setFilePath(filePath);
+            // 判断当前是否为图片对象
+            if (1 == fileType) {
+                BufferedImage image = MinIoUtil.getImage(file);
+                // 获取当前上传图片路径,图片则生成缩略图
+                String thumbName = Constants.pre_tbl + savaFileName;
+                String thumbnailFilePath = MinIoUtil.upLoadThumbnail(image, dataType, thumbName);
+                info.setThumbName(thumbName);
+                info.setThumbPath(thumbnailFilePath);
+            }
+
+            this.save(info);
+            if(null == fileInfoMap.get(fType)){
+                List<FileInfo> fileInfoList = new ArrayList<>();
+                fileInfoList.add(info);
+                fileInfoMap.put(fType,fileInfoList) ;
+            }else {
+                List<FileInfo> infoList = fileInfoMap.get(fType);
+                infoList.add(info);
+                fileInfoMap.put(fType,infoList) ;
+            }
+
+
+        });
+        fileInfoResultVo.setFileInfoMap(fileInfoMap);
+        return fileInfoResultVo;
+    }
+
+
+    @Override
+    public void downloadFile(Long id, String type, HttpServletResponse response) {
+        FileDataMiddle middleServiceOne = iFileDataMiddleService.getOne(new QueryWrapper<FileDataMiddle>().lambda().eq(FileDataMiddle::getDataType, type).eq(FileDataMiddle::getDataId, id));
+        FileInfo fileInfo = this.getById(middleServiceOne.getFileId());
+        MinIoUtil.download(type, fileInfo.getFileName(), response);
+    }
+
+    @Override
+    public List<FileInfo> getFileUrl(Long id, String type) {
+        List<Long> middleIdList = iFileDataMiddleService.list(new QueryWrapper<FileDataMiddle>().lambda().eq(FileDataMiddle::getDataType, type).eq(FileDataMiddle::getDataId, id)).stream().map(FileDataMiddle::getFileId).collect(Collectors.toList());
+        List<FileInfo> list = new ArrayList<>();
+        if(middleIdList.size()>0){
+            list.addAll(this.list(new QueryWrapper<FileInfo>().lambda().in(FileInfo::getId, middleIdList)));
+        }
+        return list;
+    }
+
+
+    @Override
+    public void downloadFileList(Long id, String type, HttpServletRequest request, HttpServletResponse response) {
+        List<Long> fileIdList = iFileDataMiddleService.list(new QueryWrapper<FileDataMiddle>().lambda().eq(FileDataMiddle::getDataType, type).eq(FileDataMiddle::getDataId, id)).stream().map(FileDataMiddle::getFileId).collect(Collectors.toList());
+        List<FileInfo> fileInfoList = this.list(new QueryWrapper<FileInfo>().lambda().in(FileInfo::getId, fileIdList));
+        Map<String, String> map =
+                fileInfoList.stream().collect(Collectors.toMap(FileInfo::getFilePath, FileInfo::getFileName));
+
+        MinIoUtil.downloadFileList(map, request, response);
+
+    }
+
+}

+ 2 - 1
src/main/java/com/tofly/river/service/data/IGovernPointInfoService.java

@@ -5,6 +5,7 @@ import com.tofly.river.model.data.vo.GovernPointInfoVo;
 import com.tofly.river.service.IBaseService;
 import com.tofly.river.strategy.ExcelStrategy;
 import com.tofly.river.strategy.PictureStrategy;
+import com.tofly.river.strategy.SpecialStrategy;
 
 import java.util.List;
 
@@ -16,7 +17,7 @@ import java.util.List;
  * @author Zev
  * @since 2021-03-16
  */
-public interface IGovernPointInfoService extends IBaseService<GovernPointInfo, GovernPointInfoVo> , ExcelStrategy, PictureStrategy {
+public interface IGovernPointInfoService extends IBaseService<GovernPointInfo, GovernPointInfoVo> , ExcelStrategy, PictureStrategy, SpecialStrategy {
 
 
 }

+ 16 - 5
src/main/java/com/tofly/river/service/data/impl/GovernPointInfoServiceImpl.java

@@ -15,11 +15,9 @@ import com.tofly.river.model.data.vo.*;
 import com.tofly.river.model.monitor.po.EstuaryMonitorInfo;
 import com.tofly.river.model.monitor.po.GovernPointMonitorInfo;
 import com.tofly.river.model.monitor.vo.WaterQualityMonitorInfoVo;
-import com.tofly.river.model.operation.OneStandard;
 import com.tofly.river.service.data.*;
 import com.tofly.river.service.monitor.ICalculateMonitorInfoService;
 import com.tofly.river.service.monitor.IGovernPointMonitorInfoService;
-import com.tofly.river.service.operation.OneStandardService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -50,9 +48,6 @@ public class GovernPointInfoServiceImpl extends ServiceImpl<GovernPointInfoMappe
     @Autowired
     private ICalculateMonitorInfoService iCalculateMonitorInfoService;
 
-    @Autowired
-    private OneStandardService oneStandardService;
-
     @Override
     public List<GovernPointInfoVo> viewConversion(List<GovernPointInfo> infoList) {
         List<GovernPointInfoVo> infoVoList = new ArrayList<>();
@@ -143,6 +138,22 @@ public class GovernPointInfoServiceImpl extends ServiceImpl<GovernPointInfoMappe
         return monitorInfoAll;
     }
 
+    @Override
+    public Map<String, Object> getSpecialList() {
+        List<GovernPointInfoVo> infoVoList = this.viewConversion(this.list());
+        // 赋值
+        List<SpecialGovernPointInfoVo> list = new ArrayList<>();
+        infoVoList.forEach(info -> {
+            SpecialGovernPointInfoVo infoVo = JSONObject.parseObject(JSON.toJSONString(info), SpecialGovernPointInfoVo.class);
+            infoVo.setCode(info.getGovernPointCode());
+            infoVo.setName(info.getGovernPointName());
+            list.add(infoVo);
+        });
+        Map<String, Object> map = new HashMap<>(12);
+        map.put("GOVERN_POINT_INFO", list);
+        return map;
+    }
+
   /*  @Override
     public List<String> getByCodeAndValueStandard(String code, String value) {
         OneStandard oneStandard = new OneStandard();

+ 1 - 0
src/main/java/com/tofly/river/util/DateTimeUtil.java

@@ -67,6 +67,7 @@ public class DateTimeUtil {
      * @param fromDate
      * @param dateFormat
      * @return
+     *
      */
     public static String getLocalDate(LocalDate fromDate, String dateFormat) {
         DateTimeFormatter df = DateTimeFormatter.ofPattern(dateFormat);

+ 152 - 0
src/main/java/com/tofly/river/util/FileTypeJudge.java

@@ -0,0 +1,152 @@
+package com.tofly.river.util;
+
+import com.tofly.river.common.FileType;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+//文件类型判断类
+public final class FileTypeJudge {
+
+    /**
+     * Constructor
+     */
+    private FileTypeJudge() {
+    }
+
+    /**
+     * 将文件头转换成16进制字符串
+     *
+     * @param src
+     * @return 16进制字符串
+     */
+    private static String bytesToHexString(byte[] src) {
+
+        StringBuilder stringBuilder = new StringBuilder();
+        if (src == null || src.length <= 0) {
+            return null;
+        }
+        for (int i = 0; i < src.length; i++) {
+            int v = src[i] & 0xFF;
+            String hv = Integer.toHexString(v);
+            if (hv.length() < 2) {
+                stringBuilder.append(0);
+            }
+            stringBuilder.append(hv);
+        }
+        return stringBuilder.toString();
+    }
+
+    /**
+     * 得到文件头
+     *
+     * @param is 文件路径
+     * @return 文件头
+     * @throws IOException
+     */
+    private static String getFileContent(InputStream is) throws IOException {
+
+        byte[] b = new byte[28];
+
+        InputStream inputStream = null;
+
+        try {
+            is.read(b, 0, 28);
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw e;
+        } finally {
+            if (inputStream != null) {
+                try {
+                    inputStream.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                    throw e;
+                }
+            }
+        }
+        return bytesToHexString(b);
+    }
+
+    /**
+     * 判断文件类型
+     *
+     * @param is 文件路径
+     * @return 文件类型
+     */
+    public static FileType getType(InputStream is) throws IOException {
+
+        String fileHead = getFileContent(is);
+        if (fileHead == null || fileHead.length() == 0) {
+            return null;
+        }
+        fileHead = fileHead.toUpperCase();
+        FileType[] fileTypes = FileType.values();
+
+        for (FileType type : fileTypes) {
+            if (fileHead.startsWith(type.getValue())) {
+                return type;
+            }
+        }
+
+        return null;
+    }
+
+    /**
+     * @param value 表示文件类型
+     * @return
+     */
+    public static Integer isFileType(FileType value) {
+        // 其他
+        Integer type = 7;
+        // 图片
+        FileType[] pics = {FileType.JPEG, FileType.PNG, FileType.GIF, FileType.TIFF, FileType.BMP, FileType.DWG, FileType.PSD};
+
+        FileType[] docs = {FileType.RTF, FileType.XML, FileType.HTML, FileType.CSS, FileType.JS, FileType.EML, FileType.DBX, FileType.PST, FileType.XLS_DOC, FileType.XLSX_DOCX, FileType.VSD,
+                FileType.MDB, FileType.WPS, FileType.WPD, FileType.EPS, FileType.PDF, FileType.QDF, FileType.PWL, FileType.ZIP, FileType.RAR, FileType.JSP, FileType.JAVA, FileType.CLASS,
+                FileType.JAR, FileType.MF, FileType.EXE, FileType.CHM};
+
+        FileType[] videos = {FileType.AVI, FileType.RAM, FileType.RM, FileType.MPG, FileType.MOV, FileType.ASF, FileType.MP4, FileType.FLV, FileType.MID};
+
+        FileType[] tottents = {FileType.TORRENT};
+
+        FileType[] audios = {FileType.WAV, FileType.MP3};
+
+        FileType[] others = {};
+
+        // 图片
+        for (FileType fileType : pics) {
+            if (fileType.equals(value)) {
+                type = 1;
+            }
+        }
+        // 文档
+        for (FileType fileType : docs) {
+            if (fileType.equals(value)) {
+                type = 2;
+            }
+        }
+        // 视频
+        for (FileType fileType : videos) {
+            if (fileType.equals(value)) {
+                type = 3;
+            }
+        }
+        // 种子
+        for (FileType fileType : tottents) {
+            if (fileType.equals(value)) {
+                type = 4;
+            }
+        }
+        // 音乐
+        for (FileType fileType : audios) {
+            if (fileType.equals(value)) {
+                type = 5;
+            }
+        }
+        return type;
+    }
+
+}

+ 322 - 0
src/main/java/com/tofly/river/util/MinIoUtil.java

@@ -0,0 +1,322 @@
+package com.tofly.river.util;
+
+import com.tofly.river.common.Constants;
+import com.tofly.river.config.MinIoConfig;
+import com.tofly.river.exception.BusinessException;
+import io.minio.MinioClient;
+import io.minio.ObjectStat;
+import io.minio.PutObjectOptions;
+import io.minio.messages.Bucket;
+import lombok.SneakyThrows;
+import lombok.extern.slf4j.Slf4j;
+import net.coobird.thumbnailator.Thumbnails;
+import org.apache.commons.compress.utils.IOUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.annotation.PostConstruct;
+import javax.imageio.ImageIO;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.net.URLEncoder;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
+
+/**
+ * Java Client API参考文档:https://docs.min.io/cn/java-client-api-reference.html
+ * MinIo工具类
+ *
+ * @author BZ-DJJ
+ */
+@Slf4j
+@Component
+public class MinIoUtil {
+    @Autowired
+    MinIoConfig minicofig;
+
+    private static MinioClient minioClient;
+
+    /**
+     * 初始化minio配置
+     *
+     * @param :
+     * @return: void
+     * @date : 2020/8/16 20:56
+     */
+    @PostConstruct
+    public void init() {
+        try {
+            minioClient = new MinioClient(minicofig.getUrl(), minicofig.getAccessKey(),
+                    minicofig.getSecretKey());
+            createBucket(minicofig.getBucketName());
+        } catch (Exception e) {
+            e.printStackTrace();
+            log.error("初始化minio配置异常: 【{}】", e.fillInStackTrace());
+        }
+    }
+
+    /**
+     * 判断 bucket是否存在
+     *
+     * @param bucketName: 桶名
+     * @return: boolean
+     * @date : 2020/8/16 20:53
+     */
+    @SneakyThrows(Exception.class)
+    public static boolean bucketExists(String bucketName) {
+        return minioClient.bucketExists(bucketName);
+    }
+
+    /**
+     * 创建 bucket
+     *
+     * @param bucketName: 桶名
+     * @return: void
+     * @date : 2020/8/16 20:53
+     */
+    @SneakyThrows(Exception.class)
+    public static void createBucket(String bucketName) {
+        boolean isExist = minioClient.bucketExists(bucketName);
+        if (!isExist) {
+            minioClient.makeBucket(bucketName);
+        }
+    }
+
+    /**
+     * 获取全部bucket
+     *
+     * @param :
+     * @return: java.util.List<io.minio.messages.Bucket>
+     * @date : 2020/8/16 23:28
+     */
+    @SneakyThrows(Exception.class)
+    public static List<Bucket> getAllBuckets() {
+        return minioClient.listBuckets();
+    }
+
+    /**
+     * 文件上传
+     *
+     * @param bucketName: 桶名
+     * @param fileName:   文件名
+     * @param filePath:   文件路径
+     * @return: void
+     * @date : 2020/8/16 20:53
+     */
+    @SneakyThrows(Exception.class)
+    public static void upload(String bucketName, String fileName, String filePath) {
+        minioClient.putObject(bucketName, fileName, filePath, null);
+    }
+
+    /**
+     * 文件上传
+     *
+     * @param bucketName: 桶名
+     * @param fileName:   文件名
+     * @param stream:     文件流
+     * @return: java.lang.String : 文件url地址
+     * @date : 2020/8/16 23:40
+     */
+    @SneakyThrows(Exception.class)
+    public static String upload(String bucketName, String fileName, InputStream stream) {
+        minioClient.putObject(bucketName, fileName, stream, new PutObjectOptions(stream.available(), -1));
+        return getFileUrl(bucketName, fileName);
+    }
+
+    /**
+     * 文件上传
+     *
+     * @param bucketName: 桶名
+     * @param file:       文件
+     * @param fileName    保存文件名
+     * @return: java.lang.String : 文件url地址
+     * @date : 2020/8/16 23:40
+     */
+    @SneakyThrows(Exception.class)
+    public static String upload(String bucketName, MultipartFile file,String fileName) {
+        final InputStream is = file.getInputStream();
+        minioClient.putObject(bucketName, fileName, is, new PutObjectOptions(is.available(), -1));
+        is.close();
+        return getFileUrl(bucketName, fileName);
+    }
+
+
+    /**
+     * 生成缩略图并上传
+     * @param image
+     * @param bucketName
+     * @param fileName
+     * @return
+     */
+    @SneakyThrows(Exception.class)
+    public static String upLoadThumbnail(BufferedImage image, String bucketName, String fileName) {
+        if (image != null) {
+            double v = (double) 64 / (double) image.getWidth();
+            try {
+                BufferedImage thumbnail = Thumbnails.of(image)
+                        .scale(v)
+                        .asBufferedImage();
+                ByteArrayOutputStream os = new ByteArrayOutputStream();
+                ImageIO.write(thumbnail, "png", os);
+                InputStream input = new ByteArrayInputStream(os.toByteArray());
+                minioClient.putObject(bucketName, fileName, input, new PutObjectOptions(input.available(), -1));
+                input.close();
+                return getFileUrl(bucketName,fileName);
+            } catch (IOException e) {
+                log.error("生成缩略图失败:{}", e);
+            }
+        }
+      return "";
+    }
+
+    /**
+     * 判断文件为图片
+     *
+     * @param file
+     * @return
+     */
+    public static BufferedImage getImage(MultipartFile file)  {
+        BufferedImage bufferedImage = null;
+        try {
+            bufferedImage = ImageIO.read(file.getInputStream());
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return bufferedImage;
+    }
+
+    /**
+     * 删除文件
+     *
+     * @param bucketName: 桶名
+     * @param fileName:   文件名
+     * @return: void
+     * @date : 2020/8/16 20:53
+     */
+    @SneakyThrows(Exception.class)
+    public static void deleteFile(String bucketName, String fileName) {
+        minioClient.removeObject(bucketName, fileName);
+    }
+
+    /**
+     * 下载文件
+     *
+     * @param bucketName: 桶名
+     * @param fileName:   文件名
+     * @param response:
+     * @return: void
+     * @date : 2020/8/17 0:34
+     */
+    @SneakyThrows(Exception.class)
+    public static void download(String bucketName, String fileName, HttpServletResponse response) {
+        // 获取对象的元数据
+        final ObjectStat stat = minioClient.statObject(bucketName, fileName);
+        response.setContentType(stat.contentType());
+        response.setCharacterEncoding("UTF-8");
+        response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(fileName, "UTF-8"));
+        InputStream is = minioClient.getObject(bucketName, fileName);
+        IOUtils.copy(is, response.getOutputStream());
+        is.close();
+    }
+
+    /**
+     * 批量下载,并打包
+     * @param filePathNameList
+     * @param request
+     * @param response
+     */
+    public static void downloadFileList(Map<String, String> filePathNameList, HttpServletRequest request, HttpServletResponse response){
+        //响应头的设置
+        response.reset();
+        response.setCharacterEncoding("utf-8");
+        response.setContentType("multipart/form-data");
+        //获取时间戳
+        String dates = LocalDateTime.now()+"";
+        //设置压缩包的名字
+        String billname = Constants.FJB+dates;
+        String downloadName = billname+Constants.POINT+Constants.ZIP;
+        //返回客户端浏览器的版本号、类型
+        String agent = request.getHeader("USER-AGENT");
+        try {
+            //针对IE或者以IE为内核的浏览器:
+            if (agent.contains("MSIE")||agent.contains("Trident")) {
+                downloadName = java.net.URLEncoder.encode(downloadName, "UTF-8");
+            } else {
+                //非IE浏览器的处理:
+                downloadName = new String(downloadName.getBytes("UTF-8"),"ISO-8859-1");
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        response.setHeader("Content-Disposition", "attachment;fileName=\"" + downloadName + "\"");
+
+        //设置压缩流:直接写入response,实现边压缩边下载
+        ZipOutputStream zipos = null;
+        try {
+            zipos = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
+            //设置压缩方法
+            zipos.setMethod(ZipOutputStream.DEFLATED);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        //循环将文件写入压缩流
+        AtomicReference<DataOutputStream> os = null;
+
+
+        //查询数据库获取文件信息
+        ZipOutputStream finalZipos = zipos;
+        filePathNameList.forEach((filePath, fileName)->{
+            File file = new File(filePath);
+            if (!file.exists()) {
+                throw new BusinessException("文件已不存在");
+            }else{
+                try {
+                    //添加ZipEntry,并ZipEntry中写入文件流
+                    finalZipos.putNextEntry(new ZipEntry(fileName));
+                    os.set(new DataOutputStream(finalZipos));
+                    InputStream is = new FileInputStream(file);
+                    byte[] b = new byte[100];
+                    int length = 0;
+                    while((length = is.read(b))!= -1){
+                        os.get().write(b, 0, length);
+                    }
+                    is.close();
+                    finalZipos.closeEntry();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+
+        //关闭流
+        try {
+            os.get().flush();
+            os.get().close();
+            zipos.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 获取minio文件的下载地址
+     *
+     * @param bucketName: 桶名
+     * @param fileName:   文件名
+     * @return: java.lang.String
+     * @date : 2020/8/16 22:07
+     */
+    @SneakyThrows(Exception.class)
+    public static String getFileUrl(String bucketName, String fileName) {
+        return minioClient.presignedGetObject(bucketName, fileName);
+    }
+
+}

+ 5 - 0
src/main/resources/mapper/common/FileDataMiddleMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tofly.river.mapper.common.FileDataMiddleMapper">
+
+</mapper>

+ 5 - 0
src/main/resources/mapper/common/FileInfoMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.tofly.river.mapper.common.FileInfoMapper">
+
+</mapper>