Merge branch 'pms'
This commit is contained in:
31
pom.xml
31
pom.xml
@@ -25,6 +25,7 @@
|
||||
<module>pqs-process</module>
|
||||
<module>pqs-algorithm</module>
|
||||
|
||||
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
<name>灿能微服务生态系统</name>
|
||||
@@ -43,7 +44,7 @@
|
||||
<properties>
|
||||
<!--中间件目标地址-->
|
||||
<!-- <middle.server.url>198.120.100.195</middle.server.url>-->
|
||||
<middle.server.url>192.168.1.31</middle.server.url>
|
||||
<middle.server.url>192.168.1.13</middle.server.url>
|
||||
<!--微服务模块发布地址-->
|
||||
<!-- <service.server.url>198.120.100.195</service.server.url>-->
|
||||
<service.server.url>192.168.1.111</service.server.url>
|
||||
@@ -52,10 +53,11 @@
|
||||
<!--nacos的ip:port-->
|
||||
<nacos.url>${middle.server.url}:18848</nacos.url>
|
||||
<!--服务器发布内容为空-->
|
||||
<nacos.namespace></nacos.namespace>
|
||||
<!-- <nacos.namespace>fd74182b-1fce-4dba-afa7-2623b0376205</nacos.namespace>-->
|
||||
<!-- <nacos.namespace></nacos.namespace>-->
|
||||
<nacos.namespace>fd74182b-1fce-4dba-afa7-2623b0376205</nacos.namespace>
|
||||
<!-- <nacos.namespace>ba3ba5d1-3480-4755-8b87-6b1fce16201c</nacos.namespace>-->
|
||||
<!-- <nacos.namespace>f6df4a49-39cb-4355-a8fd-8aeb0c537eb1</nacos.namespace>-->
|
||||
<!-- <nacos.namespace>02bcd264-c473-4bc1-b225-5fc4b937e32e</nacos.namespace>-->
|
||||
<!--sentinel:port-->
|
||||
<!-- <sentinel.url>192.168.1.14:8080</sentinel.url>-->
|
||||
<sentinel.url>${middle.server.url}:8080</sentinel.url>
|
||||
@@ -86,7 +88,6 @@
|
||||
<mybatis.version>2.1.3</mybatis.version>
|
||||
<druid.version>1.2.5</druid.version>
|
||||
<mysql.version>8.0.19</mysql.version>
|
||||
<mariadb.version>2.4.0</mariadb.version>
|
||||
<oracle.version>21.6.0.0</oracle.version>
|
||||
<orai18n.version>21.1.0.0</orai18n.version>
|
||||
<mybatis-plus.version>3.4.2</mybatis-plus.version>
|
||||
@@ -111,10 +112,8 @@
|
||||
<xxl-job.version>2.3.0</xxl-job.version>
|
||||
<mqtt.version>1.2.7</mqtt.version>
|
||||
<easypoi.version>4.4.0</easypoi.version>
|
||||
<progressbar.version>0.5.3</progressbar.version>
|
||||
<okhttp.version>4.8.1</okhttp.version>
|
||||
<minio.version>8.2.1</minio.version>
|
||||
<spring-cloud-huawei.version>1.7.0-Hoxton</spring-cloud-huawei.version>
|
||||
<okhttp.version>4.8.1</okhttp.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
@@ -341,29 +340,11 @@
|
||||
<artifactId>easypoi-spring-boot-starter</artifactId>
|
||||
<version>${easypoi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--调用minio服务器-->
|
||||
<dependency>
|
||||
<groupId>me.tongfei</groupId>
|
||||
<artifactId>progressbar</artifactId>
|
||||
<version>${progressbar.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>${okhttp.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>${minio.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- 多数据源切换,当数据源为oracle时需要使用 -->
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
|
||||
@@ -36,4 +36,13 @@ public class GeneralInfo {
|
||||
@Value("${business.tempPath}")
|
||||
private String businessTempPath;
|
||||
|
||||
/***
|
||||
* 文件存储方式
|
||||
* 1:本地磁盘
|
||||
* 2:华为obs
|
||||
* 3: minioss
|
||||
*/
|
||||
@Value("${business.file.storage}")
|
||||
private int businessFileStorage;
|
||||
|
||||
}
|
||||
|
||||
@@ -91,6 +91,7 @@ public enum CommonResponseEnum {
|
||||
ID_NOT_EXIST("A0100", "id不存在"),
|
||||
|
||||
TIME_ERROR("A0101","时间格式有误"),
|
||||
CLOSE_RESOURCE_ERROR("A0102","关闭资源有误"),
|
||||
|
||||
|
||||
;
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
<?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>pqs-common</artifactId>
|
||||
<groupId>com.njcn</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>common-minio</artifactId>
|
||||
<name>minioss的公共信息</name>
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-web</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.tongfei</groupId>
|
||||
<artifactId>progressbar</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.njcn.minio.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年10月16日 18:40
|
||||
*/
|
||||
@Data
|
||||
public class MinIoUploadResDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 475040120689218785L;
|
||||
private String minFileName;
|
||||
private String minFileUrl;
|
||||
|
||||
public MinIoUploadResDTO(String minFileName, String minFileUrl) {
|
||||
this.minFileName = minFileName;
|
||||
this.minFileUrl = minFileUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
package com.njcn.minio.bo;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年10月16日 18:41
|
||||
*/
|
||||
public class Result<T> implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6273326371984994386L;
|
||||
private Integer code;
|
||||
private String msg;
|
||||
private T data;
|
||||
|
||||
private Result() {
|
||||
this.code = 200;
|
||||
this.msg = "OK";
|
||||
}
|
||||
|
||||
private Result(T data) {
|
||||
this.code = 200;
|
||||
this.msg = "OK";
|
||||
this.setData(data);
|
||||
}
|
||||
|
||||
private Result(Integer code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
private Result(Integer code, String msg, T data) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Result<T> setError(Integer code, String msg) {
|
||||
this.setCode(code);
|
||||
this.setMsg(msg);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isSuccess() {
|
||||
return this.getCode().equals(200);
|
||||
}
|
||||
|
||||
public static Result ok() {
|
||||
return new Result();
|
||||
}
|
||||
|
||||
public static <T> Result ok(T data) {
|
||||
return new Result(data);
|
||||
}
|
||||
|
||||
public static <T> Result ok(Integer code, String msg) {
|
||||
return new Result(code, msg);
|
||||
}
|
||||
|
||||
public static <T> Result ok(Integer code, String msg, T data) {
|
||||
return new Result(code, msg, data);
|
||||
}
|
||||
|
||||
public static <T> Result error() {
|
||||
return new Result(500, "failed");
|
||||
}
|
||||
|
||||
public static <T> Result error(String msg) {
|
||||
return new Result(500, msg);
|
||||
}
|
||||
|
||||
public static <T> Result error(Integer code, String msg) {
|
||||
return new Result(code, msg);
|
||||
}
|
||||
|
||||
public static <T> Result error(Integer code, String msg, T data) {
|
||||
return new Result(code, msg, data);
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
public void setCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMsg() {
|
||||
return this.msg;
|
||||
}
|
||||
|
||||
public void setMsg(String msg) {
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public T getData() {
|
||||
return this.data;
|
||||
}
|
||||
|
||||
public void setData(T data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.njcn.minio.config;
|
||||
|
||||
import io.minio.MinioClient;
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年10月16日 18:37
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "min.io")
|
||||
public class MinIoProperties {
|
||||
|
||||
/**
|
||||
* Minio 服务端ip
|
||||
*/
|
||||
private String endpoint;
|
||||
|
||||
private String accessKey;
|
||||
|
||||
private String secretKey;
|
||||
|
||||
private String bucket;
|
||||
|
||||
@Bean
|
||||
public MinioClient getMinioClient() {
|
||||
return MinioClient.builder()
|
||||
.endpoint(endpoint).credentials(accessKey, secretKey).build();
|
||||
}
|
||||
}
|
||||
@@ -1,595 +0,0 @@
|
||||
package com.njcn.minio.utils;
|
||||
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import io.minio.*;
|
||||
import io.minio.Result;
|
||||
import io.minio.http.Method;
|
||||
import io.minio.messages.Bucket;
|
||||
import io.minio.messages.DeleteError;
|
||||
import io.minio.messages.DeleteObject;
|
||||
import io.minio.messages.Item;
|
||||
import lombok.SneakyThrows;
|
||||
import org.apache.tomcat.util.http.fileupload.IOUtils;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@Configuration
|
||||
@EnableConfigurationProperties({MinIoProperties.class})
|
||||
public class MinIoUtils {
|
||||
|
||||
@Resource
|
||||
private MinioClient instance;
|
||||
|
||||
private static final String SEPARATOR_DOT = ".";
|
||||
|
||||
private static final String SEPARATOR_ACROSS = "-";
|
||||
|
||||
private static final String SEPARATOR_STR = "";
|
||||
|
||||
// 存储桶名称
|
||||
private static final String chunkBucKet = "miniobucket";
|
||||
|
||||
/**
|
||||
* 不排序
|
||||
*/
|
||||
public final static boolean NOT_SORT = false;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
public final static boolean SORT = true;
|
||||
|
||||
/**
|
||||
* 默认过期时间(分钟)
|
||||
*/
|
||||
private final static Integer DEFAULT_EXPIRY = 60;
|
||||
|
||||
/**
|
||||
* 删除分片
|
||||
*/
|
||||
public final static boolean DELETE_CHUNK_OBJECT = true;
|
||||
/**
|
||||
* 不删除分片
|
||||
*/
|
||||
public final static boolean NOT_DELETE_CHUNK_OBJECT = false;
|
||||
|
||||
/**
|
||||
* 判断桶是否存在
|
||||
* @param bucketName 桶名
|
||||
* @return boolean
|
||||
* @author exe.wangtaotao
|
||||
* @date 2020/10/21 16:33
|
||||
*/
|
||||
public boolean bucketExists(String bucketName) {
|
||||
try {
|
||||
return instance.bucketExists(BucketExistsArgs.builder().bucket(bucketName).build());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建存储桶
|
||||
* 创建 bucket
|
||||
*
|
||||
* @param bucketName 桶名
|
||||
*/
|
||||
public void makeBucket(String bucketName) {
|
||||
try {
|
||||
boolean isExist = bucketExists(bucketName);
|
||||
if (!isExist) {
|
||||
instance.makeBucket(MakeBucketArgs.builder().bucket(bucketName).build());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return java.util.List<java.lang.String>
|
||||
* @Description 获取文件存储服务的所有存储桶名称
|
||||
* @author exe.wangtaotao
|
||||
* @date 2020/10/21 16:35
|
||||
*/
|
||||
public List<String> listBucketNames() {
|
||||
List<Bucket> bucketList = listBuckets();
|
||||
List<String> bucketListName = new ArrayList<>();
|
||||
for (Bucket bucket : bucketList) {
|
||||
bucketListName.add(bucket.name());
|
||||
}
|
||||
return bucketListName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return java.util.List<io.minio.messages.Bucket>
|
||||
* @Description 列出所有存储桶
|
||||
*/
|
||||
@SneakyThrows
|
||||
private List<Bucket> listBuckets() {
|
||||
return instance.listBuckets();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取对象文件名称列表
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param prefix 对象名称前缀(文件夹 /xx/xx/xxx.jpg 中的 /xx/xx/)
|
||||
* @return objectNames
|
||||
*/
|
||||
public List<String> listObjectNames(String bucketName, String prefix) {
|
||||
return listObjectNames(bucketName, prefix, NOT_SORT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取对象文件名称列表
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param prefix 对象名称前缀(文件夹 /xx/xx/xxx.jpg 中的 /xx/xx/)
|
||||
* @param sort 是否排序(升序)
|
||||
* @return objectNames
|
||||
*/
|
||||
@SneakyThrows
|
||||
public List<String> listObjectNames(String bucketName, String prefix, Boolean sort) {
|
||||
boolean flag = bucketExists(bucketName);
|
||||
if (flag) {
|
||||
ListObjectsArgs listObjectsArgs;
|
||||
if (null == prefix) {
|
||||
listObjectsArgs = ListObjectsArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.recursive(true)
|
||||
.build();
|
||||
} else {
|
||||
listObjectsArgs = ListObjectsArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.prefix(prefix)
|
||||
.recursive(true)
|
||||
.build();
|
||||
}
|
||||
Iterable<Result<Item>> chunks = instance.listObjects(listObjectsArgs);
|
||||
List<String> chunkPaths = new ArrayList<>();
|
||||
for (Result<Item> item : chunks) {
|
||||
chunkPaths.add(item.get().objectName());
|
||||
}
|
||||
if (sort) {
|
||||
chunkPaths.sort(new Str2IntComparator(false));
|
||||
}
|
||||
return chunkPaths;
|
||||
}
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* 在桶下创建文件夹,文件夹层级结构根据参数决定
|
||||
*
|
||||
* @param bucket 桶名称
|
||||
* @param WotDir 格式为 xxx/xxx/xxx/
|
||||
*/
|
||||
@SneakyThrows
|
||||
public String createDirectory(String bucket, String WotDir) {
|
||||
if (!this.bucketExists(bucket)) {
|
||||
return null;
|
||||
}
|
||||
instance.putObject(PutObjectArgs.builder().bucket(bucket).object(WotDir).stream(
|
||||
new ByteArrayInputStream(new byte[]{}), 0, -1)
|
||||
.build());
|
||||
return WotDir;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除一个文件
|
||||
*
|
||||
* @param bucketName 桶名称
|
||||
* @param objectName /xx/xx/xxx.jpg
|
||||
*/
|
||||
@SneakyThrows
|
||||
public boolean removeObject(String bucketName, String objectName) {
|
||||
|
||||
if (!bucketExists(bucketName)) {
|
||||
return false;
|
||||
}
|
||||
instance.removeObject(
|
||||
RemoveObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
.build());
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bucketName 桶名称
|
||||
* @param objectNames /xx/xx/xxx.jpg
|
||||
* @return java.util.List<java.lang.String>
|
||||
* @Description 删除指定桶的多个文件对象, 返回删除错误的对象列表,全部删除成功,返回空列表
|
||||
* @author exe.wangtaotao
|
||||
* @date 2020/10/21 16:43
|
||||
*/
|
||||
@SneakyThrows
|
||||
public List<String> removeObjects(String bucketName, List<String> objectNames) {
|
||||
if (!bucketExists(bucketName)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<DeleteObject> deleteObjects = new ArrayList<>(objectNames.size());
|
||||
for (String objectName : objectNames) {
|
||||
deleteObjects.add(new DeleteObject(objectName));
|
||||
}
|
||||
List<String> deleteErrorNames = new ArrayList<>();
|
||||
Iterable<Result<DeleteError>> results = instance.removeObjects(
|
||||
RemoveObjectsArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.objects(deleteObjects)
|
||||
.build());
|
||||
for (Result<DeleteError> result : results) {
|
||||
DeleteError error = result.get();
|
||||
deleteErrorNames.add(error.objectName());
|
||||
}
|
||||
return deleteErrorNames;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取访问对象的外链地址
|
||||
* 获取文件的下载url
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 对象名称
|
||||
* @param expiry 过期时间(分钟) 最大为7天 超过7天则默认最大值
|
||||
* @return viewUrl
|
||||
*/
|
||||
@SneakyThrows
|
||||
public String getObjectUrl(String bucketName, String objectName, Integer expiry) {
|
||||
expiry = expiryHandle(expiry);
|
||||
return instance.getPresignedObjectUrl(
|
||||
GetPresignedObjectUrlArgs.builder()
|
||||
.method(Method.GET)
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
.expiry(expiry)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 创建上传文件对象的外链
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 欲上传文件对象的名称
|
||||
* @return uploadUrl
|
||||
*/
|
||||
public String createUploadUrl(String bucketName, String objectName) {
|
||||
return createUploadUrl(bucketName, objectName, DEFAULT_EXPIRY);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建上传文件对象的外链
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectName 欲上传文件对象的名称
|
||||
* @param expiry 过期时间(分钟) 最大为7天 超过7天则默认最大值
|
||||
* @return uploadUrl
|
||||
*/
|
||||
@SneakyThrows
|
||||
public String createUploadUrl(String bucketName, String objectName, Integer expiry) {
|
||||
expiry = expiryHandle(expiry);
|
||||
return instance.getPresignedObjectUrl(
|
||||
GetPresignedObjectUrlArgs.builder()
|
||||
.method(Method.PUT)
|
||||
.bucket(bucketName)
|
||||
.object(objectName)
|
||||
.expiry(expiry)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// /**
|
||||
// * 批量下载
|
||||
// *
|
||||
// * @param directory
|
||||
// * @return
|
||||
// */
|
||||
// @SneakyThrows
|
||||
// public List<String> downLoadMore(String bucket, String directory) {
|
||||
// Iterable<io.minio.Result<Item>> objs = instance.listObjects(ListObjectsArgs.builder().bucket(bucket).prefix(directory).useUrlEncodingType(false).build());
|
||||
// List<String> list = new ArrayList<>();
|
||||
// for (io.minio.Result<Item> result : objs) {
|
||||
// String objectName = null;
|
||||
// objectName = result.get().objectName();
|
||||
// ObjectStat statObject = instance.statObject(StatObjectArgs.builder().bucket(bucket).object(objectName).build());
|
||||
// if (statObject != null && statObject.length() > 0) {
|
||||
// String fileurl = instance.getPresignedObjectUrl(GetPresignedObjectUrlArgs.builder().bucket(bucket).object(statObject.name()).method(Method.GET).build());
|
||||
// list.add(fileurl);
|
||||
// }
|
||||
// }
|
||||
// return list;
|
||||
// }
|
||||
//
|
||||
|
||||
/**
|
||||
* @param multipartFile 文件
|
||||
* @param bucketName 桶名
|
||||
* @param directory image/
|
||||
* @return java.lang.String
|
||||
* @Description 文件上传
|
||||
* @author exe.wangtaotao
|
||||
* @date 2020/10/21 13:45
|
||||
*/
|
||||
public MinIoUploadResDTO upload(MultipartFile multipartFile, String bucketName, String directory) throws Exception {
|
||||
if (!this.bucketExists(bucketName)) {
|
||||
this.makeBucket(bucketName);
|
||||
}
|
||||
InputStream inputStream = multipartFile.getInputStream();
|
||||
directory = Optional.ofNullable(directory).orElse("");
|
||||
String minFileName = directory + minFileName(multipartFile.getOriginalFilename());
|
||||
//上传文件到指定目录
|
||||
instance.putObject(PutObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(minFileName)
|
||||
.contentType(multipartFile.getContentType())
|
||||
.stream(inputStream, inputStream.available(), -1)
|
||||
.build());
|
||||
inputStream.close();
|
||||
// 返回生成文件名、访问路径
|
||||
return new MinIoUploadResDTO(minFileName, getObjectUrl(bucketName, minFileName, DEFAULT_EXPIRY));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param response
|
||||
* @return java.lang.String
|
||||
* @Description 下载文件
|
||||
* @author exe.wangtaotao
|
||||
* @date 2020/10/21 15:18
|
||||
*/
|
||||
public void download(HttpServletResponse response, String bucketName, String minFileName) throws Exception {
|
||||
InputStream fileInputStream = instance.getObject(GetObjectArgs.builder()
|
||||
.bucket(bucketName)
|
||||
.object(minFileName).build());
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + minFileName);
|
||||
response.setContentType("application/force-download");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
IOUtils.copy(fileInputStream, response.getOutputStream());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量创建分片上传外链
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectMD5 欲上传分片文件主文件的MD5
|
||||
* @param chunkCount 分片数量
|
||||
* @return uploadChunkUrls
|
||||
*/
|
||||
public List<String> createUploadChunkUrlList(String bucketName, String objectMD5, Integer chunkCount) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
}
|
||||
if (null == objectMD5) {
|
||||
return null;
|
||||
}
|
||||
objectMD5 += "/";
|
||||
if (null == chunkCount || 0 == chunkCount) {
|
||||
return null;
|
||||
}
|
||||
List<String> urlList = new ArrayList<>(chunkCount);
|
||||
for (int i = 1; i <= chunkCount; i++) {
|
||||
String objectName = objectMD5 + i + ".chunk";
|
||||
urlList.add(createUploadUrl(bucketName, objectName, DEFAULT_EXPIRY));
|
||||
}
|
||||
return urlList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建指定序号的分片文件上传外链
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param objectMD5 欲上传分片文件主文件的MD5
|
||||
* @param partNumber 分片序号
|
||||
* @return uploadChunkUrl
|
||||
*/
|
||||
public String createUploadChunkUrl(String bucketName, String objectMD5, Integer partNumber) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
}
|
||||
if (null == objectMD5) {
|
||||
return null;
|
||||
}
|
||||
objectMD5 += "/" + partNumber + ".chunk";
|
||||
return createUploadUrl(bucketName, objectMD5, DEFAULT_EXPIRY);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取分片文件名称列表
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param ObjectMd5 对象Md5
|
||||
* @return objectChunkNames
|
||||
*/
|
||||
public List<String> listChunkObjectNames(String bucketName, String ObjectMd5) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
}
|
||||
if (null == ObjectMd5) {
|
||||
return null;
|
||||
}
|
||||
return listObjectNames(bucketName, ObjectMd5, SORT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取分片名称地址HashMap key=分片序号 value=分片文件地址
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param ObjectMd5 对象Md5
|
||||
* @return objectChunkNameMap
|
||||
*/
|
||||
public Map<Integer, String> mapChunkObjectNames(String bucketName, String ObjectMd5) {
|
||||
if (null == bucketName) {
|
||||
bucketName = chunkBucKet;
|
||||
}
|
||||
if (null == ObjectMd5) {
|
||||
return null;
|
||||
}
|
||||
List<String> chunkPaths = listObjectNames(bucketName, ObjectMd5);
|
||||
if (null == chunkPaths || chunkPaths.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
Map<Integer, String> chunkMap = new HashMap<>(chunkPaths.size());
|
||||
for (String chunkName : chunkPaths) {
|
||||
Integer partNumber = Integer.parseInt(chunkName.substring(chunkName.indexOf("/") + 1, chunkName.lastIndexOf(".")));
|
||||
chunkMap.put(partNumber, chunkName);
|
||||
}
|
||||
return chunkMap;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 合并分片文件成对象文件
|
||||
*
|
||||
* @param chunkBucKetName 分片文件所在存储桶名称
|
||||
* @param composeBucketName 合并后的对象文件存储的存储桶名称
|
||||
* @param chunkNames 分片文件名称集合
|
||||
* @param objectName 合并后的对象文件名称
|
||||
* @return true/false
|
||||
*/
|
||||
@SneakyThrows
|
||||
public boolean composeObject(String chunkBucKetName, String composeBucketName, List<String> chunkNames, String objectName, boolean isDeleteChunkObject) {
|
||||
if (null == chunkBucKetName) {
|
||||
chunkBucKetName = chunkBucKet;
|
||||
}
|
||||
List<ComposeSource> sourceObjectList = new ArrayList<>(chunkNames.size());
|
||||
for (String chunk : chunkNames) {
|
||||
sourceObjectList.add(
|
||||
ComposeSource.builder()
|
||||
.bucket(chunkBucKetName)
|
||||
.object(chunk)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
instance.composeObject(
|
||||
ComposeObjectArgs.builder()
|
||||
.bucket(composeBucketName)
|
||||
.object(objectName)
|
||||
.sources(sourceObjectList)
|
||||
.build()
|
||||
);
|
||||
if (isDeleteChunkObject) {
|
||||
removeObjects(chunkBucKetName, chunkNames);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并分片文件成对象文件
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param chunkNames 分片文件名称集合
|
||||
* @param objectName 合并后的对象文件名称
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean composeObject(String bucketName, List<String> chunkNames, String objectName) {
|
||||
return composeObject(chunkBucKet, bucketName, chunkNames, objectName, NOT_DELETE_CHUNK_OBJECT);
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并分片文件成对象文件
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param chunkNames 分片文件名称集合
|
||||
* @param objectName 合并后的对象文件名称
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean composeObject(String bucketName, List<String> chunkNames, String objectName, boolean isDeleteChunkObject) {
|
||||
return composeObject(chunkBucKet, bucketName, chunkNames, objectName, isDeleteChunkObject);
|
||||
}
|
||||
|
||||
/**
|
||||
* 合并分片文件,合并成功后删除分片文件
|
||||
*
|
||||
* @param bucketName 存储桶名称
|
||||
* @param chunkNames 分片文件名称集合
|
||||
* @param objectName 合并后的对象文件名称
|
||||
* @return true/false
|
||||
*/
|
||||
public boolean composeObjectAndRemoveChunk(String bucketName, List<String> chunkNames, String objectName) {
|
||||
return composeObject(chunkBucKet, bucketName, chunkNames, objectName, DELETE_CHUNK_OBJECT);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param originalFileName 原始名称
|
||||
* @return java.lang.String
|
||||
* @Description 生成上传文件名
|
||||
* @author exe.wangtaotao
|
||||
* @date 2020/10/21 15:07
|
||||
*/
|
||||
private String minFileName(String originalFileName) {
|
||||
String suffix = originalFileName;
|
||||
if (originalFileName.contains(SEPARATOR_DOT)) {
|
||||
suffix = originalFileName.substring(originalFileName.lastIndexOf(SEPARATOR_DOT));
|
||||
}
|
||||
return UUID.randomUUID().toString().replace(SEPARATOR_ACROSS, SEPARATOR_STR).toUpperCase() + suffix;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 将分钟数转换为秒数
|
||||
*
|
||||
* @param expiry 过期时间(分钟数)
|
||||
* @return expiry
|
||||
*/
|
||||
private static int expiryHandle(Integer expiry) {
|
||||
expiry = expiry * 60;
|
||||
if (expiry > 604800) {
|
||||
return 604800;
|
||||
}
|
||||
return expiry;
|
||||
}
|
||||
|
||||
static class Str2IntComparator implements Comparator<String> {
|
||||
private final boolean reverseOrder; // 是否倒序
|
||||
|
||||
public Str2IntComparator(boolean reverseOrder) {
|
||||
this.reverseOrder = reverseOrder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compare(String arg0, String arg1) {
|
||||
Integer intArg0 = Integer.parseInt(arg0.substring(arg0.indexOf("/") + 1, arg0.lastIndexOf(".")));
|
||||
Integer intArg1 = Integer.parseInt(arg1.substring(arg1.indexOf("/") + 1, arg1.lastIndexOf(".")));
|
||||
if (reverseOrder) {
|
||||
return intArg1 - intArg0;
|
||||
} else {
|
||||
return intArg0 - intArg1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***
|
||||
* 根据url地址获取对象名称
|
||||
* @author hongawen
|
||||
* @date 2022/10/17 20:05
|
||||
* @param objectUrl 对象地址
|
||||
* @return String 对象名称
|
||||
*/
|
||||
public static String getObjectNameByUrl(String objectUrl) {
|
||||
if(objectUrl.indexOf("?") < 0){
|
||||
return "unknownFile";
|
||||
}
|
||||
String objectName = objectUrl.substring(0, objectUrl.indexOf("?"));
|
||||
return objectName.substring(objectName.lastIndexOf("/") + 1);
|
||||
}
|
||||
}
|
||||
37
pqs-common/common-oss/pom.xml
Normal file
37
pqs-common/common-oss/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>pqs-common</artifactId>
|
||||
<groupId>com.njcn</groupId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>common-oss</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<description>
|
||||
文件服务器处理模块
|
||||
</description>
|
||||
<dependencies>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>huawei-obs-springboot-starter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>minioss-springboot-starter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.oss.constant;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年03月06日 11:07
|
||||
*/
|
||||
public interface GeneralConstant {
|
||||
|
||||
/***
|
||||
* 文件存储的3种方式
|
||||
*/
|
||||
Integer LOCAL_DISK = 1;
|
||||
Integer HUAWEI_OBS = 2;
|
||||
Integer MINIO_OSS = 3;
|
||||
|
||||
/***
|
||||
* 波形文件的3种后缀
|
||||
*/
|
||||
String CFG =".CFG";
|
||||
String DAT =".DAT";
|
||||
String HDR =".HDR";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.oss.constant;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年03月03日 16:29
|
||||
*/
|
||||
public interface OssPath {
|
||||
|
||||
/***
|
||||
* 波形文件
|
||||
*/
|
||||
String WAVE_DIR="comtrade/";
|
||||
|
||||
/***
|
||||
* 稳态报表
|
||||
*/
|
||||
String HARMONIC_EXCEL_REPORT="harmonic/excel/report";
|
||||
|
||||
/***
|
||||
* 稳态报表模板
|
||||
*/
|
||||
String HARMONIC_EXCEL_TEMPLATE="harmonic/excel/template";
|
||||
|
||||
/***
|
||||
* 算法模块的上传路径
|
||||
*/
|
||||
String ALGORITHM="algorithm/";
|
||||
|
||||
/***
|
||||
* process模块中干扰源入网报告的上传路径
|
||||
*/
|
||||
String LOAD_TYPE_USER="loadTypeUser/";
|
||||
|
||||
/***
|
||||
* 技术监督管理 进度文件
|
||||
*/
|
||||
String ELECTRICITY_QUALITY = "electricityQuality/";
|
||||
|
||||
|
||||
/***
|
||||
* 技术监督管理 普测结果报告
|
||||
*/
|
||||
String SURVEY_RESULT = "surveyresult/";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.oss.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年03月07日 22:58
|
||||
*/
|
||||
@Getter
|
||||
public enum OssResponseEnum {
|
||||
/**
|
||||
* 文件服务器异常响应码的范围:
|
||||
* A00550 ~ A00649
|
||||
*/
|
||||
UPLOAD_FILE_ERROR("A00551","上传文件服务器错误,请检查数据"),
|
||||
DOWNLOAD_FILE_ERROR("A00554","下载文件URL不存在,请检查数据")
|
||||
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
OssResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
package com.njcn.oss.utils;
|
||||
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.huawei.obs.util.OBSUtil;
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minioss.config.MinIoProperties;
|
||||
import com.njcn.minioss.util.MinIoUtils;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2023年03月07日 22:24
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class FileStorageUtil {
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
/***
|
||||
* 华为文件服务器工具类
|
||||
* 若有方法需求或方法不满足,去私有仓库下载huawei-obs-springboot-starter模块进行二次开发
|
||||
* 开发完毕后需deploy到maven私有仓库
|
||||
*/
|
||||
private final OBSUtil obsUtil;
|
||||
|
||||
/***
|
||||
* 免费开源Minioss文件服务器工具类
|
||||
* 若有方法需求或方法不满足,去私有仓库下载minioss-springboot-starter模块进行二次开发
|
||||
* 开发完毕后需deploy到maven私有仓库
|
||||
*/
|
||||
private final MinIoUtils minIoUtils;
|
||||
|
||||
private final MinIoProperties minIoProperties;
|
||||
|
||||
|
||||
/***
|
||||
* 上传MultipartFile文件,
|
||||
* @author hongawen
|
||||
* @date 2023/3/7 22:48
|
||||
* @param multipartFile 文件源
|
||||
* @param dir 服务器文件存放路径
|
||||
*/
|
||||
public String uploadMultipart(MultipartFile multipartFile, String dir) {
|
||||
String filePath;
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
filePath = dir + minIoUtils.minFileName(multipartFile.getOriginalFilename());
|
||||
obsUtil.multiFileUpload(multipartFile, filePath);
|
||||
} else {
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO minIoUploadResDTO = minIoUtils.upload(multipartFile, minIoProperties.getBucket(), dir);
|
||||
filePath = minIoUploadResDTO.getMinFileName();
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(OssResponseEnum.UPLOAD_FILE_ERROR);
|
||||
}
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 根据文件路径获取文件短期的一个url
|
||||
* @author hongawen
|
||||
* @date 2023/3/7 23:04
|
||||
* @param filePath 文件在服务器的路径
|
||||
*/
|
||||
public String getFileUrl(String filePath){
|
||||
String url;
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
url = obsUtil.getFileUrl(filePath);
|
||||
} else {
|
||||
url = minIoUtils.getObjectUrl(minIoProperties.getBucket(), filePath, 7 * 24 * 60 * 60);
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 根据文件路径删除指定文件对象
|
||||
* @author hongawen
|
||||
* @date 2023/3/8 9:25
|
||||
* @param fileName 文件路径名
|
||||
*/
|
||||
public void deleteFile(String fileName){
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
obsUtil.delete(fileName);
|
||||
}else{
|
||||
minIoUtils.removeObject(minIoProperties.getBucket(), fileName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,8 +22,8 @@
|
||||
<module>common-influxdb</module>
|
||||
<module>common-poi</module>
|
||||
<module>common-echarts</module>
|
||||
<module>common-minio</module>
|
||||
<module>common-huawei</module>
|
||||
<module>common-oss</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.njcn.device.pms.controller.majornetwork;
|
||||
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.device.pms.service.majornetwork.TransientPmsService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
/**
|
||||
* 暂态事件列表(PMS暂用)
|
||||
* @author hongawen
|
||||
* @since 2022-10-14
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/pms/transientStasticData")
|
||||
@Api(tags = "暂态事件列表(PMS暂用)")
|
||||
@AllArgsConstructor
|
||||
public class TransientStasticDataController extends BaseController {
|
||||
|
||||
private final TransientPmsService transientPmsService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getTransientAnalyseWavePms")
|
||||
@ApiOperation("暂态事件波形分析")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "timeId", value = "暂态时刻", required = true),
|
||||
@ApiImplicitParam(name = "lineId", value = "暂态监测点Id", required = true),
|
||||
@ApiImplicitParam(name = "lineType", value = "暂态监测点类型(1主网 2配网)", required = true)
|
||||
})
|
||||
public HttpResult<WaveDataDTO> getTransientAnalyseWavePms(@RequestParam("timeId") String timeId, @RequestParam("lineId") String lineId, @RequestParam("lineType") Integer lineType){
|
||||
String methodDescribe = getMethodDescribe("getTransientAnalyseWavePms");
|
||||
WaveDataDTO wave = transientPmsService.getTransientAnalyseWavePms(timeId, lineId,lineType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.njcn.device.pms.service.majornetwork;
|
||||
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
|
||||
/**
|
||||
* TransientPmsService
|
||||
*
|
||||
* @author qijian
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/12/14 - 15:09
|
||||
*/
|
||||
public interface TransientPmsService {
|
||||
/**
|
||||
* 功能描述: 暂态事件波形分析
|
||||
* @param timeId
|
||||
* @param lineId
|
||||
* @param lineType
|
||||
* @return
|
||||
*/
|
||||
WaveDataDTO getTransientAnalyseWavePms(String timeId, String lineId, Integer lineType);
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
package com.njcn.device.pms.service.majornetwork.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.common.utils.wave.AnalyWave;
|
||||
import com.njcn.device.pms.api.DistributionMonitorClient;
|
||||
import com.njcn.device.pms.api.MonitorClient;
|
||||
import com.njcn.device.pms.mapper.majornetwork.DistributionMonitorMapper;
|
||||
import com.njcn.device.pms.mapper.majornetwork.MonitorMapper;
|
||||
import com.njcn.device.pms.mapper.majornetwork.TerminalMapper;
|
||||
import com.njcn.device.pms.pojo.po.DistributionMonitor;
|
||||
import com.njcn.device.pms.pojo.po.Monitor;
|
||||
import com.njcn.device.pms.pojo.po.PmsTerminal;
|
||||
import com.njcn.device.pms.service.majornetwork.EventDetailPmsService;
|
||||
import com.njcn.device.pms.service.majornetwork.IMonitorService;
|
||||
import com.njcn.device.pms.service.majornetwork.TransientPmsService;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.enums.DeviceResponseEnum;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.pojo.param.TransientParam;
|
||||
import com.njcn.event.pojo.param.WaveFileParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.vo.TransientVO;
|
||||
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @author: chenchao
|
||||
* @date: 2022/03/29 14:37
|
||||
* @Description: <描述>
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class TransientPmsServiceImpl implements TransientPmsService {
|
||||
|
||||
private final GeneralDeviceInfoClient generalDeviceInfoClient;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final EventDetailPmsService eventDetailPmsService;
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
private final DistributionMonitorMapper distributionMonitorMapper;
|
||||
|
||||
private final MonitorMapper monitorMapper;
|
||||
|
||||
private final TerminalMapper terminalMapper;
|
||||
|
||||
@Override
|
||||
public WaveDataDTO getTransientAnalyseWavePms(String timeId, String lineId,Integer lineType) {
|
||||
//初始化
|
||||
WaveDataDTO waveDataDTO;
|
||||
PmsTerminal pmsTerminal;
|
||||
DictData dictData;
|
||||
String ip = null;
|
||||
String ptTypeName = null;
|
||||
Float pt1 = null;
|
||||
Float pt2 = null;
|
||||
Float ct1 = null;
|
||||
Float ct2 = null;
|
||||
|
||||
//根据监测点id获取信息(1主网 2配网)
|
||||
if (lineType == 1){
|
||||
Monitor monitor = monitorMapper.selectById(lineId);
|
||||
//获取ip
|
||||
pmsTerminal = terminalMapper.selectById(monitor.getTerminalId());
|
||||
ip = pmsTerminal.getIp();
|
||||
//获取接线方式
|
||||
dictData = dicDataFeignClient.getDicDataById(monitor.getTerminalWiringMethod()).getData();
|
||||
ptTypeName = dictData.getName();
|
||||
//获取pt、ct
|
||||
pt1 = monitor.getPt1();
|
||||
pt2 = monitor.getPt1();
|
||||
ct1 = monitor.getCt1();
|
||||
ct2 = monitor.getCt2();
|
||||
}else{
|
||||
DistributionMonitor distributionMonitor = distributionMonitorMapper.selectById(lineId);
|
||||
//获取ip
|
||||
pmsTerminal = terminalMapper.selectById(distributionMonitor.getTerminalId());
|
||||
ip = pmsTerminal.getIp();
|
||||
//获取接线方式
|
||||
dictData = dicDataFeignClient.getDicDataById(distributionMonitor.getTerminalWiringMethod()).getData();
|
||||
ptTypeName = dictData.getName();
|
||||
//获取pt、ct
|
||||
pt1 = distributionMonitor.getPt1();
|
||||
pt2 = distributionMonitor.getPt1();
|
||||
ct1 = distributionMonitor.getCt1();
|
||||
ct2 = distributionMonitor.getCt2();
|
||||
}
|
||||
|
||||
EventDetail eventDetailByTime = eventDetailPmsService.getEventDetailByTime(lineId, timeId);
|
||||
String waveName = eventDetailByTime.getWaveName();
|
||||
|
||||
AnalyWave analyWave = new AnalyWave();
|
||||
WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
||||
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||
}
|
||||
waveDataDTO = analyWave.getValidData(comtrade);
|
||||
waveDataDTO.setPtType(PubUtils.ptTypeName(ptTypeName));
|
||||
waveDataDTO.setPt((double) (pt1 / pt2));
|
||||
waveDataDTO.setCt((double) (ct1 / ct2));
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -17,6 +17,9 @@ public enum EventResponseEnum {
|
||||
EVENT_COMMON_ERROR("A00650","暂降模块异常"),
|
||||
EVENT_NOT_FOUND("A00651","暂降事件或监测点不存在"),
|
||||
ANALYSEWAVE_NOT_FOUND("A00652","波形文件找不到"),
|
||||
WAVE_DATA_INVALID("A00654","波形文件数据缺失"),
|
||||
DAT_DATA_ERROR("A00653","dat文件数据读取失败"),
|
||||
RMS_DATA_ERROR("A00653","rms数据读取失败"),
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -41,6 +40,11 @@ public class ComtradeCfgDTO implements Serializable {
|
||||
// 最终采样率,计算的时候只用一个采样率
|
||||
private Long finalSampleRate;
|
||||
// 整个波形大小
|
||||
private Long nAllWaveNum = 0l;
|
||||
private Long nAllWaveNum = 0L;
|
||||
|
||||
/***
|
||||
* 赋值编码格式(二进制)
|
||||
*/
|
||||
private String strBinType;
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author yxb
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.njcn.common.pojo.dto.wave;
|
||||
package com.njcn.event.pojo.dto.wave;
|
||||
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.njcn.event.pojo.po;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @version 1.0.0
|
||||
* @author: chenchao
|
||||
* @date: 2022/06/28 19:41
|
||||
*/
|
||||
@Data
|
||||
@Component
|
||||
public class WavePath {
|
||||
|
||||
|
||||
@Value("${business.wavePath}")
|
||||
private String wavePath;
|
||||
|
||||
|
||||
}
|
||||
@@ -72,6 +72,18 @@
|
||||
<artifactId>pq-device-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okio</groupId>
|
||||
<artifactId>okio</artifactId>
|
||||
<version>2.8.0</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.njcn.event.controller.majornetwork;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
@@ -202,24 +201,6 @@ public class MonitorPointController extends BaseController {
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*监测点事件波形分析
|
||||
* @author zbj
|
||||
* @date 2022/7/27
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getMonitorEventAnalyseWave")
|
||||
@ApiOperation("监测点事件波形分析")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "timeId", value = "时间Id", required = true),
|
||||
@ApiImplicitParam(name = "lineId", value = "监测点Id", required = true)
|
||||
})
|
||||
public HttpResult<WaveDataDTO> getMonitorEventAnalyseWave(@RequestParam("timeId") String timeId, @RequestParam("lineId") String lineId){
|
||||
String methodDescribe = getMethodDescribe("getMonitorEventAnalyseWave");
|
||||
WaveDataDTO wave = eventAnalysisService.getMonitorEventAnalyseWave(timeId, lineId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, wave, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
*监测点事件波形下载
|
||||
* @author zbj
|
||||
|
||||
@@ -3,11 +3,11 @@ package com.njcn.event.controller.majornetwork;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.pojo.param.TransientParam;
|
||||
import com.njcn.event.pojo.param.WaveFileParam;
|
||||
import com.njcn.event.pojo.po.EventDetailNew;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.vo.*;
|
||||
@@ -82,12 +82,7 @@ public interface EventAnalysisService {
|
||||
*/
|
||||
Page<WaveTypeVO> getMonitorEventAnalyseQuery(EventBaseParam eventBaseParam);
|
||||
|
||||
/**
|
||||
*监测点事件波形分析
|
||||
* @author zbj
|
||||
* @date 2022/7/27
|
||||
*/
|
||||
WaveDataDTO getMonitorEventAnalyseWave(String timeId, String lineId);
|
||||
|
||||
|
||||
/**
|
||||
*监测点事件波形下载
|
||||
|
||||
@@ -4,16 +4,15 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.common.utils.wave.AnalyWave;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.pojo.constant.Param;
|
||||
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.pojo.param.*;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
import com.njcn.event.pojo.po.EventDetailNew;
|
||||
@@ -1627,55 +1626,6 @@ public class EventAnalysisServiceImpl implements EventAnalysisService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 监测点事件波形分析
|
||||
*
|
||||
* @author zbj
|
||||
* @date 2022/7/27
|
||||
*/
|
||||
@Override
|
||||
public WaveDataDTO getMonitorEventAnalyseWave(String timeId, String lineId) {
|
||||
WaveDataDTO waveDataDTO = new WaveDataDTO();
|
||||
//根据监测点id获取监测点详情
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId).getData();
|
||||
EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId, timeId);
|
||||
|
||||
//暂时没有进行拼接
|
||||
String ip = lineDetailData.getIp();
|
||||
String waveName = eventDetailByTime.getWaveName();
|
||||
/* if(StrUtil.isBlank(waveName)){
|
||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||
}*/
|
||||
|
||||
|
||||
AnalyWave analyWave = new AnalyWave();
|
||||
|
||||
|
||||
/*WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
||||
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||
}*/
|
||||
|
||||
|
||||
//测试用的本地路径
|
||||
WaveDataDTO comtrade = analyWave.getComtrade("C:\\Users\\CDF\\Desktop\\00-B7-8D-00-E7-15\\1_20220204_125513_383.cfg", 1);
|
||||
|
||||
|
||||
waveDataDTO = analyWave.getValidData(comtrade);
|
||||
|
||||
|
||||
waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
|
||||
double pt1 = Double.parseDouble(lineDetailData.getPt().split("/")[0]);
|
||||
double pt2 = Double.parseDouble(lineDetailData.getPt().split("/")[1]);
|
||||
double ct1 = Double.parseDouble(lineDetailData.getCt().split("/")[0]);
|
||||
double ct2 = Double.parseDouble(lineDetailData.getCt().split("/")[1]);
|
||||
|
||||
waveDataDTO.setPt(pt1 / pt2);
|
||||
waveDataDTO.setCt(ct1 / ct2);
|
||||
|
||||
|
||||
return waveDataDTO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,11 +5,11 @@ import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.common.pojo.enums.common.ServerEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.common.utils.wave.AnalyWave;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.device.pq.api.GeneralDeviceInfoClient;
|
||||
import com.njcn.device.pq.api.LineFeignClient;
|
||||
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
||||
@@ -17,6 +17,7 @@ import com.njcn.device.pq.pojo.vo.AreaLineInfoVO;
|
||||
import com.njcn.device.pq.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.mapper.majornetwork.TransientMapper;
|
||||
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.pojo.param.TransientParam;
|
||||
import com.njcn.event.pojo.param.WaveFileParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
@@ -24,6 +25,8 @@ import com.njcn.event.pojo.po.EventDetailNew;
|
||||
import com.njcn.event.pojo.vo.TransientVO;
|
||||
import com.njcn.event.service.majornetwork.EventDetailService;
|
||||
import com.njcn.event.service.majornetwork.TransientService;
|
||||
import com.njcn.event.utils.WaveUtil;
|
||||
import com.njcn.huawei.obs.util.OBSUtil;
|
||||
import com.njcn.influxdb.mapper.InfluxDBResultMapperCn;
|
||||
import com.njcn.influxdb.param.InfluxDBPublicParam;
|
||||
import com.njcn.influxdb.utils.InfluxDBCommUtils;
|
||||
@@ -45,7 +48,6 @@ import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -75,6 +77,11 @@ public class TransientServiceImpl implements TransientService {
|
||||
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
|
||||
private final OBSUtil obsUtil;
|
||||
|
||||
private final WaveUtil waveUtil;
|
||||
|
||||
|
||||
@Override
|
||||
public Page<TransientVO> getTransientData(TransientParam transientParam) {
|
||||
Page<TransientVO> page = new Page<>();
|
||||
@@ -168,32 +175,45 @@ public class TransientServiceImpl implements TransientService {
|
||||
@Override
|
||||
public WaveDataDTO getTransientAnalyseWave(String timeId, String lineId) {
|
||||
WaveDataDTO waveDataDTO;
|
||||
//原始数据
|
||||
WaveDataDTO originalData;
|
||||
//根据监测点id获取监测点详情
|
||||
LineDetailDataVO lineDetailData = lineFeignClient.getLineDetailData(lineId).getData();
|
||||
EventDetail eventDetailByTime = eventDetailService.getEventDetailByTime(lineId, timeId);
|
||||
String ip = lineDetailData.getIp();
|
||||
String waveName = eventDetailByTime.getWaveName();
|
||||
// TransientVO transientVO = transientMapper.getTransientDataById(lineId);
|
||||
// String name = transientVO.getName();
|
||||
// String substation = transientVO.getSubstation();
|
||||
// Double eventValue = new BigDecimal(eventDetailByTime.getEventValue()).setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
// Double v = new BigDecimal(eventValue*100).setScale(0,BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
// Double persistTime = eventDetailByTime.getPersistTime()/1000;
|
||||
|
||||
// waveDataVO.setName("变电站名称: "+ substation +" 监测点名称: "+ name +" 发生时刻: "+ timeId +" 暂降幅值: "+ v +"% 持续时间: "+ persistTime +"s");
|
||||
// waveDataVO.setTargetName("相电压有效值");
|
||||
AnalyWave analyWave = new AnalyWave();
|
||||
// 从本地读取该事件的波形
|
||||
WaveDataDTO comtrade = analyWave.getComtrade(generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + ".CFG", 1);
|
||||
if (Objects.isNull(comtrade.getComtradeCfgDTO())) {
|
||||
String cfgPath, datPath;
|
||||
if (generalInfo.getBusinessFileStorage() == GeneralConstant.LOCAL_DISK) {
|
||||
cfgPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.CFG;
|
||||
datPath = generalInfo.getBusinessWavePath() + File.separator + ip + File.separator + waveName + GeneralConstant.DAT;
|
||||
InputStream cfgStream = waveUtil.getFileInputStreamByFilePath(cfgPath);
|
||||
InputStream datStream = waveUtil.getFileInputStreamByFilePath(datPath);
|
||||
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||
}
|
||||
waveDataDTO = analyWave.getValidData(comtrade);
|
||||
originalData = waveUtil.getComtrade(cfgStream, datStream, 1);
|
||||
// } else if (generalInfo.getBusinessFileStorage() == GeneralConstant.HUAWEI_OBS) {
|
||||
} else {
|
||||
cfgPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.CFG;
|
||||
datPath = OssPath.WAVE_DIR + ip + StrUtil.SLASH + waveName + GeneralConstant.DAT;
|
||||
try (
|
||||
InputStream cfgStream = obsUtil.fileDownload(cfgPath);
|
||||
InputStream datStream = obsUtil.fileDownload(datPath)
|
||||
) {
|
||||
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||
throw new BusinessException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND);
|
||||
}
|
||||
originalData = waveUtil.getComtrade(cfgStream, datStream, 1);
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException(EventResponseEnum.WAVE_DATA_INVALID);
|
||||
}
|
||||
}
|
||||
waveDataDTO = waveUtil.getValidData(originalData);
|
||||
waveDataDTO.setPtType(PubUtils.ptTypeName(lineDetailData.getPtType()));
|
||||
double pt1 = Double.parseDouble(lineDetailData.getPt().split("/")[0]);
|
||||
double pt2 = Double.parseDouble(lineDetailData.getPt().split("/")[1]);
|
||||
double ct1 = Double.parseDouble(lineDetailData.getCt().split("/")[0]);
|
||||
double ct2 = Double.parseDouble(lineDetailData.getCt().split("/")[1]);
|
||||
double pt1 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[0]);
|
||||
double pt2 = Double.parseDouble(lineDetailData.getPt().split(StrUtil.SLASH)[1]);
|
||||
double ct1 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[0]);
|
||||
double ct2 = Double.parseDouble(lineDetailData.getCt().split(StrUtil.SLASH)[1]);
|
||||
waveDataDTO.setPt(pt1 / pt2);
|
||||
waveDataDTO.setCt(ct1 / ct2);
|
||||
return waveDataDTO;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.event.service.majornetwork;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.pojo.param.TransientParam;
|
||||
import com.njcn.event.pojo.param.WaveFileParam;
|
||||
import com.njcn.event.pojo.po.EventDetail;
|
||||
|
||||
@@ -0,0 +1,81 @@
|
||||
package com.njcn.event.utils;
|
||||
|
||||
public class BitConverter {
|
||||
|
||||
/**
|
||||
* byte数组转换为无符号short整数
|
||||
* @param bytes byte数组
|
||||
* @param off 开始位置
|
||||
* @return short整数
|
||||
*/
|
||||
public static short byte2ToUnsignedShort(byte[] bytes, int off) {
|
||||
int low = bytes[off]& 0xFF;
|
||||
int high = bytes[off + 1]& 0xFF;
|
||||
return (short)(((high & 0x00FF) << 8) | (0x00FF & low));
|
||||
}
|
||||
|
||||
/**
|
||||
* 字节转换为浮点
|
||||
*
|
||||
* @param b 字节(至少4个字节)
|
||||
* @param index 开始位置
|
||||
* @return
|
||||
*/
|
||||
public static float byte4float(byte[] b, int index) {
|
||||
/* b=new byte[4];
|
||||
b[0]=-16;
|
||||
b[1]=-1;
|
||||
b[2]=117;
|
||||
b[3]=66;*/
|
||||
|
||||
int l;
|
||||
l = b[index + 0];
|
||||
l &= 0xff;
|
||||
l |= ((long) b[index + 1] << 8);
|
||||
l &= 0xffff;
|
||||
l |= ((long) b[index + 2] << 16);
|
||||
l &= 0xffffff;
|
||||
l |= ((long) b[index + 3] << 24);
|
||||
return Float.intBitsToFloat(l);
|
||||
}
|
||||
/**
|
||||
* byte数组转换为int32整数
|
||||
* @param bytes byte数组
|
||||
* @param off 开始位置
|
||||
* @return int整数
|
||||
*/
|
||||
public static int byte4ToInt(byte[] bytes, int off) {
|
||||
int b0 = bytes[off] & 0xFF;
|
||||
int b1 = bytes[off + 1] & 0xFF;
|
||||
int b2 = bytes[off + 2] & 0xFF;
|
||||
int b3 = bytes[off + 3] & 0xFF;
|
||||
return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
|
||||
}
|
||||
|
||||
/**
|
||||
* byte数组转换为int16整数
|
||||
* @param bytes byte数组
|
||||
* @param off 开始位置
|
||||
* @return int整数
|
||||
*/
|
||||
public static int byte2ToInt(byte[] bytes, int off) {
|
||||
int b0 = bytes[off] & 0xFF;
|
||||
int b1 = bytes[off + 1] & 0xFF;
|
||||
return (b1 << 8) | b0;
|
||||
}
|
||||
|
||||
/**
|
||||
* byte数组转换为int16整数
|
||||
* @param bytes byte数组
|
||||
* @param off 开始位置
|
||||
* @return int整数
|
||||
*/
|
||||
public static long byte4ToLong(byte[] bytes, int off) {
|
||||
long b0 = bytes[off] & 0xFF;
|
||||
long b1 = bytes[off + 1] & 0xFF;
|
||||
long b2 = bytes[off + 2] & 0xFF;
|
||||
long b3 = bytes[off + 3] & 0xFF;
|
||||
|
||||
return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -44,3 +44,4 @@ mybatis-plus:
|
||||
type-aliases-package: com.njcn.event.pojo
|
||||
mqtt:
|
||||
client-id: @artifactId@${random.value}
|
||||
|
||||
|
||||
@@ -1,10 +1,16 @@
|
||||
package com.njcn.event;
|
||||
|
||||
import com.njcn.event.enums.EventResponseEnum;
|
||||
import com.njcn.event.pojo.PqsEventDetail;
|
||||
import com.njcn.event.pojo.PqsOnlinerateAggregate;
|
||||
import com.njcn.event.pojo.PqsEventDetailCount;
|
||||
import com.njcn.event.pojo.dto.wave.EigenvalueDTO;
|
||||
import com.njcn.event.pojo.dto.wave.WaveDataDTO;
|
||||
import com.njcn.event.utils.WaveUtil;
|
||||
import com.njcn.huawei.obs.util.OBSUtil;
|
||||
import com.njcn.influxdb.config.InfluxDbConfig;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import org.influxdb.dto.QueryResult;
|
||||
import org.influxdb.impl.InfluxDBResultMapper;
|
||||
import org.influxdb.querybuilder.SelectQueryImpl;
|
||||
@@ -20,8 +26,11 @@ import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
import static com.njcn.influxdb.param.InfluxDBPublicParam.PQS_EVENT_DETAIL;
|
||||
@@ -40,6 +49,12 @@ public class EventBootApplicationTest {
|
||||
@Autowired
|
||||
private InfluxDbUtils influxDbUtils;
|
||||
|
||||
@Autowired
|
||||
private WaveUtil waveUtil;
|
||||
|
||||
@Autowired
|
||||
private OBSUtil obsUtil;
|
||||
|
||||
// TODO https://github.com/influxdata/influxdb-java/blob/master/QUERY_BUILDER.md
|
||||
|
||||
@Test
|
||||
@@ -120,4 +135,28 @@ public class EventBootApplicationTest {
|
||||
andNested.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testHuaweiOBS() throws FileNotFoundException {
|
||||
|
||||
String cfgPath = OssPath.WAVE_DIR+"192.168.1.190/PQMonitor_PQM1_002438_20210508_092859_938.CFG";
|
||||
String datPath = OssPath.WAVE_DIR+"192.168.1.190/PQMonitor_PQM1_002438_20210508_092859_938.DAT";
|
||||
|
||||
InputStream cfgStream =obsUtil.fileDownload(cfgPath);
|
||||
InputStream datStream =obsUtil.fileDownload(datPath);
|
||||
|
||||
if(Objects.isNull(cfgStream) || Objects.isNull(datStream)){
|
||||
throw new FileNotFoundException(EventResponseEnum.ANALYSEWAVE_NOT_FOUND.getMessage());
|
||||
}
|
||||
|
||||
// 获取瞬时波形 //获取原始波形值
|
||||
WaveDataDTO waveDataDTO = waveUtil.getComtrade(cfgStream,datStream, 1);
|
||||
|
||||
// 获取RMS波形
|
||||
WaveDataDTO waveDataDTO1 = waveUtil.getValidData(waveDataDTO);
|
||||
|
||||
// 获取特征值
|
||||
List<EigenvalueDTO> lstEigenvalueDTO = waveUtil.getEigenvalue(waveDataDTO, true);
|
||||
System.out.println(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -60,18 +60,9 @@
|
||||
<artifactId>event-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-minio</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--调用minio服务器-->
|
||||
<dependency>
|
||||
<groupId>me.tongfei</groupId>
|
||||
<artifactId>progressbar</artifactId>
|
||||
<version>0.5.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
@@ -97,6 +88,13 @@
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!--华为obs工具包-->
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package com.njcn.harmonic.controller.algorithm;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
|
||||
import com.njcn.harmonic.enums.HarmonicResponseEnum;
|
||||
import com.njcn.harmonic.pojo.param.RStatFileVO;
|
||||
import com.njcn.harmonic.pojo.po.RStatFile;
|
||||
import com.njcn.harmonic.pojo.vo.PwRStatOrgVO;
|
||||
import com.njcn.harmonic.service.algorithm.RStatFileService;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import com.njcn.minio.utils.MinIoUtils;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -25,7 +22,6 @@ import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
@@ -37,10 +33,10 @@ public class AlgorithmController extends BaseController {
|
||||
|
||||
private final RStatFileService rStatFileService;
|
||||
|
||||
@Resource
|
||||
private MinIoUtils minIoUtils;
|
||||
@Resource
|
||||
private MinIoProperties minIoProperties;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 算法保存
|
||||
@@ -79,16 +75,10 @@ public class AlgorithmController extends BaseController {
|
||||
*/
|
||||
@PostMapping("/common/upload")
|
||||
@ResponseBody
|
||||
public HttpResult<MinIoUploadResDTO> uploadFile(MultipartFile file)
|
||||
{
|
||||
try
|
||||
{
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), "algorithm/");
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, upload, null);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
public HttpResult<String> uploadFile(MultipartFile file) {
|
||||
try {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, fileStorageUtil.uploadMultipart(file,OssPath.ALGORITHM), null);
|
||||
} catch (Exception e) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.harmonic.service.impl;
|
||||
|
||||
import ch.qos.logback.core.rolling.helper.FileStoreUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -26,13 +27,11 @@ import com.njcn.harmonic.pojo.vo.ReportTemplateVO;
|
||||
import com.njcn.harmonic.pojo.vo.ReportTreeVO;
|
||||
import com.njcn.harmonic.pojo.vo.SysDeptTempVO;
|
||||
import com.njcn.harmonic.service.CustomReportService;
|
||||
import com.njcn.influxdb.config.InfluxDbConfig;
|
||||
import com.njcn.influxdb.param.InfluxDBSqlConstant;
|
||||
import com.njcn.influxdb.param.InfluxDBTableConstant;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import com.njcn.minio.utils.MinIoUtils;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.user.api.DeptFeignClient;
|
||||
import com.njcn.user.pojo.dto.DeptDTO;
|
||||
@@ -89,31 +88,22 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
@Resource
|
||||
private MinIoUtils minIoUtils;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
@Resource
|
||||
private MinIoProperties minIoProperties;
|
||||
|
||||
@Resource
|
||||
private InfluxDbConfig influxDbConfig;
|
||||
|
||||
@Override
|
||||
public boolean addCustomReportTemplate(ReportTemplateParam reportTemplateParam) {
|
||||
checkName(reportTemplateParam, false);
|
||||
|
||||
MultipartFile fileContent = reportTemplateParam.getFileContent();
|
||||
String fileName = fileContent.getName();
|
||||
//检验模板json数据规范
|
||||
try {
|
||||
String content = MultipartFileToString(reportTemplateParam.getFileContent());
|
||||
String content = MultipartFileToString(fileContent);
|
||||
new JSONArray(content);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
|
||||
}
|
||||
|
||||
//文件上传到Minio服务器,存入文件名
|
||||
MinIoUploadResDTO minIoUploadResDTO = contentToMinio(reportTemplateParam.getFileContent());
|
||||
reportTemplateParam.setContent(minIoUploadResDTO.getMinFileName());
|
||||
|
||||
reportTemplateParam.setContent(fileStorageUtil.uploadMultipart(fileContent, OssPath.HARMONIC_EXCEL_TEMPLATE));
|
||||
//新增模板表
|
||||
ExcelRptTemp excelRptTemp = new ExcelRptTemp();
|
||||
BeanUtils.copyProperties(reportTemplateParam, excelRptTemp);
|
||||
@@ -137,10 +127,10 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
@Override
|
||||
public boolean updateCustomReportTemplate(ReportTemplateParam.UpdateReportTemplateParam reportTemplateParam) {
|
||||
checkName(reportTemplateParam, true);
|
||||
|
||||
MultipartFile fileContent = reportTemplateParam.getFileContent();
|
||||
//检验模板json数据规范
|
||||
try {
|
||||
String content = MultipartFileToString(reportTemplateParam.getFileContent());
|
||||
String content = MultipartFileToString(fileContent);
|
||||
new JSONArray(content);
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_JSON);
|
||||
@@ -148,12 +138,8 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
|
||||
//删除之前的文件
|
||||
ExcelRptTemp excelRptTempOld = excelRptTempMapper.selectById(reportTemplateParam.getId());
|
||||
minIoUtils.removeObject(minIoProperties.getBucket(), excelRptTempOld.getContent());
|
||||
|
||||
//文件上传到Minio服务器,存入文件名
|
||||
MinIoUploadResDTO minIoUploadResDTO = contentToMinio(reportTemplateParam.getFileContent());
|
||||
reportTemplateParam.setContent(minIoUploadResDTO.getMinFileName());
|
||||
|
||||
fileStorageUtil.deleteFile(excelRptTempOld.getContent());
|
||||
reportTemplateParam.setContent(fileStorageUtil.uploadMultipart(fileContent, OssPath.HARMONIC_EXCEL_TEMPLATE));
|
||||
//修改模板数据
|
||||
ExcelRptTemp excelRptTemp = new ExcelRptTemp();
|
||||
BeanUtils.copyProperties(reportTemplateParam, excelRptTemp);
|
||||
@@ -194,7 +180,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
@Override
|
||||
public ExcelRptTemp getCustomReportTemplateById(String id) {
|
||||
ExcelRptTemp excelRptTemp = excelRptTempMapper.selectById(id);
|
||||
String contentUrl = minIoUtils.getObjectUrl(minIoProperties.getBucket(), excelRptTemp.getContent(), 7 * 24 * 60 * 60);
|
||||
String contentUrl = fileStorageUtil.getFileUrl(excelRptTemp.getContent());
|
||||
excelRptTemp.setContent(contentUrl);
|
||||
return excelRptTemp;
|
||||
}
|
||||
@@ -241,9 +227,9 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
List<ExcelRpt> excelRpts = excelRptMapper.selectList(lambdaQuery);
|
||||
String content;
|
||||
if (excelRpts.size() > 0) {
|
||||
content = minIoUtils.getObjectUrl(minIoProperties.getBucket(), excelRpts.get(0).getContent(), 7 * 24 * 60 * 60);
|
||||
content = fileStorageUtil.getFileUrl(excelRpts.get(0).getContent());
|
||||
} else {
|
||||
content = minIoUtils.getObjectUrl(minIoProperties.getBucket(), analyzeReport(reportSearchParam,excelRptTemp), 7 * 24 * 60 * 60);
|
||||
content = fileStorageUtil.getFileUrl(analyzeReport(reportSearchParam, excelRptTemp));
|
||||
}
|
||||
|
||||
//拼接数据
|
||||
@@ -370,7 +356,7 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
JSONArray jsonArray = null;
|
||||
try {
|
||||
//通过文件服务器获取
|
||||
String objectUrl = minIoUtils.getObjectUrl(minIoProperties.getBucket(), excelRptTemp.getContent(), 7 * 24 * 60 * 60);
|
||||
String objectUrl = fileStorageUtil.getFileUrl(excelRptTemp.getContent());
|
||||
jsonArray = JSONUtil.parseArray(urlToString(objectUrl));
|
||||
jsonArray.forEach(item -> {
|
||||
JSONObject jsonObject = (JSONObject) item;
|
||||
@@ -462,11 +448,9 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
});
|
||||
}
|
||||
|
||||
//文件上传到Minio服务器,存入文件名
|
||||
File newFile = stringToFile(jsonArray.toString());
|
||||
MultipartFile newMultipartFile = getMultipartFile(newFile);
|
||||
MinIoUploadResDTO minIoUploadResDTO = contentToMinio(newMultipartFile);
|
||||
String newContent = minIoUploadResDTO.getMinFileName();
|
||||
String newContent = fileStorageUtil.uploadMultipart(newMultipartFile, OssPath.HARMONIC_EXCEL_REPORT);
|
||||
|
||||
//存入报表库
|
||||
ExcelRpt excelRpt = new ExcelRpt();
|
||||
@@ -539,21 +523,6 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
endList.add(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到Minio
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 成功标记
|
||||
*/
|
||||
private MinIoUploadResDTO contentToMinio(MultipartFile file) {
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), "report/");
|
||||
return upload;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_FILE);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件Url 转 String
|
||||
@@ -584,7 +553,9 @@ public class CustomReportServiceImpl implements CustomReportService {
|
||||
String businessTempPath = generalInfo.getBusinessTempPath();
|
||||
File distFile = new File(businessTempPath + File.separator + "temp.json");
|
||||
try {
|
||||
if (!distFile.getParentFile().exists()) distFile.getParentFile().mkdirs();
|
||||
if (!distFile.getParentFile().exists()) {
|
||||
distFile.getParentFile().mkdirs();
|
||||
}
|
||||
bufferedReader = new BufferedReader(new StringReader(res));
|
||||
bufferedWriter = new BufferedWriter(new FileWriter(distFile));
|
||||
bufferedWriter.write("");
|
||||
|
||||
@@ -33,7 +33,7 @@ public class Test1 extends BaseJunitTest{
|
||||
|
||||
@Test
|
||||
public void testMethod(){
|
||||
InfluxDbUtils influxDBUtil = new InfluxDbUtils(influxDbConfig.getUserName(), influxDbConfig.getPassword(), influxDbConfig.getInfluxDBUrl(), influxDbConfig.getDatabase(), "");
|
||||
InfluxDbUtils influxDBUtil = new InfluxDbUtils(influxDbConfig.getUser(), influxDbConfig.getPassword(), influxDbConfig.getUrl(), influxDbConfig.getDatabase(), "");
|
||||
SelectQueryImpl selectQuery = select().from(influxDbConfig.getDatabase(),"data_flicker").where(eq("fluc",0)).limit(1).tz("Asia/Shanghai");
|
||||
WhereQueryImpl<SelectQueryImpl> where = selectQuery.where();
|
||||
QueryResult queryResult = influxDBUtil.query(selectQuery.getCommand());
|
||||
|
||||
@@ -112,16 +112,11 @@
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-minio</artifactId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--调用minio服务器-->
|
||||
<dependency>
|
||||
<groupId>me.tongfei</groupId>
|
||||
<artifactId>progressbar</artifactId>
|
||||
<version>0.5.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
@@ -129,17 +124,6 @@
|
||||
<version>4.8.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>io.minio</groupId>
|
||||
<artifactId>minio</artifactId>
|
||||
<version>8.2.1</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
|
||||
@@ -19,9 +19,9 @@ import com.njcn.harmonic.pojo.po.ExcelRptTemp;
|
||||
import com.njcn.influxdb.param.InfluxDBSqlConstant;
|
||||
import com.njcn.influxdb.param.InfluxDBTableConstant;
|
||||
import com.njcn.influxdb.utils.InfluxDbUtils;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import com.njcn.minio.utils.MinIoUtils;
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.prepare.harmonic.constant.AlgorithmParam;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.line.ExcelRptMapper;
|
||||
import com.njcn.prepare.harmonic.mapper.mysql.line.ExcelRptTempMapper;
|
||||
@@ -65,11 +65,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
|
||||
private final GeneralInfo generalInfo;
|
||||
|
||||
@Resource
|
||||
private MinIoUtils minIoUtils;
|
||||
|
||||
@Resource
|
||||
private MinIoProperties minIoProperties;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -100,7 +96,7 @@ public class ReportServiceImpl implements ReportService {
|
||||
for (ExcelRptTemp excelRptTemp : reportTemplateList) {
|
||||
try {
|
||||
//获取content解析数据
|
||||
String objectUrl = minIoUtils.getObjectUrl(minIoProperties.getBucket(), excelRptTemp.getContent(), 7 * 24 * 60 * 60);
|
||||
String objectUrl = fileStorageUtil.getFileUrl(excelRptTemp.getContent());
|
||||
jsonArray = JSONUtil.parseArray(urlToString(objectUrl));
|
||||
dataList = getDataList(jsonArray);
|
||||
} catch (Exception e) {
|
||||
@@ -144,13 +140,11 @@ public class ReportServiceImpl implements ReportService {
|
||||
//月:例如2022十月份,传入2022-10-01进行匹配,有则更新无则插入
|
||||
//周:例如2022年第五周,传入2022-01-23(周一)进行匹配,有则更新无则插入
|
||||
//日:直接插入,无需配对
|
||||
//文件上传到Minio服务器,存入文件名
|
||||
MinIoUploadResDTO minIoUploadResDTO = contentToMinio(jsonArray.toString());
|
||||
String afterContent = minIoUploadResDTO.getMinFileName();
|
||||
//文件上传到文件服务器,存入文件名
|
||||
if (BizParamConstant.STAT_BIZ_DAY.equals(reportParam.getType().toString())){
|
||||
rptInsert(reportParam, lineId, excelRptTemp, afterContent);
|
||||
rptInsert(reportParam, lineId, excelRptTemp, contentToOss(jsonArray.toString()));
|
||||
}else{
|
||||
rptBiz(reportParam, lineId, excelRptTemp, afterContent);
|
||||
rptBiz(reportParam, lineId, excelRptTemp, contentToOss(jsonArray.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -331,23 +325,17 @@ public class ReportServiceImpl implements ReportService {
|
||||
|
||||
|
||||
/**
|
||||
* 上传文件到Minio
|
||||
* 上传文件到Oss
|
||||
*
|
||||
* @param content 文件
|
||||
* @return 成功标记
|
||||
*/
|
||||
private MinIoUploadResDTO contentToMinio(String content) {
|
||||
private String contentToOss(String content) {
|
||||
//上传到minio
|
||||
String businessTempPath = generalInfo.getBusinessTempPath();
|
||||
File file = stringToFile(content, businessTempPath + File.separator + "a.json");
|
||||
File file = stringToFile(content, businessTempPath + File.separator + "temp.json");
|
||||
MultipartFile multiFile = getMultipartFile(file);
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO upload = minIoUtils.upload(multiFile, minIoProperties.getBucket(), "report/");
|
||||
return upload;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(HarmonicResponseEnum.CUSTOM_REPORT_FILE);
|
||||
}
|
||||
return fileStorageUtil.uploadMultipart(multiFile, OssPath.HARMONIC_EXCEL_REPORT);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,10 +16,8 @@ public enum ProcessResponseEnum {
|
||||
* A00550 ~ A00649
|
||||
*/
|
||||
PROCESS_COMMON_ERROR("A00550","监督管理模块异常"),
|
||||
UPLOAD_FILE_ERROR("A00551","上传文件服务器错误,请检查数据"),
|
||||
ARCHIVE_ERROR("A00552","不满足归档调节,操作失败!"),
|
||||
PROCESS_ERROR("A00553","当前流程未审核通过,操作失败!"),
|
||||
DOWNLOAD_FILE_ERROR("A00554","下载文件URL不存在,请检查数据"),
|
||||
|
||||
;
|
||||
|
||||
|
||||
@@ -67,18 +67,9 @@
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--调用minio服务器-->
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-minio</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>me.tongfei</groupId>
|
||||
<artifactId>progressbar</artifactId>
|
||||
<version>0.5.3</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
@@ -114,6 +105,12 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<!--华为obs工具包-->
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-oss</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.process.pojo.param.*;
|
||||
import com.njcn.process.pojo.vo.*;
|
||||
import com.njcn.process.service.IssuesService;
|
||||
@@ -185,11 +184,11 @@ public class ElectricityQualityIssuesController extends BaseController {
|
||||
@PostMapping("/uploadFile")
|
||||
@ApiOperation("上传文件")
|
||||
@ApiImplicitParam(name = "file", value = "填报进度文件", required = true)
|
||||
public HttpResult<MinIoUploadResDTO> uploadFile(@RequestParam("file") MultipartFile issuesFile){
|
||||
public HttpResult<String> uploadFile(@RequestParam("file") MultipartFile issuesFile){
|
||||
String methodDescribe = getMethodDescribe("uploadFile");
|
||||
MinIoUploadResDTO out = issuesService.uploadFile(issuesFile);
|
||||
out.setMinFileName(issuesFile.getOriginalFilename());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, out, methodDescribe);
|
||||
String filePath = issuesService.uploadFile(issuesFile);
|
||||
// out.setMinFileName(issuesFile.getOriginalFilename());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, filePath, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
|
||||
@@ -9,7 +9,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.poi.util.PoiUtil;
|
||||
import com.njcn.process.pojo.param.*;
|
||||
import com.njcn.process.pojo.po.RGeneralSurveyPlanPO;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.process.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.process.pojo.param.*;
|
||||
import com.njcn.process.pojo.vo.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -79,7 +78,7 @@ public interface IssuesService {
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
MinIoUploadResDTO uploadFile(MultipartFile issuesFile);
|
||||
String uploadFile(MultipartFile issuesFile);
|
||||
|
||||
/**
|
||||
* 下载文件
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.njcn.process.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.github.jeffreyning.mybatisplus.service.IMppService;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.process.pojo.param.*;
|
||||
import com.njcn.process.pojo.po.RGeneralSurveyPlanPO;
|
||||
import com.njcn.process.pojo.vo.SurveyPlanExcel;
|
||||
|
||||
@@ -13,9 +13,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.constant.BizParamConstant;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import com.njcn.minio.utils.MinIoUtils;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.process.enums.ProcessResponseEnum;
|
||||
import com.njcn.process.mapper.*;
|
||||
import com.njcn.process.pojo.param.*;
|
||||
@@ -45,6 +44,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 电能质量问题实现类
|
||||
*
|
||||
* @author xiaoyao
|
||||
* @version 1.0.0
|
||||
* @createTime 2022/11/14 11:03
|
||||
@@ -72,11 +72,7 @@ public class IssuesServiceImpl implements IssuesService {
|
||||
|
||||
private final RStatElectricQualityProblemLogMapper rStatElectricQualityProblemLogMapper;
|
||||
|
||||
@Resource
|
||||
private MinIoUtils minIoUtils;
|
||||
|
||||
@Resource
|
||||
private MinIoProperties minIoProperties;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
/**
|
||||
* 新增电能质量问题流程表信息
|
||||
@@ -484,12 +480,8 @@ public class IssuesServiceImpl implements IssuesService {
|
||||
* 上传文件
|
||||
*/
|
||||
@Override
|
||||
public MinIoUploadResDTO uploadFile(MultipartFile issuesFile) {
|
||||
try {
|
||||
return minIoUtils.upload(issuesFile, minIoProperties.getBucket(), "electricityQuality/");
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(ProcessResponseEnum.UPLOAD_FILE_ERROR);
|
||||
}
|
||||
public String uploadFile(MultipartFile issuesFile) {
|
||||
return fileStorageUtil.uploadMultipart(issuesFile, OssPath.ELECTRICITY_QUALITY);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -568,8 +560,6 @@ public class IssuesServiceImpl implements IssuesService {
|
||||
/*已关联工单数量*/
|
||||
|
||||
|
||||
|
||||
|
||||
return issueesAndOrderVO;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,13 +4,11 @@ import cn.hutool.core.date.DateUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.config.GeneralInfo;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.device.pms.api.DistributionMonitorClient;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import com.njcn.minio.utils.MinIoUtils;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.process.constant.Param;
|
||||
import com.njcn.process.enums.ProcessResponseEnum;
|
||||
import com.njcn.process.mapper.LoadTypeUserManageMapper;
|
||||
import com.njcn.process.pojo.param.*;
|
||||
import com.njcn.process.pojo.po.RLoadTypeUserManage;
|
||||
@@ -59,13 +57,15 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
private final DeptFeignClient deptFeignClient;
|
||||
|
||||
@Resource
|
||||
private MinIoUtils minIoUtils;
|
||||
private GeneralInfo generalInfo;
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
|
||||
@Resource
|
||||
private MinIoProperties minIoProperties;
|
||||
|
||||
/**
|
||||
* 干扰源用户分页查询
|
||||
*
|
||||
* @param loadTypeUserSearchParam
|
||||
* @return
|
||||
*/
|
||||
@@ -91,6 +91,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
/**
|
||||
* 根据id查询干扰源用户
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@@ -101,11 +102,11 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
BeanUtils.copyProperties(rLoadTypeUserManage, rLoadTypeUserManageVO);
|
||||
//文件
|
||||
if (rLoadTypeUserManageVO.getIFilePath() != null) {
|
||||
String iFile = minIoUtils.getObjectUrl(minIoProperties.getBucket(), rLoadTypeUserManageVO.getIFilePath(), 7 * 24 * 60 * 60);
|
||||
String iFile = fileStorageUtil.getFileUrl(rLoadTypeUserManageVO.getIFilePath());
|
||||
rLoadTypeUserManageVO.setIFile(iFile);
|
||||
}
|
||||
if (rLoadTypeUserManageVO.getAFilePath() != null) {
|
||||
String aFile = minIoUtils.getObjectUrl(minIoProperties.getBucket(), rLoadTypeUserManageVO.getAFilePath(), 7 * 24 * 60 * 60);
|
||||
String aFile = fileStorageUtil.getFileUrl(rLoadTypeUserManageVO.getAFilePath());
|
||||
rLoadTypeUserManageVO.setIFile(aFile);
|
||||
}
|
||||
return rLoadTypeUserManageVO;
|
||||
@@ -113,6 +114,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
/**
|
||||
* 新增干扰源用户
|
||||
*
|
||||
* @param loadTypeUserParam
|
||||
* @return
|
||||
*/
|
||||
@@ -131,6 +133,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
/**
|
||||
* 上传干扰源用户入网报告
|
||||
*
|
||||
* @param loadTypeUserIUploadParam
|
||||
* @return
|
||||
*/
|
||||
@@ -140,11 +143,10 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
RLoadTypeUserManage rLoadTypeUserManage = new RLoadTypeUserManage();
|
||||
BeanUtils.copyProperties(loadTypeUserIUploadParam, rLoadTypeUserManage);
|
||||
|
||||
MultipartFile multipartFile = loadTypeUserIUploadParam.getFile();
|
||||
//文件上传到Minio服务器,存入文件名
|
||||
if(loadTypeUserIUploadParam.getFile() != null){
|
||||
MinIoUploadResDTO minIoUploadResDTO = fileToMinio(loadTypeUserIUploadParam.getFile());
|
||||
rLoadTypeUserManage.setIFilePath(minIoUploadResDTO.getMinFileName());
|
||||
if (Objects.nonNull(multipartFile)) {
|
||||
rLoadTypeUserManage.setIFilePath(fileStorageUtil.uploadMultipart(multipartFile,OssPath.LOAD_TYPE_USER));
|
||||
rLoadTypeUserManage.setIUploadTime(new Date());
|
||||
}
|
||||
|
||||
@@ -164,6 +166,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
/**
|
||||
* 关联营销用户
|
||||
*
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@@ -179,6 +182,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
/**
|
||||
* 查询所有干扰源用户(与营销系统关联)
|
||||
*
|
||||
* @param loadTypeUserSearchParam
|
||||
* @return
|
||||
*/
|
||||
@@ -202,24 +206,11 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
return loadTypeUserPage.setRecords(resultList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到Minio
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 成功标记
|
||||
*/
|
||||
private MinIoUploadResDTO fileToMinio(MultipartFile file) {
|
||||
try {
|
||||
//把名称存入数据
|
||||
MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), "loadTypeUser/");
|
||||
return upload;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(ProcessResponseEnum.UPLOAD_FILE_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 上传干扰源用户入网报告
|
||||
*
|
||||
* @param loadTypeUserAUploadParam
|
||||
* @return
|
||||
*/
|
||||
@@ -229,11 +220,10 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
RLoadTypeUserManage rLoadTypeUserManage = new RLoadTypeUserManage();
|
||||
BeanUtils.copyProperties(loadTypeUserAUploadParam, rLoadTypeUserManage);
|
||||
|
||||
//文件上传到Minio服务器,存入文件名
|
||||
if(loadTypeUserAUploadParam.getFile() != null){
|
||||
MinIoUploadResDTO minIoUploadResDTO = fileToMinio(loadTypeUserAUploadParam.getFile());
|
||||
rLoadTypeUserManage.setAFilePath(minIoUploadResDTO.getMinFileName());
|
||||
MultipartFile multipartFile = loadTypeUserAUploadParam.getFile();
|
||||
//文件上传到文件服务器,存入文件名
|
||||
if (Objects.nonNull(multipartFile)) {
|
||||
rLoadTypeUserManage.setAFilePath(fileStorageUtil.uploadMultipart(multipartFile,OssPath.LOAD_TYPE_USER));
|
||||
rLoadTypeUserManage.setAUploadTime(new Date());
|
||||
}
|
||||
|
||||
@@ -252,6 +242,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
/**
|
||||
* 导出未建档干扰源用户管理信息
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
@@ -304,6 +295,7 @@ public class LoadTypeUserManageServiceImpl implements LoadTypeUserManageService
|
||||
|
||||
/**
|
||||
* 导出干扰源用户常态化管理信息
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
|
||||
@@ -7,10 +7,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.minio.bo.MinIoUploadResDTO;
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import com.njcn.minio.utils.MinIoUtils;
|
||||
import com.njcn.process.enums.ProcessResponseEnum;
|
||||
import com.njcn.minioss.bo.MinIoUploadResDTO;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.enums.OssResponseEnum;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.process.mapper.RGeneralSurveyPlanDetailMapper;
|
||||
import com.njcn.process.mapper.RGeneralSurveyPlanPOMapper;
|
||||
import com.njcn.process.pojo.param.*;
|
||||
@@ -38,7 +38,6 @@ import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* 接口文档访问地址:http://serverIP:port/swagger-ui.html
|
||||
* Date: 2022/11/11 11:24【需求编号】
|
||||
@@ -49,25 +48,22 @@ import java.util.stream.Stream;
|
||||
@Service
|
||||
public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurveyPlanPOMapper, RGeneralSurveyPlanPO> implements RGeneralSurveyPlanPOService {
|
||||
|
||||
|
||||
private @Autowired
|
||||
RGeneralSurveyPlanDetailService rGeneralSurveyPlanDetailService;
|
||||
|
||||
private @Autowired
|
||||
RGeneralSurveyPlanPOMapper rGeneralSurveyPlanPOMapper;
|
||||
|
||||
private @Autowired
|
||||
RGeneralSurveyPlanDetailMapper rGeneralSurveyPlanDetailMapper;
|
||||
@Autowired
|
||||
private RGeneralSurveyPlanDetailService rGeneralSurveyPlanDetailService;
|
||||
|
||||
@Resource
|
||||
private MinIoUtils minIoUtils;
|
||||
|
||||
private @Autowired
|
||||
DeptFeignClient deptFeignClient;
|
||||
|
||||
private RGeneralSurveyPlanPOMapper rGeneralSurveyPlanPOMapper;
|
||||
|
||||
@Resource
|
||||
private MinIoProperties minIoProperties;
|
||||
private RGeneralSurveyPlanDetailMapper rGeneralSurveyPlanDetailMapper;
|
||||
|
||||
@Autowired
|
||||
private DeptFeignClient deptFeignClient;
|
||||
|
||||
@Resource
|
||||
private FileStorageUtil fileStorageUtil;
|
||||
|
||||
|
||||
/**
|
||||
* @param rGeneralSurveyPlanAddParm
|
||||
* @Description: addPlan
|
||||
@@ -208,9 +204,9 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
|
||||
fileCount = Optional.ofNullable(fileCount).orElse(0);
|
||||
for (int i = 0; i < surveyResultUploadParam.getFile().length; i++) {
|
||||
String OriginalFilename = surveyResultUploadParam.getFile()[i].getOriginalFilename();
|
||||
MinIoUploadResDTO minIoUploadResDTO = fileToMinio(surveyResultUploadParam.getFile ( )[i]);
|
||||
String fileStoragePath = fileStorageUtil.uploadMultipart(surveyResultUploadParam.getFile()[i], OssPath.SURVEY_RESULT);
|
||||
/*filePath格式:minIo服务文件名+##+原始文件名+;*/
|
||||
filePath=filePath+minIoUploadResDTO.getMinFileName ()+"##"+OriginalFilename+";";
|
||||
filePath = filePath + fileStoragePath + "##" + OriginalFilename + ";";
|
||||
fileCount++;
|
||||
}
|
||||
rGeneralSurveyPlanPO.setStatus(4);
|
||||
@@ -237,14 +233,14 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
|
||||
rGeneralSurveyPlanPO = this.selectByMultiId(rGeneralSurveyPlanPO);
|
||||
String filePath = rGeneralSurveyPlanPO.getFilePath();
|
||||
if (StringUtils.isEmpty(filePath)) {
|
||||
throw new BusinessException(ProcessResponseEnum.DOWNLOAD_FILE_ERROR);
|
||||
throw new BusinessException(OssResponseEnum.DOWNLOAD_FILE_ERROR);
|
||||
}
|
||||
String[] split = filePath.substring(0, filePath.length() - 1).split(";");
|
||||
List<MinIoUploadResDTO> collect = Stream.of(split).map(temp -> {
|
||||
String[] split1 = temp.split("##");
|
||||
String OriginalFilename = split1[1];
|
||||
String minoFileName = split1[0];
|
||||
MinIoUploadResDTO dto = new MinIoUploadResDTO(OriginalFilename,minIoUtils.getObjectUrl (minIoProperties.getBucket ( ), minoFileName, 7 * 24 * 60 * 60));
|
||||
MinIoUploadResDTO dto = new MinIoUploadResDTO(OriginalFilename, fileStorageUtil.getFileUrl(minoFileName));
|
||||
return dto;
|
||||
}).collect(Collectors.toList());
|
||||
return collect;
|
||||
@@ -353,18 +349,4 @@ public class RGeneralSurveyPlanPOServiceImpl extends MppServiceImpl<RGeneralSurv
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传文件到Minio
|
||||
*
|
||||
* @param file 文件
|
||||
* @return 成功标记
|
||||
*/
|
||||
private MinIoUploadResDTO fileToMinio(MultipartFile file) {
|
||||
try {
|
||||
MinIoUploadResDTO upload = minIoUtils.upload(file, minIoProperties.getBucket(), "surveyresult/");
|
||||
return upload;
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException (ProcessResponseEnum.UPLOAD_FILE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,11 +44,7 @@
|
||||
<artifactId>common-swagger</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-minio</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.njcn.minio.config.MinIoProperties;
|
||||
import com.njcn.minio.utils.MinIoUtils;
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Test;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* @author hongawen
|
||||
* @version 1.0.0
|
||||
* @date 2022年11月02日 19:49
|
||||
*/
|
||||
public class MinioTest extends BaseJunitTest {
|
||||
|
||||
@Resource
|
||||
private MinIoUtils minIoUtils;
|
||||
|
||||
@Resource
|
||||
private MinIoProperties minIoProperties;
|
||||
|
||||
/***
|
||||
* 上传
|
||||
*/
|
||||
@Test
|
||||
public void upload() throws Exception {
|
||||
String strUrl = "C:\\Users\\DELL\\Desktop\\功能测试文件\\text.json";
|
||||
File file = new File(strUrl);
|
||||
MultipartFile cMultiFile = getMultipartFile(file);
|
||||
System.out.println(minIoUtils.upload(cMultiFile, minIoProperties.getBucket(), "day/"));
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 删除
|
||||
*/
|
||||
@Test
|
||||
public void removeObject(){
|
||||
String name = "day/8D113DD5CE4B4AB2ABB5E531373E3D88.txt";
|
||||
minIoUtils.removeObject(minIoProperties.getBucket(), name);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 根据对象名获取查看的url
|
||||
*/
|
||||
@Test
|
||||
public void getObjectUrl(){
|
||||
String name = "day/8D113DD5CE4B4AB2ABB5E531373E3D88.txt";
|
||||
System.out.println(minIoUtils.getObjectUrl(minIoProperties.getBucket(), name, 7 * 24 * 60 * 60));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static MultipartFile getMultipartFile(File file) {
|
||||
FileItem item = new DiskFileItemFactory().createItem("file"
|
||||
, MediaType.MULTIPART_FORM_DATA_VALUE
|
||||
, true
|
||||
, file.getName());
|
||||
try (InputStream input = new FileInputStream(file);
|
||||
OutputStream os = item.getOutputStream()) {
|
||||
// 流转移
|
||||
IOUtils.copy(input, os);
|
||||
} catch (Exception e) {
|
||||
throw new IllegalArgumentException("Invalid file: " + e, e);
|
||||
}
|
||||
|
||||
return new CommonsMultipartFile(item);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user