Compare commits
38 Commits
Author | SHA1 | Date |
---|---|---|
|
6b0232e12d | |
|
f9b2ebaa7f | |
|
ffb86f43fa | |
|
f73d39fe1c | |
|
5a63afd7d8 | |
|
21007598a9 | |
|
c943cd82fb | |
|
ed5d7fff69 | |
|
1d979524f3 | |
|
23d06b59bb | |
|
5eea8dfb96 | |
|
90386c59a5 | |
|
aa591dc1ff | |
|
ae266436d9 | |
|
62cf866111 | |
|
351a7e7a7a | |
|
5f6648144c | |
|
f582a9601c | |
|
c398ecde8b | |
|
0baa4e0bf3 | |
|
3bddc46c9a | |
|
5ff781e133 | |
|
cff92f2399 | |
|
a778197694 | |
|
61b0cdfaee | |
|
fa2583176e | |
|
165e548056 | |
|
d9405aad90 | |
|
2874005465 | |
|
6e0b588959 | |
|
55aa4c4a92 | |
|
44fb1eaca1 | |
|
f0db5772a2 | |
|
482f0533c4 | |
|
6e6d219719 | |
|
0e471d20a3 | |
|
f33447e4f2 | |
|
cb58463319 |
|
@ -60,3 +60,9 @@ $RECYCLE.BIN/
|
|||
/common/target/
|
||||
/buildpackage/target/
|
||||
/webapp/target/
|
||||
/base-buildpackage/target/
|
||||
/base-common/target/
|
||||
/base-core/target/
|
||||
/base-webapp/target/classes/com/hzya/frame/
|
||||
/fw-weixin/target/
|
||||
/E:/yongansystem/log/2024-10-15/
|
||||
|
|
|
@ -0,0 +1,53 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>kangarooDataCenterV3</artifactId>
|
||||
<groupId>com.hzya.frame</groupId>
|
||||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>base-buildpackage</artifactId>
|
||||
<packaging>war</packaging>
|
||||
<version>${revision}</version>
|
||||
<!-- 统一管理依赖版本-->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.hzya.frame</groupId>
|
||||
<artifactId>base-webapp</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>dev</id> <!--开发环境-->
|
||||
<properties>
|
||||
<profile.active>dev</profile.active>
|
||||
</properties>
|
||||
<activation>
|
||||
<activeByDefault>true</activeByDefault>
|
||||
</activation>
|
||||
</profile>
|
||||
|
||||
|
||||
<profile>
|
||||
<id>llg</id> <!--吕磊钢-->
|
||||
<properties>
|
||||
<profile.active>llg</profile.active>
|
||||
</properties>
|
||||
</profile>
|
||||
<profile>
|
||||
<id>zqtlocal</id> <!--曾庆拓-->
|
||||
<properties>
|
||||
<profile.active>zqtlocal</profile.active>
|
||||
</properties>
|
||||
</profile>
|
||||
|
||||
</profiles>
|
||||
<build>
|
||||
<finalName>kangarooDataCenterV3</finalName>
|
||||
</build>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,386 @@
|
|||
package com.hzya.frame.plugin.BackUpDatabase.plugin;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
|
||||
import com.jcraft.jsch.Channel;
|
||||
import com.jcraft.jsch.ChannelSftp;
|
||||
import com.jcraft.jsch.JSch;
|
||||
import com.jcraft.jsch.Session;
|
||||
import com.jcraft.jsch.SftpATTRS;
|
||||
import com.jcraft.jsch.SftpException;
|
||||
import org.apache.commons.net.ftp.FTPClient;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.nio.file.Files;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Properties;
|
||||
|
||||
|
||||
/**
|
||||
* 主数据模版(MdmModule)表服务接口
|
||||
*
|
||||
* @author makejava
|
||||
* @since 2024-06-18 10:33:32
|
||||
*/
|
||||
public class BackUpDatabaseInitializer extends PluginBaseEntity {
|
||||
Logger logger = LoggerFactory.getLogger(BackUpDatabaseInitializer.class);
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "BackUpDatabasePlugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "数据库备份下发";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "BackUpDatabasePlugin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginType() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
@Value("${database.filePase:}")
|
||||
private String filePase;//文件保存路径
|
||||
|
||||
@Value("${database.fileName:data.sql}")
|
||||
private String fileName;//文件保存名称
|
||||
|
||||
@Value("${database.databaseName:}")
|
||||
private String databaseName;//库名
|
||||
|
||||
@Value("${database.host:}")
|
||||
private String host;//地址
|
||||
|
||||
@Value("${database.port:}")
|
||||
private String port;//端口
|
||||
|
||||
@Value("${database.username:}")
|
||||
private String username;//用户名
|
||||
|
||||
@Value("${database.password:}")
|
||||
private String password;//密码
|
||||
|
||||
|
||||
@Value("${sftp.host:}")
|
||||
private String sftpHost;
|
||||
|
||||
@Value("${sftp.port:}")
|
||||
private Integer sftpPort;
|
||||
|
||||
@Value("${sftp.username:}")
|
||||
private String sftpUsername;
|
||||
|
||||
@Value("${sftp.password:}")
|
||||
private String sftpPassword;
|
||||
|
||||
@Value("${sftp.filePase:}")
|
||||
private String sftpFilePase;
|
||||
|
||||
|
||||
private ChannelSftp sftp = null;
|
||||
private Session sshSession = null;
|
||||
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||
try {
|
||||
if(filePase == null || "".equals(filePase)
|
||||
|| databaseName == null || "".equals(databaseName)
|
||||
|| fileName == null || "".equals(fileName)
|
||||
|| host == null || "".equals(host)
|
||||
|| port == null || "".equals(port)
|
||||
|| username == null || "".equals(username)
|
||||
|| password == null || "".equals(password)
|
||||
){
|
||||
return BaseResult.getSuccessMessageEntity("系统参数未配置不执行,数据库备份");
|
||||
}
|
||||
//查找是否存在当天数据库
|
||||
//格式化日期
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
String data = sdf.format(new Date());
|
||||
//当天路径
|
||||
String nowDatabasePase = filePase + File.separator + data;
|
||||
//不判断文件是否存在,直接执行
|
||||
if(!backFile(nowDatabasePase)){
|
||||
return BaseResult.getFailureMessageEntity("备份失败");
|
||||
}
|
||||
//判断是否有sftp配置,有的备份,没有的不备份
|
||||
if(sftpHost != null && !"".equals(sftpHost)
|
||||
&& sftpPort != null && !"".equals(sftpPort)
|
||||
&& sftpUsername != null && !"".equals(sftpUsername)
|
||||
&& sftpPassword != null && !"".equals(sftpPassword)
|
||||
&& sftpFilePase != null && !"".equals(sftpFilePase)
|
||||
){
|
||||
String sftpnowDatabasePase = sftpFilePase + File.separator + data;
|
||||
if(!sendFile(nowDatabasePase,sftpnowDatabasePase)){
|
||||
return BaseResult.getFailureMessageEntity("备份失败");
|
||||
}
|
||||
}
|
||||
logger.info("执行成功");
|
||||
return BaseResult.getSuccessMessageEntity("执行成功");
|
||||
} catch (Exception e) {
|
||||
logger.error("执行失败{}", e.getMessage());
|
||||
return BaseResult.getFailureMessageEntity("备份失败");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean backFile(String nowDatabasePase) {
|
||||
try {
|
||||
// 构建 mysqldump 命令
|
||||
ProcessBuilder processBuilder = new ProcessBuilder(
|
||||
"mysqldump",
|
||||
"--ssl-mode=DISABLED",
|
||||
"-h", host,
|
||||
"-u", username,
|
||||
"-p" + password,
|
||||
"-P" + port,
|
||||
databaseName);
|
||||
// 启动进程并获取输入流
|
||||
Process process = processBuilder.start();
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
||||
File f = creatFile(nowDatabasePase,fileName);
|
||||
// 将备份内容写入文件
|
||||
FileWriter writer = new FileWriter(f);
|
||||
String line;
|
||||
while ((line = reader.readLine())!= null) {
|
||||
writer.write(line + "\n");
|
||||
}
|
||||
// 关闭资源
|
||||
reader.close();
|
||||
writer.close();
|
||||
process.waitFor();
|
||||
logger.info("文件备份成功路径:"+nowDatabasePase+ File.separator +fileName);
|
||||
return true;
|
||||
} catch (IOException | InterruptedException e) {
|
||||
logger.info("文件备份失败:"+e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 创建目录及文件
|
||||
* @Date 8:59 上午 2024/10/22
|
||||
* @param filePath
|
||||
* @param fileName
|
||||
* @return java.io.File
|
||||
**/
|
||||
public File creatFile(String filePath, String fileName) {
|
||||
File folder = new File(filePath);
|
||||
//文件夹路径不存在
|
||||
if (!folder.exists()) {
|
||||
boolean mkdirs = folder.mkdirs();
|
||||
}
|
||||
// 如果文件不存在就创建
|
||||
File file = new File(filePath + File.separator + fileName);
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
logger.error("创建备份文件失败:"+e.getMessage());
|
||||
}
|
||||
}
|
||||
return file;
|
||||
}
|
||||
|
||||
private boolean sendFile(String localFilePath,String remoteFileName) {
|
||||
try {
|
||||
connect();
|
||||
uploadFile(remoteFileName,fileName,localFilePath,fileName);
|
||||
disconnect();
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
logger.error("sftp文件上传失败:"+e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void connect() {
|
||||
try {
|
||||
JSch jsch = new JSch();
|
||||
jsch.getSession(sftpUsername, sftpHost, sftpPort);
|
||||
sshSession = jsch.getSession(sftpUsername, sftpHost, sftpPort);
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Session created.");
|
||||
}
|
||||
sshSession.setPassword(sftpPassword);
|
||||
Properties sshConfig = new Properties();
|
||||
sshConfig.put("StrictHostKeyChecking", "no");
|
||||
sshSession.setConfig(sshConfig);
|
||||
sshSession.connect();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Session connected.");
|
||||
}
|
||||
Channel channel = sshSession.openChannel("sftp");
|
||||
channel.connect();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Opening Channel.");
|
||||
}
|
||||
sftp = (ChannelSftp) channel;
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Connected to " + host + ".");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭连接
|
||||
*/
|
||||
public void disconnect() {
|
||||
if (this.sftp != null) {
|
||||
if (this.sftp.isConnected()) {
|
||||
this.sftp.disconnect();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("sftp is closed already");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (this.sshSession != null) {
|
||||
if (this.sshSession.isConnected()) {
|
||||
this.sshSession.disconnect();
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("sshSession is closed already");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传单个文件
|
||||
*
|
||||
* @param remotePath:远程保存目录
|
||||
* @param remoteFileName:保存文件名
|
||||
* @param localPath:本地上传目录(以路径符号结束)
|
||||
* @param localFileName:上传的文件名
|
||||
* @return
|
||||
*/
|
||||
public boolean uploadFile(String remotePath, String remoteFileName, String localPath, String localFileName) {
|
||||
FileInputStream in = null;
|
||||
try {
|
||||
createDir(remotePath);
|
||||
File file = new File(localPath + File.separator + localFileName);
|
||||
in = new FileInputStream(file);
|
||||
sftp.put(in, remoteFileName, 65536);
|
||||
return true;
|
||||
} catch (FileNotFoundException e) {
|
||||
} catch (SftpException e) {
|
||||
} finally {
|
||||
if (in != null) {
|
||||
try {
|
||||
in.close();
|
||||
} catch (IOException e) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建目录
|
||||
*
|
||||
* @param createpath
|
||||
* @return
|
||||
*/
|
||||
public boolean createDir(String createpath) {
|
||||
try {
|
||||
if (isDirExist(createpath)) {
|
||||
this.sftp.cd(createpath);
|
||||
return true;
|
||||
}
|
||||
String pathArry[] = createpath.split("/");
|
||||
StringBuffer filePath = new StringBuffer("/");
|
||||
for (String path : pathArry) {
|
||||
if (path.equals("")) {
|
||||
continue;
|
||||
}
|
||||
filePath.append(path + "/");
|
||||
if (isDirExist(filePath.toString())) {
|
||||
sftp.cd(filePath.toString());
|
||||
} else {
|
||||
// 建立目录
|
||||
sftp.mkdir(filePath.toString());
|
||||
// 进入并设置为当前目录
|
||||
sftp.cd(filePath.toString());
|
||||
}
|
||||
|
||||
}
|
||||
this.sftp.cd(createpath);
|
||||
return true;
|
||||
} catch (SftpException e) {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断目录是否存在
|
||||
*
|
||||
* @param directory
|
||||
* @return
|
||||
*/
|
||||
public boolean isDirExist(String directory) {
|
||||
boolean isDirExistFlag = false;
|
||||
try {
|
||||
SftpATTRS sftpATTRS = sftp.lstat(directory);
|
||||
isDirExistFlag = true;
|
||||
return sftpATTRS.isDir();
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().toLowerCase().equals("no such file")) {
|
||||
isDirExistFlag = false;
|
||||
}
|
||||
}
|
||||
return isDirExistFlag;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 如果目录不存在就创建目录
|
||||
*
|
||||
* @param path
|
||||
*/
|
||||
public void mkdirs(String path) {
|
||||
File f = new File(path);
|
||||
|
||||
String fs = f.getParent();
|
||||
|
||||
f = new File(fs);
|
||||
|
||||
if (!f.exists()) {
|
||||
f.mkdirs();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -452,6 +452,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.info("执行异常错误原因:"+e);
|
||||
logger.error("新增返回脚本解析保存三方id错误"+jsonResultEntity.getAttribute());
|
||||
taskDetailEntity.setResult("新增返回脚本解析保存三方id错误");
|
||||
taskLivingDetailsService.updateLogFailToSuccess(taskDetailEntity);
|
||||
|
@ -543,7 +544,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
map1.put("tableName",mainDb);
|
||||
map1.put("dataStatus", "N");
|
||||
map1.put("deleteStatus", "0");
|
||||
map1.put("size", 10);
|
||||
map1.put("size", 50);
|
||||
objects = mdmModuleDao.queryMdmSTs(map1);
|
||||
objects = toLowerCaseKeys(objects);
|
||||
|
||||
|
@ -738,7 +739,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
map1.put("tableName",mainDb);
|
||||
//map1.put("dataStatus", "F");
|
||||
map1.put("updateStatus", "0");
|
||||
map1.put("size", 10);
|
||||
map1.put("size", 50);
|
||||
objects = mdmModuleDao.queryMdmSTs(map1);
|
||||
objects = toLowerCaseKeys(objects);
|
||||
|
||||
|
@ -926,7 +927,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
map1.put("tableName",mainDb);
|
||||
//map1.put("dataStatus", "Y");
|
||||
map1.put("addStatus", "0");
|
||||
map1.put("size", 100);
|
||||
map1.put("size", 50);
|
||||
objects = mdmModuleDao.queryMdmSTs(map1);
|
||||
objects = toLowerCaseKeys(objects);
|
||||
|
||||
|
@ -991,6 +992,7 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
mdmModuleSendLogEntity.setTableName(mainDb+"_send_log");
|
||||
mdmModuleSendLogEntity.setFormmainId(doObjects.get(i).getString("id"));
|
||||
mdmModuleSendLogEntity.setSts("Y");
|
||||
mdmModuleSendLogEntity.setDataType("1");
|
||||
mdmModuleSendLogEntity.setAppId(sysApplicationEntity.getId());
|
||||
mdmModuleSendLogEntity.setApiId(apiEntity.getId());
|
||||
//mdmModuleSendLogEntity.setDistributeId(mdmModuleDistributeEntities.get(i1).getId());
|
||||
|
@ -1121,10 +1123,12 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
}
|
||||
//保存日志
|
||||
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"1","发送成功",mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
|
||||
objects.get(i).put("sendsanfzt123",true);
|
||||
continue;
|
||||
}else {
|
||||
//保存日志
|
||||
saveMdmModuleSendLogEntity(mainCode,mdmModuleDistributeEntities.get(i1).getId(),"2","转发失败:"+jsonResultEntity.getAttribute(),mainDb,objects.get(i).getString("id"),sysApplicationEntity.getName(),sysApplicationEntity.getId(),apiEntity.getApiName(),apiEntity.getId(),doObjects.get(i).toJSONString(),"1");
|
||||
objects.get(i).put("sendsanfzt123",false);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -1132,12 +1136,14 @@ public class MdmModulePluginInitializer extends PluginBaseEntity {
|
|||
|
||||
//所有下发发送完成,修改数据状态
|
||||
for (int i = 0; i < objects.size(); i++) {
|
||||
Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("tableName",mainDb);
|
||||
//updateMap.put("dataStatus", "Y");
|
||||
updateMap.put("addStatus", "1");
|
||||
updateMap.put("id", objects.get(i).getString("id"));
|
||||
mdmModuleDao.updateMdmSTs(updateMap);
|
||||
if(objects.get(i).getBoolean("sendsanfzt123")){
|
||||
Map<String, Object> updateMap = new HashMap<>();
|
||||
updateMap.put("tableName",mainDb);
|
||||
//updateMap.put("dataStatus", "Y");
|
||||
updateMap.put("addStatus", "1");
|
||||
updateMap.put("id", objects.get(i).getString("id"));
|
||||
mdmModuleDao.updateMdmSTs(updateMap);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,6 +62,7 @@ public class PushMessagePluginInitializer extends PluginBaseEntity {
|
|||
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||
try {
|
||||
logger.info("======开始执行定时消息推送========");
|
||||
//目前只查询一周内的异常日志进行消息推送
|
||||
List<SysPushMessageEntity> list = sysPushMessageDao.getAll();
|
||||
|
||||
for(SysPushMessageEntity entity : list){
|
|
@ -45,7 +45,7 @@ savefile:
|
|||
tomcatpath: /Users/apple/Desktop/log/local
|
||||
pluginpath: /Users/apple/Desktop/log/local
|
||||
zt:
|
||||
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||
cbs8:
|
||||
appId: 1P4AGrpz
|
||||
appSecret: 2c2369ae5dc04382844bbe3a5abf39e1bea9cd3a
|
||||
|
@ -59,4 +59,24 @@ cbs8:
|
|||
#电子回单下载临时存放位置
|
||||
elec_path: /Users/xiangerlin/Downloads/
|
||||
OA:
|
||||
data_source_code: yc_oa
|
||||
data_source_code: yc_oa
|
||||
server:
|
||||
port: 10086
|
||||
|
||||
# mysqldump -d mylm -hhzya.ufyct.com -p9096 -uroot -phzya1314 >%dirName%\table_view.sql
|
||||
|
||||
|
||||
database:
|
||||
databaseName: businesscenter
|
||||
host: 192.168.2.237
|
||||
port: 3306
|
||||
username: root
|
||||
password: hzya@1314
|
||||
filePase: /Users/apple/Desktop/log
|
||||
fileName: data.sql
|
||||
#sftp:
|
||||
# host: 192.168.2.237
|
||||
# port: 9091
|
||||
# username: cs237
|
||||
# password: hzya@1314
|
||||
# filePase: /databaseBack
|
|
@ -36,4 +36,4 @@ cbs8:
|
|||
OA:
|
||||
data_source_code: yc_oa
|
||||
zt:
|
||||
url: http://127.0.0.1:9082/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
|
|
@ -1,5 +1,5 @@
|
|||
server:
|
||||
port: 9999
|
||||
port: 10086
|
||||
servlet:
|
||||
context-path: /kangarooDataCenterV3
|
||||
localIP: 127.0.0.1
|
||||
|
@ -93,7 +93,7 @@ mybatis-plus:
|
|||
db-config:
|
||||
id-type: auto # 主键策略
|
||||
zt:
|
||||
url: http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||
url: http://127.0.0.1:10086/kangarooDataCenterV3/entranceController/externalCallInterface
|
||||
#JimuReport[minidao配置]
|
||||
minidao :
|
||||
base-package: org.jeecg.modules.jmreport.desreport.dao*
|
||||
|
@ -126,3 +126,17 @@ jeecg :
|
|||
bucketName: ??
|
||||
data:
|
||||
use: true
|
||||
database:
|
||||
databaseName:
|
||||
host:
|
||||
port:
|
||||
username:
|
||||
password:
|
||||
filePase:
|
||||
fileName:
|
||||
sftp:
|
||||
host:
|
||||
port:
|
||||
username:
|
||||
password:
|
||||
filePase:
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin>
|
||||
<id>BackUpDatabasePlugin</id>
|
||||
<name>BackUpDatabasePlugin插件</name>
|
||||
<category>20241021</category>
|
||||
</plugin>
|
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans default-autowire="byName">
|
||||
<bean name="seeyonExtPluginInitializer" class="com.hzya.frame.plugin.seeyonExt.plugin.SeeyonExtPluginInitializer" />
|
||||
<bean name="backUpDatabaseInitializer" class="com.hzya.frame.plugin.BackUpDatabase.plugin.BackUpDatabaseInitializer" />
|
||||
</beans>
|
|
@ -0,0 +1,146 @@
|
|||
package com.hzya.frame;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.util.AESUtil;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.config.RequestConfig;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.client.methods.HttpPut;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClientBuilder;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @ClassName dsasas
|
||||
* @Description
|
||||
* @Author llg
|
||||
* Date 2023/7/16 8:18 上午
|
||||
*/
|
||||
//@RunWith(SpringRunner.class)
|
||||
//@SpringBootTest(classes = {WebappApplication.class})
|
||||
public class temButtom {
|
||||
|
||||
@Test
|
||||
public void test01() {
|
||||
String a = AESUtil.encrypt("hzya@1314");
|
||||
System.out.println(a);
|
||||
String b = AESUtil.decrypt("62e4295b615a30dbf3b8ee96f41c820b");
|
||||
System.out.println(b);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test02() {
|
||||
// 1056162015172640840 -7858803986346327947 3178176833471791293 合同评审-待办测试(bdmanager 2024-10-22 16:45) 7743552636545550897 bdmanager 18058147870 pending start success 新增成功!
|
||||
// success 更新待办为已办成功!
|
||||
// task7803207f54ff047d6008dcce31c2628f 新增成功!
|
||||
// 2024-10-24 2024-10-24
|
||||
|
||||
String phone ="19357235324";
|
||||
String taskid ="task8b0c7ca72439bc9b0c1c89e8866c8275";
|
||||
//token
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
String token ="https://oapi.dingtalk.com/gettoken?appkey=dingxewtjaserj292ggu&appsecret=DuRw6EEEvhGXfr6Q8wN_x4025qKjrffIGCXF9KeCKKIID-LVSsR6_8KWMei6sug1";
|
||||
String body = sendGet(token,headers);
|
||||
JSONObject tokenobject = JSONObject.parseObject(body);
|
||||
|
||||
//钉钉id
|
||||
headers = new HashMap<>();
|
||||
//https://oapi.dingtalk.com/user/get_by_mobile?access_token=9abd3996cb103ba48dd8c69fea5473e7&mobile=15700100840
|
||||
String ddid ="https://oapi.dingtalk.com/user/get_by_mobile?access_token="+tokenobject.get("access_token")+"&mobile="+phone;
|
||||
String ddidbody = sendGet(ddid,headers);
|
||||
JSONObject ddidobject = JSONObject.parseObject(ddidbody);
|
||||
|
||||
//人员id
|
||||
headers = new HashMap<>();
|
||||
//https://oapi.dingtalk.com/user/get?userid=111336474727636213&access_token=3d21a6614fb037a98542a537336e8149
|
||||
String userid ="https://oapi.dingtalk.com/user/get?userid="+ddidobject.get("userid")+"&access_token="+tokenobject.get("access_token");
|
||||
String useridbody = sendGet(userid,headers);
|
||||
JSONObject useridobject = JSONObject.parseObject(useridbody);
|
||||
|
||||
|
||||
|
||||
CloseableHttpClient httpClient = HttpClients.createDefault();
|
||||
HttpPut httpPut = new HttpPut("https://api.dingtalk.com/v1.0/todo/users/"+useridobject.get("unionid")+"/tasks/"+taskid);
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(35000).setConnectionRequestTimeout(35000).setSocketTimeout(60000).build();
|
||||
httpPut.setConfig(requestConfig);
|
||||
httpPut.setHeader("Content-type", "application/json");
|
||||
httpPut.setHeader("x-acs-dingtalk-access-token", tokenobject.getString("access_token"));
|
||||
Map<String, Object> dataMap = new HashMap();
|
||||
dataMap.put("done", true);
|
||||
CloseableHttpResponse httpResponse = null;
|
||||
|
||||
try {
|
||||
httpPut.setEntity(new StringEntity("{\"done\": true}"));
|
||||
httpResponse = httpClient.execute(httpPut);
|
||||
HttpEntity entity = httpResponse.getEntity();
|
||||
String results = EntityUtils.toString(entity);
|
||||
System.out.println(results);
|
||||
} catch (Exception var15) {
|
||||
} finally {
|
||||
try {
|
||||
httpResponse.close();
|
||||
httpClient.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private String sendGet(String url, Map<String, String> headers) {
|
||||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();
|
||||
// HttpClient
|
||||
CloseableHttpClient closeableHttpClient = httpClientBuilder.disableCookieManagement().build();
|
||||
HttpGet get = new HttpGet(url.toString());
|
||||
CloseableHttpResponse response = null;
|
||||
|
||||
RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout(60000).build();
|
||||
get.setConfig(requestConfig);//设置请求参数【超时时间】
|
||||
if (headers != null && headers.size() > 0) {
|
||||
for (String key : headers.keySet()) {
|
||||
get.setHeader(key, headers.get(key));
|
||||
}
|
||||
}
|
||||
StringBuilder body = new StringBuilder();
|
||||
|
||||
try {
|
||||
|
||||
response = closeableHttpClient.execute(get);
|
||||
HttpEntity entity = response.getEntity();
|
||||
body.append(EntityUtils.toString(entity,"UTF-8"));
|
||||
} catch (Exception e) {
|
||||
body.append(e.getMessage());
|
||||
} finally {
|
||||
try {
|
||||
// 关闭响应对象
|
||||
if (response != null) {
|
||||
response.close();
|
||||
}
|
||||
// 关闭响应对象
|
||||
if (closeableHttpClient != null) {
|
||||
closeableHttpClient.close();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return body.toString();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -8,8 +8,9 @@
|
|||
<version>${revision}</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>common</artifactId>
|
||||
<artifactId>base-common</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<version>${revision}</version>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue