数据质量规则配置目录树
parent
89045be56c
commit
ab139edf83
|
@ -0,0 +1,88 @@
|
||||||
|
package net.srt.api.module.data.governance;
|
||||||
|
|
||||||
|
import net.srt.api.ServerNames;
|
||||||
|
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataCollectDto;
|
||||||
|
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataCollectRecordDto;
|
||||||
|
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataDto;
|
||||||
|
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataPropertyDto;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName DataAccessApi
|
||||||
|
* @Author zrx
|
||||||
|
* @Date 2022/10/26 11:39
|
||||||
|
*/
|
||||||
|
@FeignClient(name = ServerNames.DATA_GOVERNANCE_NAME, contextId = "data-governance-metadata-collect")
|
||||||
|
public interface DataMetadataCollectApi {
|
||||||
|
/**
|
||||||
|
* 根据id获取采集任务
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "api/data/governance/metadata-collect/{id}")
|
||||||
|
Result<DataGovernanceMetadataCollectDto> getById(@PathVariable Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取采集任务
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "api/data/governance/metadata-collect-record")
|
||||||
|
DataGovernanceMetadataCollectRecordDto addCollectRecord(@RequestBody DataGovernanceMetadataCollectRecordDto collectRecordDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id获取采集任务
|
||||||
|
*/
|
||||||
|
@PutMapping(value = "api/data/governance/metadata-collect-record")
|
||||||
|
void upCollectRecord(@RequestBody DataGovernanceMetadataCollectRecordDto collectRecordDto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父级id和数据源id获取
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "api/data/governance/metadata/datasource")
|
||||||
|
Result<DataGovernanceMetadataDto> getByParentIdAndDatasourceId(@RequestParam Long parnetId, @RequestParam Long datasourceId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父级id和数据源id获取
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "api/data/governance/metadata/info")
|
||||||
|
Result<DataGovernanceMetadataDto> getMetadataById(@RequestParam Long metadataId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据父级id和code以及modelId获取
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "api/data/governance/metadata/child-info")
|
||||||
|
Result<DataGovernanceMetadataDto> getByParentIdAndOtherInfo(@RequestParam Long parnetId, @RequestParam Long datasourceId, @RequestParam String code, @RequestParam Long metamodelId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加元数据
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "api/data/governance/metadata")
|
||||||
|
DataGovernanceMetadataDto addOrUpdateMetadata(@RequestBody DataGovernanceMetadataDto metadataDto);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取元数据属性
|
||||||
|
*/
|
||||||
|
@GetMapping(value = "api/data/governance/metadata-property")
|
||||||
|
Result<DataGovernanceMetadataPropertyDto> getByPropertyIdAndMetadataId(@RequestParam Long propertyId, @RequestParam Long metadataId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加元数据属性
|
||||||
|
*/
|
||||||
|
@PostMapping(value = "api/data/governance/metadata-prpperty")
|
||||||
|
void addOrUpdateMetadataProperty(@RequestBody DataGovernanceMetadataPropertyDto metadataPropertyDto);
|
||||||
|
|
||||||
|
@GetMapping(value = "api/data/governance/metadata/list")
|
||||||
|
Result<List<DataGovernanceMetadataDto>> listParentIdAndDatasourceId(@RequestParam Long parentId, @RequestParam Long datasourceId, @RequestParam Long metamodelId);
|
||||||
|
|
||||||
|
@DeleteMapping(value = "api/data/governance/metadata")
|
||||||
|
void deleteMetadata(@RequestParam Long id);
|
||||||
|
|
||||||
|
@GetMapping(value = "api/data/governance/by-datasourceId")
|
||||||
|
Result<DataGovernanceMetadataCollectDto> getByDatasourceId(Long id);
|
||||||
|
|
||||||
|
@GetMapping(value = "api/data/governance/metadata/by-datasourceId")
|
||||||
|
Result<DataGovernanceMetadataDto> getMetadataByDatasourceId(Long id);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,96 @@
|
||||||
|
package net.srt.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import net.srt.framework.common.utils.TreeNodeVo;
|
||||||
|
import net.srt.service.MetadataService;
|
||||||
|
import net.srt.vo.MetadataVo;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.controller
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 14:24
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("metadata")
|
||||||
|
@Tag(name = "数据治理-元数据")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MetadataController {
|
||||||
|
private final MetadataService metadataService;
|
||||||
|
@GetMapping("/list-chlid")
|
||||||
|
@Operation(summary = "根据父类id获取信息")
|
||||||
|
public Result<List<TreeNodeVo>> listByPatenId(@RequestParam Long parentId){
|
||||||
|
List<TreeNodeVo> list=metadataService.listByPatenId(parentId);
|
||||||
|
return Result.ok(list);
|
||||||
|
}
|
||||||
|
@GetMapping("/list-floder")
|
||||||
|
@Operation(summary = "获取目录树")
|
||||||
|
public Result<List<TreeNodeVo>> listFloder(){
|
||||||
|
List<TreeNodeVo> list=metadataService.listFloder();
|
||||||
|
return Result.ok(list);
|
||||||
|
}
|
||||||
|
@GetMapping("/list-db")
|
||||||
|
@Operation(summary = "获取库表目录树")
|
||||||
|
public Result<List<TreeNodeVo>> listDb() {
|
||||||
|
List<TreeNodeVo> list=metadataService.listDb();
|
||||||
|
return Result.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/list-keyword")
|
||||||
|
@Operation(summary = "模糊查询")
|
||||||
|
public Result<List<TreeNodeVo>> listKeyword( String keyword) {
|
||||||
|
List<TreeNodeVo> list=metadataService.listKeyword(keyword);
|
||||||
|
return Result.ok(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@Operation(summary = "信息")
|
||||||
|
public Result<MetadataVo> get(@PathVariable("id") Long id){
|
||||||
|
return Result.ok(metadataService.get(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary = "保存")
|
||||||
|
public Result<String> save(@RequestBody MetadataVo vo){
|
||||||
|
metadataService.save(vo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
public Result<String> update(@RequestBody @Valid MetadataVo vo){
|
||||||
|
metadataService.update(vo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping("{id}")
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
public Result<String> delete(@PathVariable Long id){
|
||||||
|
metadataService.delete(id);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("{neo4j}")
|
||||||
|
@Operation(summary = "更新neo4路径")
|
||||||
|
public Result<String> updateNeo4j(@PathVariable Neo4jInfo neo4jInfo){
|
||||||
|
metadataService.updateNeo4j(neo4jInfo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("/neo4j")
|
||||||
|
@Operation(summary = "获取neo4的路径")
|
||||||
|
public Result<Neo4jInfo> getNeo4j(){
|
||||||
|
return Result.ok(metadataService.getNeo4j());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,82 @@
|
||||||
|
package net.srt.controller;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.framework.common.page.PageResult;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import net.srt.query.QualityConfigQuery;
|
||||||
|
import net.srt.service.QualityConfigService;
|
||||||
|
import net.srt.vo.QualityConfigVo;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.controller
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 19:31
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/quality-config")
|
||||||
|
@Tag(name = "数据治理-质量规则配置")
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class QualityConfigController {
|
||||||
|
private final QualityConfigService qualityConfigService;
|
||||||
|
@GetMapping("page")
|
||||||
|
@Operation(summary = "分页")
|
||||||
|
public Result<PageResult<QualityConfigVo>> page(@Valid QualityConfigQuery query){
|
||||||
|
PageResult<QualityConfigVo> page= qualityConfigService.page(query);
|
||||||
|
return Result.ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@Operation(summary = "信息")
|
||||||
|
public Result<QualityConfigVo> get(@PathVariable("id") Long id){
|
||||||
|
return Result.ok(qualityConfigService.get(id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary = "保存")
|
||||||
|
public Result<String> save(@RequestBody QualityConfigVo vo){
|
||||||
|
qualityConfigService.save(vo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
@PutMapping
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
public Result<String> update(@RequestBody @Valid QualityConfigVo vo){
|
||||||
|
qualityConfigService.update(vo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/online/{id}")
|
||||||
|
@Operation(summary = "启用")
|
||||||
|
public Result<String> online(@PathVariable Long id){
|
||||||
|
qualityConfigService.online(id);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/offline/{id}")
|
||||||
|
@Operation(summary = "关闭")
|
||||||
|
public Result<String> offline(@PathVariable Long id){
|
||||||
|
qualityConfigService.offline(id);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/hand-run/{id}")
|
||||||
|
@Operation(summary = "手动执行")
|
||||||
|
public Result<String> handRun(@PathVariable Long id){
|
||||||
|
qualityConfigService.handRun(id);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
public Result<String> delete(@RequestBody List<Long> idList){
|
||||||
|
qualityConfigService.delete(idList);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.srt.convert;
|
||||||
|
|
||||||
|
import net.srt.entity.MetadataEntity;
|
||||||
|
import net.srt.vo.MetadataVo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.convert
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 15:42
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MetadataConvert {
|
||||||
|
|
||||||
|
MetadataConvert INSTANCE = Mappers.getMapper(MetadataConvert.class);
|
||||||
|
|
||||||
|
MetadataVo convert(MetadataEntity entity);
|
||||||
|
|
||||||
|
MetadataEntity convert(MetadataVo vo);
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package net.srt.convert;
|
||||||
|
|
||||||
|
import net.srt.entity.QualityConfigEntity;
|
||||||
|
import net.srt.vo.QualityConfigVo;
|
||||||
|
import org.mapstruct.Mapper;
|
||||||
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.convert
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 19:57
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface QualityConfigConvert {
|
||||||
|
QualityConfigConvert INSTANCE = Mappers.getMapper(QualityConfigConvert.class);
|
||||||
|
|
||||||
|
QualityConfigVo convert(QualityConfigEntity entity);
|
||||||
|
|
||||||
|
QualityConfigEntity convert(QualityConfigVo vo);
|
||||||
|
|
||||||
|
List<QualityConfigVo> convertList(List<QualityConfigEntity> list);
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
package net.srt.dao;
|
||||||
|
|
||||||
|
import net.srt.entity.MetadataEntity;
|
||||||
|
import net.srt.framework.mybatis.dao.BaseDao;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.dao
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 14:39
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MetadataDao extends BaseDao<MetadataEntity> {
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package net.srt.dao;
|
||||||
|
|
||||||
|
import net.srt.entity.MetadataPropertyEntity;
|
||||||
|
import net.srt.framework.mybatis.dao.BaseDao;
|
||||||
|
import net.srt.vo.MetamodelPropertyVO;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.dao
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 15:49
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface MetadataPropertyDao extends BaseDao<MetadataPropertyEntity> {
|
||||||
|
List<MetamodelPropertyVO> listPropertyById(@Param("id") Long id, Long metamodelId);
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package net.srt.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import net.srt.framework.mybatis.entity.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.entity
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 14:36
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Data
|
||||||
|
@TableName("data_governance_metadata")
|
||||||
|
public class MetadataEntity extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 父级id(默认0为顶级)
|
||||||
|
*/
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 树状节点的路径
|
||||||
|
*/
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点名称
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 节点英文名称
|
||||||
|
*/
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private Integer ifLeaf;
|
||||||
|
/**
|
||||||
|
* 对应的元模型id
|
||||||
|
*/
|
||||||
|
private Long metamodelId;
|
||||||
|
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 详情
|
||||||
|
*/
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 数据库类型(1-数据库 2-中台库)
|
||||||
|
*/
|
||||||
|
private Integer dbType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果是外部系统接入的库表,需要此字段
|
||||||
|
*/
|
||||||
|
private Long datasourceId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 采集任务id
|
||||||
|
*/
|
||||||
|
private Long collectTaskId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id(租户id)
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
|
||||||
|
private Integer orderNo;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package net.srt.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import net.srt.framework.mybatis.entity.BaseEntity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.entity
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 15:50
|
||||||
|
*/
|
||||||
|
@EqualsAndHashCode(callSuper=false)
|
||||||
|
@Data
|
||||||
|
@TableName("data_governance_metadata_property")
|
||||||
|
public class MetadataPropertyEntity extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 属性id
|
||||||
|
*/
|
||||||
|
private Long metamodelPropertyId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 元数据id
|
||||||
|
*/
|
||||||
|
private Long metadataId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性值
|
||||||
|
*/
|
||||||
|
private String property;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id(租户id)
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package net.srt.query;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import net.srt.framework.common.query.Query;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.query
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 19:39
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Schema(description = "数据治理-质量规则配置查询")
|
||||||
|
public class QualityConfigQuery extends Query {
|
||||||
|
private Long categoryId;
|
||||||
|
private String name;
|
||||||
|
private Long status;
|
||||||
|
private Long taskType;
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package net.srt.service;
|
||||||
|
|
||||||
|
import net.srt.entity.MetadataEntity;
|
||||||
|
import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||||
|
import net.srt.framework.common.utils.TreeNodeVo;
|
||||||
|
import net.srt.framework.mybatis.service.BaseService;
|
||||||
|
import net.srt.vo.MetadataVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.service
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 14:35
|
||||||
|
*/
|
||||||
|
|
||||||
|
public interface MetadataService extends BaseService<MetadataEntity> {
|
||||||
|
List<TreeNodeVo> listByPatenId(Long parentId);
|
||||||
|
|
||||||
|
List<TreeNodeVo> listFloder();
|
||||||
|
|
||||||
|
List<TreeNodeVo> listDb();
|
||||||
|
|
||||||
|
List<TreeNodeVo> listKeyword(String keyword);
|
||||||
|
|
||||||
|
MetadataVo get(Long id);
|
||||||
|
|
||||||
|
void save(MetadataVo vo);
|
||||||
|
|
||||||
|
void update(MetadataVo vo);
|
||||||
|
|
||||||
|
void delete(Long id);
|
||||||
|
|
||||||
|
void updateNeo4j(Neo4jInfo neo4jInfo);
|
||||||
|
|
||||||
|
Neo4jInfo getNeo4j();
|
||||||
|
}
|
|
@ -0,0 +1,34 @@
|
||||||
|
package net.srt.service;
|
||||||
|
|
||||||
|
import net.srt.entity.QualityConfigEntity;
|
||||||
|
import net.srt.framework.common.page.PageResult;
|
||||||
|
import net.srt.framework.mybatis.service.BaseService;
|
||||||
|
import net.srt.query.QualityConfigQuery;
|
||||||
|
import net.srt.vo.QualityConfigVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.service
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 19:33
|
||||||
|
*/
|
||||||
|
public interface QualityConfigService extends BaseService<QualityConfigEntity> {
|
||||||
|
PageResult<QualityConfigVo> page(QualityConfigQuery query);
|
||||||
|
|
||||||
|
QualityConfigVo get(Long id);
|
||||||
|
|
||||||
|
void save(QualityConfigVo vo);
|
||||||
|
|
||||||
|
void update(QualityConfigVo vo);
|
||||||
|
|
||||||
|
void online(Long id);
|
||||||
|
|
||||||
|
void offline(Long id);
|
||||||
|
|
||||||
|
void handRun(Long id);
|
||||||
|
|
||||||
|
|
||||||
|
void delete(List<Long> idList);
|
||||||
|
}
|
|
@ -0,0 +1,232 @@
|
||||||
|
package net.srt.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
|
||||||
|
import io.minio.messages.Metadata;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import net.srt.api.module.data.governance.constant.BuiltInMetamodel;
|
||||||
|
import net.srt.convert.MetadataConvert;
|
||||||
|
import net.srt.dao.MetadataDao;
|
||||||
|
import net.srt.dao.MetadataPropertyDao;
|
||||||
|
import net.srt.dao.MetamodelDao;
|
||||||
|
import net.srt.entity.MetadataEntity;
|
||||||
|
import net.srt.entity.MetadataPropertyEntity;
|
||||||
|
import net.srt.framework.common.cache.bean.Neo4jInfo;
|
||||||
|
import net.srt.framework.common.exception.ServerException;
|
||||||
|
import net.srt.framework.common.utils.BeanUtil;
|
||||||
|
import net.srt.framework.common.utils.BuildTreeUtils;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import net.srt.framework.common.utils.TreeNodeVo;
|
||||||
|
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
|
import net.srt.framework.security.cache.TokenStoreCache;
|
||||||
|
import net.srt.service.MetadataService;
|
||||||
|
import net.srt.vo.MetadataVo;
|
||||||
|
import net.srt.vo.MetamodelPropertyVO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.service.impl
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 14:38
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class MetadataServiceimpl extends BaseServiceImpl<MetadataDao, MetadataEntity>implements MetadataService {
|
||||||
|
private final MetamodelDao metamodelDao;
|
||||||
|
private final MetadataPropertyDao metadataPropertyDao;
|
||||||
|
private final TokenStoreCache tokenStoreCache;
|
||||||
|
@Override
|
||||||
|
public List<TreeNodeVo> listByPatenId(Long parentId) {
|
||||||
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(MetadataEntity::getParentId,parentId).orderByAsc(MetadataEntity::getOrderNo);
|
||||||
|
dataScopeWithOrgId(wrapper);
|
||||||
|
List<MetadataEntity> list = baseMapper.selectList(wrapper);
|
||||||
|
return BeanUtil.copyListProperties(list,TreeNodeVo::new,(oldItm,newItm)->{
|
||||||
|
newItm.setLabel(oldItm.getName());
|
||||||
|
newItm.setValue(oldItm.getId());
|
||||||
|
newItm.setLeaf(BuiltInMetamodel.COLUMN.getId().equals(oldItm.getMetamodelId()));
|
||||||
|
newItm.setDisabled(!BuiltInMetamodel.COLUMN.getId().equals(oldItm.getMetamodelId()));
|
||||||
|
if (newItm.getPath().contains("/")){
|
||||||
|
newItm.setParentPath(newItm.getPath().substring(0,newItm.getPath().lastIndexOf("/")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TreeNodeVo> listFloder() {
|
||||||
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(MetadataEntity::getIfLeaf,1).orderByAsc(MetadataEntity::getOrderNo).orderByAsc(MetadataEntity::getId);
|
||||||
|
dataScopeWithOrgId(wrapper);
|
||||||
|
List<MetadataEntity> list = baseMapper.selectList(wrapper);
|
||||||
|
List<TreeNodeVo> treeNodeVos=BeanUtil.copyListProperties(list,TreeNodeVo::new,(oldItm,newItm)->{
|
||||||
|
newItm.setLabel(oldItm.getName());
|
||||||
|
newItm.setValue(oldItm.getId());
|
||||||
|
if (newItm.getPath().contains("/")){
|
||||||
|
newItm.setParentPath(newItm.getPath().substring(0,newItm.getPath().lastIndexOf("/")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TreeNodeVo> listDb() {
|
||||||
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.in(MetadataEntity::getMetamodelId,BuiltInMetamodel.SCHEMA.getId(),BuiltInMetamodel.TABLE.getId())
|
||||||
|
.or().isNull(MetadataEntity::getMetamodelId)
|
||||||
|
.orderByAsc(MetadataEntity::getOrderNo);
|
||||||
|
dataScopeWithOrgId(wrapper);
|
||||||
|
List<MetadataEntity> list = baseMapper.selectList(wrapper);
|
||||||
|
List<TreeNodeVo> treeNodeVos=BeanUtil.copyListProperties(list,TreeNodeVo::new,(oldItm,newItm)->{
|
||||||
|
newItm.setLabel(oldItm.getName());
|
||||||
|
newItm.setValue(oldItm.getId());
|
||||||
|
if (newItm.getPath().contains("/")){
|
||||||
|
newItm.setParentPath(newItm.getPath().substring(0,newItm.getPath().lastIndexOf("/")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return BuildTreeUtils.buildTree(treeNodeVos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TreeNodeVo> listKeyword(String keyword) {
|
||||||
|
if (StringUtil.isBlank(keyword)){
|
||||||
|
return listByPatenId(0L);
|
||||||
|
}
|
||||||
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.like(MetadataEntity::getName,keyword).or().like(MetadataEntity::getCode,keyword).orderByAsc(MetadataEntity::getOrderNo);
|
||||||
|
ArrayList<MetadataEntity> arrayList = new ArrayList<>();
|
||||||
|
//递归获取父级
|
||||||
|
for (MetadataEntity metadataEntity : arrayList) {
|
||||||
|
recursionAddParent(metadataEntity,arrayList);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MetadataVo get(Long id) {
|
||||||
|
MetadataEntity metadataEntity = getById(id);
|
||||||
|
MetadataVo metadataVo = MetadataConvert.INSTANCE.convert(metadataEntity);
|
||||||
|
//获取元数据属性信息
|
||||||
|
metadataVo.setProperties(metadataPropertyDao.listPropertyById(id,metadataVo.getMetamodelId()));
|
||||||
|
return metadataVo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(MetadataVo vo) {
|
||||||
|
MetadataEntity entity=MetadataConvert.INSTANCE.convert(vo);
|
||||||
|
entity.setProjectId(getProjectId());
|
||||||
|
entity.setPath(recursionPath(entity, null));
|
||||||
|
buildField(entity);
|
||||||
|
MetadataEntity metadataEntity=baseMapper.selectById(vo.getParentId());
|
||||||
|
if (metadataEntity!=null){
|
||||||
|
entity.setDbType(metadataEntity.getDbType());
|
||||||
|
entity.setDatasourceId(metadataEntity.getDatasourceId());
|
||||||
|
entity.setCollectTaskId(metadataEntity.getCollectTaskId());
|
||||||
|
}
|
||||||
|
baseMapper.insert(entity);
|
||||||
|
buildProperties(entity,vo.getProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(MetadataVo vo) {
|
||||||
|
MetadataEntity entity=MetadataConvert.INSTANCE.convert(vo);
|
||||||
|
entity.setProjectId(getProjectId());
|
||||||
|
entity.setPath(recursionPath(entity,null));
|
||||||
|
buildField(entity);
|
||||||
|
updateById(entity);
|
||||||
|
buildProperties(entity,vo.getProperties());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(Long id) {
|
||||||
|
//判断是否有子节点
|
||||||
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(MetadataEntity::getParentId,id).last("limit 1");
|
||||||
|
if (baseMapper.selectOne(wrapper)!=null){
|
||||||
|
throw new ServerException("存在子节点,不可以进行删除");
|
||||||
|
}
|
||||||
|
removeById(id);
|
||||||
|
//删除属性
|
||||||
|
LambdaQueryWrapper<MetadataPropertyEntity> wrapper1 = new LambdaQueryWrapper<>();
|
||||||
|
wrapper1.eq(MetadataPropertyEntity::getMetadataId,id);
|
||||||
|
metadataPropertyDao.delete(wrapper1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateNeo4j(Neo4jInfo neo4jInfo) {
|
||||||
|
tokenStoreCache.saveNeo4jInfo(getProjectId(),neo4jInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Neo4jInfo getNeo4j() {
|
||||||
|
return tokenStoreCache.getNeo4jInfo(getProjectId());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildProperties(MetadataEntity entity, List<MetamodelPropertyVO> properties) {
|
||||||
|
if (!CollectionUtils.isEmpty(properties)){
|
||||||
|
LambdaQueryWrapper<MetadataEntity> wrapper = new LambdaQueryWrapper<>();
|
||||||
|
wrapper.eq(MetadataEntity::getMetamodelId,entity.getId());
|
||||||
|
for (MetamodelPropertyVO property : properties) {
|
||||||
|
MetadataPropertyEntity metadataPropertyEntity = new MetadataPropertyEntity();
|
||||||
|
metadataPropertyEntity.setMetamodelPropertyId(property.getId());
|
||||||
|
metadataPropertyEntity.setMetadataId(entity.getId());
|
||||||
|
metadataPropertyEntity.setProperty(property.getValue());
|
||||||
|
metadataPropertyEntity.setProjectId(entity.getProjectId());
|
||||||
|
if (property.getMetadataPropertyId()!=null){
|
||||||
|
metadataPropertyEntity.setId(property.getMetadataPropertyId());
|
||||||
|
metadataPropertyDao.updateById(metadataPropertyEntity);
|
||||||
|
}else {
|
||||||
|
metadataPropertyDao.insert(metadataPropertyEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildField(MetadataEntity entity) {
|
||||||
|
if (entity.getMetamodelId() != null) {
|
||||||
|
entity.setIcon(metamodelDao.selectById(entity.getMetamodelId()).getIcon());
|
||||||
|
}
|
||||||
|
if (entity.getIfLeaf() == 1 && entity.getMetamodelId() == null) {
|
||||||
|
entity.setIcon("/src/assets/folder.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private String recursionPath(MetadataEntity entity, String path) {
|
||||||
|
if (StringUtil.isBlank(path)) {
|
||||||
|
path = entity.getName();
|
||||||
|
}
|
||||||
|
if (entity.getParentId() != 0) {
|
||||||
|
MetadataEntity parent = getById(entity.getParentId());
|
||||||
|
path = parent.getName() + "/" + path;
|
||||||
|
return recursionPath(parent, path);
|
||||||
|
}
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void recursionAddParent(MetadataEntity metadataEntity, ArrayList<MetadataEntity> arrayList) {
|
||||||
|
if (arrayList.stream().noneMatch(item->metadataEntity.getId().equals(item.getId()))){
|
||||||
|
//添加自己
|
||||||
|
arrayList.add(metadataEntity);
|
||||||
|
}
|
||||||
|
//如果不是顶级
|
||||||
|
if (metadataEntity.getProjectId()!=0){
|
||||||
|
//获取父级,继续递归
|
||||||
|
MetadataEntity parent = getById(metadataEntity.getParentId());
|
||||||
|
recursionAddParent(parent,arrayList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,134 @@
|
||||||
|
package net.srt.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
import com.sun.org.apache.bcel.internal.generic.LADD;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.api.module.data.governance.constant.BuiltInQualityRule;
|
||||||
|
import net.srt.api.module.data.governance.dto.quality.QualityConfigParam;
|
||||||
|
import net.srt.api.module.quartz.QuartzDataGovernanceQualityApi;
|
||||||
|
import net.srt.convert.QualityConfigConvert;
|
||||||
|
import net.srt.dao.MetadataDao;
|
||||||
|
import net.srt.dao.QualityConfigDao;
|
||||||
|
import net.srt.entity.MetadataEntity;
|
||||||
|
import net.srt.entity.QualityConfigEntity;
|
||||||
|
import net.srt.framework.common.page.PageResult;
|
||||||
|
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
|
import net.srt.query.QualityConfigQuery;
|
||||||
|
import net.srt.service.QualityConfigService;
|
||||||
|
import net.srt.vo.QualityConfigVo;
|
||||||
|
import org.springframework.security.core.parameters.P;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.service.impl
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 19:42
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class QualityConfigServiceimpl extends BaseServiceImpl<QualityConfigDao, QualityConfigEntity> implements QualityConfigService {
|
||||||
|
private final QuartzDataGovernanceQualityApi quartzDataGovernanceQualityApi;
|
||||||
|
private final MetadataDao metadataDao;
|
||||||
|
@Override
|
||||||
|
public PageResult<QualityConfigVo> page(QualityConfigQuery query) {
|
||||||
|
IPage<QualityConfigEntity> page=baseMapper.selectPage(getPage(query),getWrapper(query));
|
||||||
|
return new PageResult<>(QualityConfigConvert.INSTANCE.convertList(page.getRecords()),page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QualityConfigVo get(Long id) {
|
||||||
|
QualityConfigVo qualityConfigvo= QualityConfigConvert.INSTANCE.convert(baseMapper.selectById(id));
|
||||||
|
List<Integer> metadataIds=qualityConfigvo.getMetadataIds();
|
||||||
|
LambdaQueryWrapper<MetadataEntity> metadataWrapper= Wrappers.lambdaQuery();
|
||||||
|
metadataWrapper.in(MetadataEntity::getId,metadataIds);
|
||||||
|
List<MetadataEntity> metadataEntities=metadataDao.selectList(metadataWrapper);
|
||||||
|
if (CollectionUtils.isEmpty(metadataEntities)){
|
||||||
|
qualityConfigvo.setMetadataStrs("检测字段已删除,请检查数据信息");
|
||||||
|
}else {
|
||||||
|
qualityConfigvo.setMetadataStrs(metadataEntities.stream().map(MetadataEntity::getPath).collect(Collectors.joining(";")));
|
||||||
|
}
|
||||||
|
if (BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(qualityConfigvo.getRuleId())){
|
||||||
|
QualityConfigParam param = qualityConfigvo.getParam();
|
||||||
|
Integer columnMetaId = param.getColumnMetaId();
|
||||||
|
MetadataEntity entity = metadataDao.selectById(columnMetaId);
|
||||||
|
if (entity!= null){
|
||||||
|
qualityConfigvo.setRelMetadataStr(entity.getPath());
|
||||||
|
}else {
|
||||||
|
qualityConfigvo.setMetadataStrs("关联字段已被删除,请检查元数据信息");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return qualityConfigvo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(QualityConfigVo vo) {
|
||||||
|
QualityConfigEntity entity=QualityConfigConvert.INSTANCE.convert(vo);
|
||||||
|
entity.setProjectId(getProjectId());
|
||||||
|
if (!BuiltInQualityRule.UNIQUENESS.getId().equals(entity.getRuleId())&&!BuiltInQualityRule.LENGTH_CHECK.getId().equals(entity.getRuleId())&& !BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(entity.getRuleId())&&!BuiltInQualityRule.TIMELINESS.getId().equals(entity.getRuleId())){
|
||||||
|
entity.setParam(null);
|
||||||
|
}
|
||||||
|
baseMapper.insert(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(QualityConfigVo vo) {
|
||||||
|
if (!BuiltInQualityRule.UNIQUENESS.getId().equals(vo.getRuleId())&&!BuiltInQualityRule.LENGTH_CHECK.getId().equals(vo.getRuleId())&&!BuiltInQualityRule.ASSOCIATION_CONSISTENCY.getId().equals(vo.getRuleId())&&!BuiltInQualityRule.TIMELINESS.getId().equals(vo.getRuleId())){
|
||||||
|
vo.setParam(null);
|
||||||
|
}
|
||||||
|
QualityConfigEntity entity=QualityConfigConvert.INSTANCE.convert(vo);
|
||||||
|
entity.setProjectId(getProjectId());
|
||||||
|
updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void online(Long id) {
|
||||||
|
QualityConfigEntity entity=baseMapper.selectById(id);
|
||||||
|
entity.setStatus(1);
|
||||||
|
quartzDataGovernanceQualityApi.release(id);
|
||||||
|
baseMapper.updateById(entity);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void offline(Long id) {
|
||||||
|
QualityConfigEntity entity=baseMapper.selectById(id);
|
||||||
|
entity.setStatus(0);
|
||||||
|
quartzDataGovernanceQualityApi.cancel(id);
|
||||||
|
baseMapper.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handRun(Long id) {
|
||||||
|
quartzDataGovernanceQualityApi.handRun(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(List<Long> idList) {
|
||||||
|
for (Long id : idList) {
|
||||||
|
quartzDataGovernanceQualityApi.cancel(id);
|
||||||
|
}
|
||||||
|
removeByIds(idList);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private LambdaQueryWrapper<QualityConfigEntity> getWrapper(QualityConfigQuery query) {
|
||||||
|
LambdaQueryWrapper<QualityConfigEntity> wrapper= Wrappers.lambdaQuery();
|
||||||
|
wrapper.eq(query.getCategoryId()!=null,QualityConfigEntity::getCategoryId,query.getCategoryId())
|
||||||
|
.like(StringUtil.isNotBlank(query.getName()),QualityConfigEntity::getName,query.getName())
|
||||||
|
.eq(query.getStatus()!=null,QualityConfigEntity::getStatus,query.getStatus())
|
||||||
|
.eq(query.getTaskType()!=null,QualityConfigEntity::getTaskType,query.getTaskType())
|
||||||
|
.orderByDesc(QualityConfigEntity::getId );
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,84 @@
|
||||||
|
package net.srt.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.srt.framework.common.utils.DateUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.vo
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 15:37
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "数据治理-元数据")
|
||||||
|
public class MetadataVo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "主键id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@Schema(description = "父级id(默认0为顶级)")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
|
@Schema(description = "树状节点的路径")
|
||||||
|
private String path;
|
||||||
|
|
||||||
|
@Schema(description = "节点名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "节点英文名称")
|
||||||
|
private String code;
|
||||||
|
|
||||||
|
private String icon;
|
||||||
|
|
||||||
|
private Integer ifLeaf;
|
||||||
|
|
||||||
|
@Schema(description = "对应的元模型id")
|
||||||
|
private Long metamodelId;
|
||||||
|
|
||||||
|
@Schema(description = "详情")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "数据库类型(1-数据库 2-中台库)")
|
||||||
|
private Integer dbType;
|
||||||
|
|
||||||
|
@Schema(description = "如果是外部系统接入的库表,需要此字段")
|
||||||
|
private Long datasourceId;
|
||||||
|
|
||||||
|
@Schema(description = "采集任务id")
|
||||||
|
private Long collectTaskId;
|
||||||
|
|
||||||
|
@Schema(description = "项目id(租户id)")
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
private Integer orderNo;
|
||||||
|
|
||||||
|
@Schema(description = "版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
@Schema(description = "删除标识 0:正常 1:已删除")
|
||||||
|
private Integer deleted;
|
||||||
|
|
||||||
|
@Schema(description = "创建者")
|
||||||
|
private Long creator;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Schema(description = "更新者")
|
||||||
|
private Long updater;
|
||||||
|
|
||||||
|
@Schema(description = "更新时间")
|
||||||
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
@Schema(description = "元数据属性列表")
|
||||||
|
private List<MetamodelPropertyVO> properties;
|
||||||
|
}
|
|
@ -0,0 +1,81 @@
|
||||||
|
package net.srt.vo;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.srt.api.module.data.governance.dto.quality.QualityConfigParam;
|
||||||
|
import net.srt.framework.common.utils.DateUtils;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @BelongsProject: srt_cloud
|
||||||
|
* @BelongsPackage: net.srt.vo
|
||||||
|
* @Author: jpz
|
||||||
|
* @CreateTime: 2023/12/24 19:35
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Schema(description = "数据治理-质量规则配置")
|
||||||
|
public class QualityConfigVo implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Schema(description = "自增id")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long categoryId;
|
||||||
|
|
||||||
|
@Schema(description = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "规则id")
|
||||||
|
private Integer ruleId;
|
||||||
|
|
||||||
|
@Schema(description = "个性化参数json")
|
||||||
|
private QualityConfigParam param;
|
||||||
|
@Schema(description = "当选择的规则类型为关联一致性的时候,返回此字段(前台用)")
|
||||||
|
private String relMetadataStr;
|
||||||
|
|
||||||
|
@Schema(description = "元数据字段列表")
|
||||||
|
private List<Integer> metadataIds;
|
||||||
|
@Schema(description = "检测的元数据字段信息字符串(前台用)")
|
||||||
|
private String metadataStrs;
|
||||||
|
|
||||||
|
@Schema(description = "状态,1-启用,0-关闭")
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
@Schema(description = "任务类型,1-一次性任务,2-周期任务")
|
||||||
|
private Integer taskType;
|
||||||
|
|
||||||
|
@Schema(description = "cron表达式")
|
||||||
|
private String cron;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String note;
|
||||||
|
|
||||||
|
@Schema(description = "项目id")
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
@Schema(description = "版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
@Schema(description = "删除标识 0:正常 1:已删除")
|
||||||
|
private Integer deleted;
|
||||||
|
|
||||||
|
@Schema(description = "创建者")
|
||||||
|
private Long creator;
|
||||||
|
|
||||||
|
@Schema(description = "创建时间")
|
||||||
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@Schema(description = "更新者")
|
||||||
|
private Long updater;
|
||||||
|
|
||||||
|
@Schema(description = "更新时间")
|
||||||
|
@JsonFormat(pattern = DateUtils.DATE_TIME_PATTERN)
|
||||||
|
private Date updateTime;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,12 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="net.srt.dao.MetadataPropertyDao">
|
||||||
|
|
||||||
|
|
||||||
|
<select id="listPropertyById" resultType="net.srt.vo.MetamodelPropertyVO">
|
||||||
|
SELECT mo.id,mo.metamodel_id,mo.id AS metamodel_property_id,mo.name,mo.code,mo.data_type,mo.data_length,mo.input_type,mo.nullable,mo.builtin,md.id as metadata_property_id,md.property as `value` FROM data_governance_metamodel_property mo
|
||||||
|
LEFT JOIN data_governance_metadata_property md ON mo.id=md.metamodel_property_id AND md.metadata_id=#{id}
|
||||||
|
WHERE mo.metamodel_id=#{metamodelId} AND mo.deleted=0 AND md.deleted=0 order by mo.order_no
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,67 @@
|
||||||
|
package net.srt.quartz.api;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import net.srt.api.module.data.governance.DataMetadataCollectApi;
|
||||||
|
import net.srt.api.module.data.governance.constant.MetadataCollectType;
|
||||||
|
import net.srt.api.module.data.governance.dto.DataGovernanceMetadataCollectDto;
|
||||||
|
import net.srt.api.module.quartz.QuartzDataGovernanceMetadataCollectApi;
|
||||||
|
import net.srt.api.module.quartz.constant.QuartzJobType;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import net.srt.quartz.entity.ScheduleJobEntity;
|
||||||
|
import net.srt.quartz.enums.JobGroupEnum;
|
||||||
|
import net.srt.quartz.enums.ScheduleConcurrentEnum;
|
||||||
|
import net.srt.quartz.enums.ScheduleStatusEnum;
|
||||||
|
import net.srt.quartz.service.ScheduleJobService;
|
||||||
|
import net.srt.quartz.utils.ScheduleUtils;
|
||||||
|
import org.quartz.Scheduler;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信服务API
|
||||||
|
*
|
||||||
|
* @author 阿沐 babamu@126.com
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class QuartzDataGovernanceMetadataCollectApiImpl implements QuartzDataGovernanceMetadataCollectApi {
|
||||||
|
|
||||||
|
private final Scheduler scheduler;
|
||||||
|
private final DataMetadataCollectApi dataMetadataCollectApi;
|
||||||
|
private final ScheduleJobService jobService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> release(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
//判断是否存在,不存在,新增,存在,设置主键
|
||||||
|
jobService.buildSystemJob(jobEntity);
|
||||||
|
ScheduleUtils.createScheduleJob(scheduler, jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> cancel(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
jobService.buildSystemJob(jobEntity);
|
||||||
|
ScheduleUtils.deleteScheduleJob(scheduler, jobEntity);
|
||||||
|
//更新任务状态为暂停
|
||||||
|
jobService.pauseSystemJob(jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> handRun(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
jobEntity.setOnce(true);
|
||||||
|
jobEntity.setSaveLog(false);
|
||||||
|
ScheduleUtils.run(scheduler, jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScheduleJobEntity buildJobEntity(Long id) {
|
||||||
|
DataGovernanceMetadataCollectDto collectDto = dataMetadataCollectApi.getById(id).getData();
|
||||||
|
return ScheduleJobEntity.builder().typeId(id).projectId(collectDto.getProjectId()).jobType(QuartzJobType.DATA_GOVERNANCE.getValue()).jobName(String.format("[%s]%s", id.toString(), collectDto.getName())).concurrent(ScheduleConcurrentEnum.NO.getValue())
|
||||||
|
.beanName("dataGovernanceMetadataCollectTask").method("run").jobGroup(JobGroupEnum.DATA_GOVERNANCE.getValue()).saveLog(true).cronExpression(collectDto.getCron()).status(ScheduleStatusEnum.NORMAL.getValue())
|
||||||
|
.params(String.valueOf(id)).once(MetadataCollectType.ONCE.getValue().equals(collectDto.getTaskType())).build();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package net.srt.quartz.api;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import net.srt.api.module.data.governance.DataQualityApi;
|
||||||
|
import net.srt.api.module.data.governance.constant.MetadataCollectType;
|
||||||
|
import net.srt.api.module.data.governance.dto.DataGovernanceQualityConfigDto;
|
||||||
|
import net.srt.api.module.quartz.QuartzDataGovernanceQualityApi;
|
||||||
|
import net.srt.api.module.quartz.constant.QuartzJobType;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import net.srt.quartz.entity.ScheduleJobEntity;
|
||||||
|
import net.srt.quartz.enums.JobGroupEnum;
|
||||||
|
import net.srt.quartz.enums.ScheduleConcurrentEnum;
|
||||||
|
import net.srt.quartz.enums.ScheduleStatusEnum;
|
||||||
|
import net.srt.quartz.service.ScheduleJobService;
|
||||||
|
import net.srt.quartz.utils.ScheduleUtils;
|
||||||
|
import org.quartz.Scheduler;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信服务API
|
||||||
|
*
|
||||||
|
* @author 阿沐 babamu@126.com
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class QuartzDataGovernanceQualityApiImpl implements QuartzDataGovernanceQualityApi {
|
||||||
|
|
||||||
|
private final Scheduler scheduler;
|
||||||
|
private final DataQualityApi dataQualityApi;
|
||||||
|
private final ScheduleJobService jobService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> release(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
//判断是否存在,不存在,新增,存在,设置主键
|
||||||
|
jobService.buildSystemJob(jobEntity);
|
||||||
|
ScheduleUtils.createScheduleJob(scheduler, jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> cancel(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
jobService.buildSystemJob(jobEntity);
|
||||||
|
ScheduleUtils.deleteScheduleJob(scheduler, jobEntity);
|
||||||
|
//更新任务状态为暂停
|
||||||
|
jobService.pauseSystemJob(jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> handRun(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
jobEntity.setOnce(true);
|
||||||
|
jobEntity.setSaveLog(false);
|
||||||
|
ScheduleUtils.run(scheduler, jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScheduleJobEntity buildJobEntity(Long id) {
|
||||||
|
DataGovernanceQualityConfigDto qualityConfigDto = dataQualityApi.getById(id).getData();
|
||||||
|
return ScheduleJobEntity.builder().typeId(id).projectId(qualityConfigDto.getProjectId()).jobType(QuartzJobType.DATA_QUALITY.getValue()).jobName(String.format("[%s]%s", id.toString(), qualityConfigDto.getName())).concurrent(ScheduleConcurrentEnum.NO.getValue())
|
||||||
|
.beanName("dataQualityTask").method("run").jobGroup(JobGroupEnum.DATA_QUALITY.getValue()).saveLog(true).cronExpression(qualityConfigDto.getCron()).status(ScheduleStatusEnum.NORMAL.getValue())
|
||||||
|
.params(String.valueOf(id)).once(MetadataCollectType.ONCE.getValue().equals(qualityConfigDto.getTaskType())).build();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,57 @@
|
||||||
|
package net.srt.quartz.api;
|
||||||
|
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import net.srt.api.module.data.development.DataProductionScheduleApi;
|
||||||
|
import net.srt.api.module.data.development.dto.DataProductionScheduleDto;
|
||||||
|
import net.srt.api.module.quartz.QuartzDataProductionScheduleApi;
|
||||||
|
import net.srt.api.module.quartz.constant.QuartzJobType;
|
||||||
|
import net.srt.framework.common.utils.Result;
|
||||||
|
import net.srt.quartz.entity.ScheduleJobEntity;
|
||||||
|
import net.srt.quartz.enums.JobGroupEnum;
|
||||||
|
import net.srt.quartz.enums.ScheduleConcurrentEnum;
|
||||||
|
import net.srt.quartz.enums.ScheduleStatusEnum;
|
||||||
|
import net.srt.quartz.service.ScheduleJobService;
|
||||||
|
import net.srt.quartz.utils.ScheduleUtils;
|
||||||
|
import org.quartz.Scheduler;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 短信服务API
|
||||||
|
*
|
||||||
|
* @author 阿沐 babamu@126.com
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class QuartzDataProductionScheduleApiImpl implements QuartzDataProductionScheduleApi {
|
||||||
|
|
||||||
|
private final Scheduler scheduler;
|
||||||
|
private final DataProductionScheduleApi scheduleApi;
|
||||||
|
private final ScheduleJobService jobService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> release(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
//判断是否存在,不存在,新增,存在,设置主键
|
||||||
|
jobService.buildSystemJob(jobEntity);
|
||||||
|
ScheduleUtils.createScheduleJob(scheduler, jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Result<String> cancle(Long id) {
|
||||||
|
ScheduleJobEntity jobEntity = buildJobEntity(id);
|
||||||
|
jobService.buildSystemJob(jobEntity);
|
||||||
|
ScheduleUtils.deleteScheduleJob(scheduler, jobEntity);
|
||||||
|
//更新任务状态为暂停
|
||||||
|
jobService.pauseSystemJob(jobEntity);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ScheduleJobEntity buildJobEntity(Long id) {
|
||||||
|
DataProductionScheduleDto scheduleDto = scheduleApi.getById(id).getData();
|
||||||
|
return ScheduleJobEntity.builder().typeId(id).projectId(scheduleDto.getProjectId()).jobType(QuartzJobType.DATA_PRODUCTION.getValue()).jobName(String.format("[%s]%s", id.toString(), scheduleDto.getName())).concurrent(ScheduleConcurrentEnum.NO.getValue())
|
||||||
|
.beanName("dataProductionScheduleTask").method("run").jobGroup(JobGroupEnum.DATA_PRODUCTION.getValue()).saveLog(true).cronExpression(scheduleDto.getCron()).status(ScheduleStatusEnum.NORMAL.getValue())
|
||||||
|
.params(String.valueOf(id)).once(scheduleDto.getIfCycle() == 0).build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,31 +1,10 @@
|
||||||
package net.srt.disposition.dto;
|
package net.srt.disposition.dto;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
/**
|
||||||
import lombok.Data;
|
* @BelongsProject: srt_cloud
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
* @BelongsPackage: net.srt.disposition.dto
|
||||||
|
* @Author: jpz
|
||||||
import java.util.Date;
|
* @CreateTime: 2023/12/23 9:09
|
||||||
|
*/
|
||||||
@Data
|
|
||||||
public class DataProductionTreeDto {
|
public class DataProductionTreeDto {
|
||||||
private Integer id;
|
|
||||||
private Integer parentId;
|
|
||||||
private Integer ifLeaf;
|
|
||||||
private Long taskId;
|
|
||||||
private String taskType;
|
|
||||||
private String parentPath;
|
|
||||||
private String path;
|
|
||||||
private Integer orderNo;
|
|
||||||
private String label;
|
|
||||||
private Long metamodelId;
|
|
||||||
private String name;
|
|
||||||
private String icon;
|
|
||||||
private String code;
|
|
||||||
private Boolean builtin;
|
|
||||||
private String description;
|
|
||||||
private Long projectId;
|
|
||||||
private Integer creator;
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
|
||||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
|
|
||||||
private Date creatTime;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class DataProductionServiceImpl extends BaseServiceImpl<DataProductionMap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static List<DataProductionTreeVo> getChild(Long id, List<DataProductionTreeVo> nodeVos) {
|
private static List<DataProductionTreeVo> getChild(Integer id, List<DataProductionTreeVo> nodeVos) {
|
||||||
// 子菜单
|
// 子菜单
|
||||||
List<DataProductionTreeVo> childList = new ArrayList<>(10);
|
List<DataProductionTreeVo> childList = new ArrayList<>(10);
|
||||||
for (DataProductionTreeVo node : nodeVos) {
|
for (DataProductionTreeVo node : nodeVos) {
|
||||||
|
|
Loading…
Reference in New Issue