parent
2e8bae9dca
commit
997069ffac
@ -0,0 +1,85 @@
|
||||
<?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>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.6.7</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<groupId>com.renchao</groupId>
|
||||
<artifactId>Hadoop</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<name>Hadoop</name>
|
||||
<description>Demo project for Spring Boot</description>
|
||||
<properties>
|
||||
<java.version>1.8</java.version>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>org.springframework.boot</groupId>-->
|
||||
<!-- <artifactId>spring-boot-starter</artifactId>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc -->
|
||||
<dependency>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-jdbc</artifactId>
|
||||
<version>3.1.2</version>
|
||||
|
||||
<exclusions>
|
||||
|
||||
<exclusion>
|
||||
<groupId>org.apache.hbase</groupId>
|
||||
<artifactId>hbase-server</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-framework</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-upgrade-acid</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-shims</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-metastore</artifactId>
|
||||
</exclusion>
|
||||
|
||||
<exclusion>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-runner</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
<artifactId>zookeeper</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
@ -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()";
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
<?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>agile-bacth</artifactId>
|
||||
<groupId>com.jiuyv.sptcc.agile.batch</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>agile-batch-api</artifactId>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -0,0 +1,64 @@
|
||||
<?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>agile-bacth</artifactId>
|
||||
<groupId>com.jiuyv.sptcc.agile.batch</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>agile-batch-dws</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.hive/hive-jdbc -->
|
||||
<dependency>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-jdbc</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<exclusions>
|
||||
|
||||
<exclusion>
|
||||
<groupId>org.apache.hbase</groupId>
|
||||
<artifactId>hbase-server</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.curator</groupId>
|
||||
<artifactId>curator-framework</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-upgrade-acid</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-shims</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.hive</groupId>
|
||||
<artifactId>hive-metastore</artifactId>
|
||||
</exclusion>
|
||||
|
||||
<exclusion>
|
||||
<groupId>org.mortbay.jetty</groupId>
|
||||
<artifactId>jetty</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-runner</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.zookeeper</groupId>
|
||||
<artifactId>zookeeper</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -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,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);
|
||||
}
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -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);
|
||||
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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 <T>
|
||||
* @param json
|
||||
* @param clz
|
||||
* @return
|
||||
*/
|
||||
public static <T> T json2Bean(String json, Class<T> clz) {
|
||||
try {
|
||||
return objectMapper.readValue(json, clz);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("convert failed", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* json字符串转为对象
|
||||
* @param <T>
|
||||
* @param json
|
||||
* @param clz
|
||||
* @return
|
||||
*/
|
||||
public static <T> T json2Bean(String json, JavaType clz) {
|
||||
try {
|
||||
return objectMapper.readValue(json, clz);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("convert failed", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 转为对象集合
|
||||
* @param <T>
|
||||
* @param json
|
||||
* @param clz
|
||||
* @return
|
||||
*/
|
||||
public static <T> List<T> json2List(String json, Class<T> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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 {
|
||||
}
|
@ -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();
|
||||
}
|
@ -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<Object> handleRuntimeException(RuntimeException e, HttpServletRequest request, HttpServletResponse response) {
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生未知异常.", requestURI, e);
|
||||
|
||||
return R.fail("系统忙,请稍后再试");
|
||||
}
|
||||
|
||||
/**
|
||||
* 系统异常
|
||||
*/
|
||||
@ExceptionHandler(Exception.class)
|
||||
public R<Object> handleException(Exception e, HttpServletRequest request, HttpServletResponse response) {
|
||||
response.setStatus(301);
|
||||
String requestURI = request.getRequestURI();
|
||||
log.error("请求地址'{}',发生系统异常.", requestURI, e);
|
||||
return R.fail(e.getMessage());
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.jiuyv.sptcc.agile.batch.framework;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
|
||||
|
||||
/**
|
||||
* spring security配置
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true)
|
||||
public class SecurityConfig extends WebSecurityConfigurerAdapter
|
||||
{
|
||||
@Autowired
|
||||
private Environment env;
|
||||
|
||||
@Override
|
||||
protected void configure(HttpSecurity httpSecurity) throws Exception
|
||||
{
|
||||
String actuatorPath = env.getProperty("management.endpoints.web.base-path");
|
||||
if(StringUtils.isBlank(actuatorPath)) {
|
||||
actuatorPath = "/actuator" ;
|
||||
}
|
||||
//优化一下根路径
|
||||
String servletPath = env.getProperty("server.servlet.context-path");
|
||||
if(StringUtils.isNotBlank(servletPath)) {
|
||||
if(servletPath.endsWith("/")) {
|
||||
servletPath=servletPath.substring(0,servletPath.length()-1);
|
||||
}
|
||||
servletPath=servletPath.replaceAll("[^/]+", "**");
|
||||
}else {
|
||||
servletPath="";
|
||||
}
|
||||
httpSecurity
|
||||
.csrf().disable()
|
||||
// 过滤请求
|
||||
.authorizeRequests()
|
||||
.antMatchers(servletPath+actuatorPath+"/shutdown").access("hasIpAddress(\"127.0.0.1\")")
|
||||
.antMatchers(servletPath+actuatorPath+"/**").authenticated()
|
||||
.anyRequest().permitAll()
|
||||
.and().httpBasic();
|
||||
}
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package com.jiuyv.sptcc.agile.batch.syncJiushiData.common;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 数据同步相关常量
|
||||
*/
|
||||
public class SyncDataConstants
|
||||
{
|
||||
private SyncDataConstants() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
//这个主要用于把数据直接写到文件,配置方式和写到数据库一致
|
||||
/** 数据源名称-txt文件 */
|
||||
public static final String DB_NAME_FILE_TXT="txt";
|
||||
/** 数据源名称-csv文件(和txt其实一样) */
|
||||
public static final String DB_NAME_FILE_CSV="csv";
|
||||
|
||||
/** 数据源名称-久事云,要特殊处理 */
|
||||
public static final String DB_NAME_JSY_HIVE_DS="jsyHiveDs";
|
||||
|
||||
/** Kerberos的执行命令 */
|
||||
public static final String SHELL_KERBEROS_KINIT="kinit %s";
|
||||
|
||||
/** 特殊标志,写文件需要标题 */
|
||||
public static final String FLAG_NEED_TITLE="title";
|
||||
|
||||
/** 临时文件后缀 */
|
||||
public static final String TEMP_FILE_EXTENSION ="tmp";
|
||||
|
||||
|
||||
/** 获取sql中的表*/
|
||||
public static final Pattern FROM_TABLE_RULE = Pattern.compile("\\b(FROM|DESC)\\b ([A-Z0-9_]+\\.){0,2}([A-Z]+[A-Z0-9_]*)\\b", Pattern.CASE_INSENSITIVE);
|
||||
public static String getTablecode(String sql) {
|
||||
String tablecode="";
|
||||
Matcher m = SyncDataConstants.FROM_TABLE_RULE.matcher(sql.replace("\n", " "));
|
||||
if(m.find()) {
|
||||
tablecode= m.group(3)+"-";
|
||||
}
|
||||
return tablecode;
|
||||
}
|
||||
/** 获取文件名*/
|
||||
public static final Pattern FILE_NAME_RULE = Pattern.compile("(^.*)(\\.[A-Z0-9]+$)", Pattern.CASE_INSENSITIVE);
|
||||
|
||||
|
||||
//类型转换
|
||||
public static final String CONVERT_TYPE_TO_DATE="Date";
|
||||
public static final String CONVERT_TYPE_TO_INSTANT="Instant";
|
||||
public static final String CONVERT_TYPE_TO_INTEGER="Integer";
|
||||
public static final String CONVERT_TYPE_TO_LONG="Long";
|
||||
public static final String CONVERT_TYPE_TO_BIGDECIMAL="BigDecimal";
|
||||
public static final String CONVERT_TYPE_TO_STRING="String";
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.jiuyv.sptcc.agile.batch.syncJiushiData.common.jsydb;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class KerberosUtilx {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(KerberosUtilx.class);
|
||||
|
||||
public static final String JAVA_VENDER = "java.vendor";
|
||||
public static final String IBM_FLAG = "IBM";
|
||||
public static final String CONFIG_CLASS_FOR_IBM = "com.ibm.security.krb5.internal.Config";
|
||||
public static final String CONFIG_CLASS_FOR_SUN = "sun.security.krb5.Config";
|
||||
public static final String METHOD_GET_INSTANCE = "getInstance";
|
||||
public static final String METHOD_GET_DEFAULT_REALM = "getDefaultRealm";
|
||||
public static final String DEFAULT_REALM = "HADOOP.COM";
|
||||
|
||||
public static String getKrb5DomainRealm() {
|
||||
Class<?> krb5ConfClass;
|
||||
String peerRealm;
|
||||
try {
|
||||
if (System.getProperty(JAVA_VENDER).contains(IBM_FLAG)) {
|
||||
krb5ConfClass = Class.forName(CONFIG_CLASS_FOR_IBM);
|
||||
} else {
|
||||
krb5ConfClass = Class.forName(CONFIG_CLASS_FOR_SUN);
|
||||
}
|
||||
|
||||
Method getInstanceMethod = krb5ConfClass.getMethod(METHOD_GET_INSTANCE);
|
||||
Object kerbConf = getInstanceMethod.invoke(krb5ConfClass);
|
||||
|
||||
Method getDefaultRealmMethod = krb5ConfClass.getDeclaredMethod(METHOD_GET_DEFAULT_REALM);
|
||||
peerRealm = (String)getDefaultRealmMethod.invoke(kerbConf);
|
||||
logger.info("Get default realm successfully, the realm is : " + peerRealm);
|
||||
|
||||
} catch (Exception e) {
|
||||
//e.printStackTrace();
|
||||
peerRealm = DEFAULT_REALM;
|
||||
logger.warn("Get default realm failed, use default value : " + DEFAULT_REALM);
|
||||
}
|
||||
|
||||
return peerRealm;
|
||||
}
|
||||
}
|
@ -0,0 +1,457 @@
|
||||
package com.jiuyv.sptcc.agile.batch.syncJiushiData.common.jsydb;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.security.auth.login.AppConfigurationEntry;
|
||||
import javax.security.auth.login.AppConfigurationEntry.LoginModuleControlFlag;
|
||||
|
||||
import org.apache.hadoop.conf.Configuration;
|
||||
import org.apache.hadoop.security.UserGroupInformation;
|
||||
import org.apache.hadoop.security.authentication.util.KerberosUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class LoginUtil
|
||||
{
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(LoginUtil.class);
|
||||
|
||||
private static final String JAVA_SECURITY_KRB5_CONF_KEY = "java.security.krb5.conf";
|
||||
|
||||
private static final String JAVA_SECURITY_AUTH_USE_SUBJECT_CREDS_ONLY = "javax.security.auth.useSubjectCredsOnly";
|
||||
|
||||
private static final String LOGIN_FAILED_CAUSE_PASSWORD_WRONG =
|
||||
"(wrong password) keytab file and user not match, you can kinit -k -t keytab user in client server to check";
|
||||
|
||||
private static final String LOGIN_FAILED_CAUSE_TIME_WRONG =
|
||||
"(clock skew) time of local server and remote server not match, please check ntp to remote server";
|
||||
|
||||
private static final String LOGIN_FAILED_CAUSE_AES256_WRONG =
|
||||
"(aes256 not support) aes256 not support by default jdk/jre, need copy local_policy.jar and US_export_policy.jar from remote server in path /opt/huawei/Bigdata/jdk/jre/lib/security";
|
||||
|
||||
private static final String LOGIN_FAILED_CAUSE_PRINCIPAL_WRONG =
|
||||
"(no rule) principal format not support by default, need add property hadoop.security.auth_to_local(in core-site.xml) value RULE:[1:$1] RULE:[2:$1]";
|
||||
|
||||
private static final String LOGIN_FAILED_CAUSE_TIME_OUT =
|
||||
"(time out) can not connect to kdc server or there is fire wall in the network";
|
||||
|
||||
private static final boolean IS_IBM_JDK = System.getProperty("java.vendor").contains("IBM");
|
||||
|
||||
public synchronized static void login(String userPrincipal, String userKeytabPath, String krb5ConfPath, Configuration conf)
|
||||
throws IOException
|
||||
{
|
||||
// 1.check input parameters
|
||||
if ((userPrincipal == null) || (userPrincipal.length() <= 0))
|
||||
{
|
||||
LOGGER.error("input userPrincipal is invalid.");
|
||||
throw new IOException("input userPrincipal is invalid.");
|
||||
}
|
||||
|
||||
if ((userKeytabPath == null) || (userKeytabPath.length() <= 0))
|
||||
{
|
||||
LOGGER.error("input userKeytabPath is invalid.");
|
||||
throw new IOException("input userKeytabPath is invalid.");
|
||||
}
|
||||
|
||||
if ((krb5ConfPath == null) || (krb5ConfPath.length() <= 0))
|
||||
{
|
||||
LOGGER.error("input krb5ConfPath is invalid.");
|
||||
throw new IOException("input krb5ConfPath is invalid.");
|
||||
}
|
||||
|
||||
if ((conf == null))
|
||||
{
|
||||
LOGGER.error("input conf is invalid.");
|
||||
throw new IOException("input conf is invalid.");
|
||||
}
|
||||
|
||||
// 2.check file exsits
|
||||
File userKeytabFile = new File(userKeytabPath);
|
||||
if (!userKeytabFile.exists())
|
||||
{
|
||||
LOGGER.error("userKeytabFile(" + userKeytabFile.getAbsolutePath() + ") does not exsit.");
|
||||
throw new IOException("userKeytabFile(" + userKeytabFile.getAbsolutePath() + ") does not exsit.");
|
||||
}
|
||||
if (!userKeytabFile.isFile())
|
||||
{
|
||||
LOGGER.error("userKeytabFile(" + userKeytabFile.getAbsolutePath() + ") is not a file.");
|
||||
throw new IOException("userKeytabFile(" + userKeytabFile.getAbsolutePath() + ") is not a file.");
|
||||
}
|
||||
|
||||
File krb5ConfFile = new File(krb5ConfPath);
|
||||
if (!krb5ConfFile.exists())
|
||||
{
|
||||
LOGGER.error("krb5ConfFile(" + krb5ConfFile.getAbsolutePath() + ") does not exsit.");
|
||||
throw new IOException("krb5ConfFile(" + krb5ConfFile.getAbsolutePath() + ") does not exsit.");
|
||||
}
|
||||
if (!krb5ConfFile.isFile())
|
||||
{
|
||||
LOGGER.error("krb5ConfFile(" + krb5ConfFile.getAbsolutePath() + ") is not a file.");
|
||||
throw new IOException("krb5ConfFile(" + krb5ConfFile.getAbsolutePath() + ") is not a file.");
|
||||
}
|
||||
|
||||
// 3.set and check krb5config
|
||||
setKrb5Config(krb5ConfFile.getAbsolutePath());
|
||||
setConfiguration(conf);
|
||||
|
||||
// 4.login and check for hadoop
|
||||
loginHadoop(userPrincipal, userKeytabFile.getAbsolutePath());
|
||||
|
||||
LOGGER.info("Login success!!!!!!!!!!!!!!");
|
||||
}
|
||||
|
||||
private static void setConfiguration(Configuration conf) throws IOException {
|
||||
UserGroupInformation.setConfiguration(conf);
|
||||
}
|
||||
|
||||
private static boolean checkNeedLogin(String principal)
|
||||
throws IOException
|
||||
{
|
||||
if (!UserGroupInformation.isSecurityEnabled())
|
||||
{
|
||||
LOGGER.error("UserGroupInformation is not SecurityEnabled, please check if core-site.xml exists in classpath.");
|
||||
throw new IOException(
|
||||
"UserGroupInformation is not SecurityEnabled, please check if core-site.xml exists in classpath.");
|
||||
}
|
||||
UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();
|
||||
if ((currentUser != null) && (currentUser.hasKerberosCredentials()))
|
||||
{
|
||||
if (checkCurrentUserCorrect(principal))
|
||||
{
|
||||
LOGGER.info("current user is " + currentUser + "has logined.");
|
||||
if (!currentUser.isFromKeytab())
|
||||
{
|
||||
LOGGER.error("current user is not from keytab.");
|
||||
throw new IOException("current user is not from keytab.");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.error("current user is " + currentUser + "has logined. please check your enviroment , especially when it used IBM JDK or kerberos for OS count login!!");
|
||||
throw new IOException("current user is " + currentUser + " has logined. And please check your enviroment!!");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private static void setKrb5Config(String krb5ConfFile)
|
||||
throws IOException
|
||||
{
|
||||
System.setProperty(JAVA_SECURITY_KRB5_CONF_KEY, krb5ConfFile);
|
||||
String ret = System.getProperty(JAVA_SECURITY_KRB5_CONF_KEY);
|
||||
if (ret == null)
|
||||
{
|
||||
LOGGER.error(JAVA_SECURITY_KRB5_CONF_KEY + " is null.");
|
||||
throw new IOException(JAVA_SECURITY_KRB5_CONF_KEY + " is null.");
|
||||
}
|
||||
if (!ret.equals(krb5ConfFile))
|
||||
{
|
||||
LOGGER.error(JAVA_SECURITY_KRB5_CONF_KEY + " is " + ret + " is not " + krb5ConfFile + ".");
|
||||
throw new IOException(JAVA_SECURITY_KRB5_CONF_KEY + " is " + ret + " is not " + krb5ConfFile + ".");
|
||||
}
|
||||
}
|
||||
|
||||
public static void setJaasConf(String loginContextName, String principal, String keytabFile)
|
||||
throws IOException
|
||||
{
|
||||
if ((loginContextName == null) || (loginContextName.length() <= 0))
|
||||
{
|
||||
LOGGER.error("input loginContextName is invalid.");
|
||||
throw new IOException("input loginContextName is invalid.");
|
||||
}
|
||||
|
||||
if ((principal == null) || (principal.length() <= 0))
|
||||
{
|
||||
LOGGER.error("input principal is invalid.");
|
||||
throw new IOException("input principal is invalid.");
|
||||
}
|
||||
|
||||
if ((keytabFile == null) || (keytabFile.length() <= 0))
|
||||
{
|
||||
LOGGER.error("input keytabFile is invalid.");
|
||||
throw new IOException("input keytabFile is invalid.");
|
||||
}
|
||||
|
||||
File userKeytabFile = new File(keytabFile);
|
||||
if (!userKeytabFile.exists())
|
||||
{
|
||||
LOGGER.error("userKeytabFile(" + userKeytabFile.getAbsolutePath() + ") does not exsit.");
|
||||
throw new IOException("userKeytabFile(" + userKeytabFile.getAbsolutePath() + ") does not exsit.");
|
||||
}
|
||||
|
||||
javax.security.auth.login.Configuration.setConfiguration(new JaasConfiguration(loginContextName, principal,
|
||||
userKeytabFile.getAbsolutePath()));
|
||||
|
||||
javax.security.auth.login.Configuration conf = javax.security.auth.login.Configuration.getConfiguration();
|
||||
if (!(conf instanceof JaasConfiguration))
|
||||
{
|
||||
LOGGER.error("javax.security.auth.login.Configuration is not JaasConfiguration.");
|
||||
throw new IOException("javax.security.auth.login.Configuration is not JaasConfiguration.");
|
||||
}
|
||||
|
||||
AppConfigurationEntry[] entrys = conf.getAppConfigurationEntry(loginContextName);
|
||||
if (entrys == null)
|
||||
{
|
||||
LOGGER.error("javax.security.auth.login.Configuration has no AppConfigurationEntry named " + loginContextName
|
||||
+ ".");
|
||||
throw new IOException("javax.security.auth.login.Configuration has no AppConfigurationEntry named "
|
||||
+ loginContextName + ".");
|
||||
}
|
||||
|
||||
boolean checkPrincipal = false;
|
||||
boolean checkKeytab = false;
|
||||
for (int i = 0; i < entrys.length; i++)
|
||||
{
|
||||
if (entrys[i].getOptions().get("principal").equals(principal))
|
||||
{
|
||||
checkPrincipal = true;
|
||||
}
|
||||
|
||||
if (IS_IBM_JDK)
|
||||
{
|
||||
if (entrys[i].getOptions().get("useKeytab").equals(keytabFile))
|
||||
{
|
||||
checkKeytab = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (entrys[i].getOptions().get("keyTab").equals(keytabFile))
|
||||
{
|
||||
checkKeytab = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!checkPrincipal)
|
||||
{
|
||||
LOGGER.error("AppConfigurationEntry named " + loginContextName + " does not have principal value of "
|
||||
+ principal + ".");
|
||||
throw new IOException("AppConfigurationEntry named " + loginContextName
|
||||
+ " does not have principal value of " + principal + ".");
|
||||
}
|
||||
|
||||
if (!checkKeytab)
|
||||
{
|
||||
LOGGER.error("AppConfigurationEntry named " + loginContextName + " does not have keyTab value of "
|
||||
+ keytabFile + ".");
|
||||
throw new IOException("AppConfigurationEntry named " + loginContextName + " does not have keyTab value of "
|
||||
+ keytabFile + ".");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void setZookeeperServerPrincipal(String zkServerPrincipalKey, String zkServerPrincipal)
|
||||
throws IOException
|
||||
{
|
||||
System.setProperty(zkServerPrincipalKey, zkServerPrincipal);
|
||||
String ret = System.getProperty(zkServerPrincipalKey);
|
||||
if (ret == null)
|
||||
{
|
||||
LOGGER.error(zkServerPrincipalKey + " is null.");
|
||||
throw new IOException(zkServerPrincipalKey + " is null.");
|
||||
}
|
||||
if (!ret.equals(zkServerPrincipal))
|
||||
{
|
||||
LOGGER.error(zkServerPrincipalKey + " is " + ret + " is not " + zkServerPrincipal
|
||||
+ ".");
|
||||
throw new IOException(zkServerPrincipalKey + " is " + ret + " is not "
|
||||
+ zkServerPrincipal + ".");
|
||||
}
|
||||
}
|
||||
|
||||
private static void loginHadoop(String principal, String keytabFile)
|
||||
throws IOException
|
||||
{
|
||||
System.setProperty(JAVA_SECURITY_AUTH_USE_SUBJECT_CREDS_ONLY, "false");
|
||||
try
|
||||
{
|
||||
UserGroupInformation.loginUserFromKeytab(principal, keytabFile);
|
||||
LOGGER.info("loginUserFromKeytab finished");
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
LOGGER.error("login failed with " + principal + " and " + keytabFile + ".");
|
||||
LOGGER.error("perhaps cause 1 is " + LOGIN_FAILED_CAUSE_PASSWORD_WRONG + ".");
|
||||
LOGGER.error("perhaps cause 2 is " + LOGIN_FAILED_CAUSE_TIME_WRONG + ".");
|
||||
LOGGER.error("perhaps cause 3 is " + LOGIN_FAILED_CAUSE_AES256_WRONG + ".");
|
||||
LOGGER.error("perhaps cause 4 is " + LOGIN_FAILED_CAUSE_PRINCIPAL_WRONG + ".");
|
||||
LOGGER.error("perhaps cause 5 is " + LOGIN_FAILED_CAUSE_TIME_OUT + ".");
|
||||
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkAuthenticateOverKrb()
|
||||
throws IOException
|
||||
{
|
||||
UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
|
||||
UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();
|
||||
if (loginUser == null)
|
||||
{
|
||||
LOGGER.error("current user is " + currentUser + ", but loginUser is null.");
|
||||
throw new IOException("current user is " + currentUser + ", but loginUser is null.");
|
||||
}
|
||||
if (!loginUser.equals(currentUser))
|
||||
{
|
||||
LOGGER.error("current user is " + currentUser + ", but loginUser is " + loginUser + ".");
|
||||
throw new IOException("current user is " + currentUser + ", but loginUser is " + loginUser + ".");
|
||||
}
|
||||
if (!loginUser.hasKerberosCredentials())
|
||||
{
|
||||
LOGGER.error("current user is " + currentUser + " has no Kerberos Credentials.");
|
||||
throw new IOException("current user is " + currentUser + " has no Kerberos Credentials.");
|
||||
}
|
||||
if (!UserGroupInformation.isLoginKeytabBased())
|
||||
{
|
||||
LOGGER.error("current user is " + currentUser + " is not Login Keytab Based.");
|
||||
throw new IOException("current user is " + currentUser + " is not Login Keytab Based.");
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean checkCurrentUserCorrect(String principal)
|
||||
throws IOException
|
||||
{
|
||||
UserGroupInformation ugi = UserGroupInformation.getCurrentUser();
|
||||
if (ugi == null)
|
||||
{
|
||||
LOGGER.error("current user still null.");
|
||||
throw new IOException("current user still null.");
|
||||
}
|
||||
|
||||
String defaultRealm = null;
|
||||
try {
|
||||
defaultRealm = KerberosUtil.getDefaultRealm();
|
||||
} catch (Exception e) {
|
||||
LOGGER.warn("getDefaultRealm failed.");
|
||||
throw new IOException(e);
|
||||
}
|
||||
|
||||
if ((defaultRealm != null) && (defaultRealm.length() > 0))
|
||||
{
|
||||
StringBuilder realm = new StringBuilder();
|
||||
StringBuilder principalWithRealm = new StringBuilder();
|
||||
realm.append("@").append(defaultRealm);
|
||||
if (!principal.endsWith(realm.toString()))
|
||||
{
|
||||
principalWithRealm.append(principal).append(realm);
|
||||
principal = principalWithRealm.toString();
|
||||
}
|
||||
}
|
||||
|
||||
return principal.equals(ugi.getUserName());
|
||||
}
|
||||
|
||||
/**
|
||||
* copy from hbase zkutil 0.94&0.98 A JAAS configuration that defines the login modules that we want to use for
|
||||
* login.
|
||||
*/
|
||||
private static class JaasConfiguration extends javax.security.auth.login.Configuration
|
||||
{
|
||||
private static final Map<String, String> BASIC_JAAS_OPTIONS = new HashMap<String, String>();
|
||||
static
|
||||
{
|
||||
String jaasEnvVar = System.getenv("HBASE_JAAS_DEBUG");
|
||||
if (jaasEnvVar != null && "true".equalsIgnoreCase(jaasEnvVar))
|
||||
{
|
||||
BASIC_JAAS_OPTIONS.put("debug", "true");
|
||||
}
|
||||
}
|
||||
|
||||
private static final Map<String, String> KEYTAB_KERBEROS_OPTIONS = new HashMap<String, String>();
|
||||
static
|
||||
{
|
||||
if (IS_IBM_JDK)
|
||||
{
|
||||
KEYTAB_KERBEROS_OPTIONS.put("credsType", "both");
|
||||
}
|
||||
else {
|
||||
KEYTAB_KERBEROS_OPTIONS.put("useKeyTab", "true");
|
||||
KEYTAB_KERBEROS_OPTIONS.put("useTicketCache", "false");
|
||||
KEYTAB_KERBEROS_OPTIONS.put("doNotPrompt", "true");
|
||||
KEYTAB_KERBEROS_OPTIONS.put("storeKey", "true");
|
||||
}
|
||||
|
||||
KEYTAB_KERBEROS_OPTIONS.putAll(BASIC_JAAS_OPTIONS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static final AppConfigurationEntry KEYTAB_KERBEROS_LOGIN = new AppConfigurationEntry(
|
||||
KerberosUtil.getKrb5LoginModuleName(), LoginModuleControlFlag.REQUIRED, KEYTAB_KERBEROS_OPTIONS);
|
||||
|
||||
private static final AppConfigurationEntry[] KEYTAB_KERBEROS_CONF =
|
||||
new AppConfigurationEntry[] {KEYTAB_KERBEROS_LOGIN};
|
||||
|
||||
private javax.security.auth.login.Configuration baseConfig;
|
||||
|
||||
private final String loginContextName;
|
||||
|
||||
private final boolean useTicketCache;
|
||||
|
||||
private final String keytabFile;
|
||||
|
||||
private final String principal;
|
||||
|
||||
|
||||
public JaasConfiguration(String loginContextName, String principal, String keytabFile) throws IOException
|
||||
{
|
||||
this(loginContextName, principal, keytabFile, keytabFile == null || keytabFile.length() == 0);
|
||||
}
|
||||
|
||||
private JaasConfiguration(String loginContextName, String principal, String keytabFile, boolean useTicketCache) throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
this.baseConfig = javax.security.auth.login.Configuration.getConfiguration();
|
||||
}
|
||||
catch (SecurityException e)
|
||||
{
|
||||
this.baseConfig = null;
|
||||
}
|
||||
this.loginContextName = loginContextName;
|
||||
this.useTicketCache = useTicketCache;
|
||||
this.keytabFile = keytabFile;
|
||||
this.principal = principal;
|
||||
|
||||
initKerberosOption();
|
||||
LOGGER.info("JaasConfiguration loginContextName=" + loginContextName + " principal=" + principal
|
||||
+ " useTicketCache=" + useTicketCache + " keytabFile=" + keytabFile);
|
||||
}
|
||||
|
||||
private void initKerberosOption() throws IOException
|
||||
{
|
||||
if (!useTicketCache)
|
||||
{
|
||||
if(IS_IBM_JDK)
|
||||
{
|
||||
KEYTAB_KERBEROS_OPTIONS.put("useKeytab", keytabFile);
|
||||
}
|
||||
else
|
||||
{
|
||||
KEYTAB_KERBEROS_OPTIONS.put("keyTab", keytabFile);
|
||||
KEYTAB_KERBEROS_OPTIONS.put("useKeyTab", "true");
|
||||
// KEYTAB_KERBEROS_OPTIONS.put("useTicketCache", useTicketCache ? "true" : "false");
|
||||
KEYTAB_KERBEROS_OPTIONS.put("useTicketCache", "false");
|
||||
}
|
||||
}
|
||||
KEYTAB_KERBEROS_OPTIONS.put("principal", principal);
|
||||
}
|
||||
|
||||
public AppConfigurationEntry[] getAppConfigurationEntry(String appName)
|
||||
{
|
||||
if (loginContextName.equals(appName))
|
||||
{
|
||||
return KEYTAB_KERBEROS_CONF;
|
||||
}
|
||||
if (baseConfig != null)
|
||||
return baseConfig.getAppConfigurationEntry(appName);
|
||||
return (null);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package com.jiuyv.sptcc.agile.batch.syncJiushiData.common.model;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* SQL拼接结果
|
||||
* @author zhouliang
|
||||
*
|
||||
*/
|
||||
public class SqlHandlerResultVO implements Serializable
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 查询sql语句(远程)
|
||||
*/
|
||||
private String selectSql;
|
||||
/**
|
||||
* 插入sql语句(本地)
|
||||
*/
|
||||
private String insertSql;
|
||||
|
||||
/**
|
||||
* 前置sql语句(本地)
|
||||
*/
|
||||
private String preSql;
|
||||
|
||||
/**
|
||||
* 映射关系(包含类型转换) 读取字段-存储字段/类型
|
||||
*/
|
||||
private Map<String,SqlHandlerTypeVO> fieldMapping;
|
||||
|
||||
/**
|
||||
* @return the selectSql
|
||||
*/
|
||||
public String getSelectSql() {
|
||||
return selectSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param selectSql the selectSql to set
|
||||
*/
|
||||
public void setSelectSql(String selectSql) {
|
||||
this.selectSql = selectSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the insertSql
|
||||
*/
|
||||
public String getInsertSql() {
|
||||
return insertSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param insertSql the insertSql to set
|
||||
*/
|
||||
public void setInsertSql(String insertSql) {
|
||||
this.insertSql = insertSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the preSql
|
||||
*/
|
||||
public String getPreSql() {
|
||||
return preSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param preSql the preSql to set
|
||||
*/
|
||||
public void setPreSql(String preSql) {
|
||||
this.preSql = preSql;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the fieldMapping
|
||||
*/
|
||||
public Map<String, SqlHandlerTypeVO> getFieldMapping() {
|
||||
return fieldMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param fieldMapping the fieldMapping to set
|
||||
*/
|
||||
public void setFieldMapping(Map<String, SqlHandlerTypeVO> fieldMapping) {
|
||||
this.fieldMapping = fieldMapping;
|
||||
}
|
||||
|
||||
//获取转换过后的标题
|
||||
public List<String> getFieldTitle() {
|
||||
List<String> list=new ArrayList<>();
|
||||
fieldMapping.forEach((k,v)->{
|
||||
String code = v.getColumnCode();
|
||||
list.add(StringUtils.isBlank(code)?k:code);
|
||||
});
|
||||
return list;
|
||||
}
|
||||
}
|
@ -0,0 +1,16 @@
|
||||
mybatis:
|
||||
type-aliases-super-type:
|
||||
mapper-locations: classpath:mappers/*xml
|
||||
# 加载全局的配置文件
|
||||
configLocation: classpath:mybatis/mybatis-config.xml
|
||||
|
||||
spring:
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss # 常用的时间格式
|
||||
default-property-inclusion: non_null # 忽略空对象
|
||||
serialization:
|
||||
fail-on-empty-beans: false # 序列化空对象时不抛出异常
|
||||
indent-output: true # 输出格式化为缩进的JSON
|
||||
write-dates-as-timestamps: false # 日期序列化为时间戳而不是ISO-8601格式
|
||||
deserialization:
|
||||
fail-on-unknown-properties: false # 反序列化时忽略未知的属性
|
@ -0,0 +1,41 @@
|
||||
# Spring配置
|
||||
spring:
|
||||
application:
|
||||
name : batch-service
|
||||
profiles:
|
||||
#部署时带上自身名字batch-service-dev
|
||||
active: dev
|
||||
cloud:
|
||||
config:
|
||||
#本地可以置为关闭false
|
||||
enabled: false
|
||||
discovery:
|
||||
service-id: config-service #使用服务名
|
||||
enabled: true
|
||||
#uri: http://172.16.12.109:8888
|
||||
name: ${spring.application.name}
|
||||
profile: ${spring.profiles.active}
|
||||
fail-fast: true
|
||||
security:
|
||||
user:
|
||||
name: sptcc
|
||||
password: 123456
|
||||
|
||||
# 配置eureka客户端信息
|
||||
eureka:
|
||||
instance:
|
||||
appname: ${spring.application.name}
|
||||
lease-expiration-duration-in-seconds: 30
|
||||
lease-renewal-interval-in-seconds: 10
|
||||
prefer-ip-address: true
|
||||
instance-id: ${spring.cloud.client.ip-address}:${spring.application.name}:${server.port}
|
||||
metadata-map:
|
||||
user.name: ${spring.security.user.name}
|
||||
user.password: ${spring.security.user.password}
|
||||
client:
|
||||
enabled: true
|
||||
registry-fetch-interval-seconds: 1
|
||||
register-with-eureka: true
|
||||
fetch-registry: true
|
||||
service-url:
|
||||
defaultZone: http://172.16.12.109:8761/eureka/
|
@ -0,0 +1,9 @@
|
||||
auth = KERBEROS
|
||||
zk.port = 24002
|
||||
zk.quorum = 11.125.1.4:24002,11.125.1.6:24002,11.125.1.5:24002
|
||||
beeline.entirelineascommand = true
|
||||
principal = hive/hadoop.hadoop.com@HADOOP.COM
|
||||
sasl.qop = auth-conf
|
||||
zooKeeperNamespace = hiveserver2
|
||||
serviceDiscoveryMode = zooKeeper
|
||||
instanceNo = 0
|
@ -0,0 +1,47 @@
|
||||
[kdcdefaults]
|
||||
kdc_ports = 11.125.1.5:21732
|
||||
kdc_tcp_ports = ""
|
||||
|
||||
[libdefaults]
|
||||
default_realm = HADOOP.COM
|
||||
kdc_timeout = 2500
|
||||
clockskew = 300
|
||||
use_dns_lookup = 0
|
||||
udp_preference_limit = 1465
|
||||
max_retries = 5
|
||||
dns_lookup_kdc = false
|
||||
dns_lookup_realm = false
|
||||
renewable = false
|
||||
forwardable = false
|
||||
renew_lifetime = 0m
|
||||
max_renewable_life = 30m
|
||||
allow_extend_version = false
|
||||
default_ccache_name = FILE:/tmp//krb5cc_%{uid}
|
||||
|
||||
[realms]
|
||||
HADOOP.COM = {
|
||||
kdc = 11.125.1.5:21732
|
||||
kdc = 11.125.1.4:21732
|
||||
admin_server = 11.125.1.5:21730
|
||||
admin_server = 11.125.1.4:21730
|
||||
kpasswd_server = 11.125.1.5:21731
|
||||
kpasswd_server = 11.125.1.4:21731
|
||||
kpasswd_port = 21731
|
||||
kadmind_port = 21730
|
||||
kadmind_listen = 11.125.1.5:21730
|
||||
kpasswd_listen = 11.125.1.5:21731
|
||||
renewable = false
|
||||
forwardable = false
|
||||
renew_lifetime = 0m
|
||||
max_renewable_life = 30m
|
||||
acl_file = /opt/huawei/Bigdata/FusionInsight_BASE_6.5.1.10/install/FusionInsight-kerberos-1.17/kerberos/var/krb5kdc/kadm5.acl
|
||||
key_stash_file = /opt/huawei/Bigdata/FusionInsight_BASE_6.5.1.10/install/FusionInsight-kerberos-1.17/kerberos/var/krb5kdc/.k5.HADOOP.COM
|
||||
}
|
||||
|
||||
[domain_realm]
|
||||
.hadoop.com = HADOOP.COM
|
||||
|
||||
[logging]
|
||||
kdc = SYSLOG:INFO:DAEMON
|
||||
admin_server = SYSLOG:INFO:DAEMON
|
||||
default = SYSLOG:NOTICE:DAEMON
|
Binary file not shown.
@ -0,0 +1,135 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration debug="false">
|
||||
<!-- LOG目录 -->
|
||||
<property name="LOG_HOME" value="logs"/>
|
||||
|
||||
<!-- JSON_LOG目录 -->
|
||||
<property name="JSON_LOG_HOME" value="logs/jsonlog"/>
|
||||
|
||||
<!-- spring.application.name 作为参数 -->
|
||||
<springProperty scope="context" name="APP_NAME" source="spring.application.name"/>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<target>System.out</target>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 按天压缩日志 -->
|
||||
<appender name="ZIP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${LOG_HOME}/${APP_NAME}.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/${APP_NAME}.log.%d{yyyy-MM-dd}.%i.log.zip</FileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<!-- or whenever the file size reaches 100MB -->
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 不压缩日志,保留7天 -->
|
||||
<appender name="DEFAULT_INFO_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/${APP_NAME}.log.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<maxHistory>7</maxHistory>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<!-- or whenever the file size reaches 100MB -->
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>UTF-8</charset>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- LOGSTASH,输出seuleth项,保留7天 -->
|
||||
<appender name="LOGSTASH" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${JSON_LOG_HOME}/${APP_NAME}.json.%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<maxHistory>7</maxHistory>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<!-- or whenever the file size reaches 100MB -->
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<pattern>
|
||||
<pattern>
|
||||
{
|
||||
"timestamp": "%d{yyyy-MM-dd HH:mm:ss.SSS}",
|
||||
"severity": "%level",
|
||||
"service": "${APP_NAME:-}",
|
||||
"trace": "%X{X-B3-TraceId:-}",
|
||||
"span": "%X{X-B3-SpanId:-}",
|
||||
"parent": "%X{X-B3-ParentSpanId:-}",
|
||||
"exportable": "%X{X-Span-Export:-}",
|
||||
"pid": "${PID:-}",
|
||||
"thread": "%thread",
|
||||
"class": "%logger{40}",
|
||||
"rest": "%message"
|
||||
}
|
||||
</pattern>
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>
|
||||
</appender>
|
||||
<!-- 按天压缩Json日志 -->
|
||||
<appender name="JSON_ZIP_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<file>${JSON_LOG_HOME}/${APP_NAME}.json.log</file>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${JSON_LOG_HOME}/${APP_NAME}.log.%d{yyyy-MM-dd}.%i.json.log.zip</FileNamePattern>
|
||||
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
|
||||
<!-- or whenever the file size reaches 100MB -->
|
||||
<maxFileSize>100MB</maxFileSize>
|
||||
</timeBasedFileNamingAndTriggeringPolicy>
|
||||
</rollingPolicy>
|
||||
<encoder charset="UTF-8" class="net.logstash.logback.encoder.LoggingEventCompositeJsonEncoder">
|
||||
<providers>
|
||||
<pattern>
|
||||
<pattern>
|
||||
{
|
||||
"timestamp": "%d{yyyy-MM-dd HH:mm:ss.SSS}",
|
||||
"severity": "%level",
|
||||
"service": "${APP_NAME:-}",
|
||||
"trace": "%X{X-B3-TraceId:-}",
|
||||
"span": "%X{X-B3-SpanId:-}",
|
||||
"parent": "%X{X-B3-ParentSpanId:-}",
|
||||
"exportable": "%X{X-Span-Export:-}",
|
||||
"pid": "${PID:-}",
|
||||
"thread": "%thread",
|
||||
"class": "%logger{40}",
|
||||
"rest": "%message"
|
||||
}
|
||||
</pattern>
|
||||
</pattern>
|
||||
</providers>
|
||||
</encoder>
|
||||
</appender>
|
||||
<appender name="STDERR" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<target>System.err</target>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
<logger name="com.jiuyv.sptccc.agile.thirdparty.dao" level="debug"/>
|
||||
<logger name="org.apache.http" level="error"/>
|
||||
|
||||
<root>
|
||||
<level value="INFO"/>
|
||||
<appender-ref ref="STDOUT"/>
|
||||
<appender-ref ref="ZIP_FILE"/>
|
||||
<appender-ref ref="DEFAULT_INFO_FILE"/>
|
||||
<appender-ref ref="LOGSTASH"/>
|
||||
<appender-ref ref="JSON_ZIP_FILE"/>
|
||||
</root>
|
||||
</configuration>
|
@ -0,0 +1,7 @@
|
||||
<?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="com.jiuyv.sptcc.agile.batch.dao.ISysTimeBaseMapper">
|
||||
<select id="selectSysCurrentTime" resultType="com.jiuyv.sptcc.agile.batch.common.BaseTime">
|
||||
SELECT now() AT TIME ZONE 'UTC' AS utcTime, now() AS date
|
||||
</select>
|
||||
</mapper>
|
@ -0,0 +1,45 @@
|
||||
<?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="com.jiuyv.sptcc.agile.batch.batchTask.mapper.TblBatchTableMappingMapper">
|
||||
<sql id="_select">
|
||||
a.task_no,
|
||||
a.version_num,
|
||||
a.rec_token,
|
||||
a.remote_table_sql,
|
||||
a.remote_db_name,
|
||||
a.remote_days,
|
||||
a.local_table,
|
||||
a.local_db_name,
|
||||
a.local_pre_sql,
|
||||
a.mapping_json,
|
||||
a.remarks,
|
||||
a.data_status,
|
||||
a.update_time,
|
||||
a.rsv1,
|
||||
a.rsv2,
|
||||
a.rsv3
|
||||
</sql>
|
||||
<sql id="_where">
|
||||
<!-- 默认必有条件 -->
|
||||
<choose>
|
||||
<when test="taskNo != null">and a.task_no = #{taskNo}</when>
|
||||
<otherwise>and a.task_no in(<foreach collection="taskNos" item="idx" separator=",">#{idx}</foreach>)</otherwise>
|
||||
</choose>
|
||||
<if test="versionNum != null" >and version_num = #{versionNum}</if>
|
||||
<if test="recToken != null" >and rec_token = #{recToken}</if>
|
||||
<if test="dataStatus != null" >and data_status = #{dataStatus}</if>
|
||||
</sql>
|
||||
|
||||
<!-- 查询单条 -->
|
||||
<select id="selectOneByMap" resultType="com.jiuyv.sptcc.agile.batch.batchTask.entity.TblBatchTableMapping" parameterType="com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTableMappingVO">
|
||||
select
|
||||
<include refid="_select"/>
|
||||
from tbl_batch_table_mapping a
|
||||
<where>
|
||||
<include refid="_where"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
@ -0,0 +1,82 @@
|
||||
<?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="com.jiuyv.sptcc.agile.batch.batchTask.mapper.TblBatchTaskMapper">
|
||||
<sql id="_select">
|
||||
a.task_no,
|
||||
a.version_num,
|
||||
a.rec_token,
|
||||
a.task_title,
|
||||
a.pre_start_date,
|
||||
a.pre_end_date,
|
||||
a.pre_total_time,
|
||||
a.curr_start_date,
|
||||
a.failure_conditions,
|
||||
a.bus_status,
|
||||
a.data_status,
|
||||
a.update_time,
|
||||
a.rsv1,
|
||||
a.rsv2,
|
||||
a.rsv3
|
||||
</sql>
|
||||
<sql id="_where">
|
||||
<!-- 默认必有条件 -->
|
||||
and a.task_no = #{taskNo}
|
||||
<if test="versionNum != null" >and version_num = #{versionNum}</if>
|
||||
<if test="recToken != null" >and rec_token = #{recToken}</if>
|
||||
<if test="dataStatus != null" >and data_status = #{dataStatus}</if>
|
||||
</sql>
|
||||
|
||||
<!-- 查询单条 -->
|
||||
<select id="selectOneByMap" resultType="com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTaskVO" parameterType="com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTaskVO">
|
||||
select
|
||||
<include refid="_select"/>
|
||||
from tbl_batch_task a
|
||||
<where>
|
||||
<include refid="_where"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<!-- 更新记录 -->
|
||||
<update id="updateByMap">
|
||||
update tbl_batch_task
|
||||
<set>
|
||||
<if test="vo.versionNum != null" >version_num = #{vo.versionNum},</if>
|
||||
<if test="vo.versionNum == null" >version_num = version_num+1,</if>
|
||||
<if test="vo.recToken != null and vo.recToken != ''" >rec_token = #{vo.recToken},</if>
|
||||
<if test="vo.taskTitle != null and vo.taskTitle != ''" >task_title = #{vo.taskTitle},</if>
|
||||
<if test="vo.preStartDate != null" >pre_start_date = #{vo.preStartDate},</if>
|
||||
<if test="vo.preEndDate != null" >pre_end_date = #{vo.preEndDate},</if>
|
||||
<if test="vo.preTotalTime != null and vo.preTotalTime != ''" >pre_total_time = #{vo.preTotalTime},</if>
|
||||
<if test="vo.currStartDate != null" >curr_start_date = #{vo.currStartDate},</if>
|
||||
<if test="vo.failureConditions != null and vo.failureConditions != ''" >failure_conditions = #{vo.failureConditions},</if>
|
||||
<if test="vo.busStatus != null and vo.busStatus != ''" >bus_status = #{vo.busStatus},</if>
|
||||
<if test="vo.dataStatus != null and vo.dataStatus != ''" >data_status = #{vo.dataStatus},</if>
|
||||
<if test="vo.updateTime != null" >update_time = #{vo.updateTime},</if>
|
||||
<if test="vo.rsv1 != null and vo.rsv1 != ''" >rsv1 = #{vo.rsv1},</if>
|
||||
<if test="vo.rsv2 != null and vo.rsv2 != ''" >rsv2 = #{vo.rsv2},</if>
|
||||
<if test="vo.rsv3 != null and vo.rsv3 != ''" >rsv3 = #{vo.rsv3},</if>
|
||||
</set>
|
||||
<where>
|
||||
<!-- 默认必有条件 -->
|
||||
and task_no = #{map.taskNo}
|
||||
<if test="map.versionNum != null" >and version_num = #{map.versionNum}</if>
|
||||
<if test="map.recToken != null" >and rec_token = #{map.recToken}</if>
|
||||
<if test="map.dataStatus != null" >and data_status = #{map.dataStatus}</if>
|
||||
<if test="map.busStatus != null" >and bus_status = #{map.busStatus}</if>
|
||||
<if test="map.busStatuss != null" >and bus_status in(<foreach collection="map.busStatuss" item="idx" separator=",">#{idx}</foreach>)</if>
|
||||
</where>
|
||||
</update>
|
||||
|
||||
<update id="updateResetAllBusStatus">
|
||||
update tbl_batch_task
|
||||
<set>
|
||||
bus_status = #{vo.busStatus},
|
||||
update_time = #{vo.updateTime},
|
||||
</set>
|
||||
<where>
|
||||
and bus_status = #{map.busStatus}
|
||||
</where>
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE configuration
|
||||
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-config.dtd">
|
||||
<configuration>
|
||||
<!-- 全局参数 -->
|
||||
<settings>
|
||||
<!-- 使全局的映射器启用或禁用缓存 -->
|
||||
<setting name="cacheEnabled" value="true" />
|
||||
<!-- 允许JDBC 支持自动生成主键 -->
|
||||
<setting name="useGeneratedKeys" value="true" />
|
||||
<!-- 配置默认的执行器.SIMPLE就是普通执行器;REUSE执行器会重用预处理语句(prepared statements);BATCH执行器将重用语句并执行批量更新 -->
|
||||
<setting name="defaultExecutorType" value="SIMPLE" />
|
||||
<!-- 指定 MyBatis 所用日志的具体实现 -->
|
||||
<setting name="logImpl" value="SLF4J" />
|
||||
<!-- 使用驼峰命名法转换字段 -->
|
||||
<setting name="mapUnderscoreToCamelCase" value="true"/>
|
||||
</settings>
|
||||
|
||||
</configuration>
|
@ -0,0 +1,14 @@
|
||||
spring:
|
||||
h2:
|
||||
console:
|
||||
enabled: false
|
||||
datasource:
|
||||
driver-class-name: org.h2.Driver
|
||||
url: jdbc:h2:file:~/test
|
||||
username: san
|
||||
password:
|
||||
|
||||
sql:
|
||||
init:
|
||||
data-locations: classpath:db/data.sql
|
||||
schema-locations: classpath:/dbschema.sql
|
@ -0,0 +1,149 @@
|
||||
<?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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>com.jiuyv.sptcc.agile.batch</groupId>
|
||||
<artifactId>agile-bacth</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<modules>
|
||||
<module>agile-batch-api</module>
|
||||
<module>agile-batch-service</module>
|
||||
<module>agile-batch-dws</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<maven-jar-plugin.version>3.1.1</maven-jar-plugin.version>
|
||||
<maven.clean.version>3.1.0</maven.clean.version>
|
||||
<maven.resource.version>3.1.0</maven.resource.version>
|
||||
<spring.boot.version>2.6.7</spring.boot.version>
|
||||
<hive.version>3.1.0</hive.version>
|
||||
<spring-cloud.version>2021.0.5</spring-cloud.version>
|
||||
</properties>
|
||||
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring-cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
<!-- SpringBoot的依赖配置 -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring.boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mybatis.spring.boot</groupId>
|
||||
<artifactId>mybatis-spring-boot-starter</artifactId>
|
||||
<version>2.2.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>nexus-releases</id>
|
||||
<name>Internal Releases</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-releases/</url>
|
||||
</repository>
|
||||
|
||||
<snapshotRepository>
|
||||
<id>nexus-snapshots</id>
|
||||
<name>Internal Snapshots</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-snapshots/</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
|
||||
<scm>
|
||||
<connection>scm:svn:http://172.16.12.10/sptcc_agile_etl/src/agile-batch/src/trunk/agile-batch</connection>
|
||||
<developerConnection>scm:svn:http://172.16.12.10/svn/sptcc_agile_etl/src/agile-batch/src/trunk/agile-batch</developerConnection>
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jiuyv</id>
|
||||
<name>jiuyv</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-public/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>always</updatePolicy>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jboss</id>
|
||||
<name>jboss</name>
|
||||
<url>http://repository.jboss.org/maven2/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>geotools</id>
|
||||
<name>geotools</name>
|
||||
<url>http://maven.geotools.fr/repository/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jahia</id>
|
||||
<name>jahia</name>
|
||||
<url>http://maven.jahia.org/maven2/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>vars</id>
|
||||
<name>vars</name>
|
||||
<url>http://vars.sourceforge.net/maven2/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>jiuyv</id>
|
||||
<name>jiuyv Plugin Repository</name>
|
||||
<url>http://172.16.12.11:8082/repository/maven-public/</url>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>central</id>
|
||||
<name>Maven Plugin Repository</name>
|
||||
<url>http://repo1.maven.org/maven2/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>${project.build.sourceEncoding}</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,14 +1,21 @@
|
||||
package com.jiuyv.sptccc.agile.api;
|
||||
|
||||
import com.jiuyv.sptccc.agile.common.core.domain.R;
|
||||
import com.jiuyv.sptccc.agile.common.core.page.TableDataInfo;
|
||||
import com.jiuyv.sptccc.agile.dto.DockerDownloadApplyDTO;
|
||||
import com.jiuyv.sptccc.agile.dto.FileTO;
|
||||
import com.jiuyv.sptccc.agile.dto.ReqDockerDownApplyPageDTO;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
public interface DockerDownloadApplyFeignApi {
|
||||
String API_PATH_PREFIX = "downloadApply";
|
||||
String API_PATH_PREFIX = "/downloadApply";
|
||||
|
||||
@PostMapping("/list")
|
||||
TableDataInfo<DockerDownloadApplyDTO> getList(@RequestBody ReqDockerDownApplyPageDTO reqDTO);
|
||||
|
||||
@GetMapping("/download/{downloadApplyId}")
|
||||
R<FileTO> download(@PathVariable("downloadApplyId") Long downloadApplyId);
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
package com.jiuyv.sptccc.agile.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class DockerFileDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private String fileName;
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package com.jiuyv.sptccc.agile.dto;
|
||||
|
||||
public class FileTO {
|
||||
private String fileName;
|
||||
private byte[] file;
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public byte[] getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
public void setFile(byte[] file) {
|
||||
this.file = file;
|
||||
}
|
||||
}
|
@ -0,0 +1,48 @@
|
||||
package com.jiuyv.sptccc.agile.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 文件下载申请 请求体
|
||||
*/
|
||||
public class ReqDockerDownApplyDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
/**
|
||||
* 实验室ID
|
||||
*/
|
||||
private Long applyId;
|
||||
|
||||
/**
|
||||
* 文件名
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 申请说明
|
||||
*/
|
||||
private String applyDesc;
|
||||
|
||||
public Long getApplyId() {
|
||||
return applyId;
|
||||
}
|
||||
|
||||
public void setApplyId(Long applyId) {
|
||||
this.applyId = applyId;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getApplyDesc() {
|
||||
return applyDesc;
|
||||
}
|
||||
|
||||
public void setApplyDesc(String applyDesc) {
|
||||
this.applyDesc = applyDesc;
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package com.jiuyv.sptccc.agile.dto;
|
||||
|
||||
/**
|
||||
* 文件下载申请 请求
|
||||
*/
|
||||
public class ReqDockerDownApplyPageDTO extends ReqPageDTO{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 申请用户id
|
||||
*/
|
||||
private String applyUserId;
|
||||
|
||||
/**
|
||||
* 实验室申请id
|
||||
*/
|
||||
private Long applyId;
|
||||
|
||||
/**
|
||||
* 实验室名称
|
||||
*/
|
||||
private String labTitle;
|
||||
|
||||
/**
|
||||
* 【文件名】
|
||||
*/
|
||||
private String fileName;
|
||||
|
||||
/**
|
||||
* 审核状态
|
||||
*/
|
||||
private String reviewStatus;
|
||||
|
||||
public String getApplyUserId() {
|
||||
return applyUserId;
|
||||
}
|
||||
|
||||
public void setApplyUserId(String applyUserId) {
|
||||
this.applyUserId = applyUserId;
|
||||
}
|
||||
|
||||
public Long getApplyId() {
|
||||
return applyId;
|
||||
}
|
||||
|
||||
public void setApplyId(Long applyId) {
|
||||
this.applyId = applyId;
|
||||
}
|
||||
|
||||
public String getLabTitle() {
|
||||
return labTitle;
|
||||
}
|
||||
|
||||
public void setLabTitle(String labTitle) {
|
||||
this.labTitle = labTitle;
|
||||
}
|
||||
|
||||
public String getFileName() {
|
||||
return fileName;
|
||||
}
|
||||
|
||||
public void setFileName(String fileName) {
|
||||
this.fileName = fileName;
|
||||
}
|
||||
|
||||
public String getReviewStatus() {
|
||||
return reviewStatus;
|
||||
}
|
||||
|
||||
public void setReviewStatus(String reviewStatus) {
|
||||
this.reviewStatus = reviewStatus;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package com.jiuyv.sptccc.agile.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class ResUserPasswordDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long userId;
|
||||
|
||||
private String password;
|
||||
|
||||
private String oldPassword;
|
||||
|
||||
public Long getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(Long userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getOldPassword() {
|
||||
return oldPassword;
|
||||
}
|
||||
|
||||
public void setOldPassword(String oldPassword) {
|
||||
this.oldPassword = oldPassword;
|
||||
}
|
||||
}
|
@ -1,31 +1,33 @@
|
||||
package com.jiuyv.sptccc.agile.common.core.controller;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.jiuyv.sptccc.agile.common.core.domain.AjaxResult;
|
||||
import com.jiuyv.sptccc.agile.common.core.domain.R;
|
||||
import com.jiuyv.sptccc.agile.common.core.page.TableDataInfo;
|
||||
import com.jiuyv.sptccc.agile.common.exception.ServiceException;
|
||||
import com.jiuyv.sptccc.agile.dto.DataApiDTO;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import com.jiuyv.sptccc.agile.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* web层通用数据处理
|
||||
*
|
||||
* @author admin
|
||||
*/
|
||||
public class BaseController {
|
||||
public abstract class BaseController {
|
||||
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
||||
/**
|
||||
* 响应请求分页数据
|
||||
*/
|
||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||
protected <T> TableDataInfo<T> getDataTable(List<T> list, Integer total) {
|
||||
TableDataInfo rspData = new TableDataInfo();
|
||||
rspData.setCode(HttpStatus.OK.value());
|
||||
rspData.setMsg("查询成功");
|
||||
rspData.setRows(list);
|
||||
rspData.setTotal(total);
|
||||
return rspData;
|
||||
|
||||
protected <T> AjaxResult<T> successResult(R<T> r) {
|
||||
if (r.getCode() != HttpStatus.OK.value()) {
|
||||
throw new ServiceException(r.getMsg());
|
||||
}
|
||||
return AjaxResult.success(r.getData());
|
||||
}
|
||||
|
||||
protected <T> TableDataInfo<T> successResult(TableDataInfo<T> tableDataInfo) {
|
||||
if (tableDataInfo.getCode() != HttpStatus.OK.value()) {
|
||||
throw new ServiceException(tableDataInfo.getMsg());
|
||||
}
|
||||
return tableDataInfo;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,24 @@
|
||||
package com.jiuyv.sptccc.agile.common.enums;
|
||||
|
||||
public enum ContentShowType {
|
||||
BANNER("banner", "1"),
|
||||
INFORMATION("资讯", "2"),
|
||||
SCENES("应用场景", "3"),
|
||||
DATA_PRODUCT("数据产品", "4");
|
||||
|
||||
private final String tag;
|
||||
private final String value;
|
||||
|
||||
ContentShowType(String name, String value) {
|
||||
this.tag = name;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getTag() {
|
||||
return tag;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue