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

提交

上级 0ee8d549
package org.jeecg.modules.stm.api;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.jeecg.common.api.vo.Result;
import org.jeecg.config.shiro.IgnoreAuth;
import org.jeecg.modules.stm.metric.entity.MetricMonitorSet;
import org.jeecg.modules.stm.metric.entity.MetricReport;
import org.jeecg.modules.stm.metric.service.IMetricMonitorSetService;
import org.jeecg.modules.stm.metric.service.IMetricReportService;
import org.jeecg.modules.stm.my.entity.MyTask;
import org.jeecg.modules.stm.my.service.IMyTaskService;
import org.jeecg.modules.stm.page.entity.PageMonitorchart;
import org.jeecg.modules.stm.page.entity.PageTitleconfig;
import org.jeecg.modules.stm.page.service.IPageMonitorchartService;
import org.jeecg.modules.stm.page.service.IPageTitleconfigService;
import org.jeecg.modules.stm.rectify.approve.entity.StRectifyApprove;
import org.jeecg.modules.stm.rectify.approve.service.IStRectifyApproveService;
import org.jeecg.modules.stm.rectify.assin.entity.StProblemTaskAssin;
import org.jeecg.modules.stm.rectify.assin.service.IStProblemTaskAssinService;
import org.jeecg.modules.stm.rectify.exec.service.IStRectifyExecService;
import org.jeecg.modules.stm.rectify.plan.entity.StRectifyPlan;
import org.jeecg.modules.stm.rectify.plan.service.IStRectifyPlanService;
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.RestController;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;
@RestController
@RequestMapping("/api/bigscreen/")
public class BigScreenAPIController {
@Autowired
private IPageTitleconfigService pageTitleconfigService;
@Autowired
private IMyTaskService myTaskService;
@Autowired
private IStProblemTaskAssinService stProblemTaskAssinService;
@Autowired
private IStRectifyApproveService stRectifyApproveService;
@Autowired
private IStRectifyExecService stRectifyExecService;
@Autowired
private IStRectifyPlanService iStRectifyPlanService;
@Autowired
private IPageMonitorchartService pageMonitorchartService;
@Autowired
private IMetricReportService metricReportService;
@Autowired
private IMetricMonitorSetService metricMonitorSetService;
@IgnoreAuth
@GetMapping(value = "/getBaseInfoList")
public Result<Map<Integer,List<PageTitleconfig>>> getBaseInfoList() {
QueryWrapper<PageTitleconfig> queryWrapperCfg = new QueryWrapper<>();
queryWrapperCfg.orderByAsc("show_sort");
List<PageTitleconfig> pageList = pageTitleconfigService.list(queryWrapperCfg);
Map<Integer,List<PageTitleconfig>> retMap = new HashMap<>();
List<PageTitleconfig> orgList = new ArrayList<>();
List<PageTitleconfig> techList = new ArrayList<>();
List<Map<String, String>> retList = new ArrayList<>();
if(pageList!=null && pageList.size()!=0) {
List<Map<String,Object>> listData =pageTitleconfigService.getFirstPageFxcStat();
Map<Integer,String> tmpMap = new HashMap<>();
for (Map<String,Object> cnt : listData) {
Integer dtId = Integer.valueOf(cnt.get("itemid").toString());
if (tmpMap.get(dtId) != null) {
continue;
}
if(cnt.get("content")!=null){
tmpMap.put(dtId, cnt.get("content").toString());
}
}
for(PageTitleconfig cfg:pageList) {
Integer dtId = cfg.getTplItemDtId();
String val = tmpMap.get(dtId);
if(val!=null&&!val.equals("null")) {
cfg.setDefaultVal(val);
}
if(cfg.getTp().intValue()==1) {
orgList.add(cfg);
} else {
techList.add(cfg);
}
}
}
retMap.put(1,orgList);
retMap.put(2,techList);
return Result.OK(retMap);
}
@GetMapping(value = "/getMyTask")
public Result<List> getMyTask() {
//获取待办事项列表,待审批和待填报
QueryWrapper<MyTask> queryWrapper = new QueryWrapper();
queryWrapper.eq("sta",0).orderByDesc("priority");
queryWrapper.last("limit 4");
List<MyTask> list = myTaskService.list(queryWrapper);
return Result.OK(list);
}
@RequestMapping(value = "/getPageStatProblemLevel")
public Result<?> getPageStatProblemLevel() {
List<Map<String,Object>> list = stProblemTaskAssinService.statProblemLevel();
return Result.ok(list);
}
@RequestMapping(value = "/problemStat")
public Result<?> problemStat(HttpServletResponse response) {
//@ApiModelProperty(value = "审核标志;0 未开始 1 待审核、2 已完成、3 已驳回")
long total = stProblemTaskAssinService.count();
//接收即确认的问题数
QueryWrapper<StProblemTaskAssin> queryWrapper = new QueryWrapper<>();
queryWrapper.ne("receive_status","1").or().eq("assin_status","0").or().isNull("receive_status");
//未分配的
long noAssignNm = stProblemTaskAssinService.count(queryWrapper); //已经分配,但未接收
QueryWrapper<StRectifyApprove> queryApproveWrapper = new QueryWrapper<>();
queryApproveWrapper.eq("approve_flag","3");
long finishNm = stRectifyApproveService.count(queryApproveWrapper);
long execNm = stRectifyExecService.count();
QueryWrapper<StRectifyPlan> queryPlanWrapper = new QueryWrapper<>();
queryPlanWrapper.ne("edit_flag","1");
long planNm = iStRectifyPlanService.count(queryPlanWrapper);
Map<String,Object> retMap = new LinkedHashMap<>();
retMap.put("total",total);
retMap.put("execNm",(execNm-finishNm));
retMap.put("finishNm",finishNm);
retMap.put("planNm",planNm);
retMap.put("noAssignNm",noAssignNm);
return Result.OK(retMap);
}
@RequestMapping(value = "/getPageChartData")
public Result<?> getPageCharData(HttpServletRequest request, HttpServletResponse response) {
List<PageMonitorchart> listData = pageMonitorchartService.list();
return Result.OK(listData);
}
@GetMapping(value = "/getMtricDataByMtrcNo")
public Result<?> getMtricDataByMtrcNo(String mtrcNo) {
QueryWrapper<MetricReport> queryWrapper = new QueryWrapper();
queryWrapper.eq("mtrc_no",mtrcNo);
//queryWrapper.ge("fill_time",mc.getYear());
queryWrapper.orderByAsc("fill_time");
List<MetricReport> metrcList = metricReportService.list(queryWrapper);
Map<String,Object> retMap = new HashMap<>();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
List<Float> retList = new ArrayList<>();
List<Object> retWarnList = new ArrayList<>();
List<Object> retIntvList = new ArrayList<>();
List<Object> retTolList = new ArrayList<>();
List<String> category = new ArrayList<>();
MetricMonitorSet metrcSet = getMetricMonitorSet(mtrcNo);
Float warnVal = metrcSet.getWarnVal();
Float intvVal = metrcSet.getIntvVal();
if(warnVal!=null){
for(MetricReport mr:metrcList){
retWarnList.add(warnVal);
}
retMap.put("warn",retWarnList);
}
if(intvVal!=null){
for(MetricReport mr:metrcList){
retIntvList.add(intvVal);
}
retMap.put("intv",retIntvList);
}
for(MetricReport mr:metrcList){
if(mr.getFillVals()==null)continue;
category.add(sdf.format(mr.getFillTime()));
retList.add(Float.parseFloat(mr.getFillVals()));
retTolList.add(metrcSet.getTolVal());
}
retMap.put("mtrc",retList);
retMap.put("tol",retTolList);
retMap.put("category",category);
retMap.put("unit",metrcSet.getUnit());
if(retList.size()>0) {
float max = Collections.max(retList);
float min = Collections.min(retList);
List<Float> tmpList = new ArrayList<>();
tmpList.add(max);
tmpList.add(min);
if(warnVal!=null) {
tmpList.add(warnVal);
}
if(intvVal!=null) {
tmpList.add(intvVal);
}
max = Collections.max(tmpList);
min = Collections.min(tmpList);
retMap.put("min",min);
retMap.put("max",max);
}
retMap.put("interval",metrcSet.getUnit());
return Result.OK(retMap);
}
private MetricMonitorSet getMetricMonitorSet(String mtricNo) {
QueryWrapper<MetricMonitorSet> queryWrapper = new QueryWrapper();
queryWrapper.eq("mtrc_no",mtricNo);
MetricMonitorSet metrcSet =metricMonitorSetService.getOne(queryWrapper);
return metrcSet;
}
@GetMapping(value = "/getMtricDataMultMtrc")
public Result<?> getMtricDataMultMtrc() {
Map<String,List<Map<String,Object>>> retMap = new HashMap<>();
List<Map<String,Object>> listData = pageMonitorchartService.queryMulMetrcSta();
Map<String, List<Map<String, Object>>> groupedByMtrcNo = listData.stream()
.collect(Collectors.groupingBy(record -> (String) record.get("mtrcNo")));
return Result.OK(groupedByMtrcNo);
}
@GetMapping(value = "/getBaosongJggm")
public Map<String,String> getBaosongJggm() {
Map<String,String> retMap = new HashMap<>();
retMap.put("C23A001","888");
retMap.put("C23A002","999");
return retMap;
}
@GetMapping(value = "/getBaosongDsh")
public List<Map<String,String>> getBaosongDsh() {
List<Map<String,String>> retList = new ArrayList<>();
Map<String,String> map1 = new HashMap<>();
map1.put("code","C20A001");
map1.put("type","number");
map1.put("unit","次");
map1.put("val","10");
map1.put("name","本年度董事会召开涉及信息科技议题的会议数量");
retList.add(map1);
Map<String,String> map2 = new HashMap<>();
map2.put("code","C20A003");
map2.put("type","boolean");
map2.put("val","是");
map2.put("unit","");
map2.put("name","本年度董事会(含授权的风险管理委员会)审阅信息科技风险管理报告");
retList.add(map2);
return retList;
}
}
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.Consts;
import org.apache.http.HttpStatus;
import org.apache.http.NameValuePair;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class HttpClientUtil {
private static final Logger logger = LoggerFactory.getLogger(HttpClientUtil.class);
public static String doGet(String url, String data, String header, String context1) {
CloseableHttpClient httpClient = HttpConnectionManager.getHttpClient();
String resultString = "";
HttpGet httpGet = new HttpGet(url);
if (!DataType.IsNullOrEmpty(header) && !DataType.IsNullOrEmpty(context1)) {
httpGet.setHeader(header, context1);
}
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES) {
resultString = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} else {
logger.error("执行 GET 请求至 {} 失败,状态码: {}", url, statusCode);
EntityUtils.consumeQuietly(response.getEntity());
}
} catch (IOException | IllegalArgumentException e) {
logger.error("执行 GET 请求至 {} 时发生错误", url, e);
} catch (Exception e) {
logger.error("执行 GET 请求至 {} 时发生意外错误", url, e);
}
return resultString;
}
public static String doGetSSL(String url, Map<String, String> headerMap, Map<String, String> param) {
CloseableHttpClient httpClient = HttpConnectionManager.getHttpClient();
String resultString = "";
URI uri = null;
try {
URIBuilder builder = new URIBuilder(url);
if (param != null) {
for (Map.Entry<String, String> entry : param.entrySet()) {
builder.addParameter(entry.getKey(), entry.getValue());
}
}
uri = builder.build();
} catch (URISyntaxException e) {
logger.error("为 GET SSL 请求构建 URI 时出错: {}", url, e);
return "";
}
HttpGet httpGet = new HttpGet(uri);
if (headerMap != null) {
for (Map.Entry<String, String> entry : headerMap.entrySet()) {
httpGet.setHeader(entry.getKey(), entry.getValue());
}
}
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES) {
resultString = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} else {
logger.error("执行 GET SSL 请求至 {} 失败,状态码: {}", uri, statusCode);
EntityUtils.consumeQuietly(response.getEntity());
}
} catch (IOException e) {
logger.error("执行 GET SSL 请求至 {} 时发生错误", uri, e);
} catch (Exception e) {
logger.error("执行 GET SSL 请求至 {} 时发生意外错误", uri, e);
}
return resultString;
}
public static String doGet(String url) {
return doGet(url, null, null, null);
}
public static String doPostSSL(String url, String Json, Map<String, String> headerParam) {
CloseableHttpClient httpClient = HttpConnectionManager.getHttpClient();
String resultString = "";
HttpPost httpPost = getHttpPost(url, Json, headerParam);
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES) {
resultString = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} else if (statusCode == HttpStatus.SC_MOVED_TEMPORARILY || statusCode == HttpStatus.SC_MOVED_PERMANENTLY) {
logger.info("执行 POST SSL 请求至 {} 时发生重定向,状态码: {}", url, statusCode);
resultString = "";
EntityUtils.consumeQuietly(response.getEntity());
} else {
logger.error("执行 POST SSL 请求至 {} 失败,状态码: {}", url, statusCode);
EntityUtils.consumeQuietly(response.getEntity());
}
} catch (IOException e) {
logger.error("执行 POST SSL 请求至 {} 时发生错误", url, e);
} catch (Exception e) {
logger.error("执行 POST SSL 请求至 {} 时发生意外错误", url, e);
}
return resultString;
}
private static HttpPost getHttpPost(String url, String Json, Map<String, String> headerParam) {
HttpPost httpPost = new HttpPost(url);
httpPost.setHeader("Content-Type", "application/json");
handleParams(Json, headerParam, httpPost);
return httpPost;
}
public static String doPost(String url, Map<String, String> param, String header, String context1) {
CloseableHttpClient httpClient = HttpConnectionManager.getHttpClient();
String resultString = "";
HttpPost httpPost = new HttpPost(url);
if (!DataType.IsNullOrEmpty(header) && !DataType.IsNullOrEmpty(context1)) {
httpPost.setHeader(header, context1);
}
if (param != null && !param.isEmpty()) {
List<NameValuePair> paramList = new ArrayList<>();
for (Map.Entry<String, String> entry : param.entrySet()) {
paramList.add(new BasicNameValuePair(entry.getKey(), entry.getValue()));
}
try {
UrlEncodedFormEntity entity = new UrlEncodedFormEntity(paramList, Consts.UTF_8);
httpPost.setEntity(entity);
} catch (Exception e) {
logger.error("为 POST 请求至 {} 编码表单参数时出错", url, e);
return "";
}
}
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES) {
resultString = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} else if (statusCode == HttpStatus.SC_MOVED_TEMPORARILY || statusCode == HttpStatus.SC_MOVED_PERMANENTLY) {
logger.info("执行 POST (带 context) 请求至 {} 时发生重定向,状态码: {}", url, statusCode);
resultString = "";
EntityUtils.consumeQuietly(response.getEntity());
} else {
logger.error("执行 POST (带 context) 请求至 {} 失败,状态码: {}", url, statusCode);
EntityUtils.consumeQuietly(response.getEntity());
}
} catch (IOException e) {
logger.error("执行 POST (带 context) 请求至 {} 时发生错误", url, e);
} catch (Exception e) {
logger.error("执行 POST (带 context) 请求至 {} 时发生意外错误", url, e);
}
return resultString;
}
public static String doPost(String url, String Json, Map<String, String> headerParam) throws Exception {
CloseableHttpClient httpClient = HttpConnectionManager.getHttpClient();
String resultString = "";
URI uri;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
logger.error("为 POST 请求 (带 JSON) 提供无效的 URI 语法: {}", url, e);
throw new Exception("URL 语法无效: " + url, e);
}
HttpPost httpPost = new HttpPost(uri);
handleParams(Json, headerParam, httpPost);
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES) {
resultString = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} else if (statusCode == HttpStatus.SC_MOVED_TEMPORARILY || statusCode == HttpStatus.SC_MOVED_PERMANENTLY) {
logger.info("执行 POST (带 JSON) 请求至 {} 时发生重定向,状态码: {}", url, statusCode);
resultString = "";
EntityUtils.consumeQuietly(response.getEntity());
} else {
String errorMsg = String.format("执行 POST (带 JSON) 请求至 %s 失败,状态码: %d", url, statusCode);
logger.error(errorMsg);
EntityUtils.consumeQuietly(response.getEntity());
throw new Exception(errorMsg);
}
} catch (IOException e) {
logger.error("执行 POST (带 JSON) 请求至 {} 时发生 IO 错误", url, e);
throw e;
} catch (Exception e) {
logger.error("执行 POST (带 JSON) 请求至 {} 时发生意外错误", url, e);
if (!(e instanceof URISyntaxException)) {
throw e;
} else {
throw new Exception("执行 POST 请求时出错", e);
}
}
return resultString;
}
private static void handleParams(String Json, Map<String, String> headerParam, HttpPost httpPost) {
if (headerParam != null) {
for (Map.Entry<String, String> entry : headerParam.entrySet()) {
httpPost.setHeader(entry.getKey(), entry.getValue());
}
}
if (Json != null) {
StringEntity entity = new StringEntity(Json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
}
}
public static String doPost(String url) {
return doPost(url, null, null, null);
}
public static String doPostJson(String url, String json) {
CloseableHttpClient httpClient = HttpConnectionManager.getHttpClient();
String resultString = "";
HttpPost httpPost = new HttpPost(url);
if (json != null) {
StringEntity entity = new StringEntity(json, ContentType.APPLICATION_JSON);
httpPost.setEntity(entity);
}
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getStatusLine().getStatusCode();
if (statusCode >= HttpStatus.SC_OK && statusCode < HttpStatus.SC_MULTIPLE_CHOICES) {
resultString = EntityUtils.toString(response.getEntity(), Consts.UTF_8);
} else {
logger.error("执行 POST JSON (简化版) 请求至 {} 失败,状态码: {}", url, statusCode);
EntityUtils.consumeQuietly(response.getEntity());
}
} catch (IOException e) {
logger.error("执行 POST JSON (简化版) 请求至 {} 时发生错误", url, e);
} catch (Exception e) {
logger.error("执行 POST JSON (简化版) 请求至 {} 时发生意外错误", url, e);
}
return resultString;
}
}
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论