+
agile-bacth
com.jiuyv.sptcc.agile.batch
- 1.0-SNAPSHOT
+ 1.0.5-SNAPSHOT
4.0.0
agile-batch-service
- 0.0.1-SNAPSHOT
+ 1.0.5-SNAPSHOT
agile-batch-service
agile-batch-service
@@ -73,6 +72,16 @@
0.1.55
+
+
+ io.micrometer
+ micrometer-registry-prometheus
+
+
+
+ org.springframework.cloud
+ spring-cloud-starter-sleuth
+
com.oracle.database.jdbc
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
index 60ee19fa..5424fed7 100644
--- 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
@@ -1,5 +1,7 @@
package com.jiuyv.sptcc.agile.batch.batchTask.mapper;
+import java.util.List;
+
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@@ -24,5 +26,8 @@ public interface TblBatchTaskMapper{
/** 重置全部任务 */
void updateResetAllBusStatus(@Param("vo") TblBatchTask record,@Param("map") TblBatchTaskVO paramMap);
+
+
+ List selectListByMap(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
index c93c99e7..9b648cc0 100644
--- 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
@@ -173,4 +173,12 @@ public class BatchTaskServiceImpl implements IBatchTaskService {
//不报错
}
}
+
+ @Override
+ public List getRunningBatchTaskList() throws Exception {
+ TblBatchTaskVO batchTaskParamMap = new TblBatchTaskVO();
+ batchTaskParamMap.setBusStatus(TblBatchTaskEnum.BUS_STATUS.RUNING.getCode());
+ return tblBatchTaskMapper.selectListByMap(batchTaskParamMap);
+ }
+
}
\ 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
index 1f401aee..a8b90f27 100644
--- 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
@@ -54,4 +54,9 @@ public interface IBatchTaskService {
* @throws Exception
*/
public void doBatchTaskUnFinish(TblBatchTask task) throws Exception;
+
+
+
+ /** 获取正则运行的任务*/
+ public List getRunningBatchTaskList() 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/constant/TblPublicFilesEnum.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/constant/TblPublicFilesEnum.java
new file mode 100644
index 00000000..0f82044c
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/constant/TblPublicFilesEnum.java
@@ -0,0 +1,109 @@
+package com.jiuyv.sptcc.agile.batch.common.constant;
+
+/**
+ * 文件表枚举
+ * @author zhouliang
+ *
+ */
+public class TblPublicFilesEnum {
+
+ /** 文件类型 */
+ public enum FILE_TYPE {
+ NORMAL("normal", "常规文件"),
+ FLINK("flink", "flink组件"),//和docker组件类型统一的
+ PYTHON("python", "python组件"),//和docker组件类型统一的
+ DATA("data", "数据文件"),//和docker组件类型统一的
+
+ ;
+ private String code;
+ private String msg;
+
+ FILE_TYPE(String code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+ }
+
+ /** 文件来源*/
+ public enum FILE_SOURCE_TYPE {
+ //在文件表绑定关系只用作快捷条件(建议仍在各自业务表中绑定文件id关系)
+ DOCKERLIB("dockerlib", "实验室组件表"),
+ USER("user", "用户表表"),
+
+ ;
+ private String code;
+ private String msg;
+
+ FILE_SOURCE_TYPE(String code, String msg) {
+ this.code = code;
+ this.msg = msg;
+ }
+
+ public String getCode() {
+ return code;
+ }
+
+ public String getMsg() {
+ return msg;
+ }
+ }
+
+ /** 系统类型
+ * 为了区分门户用户、控制台用户
+ */
+ public enum SYS_TYPE {
+ CONSOLE("console", "控制台"),
+ PORTAL("portal", "门户"),
+
+ ;
+ private String code;
+ private String msg;
+
+ SYS_TYPE(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", "正常"), //业务数据正常使用中
+ CLEAR("96", "已清理"),//真实的文件已删除了
+ TRANSFERRING("97", "传输中"),//表示与业务数据还没绑定的,且没有传输完成(表示在分块/续传),可以直接清理的数据,
+ TEMPORARY("98", "临时"),//表示与业务数据还没绑定的,可以直接清理的数据
+ 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/common/util/sftp/SFTPChannel.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/util/sftp/SFTPChannel.java
index a5d00524..152850c9 100644
--- a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/util/sftp/SFTPChannel.java
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/common/util/sftp/SFTPChannel.java
@@ -33,13 +33,12 @@ public class SFTPChannel {
private static final Logger LOG = LoggerFactory.getLogger(SFTPChannel.class);
/**
- * 服务器连接对象
+ * 创建连接
* @param sftpDetails
* @param timeout
- * @return
* @throws JSchException
*/
- public ChannelSftp getChannel(SFTPConfig sftpDetails, int timeout) throws JSchException {
+ public void setConnect(SFTPConfig sftpDetails, int timeout) throws JSchException {
String ftpHost = sftpDetails.getHost();
int ftpPort = sftpDetails.getPort();
String ftpUserName = sftpDetails.getUsername();
@@ -57,10 +56,6 @@ public class SFTPChannel {
session.setConfig(config); // 为Session对象设置properties
session.setTimeout(timeout); // 设置timeout时间
session.connect(); // 通过Session建立链接
- channel = session.openChannel("sftp"); // 打开SFTP通道
- channel.connect(); // 建立SFTP通道的连接
- LOG.debug("Connected successfully to ftpHost = " + ftpHost + ",as ftpUserName = " + ftpUserName);
- return (ChannelSftp) channel;
}
/**
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/controller/SftpTempFileClearController.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/controller/SftpTempFileClearController.java
index 9388336f..53623ff2 100644
--- a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/controller/SftpTempFileClearController.java
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/controller/SftpTempFileClearController.java
@@ -1,21 +1,35 @@
package com.jiuyv.sptcc.agile.batch.controller;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.time.Duration;
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.time.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jcraft.jsch.ChannelSftp;
+import com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTaskVO;
+import com.jiuyv.sptcc.agile.batch.common.BaseTime;
import com.jiuyv.sptcc.agile.batch.common.R;
+import com.jiuyv.sptcc.agile.batch.common.constant.TblPublicFilesEnum;
import com.jiuyv.sptcc.agile.batch.common.util.sftp.SFTPChannel;
import com.jiuyv.sptcc.agile.batch.common.util.sftp.model.SFTPConfig;
+import com.jiuyv.sptcc.agile.batch.entity.TblPublicFiles;
import com.jiuyv.sptcc.agile.batch.framework.SftpConfigProperties;
+import com.jiuyv.sptcc.agile.batch.service.ISftpTempFileClearService;
/**
@@ -31,9 +45,22 @@ public class SftpTempFileClearController {
@Autowired
private SftpConfigProperties sftpConfigProperties;
+ @Autowired
+ private ISftpTempFileClearService sftpTempFileClearService;
+
+ @Value("${docker.dockerDataPath:}")
+ private String dockerDataPath;
+ @Value("${syncdata.clearLogFileDays:7}")
+ private int clearLogFileDays;
+
+ /* 查找docker的待销毁的文件 */
+ public static final String DOCKER_SHELL_STAT_GREP = "ls '%s' | xargs -I {} stat -c \"%%n %%Y\" '%s'{} |grep .pid";
+ /* 删除文件 */
+ public static final String SHELL_RM = "rm -rf '%s'";
/**
- * 清理临时文件,文件表中98临时状态超过一定时间
+ * 清理临时文件,文件表中98,97这类临时状态超过一定时间
+ * 清理已删除文件,文件表99的文件
* @return
* @throws Exception
*/
@@ -41,32 +68,78 @@ public class SftpTempFileClearController {
public R clearSftpTempFile() throws Exception{
//查询临时文件
String excludeFileSourceType=sftpConfigProperties.getExcludeFileSourceType();
+ List excludeFileSourceTypes=null;
if(StringUtils.isNotBlank(excludeFileSourceType)) {
String[] excludeFileSourceTypeArr=excludeFileSourceType.trim().split(" *, *");
- List list=new ArrayList<>();
+ excludeFileSourceTypes=new ArrayList<>();
for(String fileSourceType:excludeFileSourceTypeArr) {
if(StringUtils.isNotBlank(fileSourceType)) {
- list.add(fileSourceType);
+ excludeFileSourceTypes.add(fileSourceType);
}
}
}
+ sftpConfigProperties.getClearTempFileDays();
+ BaseTime timeVO = sftpTempFileClearService.getSysDate();
+ int days1 = sftpConfigProperties.getClearTempFileDays();
+ int days2 = sftpConfigProperties.getClearTempFileDays();
+ //临时文件
+ List flist1 = sftpTempFileClearService.getTempFileList(getCurrDateReduceDay(timeVO.getUtcTime()
+ , days1),excludeFileSourceTypes);
+ //已删除文件
+ List flist2 = sftpTempFileClearService.getDeletedFileList(getCurrDateReduceDay(timeVO.getUtcTime()
+ , days2));
+
+ if(flist1.isEmpty() && flist2.isEmpty()) {
+ return R.ok("finish");
+ }
+
+ boolean flag=true;
+ List filedIds=new ArrayList<>();
//连接文件服务器清理批处理
SFTPChannel channelx = new SFTPChannel();
try {
//创建容器前先创建目录挂载目录(后续要使用sftp操作)
- ChannelSftp chSftp = channelx.getChannel(createSftpCfg(), 60000);
- chSftp.quit();//直接退
-
-
- channelx.commitCurrShellCmd(String.format("rm -rf %s",""));
-
+ channelx.setConnect(createSftpCfg(), 60000);
+ for(TblPublicFiles x:flist1) {
+ filedIds.add(x.getFileId());
+ String path="";
+ if(TblPublicFilesEnum.DATA_STATUS.TEMPORARY.getCode().equals( x.getDataStatus())) {
+ path=x.getFactPath(sftpConfigProperties.getUploadPath());
+ }else if(TblPublicFilesEnum.DATA_STATUS.TRANSFERRING.getCode().equals( x.getDataStatus())) {
+ path=sftpConfigProperties.getUploadPath()+"/"+x.getSysType()+"-tmp/"+x.getUuid();
+ }
+ channelx.commitCurrShellCmd(String.format(SHELL_RM,path));
+ x=null;
+ }
+ for(TblPublicFiles x:flist2) {
+ filedIds.add(x.getFileId());
+ String path=x.getFactPath(sftpConfigProperties.getUploadPath());
+ channelx.commitCurrShellCmd(String.format(SHELL_RM,path));
+ x=null;
+ }
} catch (Exception e) {
LOGGER.info("initDocker error>>" ,e);
+ flag=false;
}finally {
channelx.closeChannel();
}
+ flist1=null;
+ flist2=null;
+ if(!filedIds.isEmpty()) {
+ int groupSize=1000;
+ for (int i = 0; i < filedIds.size(); i += groupSize) {
+ int endIndex = Math.min(i + groupSize, filedIds.size());
+ List sublist = filedIds.subList(i, endIndex);
+ sftpTempFileClearService.doUpdateDataStatus(sublist);
+ }
+ }
+
+ if(!flag) {
+ return R.ok("failed");
+ }
+
return R.ok("finish");
}
@@ -84,4 +157,63 @@ public class SftpTempFileClearController {
cfg.setHost(sftpConfigProperties.getHost());
return cfg;
}
+
+ public String getCurrDateReduceDay(Instant tm,int days) throws Exception {
+ Instant ntime = tm.plus(-days, ChronoUnit.DAYS);
+ Date date =new Date(ntime.toEpochMilli());
+ return new SimpleDateFormat("yyyy-MM-dd").format(date);
+ }
+
+ /**
+ * 清理实验室运行的日志文件(销毁一定时期后的)
+ */
+ @GetMapping("clearDockerLogFile")
+ public R clearDockerLogFile() throws Exception{
+ BaseTime timeVO = sftpTempFileClearService.getSysDate();
+
+ boolean flag=true;
+ //连接文件服务器清理批处理
+ SFTPChannel channelx = new SFTPChannel();
+ try {
+ //创建容器前先创建目录挂载目录(后续要使用sftp操作)
+ channelx.setConnect(createSftpCfg(), 60000);
+
+ //因为实验室总数量就几个,直接扫描实验室总目录下的文件
+ if(!dockerDataPath.endsWith("/")) {
+ dockerDataPath+="/";
+ }
+ String lscommand= String.format(DOCKER_SHELL_STAT_GREP, dockerDataPath,dockerDataPath);
+ List list =channelx.commitCurrShellCmd(lscommand);
+ if(!list.isEmpty()) {
+ for(String x:list) {
+ if(StringUtils.isBlank(x)) {
+ continue;
+ }
+ String[] arrs= x.split(" +");
+ if(arrs[1].length()==10) {//没有毫秒,补全
+ arrs[1]=arrs[1]+"000";
+ }
+ // 获取文件的修改时间
+ Date modifiedDate = new Date(Long.valueOf(arrs[1]));
+ long d= timeVO.getDate().getTime()-modifiedDate.getTime();
+ Duration duration = Duration.of(d, ChronoUnit.MILLIS);
+ if(duration.toDays()>=clearLogFileDays) {
+ channelx.commitCurrShellCmd(String.format(SHELL_RM, arrs[0])
+ +" && "+ String.format(SHELL_RM, arrs[0].replace(".pid", "")));
+ }
+ }
+ }
+ } catch (Exception e) {
+ LOGGER.info("initDocker error>>" ,e);
+ flag=false;
+ }finally {
+ channelx.closeChannel();
+ }
+
+ if(!flag) {
+ return R.ok("failed");
+ }
+
+ return R.ok("finish");
+ }
}
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/TblPublicFilesMapper.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/TblPublicFilesMapper.java
new file mode 100644
index 00000000..8f2e5d87
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/dao/TblPublicFilesMapper.java
@@ -0,0 +1,25 @@
+package com.jiuyv.sptcc.agile.batch.dao;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import com.jiuyv.sptcc.agile.batch.entity.TblPublicFiles;
+import com.jiuyv.sptcc.agile.batch.entity.vo.TblPublicFilesVO;
+
+
+/**
+ * 系统文件表
+ * @author zhouliang
+ * @date 2023-06-15
+ */
+@Mapper
+public interface TblPublicFilesMapper{
+ /** 查询分页 */
+ List selectTempFileList(TblPublicFilesVO paramMap);
+
+
+ /** 更新数据状态 */
+ void updateFileDataStatus(@Param("vo") TblPublicFiles record,@Param("map") TblPublicFilesVO paramMap);
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/entity/TblPublicFiles.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/entity/TblPublicFiles.java
new file mode 100644
index 00000000..48259880
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/entity/TblPublicFiles.java
@@ -0,0 +1,393 @@
+package com.jiuyv.sptcc.agile.batch.entity;
+
+import java.io.File;
+import java.util.Date;
+
+
+/**
+ * 系统文件表
+ * @author zhouliang
+ * @date 2023-06-15
+ */
+public class TblPublicFiles implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+ /** 文件主键id */
+ private Long fileId;
+
+ /** 版本号 */
+ private Long versionNum;
+
+ /** 随机码 */
+ private String recToken;
+
+ /** uuid */
+ private String uuid;
+
+ /** 文件名称 */
+ private String fileName;
+
+ /** 文件后缀名 */
+ private String fileExtension;
+
+ /** 文件大小 */
+ private String fileSize;
+
+ /** 文件分类路径 */
+ private String fileCategoryPath;
+
+ /** 文件类型 */
+ private String fileType;
+
+ /** 文件来源 */
+ private String fileSourceType;
+
+ /** 系统类型 */
+ private String sysType;
+
+ /** 文件备注 */
+ private String remarks;
+
+ /** 关联业务id */
+ private String fileBusiId;
+
+ /** 关联业务id2 */
+ private String fileBusiId2;
+
+ /** 关联业务id3 */
+ private String fileBusiId3;
+
+ /** 已上传大小 */
+ private String uploadSize;
+
+ /** 数据状态 */
+ private String dataStatus;
+
+ /** 创建用户id */
+ private String createBy;
+
+ /** 创建用户 */
+ private String createByName;
+
+ /** 创建时间 */
+ private Date createTime;
+
+ /** 更新用户id */
+ private String updateBy;
+
+ /** 更新用户 */
+ private String updateByName;
+
+ /** 更新时间 */
+ private Date updateTime;
+
+
+
+ /**
+ * Get文件主键id
+ */
+ public Long getFileId(){
+ return fileId;
+ }
+ /**
+ * Set文件主键id
+ */
+ public void setFileId(Long fileId){
+ this.fileId = fileId;
+ }
+
+ /**
+ * 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;
+ }
+
+ /**
+ * Getuuid
+ */
+ public String getUuid(){
+ return uuid;
+ }
+ /**
+ * Setuuid
+ */
+ public void setUuid(String uuid){
+ this.uuid = uuid;
+ }
+
+ /**
+ * Get文件名称
+ */
+ public String getFileName(){
+ return fileName;
+ }
+ /**
+ * Set文件名称
+ */
+ public void setFileName(String fileName){
+ this.fileName = fileName;
+ }
+
+ /**
+ * Get文件后缀名
+ */
+ public String getFileExtension(){
+ return fileExtension;
+ }
+ /**
+ * Set文件后缀名
+ */
+ public void setFileExtension(String fileExtension){
+ this.fileExtension = fileExtension;
+ }
+
+ /**
+ * Get文件大小
+ */
+ public String getFileSize(){
+ return fileSize;
+ }
+ /**
+ * Set文件大小
+ */
+ public void setFileSize(String fileSize){
+ this.fileSize = fileSize;
+ }
+
+ /**
+ * Get文件分类路径
+ */
+ public String getFileCategoryPath(){
+ return fileCategoryPath;
+ }
+ /**
+ * Set文件分类路径
+ */
+ public void setFileCategoryPath(String fileCategoryPath){
+ this.fileCategoryPath = fileCategoryPath;
+ }
+
+ /**
+ * Get文件类型
+ */
+ public String getFileType(){
+ return fileType;
+ }
+ /**
+ * Set文件类型
+ */
+ public void setFileType(String fileType){
+ this.fileType = fileType;
+ }
+
+ /**
+ * Get文件来源
+ */
+ public String getFileSourceType(){
+ return fileSourceType;
+ }
+ /**
+ * Set文件来源
+ */
+ public void setFileSourceType(String fileSourceType){
+ this.fileSourceType = fileSourceType;
+ }
+
+ /**
+ * Get系统类型
+ */
+ public String getSysType(){
+ return sysType;
+ }
+ /**
+ * Set系统类型
+ */
+ public void setSysType(String sysType){
+ this.sysType = sysType;
+ }
+
+ /**
+ * Get文件备注
+ */
+ public String getRemarks(){
+ return remarks;
+ }
+ /**
+ * Set文件备注
+ */
+ public void setRemarks(String remarks){
+ this.remarks = remarks;
+ }
+
+ /**
+ * Get关联业务id
+ */
+ public String getFileBusiId(){
+ return fileBusiId;
+ }
+ /**
+ * Set关联业务id
+ */
+ public void setFileBusiId(String fileBusiId){
+ this.fileBusiId = fileBusiId;
+ }
+
+ /**
+ * Get关联业务id2
+ */
+ public String getFileBusiId2(){
+ return fileBusiId2;
+ }
+ /**
+ * Set关联业务id2
+ */
+ public void setFileBusiId2(String fileBusiId2){
+ this.fileBusiId2 = fileBusiId2;
+ }
+
+ /**
+ * Get关联业务id3
+ */
+ public String getFileBusiId3(){
+ return fileBusiId3;
+ }
+ /**
+ * Set关联业务id3
+ */
+ public void setFileBusiId3(String fileBusiId3){
+ this.fileBusiId3 = fileBusiId3;
+ }
+
+ /**
+ * Get已上传大小
+ */
+ public String getUploadSize(){
+ return uploadSize;
+ }
+ /**
+ * Set已上传大小
+ */
+ public void setUploadSize(String uploadSize){
+ this.uploadSize = uploadSize;
+ }
+
+ /**
+ * Get数据状态
+ */
+ public String getDataStatus(){
+ return dataStatus;
+ }
+ /**
+ * Set数据状态
+ */
+ public void setDataStatus(String dataStatus){
+ this.dataStatus = dataStatus;
+ }
+
+ /**
+ * Get创建用户id
+ */
+ public String getCreateBy(){
+ return createBy;
+ }
+ /**
+ * Set创建用户id
+ */
+ public void setCreateBy(String createBy){
+ this.createBy = createBy;
+ }
+
+ /**
+ * Get创建用户
+ */
+ public String getCreateByName(){
+ return createByName;
+ }
+ /**
+ * Set创建用户
+ */
+ public void setCreateByName(String createByName){
+ this.createByName = createByName;
+ }
+
+ /**
+ * Get创建时间
+ */
+ public Date getCreateTime(){
+ return createTime;
+ }
+ /**
+ * Set创建时间
+ */
+ public void setCreateTime(Date createTime){
+ this.createTime = createTime;
+ }
+
+ /**
+ * Get更新用户id
+ */
+ public String getUpdateBy(){
+ return updateBy;
+ }
+ /**
+ * Set更新用户id
+ */
+ public void setUpdateBy(String updateBy){
+ this.updateBy = updateBy;
+ }
+
+ /**
+ * Get更新用户
+ */
+ public String getUpdateByName(){
+ return updateByName;
+ }
+ /**
+ * Set更新用户
+ */
+ public void setUpdateByName(String updateByName){
+ this.updateByName = updateByName;
+ }
+
+ /**
+ * Get更新时间
+ */
+ public Date getUpdateTime(){
+ return updateTime;
+ }
+ /**
+ * Set更新时间
+ */
+ public void setUpdateTime(Date updateTime){
+ this.updateTime = updateTime;
+ }
+
+
+ /*
+ * 获取真实的文件路径
+ */
+ public String getFactPath(String rootPath) {
+ return rootPath+"/"+fileCategoryPath+"/"+uuid+"."+fileExtension;
+ }
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/entity/vo/TblPublicFilesVO.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/entity/vo/TblPublicFilesVO.java
new file mode 100644
index 00000000..d06cfe22
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/entity/vo/TblPublicFilesVO.java
@@ -0,0 +1,71 @@
+package com.jiuyv.sptcc.agile.batch.entity.vo;
+
+import java.util.List;
+
+import com.jiuyv.sptcc.agile.batch.entity.TblPublicFiles;
+
+ /**
+ * 系统文件表,扩展
+ * @author zhouliang
+ * @date 2023-06-15
+ */
+public class TblPublicFilesVO extends TblPublicFiles implements java.io.Serializable {
+
+ private static final long serialVersionUID = 1L;
+
+
+ /** 条件:文件来源集合 */
+ private List fileSourceTypes;
+
+ /** 条件:数据状态集合 */
+ private List dataStatuss;
+
+
+ /** 条件:文件id集合 */
+ private List fileIds;
+
+
+ /**
+ * @return the fileSourceTypes
+ */
+ public List getFileSourceTypes() {
+ return fileSourceTypes;
+ }
+
+ /**
+ * @param fileSourceTypes the fileSourceTypes to set
+ */
+ public void setFileSourceTypes(List fileSourceTypes) {
+ this.fileSourceTypes = fileSourceTypes;
+ }
+
+ /**
+ * @return the dataStatuss
+ */
+ public List getDataStatuss() {
+ return dataStatuss;
+ }
+
+ /**
+ * @param dataStatuss the dataStatuss to set
+ */
+ public void setDataStatuss(List dataStatuss) {
+ this.dataStatuss = dataStatuss;
+ }
+
+ /**
+ * @return the fileIds
+ */
+ public List getFileIds() {
+ return fileIds;
+ }
+
+ /**
+ * @param fileIds the fileIds to set
+ */
+ public void setFileIds(List fileIds) {
+ this.fileIds = fileIds;
+ }
+
+
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/framework/SftpConfigProperties.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/framework/SftpConfigProperties.java
index 45cbf8e0..ffcae8b1 100644
--- a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/framework/SftpConfigProperties.java
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/framework/SftpConfigProperties.java
@@ -39,9 +39,14 @@ public class SftpConfigProperties implements java.io.Serializable{
/** 全局上传主路径 */
private String uploadPath;
- /** 自动清理任务时排除文件类型fileSourceType */
+ /** 自动清理任务:排除文件类型fileSourceType */
private String excludeFileSourceType;
+ /** 自动清理任务:临时文件清理过期天数 */
+ private int clearTempFileDays=1;
+
+ /** 自动清理任务:删除文件清理过期天数 */
+ private int clearDelFileDays=3;
/**
* @return the host
@@ -115,4 +120,32 @@ public class SftpConfigProperties implements java.io.Serializable{
public void setExcludeFileSourceType(String excludeFileSourceType) {
this.excludeFileSourceType = excludeFileSourceType;
}
+
+ /**
+ * @return the clearTempFileDays
+ */
+ public int getClearTempFileDays() {
+ return clearTempFileDays;
+ }
+
+ /**
+ * @param clearTempFileDays the clearTempFileDays to set
+ */
+ public void setClearTempFileDays(int clearTempFileDays) {
+ this.clearTempFileDays = clearTempFileDays;
+ }
+
+ /**
+ * @return the clearDelFileDays
+ */
+ public int getClearDelFileDays() {
+ return clearDelFileDays;
+ }
+
+ /**
+ * @param clearDelFileDays the clearDelFileDays to set
+ */
+ public void setClearDelFileDays(int clearDelFileDays) {
+ this.clearDelFileDays = clearDelFileDays;
+ }
}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/service/ISftpTempFileClearService.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/service/ISftpTempFileClearService.java
new file mode 100644
index 00000000..c6906ced
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/service/ISftpTempFileClearService.java
@@ -0,0 +1,28 @@
+package com.jiuyv.sptcc.agile.batch.service;
+
+import java.util.List;
+
+import com.jiuyv.sptcc.agile.batch.common.BaseTime;
+import com.jiuyv.sptcc.agile.batch.entity.TblPublicFiles;
+
+
+/**
+ * 清理临时文件任务
+ * @author zhouliang
+ * @date 2023-07-05
+ */
+public interface ISftpTempFileClearService {
+
+ /** 获取时间 */
+ public BaseTime getSysDate() throws Exception;
+
+ /** 获取临时文件98和传输中的97*/
+ public List getTempFileList(String dateStr,List excludeFileSourceTypes) throws Exception;
+ /** 获取已删除的文件99 */
+ public List getDeletedFileList(String dateStr) throws Exception;
+
+ /** 更新文件状态*/
+ public void doUpdateDataStatus(List filedIds) throws Exception;
+
+
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/service/SftpTempFileClearImpl.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/service/SftpTempFileClearImpl.java
new file mode 100644
index 00000000..4b3ddd7f
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/service/SftpTempFileClearImpl.java
@@ -0,0 +1,76 @@
+package com.jiuyv.sptcc.agile.batch.service;
+
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.commons.lang3.time.DateUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.jiuyv.sptcc.agile.batch.common.BaseTime;
+import com.jiuyv.sptcc.agile.batch.common.constant.TblPublicFilesEnum;
+import com.jiuyv.sptcc.agile.batch.dao.ISysTimeBaseMapper;
+import com.jiuyv.sptcc.agile.batch.dao.TblPublicFilesMapper;
+import com.jiuyv.sptcc.agile.batch.entity.TblPublicFiles;
+import com.jiuyv.sptcc.agile.batch.entity.vo.TblPublicFilesVO;
+
+
+/**
+ * 清理临时文件任务
+ * @author zhouliang
+ * @date 2023-07-05
+ */
+@Service("sftpTempFileClearService")
+public class SftpTempFileClearImpl implements ISftpTempFileClearService {
+ @Autowired
+ private TblPublicFilesMapper tblPublicFilesMapper;
+ @Autowired
+ private ISysTimeBaseMapper sysTimeBaseMapper;
+
+ @Override
+ public List getTempFileList(String dateStr,List excludeFileSourceTypes) throws Exception {
+ TblPublicFilesVO paramMap=new TblPublicFilesVO();
+ Date currdate=new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
+ paramMap.setCreateTime(DateUtils.addDays(currdate, -3));
+ paramMap.setUpdateTime(DateUtils.addDays(currdate, 1));//因为不含等于所以加一天
+ List dataStatuss=new ArrayList<>();
+ dataStatuss.add(TblPublicFilesEnum.DATA_STATUS.TEMPORARY.getCode());
+ dataStatuss.add(TblPublicFilesEnum.DATA_STATUS.TRANSFERRING.getCode());
+ paramMap.setDataStatuss(dataStatuss);
+ paramMap.setFileSourceTypes(excludeFileSourceTypes);
+ return tblPublicFilesMapper.selectTempFileList(paramMap);
+ }
+ @Override
+ public List getDeletedFileList(String dateStr) throws Exception {
+ TblPublicFilesVO paramMap=new TblPublicFilesVO();
+ Date currdate=new SimpleDateFormat("yyyy-MM-dd").parse(dateStr);
+ paramMap.setCreateTime(DateUtils.addDays(currdate, -3));//预留几天,防止任务没有正常运行
+ paramMap.setUpdateTime(DateUtils.addDays(currdate, 1));//因为不含等于所以加一天
+ List dataStatuss=new ArrayList<>();
+ dataStatuss.add(TblPublicFilesEnum.DATA_STATUS.DELETED.getCode());
+ paramMap.setDataStatuss(dataStatuss);
+ return tblPublicFilesMapper.selectTempFileList(paramMap);
+ }
+
+ @Override
+ public void doUpdateDataStatus(List filedIds) throws Exception {
+ BaseTime tmieVO = getSysDate();
+
+ TblPublicFiles record=new TblPublicFiles();
+ record.setUpdateTime(tmieVO.getDate());
+ record.setDataStatus(TblPublicFilesEnum.DATA_STATUS.CLEAR.getCode());
+
+ TblPublicFilesVO paramMap=new TblPublicFilesVO();
+ paramMap.setFileIds(filedIds);
+ tblPublicFilesMapper.updateFileDataStatus(record,paramMap);
+ }
+
+ //获取系统时间
+ @Override
+ public BaseTime getSysDate() throws Exception {
+ return sysTimeBaseMapper.selectSysCurrentTime();
+ }
+
+}
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/jsydb/JsyHiveJDBCBuilder.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/jsydb/JsyHiveJDBCBuilder.java
index 84cd8c1a..a42e780a 100644
--- a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/jsydb/JsyHiveJDBCBuilder.java
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/jsydb/JsyHiveJDBCBuilder.java
@@ -59,6 +59,8 @@ public class JsyHiveJDBCBuilder {
String zooKeeperNamespace = clientInfo.getProperty("zooKeeperNamespace");
String serviceDiscoveryMode = clientInfo.getProperty("serviceDiscoveryMode");
String principal = clientInfo.getProperty("principal");
+ String socketTimeout = clientInfo.getProperty("socketTimeout");
+ String connectTimeout = clientInfo.getProperty("connectTimeout");
String userKeytabFile=null;
String krb5File=null;
@@ -95,8 +97,19 @@ public class JsyHiveJDBCBuilder {
.append(serviceDiscoveryMode)
.append(";zooKeeperNamespace=")
.append(zooKeeperNamespace)
- .append(";auth=none");
+ .append(";auth=none;");
}
+ if(StringUtils.isNotBlank(socketTimeout)) {
+ sBuilder.append("socketTimeout="+socketTimeout+";");
+ }else {
+ sBuilder.append("socketTimeout=12000;");
+ }
+ if(StringUtils.isNotBlank(connectTimeout)) {
+ sBuilder.append("connectTimeout="+connectTimeout+";");
+ }else {
+ sBuilder.append("connectTimeout=6000;");
+ }
+
String url = sBuilder.toString();
// System.out.print(url);
return url;
@@ -168,8 +181,9 @@ public class JsyHiveJDBCBuilder {
.append(serviceDiscoveryMode)
.append(";zooKeeperNamespace=")
.append(zooKeeperNamespace)
- .append(";auth=none");
+ .append(";auth=none;");
}
+ sBuilder.append("hive2.server.execute.timeout=12000;");
String url = sBuilder.toString();
// System.out.print(url);
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/JdbcBaseReader.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/JdbcBaseReader.java
index 5b4946a3..8622f2dd 100644
--- a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/JdbcBaseReader.java
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/JdbcBaseReader.java
@@ -36,6 +36,13 @@ public class JdbcBaseReader {
LOGGER.info("Create connection url={}, username={}",url,username);
// 加载JDBC驱动
Class.forName(driverClassName);
+ if(!url.contains("socketTimeout")) {
+ // socketTimeout=12000
+ //loginTimeout=60
+ }else if(!url.contains("loginTimeout")) {
+ // socketTimeout=12000
+ //loginTimeout=60
+ }
// 获取JDBC连接
connection = DriverManager.getConnection(url, username!=null?username:"", password!=null?password:"");
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/ReaderWriterHelper.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/ReaderWriterHelper.java
index ca3d0a0a..449b57c1 100644
--- a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/ReaderWriterHelper.java
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/common/reader/ReaderWriterHelper.java
@@ -215,7 +215,7 @@ public class ReaderWriterHelper {
LOGGER.info("writeData exec selectSql>>time={}",(ttime2-ttime));
long count=0;
if(resultSet!=null) {
- LOGGER.info("writeData Task Progress>>start");
+ LOGGER.info("writeData Task Progress>>start, each num={}",singleWriteNumber);
//解决使用*的返回字段全路径问题
int n=resultSet.getMetaData().getColumnCount();
Map colMap=new LinkedHashMap<>();
diff --git a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/controller/SyncDataReadTaskController.java b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/controller/SyncDataReadTaskController.java
index 7986372c..89c34c9a 100644
--- a/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/controller/SyncDataReadTaskController.java
+++ b/agile-bacth/agile-batch-service/src/main/java/com/jiuyv/sptcc/agile/batch/syncJiushiData/controller/SyncDataReadTaskController.java
@@ -1,13 +1,19 @@
package com.jiuyv.sptcc.agile.batch.syncJiushiData.controller;
+import java.io.BufferedReader;
import java.io.File;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
-import java.util.Calendar;
+import java.time.Duration;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
import java.util.Date;
import java.util.Enumeration;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
@@ -28,6 +34,7 @@ import org.springframework.web.bind.annotation.RestController;
import com.jiuyv.sptcc.agile.batch.batchTask.common.TblBatchTaskEnum;
import com.jiuyv.sptcc.agile.batch.batchTask.entity.vo.TblBatchTaskVO;
import com.jiuyv.sptcc.agile.batch.batchTask.service.IBatchTaskService;
+import com.jiuyv.sptcc.agile.batch.common.BaseTime;
import com.jiuyv.sptcc.agile.batch.common.R;
import com.jiuyv.sptcc.agile.batch.syncJiushiData.common.DDsProperties;
import com.jiuyv.sptcc.agile.batch.syncJiushiData.common.SyncDataConstants;
@@ -51,8 +58,10 @@ public class SyncDataReadTaskController {
private IBatchTaskService batchTaskService;
@Value("${syncdata.clearTempFileDs:}")
private String defaultClearTempFileDs;
- @Value("${syncdata.clearTempFileDays:15}")
+ @Value("${syncdata.clearTempFileDays:7}")
private int defaultClearTempFileDays;
+ @Value("${syncdata.resetTaskStatusTime:30}")
+ private int resetTaskStatusTime;
//外部任务调度器触发的任务,线程不是同一个,必须保证任务只能有一个执行
//下面实现了通用的按天处理的单表同步模式
@@ -195,6 +204,17 @@ public class SyncDataReadTaskController {
printWriter.flush();
int exitCode= process.waitFor();
if (exitCode != 0) {
+ // 获取错误信息流
+ InputStream errorStream = process.getErrorStream();
+ BufferedReader errorReader = new BufferedReader(new InputStreamReader(errorStream));
+ String line;
+ String line2="";
+ while ((line = errorReader.readLine()) != null) {
+ line2+="\n"+line;
+ }
+ LOGGER.error(">>>>>>"+line2);
+ // 关闭流
+ errorReader.close();
LOGGER.error("refresh Kerberos TGT:Check if the Kerberos command exists and permissions!!");
}else {
LOGGER.warn("refresh Kerberos TGT Finish.");
@@ -212,15 +232,14 @@ public class SyncDataReadTaskController {
refreshTicket();//启动就初始化一次,这样可以不用先手动创建
}
-
/**
- * 清理临时文件
+ * 清理同步产生的临时文件
* @return
* @throws Exception
*/
- @GetMapping("clearTempFile")
+ @GetMapping("clearSyncTempFile")
public R clearTempFile() throws Exception{
- //如果写入的是文件,则会产生临时文件,定时清理1个月之前文件
+ //如果写入的是文件,则会产生临时文件,定时清理
if(StringUtils.isNotBlank(defaultClearTempFileDs)) {
String[] dsarr=defaultClearTempFileDs.split(",");
for(String dsx:dsarr) {
@@ -253,12 +272,33 @@ public class SyncDataReadTaskController {
}
// 获取文件的修改时间
Date modifiedDate = new Date(file.lastModified());
- Date date = DateUtils.addDays(modifiedDate, days);
Date currDate = new Date();
- int d= DateUtils.truncatedCompareTo(date, currDate, Calendar.DATE);
- if(d<0 && file.delete()) {
+ long d= currDate.getTime()-modifiedDate.getTime();
+ Duration duration = Duration.of(d, ChronoUnit.MILLIS);
+ if(duration.toDays()>=days && file.delete()) {
//ok
}
}
}
+
+
+
+ /**
+ * 重置任务状态,假设任务超时没有正常结束
+ * @throws Exception
+ */
+ @Scheduled(cron = "0 */10 * * * ?")
+ public void batchTaskReset() throws Exception{
+ List list = batchTaskService.getRunningBatchTaskList();
+ if(list==null || list.isEmpty()) {
+ return;
+ }
+ BaseTime timeVO = syncDataReadTaskServiceManager.getSysDate();
+ for(TblBatchTaskVO x:list) {
+ if((timeVO.getUtcTime().toEpochMilli()-x.getCurrStartDate().getTime())>=(resetTaskStatusTime*60*1000)) {
+ LOGGER.error("batchTaskReset>>{}", x.getTaskNo());
+ batchTaskService.doBatchTaskUnFinish(x);
+ }
+ }
+ }
}
diff --git a/agile-bacth/agile-batch-service/src/main/resources/application-dev.yml b/agile-bacth/agile-batch-service/src/main/resources/application-dev.yml
index 31f08b32..e914eb2f 100644
--- a/agile-bacth/agile-batch-service/src/main/resources/application-dev.yml
+++ b/agile-bacth/agile-batch-service/src/main/resources/application-dev.yml
@@ -21,11 +21,17 @@ filesftp:
username: flink
password: mIVYkELj5T+4MnD5+V542A==
uploadPath: /home/flink/sysfile
- #清理文件时,需要排除文件表的类型,多个用,分隔
- excludeFileSourceType: usertest,usertest2
- #清理分块上传临时目录,多个用,分隔
- includeFileCategoryPath: console-tmp,portal-tmp
- clearTempFileDays: 3 #过期天数,更新时间超过N天即过期
+ #清理临时文件时,排除文件表的FileSourceType,多个用,分隔(要排除的自己定义不同的类型,勿冲突)
+ excludeFileSourceType: portaltest
+ #临时文件过期天数,更新时间超过N天即过期
+ clearTempFileDays: 30
+ #已删除文件过期天数,更新时间超过N天即过期(分开控制)
+ clearDelFileDays: 30
+docker:
+ #实验室主目录
+ dockerDataPath: /home/flink/docker_data
+ clearLogFileDays: 3 #日志过期天数,销毁超过N天即过期
+
console:
#readWritePath: /home/flink/read_write_data
readWritePath: F:\ZLworkspace\agilesystem\agile.batch\src\trunk\agile-bacth\agile-batch-service\read_write_data
@@ -35,6 +41,7 @@ syncdata:
singleWriteNumber: 20000 #读取一定数量写入一次
clearTempFileDs: klbHiveDs #需清理的数据库,同步任务临时文件、过期文件,多个用,分隔
clearTempFileDays: 7 #过期天数,更新时间超过N天即过期
+ resetTaskStatusTime: 40 #任务超过N分钟没结束就强制终止,最长的算
klbHiveDs: #客流宝hive
url: jdbc:hive2://172.16.12.101:10000/hive;socketTimeout=12000;
@@ -44,6 +51,7 @@ klbHiveDs: #客流宝hive
singleWriteNumber: 2000 #读取一定数量写入一次,覆盖默认
readWritePath: ${console.readWritePath}2 #文件存放路径,覆盖默认
fieldSeparator: ',' #文件字段分隔符号,默认就是逗号
+ clearTempFileDays: 7 #过期天数,更新时间超过N天即过期
klbPgDs: #客流宝pg
url: ${spring.datasource.url}
username: ${spring.datasource.username}
diff --git a/agile-bacth/agile-batch-service/src/main/resources/config/hiveJsy/hiveclient.properties b/agile-bacth/agile-batch-service/src/main/resources/config/hiveJsy/hiveclient.properties
index 41e45779..032088cd 100644
--- a/agile-bacth/agile-batch-service/src/main/resources/config/hiveJsy/hiveclient.properties
+++ b/agile-bacth/agile-batch-service/src/main/resources/config/hiveJsy/hiveclient.properties
@@ -7,3 +7,5 @@ sasl.qop = auth-conf
zooKeeperNamespace = hiveserver2
serviceDiscoveryMode = zooKeeper
instanceNo = 0
+socketTimeout=12000
+connectTimeout=6000
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/resources/mappers/SysBaseMapper.xml b/agile-bacth/agile-batch-service/src/main/resources/mappers/SysBaseMapper.xml
index 2a222f39..7356850b 100644
--- a/agile-bacth/agile-batch-service/src/main/resources/mappers/SysBaseMapper.xml
+++ b/agile-bacth/agile-batch-service/src/main/resources/mappers/SysBaseMapper.xml
@@ -2,6 +2,6 @@
\ No newline at end of file
diff --git a/agile-bacth/agile-batch-service/src/main/resources/mappers/TblBatchTaskMapper.xml b/agile-bacth/agile-batch-service/src/main/resources/mappers/TblBatchTaskMapper.xml
index 7612b6c6..ffaaae87 100644
--- a/agile-bacth/agile-batch-service/src/main/resources/mappers/TblBatchTaskMapper.xml
+++ b/agile-bacth/agile-batch-service/src/main/resources/mappers/TblBatchTaskMapper.xml
@@ -49,7 +49,7 @@
pre_end_date = #{vo.preEndDate},
pre_total_time = #{vo.preTotalTime},
curr_start_date = #{vo.currStartDate},
- failure_conditions = #{vo.failureConditions},
+ failure_conditions = #{vo.failureConditions},
bus_status = #{vo.busStatus},
data_status = #{vo.dataStatus},
update_time = #{vo.updateTime},
@@ -79,4 +79,15 @@
+
+
+
+
diff --git a/agile-bacth/agile-batch-service/src/main/resources/mappers/TblPublicFilesMapper.xml b/agile-bacth/agile-batch-service/src/main/resources/mappers/TblPublicFilesMapper.xml
new file mode 100644
index 00000000..2f8b8c3b
--- /dev/null
+++ b/agile-bacth/agile-batch-service/src/main/resources/mappers/TblPublicFilesMapper.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
+
+
+ update tbl_public_files
+ set
+ #{vo.updateBy},
+ #{vo.updateByName},
+ data_status = #{vo.dataStatus},
+ update_time = #{vo.updateTime}
+ where
+ file_id in (#{fileId})
+
+
+
diff --git a/agile-bacth/pom.xml b/agile-bacth/pom.xml
index 40e03754..1f0d8bbf 100644
--- a/agile-bacth/pom.xml
+++ b/agile-bacth/pom.xml
@@ -1,18 +1,16 @@
-
+
4.0.0
org.springframework.boot
spring-boot-starter-parent
2.6.7
-
+
com.jiuyv.sptcc.agile.batch
agile-bacth
- 1.0-SNAPSHOT
+ 1.0.5-SNAPSHOT
agile-batch-api
agile-batch-service
@@ -68,8 +66,8 @@
- scm:svn:http://172.16.12.10/sptcc_agile_etl/src/agile-batch/src/trunk/agile-batch
- scm:svn:http://172.16.12.10/svn/sptcc_agile_etl/src/agile-batch/src/trunk/agile-batch
+ scm:svn:http://172.16.12.10/svn/sptcc_agile_etl/src/agile.batch/src/trunk/agile-bacth
+ scm:svn:http://172.16.12.10/svn/sptcc_agile_etl/src/agile.batch/src/trunk/agile-bacth
diff --git a/agile-portal/agile-portal-api/pom.xml b/agile-portal/agile-portal-api/pom.xml
index 92895b47..0674fad1 100644
--- a/agile-portal/agile-portal-api/pom.xml
+++ b/agile-portal/agile-portal-api/pom.xml
@@ -3,7 +3,7 @@
agile-portal
com.jiuyv.sptcc.agile
- 0.0.5-SNAPSHOT
+ 0.2.4-SNAPSHOT
4.0.0
@@ -20,16 +20,59 @@
spring-web
-
- org.springframework.cloud
- spring-cloud-starter-netflix-eureka-client
+ javax.servlet
+ javax.servlet-api
+
+
+
+
+ com.fasterxml.jackson.core
+ jackson-databind
+
com.jiuyv.sptcc.agile
agile-common
+
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.mockito
+ mockito-inline
+ test
+
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.10
+
+
+ default-prepare-agent
+
+ prepare-agent
+
+
+
+ default-report
+ prepare-package
+
+ report
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/ContentFeignApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/ContentFeignApi.java
index 5a2106a8..c127e99b 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/ContentFeignApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/ContentFeignApi.java
@@ -1,7 +1,7 @@
package com.jiuyv.sptccc.agile.api;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.common.core.domain.R;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.domain.TableDataPage;
import com.jiuyv.sptccc.agile.dto.PortalContentDTO;
import com.jiuyv.sptccc.agile.dto.ReqPageDTO;
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerApplyFeignApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerApplyFeignApi.java
index 7cfdb5f7..76efd235 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerApplyFeignApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerApplyFeignApi.java
@@ -1,7 +1,7 @@
package com.jiuyv.sptccc.agile.api;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.common.core.domain.R;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.domain.TableDataPage;
import com.jiuyv.sptccc.agile.dto.DockerApplyReviewDTO;
import com.jiuyv.sptccc.agile.dto.ReqDockerApplyPageDTO;
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerDownloadApplyFeignApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerDownloadApplyFeignApi.java
index 59020956..02f8e04e 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerDownloadApplyFeignApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerDownloadApplyFeignApi.java
@@ -1,6 +1,6 @@
package com.jiuyv.sptccc.agile.api;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.domain.TableDataPage;
import com.jiuyv.sptccc.agile.dto.DockerDownloadApplyDTO;
import com.jiuyv.sptccc.agile.dto.ReqDockerDownApplyPageDTO;
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerWithUserFeignApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerWithUserFeignApi.java
index 7e1ac05b..6da7e792 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerWithUserFeignApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/DockerWithUserFeignApi.java
@@ -1,7 +1,7 @@
package com.jiuyv.sptccc.agile.api;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.common.core.domain.R;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.domain.TableDataPage;
import com.jiuyv.sptccc.agile.dto.DockerFileDTO;
import com.jiuyv.sptccc.agile.dto.DockerWithUserDTO;
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/FileFeignApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/FileFeignApi.java
index 6df96dbf..1133c57e 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/FileFeignApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/FileFeignApi.java
@@ -1,7 +1,7 @@
package com.jiuyv.sptccc.agile.api;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.common.core.domain.R;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.domain.TableDataPage;
import com.jiuyv.sptccc.agile.dto.ReqFileDTO;
import com.jiuyv.sptccc.agile.dto.UploadFileDTO;
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalLogFeignApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalLogFeignApi.java
index 969d9cce..fcf1bed4 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalLogFeignApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalLogFeignApi.java
@@ -1,7 +1,7 @@
package com.jiuyv.sptccc.agile.api;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.common.core.domain.R;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.dto.ReqLogDTO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalMessageApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalMessageApi.java
index d4959852..85a0ed20 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalMessageApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalMessageApi.java
@@ -1,7 +1,7 @@
package com.jiuyv.sptccc.agile.api;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.common.core.domain.R;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.domain.TableDataPage;
import com.jiuyv.sptccc.agile.dto.PortalMessageDTO;
import com.jiuyv.sptccc.agile.dto.ReqPageDTO;
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalUserFeignApi.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalUserFeignApi.java
index a0a0d9bd..e456f464 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalUserFeignApi.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/api/PortalUserFeignApi.java
@@ -1,7 +1,7 @@
package com.jiuyv.sptccc.agile.api;
+import com.jiuyv.sptccc.agile.common.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.common.core.domain.R;
-import com.jiuyv.sptccc.agile.constant.FeignApiConstant;
import com.jiuyv.sptccc.agile.dto.PortalUserDTO;
import com.jiuyv.sptccc.agile.dto.ResUserPasswordDTO;
import org.springframework.web.bind.annotation.GetMapping;
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Anonymous.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Anonymous.java
similarity index 100%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Anonymous.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Anonymous.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Log.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Log.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Log.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Log.java
index eb2b6ea3..8df1ef6e 100644
--- a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Log.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/Log.java
@@ -1,14 +1,14 @@
package com.jiuyv.sptccc.agile.common.annotation;
+import com.jiuyv.sptccc.agile.common.enums.BusinessType;
+import com.jiuyv.sptccc.agile.common.enums.OperatorType;
+
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-import com.jiuyv.sptccc.agile.common.enums.BusinessType;
-import com.jiuyv.sptccc.agile.common.enums.OperatorType;
-
/**
* 自定义操作日志记录注解
*
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogIgnore.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogIgnore.java
similarity index 100%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogIgnore.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogIgnore.java
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogSimpleResult.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogSimpleResult.java
similarity index 100%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogSimpleResult.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogSimpleResult.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogIgnore.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/NoRepeatSubmit.java
similarity index 65%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogIgnore.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/NoRepeatSubmit.java
index 3d5e94cc..011ce293 100644
--- a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/annotation/LogIgnore.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/annotation/NoRepeatSubmit.java
@@ -2,18 +2,20 @@ package com.jiuyv.sptccc.agile.common.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
/**
- * 方法不需要输出日志时使用
+ * 忽略连续提交限制
+ *
+ * @author admin
*
- * @author zhouliang
*/
-@Target({ElementType.METHOD})
+@Inherited
+@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
-public @interface LogIgnore {
-}
\ No newline at end of file
+public @interface NoRepeatSubmit {
+}
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/constant/CacheNames.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/CacheNames.java
similarity index 100%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/constant/CacheNames.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/CacheNames.java
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/constant/FeignApiConstant.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/FeignApiConstant.java
similarity index 87%
rename from agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/constant/FeignApiConstant.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/FeignApiConstant.java
index 2dd78979..adc2c74d 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/constant/FeignApiConstant.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/FeignApiConstant.java
@@ -1,4 +1,4 @@
-package com.jiuyv.sptccc.agile.constant;
+package com.jiuyv.sptccc.agile.common.constant;
public final class FeignApiConstant {
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/constant/Constants.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/FrontConstant.java
similarity index 97%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/constant/Constants.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/FrontConstant.java
index 42480239..65a03912 100644
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/constant/Constants.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/FrontConstant.java
@@ -4,7 +4,7 @@ package com.jiuyv.sptccc.agile.common.constant;
* 通用常量信息
*
*/
-public class Constants {
+public class FrontConstant {
/**
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/constant/Constants.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/ServiceConstant.java
similarity index 96%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/constant/Constants.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/ServiceConstant.java
index e7794b46..98091b6e 100644
--- a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/constant/Constants.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/constant/ServiceConstant.java
@@ -5,7 +5,7 @@ package com.jiuyv.sptccc.agile.common.constant;
*
* @author admin
*/
-public class Constants {
+public class ServiceConstant {
/**
* 门户文件上传 - 文件来源
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessStatus.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessStatus.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessStatus.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessStatus.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessType.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessType.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessType.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/BusinessType.java
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/enums/ContentShowType.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/ContentShowType.java
similarity index 100%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/enums/ContentShowType.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/ContentShowType.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/DataStatusEnum.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/DataStatusEnum.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/DataStatusEnum.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/DataStatusEnum.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/DockerFileReviewStatus.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/DockerFileReviewStatus.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/DockerFileReviewStatus.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/DockerFileReviewStatus.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/FileTypeEnum.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/FileTypeEnum.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/FileTypeEnum.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/FileTypeEnum.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/LabStatusEnum.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/LabStatusEnum.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/LabStatusEnum.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/LabStatusEnum.java
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/OperatorType.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/OperatorType.java
similarity index 100%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/enums/OperatorType.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/OperatorType.java
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/enums/UserStatus.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/UserStatus.java
similarity index 100%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/enums/UserStatus.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/enums/UserStatus.java
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/exception/ServiceException.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/exception/ServiceException.java
similarity index 93%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/exception/ServiceException.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/exception/ServiceException.java
index d1f6fdfc..8e664c8b 100644
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/exception/ServiceException.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/exception/ServiceException.java
@@ -20,8 +20,6 @@ public final class ServiceException extends RuntimeException {
/**
* 错误明细,内部调试错误
- *
- * 和 {@link CommonResult#getDetailMessage()} 一致的设计
*/
private String detailMessage;
@@ -44,12 +42,13 @@ public final class ServiceException extends RuntimeException {
return detailMessage;
}
- public String getMessage() {
- return message;
+ public ServiceException setDetailMessage(String detailMessage) {
+ this.detailMessage = detailMessage;
+ return this;
}
- public Integer getCode() {
- return code;
+ public String getMessage() {
+ return message;
}
public ServiceException setMessage(String message) {
@@ -57,8 +56,7 @@ public final class ServiceException extends RuntimeException {
return this;
}
- public ServiceException setDetailMessage(String detailMessage) {
- this.detailMessage = detailMessage;
- return this;
+ public Integer getCode() {
+ return code;
}
}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ip/IpUtils.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/IpUtils.java
similarity index 77%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ip/IpUtils.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/IpUtils.java
index 10461447..ab596ace 100644
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ip/IpUtils.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/IpUtils.java
@@ -1,10 +1,14 @@
-package com.jiuyv.sptccc.agile.common.utils.ip;
-
-import java.net.InetAddress;
-import java.net.UnknownHostException;
-import javax.servlet.http.HttpServletRequest;
+package com.jiuyv.sptccc.agile.common.utils;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.client.RestTemplate;
+
+import javax.servlet.http.HttpServletRequest;
/**
* 获取IP方法
@@ -12,6 +16,36 @@ import org.apache.commons.lang3.StringUtils;
* @author admin
*/
public class IpUtils {
+ // IP地址查询
+ public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
+ // 未知地址
+ public static final String UNKNOWN = "XX XX";
+ private static final Logger LOGGER = LoggerFactory.getLogger(IpUtils.class);
+ private static final RestTemplate restTemplate = new RestTemplate();
+ private static final ObjectMapper objectMapper = new ObjectMapper();
+
+ public static String getRealAddressByIP(String ip, boolean isAddressEnabled) {
+ // 内网不查询
+ if (IpUtils.internalIp(ip)) {
+ return "内网IP";
+ }
+ if (isAddressEnabled) {
+ String rspStr = restTemplate.getForEntity(IP_URL + "?ip=" + ip + "&json=true", String.class).getBody();
+ if (StringUtils.isBlank(rspStr)) {
+ LOGGER.error("获取地理位置异常 {}", ip);
+ return UNKNOWN;
+ }
+ try {
+ JsonNode obj = objectMapper.readTree(rspStr);
+ return obj == null ? UNKNOWN : (obj.get("pro").asText() + " " + obj.get("city").asText());
+ } catch (JsonProcessingException e) {
+ LOGGER.error("获取地理位置异常 {}", ip);
+ return UNKNOWN;
+ }
+ }
+ return UNKNOWN;
+ }
+
/**
* 获取客户端IP
*
@@ -64,9 +98,6 @@ public class IpUtils {
* @return 结果
*/
private static boolean internalIp(byte[] addr) {
- if (addr == null || addr.length < 2) {
- return true;
- }
final byte b0 = addr[0];
final byte b1 = addr[1];
// 10.x.x.x/8
@@ -82,15 +113,9 @@ public class IpUtils {
case SECTION_1:
return true;
case SECTION_2:
- if (b1 >= SECTION_3 && b1 <= SECTION_4) {
- return true;
- }
- return false;
+ return b1 >= SECTION_3 && b1 <= SECTION_4;
case SECTION_5:
- if (b1 == SECTION_6) {
- return true;
- }
- return false;
+ return b1 == SECTION_6;
default:
return false;
}
@@ -103,7 +128,7 @@ public class IpUtils {
* @return byte 字节
*/
public static byte[] textToNumericFormatV4(String text) {
- if (org.apache.commons.lang3.StringUtils.isBlank(text)) {
+ if (StringUtils.isBlank(text)) {
return null;
}
@@ -170,32 +195,6 @@ public class IpUtils {
return bytes;
}
- /**
- * 获取IP地址
- *
- * @return 本地IP地址
- */
- public static String getHostIp() {
- try {
- return InetAddress.getLocalHost().getHostAddress();
- } catch (UnknownHostException e) {
- }
- return "127.0.0.1";
- }
-
- /**
- * 获取主机名
- *
- * @return 本地主机名
- */
- public static String getHostName() {
- try {
- return InetAddress.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
- }
- return "未知";
- }
-
/**
* 从多级反向代理中获得第一个非unknown IP地址
*
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ServletUtils.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/ServletUtils.java
similarity index 77%
rename from agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ServletUtils.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/ServletUtils.java
index c797a379..765a5518 100644
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ServletUtils.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/ServletUtils.java
@@ -1,12 +1,13 @@
package com.jiuyv.sptccc.agile.common.utils;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpSession;
-
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
/**
* 客户端工具类
*
@@ -24,6 +25,15 @@ public class ServletUtils {
}
+ /**
+ * 获取response
+ */
+ public static HttpServletResponse getResponse() {
+ ServletRequestAttributes requestAttributes = getRequestAttributes();
+ assert requestAttributes != null;
+ return requestAttributes.getResponse();
+ }
+
public static ServletRequestAttributes getRequestAttributes() {
RequestAttributes attributes = RequestContextHolder.getRequestAttributes();
return (ServletRequestAttributes) attributes;
diff --git a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java
similarity index 66%
rename from agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java
rename to agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java
index f51567ed..877d6366 100644
--- a/agile-portal/agile-portal-service/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java
@@ -1,15 +1,17 @@
package com.jiuyv.sptccc.agile.common.utils;
-
import org.apache.commons.lang3.StringUtils;
+import java.security.SecureRandom;
import java.util.UUID;
/**
* 字符串工具类
*
+ * @author admin
*/
public class StringUtil {
+ private static final SecureRandom random = new SecureRandom();
/**
* 空字符串
*/
@@ -57,34 +59,6 @@ public class StringUtil {
return str.substring(start, end);
}
- /**
- * 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
- *
- * @param s 原始字符串
- * @param size 字符串指定长度
- * @param c 使用的字符
- * @return 返回指定长度的字符串。
- */
- public static String align(final String s, final int size, final char c) {
- final StringBuilder sb = new StringBuilder(size);
- if (s != null) {
- final int len = s.length();
- if (s.length() <= size) {
- for (int i = size - len; i > 0; i--) {
- sb.append(c);
- }
- sb.append(s);
- } else {
- return s.substring(len - size, len);
- }
- } else {
- for (int i = size; i > 0; i--) {
- sb.append(c);
- }
- }
- return sb.toString();
- }
-
public static String getFileExtension(String fileName) {
if (StringUtils.isBlank(fileName)) {
return BLANK_STR;
@@ -107,10 +81,40 @@ public class StringUtil {
/**
* 获取RecToken
- * @return
+ *
*/
public static String getRecToken() {
return getSimpleUUID().substring(0, 10);
}
+
+ /**
+ * 敏感数据脱敏
+ *
+ */
+ public static String strHide(String str) {
+ if (str == null || str.length() <= 2) {
+ return str;
+ }
+ if (str.length() <= 7) {
+ return str.substring(0, 2) + "***";
+ }
+ return str.substring(0, 3) + "****" + str.substring(str.length() - 4);
+ }
+
+ /**
+ * 指定长度的字符串,比如给手机验证码
+ *
+ */
+ public static String randomNumber(int length) {
+ if (length < 4) {
+ length = 4;
+ }
+ StringBuilder bld = new StringBuilder();
+ for (int i = 0; i < length; i++) {
+ bld.append(random.nextInt(10));
+ }
+ return bld.toString();
+ }
+
}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/domain/TableDataPage.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/domain/TableDataPage.java
index f06c3c68..4d5c74b4 100644
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/domain/TableDataPage.java
+++ b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/domain/TableDataPage.java
@@ -10,7 +10,7 @@ import java.util.List;
*/
public class TableDataPage implements Serializable {
private static final long serialVersionUID = 1L;
- private int total;
+ private Integer total;
private List rows;
private Integer code;
private String msg;
@@ -18,16 +18,16 @@ public class TableDataPage implements Serializable {
public TableDataPage() {
}
- public TableDataPage(List list, int total) {
+ public TableDataPage(List list, Integer total) {
this.rows = list;
this.total = total;
}
- public int getTotal() {
+ public Integer getTotal() {
return this.total;
}
- public void setTotal(int total) {
+ public void setTotal(Integer total) {
this.total = total;
}
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DataApiDTO.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DataApiDTO.java
deleted file mode 100644
index 42982f85..00000000
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DataApiDTO.java
+++ /dev/null
@@ -1,116 +0,0 @@
-package com.jiuyv.sptccc.agile.dto;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-import java.io.Serializable;
-import java.util.Date;
-
-public class DataApiDTO implements Serializable {
- private static final long serialVersionUID = 1L;
-
- /**
- * 机构号
- */
- private String orgNo;
-
- /**
- * 机构名称
- */
- private String orgName;
-
- /**
- * 接口id
- */
- private Long apiId;
-
- /**
- * 接口名称
- */
- private String apiName;
-
- /**
- * 接口描述
- */
- private String remark;
-
- /**
- * 更新时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date updateTime;
-
- /**
- * 生效时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date dataBegin;
- /**
- * 结束时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date dataEnd;
-
- public String getOrgNo() {
- return orgNo;
- }
-
- public void setOrgNo(String orgNo) {
- this.orgNo = orgNo;
- }
-
- public String getOrgName() {
- return orgName;
- }
-
- public void setOrgName(String orgName) {
- this.orgName = orgName;
- }
-
- public Long getApiId() {
- return apiId;
- }
-
- public void setApiId(Long apiId) {
- this.apiId = apiId;
- }
-
- public String getApiName() {
- return apiName;
- }
-
- public void setApiName(String apiName) {
- this.apiName = apiName;
- }
-
- public String getRemark() {
- return remark;
- }
-
- public void setRemark(String remark) {
- this.remark = remark;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-
- public Date getDataBegin() {
- return dataBegin;
- }
-
- public void setDataBegin(Date dataBegin) {
- this.dataBegin = dataBegin;
- }
-
- public Date getDataEnd() {
- return dataEnd;
- }
-
- public void setDataEnd(Date dataEnd) {
- this.dataEnd = dataEnd;
- }
-}
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DataApiStatisticsDTO.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DataApiStatisticsDTO.java
deleted file mode 100644
index b8cf9fad..00000000
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DataApiStatisticsDTO.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package com.jiuyv.sptccc.agile.dto;
-
-import java.io.Serializable;
-import java.util.Date;
-
-public class DataApiStatisticsDTO implements Serializable {
- private static final long serialVersionUID = 1L;
- /**
- *
- */
- private Object id;
-
- /**
- * 机构号
- */
- private String orgNo;
-
- /**
- * 机构名称
- */
- private String orgName;
-
- /**
- * API ID
- */
- private Object apiId;
-
- /**
- * 接口名称
- */
- private String apiName;
-
- /**
- * 成功次数
- */
- private Object successTotal;
-
- /**
- * 失败次数
- */
- private Integer failTotal;
-
- /**
- * 更新时间
- */
- private Date updateTime;
-
- public Object getId() {
- return id;
- }
-
- public void setId(Object id) {
- this.id = id;
- }
-
- public String getOrgNo() {
- return orgNo;
- }
-
- public void setOrgNo(String orgNo) {
- this.orgNo = orgNo;
- }
-
- public String getOrgName() {
- return orgName;
- }
-
- public void setOrgName(String orgName) {
- this.orgName = orgName;
- }
-
- public Object getApiId() {
- return apiId;
- }
-
- public void setApiId(Object apiId) {
- this.apiId = apiId;
- }
-
- public Object getSuccessTotal() {
- return successTotal;
- }
-
- public void setSuccessTotal(Object successTotal) {
- this.successTotal = successTotal;
- }
-
- public Integer getFailTotal() {
- return failTotal;
- }
-
- public void setFailTotal(Integer failTotal) {
- this.failTotal = failTotal;
- }
-
- public String getApiName() {
- return apiName;
- }
-
- public void setApiName(String apiName) {
- this.apiName = apiName;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-}
diff --git a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DockerApplyInfoDTO.java b/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DockerApplyInfoDTO.java
deleted file mode 100644
index 3e5d06f1..00000000
--- a/agile-portal/agile-portal-api/src/main/java/com/jiuyv/sptccc/agile/dto/DockerApplyInfoDTO.java
+++ /dev/null
@@ -1,297 +0,0 @@
-package com.jiuyv.sptccc.agile.dto;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.List;
-
-/**
- * 实验室数据上传申请
- */
-public class DockerApplyInfoDTO implements Serializable {
- private static final long serialVersionUID = 1L;
- /**
- * 申请主键id
- */
- private Long applyId;
-
- /**
- * 随机码
- */
- private String recToken;
-
- /**
- * 服务器id
- */
- private Long dockerServerId;
-
- /**
- * 申请用户id
- */
- private String applyUserId;
-
- /**
- * 申请用户
- */
- private String applyUserName;
-
- /**
- * 申请原因
- */
- private String applyDesc;
-
- /**
- * 实验室名称
- */
- private String labTitle;
-
- /**
- * 服务类型
- */
- private String serviceType;
-
- /**
- * 使用镜像
- */
- private String dockerImageName;
-
- /**
- * 申请时效
- */
- private String usageTime;
-
- /**
- * 时间单位
- */
- private String usageTimeUnit;
-
- /**
- * 开始时间
- */
- private Date startDate;
-
- /**
- * 结束时间
- */
- private Date endDate;
-
- /**
- * 延期次数
- */
- private String delayTimes;
-
- /**
- * cpu数量
- */
- private String cpuLimits;
-
- /**
- * cpu序号
- */
- private String cpuSeq;
-
- /**
- * 内存大小
- */
- private String memoryLimits;
-
- /**
- * 磁盘大小
- */
- private String discLimits;
-
- /**
- * 备注
- */
- private String remarks;
-
- /**
- * 审核状态
- */
- private String reviewStatus;
-
- /**
- * 驳回原因
- */
- private String reviewDesc;
-
- /**
- * 申请组件
- */
- private List applyLibList;
-
- public Long getApplyId() {
- return applyId;
- }
-
- public void setApplyId(Long applyId) {
- this.applyId = applyId;
- }
-
- public String getRecToken() {
- return recToken;
- }
-
- public void setRecToken(String recToken) {
- this.recToken = recToken;
- }
-
- public Long getDockerServerId() {
- return dockerServerId;
- }
-
- public void setDockerServerId(Long dockerServerId) {
- this.dockerServerId = dockerServerId;
- }
-
- public String getApplyUserId() {
- return applyUserId;
- }
-
- public void setApplyUserId(String applyUserId) {
- this.applyUserId = applyUserId;
- }
-
- public String getApplyUserName() {
- return applyUserName;
- }
-
- public void setApplyUserName(String applyUserName) {
- this.applyUserName = applyUserName;
- }
-
- public String getApplyDesc() {
- return applyDesc;
- }
-
- public void setApplyDesc(String applyDesc) {
- this.applyDesc = applyDesc;
- }
-
- public String getLabTitle() {
- return labTitle;
- }
-
- public void setLabTitle(String labTitle) {
- this.labTitle = labTitle;
- }
-
- public String getServiceType() {
- return serviceType;
- }
-
- public void setServiceType(String serviceType) {
- this.serviceType = serviceType;
- }
-
- public String getDockerImageName() {
- return dockerImageName;
- }
-
- public void setDockerImageName(String dockerImageName) {
- this.dockerImageName = dockerImageName;
- }
-
- public String getUsageTime() {
- return usageTime;
- }
-
- public void setUsageTime(String usageTime) {
- this.usageTime = usageTime;
- }
-
- public String getUsageTimeUnit() {
- return usageTimeUnit;
- }
-
- public void setUsageTimeUnit(String usageTimeUnit) {
- this.usageTimeUnit = usageTimeUnit;
- }
-
- public Date getStartDate() {
- return startDate;
- }
-
- public void setStartDate(Date startDate) {
- this.startDate = startDate;
- }
-
- public Date getEndDate() {
- return endDate;
- }
-
- public void setEndDate(Date endDate) {
- this.endDate = endDate;
- }
-
- public String getDelayTimes() {
- return delayTimes;
- }
-
- public void setDelayTimes(String delayTimes) {
- this.delayTimes = delayTimes;
- }
-
- public String getCpuLimits() {
- return cpuLimits;
- }
-
- public void setCpuLimits(String cpuLimits) {
- this.cpuLimits = cpuLimits;
- }
-
- public String getCpuSeq() {
- return cpuSeq;
- }
-
- public void setCpuSeq(String cpuSeq) {
- this.cpuSeq = cpuSeq;
- }
-
- public String getMemoryLimits() {
- return memoryLimits;
- }
-
- public void setMemoryLimits(String memoryLimits) {
- this.memoryLimits = memoryLimits;
- }
-
- public String getDiscLimits() {
- return discLimits;
- }
-
- public void setDiscLimits(String discLimits) {
- this.discLimits = discLimits;
- }
-
- public String getRemarks() {
- return remarks;
- }
-
- public void setRemarks(String remarks) {
- this.remarks = remarks;
- }
-
- public String getReviewStatus() {
- return reviewStatus;
- }
-
- public void setReviewStatus(String reviewStatus) {
- this.reviewStatus = reviewStatus;
- }
-
- public String getReviewDesc() {
- return reviewDesc;
- }
-
- public void setReviewDesc(String reviewDesc) {
- this.reviewDesc = reviewDesc;
- }
-
- public List getApplyLibList() {
- return applyLibList;
- }
-
- public void setApplyLibList(List applyLibList) {
- this.applyLibList = applyLibList;
- }
-}
diff --git a/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/IpUtilsTest.java b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/IpUtilsTest.java
new file mode 100644
index 00000000..752abaa5
--- /dev/null
+++ b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/IpUtilsTest.java
@@ -0,0 +1,113 @@
+package com.jiuyv.sptccc.agile.common.utils;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+import javax.servlet.http.HttpServletRequest;
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+import static com.jiuyv.sptccc.agile.common.utils.IpUtils.UNKNOWN;
+import static org.junit.jupiter.api.Assertions.*;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * IpUtils单元测试
+ *
+ * @author ren_chao
+ */
+@ExtendWith(MockitoExtension.class)
+class IpUtilsTest {
+
+ @Mock
+ private RestTemplate restTemplate;
+
+ @Mock
+ private ObjectMapper objectMapper;
+
+ @Mock
+ private ResponseEntity response;
+
+ @BeforeEach
+ void setUp() throws ReflectiveOperationException {
+ Field modifier = Field.class.getDeclaredField("modifiers");
+ modifier.setAccessible(true);
+
+ Field restTemplateField = IpUtils.class.getDeclaredField("restTemplate");
+ restTemplateField.setAccessible(true);
+ modifier.setInt(restTemplateField, restTemplateField.getModifiers() & ~Modifier.FINAL);
+ restTemplateField.set(null, restTemplate);
+
+ Field objectMapperField = IpUtils.class.getDeclaredField("objectMapper");
+ objectMapperField.setAccessible(true);
+ modifier.setInt(objectMapperField, objectMapperField.getModifiers() & ~Modifier.FINAL);
+ objectMapperField.set(null, objectMapper);
+ }
+
+ @Test
+ void getRealAddressByIP() throws JsonProcessingException {
+ String json = "{}";
+ assertEquals("内网IP", IpUtils.getRealAddressByIP("192.168.0.1", true));
+
+ when(restTemplate.getForEntity(anyString(), eq(String.class))).thenReturn(response);
+ assertEquals(UNKNOWN, IpUtils.getRealAddressByIP("localhost", true));
+
+ when(response.getBody()).thenReturn(json);
+ assertEquals(UNKNOWN, IpUtils.getRealAddressByIP("localhost", true));
+
+ when(objectMapper.readTree(anyString())).thenThrow(JsonProcessingException.class);
+ assertEquals(UNKNOWN, IpUtils.getRealAddressByIP("localhost", true));
+
+ assertEquals("内网IP", IpUtils.getRealAddressByIP("10.0.0.1", false));
+ assertEquals("内网IP", IpUtils.getRealAddressByIP("172.16.0.1", false));
+ assertEquals(UNKNOWN, IpUtils.getRealAddressByIP("1", false));
+
+ }
+
+ @Test
+ void getIpAddr() {
+ assertEquals("unknown", IpUtils.getIpAddr(null));
+
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ assertNull(IpUtils.getIpAddr(request));
+ }
+
+ @Test
+ void textToNumericFormatV4() {
+ try {
+ IpUtils.textToNumericFormatV4("127");
+ IpUtils.textToNumericFormatV4("127.0");
+ IpUtils.textToNumericFormatV4("127.0.0");
+ IpUtils.textToNumericFormatV4("127.0.0.1");
+ IpUtils.textToNumericFormatV4("127.0.0.1.1");
+
+ IpUtils.textToNumericFormatV4("-1");
+ IpUtils.textToNumericFormatV4("-1.0");
+ IpUtils.textToNumericFormatV4("-1.0.0");
+ IpUtils.textToNumericFormatV4("-1.0.0.1");
+
+ IpUtils.textToNumericFormatV4("127.-1");
+ IpUtils.textToNumericFormatV4("127.0.-1");
+ IpUtils.textToNumericFormatV4("");
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ @Test
+ void getMultistageReverseProxyIp() {
+ String ip = "127.0.0.1,localhost";
+ assertEquals("127.0.0.1", IpUtils.getMultistageReverseProxyIp(ip));
+ }
+
+}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/ServletUtilsTest.java b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/ServletUtilsTest.java
new file mode 100644
index 00000000..249214a4
--- /dev/null
+++ b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/ServletUtilsTest.java
@@ -0,0 +1,71 @@
+package com.jiuyv.sptccc.agile.common.utils;
+
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.MockedStatic;
+import org.mockito.junit.jupiter.MockitoExtension;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpSession;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.mockito.Mockito.when;
+
+/**
+ * ServletUtils单元测试
+ *
+ * @author ren_chao
+ */
+@ExtendWith(MockitoExtension.class)
+class ServletUtilsTest {
+ @Mock
+ private MockedStatic mockStatic;
+ @Mock
+ private ServletRequestAttributes attributes;
+ @Mock
+ private HttpServletRequest request;
+ @Mock
+ private HttpServletResponse response;
+ @Mock
+ private HttpSession session;
+
+ @BeforeEach
+ void setUp() {
+ mockStatic.when(RequestContextHolder::getRequestAttributes).thenReturn(attributes);
+ }
+
+ @AfterEach
+ void tearDown() {
+ mockStatic.close();
+ }
+
+ @Test
+ void getRequest() {
+ when(attributes.getRequest()).thenReturn(request);
+ assertEquals(request, ServletUtils.getRequest());
+ }
+
+ @Test
+ void getResponse() {
+ when(attributes.getResponse()).thenReturn(response);
+ assertEquals(response, ServletUtils.getResponse());
+ }
+
+ @Test
+ void getRequestAttributes() {
+ assertEquals(attributes, ServletUtils.getRequestAttributes());
+ }
+
+ @Test
+ void getSession() {
+ when(attributes.getRequest()).thenReturn(request);
+ when(request.getSession()).thenReturn(session);
+ assertEquals(session, ServletUtils.getSession());
+ }
+}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/StringUtilTest.java b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/StringUtilTest.java
new file mode 100644
index 00000000..b8af3eb9
--- /dev/null
+++ b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/common/utils/StringUtilTest.java
@@ -0,0 +1,48 @@
+package com.jiuyv.sptccc.agile.common.utils;
+
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * StringUtil单元测试
+ *
+ * @author ren_chao
+ */
+class StringUtilTest {
+
+ @Test
+ void substring() {
+ String str = "testSubstring";
+ assertEquals("", StringUtil.substring(str, -1, -1));
+ assertEquals("g", StringUtil.substring(str, -1, 20));
+ assertEquals("", StringUtil.substring(str, 1, 0));
+ assertEquals("", StringUtil.substring(str, -20, -20));
+ assertEquals("", StringUtil.substring(null, 0, 0));
+ }
+
+ @Test
+ void getFileExtension() {
+ assertEquals("", StringUtil.getFileExtension(""));
+ assertEquals("", StringUtil.getFileExtension("a"));
+ assertEquals("txt", StringUtil.getFileExtension("a.txt"));
+ }
+
+ @Test
+ void getRecToken() {
+ assertEquals(10, StringUtil.getRecToken().length());
+ }
+
+ @Test
+ void strHide() {
+ assertEquals("1", StringUtil.strHide("1"));
+ assertEquals("13***", StringUtil.strHide("1333333"));
+ assertEquals("133****3333", StringUtil.strHide("13333333"));
+ }
+
+ @Test
+ void randomNumber() {
+ assertEquals(4, StringUtil.randomNumber(2).length());
+ }
+
+}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/domain/TblDomainTest.java b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/domain/TblDomainTest.java
new file mode 100644
index 00000000..53c5840f
--- /dev/null
+++ b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/domain/TblDomainTest.java
@@ -0,0 +1,56 @@
+package com.jiuyv.sptccc.agile.domain;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * Domain测试类
+ *
+ * @author ren_chao
+ */
+@ExtendWith(MockitoExtension.class)
+class TblDomainTest {
+
+ @Test
+ void domainTest() {
+ String packageName = "com.jiuyv.sptccc.agile.domain";
+ try {
+ invoke(packageName);
+ } catch (Exception e) {
+ Assertions.fail();
+ }
+ }
+
+ private void invoke(String packageName) throws InstantiationException, IllegalAccessException, InvocationTargetException {
+ List> classList = ReflectionUtils.findAllClassesInPackage(packageName, aClass -> true, s -> !s.endsWith("Test"));
+
+ for (Class> aClass : classList) {
+ Method[] methods = aClass.getDeclaredMethods();
+ Object o = aClass.newInstance();
+ for (Method method : methods) {
+ String name = method.getName();
+ if (name.startsWith("get")) {
+ method.invoke(o);
+ } else if (name.startsWith("set")) {
+ Class>[] parameterTypes = method.getParameterTypes();
+ Object[] objects = Arrays.stream(parameterTypes).map(p -> {
+ try {
+ return p.newInstance();
+ } catch (ReflectiveOperationException e) {
+ return null;
+ }
+ }).toArray();
+ method.invoke(o, objects);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/dto/PortalDTOTest.java b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/dto/PortalDTOTest.java
new file mode 100644
index 00000000..39a1c271
--- /dev/null
+++ b/agile-portal/agile-portal-api/src/test/java/com/jiuyv/sptccc/agile/dto/PortalDTOTest.java
@@ -0,0 +1,57 @@
+package com.jiuyv.sptccc.agile.dto;
+
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.junit.platform.commons.util.ReflectionUtils;
+import org.mockito.junit.jupiter.MockitoExtension;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.List;
+
+/**
+ * DTO测试类
+ *
+ * @author ren_chao
+ */
+@ExtendWith(MockitoExtension.class)
+class PortalDTOTest {
+
+ @Test
+ void dtoTest() {
+ String packageName = "com.jiuyv.sptccc.agile.dto";
+ try {
+ invoke(packageName);
+ } catch (Exception e) {
+ Assertions.fail();
+ }
+ }
+
+ private void invoke(String packageName) throws InstantiationException, IllegalAccessException, InvocationTargetException {
+ List> classList = ReflectionUtils.findAllClassesInPackage(packageName, aClass -> true, s -> !s.endsWith("Test"));
+
+ for (Class> aClass : classList) {
+ Method[] methods = aClass.getDeclaredMethods();
+ Object o = aClass.newInstance();
+ for (Method method : methods) {
+ String name = method.getName();
+ if (name.startsWith("get")) {
+ method.invoke(o);
+ } else if (name.startsWith("set")) {
+ Class>[] parameterTypes = method.getParameterTypes();
+ Object[] objects = Arrays.stream(parameterTypes).map(p -> {
+ try {
+ return p.newInstance();
+ } catch (ReflectiveOperationException e) {
+ return null;
+ }
+ }).toArray();
+ method.invoke(o, objects);
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-gateway/pom.xml b/agile-portal/agile-portal-gateway/pom.xml
index a189c41e..06d88be6 100644
--- a/agile-portal/agile-portal-gateway/pom.xml
+++ b/agile-portal/agile-portal-gateway/pom.xml
@@ -3,7 +3,7 @@
com.jiuyv.sptcc.agile
agile-portal
- 0.0.5-SNAPSHOT
+ 0.2.4-SNAPSHOT
agile-portal-gateway
@@ -85,6 +85,11 @@
commons-lang3
+
+ commons-codec
+ commons-codec
+
+
org.springframework.boot
spring-boot-configuration-processor
@@ -114,14 +119,7 @@
io.micrometer
micrometer-registry-prometheus
-
- org.springframework.cloud
- spring-cloud-starter-config
-
-
- org.springframework.cloud
- spring-cloud-starter-bootstrap
-
+
org.springframework.cloud
spring-cloud-starter-sleuth
@@ -141,10 +139,42 @@
feign-okhttp
+
+ org.springframework.boot
+ spring-boot-starter-test
+ test
+
+
+
+ org.mockito
+ mockito-inline
+ test
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+ 0.8.10
+
+
+ default-prepare-agent
+
+ prepare-agent
+
+
+
+ default-report
+ prepare-package
+
+ report
+
+
+
+
org.apache.maven.plugins
maven-deploy-plugin
@@ -186,7 +216,7 @@
- src/main/resources/public
+ src/main/resources/view
@@ -203,7 +233,7 @@
copy-resources
- src/main/resources/public
+ src/main/resources/view
true
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/PortalGatewayApplication.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/PortalGatewayApplication.java
index 84dd04c1..fa73fba3 100644
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/PortalGatewayApplication.java
+++ b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/PortalGatewayApplication.java
@@ -7,7 +7,6 @@ import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.cache.annotation.EnableCaching;
-import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
/**
@@ -16,7 +15,6 @@ import org.springframework.cloud.openfeign.EnableFeignClients;
* @author admin
*/
@EnableFeignClients
-@EnableDiscoveryClient
@EnableCaching
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class PortalGatewayApplication {
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/SensitiveData.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/SensitiveData.java
deleted file mode 100644
index 59ed30cd..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/annotation/SensitiveData.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jiuyv.sptccc.agile.common.annotation;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-
-/**
- * 日志对敏感字段处理为*(不是过滤,方便确认有没有值)
- * 一些固定字段强制处理了,就不需要注解,如password
- *
- * @author zhouliang
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.FIELD)
-public @interface SensitiveData {
- char defaultMark() default '*';//默认使用*
-
- int firstLength() default 3;//保留前三位
-
- int endLength() default 3;//保留后三位
-}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/config/WebConfig.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/config/WebConfig.java
deleted file mode 100644
index faa3a7a6..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/config/WebConfig.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jiuyv.sptccc.agile.common.config;
-
-import org.springframework.boot.web.servlet.ServletContextInitializer;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-
-@Configuration
-public class WebConfig {
-
- /**
- * 设置JSESSIONID的Path为"/"
- *
- */
- @Bean
- public ServletContextInitializer servletContextInitializer() {
- return servletContext -> servletContext.getSessionCookieConfig().setPath("/");
- }
-}
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/core/domain/BaseEntity.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/core/domain/BaseEntity.java
deleted file mode 100644
index 0834dac2..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/core/domain/BaseEntity.java
+++ /dev/null
@@ -1,152 +0,0 @@
-package com.jiuyv.sptccc.agile.common.core.domain;
-
-import java.io.Serializable;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
-
-import com.fasterxml.jackson.annotation.JsonFormat;
-
-/**
- * Entity基类
- *
- * @author admin
- */
-public class BaseEntity implements Serializable {
- private static final long serialVersionUID = 1L;
-
- /**
- * 创建者姓名
- */
- private String createByName;
-
- /**
- * 创建时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date createTime;
-
- /**
- * 创建者id(或账户)
- */
- private String createBy;
-
- /**
- * 更新者姓名
- */
- private String updateByName;
-
- /**
- * 更新者id(或账户)
- */
- private String updateBy;
-
- /**
- * 更新时间
- */
- @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
- private Date updateTime;
-
- /**
- * 搜索值
- */
- private String searchValue;
-
- /**
- * 备注
- */
- private String remark;
-
- /**
- * 请求参数
- */
- private Map params;
-
- /**
- * @return the createByName
- */
- public String getCreateByName() {
- return createByName;
- }
-
- /**
- * @param createByName the createByName to set
- */
- public void setCreateByName(String createByName) {
- this.createByName = createByName;
- }
-
- /**
- * @return the updateByName
- */
- public String getUpdateByName() {
- return updateByName;
- }
-
- /**
- * @param updateByName the updateByName to set
- */
- public void setUpdateByName(String updateByName) {
- this.updateByName = updateByName;
- }
-
- public String getSearchValue() {
- return searchValue == null ? "" : searchValue;
- }
-
- public void setSearchValue(String searchValue) {
- this.searchValue = searchValue;
- }
-
- public String getCreateBy() {
- return createBy == null ? "" : createBy;
- }
-
- public void setCreateBy(String createBy) {
- this.createBy = createBy;
- }
-
- public Date getCreateTime() {
- return createTime;
- }
-
- public void setCreateTime(Date createTime) {
- this.createTime = createTime;
- }
-
- public String getUpdateBy() {
- return updateBy == null ? "" : updateBy;
- }
-
- public void setUpdateBy(String updateBy) {
- this.updateBy = updateBy;
- }
-
- public Date getUpdateTime() {
- return updateTime;
- }
-
- public void setUpdateTime(Date updateTime) {
- this.updateTime = updateTime;
- }
-
- public String getRemark() {
- return remark == null ? "" : remark;
- }
-
- public void setRemark(String remark) {
- this.remark = remark;
- }
-
- public Map getParams() {
- if (params == null) {
- params = new HashMap<>();
- }
- return params;
- }
-
- public void setParams(Map params) {
- this.params = params;
- }
-
-}
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/enums/HttpMethod.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/enums/HttpMethod.java
deleted file mode 100644
index 3e9a170e..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/enums/HttpMethod.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.jiuyv.sptccc.agile.common.enums;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.springframework.lang.Nullable;
-
-/**
- * 请求方式
- *
- * @author admin
- */
-public enum HttpMethod {
- GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS, TRACE;
-
- private static final Map mappings = new HashMap<>(16);
-
- static {
- for (HttpMethod httpMethod : values()) {
- mappings.put(httpMethod.name(), httpMethod);
- }
- }
-
- @Nullable
- public static HttpMethod resolve(@Nullable String method) {
- return (method != null ? mappings.get(method) : null);
- }
-
- public boolean matches(String method) {
- return (this == resolve(method));
- }
-}
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/JsonUtil.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/JsonUtil.java
deleted file mode 100644
index f3dcce95..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/JsonUtil.java
+++ /dev/null
@@ -1,273 +0,0 @@
-package com.jiuyv.sptccc.agile.common.utils;
-
-import java.io.IOException;
-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;
-import com.fasterxml.jackson.core.JsonGenerator.Feature;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.introspect.Annotated;
-import com.fasterxml.jackson.databind.introspect.JacksonAnnotationIntrospector;
-import com.fasterxml.jackson.databind.node.ArrayNode;
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.jiuyv.sptccc.agile.common.annotation.SensitiveData;
-import com.jiuyv.sptccc.agile.common.utils.jackson.MaskSensitiveDataSerializerProvider;
-
-/**
- * @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();
- //专门使用一个独立的,处理敏感字段等
- private static ObjectMapper objectMapper2 = 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"));
-
-
- objectMapper2.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
- objectMapper2.setSerializationInclusion(Include.NON_NULL);
- objectMapper2.configure(Feature.WRITE_BIGDECIMAL_AS_PLAIN, true);
- objectMapper2.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
- // 启用自定义注解功能
- objectMapper2.setAnnotationIntrospector(new JsonUtil.SensitiveDataIntrospector());
- objectMapper2.setSerializerProvider(new MaskSensitiveDataSerializerProvider());
- }
-
- public static ObjectMapper JsonMapper() {
- return objectMapper;
- }
-
- public static ObjectMapper JsonMapper2() {
- return objectMapper2;
- }
-
- /**
- * 通过注解处理敏感字段,自行在需要的注入
- *
- * @author zhouliang
- */
- public static class SensitiveDataIntrospector extends JacksonAnnotationIntrospector {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Object findSerializer(Annotated annotated) {
- if (annotated.hasAnnotation(SensitiveData.class)) {
- SensitiveData sensitiveDataProperty = annotated.getAnnotation(SensitiveData.class);
- return new JsonSerializer() {
- @Override
- public void serialize(String value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- if (value != null) {
- String val = StringUtil.padl("", 6, sensitiveDataProperty.defaultMark());
- //大于允许截取
- if (value.length() * 2 / 3 >= (sensitiveDataProperty.firstLength() + sensitiveDataProperty.endLength())) {
- gen.writeString(value.substring(0, sensitiveDataProperty.firstLength()) + val + value.substring(value.length() - sensitiveDataProperty.endLength()));
- } else {
- gen.writeString(val);
- }
- }
- }
- };
- }
- return super.findSerializer(annotated);
- }
- }
-
-
- /**
- * 转为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;
- }
- }
-
- /**
- * 创建ArrayNode
- *
- * @param json
- * @return
- */
- public static ArrayNode createArray() {
- return objectMapper.createArrayNode();
- }
-
- /**
- * 创建ObjectNode
- *
- * @param json
- * @return
- */
- public static ObjectNode createObject() {
- return objectMapper.createObjectNode();
- }
-
- /**
- * 集合实体对象转ArrayNode
- *
- * @param json
- * @return
- */
- public static ArrayNode toArray(Object obj) {
- try {
- return objectMapper.valueToTree(obj);
- } catch (Exception e) {
- LOGGER.error("convert failed", e);
- return createArray();
- }
- }
-
- /**
- * 实体对象转ObjectNode
- *
- * @param json
- * @return
- */
- public static ObjectNode toObject(Object obj) {
- try {
- return objectMapper.valueToTree(obj);
- } catch (Exception e) {
- LOGGER.error("convert failed", e);
- return createObject();
- }
- }
-
- /**
- * 拷贝对象
- * 主要还是是用于Node拷贝
- */
- public static void copyProperties(K source, V target) {
- try {
- objectMapper.updateValue(target, source);
- } catch (Exception e) {
- LOGGER.error("convert failed", e);
- }
- }
-}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java
deleted file mode 100644
index 83db310d..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/StringUtil.java
+++ /dev/null
@@ -1,126 +0,0 @@
-package com.jiuyv.sptccc.agile.common.utils;
-
-import java.io.UnsupportedEncodingException;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
-import java.util.List;
-import java.util.Random;
-
-import com.jiuyv.sptccc.agile.common.exception.ServiceException;
-import org.apache.commons.lang3.StringUtils;
-import org.springframework.util.AntPathMatcher;
-
-import org.springframework.util.CollectionUtils;
-
-/**
- * 字符串工具类
- *
- * @author admin
- */
-public class StringUtil {
- private static final Random random = new Random();
-
- /**
- * 查找指定字符串是否匹配指定字符串列表中的任意一个字符串
- *
- * @param str 指定字符串
- * @param strs 需要检查的字符串数组
- * @return 是否匹配
- */
- public static boolean matches(String str, List strs) {
- if (StringUtils.isBlank(str) || CollectionUtils.isEmpty(strs)) {
- return false;
- }
- for (String pattern : strs) {
- if (isMatch(pattern, str)) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * 判断url是否与规则配置:
- * ? 表示单个字符;
- * * 表示一层路径内的任意字符串,不可跨层级;
- * ** 表示任意层路径;
- *
- * @param pattern 匹配规则
- * @param url 需要匹配的url
- */
- public static boolean isMatch(String pattern, String url) {
- AntPathMatcher matcher = new AntPathMatcher();
- return matcher.match(pattern, url);
- }
-
- /**
- * 字符串左补齐。如果原始字符串s长度大于size,则只保留最后size个字符。
- *
- * @param s 原始字符串
- * @param size 字符串指定长度
- * @param c 用于补齐的字符
- * @return 返回指定长度的字符串,由原字符串左补齐或截取得到。
- */
- public static String padl(final String s, final int size, final char c) {
- final StringBuilder sb = new StringBuilder(size);
- if (s != null) {
- final int len = s.length();
- if (s.length() <= size) {
- for (int i = size - len; i > 0; i--) {
- sb.append(c);
- }
- sb.append(s);
- } else {
- return s.substring(len - size, len);
- }
- } else {
- for (int i = size; i > 0; i--) {
- sb.append(c);
- }
- }
- return sb.toString();
- }
-
-
- /**
- * 敏感数据脱敏
- *
- */
- public static String strHide(String str) {
- if (str == null || str.length() <= 2) {
- return str;
- }
- if (str.length() <= 7) {
- return str.substring(0, 2) + "***";
- }
- return str.substring(0, 3) + "****" + str.substring(str.length() - 4);
- }
-
- /**
- * 指定长度的字符串,比如给手机验证码
- *
- */
- public static String randomNumber(int length) {
- if (length < 4) {//最少4位
- length = 4;
- }
- StringBuilder bld = new StringBuilder();
- for (int i = 0; i < length; i++) {
- bld.append(random.nextInt(9)); //生成随机数
- }
- return bld.toString();
- }
-
- /**
- * 对文件名进行URL编码
- *
- */
- public static String encoderURL(String str) {
- try {
- return URLEncoder.encode(str, StandardCharsets.UTF_8.toString()).replace("+", "%20");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- throw new ServiceException("编码异常");
- }
- }
-}
\ No newline at end of file
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/Threads.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/Threads.java
deleted file mode 100644
index 3e97f973..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/Threads.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package com.jiuyv.sptccc.agile.common.utils;
-
-import java.util.concurrent.CancellationException;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * 线程相关工具类.
- *
- * @author admin
- */
-public class Threads {
- private static final Logger logger = LoggerFactory.getLogger(Threads.class);
-
- /**
- * sleep等待,单位为毫秒
- */
- public static void sleep(long milliseconds) {
- try {
- Thread.sleep(milliseconds);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- return;
- }
- }
-
- /**
- * 停止线程池 先使用shutdown, 停止接收新任务并尝试完成所有已存在任务. 如果超时, 则调用shutdownNow,
- * 取消在workQueue中Pending的任务,并中断所有阻塞函数. 如果仍然超時,則強制退出. 另对在shutdown时线程本身被调用中断做了处理.
- */
- public static void shutdownAndAwaitTermination(ExecutorService pool) {
- if (pool != null && !pool.isShutdown()) {
- pool.shutdown();
- try {
- if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
- pool.shutdownNow();
- if (!pool.awaitTermination(120, TimeUnit.SECONDS)) {
- logger.info("Pool did not terminate");
- }
- }
- } catch (InterruptedException ie) {
- pool.shutdownNow();
- Thread.currentThread().interrupt();
- }
- }
- }
-
- /**
- * 打印线程异常信息
- */
- public static void printException(Runnable r, Throwable t) {
- if (t == null && r instanceof Future>) {
- try {
- Future> future = (Future>) r;
- if (future.isDone()) {
- future.get();
- }
- } catch (CancellationException ce) {
- t = ce;
- } catch (ExecutionException ee) {
- t = ee.getCause();
- } catch (InterruptedException ie) {
- Thread.currentThread().interrupt();
- }
- }
- if (t != null) {
- logger.error(t.getMessage(), t);
- }
- }
-}
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ip/AddressUtils.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ip/AddressUtils.java
deleted file mode 100644
index 1affed59..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/ip/AddressUtils.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.jiuyv.sptccc.agile.common.utils.ip;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.jiuyv.sptccc.agile.common.config.ConsoleConfig;
-import com.jiuyv.sptccc.agile.common.utils.JsonUtil;
-import com.jiuyv.sptccc.agile.common.utils.SpringUtils;
-import org.apache.commons.lang3.StringUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.boot.web.client.RestTemplateBuilder;
-import org.springframework.web.client.RestTemplate;
-
-/**
- * 获取地址类
- *
- * @author admin
- */
-public class AddressUtils {
- // IP地址查询
- public static final String IP_URL = "http://whois.pconline.com.cn/ipJson.jsp";
- // 未知地址
- public static final String UNKNOWN = "XX XX";
- private static final Logger log = LoggerFactory.getLogger(AddressUtils.class);
- private static final ConsoleConfig consoleProperties;
- private static final RestTemplate restTemplate;
-
- static {
- consoleProperties = SpringUtils.getBean(ConsoleConfig.class);
- restTemplate = SpringUtils.getBean(RestTemplateBuilder.class).build();
- }
-
- public static String getRealAddressByIP(String ip) {
- // 内网不查询
- if (IpUtils.internalIp(ip)) {
- return "内网IP";
- }
- if (consoleProperties.isAddressEnabled()) {
- String rspStr = restTemplate.getForEntity(IP_URL + "?ip=" + ip + "&json=true", String.class).getBody();
- if (StringUtils.isBlank(rspStr)) {
- log.error("获取地理位置异常 {}", ip);
- return UNKNOWN;
- }
- ObjectNode obj = JsonUtil.parseObject(rspStr);
- assert obj != null;
- return obj.get("pro").asText() + " " + obj.get("city").asText();
- }
- return UNKNOWN;
- }
-}
diff --git a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/jackson/MaskSensitiveDataSerializerProvider.java b/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/jackson/MaskSensitiveDataSerializerProvider.java
deleted file mode 100644
index fb781830..00000000
--- a/agile-portal/agile-portal-gateway/src/main/java/com/jiuyv/sptccc/agile/common/utils/jackson/MaskSensitiveDataSerializerProvider.java
+++ /dev/null
@@ -1,168 +0,0 @@
-package com.jiuyv.sptccc.agile.common.utils.jackson;
-
-import java.io.IOException;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Optional;
-import java.util.Set;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-
-import com.jiuyv.sptccc.agile.common.utils.StringUtil;
-import org.apache.commons.lang3.ObjectUtils;
-
-import com.fasterxml.jackson.core.JsonGenerator;
-import com.fasterxml.jackson.databind.BeanProperty;
-import com.fasterxml.jackson.databind.JavaType;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.JsonSerializer;
-import com.fasterxml.jackson.databind.SerializationConfig;
-import com.fasterxml.jackson.databind.SerializerProvider;
-import com.fasterxml.jackson.databind.ser.DefaultSerializerProvider;
-import com.fasterxml.jackson.databind.ser.SerializerFactory;
-
-
-/**
- * 敏感字段处理为*(不是过滤,方便确认有没有值)
- * 无需注解,固定的可以直接写这里面
- * 如需要特殊处理修改自定义实现
- *
- * @author zhouliang
- */
-public class MaskSensitiveDataSerializerProvider extends DefaultSerializerProvider {
-
- private static final long serialVersionUID = 1L;
-
- //开始或结尾是,就认为是敏感字段
- private static final String LIKE_FILEDS = "password,email,phone";
- //明确敏感字段
- private static final String STATIC_FILEDS = "idCard,socialCreditCode";
-
- private static final Set STATIC_FILED_SET = new HashSet<>(
- Arrays.stream(STATIC_FILEDS.split(","))
- .map(String::trim)
- .filter(o -> !ObjectUtils.isEmpty(o))
- .collect(Collectors.toSet())
- );
- private static final Set LIKE_FILED_SET = new HashSet<>(
- Arrays.stream(LIKE_FILEDS.split(","))
- .map(String::trim)
- .filter(o -> !ObjectUtils.isEmpty(o))
- .collect(Collectors.toSet())
- );
-
- public MaskSensitiveDataSerializerProvider() {
- super();
- }
-
- public MaskSensitiveDataSerializerProvider(MaskSensitiveDataSerializerProvider src) {
- super(src);
- }
-
- protected MaskSensitiveDataSerializerProvider(SerializerProvider src, SerializationConfig config, SerializerFactory f) {
- super(src, config, f);
- }
-
- @Override
- public DefaultSerializerProvider copy() {
- if (this.getClass() != MaskSensitiveDataSerializerProvider.class) {
- return super.copy();
- }
- return new MaskSensitiveDataSerializerProvider(this);
- }
-
- @Override
- public MaskSensitiveDataSerializerProvider createInstance(SerializationConfig config, SerializerFactory jsf) {
- return new MaskSensitiveDataSerializerProvider(this, config, jsf);
- }
-
- @Override
- public JsonSerializer