diff --git a/Test/Hadoop/pom.xml b/Test/Hadoop/pom.xml
new file mode 100644
index 00000000..6ca35f82
--- /dev/null
+++ b/Test/Hadoop/pom.xml
@@ -0,0 +1,85 @@
+
+
+ 4.0.0
+
+ org.springframework.boot
+ spring-boot-starter-parent
+ 2.6.7
+
+
+ com.renchao
+ Hadoop
+ 0.0.1-SNAPSHOT
+ Hadoop
+ Demo project for Spring Boot
+
+ 1.8
+
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.apache.hive
+ hive-jdbc
+ 3.1.2
+
+
+
+
+ org.apache.hbase
+ hbase-server
+
+
+ org.apache.curator
+ curator-framework
+
+
+ org.apache.hive
+ hive-upgrade-acid
+
+
+ org.apache.hive
+ hive-shims
+
+
+ org.apache.hive
+ hive-metastore
+
+
+
+ org.mortbay.jetty
+ jetty
+
+
+ org.eclipse.jetty
+ jetty-runner
+
+
+ org.apache.zookeeper
+ zookeeper
+
+
+
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+
+
diff --git a/Test/Hadoop/src/main/java/com/renchao/HadoopApplication.java b/Test/Hadoop/src/main/java/com/renchao/HadoopApplication.java
new file mode 100644
index 00000000..466cd940
--- /dev/null
+++ b/Test/Hadoop/src/main/java/com/renchao/HadoopApplication.java
@@ -0,0 +1,14 @@
+package com.renchao;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class HadoopApplication {
+
+ public static void main(String[] args) {
+
+ SpringApplication.run(HadoopApplication.class, args);
+ }
+
+}
diff --git a/Test/Hadoop/src/main/java/com/renchao/controller/HiveController.java b/Test/Hadoop/src/main/java/com/renchao/controller/HiveController.java
new file mode 100644
index 00000000..2a74dc22
--- /dev/null
+++ b/Test/Hadoop/src/main/java/com/renchao/controller/HiveController.java
@@ -0,0 +1,17 @@
+package com.renchao.controller;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+public class HiveController {
+
+
+ @GetMapping("/test")
+ public String test() {
+ return "hiveService.test()";
+ }
+}
diff --git a/Test/Hadoop/src/main/java/com/renchao/hive/HiveTest.java b/Test/Hadoop/src/main/java/com/renchao/hive/HiveTest.java
new file mode 100644
index 00000000..0edf484f
--- /dev/null
+++ b/Test/Hadoop/src/main/java/com/renchao/hive/HiveTest.java
@@ -0,0 +1,43 @@
+package com.renchao.hive;
+
+import java.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+public class HiveTest {
+ public static void main(String[] args) {
+ // HiveServer2的JDBC连接URL
+ String hiveServerURL = "jdbc:hive2://172.16.12.101:10000/hive;socketTimeout=12000;";
+ String hiveUser = "flink";
+ String hivePassword = "flink";
+
+ try {
+ // 加载Hive JDBC驱动程序
+ Class.forName("org.apache.hive.jdbc.HiveDriver");
+
+ // 连接到HiveServer2
+ Connection connection = DriverManager.getConnection(hiveServerURL, hiveUser, hivePassword);
+
+ // 创建一个Hive语句对象
+ Statement statement = connection.createStatement();
+
+ // 执行Hive查询
+ String sql = "select * from student2";
+ ResultSet resultSet = statement.executeQuery(sql);
+
+ // 处理查询结果
+ while (resultSet.next()) {
+ System.out.println(resultSet.getInt("id"));
+ System.out.println(resultSet.getString("name"));
+ }
+
+ // 关闭资源
+ resultSet.close();
+ statement.close();
+ connection.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
diff --git a/Test/MyMaven/src/main/java/com/renchao/RestTemplate/RestDemo.java b/Test/MyMaven/src/main/java/com/renchao/RestTemplate/RestDemo.java
index 3347831c..7249273a 100644
--- a/Test/MyMaven/src/main/java/com/renchao/RestTemplate/RestDemo.java
+++ b/Test/MyMaven/src/main/java/com/renchao/RestTemplate/RestDemo.java
@@ -10,8 +10,10 @@ import org.springframework.web.client.RestTemplate;
import java.io.UnsupportedEncodingException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.List;
public class RestDemo {
public static void main(String[] args) throws UnsupportedEncodingException {
@@ -25,6 +27,7 @@ public class RestDemo {
ResponseEntity exchange = restTemplate.postForEntity("http://localhost:8889/test02", request, String.class);
// ResponseEntity exchange = restTemplate.getForEntity("https://www.baidu.com/", String.class, request);
System.out.println(exchange.getBody());
+ List bytes = new ArrayList<>();
test();
}
diff --git a/Test/MyMaven/src/main/java/com/renchao/spring/AnnotationUtilsTest.java b/Test/MyMaven/src/main/java/com/renchao/spring/AnnotationUtilsTest.java
index 265069fb..b5ca55cd 100644
--- a/Test/MyMaven/src/main/java/com/renchao/spring/AnnotationUtilsTest.java
+++ b/Test/MyMaven/src/main/java/com/renchao/spring/AnnotationUtilsTest.java
@@ -2,8 +2,10 @@ package com.renchao.spring;
import com.renchao.spring.bean.Anonymous;
import com.renchao.spring.bean.TestController;
+import org.junit.Test;
import org.springframework.core.annotation.AnnotatedElementUtils;
import org.springframework.core.annotation.AnnotationUtils;
+import org.springframework.http.ContentDisposition;
public class AnnotationUtilsTest {
public static void main(String[] args) {
@@ -11,4 +13,9 @@ public class AnnotationUtilsTest {
System.out.println(annotation);
System.out.println(AnnotatedElementUtils.isAnnotated(TestController.class, Anonymous.class));
}
+
+ @Test
+ public void test01() {
+ System.out.println(ContentDisposition.attachment().filename("55.txt").build());
+ }
}
diff --git a/Test/src/com/renchao/RSADemo.java b/Test/src/com/renchao/RSADemo.java
index bf65910c..d4547e7e 100644
--- a/Test/src/com/renchao/RSADemo.java
+++ b/Test/src/com/renchao/RSADemo.java
@@ -2,14 +2,24 @@ package com.renchao;
import org.junit.Test;
+import javax.crypto.BadPaddingException;
import javax.crypto.Cipher;
+import javax.crypto.IllegalBlockSizeException;
+import javax.crypto.NoSuchPaddingException;
+import javax.crypto.spec.OAEPParameterSpec;
+import javax.crypto.spec.PSource;
import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
+import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
+import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
+import java.security.spec.MGF1ParameterSpec;
+import java.security.spec.PKCS8EncodedKeySpec;
import java.security.spec.X509EncodedKeySpec;
import java.util.Base64;
@@ -25,7 +35,7 @@ public class RSADemo {
// 加密消息
String message = "Hello RSA";
- Cipher cipher = Cipher.getInstance("RSA");
+ Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-256AndMGF1Padding");
cipher.init(Cipher.ENCRYPT_MODE, publicKey);
byte[] encryptedMessage = cipher.doFinal(message.getBytes());
System.out.println("Encrypted message: " + Base64.getEncoder().encodeToString(encryptedMessage));
@@ -39,7 +49,7 @@ public class RSADemo {
@Test
public void test01() throws Exception {
// String publicKeyStr = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDG03gR1w6i3E6h6+N9F2///BnRrkzPc7RT4qZKKl2b/rolym0EYl3QZTsIV5oQngT93TLtld7EK5svdwUabX6kzqd8yDDChZXS/E7/FrufN6Hwf9S3O3ZzkhEyd45HmRHV4aNRFsS/NviEZx83D6FR94l0SPnomvPkVqM8UnafnQIDAQAB";
- String publicKeyStr = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCUAPS4EiEkyKAay4dRY7hWuyTSewj3X1g9NXj6832Eup0VE+xxGfsDiU5xlZBenFcLT8nn88q3mYit5DowuwxTCmem2TIAfkxdAnZ4vm7ndVbugQTu3TDB5R7LIGRjNF62lfwzYc7ywJFHVH/7dVfh4/uaijjQeDhznlBxM57NgwIDAQAB";
+ String publicKeyStr = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC5Kfw/IMSSsGOKhN08Vmf4ztuvnBrfm8EYJ7pdBmeh64RDSd4t5QGeH086ExXfFKCHyiF2ryfMY/rknictvBSMTomD4U8JwKEgIKQcukHaFnyEpHmZalqSUuWjZJyE6Ru6O8CLM9yMwQHKW7H4vSxrw3MM4acgytPuTGgaC6oeaQIDAQAB";
String privateKeyStr = "MIICdgIBADANBgkqhkiG9w0BAQEFAASCAmAwggJcAgEAAoGBAMbTeBHXDqLcTqHr430Xb//8GdGuTM9ztFPipkoqXZv+uiXKbQRiXdBlOwhXmhCeBP3dMu2V3sQrmy93BRptfqTOp3zIMMKFldL8Tv8Wu583ofB/1Lc7dnOSETJ3jkeZEdXho1EWxL82+IRnHzcPoVH3iXRI+eia8+RWozxSdp+dAgMBAAECgYAJjtfqT6LR/HJBQXQ9qrdFIIrjNBRYMrE8CRzCWvgGDEBJmcoU2F+3KW6lj4SGAPqvc4dDuZ0sZAZBSWDy7MmWL+Zz2z44sulxsOsb3DJqIyBSAr5D6mhrRmu7MJA5AGgDHo/2gn+9Cji2JQBHBFe18BzJdr2tIM4uAYTVB6EW8QJBAPCrnHohSDtgLSmHrbORP/cIS8OOF/M3PsYfHZ3cpdrKk2zs1rXAHJq80GlmhSQx8tezx6wt63Cph0reiHbOMRkCQQDTfYqahFR0NTFFfTBfSJKQEqoiRYMnOrjkkOOgFv6cBwYd16pnqTfNISSYkBsOcDO09qiMILW96MoJONCV458lAkEAmMrqueK9X+zMX0xjK9hwOp5Ks2lXrTKKqO+CNwGpTkFD3WhzW8oOnvJ2giPzLSqE2QqrHpW8nrcSTKcBDiQTqQJABORmjGR7P6TrWtwmfk3Ddim4XcqV2hZ1qHPhkBZ4FUvkTFRs0LENZWVa31yWA6N8zrbV90fabGYyJjx2NsFpMQJARtRflzJjWc/49nzu+om41bz9Ngg07/S8Rxe8AlZbSlCxggmp/KUBcoVgNJCa5qGsX2AvTOCXaHngp+YLtHHPBQ==";
KeyFactory keyFactory = KeyFactory.getInstance("RSA");
@@ -50,7 +60,8 @@ public class RSADemo {
System.out.println(publicKey);
System.out.println(System.currentTimeMillis());
rsa.init(Cipher.ENCRYPT_MODE, publicKey);
- String str = "Admin1234," + System.currentTimeMillis();
+ String str = "111111," + System.currentTimeMillis();
+// String str = "Admin1234," + System.currentTimeMillis();
byte[] bytes = rsa.doFinal(str.getBytes(StandardCharsets.UTF_8));
String s = Base64.getEncoder().encodeToString(bytes);
System.out.println(s);
@@ -66,5 +77,12 @@ public class RSADemo {
}
+ @Test
+ public void test02() throws InterruptedException {
+ System.out.println(System.currentTimeMillis());
+ Thread.sleep(1000);
+ System.out.println(System.currentTimeMillis());
+ System.out.println(1000 << 9);
+ }
}
diff --git a/Test/src/com/renchao/Test01.java b/Test/src/com/renchao/Test01.java
index 7537cd76..e1f09119 100644
--- a/Test/src/com/renchao/Test01.java
+++ b/Test/src/com/renchao/Test01.java
@@ -1,6 +1,18 @@
package com.renchao;
+import org.junit.Test;
+import sun.net.www.http.HttpClient;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Arrays;
import java.util.Date;
+import java.util.List;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@@ -16,5 +28,48 @@ public class Test01 {
System.out.println(TimeUnit.NANOSECONDS.toMillis(duration));
}
+
+ @Test
+ public void test02() {
+ List ALLOW_PYTHON_EXT = Arrays.asList("zip", "tar", "gz", "bz2");
+ List ALLOW_DATA_EXT = Arrays.asList("zip", "tar", "gz", "csv", "txt", "xls", "xlsx");
+
+ String fileType = "PYTHONs";
+ String fileExt = "zip";
+
+ boolean isPython = "PYTHON".equals(fileType) && ALLOW_PYTHON_EXT.contains(fileExt);
+ boolean isData = "DATA".equals(fileType) && ALLOW_DATA_EXT.contains(fileExt);
+ if (!isPython && !isData) {
+ System.out.println("文件类型错误");
+ } else {
+ System.out.println("文件类型正确====");
+ }
+ }
+
+ @Test
+ public void test03() throws IOException {
+ String ipAddress = "8.8.8.8"; // 要查询的IP地址
+ String apiKey = "YOUR_API_KEY"; // 在https://ipinfo.io/signup获取您的免费API密钥
+
+ String apiUrl = "http://whois.pconline.com.cn/ipJson.jsp?ip=112.64.187.2&json=true";
+
+ URL url = new URL(apiUrl);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+
+ BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8.name()));
+ StringBuilder response = new StringBuilder();
+ String line;
+
+ while ((line = reader.readLine()) != null) {
+ response.append(line);
+ }
+ reader.close();
+
+ String jsonResponse = response.toString();
+ System.out.println(jsonResponse); // 打印响应,包含地理位置等信息
+
+ // 在这里您可以解析jsonResponse并提取所需的地理位置信息
+ }
+
}
diff --git a/agile-bacth/agile-batch-api/pom.xml b/agile-bacth/agile-batch-api/pom.xml
new file mode 100644
index 00000000..3d301aa0
--- /dev/null
+++ b/agile-bacth/agile-batch-api/pom.xml
@@ -0,0 +1,19 @@
+
+
+
+ agile-bacth
+ com.jiuyv.sptcc.agile.batch
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ agile-batch-api
+
+
+ 8
+ 8
+
+
+
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-dws/pom.xml b/agile-bacth/agile-batch-dws/pom.xml
new file mode 100644
index 00000000..900be25b
--- /dev/null
+++ b/agile-bacth/agile-batch-dws/pom.xml
@@ -0,0 +1,64 @@
+
+
+
+ agile-bacth
+ com.jiuyv.sptcc.agile.batch
+ 1.0-SNAPSHOT
+
+ 4.0.0
+
+ agile-batch-dws
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.apache.hive
+ hive-jdbc
+ 3.1.2
+
+
+
+ org.apache.hbase
+ hbase-server
+
+
+ org.apache.curator
+ curator-framework
+
+
+ org.apache.hive
+ hive-upgrade-acid
+
+
+ org.apache.hive
+ hive-shims
+
+
+ org.apache.hive
+ hive-metastore
+
+
+
+ org.mortbay.jetty
+ jetty
+
+
+ org.eclipse.jetty
+ jetty-runner
+
+
+ org.apache.zookeeper
+ zookeeper
+
+
+
+
+
+
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/.gitignore b/agile-bacth/agile-batch-service/.gitignore
new file mode 100644
index 00000000..549e00a2
--- /dev/null
+++ b/agile-bacth/agile-batch-service/.gitignore
@@ -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/
diff --git a/agile-bacth/agile-batch-service/pom.xml b/agile-bacth/agile-batch-service/pom.xml
new file mode 100644
index 00000000..8e5d1d76
--- /dev/null
+++ b/agile-bacth/agile-batch-service/pom.xml
@@ -0,0 +1,187 @@
+
+
+
+
+ agile-bacth
+ com.jiuyv.sptcc.agile.batch
+ 1.0-SNAPSHOT
+
+
+ 4.0.0
+ agile-batch-service
+ 0.0.1-SNAPSHOT
+ agile-batch-service
+ agile-batch-service
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+ org.mybatis.spring.boot
+ mybatis-spring-boot-starter
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-netflix-eureka-client
+
+
+ org.springframework.cloud
+ spring-cloud-starter-loadbalancer
+
+
+ org.springframework.cloud
+ spring-cloud-starter-config
+
+
+ org.springframework.cloud
+ spring-cloud-starter-bootstrap
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+ org.springframework.boot
+ spring-boot-devtools
+ runtime
+ true
+
+
+ org.postgresql
+ postgresql
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+
+
+
+ org.apache.httpcomponents
+ httpclient
+
+
+ org.apache.curator
+ curator-client
+ 2.12.0
+
+
+ org.apache.curator
+ curator-framework
+ 2.12.0
+
+
+ com.fasterxml.woodstox
+ woodstox-core
+ 6.2.1
+
+
+ org.codehaus.woodstox
+ woodstox-core-asl
+ 4.4.1
+
+
+ commons-collections
+ commons-collections
+ 3.2.2
+
+
+ commons-configuration
+ commons-configuration
+ 1.10
+
+
+ org.apache.commons
+ commons-configuration2
+ 2.9.0
+
+
+ org.apache.commons
+ commons-lang3
+
+
+
+
+ net.logstash.logback
+ logstash-logback-encoder
+ 6.4
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+ 2.1.1.RELEASE
+
+ true
+
+
+
+
+ repackage
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ 1.8
+ 1.8
+ UTF-8
+
+ ${project.basedir}/src/main/resources/libx
+
+
+
+
+
+
+
+ src/main/resources
+
+ **/*
+
+
+ libx/**
+ config/hiveJsy/**
+
+ false
+
+
+
+ src/main/resources/libx
+ BOOT-INF/lib/
+
+ **/*.jar
+
+
+
+
+
+
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/AgileBatchServiceApplication.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/AgileBatchServiceApplication.java
new file mode 100644
index 00000000..9b0bb157
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/AgileBatchServiceApplication.java
@@ -0,0 +1,17 @@
+package com.jiuyv.sptcc.agile.batch;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.transaction.annotation.EnableTransactionManagement;
+
+@EnableScheduling
+@SpringBootApplication
+@EnableTransactionManagement
+public class AgileBatchServiceApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(AgileBatchServiceApplication.class, args);
+ }
+
+}
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/common/TblBatchTaskEnum.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/common/TblBatchTaskEnum.java
new file mode 100644
index 00000000..bcff8d61
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/common/TblBatchTaskEnum.java
@@ -0,0 +1,58 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.common;
+
+/**
+ * 批处理任务表枚举
+ * @author zhouliang
+ *
+ */
+public class TblBatchTaskEnum {
+
+ /** 业务状态*/
+ public enum BUS_STATUS {
+ RUNING("runing", "任务运行中"),
+ //三个结束都等价任务未运行
+ END("end", "强制结束"),//如果任务运行中项目重启,那么会更新为此状态.
+ FINISH("finish", "正常结束"),
+ UNFINISH("unfinish", "异常结束"),
+
+ ;
+ private String code;
+ private String msg;
+
+ BUS_STATUS(String code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+ }
+
+ /** 数据状态*/
+ public enum DATA_STATUS {
+ NORMAL("00", "正常"),
+ DELETED("99", "删除"),
+
+ ;
+ private String code;
+ private String msg;
+
+ DATA_STATUS(String code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+ }
+}
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/TblBatchTableMapping.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/TblBatchTableMapping.java
new file mode 100644
index 00000000..e95489a7
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/TblBatchTableMapping.java
@@ -0,0 +1,274 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+/**
+ * 批处理同步表映射表
+ * @author zhouliang
+ * @date 2023-07-24
+ */
+public class TblBatchTableMapping implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** 任务编号 */
+ private String taskNo;
+
+ /** 版本号 */
+ private Long versionNum;
+
+ /** 随机码 */
+ private String recToken;
+
+ /** 远程表查询sql */
+ private String remoteTableSql;
+
+ /** 远程数据库 */
+ private String remoteDbName;
+
+ /** 远程前推天数 */
+ private Integer remoteDays;
+
+ /** 本地表编码 */
+ private String localTable;
+
+ /** 本地数据库 */
+ private String localDbName;
+
+ /** 本地前置sql */
+ private String localPreSql;
+
+
+ /** 映射关系 */
+ private String mappingJson;
+
+ /** 备注 */
+ private String remarks;
+
+ /** 数据状态 */
+ private String dataStatus;
+
+ /** 更新时间 */
+ private Date updateTime;
+
+ /** 备用字段1 */
+ private String rsv1;
+
+ /** 备用字段2 */
+ private String rsv2;
+
+ /** 备用字段3 */
+ private String rsv3;
+
+
+
+ /**
+ * Get任务编号
+ */
+ public String getTaskNo(){
+ return taskNo;
+ }
+ /**
+ * Set任务编号
+ */
+ public void setTaskNo(String taskNo){
+ this.taskNo = taskNo;
+ }
+
+ /**
+ * Get版本号
+ */
+ public Long getVersionNum(){
+ return versionNum;
+ }
+ /**
+ * Set版本号
+ */
+ public void setVersionNum(Long versionNum){
+ this.versionNum = versionNum;
+ }
+
+ /**
+ * Get随机码
+ */
+ public String getRecToken(){
+ return recToken;
+ }
+ /**
+ * Set随机码
+ */
+ public void setRecToken(String recToken){
+ this.recToken = recToken;
+ }
+
+ /**
+ * Get远程表查询sql
+ */
+ public String getRemoteTableSql(){
+ return remoteTableSql;
+ }
+ /**
+ * Set远程表查询sql
+ */
+ public void setRemoteTableSql(String remoteTableSql){
+ this.remoteTableSql = remoteTableSql;
+ }
+
+ /**
+ * Get远程数据库
+ */
+ public String getRemoteDbName(){
+ return remoteDbName;
+ }
+ /**
+ * Set远程数据库
+ */
+ public void setRemoteDbName(String remoteDbName){
+ this.remoteDbName = remoteDbName;
+ }
+
+ /**
+ * Get远程前推天数
+ */
+ public Integer getRemoteDays() {
+ return remoteDays;
+ }
+ /**
+ * Set远程前推天数
+ */
+ public void setRemoteDays(Integer remoteDays) {
+ this.remoteDays = remoteDays;
+ }
+
+ /**
+ * Get本地表编码
+ */
+ public String getLocalTable(){
+ return localTable;
+ }
+ /**
+ * Set本地表编码
+ */
+ public void setLocalTable(String localTable){
+ this.localTable = localTable;
+ }
+
+ /**
+ * Get本地数据库
+ */
+ public String getLocalDbName(){
+ return localDbName;
+ }
+ /**
+ * Set本地数据库
+ */
+ public void setLocalDbName(String localDbName){
+ this.localDbName = localDbName;
+ }
+
+ /**
+ * Get本地前置sql
+ */
+ public String getLocalPreSql() {
+ return localPreSql;
+ }
+ /**
+ * Set本地前置sql
+ */
+ public void setLocalPreSql(String localPreSql) {
+ this.localPreSql = localPreSql;
+ }
+
+ /**
+ * Get映射关系
+ */
+ public String getMappingJson(){
+ return mappingJson;
+ }
+ /**
+ * Set映射关系
+ */
+ public void setMappingJson(String mappingJson){
+ this.mappingJson = mappingJson;
+ }
+
+ /**
+ * Get备注
+ */
+ public String getRemarks(){
+ return remarks;
+ }
+ /**
+ * Set备注
+ */
+ public void setRemarks(String remarks){
+ this.remarks = remarks;
+ }
+
+ /**
+ * Get数据状态
+ */
+ public String getDataStatus(){
+ return dataStatus;
+ }
+ /**
+ * Set数据状态
+ */
+ public void setDataStatus(String dataStatus){
+ this.dataStatus = dataStatus;
+ }
+
+ /**
+ * Get更新时间
+ */
+ public Date getUpdateTime(){
+ return updateTime;
+ }
+ /**
+ * Set更新时间
+ */
+ public void setUpdateTime(Date updateTime){
+ this.updateTime = updateTime;
+ }
+
+ /**
+ * Get备用字段1
+ */
+ public String getRsv1(){
+ return rsv1;
+ }
+ /**
+ * Set备用字段1
+ */
+ public void setRsv1(String rsv1){
+ this.rsv1 = rsv1;
+ }
+
+ /**
+ * Get备用字段2
+ */
+ public String getRsv2(){
+ return rsv2;
+ }
+ /**
+ * Set备用字段2
+ */
+ public void setRsv2(String rsv2){
+ this.rsv2 = rsv2;
+ }
+
+ /**
+ * Get备用字段3
+ */
+ public String getRsv3(){
+ return rsv3;
+ }
+ /**
+ * Set备用字段3
+ */
+ public void setRsv3(String rsv3){
+ this.rsv3 = rsv3;
+ }
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/TblBatchTask.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/TblBatchTask.java
new file mode 100644
index 00000000..71f08514
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/TblBatchTask.java
@@ -0,0 +1,258 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+
+/**
+ * 批处理任务表
+ * @author zhouliang
+ * @date 2023-07-05
+ */
+public class TblBatchTask implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** 任务编号 */
+ private String taskNo;
+
+ /** 版本号 */
+ private Long versionNum;
+
+ /** 随机码 */
+ private String recToken;
+
+ /** 任务名称 */
+ private String taskTitle;
+
+ /** 上次开始时间 */
+ private Date preStartDate;
+
+ /** 上次结束时间 */
+ private Date preEndDate;
+
+ /** 上次耗时 */
+ private String preTotalTime;
+
+ /** 当前开始时间 */
+ private Date currStartDate;
+
+ /** 失败数据条件 */
+ private String failureConditions;
+
+ /** 任务状态 */
+ private String busStatus;
+
+ /** 数据状态 */
+ private String dataStatus;
+
+ /** 更新时间 */
+ private Date updateTime;
+
+ /** 备用字段1 */
+ private String rsv1;
+
+ /** 备用字段2 */
+ private String rsv2;
+
+ /** 备用字段3 */
+ private String rsv3;
+
+
+
+ /**
+ * Get任务编号
+ */
+ public String getTaskNo(){
+ return taskNo;
+ }
+ /**
+ * Set任务编号
+ */
+ public void setTaskNo(String taskNo){
+ this.taskNo = taskNo;
+ }
+
+ /**
+ * Get版本号
+ */
+ public Long getVersionNum(){
+ return versionNum;
+ }
+ /**
+ * Set版本号
+ */
+ public void setVersionNum(Long versionNum){
+ this.versionNum = versionNum;
+ }
+
+ /**
+ * Get随机码
+ */
+ public String getRecToken(){
+ return recToken;
+ }
+ /**
+ * Set随机码
+ */
+ public void setRecToken(String recToken){
+ this.recToken = recToken;
+ }
+
+ /**
+ * Get任务名称
+ */
+ public String getTaskTitle(){
+ return taskTitle;
+ }
+ /**
+ * Set任务名称
+ */
+ public void setTaskTitle(String taskTitle){
+ this.taskTitle = taskTitle;
+ }
+
+ /**
+ * Get上次开始时间
+ */
+ public Date getPreStartDate(){
+ return preStartDate;
+ }
+ /**
+ * Set上次开始时间
+ */
+ public void setPreStartDate(Date preStartDate){
+ this.preStartDate = preStartDate;
+ }
+
+ /**
+ * Get上次结束时间
+ */
+ public Date getPreEndDate(){
+ return preEndDate;
+ }
+ /**
+ * Set上次结束时间
+ */
+ public void setPreEndDate(Date preEndDate){
+ this.preEndDate = preEndDate;
+ }
+
+ /**
+ * Get上次耗时
+ */
+ public String getPreTotalTime(){
+ return preTotalTime;
+ }
+ /**
+ * Set上次耗时
+ */
+ public void setPreTotalTime(String preTotalTime){
+ this.preTotalTime = preTotalTime;
+ }
+
+ /**
+ * Get当前开始时间
+ */
+ public Date getCurrStartDate(){
+ return currStartDate;
+ }
+ /**
+ * Set当前开始时间
+ */
+ public void setCurrStartDate(Date currStartDate){
+ this.currStartDate = currStartDate;
+ }
+
+ /**
+ * Get失败数据条件
+ */
+ public String getFailureConditions(){
+ return failureConditions;
+ }
+ /**
+ * Set失败数据条件
+ */
+ public void setFailureConditions(String failureConditions){
+ this.failureConditions = failureConditions;
+ }
+
+ /**
+ * Get任务状态
+ */
+ public String getBusStatus(){
+ return busStatus;
+ }
+ /**
+ * Set任务状态
+ */
+ public void setBusStatus(String busStatus){
+ this.busStatus = busStatus;
+ }
+
+ /**
+ * Get数据状态
+ */
+ public String getDataStatus(){
+ return dataStatus;
+ }
+ /**
+ * Set数据状态
+ */
+ public void setDataStatus(String dataStatus){
+ this.dataStatus = dataStatus;
+ }
+
+ /**
+ * Get更新时间
+ */
+ public Date getUpdateTime(){
+ return updateTime;
+ }
+ /**
+ * Set更新时间
+ */
+ public void setUpdateTime(Date updateTime){
+ this.updateTime = updateTime;
+ }
+
+ /**
+ * Get备用字段1
+ */
+ public String getRsv1(){
+ return rsv1;
+ }
+ /**
+ * Set备用字段1
+ */
+ public void setRsv1(String rsv1){
+ this.rsv1 = rsv1;
+ }
+
+ /**
+ * Get备用字段2
+ */
+ public String getRsv2(){
+ return rsv2;
+ }
+ /**
+ * Set备用字段2
+ */
+ public void setRsv2(String rsv2){
+ this.rsv2 = rsv2;
+ }
+
+ /**
+ * Get备用字段3
+ */
+ public String getRsv3(){
+ return rsv3;
+ }
+ /**
+ * Set备用字段3
+ */
+ public void setRsv3(String rsv3){
+ this.rsv3 = rsv3;
+ }
+
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/vo/TblBatchTableMappingVO.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/vo/TblBatchTableMappingVO.java
new file mode 100644
index 00000000..37b1760e
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/vo/TblBatchTableMappingVO.java
@@ -0,0 +1,16 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.entity.vo;
+
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTableMapping;
+
+ /**
+ * 批处理同步表映射表,扩展
+ * @author zhouliang
+ * @date 2023-07-24
+ */
+public class TblBatchTableMappingVO extends TblBatchTableMapping implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+
+
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/vo/TblBatchTaskVO.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/vo/TblBatchTaskVO.java
new file mode 100644
index 00000000..bd604449
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/entity/vo/TblBatchTaskVO.java
@@ -0,0 +1,38 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.entity.vo;
+
+import java.util.List;
+
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTableMapping;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTask;
+
+ /**
+ * 批处理任务表,扩展
+ * @author zhouliang
+ * @date 2023-07-05
+ */
+public class TblBatchTaskVO extends TblBatchTask implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** 任务状态集合 */
+ private List busStatuss;
+
+ private TblBatchTableMapping mappingInfo;
+
+
+ public List getBusStatuss() {
+ return busStatuss;
+ }
+
+ public void setBusStatuss(List busStatuss) {
+ this.busStatuss = busStatuss;
+ }
+
+ public TblBatchTableMapping getMappingInfo() {
+ return mappingInfo;
+ }
+
+ public void setMappingInfo(TblBatchTableMapping mappingInfo) {
+ this.mappingInfo = mappingInfo;
+ }
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/mapper/TblBatchTableMappingMapper.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/mapper/TblBatchTableMappingMapper.java
new file mode 100644
index 00000000..df39ed9f
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/mapper/TblBatchTableMappingMapper.java
@@ -0,0 +1,20 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTableMapping;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTableMappingVO;
+
+
+/**
+ * 批处理同步表映射表
+ * @author zhouliang
+ * @date 2023-07-24
+ */
+@Mapper
+public interface TblBatchTableMappingMapper{
+
+ /** 查询单条 */
+ TblBatchTableMapping selectOneByMap(TblBatchTableMappingVO paramMap);
+
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/mapper/TblBatchTaskMapper.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/mapper/TblBatchTaskMapper.java
new file mode 100644
index 00000000..60ee19fa
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/mapper/TblBatchTaskMapper.java
@@ -0,0 +1,28 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTask;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTaskVO;
+
+
+/**
+ * 批处理任务表
+ * @author zhouliang
+ * @date 2023-07-05
+ */
+@Mapper
+public interface TblBatchTaskMapper{
+
+ /** 查询单条 */
+ TblBatchTaskVO selectOneByMap(TblBatchTaskVO paramMap);
+
+
+ /** 更新记录 */
+ int updateByMap(@Param("vo") TblBatchTask record,@Param("map") TblBatchTaskVO paramMap);
+
+ /** 重置全部任务 */
+ void updateResetAllBusStatus(@Param("vo") TblBatchTask record,@Param("map") TblBatchTaskVO paramMap);
+
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/service/BatchTaskServiceImpl.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/service/BatchTaskServiceImpl.java
new file mode 100644
index 00000000..509557a8
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/service/BatchTaskServiceImpl.java
@@ -0,0 +1,174 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.service;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.UUID;
+
+import javax.annotation.PostConstruct;
+
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.jiuyv.sptcc.agile.batch.batchTask.common.TblBatchTaskEnum;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTableMapping;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTask;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTableMappingVO;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTaskVO;
+import com.jiuyv.sptcc.agile.batch.batchTask.mapper.TblBatchTableMappingMapper;
+import com.jiuyv.sptcc.agile.batch.batchTask.mapper.TblBatchTaskMapper;
+import com.jiuyv.sptcc.agile.batch.common.BaseTime;
+import com.jiuyv.sptcc.agile.batch.dao.ISysTimeBaseMapper;
+
+
+/**
+ * 批处理任务表
+ * @author zhouliang
+ * @date 2023-07-05
+ */
+@Service("batchTaskService")
+public class BatchTaskServiceImpl implements IBatchTaskService {
+ @Autowired
+ private TblBatchTaskMapper tblBatchTaskMapper;
+ @Autowired
+ private TblBatchTableMappingMapper tblBatchTableMappingMapper;
+ @Autowired
+ private ISysTimeBaseMapper sysTimeBaseMapper;
+
+ @Override
+ public TblBatchTaskVO getDetailBatchTask(String taskNo) throws Exception {
+ TblBatchTaskVO batchTaskParamMap = new TblBatchTaskVO();
+ batchTaskParamMap.setTaskNo(taskNo);
+ TblBatchTaskVO batchTaskRecord = tblBatchTaskMapper.selectOneByMap(batchTaskParamMap);
+ if(batchTaskRecord!=null) {
+ //查询同步配置,这个有没有取决于业务自己的实现
+ TblBatchTableMappingVO batchTaskMappingParamMap = new TblBatchTableMappingVO();
+ batchTaskMappingParamMap.setTaskNo(taskNo);
+ TblBatchTableMapping batchTaskMappingRecord = tblBatchTableMappingMapper.selectOneByMap(batchTaskMappingParamMap);
+ batchTaskRecord.setMappingInfo(batchTaskMappingRecord);
+ }
+ return batchTaskRecord;
+ }
+
+ @Override
+ public void doBatchTaskReset(String taskNo) throws Exception {
+ BaseTime timeVO = sysTimeBaseMapper.selectSysCurrentTime();
+ TblBatchTask batchTaskRecord = new TblBatchTask();
+ batchTaskRecord.setBusStatus(TblBatchTaskEnum.BUS_STATUS.END.getCode());
+ batchTaskRecord.setUpdateTime(timeVO.getDate());
+ TblBatchTaskVO batchTaskParamMap = new TblBatchTaskVO();
+ batchTaskParamMap.setTaskNo(taskNo);
+ batchTaskParamMap.setBusStatus(TblBatchTaskEnum.BUS_STATUS.RUNING.getCode());
+ tblBatchTaskMapper.updateByMap(batchTaskRecord, batchTaskParamMap);
+ }
+
+ @Override
+ public void doBatchTaskReset(List excludedTaskNos) throws Exception {
+ BaseTime timeVO = sysTimeBaseMapper.selectSysCurrentTime();
+ TblBatchTask batchTaskRecord = new TblBatchTask();
+ batchTaskRecord.setBusStatus(TblBatchTaskEnum.BUS_STATUS.END.getCode());
+ batchTaskRecord.setUpdateTime(timeVO.getDate());
+ TblBatchTaskVO batchTaskParamMap = new TblBatchTaskVO();
+ batchTaskParamMap.setBusStatus(TblBatchTaskEnum.BUS_STATUS.RUNING.getCode());
+ tblBatchTaskMapper.updateResetAllBusStatus(batchTaskRecord, batchTaskParamMap);
+ }
+
+ @Override
+ public boolean doBatchTaskStart(TblBatchTask task) throws Exception {
+ BaseTime timeVO = sysTimeBaseMapper.selectSysCurrentTime();
+ task.setCurrStartDate(timeVO.getDate());//当前开始时间
+ TblBatchTask batchTaskRecord = new TblBatchTask();
+ batchTaskRecord.setBusStatus(TblBatchTaskEnum.BUS_STATUS.RUNING.getCode());
+ batchTaskRecord.setRecToken(getNewRecToken());
+ batchTaskRecord.setCurrStartDate(timeVO.getDate());//当前开始时间
+ batchTaskRecord.setUpdateTime(timeVO.getDate());
+ TblBatchTaskVO batchTaskParamMap = new TblBatchTaskVO();
+ batchTaskParamMap.setTaskNo(task.getTaskNo());
+ batchTaskParamMap.setVersionNum(task.getVersionNum());//避免开始多次任务
+ batchTaskParamMap.setRecToken(task.getRecToken());//避免开始多次任务
+ List busStatuss=new ArrayList<>();//非运行状态
+ busStatuss.add(TblBatchTaskEnum.BUS_STATUS.FINISH.getCode());
+ busStatuss.add(TblBatchTaskEnum.BUS_STATUS.UNFINISH.getCode());
+ busStatuss.add(TblBatchTaskEnum.BUS_STATUS.END.getCode());
+ batchTaskParamMap.setBusStatuss(busStatuss);
+ int num = tblBatchTaskMapper.updateByMap(batchTaskRecord, batchTaskParamMap);
+ return num!=0;
+ }
+
+ @Override
+ public void doBatchTaskFinish(TblBatchTask task) throws Exception {
+ BaseTime timeVO = sysTimeBaseMapper.selectSysCurrentTime();
+ TblBatchTask batchTaskRecord = new TblBatchTask();
+ batchTaskRecord.setBusStatus(TblBatchTaskEnum.BUS_STATUS.FINISH.getCode());
+ batchTaskRecord.setRecToken(getNewRecToken());
+ //结束时
+ batchTaskRecord.setFailureConditions("");
+ batchTaskRecord.setPreStartDate(task.getCurrStartDate());
+ batchTaskRecord.setPreEndDate(timeVO.getDate());
+ batchTaskRecord.setPreTotalTime(getTotalTime(batchTaskRecord.getPreStartDate(),batchTaskRecord.getPreEndDate()));
+ batchTaskRecord.setUpdateTime(timeVO.getDate());
+ TblBatchTaskVO batchTaskParamMap = new TblBatchTaskVO();
+ batchTaskParamMap.setTaskNo(task.getTaskNo());
+ batchTaskParamMap.setBusStatus(TblBatchTaskEnum.BUS_STATUS.RUNING.getCode());
+ tblBatchTaskMapper.updateByMap(batchTaskRecord, batchTaskParamMap);
+ }
+
+ @Override
+ public void doBatchTaskUnFinish(TblBatchTask task) throws Exception {
+ BaseTime timeVO = sysTimeBaseMapper.selectSysCurrentTime();
+ TblBatchTask batchTaskRecord = new TblBatchTask();
+ batchTaskRecord.setBusStatus(TblBatchTaskEnum.BUS_STATUS.UNFINISH.getCode());
+ batchTaskRecord.setRecToken(getNewRecToken());
+ //结束时,如果需要根据条件重新跑就存到FailureConditions,比如标志、日期、id等等
+ batchTaskRecord.setFailureConditions(StringUtils.isNotBlank(task.getFailureConditions())?task.getFailureConditions():"");
+ batchTaskRecord.setPreStartDate(task.getCurrStartDate());
+ batchTaskRecord.setPreEndDate(timeVO.getDate());
+ batchTaskRecord.setPreTotalTime(getTotalTime(batchTaskRecord.getPreStartDate(),batchTaskRecord.getPreEndDate()));
+ batchTaskRecord.setUpdateTime(timeVO.getDate());
+ TblBatchTaskVO batchTaskParamMap = new TblBatchTaskVO();
+ batchTaskParamMap.setTaskNo(task.getTaskNo());
+ batchTaskParamMap.setBusStatus(TblBatchTaskEnum.BUS_STATUS.RUNING.getCode());
+ tblBatchTaskMapper.updateByMap(batchTaskRecord, batchTaskParamMap);
+ }
+
+ private String getNewRecToken() {
+ return UUID.randomUUID().toString().substring(0,8);
+ }
+ /**
+ * 计算任务耗时
+ * @param start
+ * @param end
+ * @return
+ */
+ private String getTotalTime(Date start,Date end) {
+ // 获取日期间的时间差
+ long diff = end.getTime() - start.getTime();
+ // 计算小时、分钟和秒
+ long totaltime=(diff / 1000);
+ String totaltimeUnit="秒";
+ if(totaltime>=60) {
+ totaltime=totaltime/60;
+ totaltimeUnit="分";
+ }
+ if(totaltime>=60) {
+ totaltime=totaltime/60;
+ totaltimeUnit="小时";
+ }
+ return totaltime+totaltimeUnit;
+ }
+
+
+
+ @PostConstruct
+ public void taskInit() {
+ //默认项目重启就应该重置任务状态,没完成的任务状态肯定有问题
+ List excludedTaskNos=new ArrayList<>();
+ //如果不需要重置的自行排除
+ try {
+ this.doBatchTaskReset(excludedTaskNos);
+ } catch (Exception e) {
+ //不报错
+ }
+ }
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/service/IBatchTaskService.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/service/IBatchTaskService.java
new file mode 100644
index 00000000..1f401aee
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/batchTask/service/IBatchTaskService.java
@@ -0,0 +1,57 @@
+package com.jiuyv.sptcc.agile.batch.batchTask.service;
+
+import java.util.List;
+
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTask;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTaskVO;
+
+
+/**
+ * 批处理任务表
+ * @author zhouliang
+ * @date 2023-07-05
+ */
+public interface IBatchTaskService {
+
+ /** 获取任务详情*/
+ public TblBatchTaskVO getDetailBatchTask(String taskNo) throws Exception;
+
+ /**
+ * 重置任务
+ * 让任务回到未运行状态
+ * @param taskNo
+ * @throws Exception
+ */
+ public void doBatchTaskReset(String taskNo) throws Exception;
+ /**
+ * 重置全部任务
+ * 让任务回到未运行状态
+ * @param excludedTaskNos 排除任务
+ * @throws Exception
+ */
+ public void doBatchTaskReset(List excludedTaskNos) throws Exception;
+ /**
+ * 开始任务
+ * 任务如何重跑,由业务代码实现
+ * @param taskNo
+ * @param versionNum
+ * @param recToken
+ * @return 如果任务已在运行则返回false,反之true
+ * @throws Exception
+ */
+ public boolean doBatchTaskStart(TblBatchTask task) throws Exception;
+
+ /**
+ * 正常结束任务
+ * 任务如何重跑,由业务代码实现
+ */
+ public void doBatchTaskFinish(TblBatchTask task) throws Exception;
+
+ /**
+ * 异常结束任务
+ * 任务如何重跑,由业务代码实现
+ * @param taskNo
+ * @throws Exception
+ */
+ public void doBatchTaskUnFinish(TblBatchTask task) throws Exception;
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/BaseTime.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/BaseTime.java
new file mode 100644
index 00000000..6e50a2e2
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/BaseTime.java
@@ -0,0 +1,85 @@
+package com.jiuyv.sptcc.agile.batch.common;
+
+import java.time.Instant;
+import java.util.Date;
+
+/**
+ * 时间对象
+ * @author zhouliang
+ *
+ */
+public class BaseTime implements java.io.Serializable {
+
+ /** default Serial Version UID*/
+ private static final long serialVersionUID = 1L;
+
+ /** 当前时区 */
+ private String timeZone ="+08:00";
+
+ /** 当前时区 YYYY-MM-DD */
+ private String dateDay;
+
+ /** 当前时区 YYYY-MM-DD HH:MM:SS */
+ private String dateTime;
+
+ /** 当前时区日期 */
+ private Date date;
+
+ /** UTC-0 带时区时间 */
+ private Instant utcTime;
+
+ /** UTC-0 带时区时间 */
+ private String utcTimeStr;
+
+ public String getTimeZone() {
+ return timeZone;
+ }
+
+ public void setTimeZone(String timeZone) {
+ this.timeZone = timeZone;
+ }
+
+ public String getDateDay() {
+ return dateDay;
+ }
+
+ public void setDateDay(String dateDay) {
+ this.dateDay = dateDay;
+ }
+
+ public String getDateTime() {
+ return dateTime;
+ }
+
+ public void setDateTime(String dateTime) {
+ this.dateTime = dateTime;
+ }
+
+ public Date getDate() {
+ return date;
+ }
+
+ public void setDate(Date date) {
+ this.date = date;
+ }
+
+ public Instant getUtcTime() {
+ return utcTime;
+ }
+
+ public void setUtcTime(Instant utcTime) {
+ this.utcTime = utcTime;
+ }
+
+ public String getUtcTimeStr() {
+ return utcTimeStr;
+ }
+
+ public void setUtcTimeStr(String utcTimeStr) {
+ this.utcTimeStr = utcTimeStr;
+ }
+
+ public String getYearMonth() {
+ return dateDay.substring(0,7);
+ }
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/JsonUtil.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/JsonUtil.java
new file mode 100644
index 00000000..f34a483c
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/JsonUtil.java
@@ -0,0 +1,153 @@
+package com.jiuyv.sptcc.agile.batch.common;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.core.JsonGenerator.Feature;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.JavaType;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+
+
+/**
+ *
+ * @author zhouliang
+ *
+ */
+public abstract class JsonUtil {
+
+ /**
+ * The Constant LOGGER.
+ */
+ private static final Logger LOGGER = LoggerFactory.getLogger(JsonUtil.class);
+
+ private JsonUtil() {
+ throw new IllegalStateException("Utility class");
+ }
+
+ /**
+ * The object mapper.
+ */
+ private static ObjectMapper objectMapper = new ObjectMapper();
+
+ static {
+ objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+ objectMapper.setSerializationInclusion(Include.NON_NULL);
+ objectMapper.configure(Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
+ objectMapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
+ objectMapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);//允许单引号
+ }
+ public static ObjectMapper JsonMapper(){
+ return objectMapper;
+ }
+
+ /**
+ * 转为json字符串
+ *
+ * @param object the object
+ * @return the string
+ */
+ public static String toJSONString(Object object) {
+ try {
+ return objectMapper.writeValueAsString(object);
+ } catch (Exception e) {
+ LOGGER.error("convert failed", e);
+ return "";
+ }
+ }
+
+ /**
+ * json字符串转为对象
+ * @param
+ * @param json
+ * @param clz
+ * @return
+ */
+ public static T json2Bean(String json, Class clz) {
+ try {
+ return objectMapper.readValue(json, clz);
+ } catch (Exception e) {
+ LOGGER.error("convert failed", e);
+ return null;
+ }
+ }
+ /**
+ * json字符串转为对象
+ * @param
+ * @param json
+ * @param clz
+ * @return
+ */
+ public static T json2Bean(String json, JavaType clz) {
+ try {
+ return objectMapper.readValue(json, clz);
+ } catch (Exception e) {
+ LOGGER.error("convert failed", e);
+ return null;
+ }
+ }
+
+ /**
+ * 转为对象集合
+ * @param
+ * @param json
+ * @param clz
+ * @return
+ */
+ public static List json2List(String json, Class clz) {
+ try {
+ JavaType javaType = getCollectionType(ArrayList.class, clz);
+ return objectMapper.readValue(json, javaType);
+ } catch (Exception e) {
+ LOGGER.error("convert failed", e);
+ return new ArrayList<>();
+ }
+ }
+
+ /**
+ * 获取泛型的Collection Type
+ *
+ * @param collectionClass 泛型的Collection
+ * @param elementClasses 元素类
+ * @return JavaType Java类型
+ * @since 1.0
+ */
+ public static JavaType getCollectionType(Class> collectionClass, Class>... elementClasses) {
+ return objectMapper.getTypeFactory().constructParametricType(collectionClass, elementClasses);
+ }
+
+ /**
+ * json字符转ArrayNode
+ * @param json
+ * @return
+ */
+ public static ArrayNode parseArray(String json) {
+ try {
+ return (ArrayNode) objectMapper.readTree(json);
+ } catch (Exception e) {
+ LOGGER.error("convert failed", e);
+ return null;
+ }
+ }
+ /**
+ * json字符转ObjectNode
+ * @param json
+ * @return
+ */
+ public static ObjectNode parseObject(String json) {
+ try {
+ return (ObjectNode) objectMapper.readTree(json);
+ } catch (Exception e) {
+ LOGGER.error("convert failed", e);
+ return null;
+ }
+ }
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/R.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/R.java
new file mode 100644
index 00000000..4b7b25e9
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/R.java
@@ -0,0 +1,135 @@
+package com.jiuyv.sptcc.agile.batch.common;
+
+import java.io.Serializable;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.http.HttpStatus;
+
+import com.fasterxml.jackson.annotation.JsonIgnore;
+
+/**
+ * 响应信息主体
+ *
+ * @author admin
+ */
+public class R implements Serializable
+{
+ private static final Logger log = LoggerFactory.getLogger(R.class);
+
+ private static final long serialVersionUID = 1L;
+
+ /** 成功 */
+ public static final int SUCCESS = 200;
+
+ /** 失败 */
+ public static final int FAIL = 500;
+
+ /**
+ * 应答码,默认200为成功
+ */
+ private int code;
+
+ /**
+ * 应答描述
+ */
+ private String msg;
+
+ /**
+ * 返回数据
+ */
+ private T data;
+
+ public static R ok()
+ {
+ return restResult(null, SUCCESS, "操作成功");
+ }
+
+ public static R ok(T data)
+ {
+ return restResult(data, SUCCESS, "操作成功");
+ }
+
+ public static R ok(T data, String msg)
+ {
+ return restResult(data, SUCCESS, msg);
+ }
+
+ public static R fail()
+ {
+ return restResult(null, FAIL, "操作失败");
+ }
+
+ public static R fail(String msg)
+ {
+ return restResult(null, FAIL, msg);
+ }
+
+ public static R fail(T data)
+ {
+ return restResult(data, FAIL, "操作失败");
+ }
+
+ public static R fail(T data, String msg)
+ {
+ return restResult(data, FAIL, msg);
+ }
+
+ public static R fail(int code, String msg)
+ {
+ return restResult(null, code, msg);
+ }
+
+ private static R restResult(T data, int code, String msg)
+ {
+ if(SUCCESS!=code) {
+ //异常要输出
+ log.info("Return Business Exception >> code={}, msg={}",code, msg);
+ }
+ R apiResult = new R<>();
+ apiResult.setCode(code);
+ apiResult.setData(data);
+ apiResult.setMsg(msg);
+ return apiResult;
+ }
+
+ public int getCode()
+ {
+ return code;
+ }
+
+ public void setCode(int code)
+ {
+ this.code = code;
+ }
+
+ public String getMsg()
+ {
+ return msg;
+ }
+
+ public void setMsg(String msg)
+ {
+ this.msg = msg;
+ }
+
+ public T getData()
+ {
+ return data;
+ }
+
+ public void setData(T data)
+ {
+ this.data = data;
+ }
+
+ /**
+ * 这里只处理200成功,如果不是则那么不要使用,自行单独判断
+ * @return
+ */
+ @JsonIgnore
+ public boolean isSuccess()
+ {
+ return code==SUCCESS;
+ }
+}
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/BaseDao.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/BaseDao.java
new file mode 100644
index 00000000..66410c34
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/BaseDao.java
@@ -0,0 +1,10 @@
+package com.jiuyv.sptcc.agile.batch.dao;
+
+/**
+ * @ClassName : BaseDao
+ * @Description : 公告类
+ * @Author : sky
+ * @Date: 2023-06-07 15:27
+ */
+public interface BaseDao {
+}
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/ISysTimeBaseMapper.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/ISysTimeBaseMapper.java
new file mode 100644
index 00000000..ba431fa8
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/ISysTimeBaseMapper.java
@@ -0,0 +1,15 @@
+package com.jiuyv.sptcc.agile.batch.dao;
+
+import org.apache.ibatis.annotations.Mapper;
+
+import com.jiuyv.sptcc.agile.batch.common.BaseTime;
+
+@Mapper
+public interface ISysTimeBaseMapper {
+
+ /**
+ * 获取系统当前时间-yyyyMMddHHmmss
+ * @return
+ */
+ BaseTime selectSysCurrentTime();
+}
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/framework/GlobalExceptionHandler.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/framework/GlobalExceptionHandler.java
new file mode 100644
index 00000000..40839e6e
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/framework/GlobalExceptionHandler.java
@@ -0,0 +1,43 @@
+package com.jiuyv.sptcc.agile.batch.framework;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.ExceptionHandler;
+import org.springframework.web.bind.annotation.RestControllerAdvice;
+
+import com.jiuyv.sptcc.agile.batch.common.R;
+
+/**
+ * 全局异常处理器
+ *
+ * @author admin
+ */
+@RestControllerAdvice
+public class GlobalExceptionHandler {
+ private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
+
+ /**
+ * 拦截未知的运行时异常
+ */
+ @ExceptionHandler({RuntimeException.class})
+ public R