home vor 2 Jahren
Ursprung
Commit
3eeb79e5c3
35 geänderte Dateien mit 830 neuen und 9 gelöschten Zeilen
  1. 1 0
      bladex-tool/blade-core-context/pom.xml
  2. 1 0
      bladex-tool/blade-core-db/pom.xml
  3. 1 0
      bladex-tool/blade-starter-actuate/pom.xml
  4. 1 0
      bladex-tool/blade-starter-api-crypto/pom.xml
  5. 1 0
      bladex-tool/blade-starter-auth/pom.xml
  6. 1 0
      bladex-tool/blade-starter-cache/pom.xml
  7. 1 0
      bladex-tool/blade-starter-develop/pom.xml
  8. 1 0
      bladex-tool/blade-starter-http/pom.xml
  9. 1 0
      bladex-tool/blade-starter-mongo/pom.xml
  10. 1 0
      bladex-tool/blade-starter-redis/pom.xml
  11. 1 0
      bladex-tool/blade-starter-swagger/pom.xml
  12. 1 0
      bladex-tool/blade-starter-trace/pom.xml
  13. 1 0
      bladex/blade-ops/blade-turbine/pom.xml
  14. 96 0
      hx-api/file-serve-api/src/main/java/com/fjhx/feign/IFileClient.java
  15. 28 0
      hx-api/file-serve-api/src/main/java/com/fjhx/params/FileInfoParam.java
  16. 6 0
      hx-api/iot-management-api/src/main/java/com/fjhx/params/bom/BomVo.java
  17. 7 0
      hx-common/hx-tool/pom.xml
  18. 113 0
      hx-common/hx-tool/src/main/java/com/fjhx/utils/feign/FileClientUtil.java
  19. 6 0
      hx-common/pom.xml
  20. 34 0
      hx-serve/file-serve/pom.xml
  21. 18 0
      hx-serve/file-serve/src/main/java/com/fjhx/FileServeApplication.java
  22. 34 0
      hx-serve/file-serve/src/main/java/com/fjhx/controller/FileInfoController.java
  23. 69 0
      hx-serve/file-serve/src/main/java/com/fjhx/entity/FileInfo.java
  24. 68 0
      hx-serve/file-serve/src/main/java/com/fjhx/feign/FileClient.java
  25. 16 0
      hx-serve/file-serve/src/main/java/com/fjhx/mapper/FileInfoMapper.java
  26. 5 0
      hx-serve/file-serve/src/main/java/com/fjhx/mapper/FileInfoMapper.xml
  27. 56 0
      hx-serve/file-serve/src/main/java/com/fjhx/service/FileInfoService.java
  28. 208 0
      hx-serve/file-serve/src/main/java/com/fjhx/service/impl/FileInfoServiceImpl.java
  29. 13 0
      hx-serve/file-serve/src/main/resources/application-dev.yml
  30. 12 0
      hx-serve/file-serve/src/main/resources/application-prod.yml
  31. 11 0
      hx-serve/file-serve/src/main/resources/application-test.yml
  32. 5 0
      hx-serve/iot-management/pom.xml
  33. 10 2
      hx-serve/iot-management/src/main/java/com/fjhx/serve/bom/service/impl/BomServiceImpl.java
  34. 1 6
      hx-serve/pom.xml
  35. 1 1
      hx-serve/product-library/src/main/java/com/fjhx/ProductLibraryApplication.java

+ 1 - 0
bladex-tool/blade-core-context/pom.xml

@@ -18,6 +18,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <!-- Auto -->
         <dependency>

+ 1 - 0
bladex-tool/blade-core-db/pom.xml

@@ -19,6 +19,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <!--Spring-->
         <dependency>

+ 1 - 0
bladex-tool/blade-starter-actuate/pom.xml

@@ -18,6 +18,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <!-- Auto -->
         <dependency>

+ 1 - 0
bladex-tool/blade-starter-api-crypto/pom.xml

@@ -18,6 +18,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springblade</groupId>

+ 1 - 0
bladex-tool/blade-starter-auth/pom.xml

@@ -19,6 +19,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springblade</groupId>

+ 1 - 0
bladex-tool/blade-starter-cache/pom.xml

@@ -19,6 +19,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springblade</groupId>

+ 1 - 0
bladex-tool/blade-starter-develop/pom.xml

@@ -19,6 +19,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <!--Mybatis-Plus-Generator-->
         <dependency>

+ 1 - 0
bladex-tool/blade-starter-http/pom.xml

@@ -18,6 +18,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>com.squareup.okhttp3</groupId>

+ 1 - 0
bladex-tool/blade-starter-mongo/pom.xml

@@ -18,6 +18,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springframework.boot</groupId>

+ 1 - 0
bladex-tool/blade-starter-redis/pom.xml

@@ -20,6 +20,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springblade</groupId>

+ 1 - 0
bladex-tool/blade-starter-swagger/pom.xml

@@ -20,6 +20,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springblade</groupId>

+ 1 - 0
bladex-tool/blade-starter-trace/pom.xml

@@ -19,6 +19,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <!-- Turbine -->
         <dependency>

+ 1 - 0
bladex/blade-ops/blade-turbine/pom.xml

@@ -27,6 +27,7 @@
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-core-tool</artifactId>
+            <version>3.2.0</version>
         </dependency>
         <dependency>
             <groupId>org.springblade</groupId>

+ 96 - 0
hx-api/file-serve-api/src/main/java/com/fjhx/feign/IFileClient.java

@@ -0,0 +1,96 @@
+package com.fjhx.feign;
+
+import com.fjhx.constants.ClientConstant;
+import com.fjhx.params.FileInfoParam;
+import org.springblade.core.tool.api.R;
+import org.springframework.cloud.openfeign.FeignClient;
+import org.springframework.web.bind.annotation.PostMapping;
+
+import java.util.List;
+
+/**
+ * File Feign接口类
+ */
+@FeignClient(value = "file-serve")
+public interface IFileClient {
+
+    String BINDING_FILE = ClientConstant.API_PREFIX + "/bindingFile";
+
+    String BINDING_FILE_LIST = ClientConstant.API_PREFIX + "/bindingFileList";
+
+    String AGAIN_BINDING_FILE = ClientConstant.API_PREFIX + "/againBindingFile";
+
+    String AGAIN_BINDING_FILE_List = ClientConstant.API_PREFIX + "/againBindingFileList";
+
+    String RELIEVE_BINDING_FILE = ClientConstant.API_PREFIX + "/relieveBindingFile";
+
+    String GET_FILE_INFO = ClientConstant.API_PREFIX + "/getFileInfo";
+
+    String GET_FILE_INFO_LIST = ClientConstant.API_PREFIX + "/getFileInfoList";
+
+
+    /**
+     * 文件绑定业务id
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param param        文件信息
+     */
+    @PostMapping(BINDING_FILE)
+    R bindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param);
+
+    /**
+     * 文件绑定业务id
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param paramList    文件信息
+     */
+    @PostMapping(BINDING_FILE_LIST)
+    R bindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList);
+
+    /**
+     * 修改文件绑定信息
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param param        文件信息
+     */
+    @PostMapping(AGAIN_BINDING_FILE)
+    R againBindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param);
+
+    /**
+     * 修改文件绑定信息
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param paramList    文件信息
+     */
+    @PostMapping(AGAIN_BINDING_FILE_List)
+    R againBindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList);
+
+    /**
+     * 删除文件绑定信息
+     *
+     * @param businessId 业务id
+     */
+    @PostMapping(RELIEVE_BINDING_FILE)
+    R relieveBindingFile(Long businessId);
+
+    /**
+     * 获取文件信息
+     *
+     * @param businessId 业务id
+     */
+    @PostMapping(GET_FILE_INFO)
+    R<FileInfoParam> getFileInfo(Long businessId, Integer businessType);
+
+    /**
+     * 获取文件信息
+     *
+     * @param businessId 业务id
+     */
+    @PostMapping(GET_FILE_INFO_LIST)
+    R<List<FileInfoParam>> getFileInfoList(Long businessId, Integer businessType);
+
+}

+ 28 - 0
hx-api/file-serve-api/src/main/java/com/fjhx/params/FileInfoParam.java

@@ -0,0 +1,28 @@
+package com.fjhx.params;
+
+import lombok.Data;
+
+@Data
+public class FileInfoParam {
+
+    /**
+     * 文件id
+     */
+    private Long id;
+
+    /**
+     * 文件名称
+     */
+    private String fileName;
+
+    /**
+     * 文件大小
+     */
+    private String filePath;
+
+    /**
+     * 业务id
+     */
+    private Long businessId;
+
+}

+ 6 - 0
hx-api/iot-management-api/src/main/java/com/fjhx/params/bom/BomVo.java

@@ -1,6 +1,7 @@
 package com.fjhx.params.bom;
 
 import com.fjhx.entity.bom.Bom;
+import com.fjhx.params.FileInfoParam;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -24,4 +25,9 @@ public class BomVo extends Bom {
      */
     private String classifName;
 
+    /**
+     * 文件信息
+     */
+    private FileInfoParam fileInfoParam;
+
 }

+ 7 - 0
hx-common/hx-tool/pom.xml

@@ -40,11 +40,18 @@
             <artifactId>hutool-all</artifactId>
         </dependency>
 
+        <!--    用户模块    -->
         <dependency>
             <groupId>org.springblade</groupId>
             <artifactId>blade-user-api</artifactId>
         </dependency>
 
+        <!--    文件模块    -->
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>file-serve-api</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 113 - 0
hx-common/hx-tool/src/main/java/com/fjhx/utils/feign/FileClientUtil.java

@@ -0,0 +1,113 @@
+package com.fjhx.utils.feign;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.extra.spring.SpringUtil;
+import com.fjhx.feign.IFileClient;
+import com.fjhx.params.FileInfoParam;
+import com.fjhx.utils.Assert;
+import org.springblade.core.tool.api.R;
+
+import java.util.List;
+
+public class FileClientUtil {
+
+    // app名称
+    private static final String APPLICATION_NAME = SpringUtil.getApplicationName();
+    // fileClient
+    private static final IFileClient fileClient = SpringUtil.getBean(IFileClient.class);
+
+    /**
+     * 文件绑定业务id
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param param        文件信息
+     */
+    public static void bindingFile(Long businessId, Integer businessType, FileInfoParam param) {
+        if (ObjectUtil.isEmpty(param)) return;
+        R result = fileClient.bindingFile(APPLICATION_NAME, businessId, businessType, param);
+        Assert.eqTrue(result.isSuccess(), "保存文件信息失败");
+    }
+
+    /**
+     * 文件绑定业务id
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param paramList    文件信息
+     */
+    public static void bindingFile(Long businessId, Integer businessType, List<FileInfoParam> paramList) {
+        if (ObjectUtil.isEmpty(paramList)) return;
+        R result = fileClient.bindingFile(APPLICATION_NAME, businessId, businessType, paramList);
+        Assert.eqTrue(result.isSuccess(), "保存文件信息失败");
+    }
+
+    /**
+     * 修改文件绑定信息
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param param        文件信息
+     */
+    public static void againBindingFile(Long businessId, Integer businessType, FileInfoParam param) {
+        if (ObjectUtil.isEmpty(param)) return;
+        R result = fileClient.againBindingFile(APPLICATION_NAME, businessId, businessType, param);
+        Assert.eqTrue(result.isSuccess(), "保存文件信息失败");
+    }
+
+    /**
+     * 修改文件绑定信息
+     *
+     * @param businessId   业务id
+     * @param businessType 业务类型
+     * @param paramList    文件信息
+     */
+    public static void againBindingFile(Long businessId, Integer businessType, List<FileInfoParam> paramList) {
+        if (ObjectUtil.isEmpty(paramList)) return;
+        R result = fileClient.againBindingFile(APPLICATION_NAME, businessId, businessType, paramList);
+        Assert.eqTrue(result.isSuccess(), "保存文件信息失败");
+    }
+
+    /**
+     * 删除文件绑定信息
+     *
+     * @param businessId 业务id
+     */
+    public static void relieveBindingFile(Long businessId) {
+        R result = fileClient.relieveBindingFile(businessId);
+        Assert.eqTrue(result.isSuccess(), "文件删除失败");
+    }
+
+    /**
+     * 获取文件信息
+     */
+    public static void getFileInfo(Long businessId) {
+        R<FileInfoParam> result = fileClient.getFileInfo(businessId, null);
+        Assert.eqTrue(result.isSuccess(), "获取文件信息失败");
+    }
+
+    /**
+     * 获取文件信息
+     */
+    public static void getFileInfo(Long businessId, Integer businessType) {
+        R<FileInfoParam> result = fileClient.getFileInfo(businessId, businessType);
+        Assert.eqTrue(result.isSuccess(), "获取文件信息失败");
+    }
+
+    /**
+     * 获取文件信息
+     */
+    public static void getFileInfoList(Long businessId) {
+        R<List<FileInfoParam>> result = fileClient.getFileInfoList(businessId, null);
+        Assert.eqTrue(result.isSuccess(), "获取文件信息失败");
+    }
+
+    /**
+     * 获取文件信息
+     */
+    public static void getFileInfoList(Long businessId, Integer businessType) {
+        R<List<FileInfoParam>> result = fileClient.getFileInfoList(businessId, businessType);
+        Assert.eqTrue(result.isSuccess(), "获取文件信息失败");
+    }
+
+}

+ 6 - 0
hx-common/pom.xml

@@ -50,6 +50,12 @@
                 <version>${hx.version}</version>
             </dependency>
 
+            <dependency>
+                <groupId>com.fjhx</groupId>
+                <artifactId>file-serve-api</artifactId>
+                <version>${hx.version}</version>
+            </dependency>
+
             <!-- hutool 工具包 -->
             <dependency>
                 <groupId>cn.hutool</groupId>

+ 34 - 0
hx-serve/file-serve/pom.xml

@@ -0,0 +1,34 @@
+<?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>hx-serve</artifactId>
+        <groupId>com.fjhx</groupId>
+        <version>3.2.0</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>file-serve</artifactId>
+
+    <properties>
+        <maven.compiler.source>8</maven.compiler.source>
+        <maven.compiler.target>8</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>hx-tool</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>file-serve-api</artifactId>
+        </dependency>
+
+    </dependencies>
+
+
+</project>

+ 18 - 0
hx-serve/file-serve/src/main/java/com/fjhx/FileServeApplication.java

@@ -0,0 +1,18 @@
+package com.fjhx;
+
+import org.springblade.core.launch.BladeApplication;
+import org.springframework.cloud.client.SpringCloudApplication;
+
+/**
+ * 杰生模块启动器
+ */
+@SpringCloudApplication
+public class FileServeApplication {
+
+    private static final String APP_NAME = "file-serve";
+
+    public static void main(String[] args) {
+        BladeApplication.run(APP_NAME, FileServeApplication.class, args);
+    }
+
+}

+ 34 - 0
hx-serve/file-serve/src/main/java/com/fjhx/controller/FileInfoController.java

@@ -0,0 +1,34 @@
+package com.fjhx.controller;
+
+import com.fjhx.service.FileInfoService;
+import org.springblade.core.tool.api.R;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.Map;
+
+/**
+ * <p>
+ * 文件 前端控制器
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-07-07
+ */
+@RestController
+public class FileInfoController {
+
+    @Autowired
+    private FileInfoService fileInfoService;
+
+    @PostMapping("/uploadFile")
+    public R uploadFile(@RequestParam("file") MultipartFile file) {
+        Map<String, String> result = fileInfoService.uploadFile(file);
+        return R.success(result);
+    }
+
+}
+

+ 69 - 0
hx-serve/file-serve/src/main/java/com/fjhx/entity/FileInfo.java

@@ -0,0 +1,69 @@
+package com.fjhx.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fjhx.base.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 文件
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-07-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class FileInfo extends BaseEntity {
+
+    /**
+     * 文件名称
+     */
+    private String fileName;
+
+    /**
+     * 文件后缀
+     */
+    private String fileSuffix;
+
+    /**
+     * 文件类型
+     */
+    private String contentType;
+
+    /**
+     * 文件大小
+     */
+    private Long fileSize;
+
+    /**
+     * 文件路径
+     */
+    private String filePath;
+
+    /**
+     * 业务id
+     */
+    private Long businessId;
+
+    /**
+     * 业务类型
+     */
+    private Integer businessType;
+
+    /**
+     * 模块名称
+     */
+    private String applicationName;
+
+    /**
+     * 逻辑删除 0未删除 1已删除
+     */
+    @TableField(fill = FieldFill.INSERT)
+    @TableLogic
+    private Integer delFlag;
+
+}

+ 68 - 0
hx-serve/file-serve/src/main/java/com/fjhx/feign/FileClient.java

@@ -0,0 +1,68 @@
+package com.fjhx.feign;
+
+import com.fjhx.params.FileInfoParam;
+import com.fjhx.service.FileInfoService;
+import org.springblade.core.tool.api.R;
+import org.springblade.system.user.entity.UserInfo;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+public class FileClient implements IFileClient {
+
+    @Autowired
+    private FileInfoService fileInfoService;
+
+    @PostMapping(BINDING_FILE)
+    @Override
+    public R bindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param) {
+        fileInfoService.bindingFile(applicationName, businessId, businessType, param);
+        return R.success();
+    }
+
+    @PostMapping(BINDING_FILE_LIST)
+    @Override
+    public R<UserInfo> bindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList) {
+        fileInfoService.bindingFile(applicationName, businessId, businessType, paramList);
+        return R.success();
+    }
+
+    @PostMapping(AGAIN_BINDING_FILE)
+    @Override
+    public R againBindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param) {
+        fileInfoService.againBindingFile(applicationName, businessId, businessType, param);
+        return R.success();
+    }
+
+    @PostMapping(AGAIN_BINDING_FILE_List)
+    @Override
+    public R<UserInfo> againBindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList) {
+        fileInfoService.againBindingFile(applicationName, businessId, businessType, paramList);
+        return R.success();
+    }
+
+    @PostMapping(RELIEVE_BINDING_FILE)
+    @Override
+    public R<UserInfo> relieveBindingFile(Long businessId) {
+        fileInfoService.relieveBindingFile(businessId);
+        return R.success();
+    }
+
+    @PostMapping(GET_FILE_INFO)
+    @Override
+    public R<FileInfoParam> getFileInfo(Long businessId, Integer businessType) {
+        FileInfoParam fileInfoParam = fileInfoService.getFileInfo(businessId, businessType);
+        return R.success(fileInfoParam);
+    }
+
+    @PostMapping(GET_FILE_INFO_LIST)
+    @Override
+    public R<List<FileInfoParam>> getFileInfoList(Long businessId, Integer businessType) {
+        List<FileInfoParam> fileInfoParamList = fileInfoService.getFileInfoList(businessId, businessType);
+        return R.success(fileInfoParamList);
+    }
+
+}

+ 16 - 0
hx-serve/file-serve/src/main/java/com/fjhx/mapper/FileInfoMapper.java

@@ -0,0 +1,16 @@
+package com.fjhx.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fjhx.entity.FileInfo;
+
+/**
+ * <p>
+ * 文件 Mapper 接口
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-07-07
+ */
+public interface FileInfoMapper extends BaseMapper<FileInfo> {
+
+}

+ 5 - 0
hx-serve/file-serve/src/main/java/com/fjhx/mapper/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.fjhx.mapper.FileInfoMapper">
+
+</mapper>

+ 56 - 0
hx-serve/file-serve/src/main/java/com/fjhx/service/FileInfoService.java

@@ -0,0 +1,56 @@
+package com.fjhx.service;
+
+import com.fjhx.base.BaseService;
+import com.fjhx.entity.FileInfo;
+import com.fjhx.params.FileInfoParam;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * <p>
+ * 文件 服务类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-07-07
+ */
+public interface FileInfoService extends BaseService<FileInfo> {
+
+    /**
+     * 文件上传
+     */
+    Map<String, String> uploadFile(MultipartFile file);
+
+    /**
+     * 绑定文件
+     */
+    void bindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param);
+
+    /**
+     * 绑定文件
+     */
+    void bindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList);
+
+    /**
+     * 重新绑定文件
+     */
+    void againBindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param);
+
+    /**
+     * 重新绑定文件
+     */
+    void againBindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList);
+
+    /**
+     * 解除绑定文件
+     */
+    void relieveBindingFile(Long businessId);
+
+
+    FileInfoParam getFileInfo(Long businessId, Integer businessType);
+
+    List<FileInfoParam> getFileInfoList(Long businessId, Integer businessType);
+
+}

+ 208 - 0
hx-serve/file-serve/src/main/java/com/fjhx/service/impl/FileInfoServiceImpl.java

@@ -0,0 +1,208 @@
+package com.fjhx.service.impl;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.io.FileUtil;
+import cn.hutool.core.lang.UUID;
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.fjhx.base.BaseEntity;
+import com.fjhx.entity.FileInfo;
+import com.fjhx.mapper.FileInfoMapper;
+import com.fjhx.params.FileInfoParam;
+import com.fjhx.service.FileInfoService;
+import org.springblade.core.launch.BladeApplication;
+import org.springblade.core.log.exception.ServiceException;
+import org.springblade.core.tool.utils.DateUtil;
+import org.springframework.stereotype.Service;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 文件 服务实现类
+ * </p>
+ *
+ * @author ${author}
+ * @since 2022-07-07
+ */
+@Service
+public class FileInfoServiceImpl extends ServiceImpl<FileInfoMapper, FileInfo> implements FileInfoService {
+
+    @Override
+    public Map<String, String> uploadFile(MultipartFile file) {
+
+        String fileName = file.getOriginalFilename();
+        String suffix = FileUtil.getSuffix(fileName);
+
+        String path = getFilePath();
+        String filePath = path + UUID.randomUUID() + "." + suffix;
+
+        FileUtil.mkdir(path);
+        FileOutputStream fileOutputStream = null;
+        InputStream inputStream = null;
+
+        try {
+            inputStream = file.getInputStream();
+            fileOutputStream = new FileOutputStream(filePath);
+            int index;
+            byte[] bytes = new byte[1024];
+
+            while ((index = inputStream.read(bytes)) != -1) {
+                fileOutputStream.write(bytes, 0, index);
+                fileOutputStream.flush();
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+            throw new ServiceException("上传文件失败");
+        } finally {
+            try {
+                if (fileOutputStream != null) {
+                    fileOutputStream.close();
+                }
+                if (inputStream != null) {
+                    inputStream.close();
+                }
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+
+        FileInfo fileInfo = new FileInfo();
+        fileInfo.setFileName(fileName);
+        fileInfo.setFileSuffix(suffix);
+        fileInfo.setContentType(file.getContentType());
+        fileInfo.setFileSize(file.getSize());
+        fileInfo.setFilePath(filePath);
+        save(fileInfo);
+
+        Map<String, String> map = new HashMap<>();
+
+        map.put("fileName", fileName);
+        map.put("filePath", filePath);
+        map.put("id", fileInfo.getId().toString());
+
+        return map;
+    }
+
+    @Override
+    public void bindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param) {
+
+        FileInfo fileInfo = BeanUtil.toBean(param, FileInfo.class);
+        fileInfo.setBusinessId(businessId);
+        fileInfo.setBusinessType(businessType);
+        fileInfo.setApplicationName(applicationName);
+
+        updateById(fileInfo);
+    }
+
+    public void bindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList) {
+        if (paramList.size() == 0) {
+            return;
+        }
+
+        List<FileInfo> collect = paramList.stream().map(item -> {
+            FileInfo fileInfo = BeanUtil.toBean(item, FileInfo.class);
+            fileInfo.setBusinessId(businessId);
+            fileInfo.setBusinessType(businessType);
+            fileInfo.setApplicationName(applicationName);
+            return fileInfo;
+        }).collect(Collectors.toList());
+
+        updateBatchById(collect);
+    }
+
+    @Override
+    public void againBindingFile(String applicationName, Long businessId, Integer businessType, FileInfoParam param) {
+        if (ObjectUtil.isNotEmpty(param.getBusinessId())) {
+            return;
+        }
+        removeById(param.getId());
+
+        FileInfo fileInfo = BeanUtil.toBean(param, FileInfo.class);
+        fileInfo.setBusinessId(businessId);
+        fileInfo.setBusinessType(businessType);
+        fileInfo.setApplicationName(applicationName);
+        updateById(fileInfo);
+    }
+
+    @Override
+    public void againBindingFile(String applicationName, Long businessId, Integer businessType, List<FileInfoParam> paramList) {
+
+        List<Long> excludeIdList = new ArrayList<>();
+
+        List<FileInfo> collect = paramList.stream().filter(fileInfo -> {
+            if (ObjectUtil.isNotEmpty(fileInfo.getBusinessId())) {
+                excludeIdList.add(fileInfo.getId());
+                return false;
+            }
+            return true;
+        }).map(item -> {
+            FileInfo fileInfo = BeanUtil.toBean(item, FileInfo.class);
+            fileInfo.setBusinessId(businessId);
+            fileInfo.setBusinessType(businessType);
+            fileInfo.setApplicationName(applicationName);
+            return fileInfo;
+        }).collect(Collectors.toList());
+
+        remove(Wrappers.<FileInfo>lambdaQuery()
+                .eq(FileInfo::getBusinessId, businessId)
+                .eq(FileInfo::getBusinessType, businessType)
+                .notIn(excludeIdList.size() > 0, BaseEntity::getId, collect));
+
+        if (collect.size() > 0) {
+            updateBatchById(collect);
+        }
+
+    }
+
+    @Override
+    public void relieveBindingFile(Long businessId) {
+        remove(FileInfo::getBusinessId, businessId);
+    }
+
+    @Override
+    public FileInfoParam getFileInfo(Long businessId, Integer businessType) {
+
+        LambdaQueryWrapper<FileInfo> wrapper = Wrappers.<FileInfo>lambdaQuery()
+                .eq(FileInfo::getBusinessId, businessId)
+                .eq(ObjectUtil.isNotEmpty(businessType), FileInfo::getBusinessType, businessType)
+                .orderByDesc(BaseEntity::getId)
+                .last("limit 1");
+
+        FileInfo fileInfo = getOne(wrapper);
+
+        return BeanUtil.toBean(fileInfo, FileInfoParam.class);
+    }
+
+    @Override
+    public List<FileInfoParam> getFileInfoList(Long businessId, Integer businessType) {
+
+        LambdaQueryWrapper<FileInfo> wrapper = Wrappers.<FileInfo>lambdaQuery()
+                .eq(FileInfo::getBusinessId, businessId)
+                .eq(ObjectUtil.isNotEmpty(businessType), FileInfo::getBusinessType, businessType);
+
+        List<FileInfo> list = list(wrapper);
+
+        return list.stream().map(item -> BeanUtil.toBean(item, FileInfoParam.class)).collect(Collectors.toList());
+    }
+
+    /**
+     * 获取文件保存路径
+     *
+     * @return
+     */
+    private String getFilePath() {
+        StringJoiner joiner = new StringJoiner("/");
+        joiner.add(BladeApplication.isLocalDev() ? "D:/hx" : "/mnt/file");
+        joiner.add(DateUtil.format(new Date(), "yyyy-MM/dd/"));
+        return joiner.toString();
+    }
+
+}

+ 13 - 0
hx-serve/file-serve/src/main/resources/application-dev.yml

@@ -0,0 +1,13 @@
+# 服务器端口
+server:
+  port: 8001
+logging:
+  level:
+    org.springframework.data.mongodb.core: DEBUG
+# 数据源配置
+spring:
+  # 数据库
+  datasource:
+    url: ${blade.datasource.file_serve.dev.url}
+    username: ${blade.datasource.file_serve.dev.username}
+    password: ${blade.datasource.file_serve.dev.password}

+ 12 - 0
hx-serve/file-serve/src/main/resources/application-prod.yml

@@ -0,0 +1,12 @@
+# 服务器端口
+server:
+  port: 8001
+
+# 数据源配置
+spring:
+  # 数据库
+  datasource:
+    url: ${blade.datasource.file_serve.prod.url}
+    username: ${blade.datasource.file_serve.prod.username}
+    password: ${blade.datasource.file_serve.prod.password}
+

+ 11 - 0
hx-serve/file-serve/src/main/resources/application-test.yml

@@ -0,0 +1,11 @@
+# 服务器端口
+server:
+  port: 8001
+
+# 数据源配置
+spring:
+  # 数据库
+  datasource:
+    url: ${blade.datasource.file_serve.test.url}
+    username: ${blade.datasource.file_serve.test.username}
+    password: ${blade.datasource.file_serve.test.password}

+ 5 - 0
hx-serve/iot-management/pom.xml

@@ -28,6 +28,11 @@
             <artifactId>iot-management-api</artifactId>
         </dependency>
 
+        <dependency>
+            <groupId>com.fjhx</groupId>
+            <artifactId>file-serve-api</artifactId>
+        </dependency>
+
     </dependencies>
 
 </project>

+ 10 - 2
hx-serve/iot-management/src/main/java/com/fjhx/serve/bom/service/impl/BomServiceImpl.java

@@ -3,15 +3,18 @@ package com.fjhx.serve.bom.service.impl;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.fjhx.serve.bom.mapper.BomMapper;
-import com.fjhx.serve.bom.service.BomService;
 import com.fjhx.constants.StatusConstant;
 import com.fjhx.entity.bom.Bom;
 import com.fjhx.enums.bom.BomTypeEnum;
+import com.fjhx.params.FileInfoParam;
 import com.fjhx.params.bom.BomVo;
+import com.fjhx.serve.bom.mapper.BomMapper;
+import com.fjhx.serve.bom.service.BomService;
 import com.fjhx.utils.WrapperUtil;
+import com.fjhx.utils.feign.FileClientUtil;
 import com.fjhx.utils.feign.UserClientUtil;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.Map;
 
@@ -48,10 +51,15 @@ public class BomServiceImpl extends ServiceImpl<BomMapper, Bom> implements BomSe
         return result;
     }
 
