配置多环境前的备份

main
熊朝柱 3 months ago
commit 0632911e4a

33
.gitignore vendored

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

@ -0,0 +1 @@
当前项目为滨湖项目物料&图纸自动下发的中转服务

@ -0,0 +1,150 @@
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>BHDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>BHDemo</name>
<description>BHDemo</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.4</version>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version> <!-- 确保使用最新或兼容的版本 -->
</dependency>
<!-- 德魯伊數據源-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.2.23</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.13</version>
</dependency>
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis-spring</artifactId>
<version>2.1.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>6.1.14</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.24</version>
</dependency>
<dependency>
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
<version>3.6</version>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
<!--rabbitmq-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-amqp</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <version>${spring-boot.version}</version>-->
<!-- <configuration>-->
<!-- <mainClass>cn.com.connor.bh.bhdemo.BhDemoApplication</mainClass>-->
<!-- <skip>true</skip>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>repackage</id>-->
<!-- <goals>-->
<!-- <goal>repackage</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>cn.com.connor.bh.bhdemo.BhDemoApplication</mainClass>
<skip>false</skip>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,16 @@
package cn.com.connor.bh.bhdemo;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@SpringBootApplication
@MapperScan("cn.com.connor.bh.bhdemo.demos.web.mapper")
public class BhDemoApplication {
public static void main(String[] args) {
SpringApplication.run(BhDemoApplication.class, args);
}
}

@ -0,0 +1,22 @@
package cn.com.connor.bh.bhdemo.demos.web.Listener;
import cn.com.connor.bh.bhdemo.demos.web.service.CallExeService;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
*/
@Component
public class StoCAPPListener {
@Autowired
private CallExeService callExeService;
@RabbitListener(queues = "StoCAPP")
public void listenQueueMsg(String msg) {
System.out.println("StoCAPPListener 监听到消息:" + msg);
//调用批处理文件开始执行EXE程序
callExeService.callExe(msg);
}
}

@ -0,0 +1,96 @@
package cn.com.connor.bh.bhdemo.demos.web.controller;
import cn.com.connor.bh.bhdemo.demos.web.mapper.TaskMapper;
import cn.com.connor.bh.bhdemo.demos.web.service.CallExeService;
import cn.com.connor.bh.bhdemo.demos.web.service.MqQueueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/drawing")
public class DrawingController {
@Autowired
private CallExeService callExeService;
@Autowired
private TaskMapper taskMapper;
@Autowired
private MqQueueService mqQueueService;
@PostMapping("/getByMSG")
public int getByMSG(@RequestBody Map<String, Object> map) {
System.out.println("getByMSG - 已收到异步任务信息:"+ map.toString());
int result = 0;
try {
String param = map.get("MSG").toString();
System.out.println("----"+param);
result = taskMapper.getByMSG(param);
System.out.println("==>result:"+result);
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
return 0;
}
System.out.println("getByMSG方法执行完毕");
return result;
}
@PostMapping("/updateTask")
public int updateTask(@RequestBody Map<String, Object> map) {
System.out.println("updateTask - 已收到异步任务信息:"+ map.toString());
int result = 0;
try {
String param = map.get("MSG").toString();
System.out.println("----"+param);
result = taskMapper.updateTask(map);
System.out.println("==>result:"+result);
// callExeService.callExe();
mqQueueService.sendMsgToQueue(param);
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
return 0;
}
System.out.println("updateTask方法执行完毕");
return result;
}
@PostMapping("/insertTask")
public int insertTask(@RequestBody Map<String, Object> map) {
System.out.println("insertTask - 已收到异步任务信息:"+ map.toString());
int result = 0;
try {
String param = map.get("MSG").toString();
System.out.println("----"+param);
result = taskMapper.insertTask(map);
System.out.println("==>result:"+result);
// callExeService.callExe();
mqQueueService.sendMsgToQueue(param);
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
return 0;
}
System.out.println("insertTask方法执行完毕");
return result;
}
/**
* handler
* handler使c++
*
*/
@GetMapping
public void drawToExe() {
System.out.println("已收到异步任务请求开始调用exe程序");
try {
// callExeService.callExe();
mqQueueService.sendMsgToQueue("handler");
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
}
System.out.println("drawToExe方法执行完毕");
}
}

@ -0,0 +1,35 @@
package cn.com.connor.bh.bhdemo.demos.web.controller;
import cn.com.connor.bh.bhdemo.demos.web.utils.CurlUtil;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/ftp")
public class FtpController {
@PostMapping
public int localToFTP(@RequestBody Map<String, Object> map) {
System.out.println("localToFTP - 已收到操作FTP相关信息"+ map.toString());
int result = 0;
try {
String ftpip = map.get("ftp_ip").toString();//ftp的ip·
String username = map.get("user_name").toString();//ftp的账号·
String password = map.get("pass_word").toString();//ftp的密码·
String source = map.get("source_path").toString();//本地文件路径(文件全路径:包含文件名)·
String targetPath = map.get("target_path").toString();//ftp目标文件夹路径·
String targetFileName = map.get("target_file_name").toString();//ftp目标文件名·
//连接ftp并登录
// String resultString = FtpUtil.upload(targetPath,targetFileName, source, ftpip, 21, username, password, null);
String resultString = CurlUtil.uploadToFTP(source, username, password, ftpip, targetPath, targetFileName);
System.out.println(resultString);
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》上传FTP异常《《《《《《《《《《");
return 0;
}
return result;
}
}

@ -0,0 +1,93 @@
package cn.com.connor.bh.bhdemo.demos.web.controller;
import cn.com.connor.bh.bhdemo.demos.web.mapper.TaskMapper;
import cn.com.connor.bh.bhdemo.demos.web.service.CallExeService;
import cn.com.connor.bh.bhdemo.demos.web.service.MqQueueService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/part")
public class PartController {
@Autowired
private CallExeService callExeService;
@Autowired
private MqQueueService mqQueueService;
@Autowired
private TaskMapper taskMapper;
@PostMapping("/getByMSG")
public int getByMSG(@RequestBody Map<String, Object> map) {
System.out.println("getByMSG - 已收到异步任务信息:"+ map.toString());
int result = 0;
try {
String param = map.get("MSG").toString();
System.out.println("----"+param);
result = taskMapper.getByMSG(param);
System.out.println("==>result:"+result);
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
return 0;
}
System.out.println("getByMSG方法执行完毕");
return result;
}
@PostMapping("/updateTask")
public int updateTask(@RequestBody Map<String, Object> map) {
System.out.println("updateTask - 已收到异步任务信息:"+ map.toString());
int result = 0;
try {
String param = map.get("MSG").toString();
System.out.println("----"+param);
result = taskMapper.updateTask(map);
System.out.println("==>result:"+result);
// callExeService.callExe();
mqQueueService.sendMsgToQueue(param);
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
return 0;
}
System.out.println("updateTask方法执行完毕");
return result;
}
@PostMapping("/insertTask")
public int insertTask(@RequestBody Map<String, Object> map) {
System.out.println("insertTask - 已收到异步任务信息:"+ map.toString());
int result = 0;
try {
String param = map.get("MSG").toString();
System.out.println("----"+param);
result = taskMapper.insertTask(map);
System.out.println("==>result:"+result);
// callExeService.callExe();
mqQueueService.sendMsgToQueue(param);
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
return 0;
}
System.out.println("insertTask方法执行完毕");
return result;
}
@GetMapping
public int partToExe() {
System.out.println("已收到异步任务请求开始调用exe程序");
try {
// callExeService.callExe();
mqQueueService.sendMsgToQueue("handler");
}catch (Exception e){
e.printStackTrace();
System.out.println("》》》》》》》》》》转发异常《《《《《《《《《《");
return 0;
}
System.out.println("partToExe方法执行完毕");
return 1;
}
}

@ -0,0 +1,33 @@
package cn.com.connor.bh.bhdemo.demos.web.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CappTask {
private String code;
//任务来源
private String taskSource;
//用户名称
private String userName;
//用户id
private String userId;
//流程uid
private String flowId;
//状态
private String status;
//数据信息
private String msg;
//处理开始时间
private String starttime;
//处理完成时间
private String finishtime;
//下发完成时间
private String endingtime;
}

@ -0,0 +1,16 @@
package cn.com.connor.bh.bhdemo.demos.web.mapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.Map;
@Mapper
public interface TaskMapper {
int getByMSG(@Param("MSG") String MSG);
int insertTask(@Param("map") Map<String, Object> map);
int updateTask(@Param("map") Map<String, Object> map);
}

@ -0,0 +1,66 @@
package cn.com.connor.bh.bhdemo.demos.web.service;
import org.springframework.stereotype.Service;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
@Service
public class CallExeService {
/**
* exe
*/
public void callExe(String msg){
System.out.println("callExe方法被调用开始执行批处理命令");
String command = "C:\\Users\\Administrator\\Desktop\\TOCAPP.bat";
System.out.println("cmd====="+command);
try {
// 使用 Runtime.exec() 执行命令
Process process = Runtime.getRuntime().exec(command);
// 获取命令的输入流
try(InputStream inputStream = process.getInputStream();
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))){
System.out.println("执行exe程序打印信息begin···");
// 读取并打印输出
String line;
while ((line = reader.readLine()) != null) {
System.out.println("line => "+line);
}
System.out.println("执行exe程序打印信息end");
// 等待命令执行完毕
int exitCode = process.waitFor();
/* System.out.println();
System.out.println();
System.out.println();*/
System.out.println("Command executed with exit code: " + exitCode);
}
// 关闭资源
// reader.close();
} catch (IOException e) {
// 处理命令执行失败的情况
System.err.println("命令执行失败: " + e.getMessage());
e.printStackTrace();
} catch (InterruptedException e) {
// 重新设置中断状态
Thread.currentThread().interrupt();
System.err.println("命令执行被中断: " + e.getMessage());
e.printStackTrace();
}
}
}

@ -0,0 +1,21 @@
package cn.com.connor.bh.bhdemo.demos.web.service;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class MqQueueService {
@Autowired
private RabbitTemplate rabbitTemplate;
/**
*
*/
public void sendMsgToQueue(String msg) {
String queueName = "StoCAPP";
System.out.println("发送消息:" + msg + "到队列:" + queueName);
rabbitTemplate.convertAndSend(queueName,msg);
}
}

@ -0,0 +1,31 @@
package cn.com.connor.bh.bhdemo.demos.web.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class CurlUtil {
public static String uploadToFTP(String localFile, String username, String password, String ip, String targetPath, String targetFileName) {
String command = "curl -T " + localFile + " ftp://" + username + ":" + password + "@"+ ip + targetPath;
System.out.println("执行curl命令"+ command);
try {
// 执行一个简单的命令例如dir
Process process = Runtime.getRuntime().exec(command);
// 获取命令输出流
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
// 等待命令执行完成
int exitCode = process.waitFor();
System.out.println("命令执行完成,退出码: " + exitCode);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
return "error";
}
return "success";
}
}

