Merge remote-tracking branch 'origin/master'

This commit is contained in:
范强强
2024-03-12 14:17:45 +08:00
8 changed files with 110 additions and 291 deletions
@@ -12,7 +12,6 @@ import com.jero.common.system.api.ISysBaseAPI;
import com.jero.common.util.*;
import com.jero.modules.oss.entity.OSSFile;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.system.util.SysWaterMarkUtil;
import com.jero.modules.system.util.UserUtils;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
@@ -55,9 +54,6 @@ public class CommonController {
@Resource
private IOSSFileService ossFileService;
@Resource
private SysWaterMarkUtil sysWaterMarkUtil;
@Value(value = "${jero.path.upload}")
private String uploadpath;
@@ -1,146 +0,0 @@
package com.jero.modules.system.util;
import com.jero.common.system.vo.LoginUser;
import com.jero.common.util.DateUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.pdfbox.pdmodel.PDPage;
import org.apache.pdfbox.pdmodel.PDPageContentStream;
import org.apache.pdfbox.pdmodel.common.PDRectangle;
import org.apache.pdfbox.pdmodel.font.PDType0Font;
import org.apache.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState;
import org.apache.pdfbox.pdmodel.graphics.state.RenderingMode;
import org.apache.pdfbox.util.Matrix;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List;
import java.awt.*;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.util.Date;
/**
* 水印工具类
*
* @author CaiHaohan
*/
@Component
public class SysWaterMarkUtil {
@Value("${watermark.font-size}")
private float fontSize;
@Value("${watermark.color.r}")
private int r;
@Value("${watermark.color.g}")
private int g;
@Value("${watermark.color.b}")
private int b;
@Value("${watermark.color.a}")
private int a;
@Value("${watermark.lineNumPerPage}")
private int lineNumPerPage;
@Value("${watermark.columnNumPerPage}")
private int columnNumPerPage;
@Value("${watermark.degree}")
private int degree;
@Value("${watermark.margin.left}")
private float marginLeft;
@Value("${watermark.margin.top}")
private float marginTop;
public List<String> getWaterMarkConfig() {
LoginUser loginUser = UserUtils.getLoginUser();
if (loginUser == null) {
return new ArrayList<>();
}
Date curDate = new Date();
String cudDateStr = DateUtils.date2Str(curDate, new SimpleDateFormat("yyyyMMddHHmmss"));
List<String> result = new ArrayList<>();
result.add(loginUser.getUsername() + " " + loginUser.getRealname());
result.add(cudDateStr);
return result;
}
public synchronized InputStream addWatermarkToPdf(InputStream inputStream) throws IOException {
List<String> watermarkText = getWaterMarkConfig();
PDDocument document = PDDocument.load(inputStream);
// 加载水印字体
ClassPathResource fontResource = new ClassPathResource("fonts/SourceHanSerif-VF.ttf");
PDType0Font font = PDType0Font.load(document, fontResource.getInputStream());
// 设置水印颜色和透明度
Color color = new Color(r, g, b, a);
PDExtendedGraphicsState graphicsState = new PDExtendedGraphicsState();
graphicsState.setNonStrokingAlphaConstant(0.4f);
graphicsState.setStrokingAlphaConstant(0.4f);
// 遍历每一页并添加水印
for (PDPage page : document.getPages()) {
// 获取页面尺寸以计算水印位置和大小
PDRectangle pageSize = page.getMediaBox();
float pageWidth = pageSize.getWidth();
float pageHeight = pageSize.getHeight();
// 根据页面宽度动态调整字体大小
float dynamicFontSize = pageWidth * (this.fontSize / 595); // 假设基准页面宽度为595单位
float xStep = pageWidth / columnNumPerPage;
float yStep = pageHeight / lineNumPerPage;
float rotationInRadians = (float) Math.toRadians(degree);
// 行间距,设为字体大小的一半
float lineSpacing = dynamicFontSize / 2;
// 计算两行文本的总高度
float totalTextHeight = (dynamicFontSize + lineSpacing) * (watermarkText.size() - 1);
for (float xPosition = pageSize.getLowerLeftX() + marginLeft; xPosition <= pageWidth - marginLeft; xPosition += xStep) {
for (float yPosition = pageSize.getLowerLeftY() + marginTop; yPosition <= pageHeight - marginTop; yPosition += yStep) {
try (PDPageContentStream contentStream = new PDPageContentStream(document, page, PDPageContentStream.AppendMode.APPEND, true, true)) {
contentStream.setGraphicsStateParameters(graphicsState);
contentStream.setNonStrokingColor(color);
float textYPosition = yPosition + (totalTextHeight / 2);
for (String line : watermarkText) {
contentStream.beginText();
contentStream.setFont(font, dynamicFontSize);
contentStream.setRenderingMode(RenderingMode.FILL);
contentStream.setTextMatrix(Matrix.getRotateInstance(rotationInRadians, xPosition, textYPosition));
contentStream.showText(line);
contentStream.endText();
// 更新文本的Y坐标,为下一行准备
textYPosition -= (dynamicFontSize + lineSpacing);
}
}
}
}
}
// 创建一个临时的ByteArrayOutputStream保存修改过的PDF
ByteArrayOutputStream baos = new ByteArrayOutputStream();
document.save(baos);
document.close();
// 将ByteArrayOutputStream转换为ByteArrayInputStream以供返回
return new ByteArrayInputStream(baos.toByteArray());
}
}
@@ -1,7 +1,6 @@
package com.jero.modules.sys.controller;
import com.jero.modules.oss.service.IOSSFileService;
import com.jero.modules.system.util.SysWaterMarkUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@@ -17,9 +16,6 @@ import javax.annotation.Resource;
@RequestMapping("/sys/common")
public class SysCommonController {
@Resource
private SysWaterMarkUtil sysWaterMarkUtil;
@Resource
private IOSSFileService ossFileService;
@@ -406,26 +406,6 @@ download:
# 办公域
scope_work: 52
# 水印配置项
watermark:
font-size: 13.0
# 每页几行
lineNumPerPage: 8
# 每页几列
columnNumPerPage: 3
# 倾斜角度
degree: 30
# 颜色
color:
r: 180
g: 180
b: 180
a: 1
# 页边距
margin:
top: 100
left: 60
# 特殊公式处理服务URL
mathToImg:
url: http://127.0.0.1:9998/mathToImg
@@ -7,7 +7,7 @@ server:
include-stacktrace: ALWAYS
include-message: ALWAYS
servlet:
context-path: /laws-sinotruk
context-path: /byd-structuredplugins-serve
compression:
enabled: true
min-response-size: 1024
@@ -205,7 +205,7 @@ jero:
backUrl: http://localhost:3000
backUrlPhone: http://localhost:3000
#拆分图片展示地址
splitUrl: http://srms.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName=
splitUrl: http://srms.sinotruk.com/byd-structuredplugins-serve/sys/split/file/getImage?fileName=
path:
#文件上传根目录 设置
upload: /app/opt/upFiles
@@ -247,7 +247,7 @@ jero:
minio_url: http://grp-minio.yf-grp:9000
minio_name: root
minio_pass: Grp2kvs@!dd
bucketName: laws-sinotruk
bucketName: byd-laws
#大屏报表参数设置
jmreport:
mode: dev
@@ -350,7 +350,7 @@ justauth:
file:
# 在线编辑文件下载映射地址
downloadUrl: http://localhost:8184/laws-sinotruk/file/
downloadUrl: http://localhost:8184/byd-structuredplugins-serve/file/
split:
path: D://opt//onlyOffice//file//splitImage//
# 在线编辑空白docx地址
@@ -432,22 +432,17 @@ download:
# 办公域
scope_work: 52
# 水印配置项
watermark:
font-size: 13.0
# 每页几行
lineNumPerPage: 8
# 每页几列
columnNumPerPage: 2
# 倾斜角度
degree: 30
# 颜色
color:
r: 180
g: 180
b: 180
a: 1
# 页边距
margin:
top: 100
left: 60
# 特殊公式处理服务URL
mathToImg:
url: http://127.0.0.1:9998/mathToImg
# onlyOffice在线编辑页Url
onlyOffice:
editorUrl: http://39.98.140.126:8999/editor?
previewUrl: http://39.98.140.126:8889/onlyOffice?
# 与比亚迪对接,调用的URL地址
byd:
uploadFileUrl: http://127.0.0.1:9998/ipd-files/file/v1/upload
saveBaseLineDocIdUrl: http://127.0.0.1:9998/api/qbp/organization/saveBaseLineDocId
splitResultUrl: http://127.0.0.1:9998/api/qbp/library/structured
downLoadFileUrl: http://127.0.0.1:9998/ipd-files/file/downLoad
@@ -1,5 +1,5 @@
server:
port: 8184
port: 8186
tomcat:
max-swallow-size: -1
error:
@@ -7,7 +7,7 @@ server:
include-stacktrace: ALWAYS
include-message: ALWAYS
servlet:
context-path: /laws-sinotruk
context-path: /byd-structuredplugins-serve
compression:
enabled: true
min-response-size: 1024
@@ -39,31 +39,31 @@ spring:
enable: true
required: true
## quartz定时任务,采用数据库方式
quartz:
job-store-type: jdbc
initialize-schema: embedded
#定时任务启动开关,true-开 false-关
auto-startup: true
#启动时更新己存在的Job
overwrite-existing-jobs: true
properties:
org:
quartz:
scheduler:
instanceName: MyScheduler
instanceId: AUTO
jobStore:
class: org.quartz.impl.jdbcjobstore.JobStoreTX
driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
tablePrefix: QRTZ_
isClustered: true
misfireThreshold: 60000
clusterCheckinInterval: 10000
threadPool:
class: org.quartz.simpl.SimpleThreadPool
threadCount: 10
threadPriority: 5
threadsInheritContextClassLoaderOfInitializingThread: true
# quartz:
# job-store-type: jdbc
# initialize-schema: embedded
# #定时任务启动开关,true-开 false-关
# auto-startup: true
# #启动时更新己存在的Job
# overwrite-existing-jobs: true
# properties:
# org:
# quartz:
# scheduler:
# instanceName: MyScheduler
# instanceId: AUTO
# jobStore:
# class: org.quartz.impl.jdbcjobstore.JobStoreTX
# driverDelegateClass: org.quartz.impl.jdbcjobstore.StdJDBCDelegate
# tablePrefix: QRTZ_
# isClustered: true
# misfireThreshold: 60000
# clusterCheckinInterval: 10000
# threadPool:
# class: org.quartz.simpl.SimpleThreadPool
# threadCount: 10
# threadPriority: 5
# threadsInheritContextClassLoaderOfInitializingThread: true
#json 时间戳统一转换
jackson:
date-format: yyyy-MM-dd HH:mm:ss
@@ -71,11 +71,20 @@ spring:
jpa:
open-in-view: false
activiti:
# 检测身份信息表是否存在
db-identity-used: false
database-schema-update: false
# 自动部署验证设置:true-开启(默认)、false-关闭
# 关闭activiti自动部署(使用流程设计器部署,不使用具体文件访问方式)
check-process-definitions: false
#启用作业执行器
# none:不保存任何的历史数据,因此,在流程执行过程中,这是最高效的。
# activity:级别高于none,保存流程实例与流程行为,其他数据不保存。
# audit:除activity级别会保存的数据外,还会保存全部的流程任务及其属性。audit为history的默认值。
# full:保存历史数据的最高级别,除了会保存audit级别的数据外,还会保存其他全部流程相关的细节数据,包括一些流程参数等。
history-level: full
#添加这个配置就不会一直调用了
#在流程引擎启动就激活AsyncExecutor,异步 true false 关闭(切记关闭)
async-executor-activate: false
#启用异步执行器
job-executor-activate: false
aop:
proxy-target-class: true
#配置freemarker
@@ -130,29 +139,18 @@ spring:
maxPoolPreparedStatementPerConnectionSize: 20
# 配置监控统计拦截的filters,去掉后监控界面sql无法统计,'wall'用于防火墙
filters: stat,slf4j
# 通过connectProperties属性来打开mergeSql功能;慢SQL记录
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000;druid.stat.logSlowSql\=true
datasource:
master:
url: jdbc:p6spy:mysql://10.186.40.44:8921/laws_sinotrunk_grp?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&autoReconnect=true
username: law_dev
password: Lawdev!@#1234
url: jdbc:p6spy:mysql://121.36.69.172:3307/laws_byd_structuredplugins_test?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true&autoReconnect=true
username: root
password: hzwlsoft.com
driver-class-name: com.p6spy.engine.spy.P6SpyDriver
# url: jdbc:mysql://127.0.0.1:3306/jero-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
# username: root
# password: 123456
# driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
#url: jdbc:mysql://localhost:3306/jero-boot2?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
#username: root
#password: root
#driver-class-name: com.mysql.cj.jdbc.Driver
#redis 配置
redis:
database: 8
host: 10.186.40.105
database: 11
host: 121.36.69.172
#host: localhost
lettuce:
pool:
max-active: 8 #最大连接数据库连接数,设 0 为没有限制
@@ -160,8 +158,10 @@ spring:
max-wait: -1ms #最大建立连接等待时间。如果超过此时间将接到异常。设为-1表示无限制。
min-idle: 0 #最小等待连接中的数量,设 0 为没有限制
shutdown-timeout: 100ms
password: 'nb!ydy%cGm82'
port: 20260
password: hzwlsoft.com
port: 4780
# port: 6379
#rabbitmq 配置
rabbitmq:
host: 121.36.69.172
@@ -206,12 +206,13 @@ jero:
backUrl: http://localhost:3000
backUrlPhone: http://localhost:3000
#拆分图片展示地址
splitUrl: http://laws-test.sinotruk.com/laws-sinotruk/sys/split/file/getImage?fileName=
splitUrl: http://39.98.140.126:8186/byd-structuredplugins-serve/sys/split/file/getImage?fileName=
path:
#文件上传根目录 设置
upload: /app/opt/upFiles
upload: D://opt//upFiles
img: /upFiles/
#webapp文件路径
webapp: /app/opt/webapp
webapp: D://opt//webapp
uploadCos: 1
#导出pdf临时文件路径 设置
exportPdfTempPath: D://opt//exportTemp/
@@ -233,7 +234,7 @@ jero:
username: grp
password: Grp2023.08
cluster-name: jero-ES
cluster-nodes: 10.186.43.11:9200
cluster-nodes: 10.10.10.45:7900
check-enabled: false
# 表单设计器配置
desform:
@@ -245,10 +246,10 @@ jero:
file-view-domain: 127.0.0.1:8012
# minio文件上传
minio:
minio_url: http://grp-minio.yf-grp:9000
minio_name: root
minio_pass: bpm@2023
bucketName: laws-sinotruk
minio_url: 47.92.92.38:9000
minio_name: admin
minio_pass: hzwlsoft.com
bucketName: byd-laws
#大屏报表参数设置
jmreport:
mode: dev
@@ -289,13 +290,12 @@ jero:
# 文件限制后缀黑名单
fileSuffixLimits : 0x00,%00,\\00,.jsp,.exe,.php,.asp,.aspx,.jspx,.xml,.html,.js,.sh,.bin,$DATA
# 跨站白名单
whiteUrls: localhost:3000,localhost:8080,localhost:62345,laws-test.sinotruk.com
# xss白名单
whiteUrls: localhost:62345,localhost:8186,localhost:8187,localhost:3435,localhost:3408,127.0.0.1:8080,10.0.3.23:3334,39.98.140.126:8187,47.92.92.38:8104,39.98.140.126:8999
xssExcludedPages: /login,/updatePassword
# cors白名单
notFilter:
# origin地址
originIp: http://localhost:3000,http://localhost:62345,http://laws-test.sinotruk.com
originIp: http://localhost:62345,http://localhost:8186,http://localhost:8187,http://localhost:3435,http://localhost:3408,http://127.0.0.1:8080,http://10.0.3.23:3334,http://39.98.140.126:8187,http://47.92.92.38:8104,http://39.98.140.126:8999
# 加密默认值
password:
pbe:
@@ -312,13 +312,11 @@ logging:
level:
com.jero.modules.system.mapper : info
#swagger
swagger:
enabled: false
knife4j:
#开启增强配置
enable: true
#开启生产环境屏蔽,为true,则knife4j无法访问
production: true
production: false
basic:
enable: false
username: jero
@@ -351,11 +349,11 @@ justauth:
file:
# 在线编辑文件下载映射地址
downloadUrl: http://localhost:8184/laws-sinotruk/file/
downloadUrl: http://39.98.140.126:8188/file/
split:
path: D://opt//onlyOffice//file//splitImage//
# 在线编辑空白docx地址
sourceFilePath: D://opt//onlyOffice//DOCX.docx
sourceFilePath: D://opt//onlyOffice//file//DOCX.docx
# 在线编辑本地存储地址
path: D:/opt/onlyOffice/file/
@@ -378,7 +376,7 @@ hiwork:
# 统一消息集成
messageUrl: taskapi/task.basedata/notice/noticeCalls/send
# 是否发送消息
isSend: true
isSend: false
# 汽车标准数字化平台ASMS
asms:
@@ -390,7 +388,6 @@ asms:
# token过期时间(单位:小时)
expire: 48
# 单点登录配置(所有配置信息需要协调注册,现在都为假)
# 单点登录配置(所有配置信息需要协调注册,现在都为假)
oauth:
# 客户端应用注册ID--客户申请的:SRMS
@@ -399,15 +396,16 @@ oauth:
clientSecret: 58a1001438de462193bec307826463c2
# 授权码验证
grantType: authorization_code
# 通过授权码获取accessToken请求地址 https://iam-uat.sinotruk.com:7011 --> https://iam-uat-new.sinotruk.com
accessTokenUrl: https://iam-uat.sinotruk.com:7011/idp/oauth2/getToken
# 通过accessToken获取账号信息请求地址 https://iam-uat.sinotruk.com:7011 --> https://iam-uat-new.sinotruk.com
userInfoUrl: https://iam-uat.sinotruk.com:7011/idp/oauth2/getUserInfo
# 通过授权码获取accessToken请求地址
accessTokenUrl: https://iam-uat-new.sinotruk.com/idp/oauth2/getToken
# 通过accessToken获取账号信息请求地址
userInfoUrl: https://iam-uat-new.sinotruk.com/idp/oauth2/getUserInfo
# 防止跨站请求伪造(CSRF)标识(暂时不用)
state: zhongQi
# 起草部门部门名称
draftDepartName: 流程与标准化
draftDepartName: 起草部门
# 管理员权限roleCode,多填用英文逗号拼接
adminRoleCode: admin
@@ -434,22 +432,22 @@ download:
# 办公域
scope_work: 52
# 水印配置项
watermark:
font-size: 13.0
# 每页几行
lineNumPerPage: 8
# 每页几列
columnNumPerPage: 2
# 倾斜角度
degree: 30
# 颜色
color:
r: 180
g: 180
b: 180
a: 1
# 页边距
margin:
top: 100
left: 60
# 特殊公式处理服务URL
mathToImg:
url: http://127.0.0.1:9998/mathToImg
# onlyOffice在线编辑页Url
onlyOffice:
editorUrl: http://39.98.140.126:8999/editor?
previewUrl: http://39.98.140.126:8889/onlyOffice?
# 与比亚迪对接,调用的URL地址
byd:
# uploadFileUrl: http://127.0.0.1:9998/ipd-files/file/v1/upload
# saveBaseLineDocIdUrl: http://127.0.0.1:9998/api/qbp/organization/saveBaseLineDocId
# splitResultUrl: http://127.0.0.1:9998/api/qbp/library/structured
# downLoadFileUrl: http://127.0.0.1:9998/ipd-files/file/downLoad
# 开发环境
uploadFileUrl: http://127.0.0.1:9998/uploadFileUrl
saveBaseLineDocIdUrl: http://127.0.0.1:9998/saveBaseLineDocIdUrl
splitResultUrl: http://127.0.0.1:9998/splitResultUrl
downLoadFileUrl: http://127.0.0.1:9998/downLoadFileUrl
@@ -1,5 +1,5 @@
spring:
application:
name: laws-sinotruk
name: byd-structuredplugins-serve
profiles:
active: dev
active: dev
@@ -459,7 +459,7 @@ export default {
},
handleExportXls () {
const fileName = '全文比对信息'
const fileSuffix = '.xlsx'
const fileSuffix = '.xls'
const param = {}
param.id = this.$route.query.id
param.exportName = fileName + fileSuffix