+    @Transactional
     @Override
     public void add(BomVo bomVo) {
 
         save(bomVo);
+
+        FileInfoParam fileInfoParam = bomVo.getFileInfoParam();
+        FileClientUtil.bindingFile(bomVo.getId(), 1, fileInfoParam);
+
     }
 
     @Override

+ 1 - 6
hx-serve/pom.xml

@@ -24,6 +24,7 @@
         <module>iot-management</module>
         <module>storage</module>
         <module>product-library</module>
+        <module>file-serve</module>
     </modules>
 
     <dependencyManagement>
@@ -47,12 +48,6 @@
 
             <dependency>
                 <groupId>com.fjhx</groupId>
-                <artifactId>file-tool</artifactId>
-                <version>${hx.version}</version>
-            </dependency>
-
-            <dependency>
-                <groupId>com.fjhx</groupId>
                 <artifactId>iot-management-api</artifactId>
                 <version>${hx.version}</version>
             </dependency>

+ 1 - 1
hx-serve/product-library/src/main/java/com/fjhx/ProductLibraryApplication.java

@@ -9,7 +9,7 @@ import org.springframework.cloud.client.SpringCloudApplication;
 @SpringCloudApplication
 public class ProductLibraryApplication {
 
-    private static final String APP_NAME = "product-library";
+    public static final String APP_NAME = "product-library";
 
     public static void main(String[] args) {
         BladeApplication.run(APP_NAME, ProductLibraryApplication.class, args);