@ -0,0 +1,112 @@
package cn.com.connor.bh.bhdemo.demos.web.utils;
import cn.hutool.core.io.FileUtil;
import cn.hutool.extra.ftp.Ftp;
import cn.hutool.extra.ftp.FtpMode;
import org.apache.commons.lang.StringUtils;
import java.io.File;
import java.io.IOException;
public class FtpUtil {
/**
* ftp
* @param remoteFile
* @param localFile
* @param ip
* @param port
* @param username
* @param password
* @param ftpMode
* @return :success
*/
public static String download(String remoteFile, String localFile, String ip, Integer port, String username, String password, FtpMode ftpMode) {
if(StringUtils.isBlank(localFile)) {
return "本地保存路径及名称不能为空";
}
File lFile = FileUtil.file(localFile);
Ftp ftp = null;
try {
//匿名登录无需帐号密码的FTP服务器
ftp = new Ftp(ip,port == null ? 21 : port,username,password);
if(ftpMode != null) {
ftp.setMode(ftpMode);
}
ftp.download(remoteFile, lFile);
} catch (Exception e) {
return e.getMessage();
} finally {
//关闭连接
try {
if(ftp != null) ftp.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
if(lFile.exists() && lFile.length() > 0) {
return "success";
} else {
lFile.delete();
return "download failure,"+ remoteFile +" maybe not exists !!";
}
}
/**
*
* @param remoteDir
* @param localFile
* @param ip
* @param port
* @param username
* @param password
* @return :success
*/
public static String upload(String remoteDir, String localFile, String ip, Integer port, String username, String password, FtpMode ftpMode) {
return upload(remoteDir, null, localFile, ip, port, username, password, ftpMode);
}
/**
*
* @param remoteDir ftp
* @param remoteFileName ftp
* @param localFile
* @param ip
* @param port
* @param username
* @param password
* @return :success
*/
public static String upload(String remoteDir, String remoteFileName, String localFile, String ip, Integer port, String username, String password, FtpMode ftpMode) {
if(StringUtils.isBlank(localFile)) {
return "本地文件名称不能为空";
}
File lFile = FileUtil.file(localFile);
if(!lFile.exists()) {
return "本地文件不存在";
}
Ftp ftp = null;
try {
//匿名登录无需帐号密码的FTP服务器
ftp = new Ftp(ip,port == null ? 21 : port,username,password);
if(ftpMode != null) {
ftp.setMode(ftpMode);
}
if(StringUtils.isBlank(remoteFileName)) {
ftp.upload(remoteDir, lFile);
} else {
ftp.upload(remoteDir, remoteFileName, lFile);
}
} catch (Exception e) {
return e.getMessage();
} finally {
//关闭连接
try {
if(ftp != null) ftp.close();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return "success";
}
}

@ -0,0 +1,17 @@
#下面这些内容是为了让MyBatis映射
#指定Mybatis的Mapper文件
mybatis.mapper-locations=classpath:mappers/*xml
#指定Mybatis的实体目录
mybatis.type-aliases-package=cn.com.connor.bh.bhdemo.mybatis.entity
# 应用服务 WEB 访问端口
server.port=8080
#数据库连接配置
spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
spring.datasource.druid.url=jdbc:sqlserver://192.168.189.128:1433/bhdemo
spring.datasource.druid.username=root
spring.datasource.druid.password=123456
spring.datasource.druid.driver-class-name=com.mysql.cj.jdbc.Driver

@ -0,0 +1,26 @@
server:
port: 8080
spring:
datasource:
driverClassName: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@10.41.213.19:1521/orcl
username: system
password: Aa12345678
rabbitmq:
host: 192.168.3.125
port: 5672
# virtual-host: /
username: kuma
password: 123
template:
default-receive-queue: StoCAPP
# url: jdbc:oracle:thin:@192.168.3.125:1521/TC12
# username: infodba
# password: infodba
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: cn.com.connor.bh.bhdemo.demos.web.entity
configuration:
map-underscore-to-camel-case: true

@ -0,0 +1,25 @@
server:
port: 8080
spring:
datasource:
driverClassName: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@10.41.213.19:1521/orcl
username: system
password: Aa12345678
rabbitmq:
host: 192.168.3.125
port: 5672
username: kuma
password: 123
template:
default-receive-queue: StoCAPP
# url: jdbc:oracle:thin:@192.168.3.125:1521/TC12
# username: infodba
# password: infodba
mybatis:
mapper-locations: classpath:mapper/*.xml
type-aliases-package: cn.com.connor.bh.bhdemo.demos.web.entity
configuration:
map-underscore-to-camel-case: true

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.connor.bh.bhdemo.demos.web.mapper.TaskMapper">
<insert id="insertTask" parameterType="Map" >
insert into WHBH_CAPP_TASK (TASKSOURCE, USERNAME, USERID, STATUS, MSG, STARTTIME)
values (#{map.TASKSOURCE},#{map.USERNAME},#{map.USERID},#{map.STATUS},#{map.MSG},#{map.STARTTIME})
</insert>
<update id="updateTask" parameterType="Map" >
update WHBH_CAPP_TASK set TASKSOURCE = #{map.TASKSOURCE},
USERNAME = #{map.USERNAME},
USERID = #{map.USERID},
STATUS = #{map.STATUS},
STARTTIME = #{map.STARTTIME}
where MSG = #{map.MSG}
</update>
<select id = "getName" resultType="String">
select name from v_emp where barcode=#{code} and rownum = 1
</select>
<select id="getByMSG" resultType="Integer">
SELECT COUNT(*) FROM WHBH_CAPP_TASK WHERE MSG = #{MSG}
</select>
</mapper>

@ -0,0 +1,6 @@
<html>
<body>
<h1>hello word!!!</h1>
<p>this is a html page</p>
</body>
</html>

@ -0,0 +1,13 @@
package cn.com.connor.bh.bhdemo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class BhDemoApplicationTests {
@Test
void contextLoads() {
}
}
Loading…
Cancel
Save