提交 05bcf8a9 authored 作者: kxjia's avatar kxjia

提交

上级 0ee8d549
package org.jeecg.modules.stm.api;
public class DBAccess {
public static String GenerMD5(String str){
return GenerMD5(str, false);
}
public static String GenerMD5(String str,boolean islower)
{
if (islower == true)
return MD5Utill.MD52X_Encrypt(str).toLowerCase();
else
return MD5Utill.MD52X_Encrypt(str);
}
}
package org.jeecg.modules.stm.api;
import java.text.SimpleDateFormat;
import java.util.Date;
public class DataType {
public static boolean IsNullOrEmpty(Object object) {
return object == null || object.equals("") || object.equals("null");
}
public static String getCurrentDateByFormart(String formart) {
Date dt = new Date();
SimpleDateFormat matter = new SimpleDateFormat(formart);
String date = matter.format(dt);
return date;
}
}
package org.jeecg.modules.stm.api;
import org.apache.http.client.config.CookieSpecs;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.config.Registry;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.config.SocketConfig;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import javax.net.ssl.SSLContext;
import java.io.IOException;
import java.security.NoSuchAlgorithmException;
import java.util.concurrent.TimeUnit;
public class HttpConnectionManager {
private static final PoolingHttpClientConnectionManager connectionManager;
private static final CloseableHttpClient httpClient;
private static final IdleConnectionMonitorThread monitorThread;
static {
try {
SSLConnectionSocketFactory factory = new SSLConnectionSocketFactory(SSLContext.getDefault());
Registry<ConnectionSocketFactory> socketFactoryRegistry = RegistryBuilder.<ConnectionSocketFactory>create()
.register("https", factory)
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.build();
connectionManager = new PoolingHttpClientConnectionManager(socketFactoryRegistry);
connectionManager.setMaxTotal(200);
connectionManager.setDefaultMaxPerRoute(20);
// 设置连接存活策略
SocketConfig socketConfig = SocketConfig.custom()
.setSoTimeout(30000)
.build();
connectionManager.setDefaultSocketConfig(socketConfig);
// 设置连接闲置策略
connectionManager.setValidateAfterInactivity(10000);
// 设置请求配置
RequestConfig requestConfig = RequestConfig.custom()
.setCookieSpec(CookieSpecs.STANDARD)
.setConnectTimeout(5000)
.setSocketTimeout(30000)
.setConnectionRequestTimeout(5000)
.build();
// 创建一个单例的HttpClient
httpClient = HttpClients.custom()
.setConnectionManager(connectionManager)
.setDefaultRequestConfig(requestConfig)
.setConnectionManagerShared(true)
.build();
// 启动一个守护线程来清理过期和闲置连接
monitorThread = new IdleConnectionMonitorThread(connectionManager);
monitorThread.setDaemon(true);
monitorThread.start();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("Failed to initialize HttpConnectionManager", e);
}
}
public static CloseableHttpClient getHttpClient() {
return httpClient;
}
/**
* 关闭连接管理器和相关资源。
* 应用程序在关闭时应该调用此方法。
*/
public static void shutdown() {
if (monitorThread != null) {
monitorThread.shutdown();
}
try {
if (httpClient != null) {
httpClient.close();
}
if (connectionManager != null) {
connectionManager.close();
}
} catch (IOException e) {
// 记录日志但不抛出异常
e.printStackTrace();
}
}
// 注册JVM关闭钩子来关闭连接管理器
static {
Runtime.getRuntime().addShutdownHook(new Thread(HttpConnectionManager::shutdown));
}
// 闲置连接监控线程
private static class IdleConnectionMonitorThread extends Thread {
private final PoolingHttpClientConnectionManager connectionManager;
private volatile boolean shutdown;
public IdleConnectionMonitorThread(PoolingHttpClientConnectionManager connectionManager) {
super("idle-connection-monitor");
this.connectionManager = connectionManager;
}
@Override
public void run() {
try {
while (!shutdown) {
synchronized (this) {
wait(5000);
// 关闭过期连接
connectionManager.closeExpiredConnections();
// 关闭空闲超过30秒的连接
connectionManager.closeIdleConnections(30, TimeUnit.SECONDS);
}
}
} catch (InterruptedException ex) {
// 终止
}
}
public void shutdown() {
shutdown = true;
synchronized (this) {
notifyAll();
}
}
}
}
package org.jeecg.modules.stm.api;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/api/jflow")
public class JFlowAPIController {
@Autowired
private RedisUtil redisUtil;
@GetMapping(value = "/getUserTokey")
public Result<?> getUserTokey(@RequestParam(name="Token",required=true) String Token) {
Object username = redisUtil.get(Token);
if(username==null){
return Result.OK("");
}
Object tokenpt = redisUtil.get( "pt_"+username.toString());
System.out.println("getUserTokey "+tokenpt.toString());
redisUtil.set("TokenUser",username.toString());
return Result.OK(tokenpt);
}
}
package org.jeecg.modules.stm.api;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
public class MD5Utill {
public static String byteArrayToHexString(byte b[]) {
StringBuffer resultSb = new StringBuffer();
for (int i = 0; i < b.length; i++){
resultSb.append(byteToHexString(b[i]));
}
return resultSb.toString();
}
private static String byteToHexString(byte b) {
int n = b;
if (n < 0) {
n += 256;
}
int d1 = n / 16;
int d2 = n % 16;
return hexDigits[d1] + hexDigits[d2];
}
public static String MD5Encode(String origin, String charsetname) {
String resultString = null;
try {
resultString = new String(origin);
MessageDigest md = MessageDigest.getInstance("MD5");
if (charsetname == null || "".equals(charsetname)) {
resultString = byteArrayToHexString(md.digest(resultString.getBytes()));
} else {
resultString = byteArrayToHexString(md.digest(resultString.getBytes(charsetname)));
}
} catch (Exception exception) {
}
return resultString;
}
public static String MD52X_Encrypt(String origin ) {
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(origin.getBytes());
byte[] digest = md.digest();
StringBuilder sb = new StringBuilder();
for (byte b : digest) {
//16进制 不足2位前面补0
sb.append(String.format("%02x", b));
}
return sb.toString().toUpperCase();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
return null;
}
}
private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
"6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };
public static void main(String[] args) {
String pwd="123";
String pwd1=MD52X_Encrypt(pwd);
System.out.println(pwd1);
}
}
\ No newline at end of file
......@@ -7,7 +7,7 @@ server:
include-stacktrace: ALWAYS
include-message: ALWAYS
servlet:
context-path: /jeecg-boot
context-path: /stm
compression:
enabled: true
min-response-size: 1024
......@@ -20,13 +20,16 @@ management:
include: metrics,httpexchanges,jeecghttptrace
spring:
# main:
# # 启动加速 (建议开发环境,开启后flyway自动升级失效)
# lazy-initialization: true
flyway:
# 是否启用flyway
enabled: false
# 是否关闭要清除已有库下的表功能,生产环境必须为true,否则会删库,非常重要!!!
clean-disabled: true
# 迁移sql脚本存放路径
locations: classpath:flyway/sql/mysql
# 是否关闭要清除已有库下的表功能,生产环境必须为true,否则会删库,非常重要!!!
clean-disabled: true
servlet:
multipart:
max-file-size: 10MB
......@@ -38,14 +41,18 @@ spring:
username: jeecgos@163.com
password: ??
properties:
mail.smtp.timeout: 10000 # 连接超时(毫秒)
mail.smtp.connectiontimeout: 10000 # 连接超时(毫秒)
mail.smtp.writetimeout: 10000 # 写入超时(毫秒)
mail.smtp.auth: true
smtp.ssl.enable: true
# mail.debug: true # 启用调试模式(查看详细日志)
## quartz定时任务,采用数据库方式
quartz:
job-store-type: jdbc
jdbc:
initialize-schema: embedded
#定时任务开关,true-开 false-关
#定时任务启动开关,true-开 false-关
auto-startup: true
#延迟1秒启动定时任务
startup-delay: 1s
......@@ -126,7 +133,7 @@ spring:
timeBetweenEvictionRunsMillis: 60000
# 配置一个连接在池中最小生存的时间,单位是毫秒
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
validationQuery: SELECT 1
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
......@@ -140,30 +147,27 @@ spring:
selectWhereAlwayTrueCheck: false
# 打开mergeSql功能;慢SQL记录
stat:
merge-sql: true
merge-sql: false
slow-sql-millis: 5000
datasource:
master:
url: jdbc:mysql://127.0.0.1:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
url: jdbc:mysql://127.0.0.1:3306/zrch_stm_db_3.9?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
username: root
password: root
password: ZhongRunChangHong/123
driver-class-name: com.mysql.cj.jdbc.Driver
# 多数据源配置
#multi-datasource1:
#url: jdbc:mysql://localhost:3306/jeecg-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 配置
data:
redis:
database: 0
host: 127.0.0.1
port: 6379
password:
password: 9vsNe85pUWRrsF5z
#mybatis plus 设置
mybatis-plus:
mapper-locations: classpath*:org/jeecg/**/xml/*Mapper.xml
mapper-locations:
- classpath*:org/jeecg/**/xml/*Mapper.xml
- classpath*:mapping/**/*Mapper.xml
- classpath:org/jeecg/modules/flowable/apithird/business/mapper/*Mapper.xml
global-config:
# 关闭MP3.0自带的banner
banner: false
......@@ -180,13 +184,15 @@ mybatis-plus:
#jeecg专用配置
minidao:
base-package: org.jeecg.modules.jmreport.*,org.jeecg.modules.drag.*
# base-package: org.jeecg.modules.jmreport.desreport.*,org.jeecg.modules.drag.*
# exclude-package: org.jeecg.modules.jmreport.calcite.*,org.jeecg.modules.jmreport.dyndb.*
jeecg:
# AI集成
ai-chat:
enabled: true
model: deepseek-chat
apiKey: ??
apiHost: https://api.deepseek.com
apiHost: https://api.deepseek.com/v1
timeout: 60
# AIRag向量库
ai-rag:
......@@ -203,28 +209,28 @@ jeecg:
# 平台上线安全配置
firewall:
# 数据源安全 (开启后,Online报表和图表的数据源为必填)
dataSourceSafe: true
dataSourceSafe: false
# 低代码模式(dev:开发模式,prod:发布模式——关闭所有在线开发配置能力)
lowCodeMode: prod
lowCodeMode: dev
# 是否允许同一账号多地同时登录 (为 true 时允许一起登录, 为 false 时新登录挤掉旧登录)
is-concurrent: true
# 签名密钥串(前后端要一致,正式发布请自行修改)
signatureSecret: dd05f1c54d63749eda95f9fa6d49v442a
#签名拦截接口
signUrls: /sys/dict/getDictItems/*,/sys/dict/loadDict/*,/sys/dict/loadDictOrderByValue/*,/sys/dict/loadDictItem/*,/sys/dict/loadTreeData,/sys/api/queryTableDictItemsByCode,/sys/api/queryFilterTableDictInfo,/sys/api/queryTableDictByKeys,/sys/api/translateDictFromTable,/sys/api/translateDictFromTableByKeys,/sys/sendChangePwdSms,/sys/user/sendChangePhoneSms,/sys/sms,/desform/api/sendVerifyCode
# local\minio\alioss
uploadType: alioss
# 本地:local、Minio:minio、阿里云:alioss
uploadType: local
# 前端访问地址
domainUrl:
pc: http://localhost:3100
app: http://localhost:8051
path:
#文件上传根目录 设置
upload: /opt/jeecg-boot/upload
upload: /opt/upFiles
#webapp文件路径
webapp: /opt/jeecg-boot/webapp
webapp: /opt/webapp
shiro:
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**,/api/getUserInfo
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
# 短信发送方式 aliyun阿里云短信 tencent腾讯云短信
smsSendType: aliyun
#阿里云oss存储和大鱼短信秘钥配置
......@@ -233,7 +239,6 @@ jeecg:
secretKey: ??
endpoint: oss-cn-beijing.aliyuncs.com
bucketName: jeecgdev
staticDomain: https://static.jeecg.com
# 短信模板
sms-template:
# 签名
......@@ -246,7 +251,6 @@ jeecg:
SMS_465391221:
# 注册账号短信模板编码
SMS_175430166:
SMS_461885023:
#腾讯短信秘钥配置
tencent:
# 接入域名
......@@ -272,9 +276,9 @@ jeecg:
# 平台上线安全配置(v1.6.2+ 新增)
firewall:
# 数据源安全 (开启后,不允许使用平台数据源、SQL解析加签并且不允许查询数据库)
dataSourceSafe: true
dataSourceSafe: false
# 低代码开发模式(dev:开发模式,prod:发布模式—关闭在线报表设计功能,分配角色admin、lowdeveloper可以放开限制)
lowCodeMode: prod
lowCodeMode: dev
# 高德地图Api配置(v2.1.3+ BI新增高德地图)
gao-de-api:
# 应用key
......@@ -303,23 +307,32 @@ jeecg:
app-id: ??
api-key: ??
secret-key: ??
elasticsearch:
cluster-name: risk
cluster-nodes: 47.110.158.206:9200
check-enabled: false
#cas单点登录
cas:
prefixUrl: http://cas.example.org:8443/cas
#Mybatis输出sql日志
logging:
file:
name: logs/application.log
level:
org.flowable: error
org.springframework.context.support.PostProcessorRegistrationDelegate: error
org.flywaydb: debug
org.jeecg.modules.system.mapper: info
org.flywaydb: error
org.jeecg.modules.system.mapper: debug
# org.jeecg.modules.demo.test.mapper: info
#swagger
knife4j:
#开启增强配置
enable: true
#开启生产环境屏蔽
production: true
production: false
basic:
enable: true
enable: false
username: jeecg
password: jeecg1314
#第三方登录
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论