数据开发模块N.0
parent
2c4132f6fa
commit
e17ee79fa3
|
@ -1,49 +0,0 @@
|
||||||
package net.srt.vo;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @ClassName : DatastandardVo
|
|
||||||
* @Description :
|
|
||||||
* @Author : FJJ
|
|
||||||
* @Date: 2023-12-23 12:05
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@Schema(description = "标准管理查询")
|
|
||||||
public class DatastandardVo implements Serializable {
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
@TableId("id")
|
|
||||||
private Long id;
|
|
||||||
private Integer categoryId;
|
|
||||||
private String engName;
|
|
||||||
private String cnName;
|
|
||||||
private Integer codeNum;
|
|
||||||
private String dataType;
|
|
||||||
private Integer dataLength;
|
|
||||||
private Integer dataPrecision;
|
|
||||||
private Integer nullable;
|
|
||||||
private Integer standardCodeId;
|
|
||||||
private Integer type;
|
|
||||||
private String note;
|
|
||||||
private Long projectId;
|
|
||||||
private Integer status;
|
|
||||||
private Integer version;
|
|
||||||
private Integer deleted;
|
|
||||||
private String creator;
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
||||||
private Date createTime;
|
|
||||||
private String updater;
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
||||||
private Date updateTime;
|
|
||||||
private Integer ifStandardRel;
|
|
||||||
private String group;
|
|
||||||
}
|
|
|
@ -18,7 +18,6 @@ import static com.alibaba.druid.sql.SQLUtils.toSQLString;
|
||||||
@EnableDiscoveryClient
|
@EnableDiscoveryClient
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableFeignClients
|
@EnableFeignClients
|
||||||
|
|
||||||
@MapperScan("net.srt.Fink.mapper")
|
@MapperScan("net.srt.Fink.mapper")
|
||||||
@MapperScan("net.srt.Hadoop.mapper")
|
@MapperScan("net.srt.Hadoop.mapper")
|
||||||
@MapperScan("net.srt.disposition.mapper")
|
@MapperScan("net.srt.disposition.mapper")
|
||||||
|
|
|
@ -2,13 +2,17 @@ package net.srt.disposition.controller;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import net.srt.disposition.dto.DataCheckSqlDto;
|
import net.srt.disposition.dto.DataCheckSqlDto;
|
||||||
|
import net.srt.disposition.dto.DataSqlDto;
|
||||||
import net.srt.disposition.entity.DataCheckSqlEntity;
|
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||||
import net.srt.disposition.service.DataCheckSqlService;
|
import net.srt.disposition.service.DataCheckSqlService;
|
||||||
import net.srt.disposition.vo.DataCheckSqlVo;
|
import net.srt.disposition.vo.DataCheckSqlVo;
|
||||||
|
import net.srt.disposition.vo.DataSqlVo;
|
||||||
|
import net.srt.flink.common.result.SqlExplainResult;
|
||||||
import net.srt.framework.common.utils.Result;
|
import net.srt.framework.common.utils.Result;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@ -17,8 +21,31 @@ public class DataCheckSqlController {
|
||||||
|
|
||||||
private DataCheckSqlService dataCheckSqlService;
|
private DataCheckSqlService dataCheckSqlService;
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
public Result add(@RequestBody DataCheckSqlDto dataCheckSqlDto){
|
||||||
|
dataCheckSqlService.add(dataCheckSqlDto);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@GetMapping("/console-log")
|
||||||
|
public Result consoleLog(){
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
@GetMapping("/clear-log")
|
||||||
|
public Result checkLog(){
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/explain-sql")
|
@PostMapping("/explain-sql")
|
||||||
public Result<DataCheckSqlVo> explainSql(DataCheckSqlDto dataCheckSqlDto) {
|
public Result<List<SqlExplainResult>> explainSql(@RequestBody DataSqlDto dataSqlDto){
|
||||||
return Result.ok(dataCheckSqlService.explainSql(dataCheckSqlDto));
|
List<SqlExplainResult> dataSqlVo=dataCheckSqlService.explainSql(dataSqlDto);
|
||||||
|
return Result.ok(dataSqlVo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/{id}")
|
||||||
|
public Result<DataCheckSqlEntity> get(@PathVariable Integer id) {
|
||||||
|
DataCheckSqlEntity dataCheckSqlEntity = dataCheckSqlService.find(id);
|
||||||
|
return Result.ok(dataCheckSqlEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
package net.srt.disposition.controller;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
|
||||||
import net.srt.disposition.service.DataSaveService;
|
|
||||||
import net.srt.framework.common.utils.Result;
|
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@AllArgsConstructor
|
|
||||||
@RequestMapping("/task")
|
|
||||||
public class DataSaveController {
|
|
||||||
private DataSaveService dataSaveService;
|
|
||||||
@PostMapping
|
|
||||||
public Result addSave(@RequestBody DataSqlSaveDto dataSqlSaveDto){
|
|
||||||
dataSaveService.dataSaver(dataSqlSaveDto);
|
|
||||||
return Result.ok();
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
package net.srt.disposition.convert;
|
||||||
|
|
||||||
|
import net.srt.disposition.dto.DataCheckSqlDto;
|
||||||
|
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface DataCheckSqlConvert {
|
||||||
|
DataCheckSqlConvert INSTANCE = Mappers.getMapper(DataCheckSqlConvert.class);
|
||||||
|
|
||||||
|
DataCheckSqlEntity convert(DataCheckSqlDto dataCheckSqlDto);
|
||||||
|
}
|
|
@ -1,14 +0,0 @@
|
||||||
package net.srt.disposition.convert;
|
|
||||||
|
|
||||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
|
||||||
import net.srt.disposition.dto.DispositionDto;
|
|
||||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
|
||||||
import net.srt.disposition.entity.DispositionEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface DataSqlSaveConvert {
|
|
||||||
DataSqlSaveConvert INSTANCE = Mappers.getMapper(DataSqlSaveConvert.class);
|
|
||||||
DataSqlSaveEntity convert(DataSqlSaveDto vo);
|
|
||||||
}
|
|
|
@ -2,6 +2,7 @@ package net.srt.disposition.dto;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import net.srt.disposition.entity.DataDatabaseDevEntity;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
@ -9,48 +10,15 @@ import java.util.List;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class DataCheckSqlDto {
|
public class DataCheckSqlDto {
|
||||||
private Long alertGroupId;
|
|
||||||
private String alias;
|
private String alias;
|
||||||
private boolean batchModel;
|
|
||||||
private Long catalogueId;
|
private Long catalogueId;
|
||||||
private Integer checkPoint;
|
private Long databaseId;
|
||||||
private String clusterConfigurationId;
|
private List<DataDatabaseDevEntity> databaseList;
|
||||||
private Long clusterId;
|
|
||||||
private String configJson;
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
||||||
private Date createTime;
|
|
||||||
private Integer databaseId;
|
|
||||||
private Integer deleted;
|
|
||||||
private Integer dialect;
|
private Integer dialect;
|
||||||
private boolean enabled;
|
private Long id;
|
||||||
private Integer envId;
|
|
||||||
private boolean fragment;
|
|
||||||
private Integer id;
|
|
||||||
private Integer jarId;
|
|
||||||
private String jobName;
|
|
||||||
private Integer maxRowNum;
|
|
||||||
private String name;
|
private String name;
|
||||||
private String note;
|
|
||||||
private Integer openTrans;
|
private Integer openTrans;
|
||||||
private Integer parallelism;
|
|
||||||
private boolean processEnd;
|
|
||||||
private Integer projectId;
|
|
||||||
private Integer pvdataNum;
|
private Integer pvdataNum;
|
||||||
private String savePointPath;
|
|
||||||
private String savePointStrategy;
|
|
||||||
private Integer sqlDbType;
|
private Integer sqlDbType;
|
||||||
private String statement;
|
private String statement;
|
||||||
private boolean statementSet;
|
|
||||||
private Integer step;
|
|
||||||
private String type;
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
||||||
private Date updateTime;
|
|
||||||
private Integer updater;
|
|
||||||
private boolean useAutoCancel;
|
|
||||||
private boolean useChangeLog;
|
|
||||||
private boolean usrResult;
|
|
||||||
private Integer version;
|
|
||||||
private Integer versionId;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,59 @@
|
||||||
|
package net.srt.disposition.dto;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.srt.disposition.entity.DataDatabaseDevEntity;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DataSqlDto {
|
||||||
|
private Long alertGroupId;
|
||||||
|
private String alias;
|
||||||
|
private String batchModel;
|
||||||
|
private String checkPoint;
|
||||||
|
private Long clusterConfigurationId;
|
||||||
|
private Long clusterId;
|
||||||
|
private String configJson;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date creatTime;
|
||||||
|
private String creator;
|
||||||
|
private Long databaseId;
|
||||||
|
private List<DataDatabaseDevEntity> databaseList;
|
||||||
|
private String deleted;
|
||||||
|
private Integer dialect;
|
||||||
|
private String enabled;
|
||||||
|
private Long envId;
|
||||||
|
private String fragment;
|
||||||
|
private Long id;
|
||||||
|
private Long jarId;
|
||||||
|
private Long jobInstanceId;
|
||||||
|
private String jobName;
|
||||||
|
private Integer maxRowNum;
|
||||||
|
private String name;
|
||||||
|
private String note;
|
||||||
|
private Integer parallelism;
|
||||||
|
private boolean processEnd;
|
||||||
|
private Long projectId;
|
||||||
|
private Integer pvdataNum;
|
||||||
|
private String savePointPath;
|
||||||
|
private String savePointStrategy;
|
||||||
|
private Integer sqlDbType;
|
||||||
|
private String statement;
|
||||||
|
private String statementSet;
|
||||||
|
private String step;
|
||||||
|
private Integer taskId;
|
||||||
|
private String type;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date updateTime;
|
||||||
|
private String updater;
|
||||||
|
private String usrAutoCancel;
|
||||||
|
private String usrChangeLog;
|
||||||
|
private String userResult;
|
||||||
|
private String version;
|
||||||
|
private Long versionId;
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
package net.srt.disposition.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@TableName("data_centre")
|
||||||
|
public class DataCentre {
|
||||||
|
private Long id;
|
||||||
|
private Long projectId;
|
||||||
|
private String sqlDbType;
|
||||||
|
private Long databaseId;
|
||||||
|
private Long clusterId;
|
||||||
|
private Long clusterConfigurationId;
|
||||||
|
private String session;
|
||||||
|
private Long jobId;
|
||||||
|
private String jobName;
|
||||||
|
private String jobManagerAddress;
|
||||||
|
private Integer status;
|
||||||
|
private Integer dialect;
|
||||||
|
private String type;
|
||||||
|
private String statement;
|
||||||
|
private String error;
|
||||||
|
private String result;
|
||||||
|
private String configJson;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date startTime;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date endTime;
|
||||||
|
private Long taskId;
|
||||||
|
private String executeType;
|
||||||
|
private Long scheduleId;
|
||||||
|
private Long scheduleRecordId;
|
||||||
|
private Long scheduleNodeRecordId;
|
||||||
|
private Integer version;
|
||||||
|
private Integer deleted;
|
||||||
|
private String creator;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date createTime;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date updateTime;@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date finishTime;
|
||||||
|
private String instanceStatus;
|
||||||
|
private String executeSql;
|
||||||
|
private String executeNo;
|
||||||
|
private String jib;
|
||||||
|
private String duration;
|
||||||
|
|
||||||
|
}
|
|
@ -11,16 +11,48 @@ import java.util.Date;
|
||||||
@Data
|
@Data
|
||||||
@TableName("data_check_sql")
|
@TableName("data_check_sql")
|
||||||
public class DataCheckSqlEntity {
|
public class DataCheckSqlEntity {
|
||||||
@TableId("id")
|
private Long id;
|
||||||
private Integer id;
|
@TableId
|
||||||
|
private Long taskId;
|
||||||
|
private String name;
|
||||||
|
private Long projectId;
|
||||||
|
private String alias;
|
||||||
|
private Integer dialect;
|
||||||
private String type;
|
private String type;
|
||||||
private String sql;
|
private Integer checkPoint;
|
||||||
private String parse;
|
private Integer savePointStrategy;
|
||||||
private String explain;
|
private String savePointPath;
|
||||||
private String error;
|
private Integer parallelism;
|
||||||
private String parseTrue;
|
private Boolean fragment;
|
||||||
private String explainTrue;
|
private Boolean statementSet;
|
||||||
|
private Boolean batchModel;
|
||||||
|
private Long clusterId;
|
||||||
|
private Long clusterConfigurationId;
|
||||||
|
private Integer sqlDbType;
|
||||||
|
private Long databaseId;
|
||||||
|
private Integer openTrans;
|
||||||
|
private Long jarId;
|
||||||
|
private Long envId;
|
||||||
|
private Long alertGroupId;
|
||||||
|
private String configJson;
|
||||||
|
private String note;
|
||||||
|
private Integer step;
|
||||||
|
private Long jobInstanceId;
|
||||||
|
private Boolean useAutoCancel;
|
||||||
|
private Boolean useChangeLog;
|
||||||
|
private Boolean useResult;
|
||||||
|
private Integer pvdataNum;
|
||||||
|
private Boolean enabled;
|
||||||
|
private Long versionId;
|
||||||
|
private Integer version;
|
||||||
|
private Integer deleted;
|
||||||
|
private Long creator;
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
private Date explainTime;
|
private Date createTime;
|
||||||
|
private Long updater;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||||
|
private Date updateTime;
|
||||||
|
private String statement;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,61 +0,0 @@
|
||||||
package net.srt.disposition.entity;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import lombok.Data;
|
|
||||||
import net.srt.framework.mybatis.entity.BaseEntity;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@TableName("data_sql_save")
|
|
||||||
public class DataSqlSaveEntity {
|
|
||||||
@TableId("id")
|
|
||||||
private Long id;
|
|
||||||
private Long catalogueId;
|
|
||||||
private String name;
|
|
||||||
private Long projectId;
|
|
||||||
private String alias;
|
|
||||||
private Integer dialect;
|
|
||||||
private Integer type;
|
|
||||||
private Integer checkPoint;
|
|
||||||
private Integer savePointStrategy;
|
|
||||||
private String savePointPath;
|
|
||||||
private Integer parallelism;
|
|
||||||
private boolean fragment;
|
|
||||||
private boolean statementSet;
|
|
||||||
private boolean batchModel;
|
|
||||||
private Long clusterId;
|
|
||||||
private Long clusterConfigurationId;
|
|
||||||
private Integer sqlDbType;
|
|
||||||
private Long databaseId;
|
|
||||||
private Integer openTrans;
|
|
||||||
private Long jarId;
|
|
||||||
private Long envId;
|
|
||||||
private Long alertGroupId;
|
|
||||||
private String configJson;
|
|
||||||
private String note;
|
|
||||||
private Integer step;
|
|
||||||
private Long jobInstanceId;
|
|
||||||
private boolean useAutoCancel;
|
|
||||||
private boolean useChangeLog;
|
|
||||||
private boolean useResult;
|
|
||||||
private Integer pvdataNum;
|
|
||||||
private boolean enabled;
|
|
||||||
private Long versionId;
|
|
||||||
private Integer version;
|
|
||||||
private Integer deleted;
|
|
||||||
private Long creator;
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
||||||
private Date createTime;
|
|
||||||
private Long updater;
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
|
||||||
private Date updateTime;
|
|
||||||
private String statement;
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,9 +0,0 @@
|
||||||
package net.srt.disposition.mapper;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
||||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface DataSaveServiceMapper extends BaseMapper<DataSqlSaveEntity> {
|
|
||||||
}
|
|
|
@ -2,9 +2,18 @@ package net.srt.disposition.service;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import net.srt.disposition.dto.DataCheckSqlDto;
|
import net.srt.disposition.dto.DataCheckSqlDto;
|
||||||
|
import net.srt.disposition.dto.DataSqlDto;
|
||||||
import net.srt.disposition.entity.DataCheckSqlEntity;
|
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||||
import net.srt.disposition.vo.DataCheckSqlVo;
|
import net.srt.disposition.vo.DataCheckSqlVo;
|
||||||
|
import net.srt.disposition.vo.DataSqlVo;
|
||||||
|
import net.srt.flink.common.result.SqlExplainResult;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface DataCheckSqlService extends IService<DataCheckSqlEntity> {
|
public interface DataCheckSqlService extends IService<DataCheckSqlEntity> {
|
||||||
DataCheckSqlVo explainSql(DataCheckSqlDto dataCheckSqlDto);
|
DataCheckSqlEntity find(Integer id);
|
||||||
|
|
||||||
|
void add(DataCheckSqlDto dataCheckSqlDto);
|
||||||
|
|
||||||
|
List<SqlExplainResult> explainSql(DataSqlDto dataSqlDto);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
package net.srt.disposition.service;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
|
||||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
|
||||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
|
||||||
|
|
||||||
public interface DataSaveService extends IService<DataSqlSaveEntity> {
|
|
||||||
void dataSaver(DataSqlSaveDto dataSqlSaveDto);
|
|
||||||
|
|
||||||
}
|
|
|
@ -1,48 +1,120 @@
|
||||||
package net.srt.disposition.service.impl;
|
package net.srt.disposition.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.druid.sql.SQLUtils;
|
||||||
import com.alibaba.druid.sql.ast.SQLStatement;
|
import com.alibaba.druid.sql.ast.SQLStatement;
|
||||||
import com.alibaba.druid.sql.parser.SQLParserUtils;
|
|
||||||
import com.alibaba.druid.sql.parser.SQLStatementParser;
|
|
||||||
import jdk.nashorn.internal.runtime.ParserException;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.disposition.convert.DataCheckSqlConvert;
|
||||||
import net.srt.disposition.dto.DataCheckSqlDto;
|
import net.srt.disposition.dto.DataCheckSqlDto;
|
||||||
|
import net.srt.disposition.dto.DataSqlDto;
|
||||||
import net.srt.disposition.entity.DataCheckSqlEntity;
|
import net.srt.disposition.entity.DataCheckSqlEntity;
|
||||||
|
import net.srt.disposition.entity.DataProductionTreeEntity;
|
||||||
import net.srt.disposition.mapper.DataCheckSqlMapper;
|
import net.srt.disposition.mapper.DataCheckSqlMapper;
|
||||||
|
import net.srt.disposition.mapper.DataProductionMapper;
|
||||||
import net.srt.disposition.service.DataCheckSqlService;
|
import net.srt.disposition.service.DataCheckSqlService;
|
||||||
import net.srt.disposition.vo.DataCheckSqlVo;
|
import net.srt.flink.common.result.SqlExplainResult;
|
||||||
|
import net.srt.flink.common.utils.LogUtil;
|
||||||
|
import net.srt.flink.process.context.ProcessContextHolder;
|
||||||
|
import net.srt.flink.process.model.ProcessEntity;
|
||||||
|
import net.srt.flink.process.model.ProcessStatus;
|
||||||
|
import net.srt.flink.process.model.ProcessStep;
|
||||||
|
import net.srt.flink.process.model.ProcessType;
|
||||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import org.apache.ibatis.annotations.Select;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
import static com.alibaba.druid.sql.SQLUtils.toSQLString;
|
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class DataCheckSqlServiceImpl extends BaseServiceImpl<DataCheckSqlMapper, DataCheckSqlEntity> implements DataCheckSqlService {
|
public class DataCheckSqlServiceImpl extends BaseServiceImpl<DataCheckSqlMapper, DataCheckSqlEntity> implements DataCheckSqlService {
|
||||||
|
|
||||||
|
private DataProductionMapper dataProductionMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DataCheckSqlVo explainSql(DataCheckSqlDto dataCheckSqlDto) {
|
public DataCheckSqlEntity find(Integer id) {
|
||||||
DataCheckSqlVo dataCheckSqlVo = new DataCheckSqlVo();
|
DataCheckSqlEntity dataCheckSqlEntity = baseMapper.selectById(id);
|
||||||
try {
|
return dataCheckSqlEntity;
|
||||||
SQLStatementParser mysql = SQLParserUtils.createSQLStatementParser(dataCheckSqlDto.getStatement(), "mysql");
|
|
||||||
SQLStatement sqlStatement = mysql.parseStatement();
|
|
||||||
if (sqlStatement instanceof Select) {
|
|
||||||
dataCheckSqlVo.setType("SQLSelectStatement");
|
|
||||||
}
|
|
||||||
dataCheckSqlVo.setSql(dataCheckSqlDto.getStatement());
|
|
||||||
dataCheckSqlVo.setParseTrue(true);
|
|
||||||
dataCheckSqlVo.setExplainTrue(true);
|
|
||||||
dataCheckSqlVo.setExplainTime(new Date());
|
|
||||||
} catch (ParserException e) {
|
|
||||||
System.out.println("SQL转换中发生了错误:"+e.getMessage());
|
|
||||||
dataCheckSqlVo.setSql(dataCheckSqlDto.getStatement());
|
|
||||||
dataCheckSqlVo.setError(e.getMessage());
|
|
||||||
dataCheckSqlVo.setParseTrue(false);
|
|
||||||
dataCheckSqlVo.setExplainTrue(false);
|
|
||||||
dataCheckSqlVo.setExplainTime(new Date());
|
|
||||||
}
|
|
||||||
return dataCheckSqlVo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void add(DataCheckSqlDto dataCheckSqlDto) {
|
||||||
|
DataCheckSqlEntity convert = DataCheckSqlConvert.INSTANCE.convert(dataCheckSqlDto);
|
||||||
|
convert.setTaskId(dataCheckSqlDto.getCatalogueId());
|
||||||
|
DataProductionTreeEntity dataProductionTreeEntity = new DataProductionTreeEntity();
|
||||||
|
dataProductionTreeEntity.setId(dataCheckSqlDto.getCatalogueId());
|
||||||
|
dataProductionTreeEntity.setTaskId(dataCheckSqlDto.getCatalogueId());
|
||||||
|
dataProductionMapper.updateById(dataProductionTreeEntity);
|
||||||
|
baseMapper.insert(convert);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<SqlExplainResult> explainSql(DataSqlDto dataSqlDto) {
|
||||||
|
ProcessEntity process = BuildStes(dataSqlDto);
|
||||||
|
// 初始化一个列表,用于存储SQL解析结果
|
||||||
|
List<SqlExplainResult> sqlExplainResults = new ArrayList<>();
|
||||||
|
// 初始化一个变量,用于存储当前正在处理的SQL语句
|
||||||
|
String current = null;
|
||||||
|
// 记录SQL验证开始的日志
|
||||||
|
process.info("Start check sql...");
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 使用SQLUtils将输入的SQL解析为SQL语句列表
|
||||||
|
List<SQLStatement> stmtList = SQLUtils.parseStatements(dataSqlDto.getStatement(), "SqlServer");
|
||||||
|
|
||||||
|
// 遍历列表中的每个SQL语句
|
||||||
|
for (SQLStatement item : stmtList) {
|
||||||
|
// 设置当前正在处理的SQL语句,以便记录日志
|
||||||
|
current = item.toString();
|
||||||
|
|
||||||
|
// 获取SQL语句的类型(例如,SELECT、INSERT)并添加到结果列表中
|
||||||
|
String type = item.getClass().getSimpleName();
|
||||||
|
SqlExplainResult success = SqlExplainResult.success(type, current, null);
|
||||||
|
sqlExplainResults.add(success);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 记录SQL正确的日志消息
|
||||||
|
process.info("Sql is correct.");
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 如果在SQL解析过程中发生异常,将失败的结果添加到列表中
|
||||||
|
SqlExplainResult fail = SqlExplainResult.fail(current, LogUtil.getError(e));
|
||||||
|
sqlExplainResults.add(fail);
|
||||||
|
|
||||||
|
String error = LogUtil.getError(e);
|
||||||
|
// 记录错误消息
|
||||||
|
process.error(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 返回SQL解析结果列表
|
||||||
|
return sqlExplainResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ProcessEntity BuildStes(DataSqlDto dto) {
|
||||||
|
// 从上下文获取当前进程实体
|
||||||
|
ProcessEntity process = ProcessContextHolder.getProcess();
|
||||||
|
process.setPid(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||||
|
process.setName(dto.getName());
|
||||||
|
process.setTaskId(Math.toIntExact(dto.getDatabaseId()));
|
||||||
|
process.setType(ProcessType.SQLEXECUTE);
|
||||||
|
process.setStatus(ProcessStatus.RUNNING);
|
||||||
|
process.setAccessToken(getAccessToken());
|
||||||
|
process.setProjectId(dto.getProjectId());
|
||||||
|
process.setStartTime(LocalDateTime.now());
|
||||||
|
process.setEndTime(LocalDateTime.now());
|
||||||
|
process.setStepIndex(1);
|
||||||
|
|
||||||
|
ProcessStep processStep = new ProcessStep();
|
||||||
|
processStep.setStepStatus(process.getStatus());
|
||||||
|
processStep.setStartTime(LocalDateTime.now());
|
||||||
|
processStep.setEndTime(LocalDateTime.now());
|
||||||
|
List<ProcessStep> steps = new ArrayList<>();
|
||||||
|
steps.add(processStep);
|
||||||
|
process.setSteps(steps);
|
||||||
|
|
||||||
|
return process;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
package net.srt.disposition.service.impl;
|
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import net.srt.disposition.convert.DataSqlSaveConvert;
|
|
||||||
import net.srt.disposition.dto.DataSqlSaveDto;
|
|
||||||
import net.srt.disposition.entity.DataSqlSaveEntity;
|
|
||||||
import net.srt.disposition.mapper.DataSaveServiceMapper;
|
|
||||||
import net.srt.disposition.service.DataSaveService;
|
|
||||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@AllArgsConstructor
|
|
||||||
public class DataSaveServiceImpl extends BaseServiceImpl<DataSaveServiceMapper,DataSqlSaveEntity> implements DataSaveService {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dataSaver(DataSqlSaveDto dataSqlSaveDto) {
|
|
||||||
DataSqlSaveEntity convert = DataSqlSaveConvert.INSTANCE.convert(dataSqlSaveDto);
|
|
||||||
convert.setCreateTime(new Date());
|
|
||||||
baseMapper.insert(convert);
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.srt.disposition.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import lombok.Data;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class DataSqlVo {
|
||||||
|
private Long index;
|
||||||
|
private String type;
|
||||||
|
private String sql;
|
||||||
|
private String parse;
|
||||||
|
private String explain;
|
||||||
|
private String error;
|
||||||
|
private boolean parseTrue;
|
||||||
|
private boolean explainTrue;
|
||||||
|
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
||||||
|
private Date explainTime;
|
||||||
|
}
|
Loading…
Reference in New Issue