Merge branch 'caihaohan'

This commit is contained in:
2023-04-28 09:41:22 +08:00
16 changed files with 488 additions and 212 deletions
@@ -21,7 +21,7 @@ public class WebMvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// /home/file/**为前端URL访问路径 后面 file:xxxx为本地磁盘映射
registry.addResourceHandler(picPath+"**").addResourceLocations("file://"+uploadFile);
registry.addResourceHandler(picPath + "**").addResourceLocations("file:" + uploadFile);
}
}
@@ -18,7 +18,7 @@
#spring.datasource.password = adc_forecast
#kylin数据库 ds1
#kylin\u6570\u636E\u5E93 ds1
#spring.datasource.kylin.name=PROJECT_MI
#spring.datasource.kylin.driverClassName=org.apache.kylin.jdbc.Driver
#spring.datasource.kylin.url=jdbc:kylin://10.64.23.8:7070/PROJECT_MI
@@ -28,32 +28,32 @@
#spring.datasource.kylin.maxWaitTime=10000
#spring.datasource.kylin.poolSize=10
#
##mysql数据库 ds2
##mysql\u6570\u636E\u5E93 ds2
#spring.datasource.mysql.driverClassName = com.mysql.jdbc.Driver
#spring.datasource.mysql.url = jdbc:mysql://192.168.144.80:3306/cadata?characterEncoding=utf-8&&zeroDateTimeBehavior=convertToNull
#spring.datasource.mysql.username = root
#spring.datasource.mysql.password = root
spring.datasource.driverClassName = com.mysql.cj.jdbc.Driver
spring.datasource.url = jdbc:mysql://121.36.69.172:3307/report-library?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
spring.datasource.url = jdbc:mysql://121.36.69.172:3307/report-library?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
spring.datasource.username = root
spring.datasource.password = hzwlsoft.com
#后端端口
#\u540E\u7AEF\u7AEF\u53E3
server.port=7060
#验证码后台模式,默认为1:1为不开启,2为开启,3为输错 用户名或密码 ${maxLoginErrorCount} 次 才开启
#\u9A8C\u8BC1\u7801\u540E\u53F0\u6A21\u5F0F\uFF0C\u9ED8\u8BA4\u4E3A1\uFF1A1\u4E3A\u4E0D\u5F00\u542F\uFF0C2\u4E3A\u5F00\u542F\uFF0C3\u4E3A\u8F93\u9519 \u7528\u6237\u540D\u6216\u5BC6\u7801 ${maxLoginErrorCount} \u6B21 \u624D\u5F00\u542F
verifyCodeMode=3
#仅当验证码模式 ${verifyCodeMode} 为 3时生效,设置错误登录出现验证码的阈值,默认为3
#\u4EC5\u5F53\u9A8C\u8BC1\u7801\u6A21\u5F0F ${verifyCodeMode} \u4E3A 3\u65F6\u751F\u6548\uFF0C\u8BBE\u7F6E\u9519\u8BEF\u767B\u5F55\u51FA\u73B0\u9A8C\u8BC1\u7801\u7684\u9608\u503C\uFF0C\u9ED8\u8BA4\u4E3A3
maxLoginErrorCount=3
#密码Base64加密开关,true为开启,false为关闭
#\u5BC6\u7801Base64\u52A0\u5BC6\u5F00\u5173,true\u4E3A\u5F00\u542F,false\u4E3A\u5173\u95ED
isPassEncrypted=true
#{
#"password": "YWJjMTIz",
#"username": "YWRtaW4x"
#}
#swagger 显示api1为只显示${restPath:/api}前缀的api,0为显示所有api,其他为不显示api
#swagger \u663E\u793Aapi\uFF0C1\u4E3A\u53EA\u663E\u793A${restPath:/api}\u524D\u7F00\u7684api,0\u4E3A\u663E\u793A\u6240\u6709api\uFF0C\u5176\u4ED6\u4E3A\u4E0D\u663E\u793Aapi
swaggerLevel=0
@@ -61,12 +61,13 @@ swaggerLevel=0
#
#picPath=/EPR/file/home/pic/
# 本地存储文件的磁盘地址
uploadFile=D:\\work\\idea\\changan\\
# 本地文件访问的url地址
# \u672C\u5730\u5B58\u50A8\u6587\u4EF6\u7684\u78C1\u76D8\u5730\u5740
#uploadFile=D:\\work\\idea\\changan\\
uploadFile=D:\\uploadfile\\tmp\\
#uploadFile=/data/DeploymentPackage/report_library/uploadfile/
# \u672C\u5730\u6587\u4EF6\u8BBF\u95EE\u7684url\u5730\u5740
picPath=/api/home/pic/
serverIp=http://127.0.0.1:7060/
@@ -89,47 +90,51 @@ MAIL_POP_PORT=110
IPANDPORT=http://localhost:7061/
#redis
#Redis服务器地址
#Redis\u670D\u52A1\u5668\u5730\u5740
spring.redis.host=192.168.144.29
#spring.redis.host=192.168.1.103
#spring.redis.host=localhost
## Redis服务器连接端口
## Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
## Redis服务器连接密码(默认为空)
## Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=123321
## 连接超时时间(毫秒)
#spring.redis.password=
## \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=200000ms
## 连接池中的最大空闲连接,默认值是8。
## \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u662F8\u3002
spring.redis.jedis.pool.max-idle=50
##连接池中的最小空闲连接,默认值是0。
##\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u662F0\u3002
spring.redis.jedis.pool.min-idle=10
## 如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。
## \u5982\u679C\u8D4B\u503C\u4E3A-1\uFF0C\u5219\u8868\u793A\u4E0D\u9650\u5236\uFF1B\u5982\u679Cpool\u5DF2\u7ECF\u5206\u914D\u4E86maxActive\u4E2Ajedis\u5B9E\u4F8B\uFF0C\u5219\u6B64\u65F6pool\u7684\u72B6\u6001\u4E3Aexhausted(\u8017\u5C3D)\u3002
spring.redis.jedis.pool.max-active=2000
## 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException
## \u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
spring.redis.jedis.pool.max-wait=2000ms
spring.redis.database=6
# 上传方式:阿里云:alioss 华为云:hwobs
uploadType: hwobs
# \u4E0A\u4F20\u65B9\u5F0F\uFF1A\u963F\u91CC\u4E91\uFF1Aalioss \u534E\u4E3A\u4E91\uFF1Ahwobs \u672C\u5730\uFF1Alocal
uploadType: local
# ======= 阿里OSS配置 =========
# \u672C\u5730\u6587\u4EF6\u5B58\u50A8\u5730\u5740
localFilePath=D:\\uploadfile\\
# ======= \u963F\u91CCOSS\u914D\u7F6E =========
aliyun.OSS.endpoint=https://oss-cn-hangzhou.aliyuncs.com
aliyun.OSS.accessKeyId= LTAI5tBmUfVF6Z8R6sHTdTG7
aliyun.OSS.accessKeySecret= mY6UvWv20Tg2R46ORe6uV5gL6TQloC
aliyun.OSS.bucketName=qqxexamplebucket
aliyun.OSS.fileMaxSize=10 #文件上传最大M数
aliyun.OSS.fileMaxSize=10 #\u6587\u4EF6\u4E0A\u4F20\u6700\u5927M\u6570
# ======= 华为OBS配置 =========
# ======= \u534E\u4E3AOBS\u914D\u7F6E =========
huawei.OBS.endPoint=https://obs.cn-north-4.myhuaweicloud.com
huawei.OBS.accessKey=EEMAGYTHP9KKPF18TZCL
huawei.OBS.secretKey=3NmFNf1uX3EV1LbCEzgw6gDv0tZ6WAVwG37BGq1p
huawei.OBS.bucketName=gcpa
huawei.OBS.fileMaxSize=10 #文件上传最大M数
huawei.OBS.fileMaxSize=10 #\u6587\u4EF6\u4E0A\u4F20\u6700\u5927M\u6570
logging.level.com.adc: debug
# ==== IAM????
iam.url=https://iamuat.faw-vw.com/
iam.appkey=xxxx
iam.appSecret=xxx
iam.appSecret=xxx
@@ -18,7 +18,7 @@
#spring.datasource.password = adc_forecast
#kylin数据库 ds1
#kylin\u6570\u636E\u5E93 ds1
#spring.datasource.kylin.name=PROJECT_MI
#spring.datasource.kylin.driverClassName=org.apache.kylin.jdbc.Driver
#spring.datasource.kylin.url=jdbc:kylin://10.64.23.8:7070/PROJECT_MI
@@ -28,7 +28,7 @@
#spring.datasource.kylin.maxWaitTime=10000
#spring.datasource.kylin.poolSize=10
#
##mysql数据库 ds2
##mysql\u6570\u636E\u5E93 ds2
#spring.datasource.mysql.driverClassName = com.mysql.jdbc.Driver
#spring.datasource.mysql.url = jdbc:mysql://192.168.144.80:3306/cadata?characterEncoding=utf-8&&zeroDateTimeBehavior=convertToNull
#spring.datasource.mysql.username = root
@@ -39,21 +39,21 @@ spring.datasource.url = jdbc:mysql://121.36.69.172:3307/report-library?character
spring.datasource.username = root
spring.datasource.password = hzwlsoft.com
#后端端口
#\u540E\u7AEF\u7AEF\u53E3
server.port=7060
#验证码后台模式,默认为1:1为不开启,2为开启,3为输错 用户名或密码 ${maxLoginErrorCount} 次 才开启
#\u9A8C\u8BC1\u7801\u540E\u53F0\u6A21\u5F0F\uFF0C\u9ED8\u8BA4\u4E3A1\uFF1A1\u4E3A\u4E0D\u5F00\u542F\uFF0C2\u4E3A\u5F00\u542F\uFF0C3\u4E3A\u8F93\u9519 \u7528\u6237\u540D\u6216\u5BC6\u7801 ${maxLoginErrorCount} \u6B21 \u624D\u5F00\u542F
verifyCodeMode=3
#仅当验证码模式 ${verifyCodeMode} 为 3时生效,设置错误登录出现验证码的阈值,默认为3
#\u4EC5\u5F53\u9A8C\u8BC1\u7801\u6A21\u5F0F ${verifyCodeMode} \u4E3A 3\u65F6\u751F\u6548\uFF0C\u8BBE\u7F6E\u9519\u8BEF\u767B\u5F55\u51FA\u73B0\u9A8C\u8BC1\u7801\u7684\u9608\u503C\uFF0C\u9ED8\u8BA4\u4E3A3
maxLoginErrorCount=3
#密码Base64加密开关,true为开启,false为关闭
#\u5BC6\u7801Base64\u52A0\u5BC6\u5F00\u5173,true\u4E3A\u5F00\u542F,false\u4E3A\u5173\u95ED
isPassEncrypted=true
#{
#"password": "YWJjMTIz",
#"username": "YWRtaW4x"
#}
#swagger 显示api1为只显示${restPath:/api}前缀的api,0为显示所有api,其他为不显示api
#swagger \u663E\u793Aapi\uFF0C1\u4E3A\u53EA\u663E\u793A${restPath:/api}\u524D\u7F00\u7684api,0\u4E3A\u663E\u793A\u6240\u6709api\uFF0C\u5176\u4ED6\u4E3A\u4E0D\u663E\u793Aapi
swaggerLevel=0
@@ -61,9 +61,14 @@ swaggerLevel=0
#
#picPath=/EPR/file/home/pic/
# 本地存储文件的磁盘地址
uploadFile=D:\\work\\idea\\changan\\
# 本地文件访问的url地址
# \u672C\u5730\u6587\u4EF6\u5B58\u50A8\u8DEF\u5F84\u65B9\u5F0F jar\u5305\u8DEF\u5F84\uFF1Ajar \u5DE5\u4F5C\u76EE\u5F55\uFF1Auserdir \u56FA\u5B9A\u76EE\u5F55\uFF1Asettled
localSaveFileType=settled
#localSaveFileType=userdir
# \u672C\u5730\u5B58\u50A8\u6587\u4EF6\u7684\u78C1\u76D8\u5730\u5740
#uploadFile=D:\\work\\idea\\changan\\
uploadFile=/data/DeploymentPackage/report_library/uploadfile
# \u672C\u5730\u6587\u4EF6\u8BBF\u95EE\u7684url\u5730\u5740
picPath=/api/home/pic/
@@ -89,42 +94,42 @@ MAIL_POP_PORT=110
IPANDPORT=http://localhost:7061/
#redis
#Redis服务器地址
#Redis\u670D\u52A1\u5668\u5730\u5740
spring.redis.host=192.168.144.29
#spring.redis.host=localhost
## Redis服务器连接端口
## Redis\u670D\u52A1\u5668\u8FDE\u63A5\u7AEF\u53E3
spring.redis.port=6379
## Redis服务器连接密码(默认为空)
## Redis\u670D\u52A1\u5668\u8FDE\u63A5\u5BC6\u7801\uFF08\u9ED8\u8BA4\u4E3A\u7A7A\uFF09
spring.redis.password=123321
## 连接超时时间(毫秒)
## \u8FDE\u63A5\u8D85\u65F6\u65F6\u95F4\uFF08\u6BEB\u79D2\uFF09
spring.redis.timeout=200000ms
## 连接池中的最大空闲连接,默认值是8。
## \u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5927\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u662F8\u3002
spring.redis.jedis.pool.max-idle=50
##连接池中的最小空闲连接,默认值是0。
##\u8FDE\u63A5\u6C60\u4E2D\u7684\u6700\u5C0F\u7A7A\u95F2\u8FDE\u63A5\uFF0C\u9ED8\u8BA4\u503C\u662F0\u3002
spring.redis.jedis.pool.min-idle=10
## 如果赋值为-1,则表示不限制;如果pool已经分配了maxActive个jedis实例,则此时pool的状态为exhausted(耗尽)。
## \u5982\u679C\u8D4B\u503C\u4E3A-1\uFF0C\u5219\u8868\u793A\u4E0D\u9650\u5236\uFF1B\u5982\u679Cpool\u5DF2\u7ECF\u5206\u914D\u4E86maxActive\u4E2Ajedis\u5B9E\u4F8B\uFF0C\u5219\u6B64\u65F6pool\u7684\u72B6\u6001\u4E3Aexhausted(\u8017\u5C3D)\u3002
spring.redis.jedis.pool.max-active=2000
## 等待可用连接的最大时间,单位毫秒,默认值为-1,表示永不超时。如果超过等待时间,则直接抛出JedisConnectionException
## \u7B49\u5F85\u53EF\u7528\u8FDE\u63A5\u7684\u6700\u5927\u65F6\u95F4\uFF0C\u5355\u4F4D\u6BEB\u79D2\uFF0C\u9ED8\u8BA4\u503C\u4E3A-1\uFF0C\u8868\u793A\u6C38\u4E0D\u8D85\u65F6\u3002\u5982\u679C\u8D85\u8FC7\u7B49\u5F85\u65F6\u95F4\uFF0C\u5219\u76F4\u63A5\u629B\u51FAJedisConnectionException
spring.redis.jedis.pool.max-wait=2000ms
spring.redis.database=6
# 上传方式:阿里云:alioss 华为云:hwobs
# \u4E0A\u4F20\u65B9\u5F0F\uFF1A\u963F\u91CC\u4E91\uFF1Aalioss \u534E\u4E3A\u4E91\uFF1Ahwobs \u672C\u5730\uFF1Alocal
uploadType: hwobs
# ======= 阿里OSS配置 =========
# ======= \u963F\u91CCOSS\u914D\u7F6E =========
aliyun.OSS.endpoint=https://oss-cn-hangzhou.aliyuncs.com
aliyun.OSS.accessKeyId= LTAI5tBmUfVF6Z8R6sHTdTG7
aliyun.OSS.accessKeySecret= mY6UvWv20Tg2R46ORe6uV5gL6TQloC
aliyun.OSS.bucketName=qqxexamplebucket
aliyun.OSS.fileMaxSize=10 #文件上传最大M数
aliyun.OSS.fileMaxSize=10 #\u6587\u4EF6\u4E0A\u4F20\u6700\u5927M\u6570
# ======= 华为OBS配置 =========
# ======= \u534E\u4E3AOBS\u914D\u7F6E =========
huawei.OBS.endPoint=https://obs.cn-north-4.myhuaweicloud.com
huawei.OBS.accessKey=EEMAGYTHP9KKPF18TZCL
huawei.OBS.secretKey=3NmFNf1uX3EV1LbCEzgw6gDv0tZ6WAVwG37BGq1p
huawei.OBS.bucketName=gcpa
huawei.OBS.fileMaxSize=10 #文件上传最大M数
huawei.OBS.fileMaxSize=10 #\u6587\u4EF6\u4E0A\u4F20\u6700\u5927M\u6570
logging.level.com.adc: debug
-1
View File
@@ -118,7 +118,6 @@
<artifactId>spring-boot-starter-data-redis</artifactId>
</dependency>
</dependencies>
@@ -5,6 +5,7 @@ import com.adc.da.report.eo.FileEntity;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.service.IFileService;
import com.adc.da.report.service.IReportService;
import com.adc.da.report.util.LocalFileUtil;
import com.adc.da.report.util.OSSClientUtil;
import com.adc.da.report.util.ObsBootUtil;
import com.adc.da.report.vo.ReportQueryVo;
@@ -26,6 +27,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@@ -62,6 +64,9 @@ public class ReportManageConroller {
@Autowired
private ObsBootUtil obsBootUtil;
@Autowired
private LocalFileUtil localFileUtil;
@Value("${uploadType}")
private String uploadType;
@@ -74,7 +79,7 @@ public class ReportManageConroller {
@ApiOperation("新增或编辑报告")
@PostMapping("/add")
@ReportLog(description = "新增或编辑")
public ResponseMessage add(@RequestBody ReportVo vo) {
public ResponseMessage add(@RequestBody ReportVo vo) throws IOException {
ReportEntity entity = new ReportEntity();
BeanUtils.copyProperties(vo, entity);
String name = reportService.insert(entity, vo.getLabelList());
@@ -189,7 +194,17 @@ public class ReportManageConroller {
stringRedisTemplate.boundValueOps("1121212").set("1212");
}
@ApiOperation("testPath")
@GetMapping("/testPath")
@Deprecated
public ResponseMessage testPath() throws URISyntaxException {
HashMap<String, String> pathMap = new HashMap<>();
String jarPath = new File(getClass().getProtectionDomain().getCodeSource().getLocation().toURI().getPath()).getParentFile().getPath();
String property = System.getProperty("user.dir");
pathMap.put("jarpath", jarPath);
pathMap.put("propertyPath", property);
return Result.success(pathMap);
}
/**
* 上传文件
@@ -224,10 +239,12 @@ public class ReportManageConroller {
try{
String result="";
// 上传方式:阿里云:alioss 华为云:hwobs
if (uploadType.equals("hwobs")){
if ("hwobs".equals(uploadType)){
result = obsBootUtil.upload(file, fileName);
}else if (uploadType.equals("alioss")){
}else if ("alioss".equals(uploadType)) {
result = ossClientUtil.uploadFile2OSS(file.getInputStream(),fileName);
}else if ("local".equals(uploadType)) {
localFileUtil.saveFile(file.getInputStream(), fileName);
}
resultMap.put("key", date + num);
resultMap.put("value", path + "//" + fileName);
@@ -339,10 +356,12 @@ public class ReportManageConroller {
response.setContentType("application/x-download");
// File file = new File(uploadFile, entity.getSavePath());
// 上传方式:阿里云:alioss 华为云:hwobs
if (uploadType.equals("hwobs")){
if ("hwobs".equals(uploadType)){
obsBootUtil.downFile(entity.getSavePath(), response);
}else if (uploadType.equals("alioss")){
}else if ("alioss".equals(uploadType)){
ossClientUtil.downloadFileFromOSS(entity.getSavePath(),response);
}else if ("local".equals(uploadType)){
localFileUtil.downFile(entity.getSavePath(), response);
}
} catch (Exception ex) {
@@ -0,0 +1,18 @@
package com.adc.da.report.dao.mysql;
import com.adc.da.report.eo.ReportContentEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @author ThinkBook
* @description 针对表【ts_report_content】的数据库操作Mapper
* @createDate 2023-04-27 11:48:22
* @Entity com.adc.da.report.eo.ReportContentEntity
*/
public interface ReportContentDao extends BaseMapper<ReportContentEntity> {
}
@@ -0,0 +1,46 @@
package com.adc.da.report.eo;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
/**
*
* @author Caihaohan
* @TableName ts_report_content
*/
@TableName(value ="ts_report_content")
@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class ReportContentEntity implements Serializable {
/**
* 主键id
*/
@TableId(value = "id",type = IdType.INPUT)
private String id;
/**
* 报告id
*/
@TableField(value = "report_id")
private String reportId;
/**
* 文件内容
*/
@TableField(value = "report_content")
private String reportContent;
@TableField(exist = false)
private static final long serialVersionUID = 1L;
}
@@ -0,0 +1,24 @@
package com.adc.da.report.service;
import com.adc.da.report.eo.ReportContentEntity;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.FileNotFoundException;
import java.io.IOException;
/**
* @author ThinkBook
* @description 针对表【ts_report_content】的数据库操作Service
* @createDate 2023-04-27 11:48:22
*/
public interface IReportContentService extends IService<ReportContentEntity> {
/**
* 插入报告内容表
*
* @param reportId 报告id
* @param fileId 文件id
*/
void insertReportContent(String reportId, String fileId) throws IOException;
}
@@ -5,6 +5,7 @@ import com.adc.da.report.vo.ReportQueryVo;
import com.adc.da.report.vo.ReportVo;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.io.IOException;
import java.util.List;
/**
@@ -20,7 +21,7 @@ public interface IReportService {
* @param labelList
* @return 报告名称
*/
String insert(ReportEntity entity, List<String> labelList);
String insert(ReportEntity entity, List<String> labelList) throws IOException;
/**
* 报告列表展示
@@ -0,0 +1,82 @@
package com.adc.da.report.service.impl;
import com.adc.da.report.dao.mysql.FileDao;
import com.adc.da.report.eo.FileEntity;
import com.adc.da.report.util.FileContentUtil;
import com.adc.da.report.util.LocalFileUtil;
import com.adc.da.report.util.OSSClientUtil;
import com.adc.da.report.util.ObsBootUtil;
import com.adc.da.util.utils.FileUtil;
import com.adc.da.util.utils.UUID;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.adc.da.report.eo.ReportContentEntity;
import com.adc.da.report.service.IReportContentService;
import com.adc.da.report.dao.mysql.ReportContentDao;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
/**
* @author Caihaohan
* @description 针对表【ts_report_content】的数据库操作Service实现
* @createDate 2023-04-27 11:48:22
*/
@Service
@Slf4j
public class IReportContentServiceImpl extends ServiceImpl<ReportContentDao, ReportContentEntity>
implements IReportContentService {
@Value("${uploadFile}")
private String uploadFile;
@Value("${uploadType}")
private String uploadType;
@Resource
private OSSClientUtil ossClientUtil;
@Resource
private ObsBootUtil obsBootUtil;
@Resource
private LocalFileUtil localFileUtil;
@Resource
private FileDao fileDao;
@Override
@Transactional(rollbackFor = Exception.class)
public void insertReportContent(String reportId, String fileId) throws IOException {
//获取文件
FileEntity fileEntity = fileDao.selectById(fileId);
String path = uploadFile + fileEntity.getSavePath();
FileOutputStream outputStream = new FileOutputStream(path);
// 上传方式:阿里云:alioss 华为云:hwobs
if ("hwobs".equals(uploadType)) {
obsBootUtil.getFileFromOBS(fileEntity.getSavePath(), outputStream);
} else if ("alioss".equals(uploadType)) {
ossClientUtil.getFileFromOSS(fileEntity.getSavePath(), outputStream);
} else if ("local".equals(uploadType)) {
localFileUtil.getFileFromLocal(fileEntity.getSavePath(), outputStream);
}
File file = new File(path);
//解析出内容
String content = FileContentUtil.readFileContent(file);
//将内容存入
ReportContentEntity reportContentEntity = new ReportContentEntity(UUID.randomUUID10(), reportId, content);
save(reportContentEntity);
//将文件删除
FileUtil.deleteFile(path);
}
}
@@ -11,6 +11,7 @@ import com.adc.da.report.eo.FileEntity;
import com.adc.da.report.eo.ReportEntity;
import com.adc.da.report.eo.ReportLabelEntity;
import com.adc.da.report.eo.ReportUserEntity;
import com.adc.da.report.service.IReportContentService;
import com.adc.da.report.service.IReportLabelService;
import com.adc.da.report.service.IReportService;
import com.adc.da.report.service.ITreeLabelService;
@@ -28,6 +29,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -37,6 +41,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@@ -90,6 +95,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
@Autowired
private RoleEODao roleEODao;
@Resource
private IReportContentService iReportContentService;
@Autowired
private LocalFileUtil localFileUtil;
/**
* 新增或编辑报告
*
@@ -99,7 +110,7 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String insert(ReportEntity entity, List<String> labelList) {
public String insert(ReportEntity entity, List<String> labelList) throws IOException {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (StringUtils.isEmpty(entity.getId())) {
@@ -124,6 +135,9 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
reportLabelDao.insert(reportLabelEntity);
});
//插入报表内容表
iReportContentService.insertReportContent(entity.getId() ,entity.getFileId());
CommonUtils.threadPoolExecutor().execute(() -> {
//生成html
try {
@@ -217,7 +231,6 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
idSet.add(reportLabelEntity.getReportId());
});
}
// TODO ES模糊查询
IPage<ReportVo> list = reportDao.list(page, vo, idSet);
@@ -533,10 +546,12 @@ public class IReportServiceImpl extends ServiceImpl<ReportDao, ReportEntity>
String path = uploadFile + fileEntity.getSavePath();
FileOutputStream outputStream = new FileOutputStream(path);
// 上传方式:阿里云:alioss 华为云:hwobs
if (uploadType.equals("hwobs")) {
if ("hwobs".equals(uploadType)) {
obsBootUtil.getFileFromOBS(fileEntity.getSavePath(), outputStream);
} else if (uploadType.equals("alioss")) {
} else if ("alioss".equals(uploadType)) {
ossClientUtil.getFileFromOSS(fileEntity.getSavePath(), outputStream);
} else if ("local".equals(uploadType)) {
localFileUtil.getFileFromLocal(fileEntity.getSavePath(), outputStream);
}
String html = null;
@@ -0,0 +1,86 @@
package com.adc.da.report.util;
import com.adc.da.util.exception.AdcDaBaseException;
import com.obs.services.exception.ObsException;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.Paths;
/**
* @author Caihaohan
*/
@Slf4j
@Component
public class LocalFileUtil {
@Value("${uploadFile}")
private String uploadFile;
@Value("${localFilePath}")
private String localFilePath;
public void saveFile(InputStream fileInputStream, String fileName) throws IOException {
String path = localFilePath + fileName;
FileOutputStream fileOutputStream = new FileOutputStream(path);
byte[] buffer = new byte[1024];
int length;
while ((length = fileInputStream.read(buffer)) > 0) {
fileOutputStream.write(buffer, 0, length);
}
fileInputStream.close();
fileOutputStream.close();
}
public void getFileFromLocal(String savePath, FileOutputStream outputStream) throws IOException {
// 创建源文件对象
File sourceFile = new File(localFilePath, savePath);
// 如果源文件不存在,则抛出异常
if (!sourceFile.exists()) {
throw new IOException("Source file does not exist.");
}
// 创建输入流
FileInputStream inputStream = new FileInputStream(sourceFile);
// 创建缓冲区
byte[] buffer = new byte[1024];
int bytesRead;
// 从输入流读取数据,并写入输出流
while ((bytesRead = inputStream.read(buffer)) != -1) {
outputStream.write(buffer, 0, bytesRead);
}
// 关闭输入流和输出流
inputStream.close();
outputStream.close();
}
public void downFile(String savePath, HttpServletResponse response) throws IOException {
String filePath = uploadFile + savePath;
//复制到本地
FileOutputStream fileOutputStream = new FileOutputStream(filePath);
getFileFromLocal(savePath, fileOutputStream);
//将文件写到response中
try (InputStream objectContent = Files.newInputStream(Paths.get(filePath))) {
byte[] bt = new byte[1024 * 1024];
int len = 0;
while ((len = objectContent.read(bt)) != -1) {
response.getOutputStream().write(bt, 0, len);
}
} catch (ObsException | IOException oe) {
throw new AdcDaBaseException("获取本地文件失败");
} finally {
// 数据读取完成后,获取的流必须关闭,否则会造成连接泄漏,导致请求无连接可用,程序无法正常工作。
response.getOutputStream().close();
}
}
}
@@ -0,0 +1,72 @@
package com.adc.da.report.util;
import java.util.ArrayList;
import java.util.List;
/**
* 分页工具类
*
* @author 程序员小强
*/
public class PageUtils {
/**
* 默认第一页
*/
private static final int PAGE = 1;
/**
* 默认一页10条
*/
private static final int PAGE_SIZE = 10;
public static Integer getStartRow(Integer pageNo, Integer pageSize) {
if (null == pageNo) {
pageNo = PAGE;
}
if (null == pageSize) {
pageSize = PAGE_SIZE;
}
return pageSize * (pageNo - 1);
}
public static Integer getOffset(Integer pageSize) {
if (null == pageSize) {
pageSize = PAGE_SIZE;
}
return pageSize;
}
/**
* list分页
*
* @param list
* @param pageNo
* @param pageSize
*/
public static <T> List<T> listPage(List<T> list, Integer pageNo, Integer pageSize) {
if (null == list || list.isEmpty()) {
return list;
}
if (null == pageNo) {
pageNo = PAGE;
}
if (null == pageSize) {
pageSize = PAGE_SIZE;
}
int totalCount = list.size();
pageNo = pageNo - 1;
int fromIndex = pageNo * pageSize;
if (fromIndex > totalCount) {
return new ArrayList<>(0);
}
int toIndex = ((pageNo + 1) * pageSize);
if (toIndex > totalCount) {
toIndex = totalCount;
}
return list.subList(fromIndex, toIndex);
}
}
@@ -4,6 +4,8 @@ import com.adc.da.util.utils.UUID;
import lombok.extern.slf4j.Slf4j;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.rendering.PDFRenderer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import sun.misc.BASE64Encoder;
import javax.imageio.ImageIO;
@@ -14,28 +16,37 @@ import java.util.ArrayList;
import java.util.List;
@Slf4j
@Component
public class PdfUtil {
private PdfUtil(){
throw new IllegalStateException("Utility class");
private static String uploadType;
@Value("${uploadType}")
public void setUploadType(String uploadType) {
PdfUtil.uploadType = uploadType;
}
private PdfUtil() {
}
/**
* 截取pdf成图片
*
* @param inputStream
* @param targetPath
* @param ipAddress
* @return
*/
public static String pdfStreamToPng( InputStream inputStream,String targetPath,String ipAddress) {
public static String pdfStreamToPng(InputStream inputStream, String targetPath, String ipAddress) {
try(PDDocument doc=PDDocument.load( inputStream)) {
try (PDDocument doc = PDDocument.load(inputStream)) {
PDFRenderer renderer = new PDFRenderer(doc);
List<String> list=new ArrayList<>();
List<String> list = new ArrayList<>();
int pageCount = doc.getNumberOfPages();
BufferedImage image = null;
log.info("开始时间"+System.currentTimeMillis());
log.info("开始时间" + System.currentTimeMillis());
String fileName = UUID.randomUUID10();
for (int i = 0; i < pageCount; i++) {
image = renderer.renderImage(i, 2.0f);
@@ -46,32 +57,31 @@ public class PdfUtil {
imOut = ImageIO.createImageOutputStream(bs);
ImageIO.write(image, "png", imOut);
try(ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bs.toByteArray());){
File ff=new File(targetPath+"/"+fileName);
if(!ff.exists()){
try (ByteArrayInputStream byteInputStream = new ByteArrayInputStream(bs.toByteArray());) {
File ff = new File(targetPath + "/" + fileName);
if (!ff.exists()) {
ff.mkdirs();
}
File uploadFile = new File(targetPath+"/"+fileName+"/"+i+".png");
try(FileOutputStream fops = new FileOutputStream(uploadFile);){
File uploadFile = new File(targetPath + "/" + fileName + "/" + i + ".png");
try (FileOutputStream fops = new FileOutputStream(uploadFile);) {
fops.write(readInputStream(byteInputStream));
}
catch (Exception e){
log.error(e.getMessage(),e);
} catch (Exception e) {
log.error(e.getMessage(), e);
}
list.add(ipAddress+"api/home/pic"+"/"+fileName+"/"+i+".png");
}
catch (Exception e){
list.add(ipAddress + "api/home/pic" + "/" + fileName + "/" + i + ".png");
} catch (Exception e) {
}
}
log.info("结束时间"+System.currentTimeMillis());
log.info("结束时间" + System.currentTimeMillis());
String htmlByBase64 = createHtmlByImg(list);
String htmlByBase64 = createHtmlByImg(list);
return htmlByBase64;
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error(e.getMessage(), e);
return "";
}
}
@@ -88,15 +98,15 @@ public class PdfUtil {
buffer.append("<style>\r\n");
buffer.append(".preview-img {background-color:#fff; text-align:center; width:100%; max-width:100%;margin-top:6px;}\r\n");
buffer.append("</style>\r\n");
for(int i=0;i<baseList.size();i++){
buffer.append("<img class ='preview-img' src="+baseList.get(i)+" />");
for (int i = 0; i < baseList.size(); i++) {
buffer.append("<img class ='preview-img' src=" + baseList.get(i) + " />");
}
buffer.append("</body></html>");
try {
return buffer.toString();
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error(e.getMessage(), e);
return "";
}
@@ -109,7 +119,7 @@ public class PdfUtil {
public static byte[] readInputStream(InputStream inStream) throws Exception {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024*1024];
byte[] buffer = new byte[1024 * 1024];
int len = 0;
while ((len = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
@@ -2,124 +2,21 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.adc.da.report.dao.mysql.ReportDao">
<!-- <select id="list" parameterType="com.adc.da.report.vo.ReportQueryVo" resultType="com.adc.da.report.vo.ReportVo">-->
<!-- select t1.id,t1.labelOneId,t1.labelTwoId,t1.labelThreeId,t1.labelOneName,t1.labelTwoName,t1.labelThreeName,t1.name,t1.year,t1.keyContent,t1.mainContent-->
<!-- ,t1.department,date_format(t1.updateDate,'%Y-%m-%d') createDate,t1.fileId-->
<!-- from(-->
<!-- (-->
<!-- select distinct b1.*,(case when b3.name is null then '-' else b3.name end) labelOneName-->
<!-- ,(case when b4.name is null then '-' else b4.name end) labelTwoName-->
<!-- ,(case when b5.name is null then '-' else b5.name end) labelThreeName from-->
<!-- (select * from TT_REPORT_MANAGE )b1-->
<!-- left join TR_REPORT_USER b2 on b1.id=b2.reportId-->
<!-- left join TS_LABEL b3 on b1.labelOneId=b3.id-->
<!-- left join TS_LABEL b4 on b1.labelTwoId=b4.id-->
<!-- left join TS_LABEL b5 on b1.labelThreeId=b5.id-->
<!-- where b1.del_flag='0' and(b3.name is null or b4.name is null or b5.name is null )-->
<!-- &lt;!&ndash;文本搜索&ndash;&gt;-->
<!-- <if test="Vo.keyContent !=null and Vo.keyContent !=''">-->
<!-- and (b1.name like "%"#{Vo.keyContent}"%" or b1.keycontent like "%"#{Vo.keyContent}"%"-->
<!-- or b1.maincontent like "%"#{Vo.keyContent}"%" or b1.department like "%"#{Vo.keyContent}"%")-->
<!-- </if>-->
<!-- &lt;!&ndash;年份搜索&ndash;&gt;-->
<!-- <if test="Vo.year !=null and Vo.year.size() >0">-->
<!-- and b1.year in-->
<!-- <foreach collection="Vo.year" item="year" open="(" separator="," close=")">-->
<!-- #{year}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- &lt;!&ndash;标签搜索&ndash;&gt;-->
<!-- <if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">-->
<!-- and b1.labelOneId in-->
<!-- <foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">-->
<!-- #{labelOneId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">-->
<!-- and b1.labelTwoId in-->
<!-- <foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">-->
<!-- #{labelTwoId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">-->
<!-- and b1.labelThreeId in-->
<!-- <foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">-->
<!-- #{labelThreeId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.usid !=null and Vo.usid !=''">-->
<!-- and b2.userId=#{Vo.usid}-->
<!-- </if>-->
<!-- ORDER BY updateDate desc limit 999999999-->
<!-- )-->
<!-- UNION ALL-->
<!-- (select distinct a1.* ,a3.name labelOneName,a4.name labelTwoName,a5.name labelThreeName from(select * from TT_REPORT_MANAGE ) a1-->
<!-- left join TR_REPORT_USER a2 on a1.id=a2.reportId-->
<!-- left join TS_LABEL a3 on a1.labelOneId=a3.id-->
<!-- left join TS_LABEL a4 on a1.labelTwoId=a4.id-->
<!-- left join TS_LABEL a5 on a1.labelThreeId=a5.id-->
<!-- where a1.del_flag='0' and (a3.name is not null and a4.name is not null and a5.name is not null )-->
<!-- &lt;!&ndash;文本搜索&ndash;&gt;-->
<!-- <if test="Vo.keyContent !=null and Vo.keyContent !=''">-->
<!-- and (a1.name like "%"#{Vo.keyContent}"%" or a1.keycontent like "%"#{Vo.keyContent}"%"-->
<!-- or a1.maincontent like "%"#{Vo.keyContent}"%" or a1.department like "%"#{Vo.keyContent}"%" )-->
<!-- </if>-->
<!-- &lt;!&ndash;年份搜索&ndash;&gt;-->
<!-- <if test="Vo.year !=null and Vo.year.size >0">-->
<!-- and a1.year in-->
<!-- <foreach collection="Vo.year" item="year" open="(" separator="," close=")">-->
<!-- #{year}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- &lt;!&ndash;标签搜索&ndash;&gt;-->
<!-- <if test="Vo.labelOneId !=null and Vo.labelOneId.size() >0">-->
<!-- and a1.labelOneId in-->
<!-- <foreach collection="Vo.labelOneId" item="labelOneId" open="(" separator="," close=")">-->
<!-- #{labelOneId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelTwoId !=null and Vo.labelTwoId.size() >0">-->
<!-- and a1.labelTwoId in-->
<!-- <foreach collection="Vo.labelTwoId" item="labelTwoId" open="(" separator="," close=")">-->
<!-- #{labelTwoId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.labelThreeId !=null and Vo.labelThreeId.size() >0">-->
<!-- and a1.labelThreeId in-->
<!-- <foreach collection="Vo.labelThreeId" item="labelThreeId" open="(" separator="," close=")">-->
<!-- #{labelThreeId}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="Vo.usid !=null and Vo.usid !=''">-->
<!-- and a2.userId=#{Vo.usid}-->
<!-- </if>-->
<!-- ORDER BY updateDate desc limit 999999999)-->
<!-- )t1-->
<!-- </select>-->
<select id="list" parameterType="com.adc.da.report.vo.ReportQueryVo" resultType="com.adc.da.report.vo.ReportVo">
SELECT DISTINCT t.id, t.year, t.name, t.keycontent, t.fileId, t.createDate, t.department, t.maincontent,
t.confidentialLevel, t.privacyLevel
SELECT DISTINCT
t.id,
t.year,
t.name,
t.keycontent,
t.fileId,
t.createDate,
t.department,
t.maincontent,
t.confidentialLevel,
t.privacyLevel
FROM `tt_report_manage` AS t
INNER JOIN ts_report_label AS trl ON t.id = trl.report_id
WHERE 1 = 1
WHERE t.delFlag = 0
<!--报表名称搜索-->
<if test="Vo.name != null and Vo.name != ''">
@@ -304,9 +201,6 @@
<if test="pageVO.name !='' and pageVO.name != null">
and name like CONCAT(CONCAT('%',#{pageVO.name}),'%')
</if>
<if test="pageVO.keyContent !='' and pageVO.keyContent != null">
and keycontent like CONCAT(CONCAT('%',#{pageVO.keyContent}),'%')
</if>
<!--年份搜索-->
<if test="pageVO.year != null and pageVO.year.size() > 0">
and year in
+6 -6
View File
@@ -35,7 +35,7 @@
<commons-io.version>2.5</commons-io.version>
<commons-codec.version>1.10</commons-codec.version>
<commons-configuration.version>1.10</commons-configuration.version>
<elasticsearch.version>2.4.6</elasticsearch.version>
<!-- <elasticsearch.version>2.4.6</elasticsearch.version>-->
<shiro.version>1.4.0-RC2</shiro.version>
<tomcat.version>8.5.37</tomcat.version>
<poi.version>3.16</poi.version>
@@ -332,11 +332,11 @@
<version>${aspectj.version}</version>
</dependency>
<dependency>
<groupId>org.elasticsearch</groupId>
<artifactId>elasticsearch</artifactId>
<version>${elasticsearch.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.elasticsearch</groupId>-->
<!-- <artifactId>elasticsearch</artifactId>-->
<!-- <version>${elasticsearch.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.jdom</groupId>