Commit ec56b184 by yuwei

项目初始化

parent dea3a460
......@@ -31,7 +31,7 @@ public class CheckRuleDto implements Serializable {
@ApiModelProperty(value = "规则类型")
private String ruleTypeId;
@ApiModelProperty(value = "规则级别(3高、2中、1低)")
private String ruleLevel;
private String ruleLevelId;
@ApiModelProperty(value = "数据源主键")
private String ruleSourceId;
@ApiModelProperty(value = "数据源")
......
......@@ -42,6 +42,9 @@ public class CheckRuleEntity extends DataScopeBaseEntity {
/**
* 规则级别(3高、2中、1低)
*/
private String ruleLevelId;
@TableField(exist = false)
private String ruleLevel;
/**
......
package cn.datax.service.data.quality.api.entity;
import lombok.Data;
import java.io.Serializable;
@Data
public class DataReportEntity implements Serializable {
private static final long serialVersionUID=1L;
private String ruleTypeId;
private String ruleTypeName;
private String ruleId;
private String ruleName;
private String ruleSourceId;
private String ruleSourceName;
private String ruleLevelId;
private String ruleLevelName;
private Integer checkErrorCount;
}
package cn.datax.service.data.quality.api.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.experimental.Accessors;
import java.io.Serializable;
/**
* <p>
* 规则级别信息表
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
@Data
@Accessors(chain = true)
@TableName("quality_rule_level")
public class RuleLevelEntity implements Serializable {
private static final long serialVersionUID=1L;
/**
* 主键
*/
@TableId(value = "id", type = IdType.ASSIGN_ID)
private String id;
/**
* 规则级别编码
*/
private String code;
/**
* 规则级别名称
*/
private String name;
}
package cn.datax.service.data.quality.api.query;
import cn.datax.common.base.BaseQueryParams;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* <p>
* 规则级别信息表 查询实体
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class RuleLevelQuery extends BaseQueryParams {
private static final long serialVersionUID=1L;
}
......@@ -27,6 +27,7 @@ public class CheckRuleVo implements Serializable {
private String ruleName;
private String ruleTypeId;
private String ruleType;
private String ruleLevelId;
private String ruleLevel;
private String ruleSourceId;
private String ruleSource;
......
package cn.datax.service.data.quality.api.vo;
import lombok.Data;
import java.io.Serializable;
/**
* <p>
* 规则级别信息表 实体VO
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
@Data
public class RuleLevelVo implements Serializable {
private static final long serialVersionUID=1L;
private String id;
private String code;
private String name;
}
......@@ -3,6 +3,7 @@ package cn.datax.service.data.quality.controller;
import cn.datax.common.core.JsonPage;
import cn.datax.common.core.R;
import cn.datax.service.data.quality.api.entity.CheckReportEntity;
import cn.datax.service.data.quality.api.entity.DataReportEntity;
import cn.datax.service.data.quality.api.vo.CheckReportVo;
import cn.datax.service.data.quality.api.query.CheckReportQuery;
import cn.datax.service.data.quality.mapstruct.CheckReportMapper;
......@@ -81,4 +82,16 @@ public class CheckReportController extends BaseController {
JsonPage<CheckReportVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
return R.ok().setData(jsonPage);
}
@GetMapping("/getReportBySource")
public R getReportBySource() {
List<DataReportEntity> list = checkReportService.getReportBySource();
return R.ok().setData(list);
}
@GetMapping("/getReportByType")
public R getReportByType() {
List<DataReportEntity> list = checkReportService.getReportByType();
return R.ok().setData(list);
}
}
package cn.datax.service.data.quality.controller;
import cn.datax.common.core.JsonPage;
import cn.datax.common.core.R;
import cn.datax.service.data.quality.api.entity.RuleLevelEntity;
import cn.datax.service.data.quality.api.vo.RuleLevelVo;
import cn.datax.service.data.quality.api.query.RuleLevelQuery;
import cn.datax.service.data.quality.mapstruct.RuleLevelMapper;
import cn.datax.service.data.quality.service.RuleLevelService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import cn.datax.common.base.BaseController;
import java.util.List;
import java.util.stream.Collectors;
/**
* <p>
* 规则级别信息表 前端控制器
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
@Api(tags = {"规则级别信息表"})
@RestController
@RequestMapping("/ruleLevels")
public class RuleLevelController extends BaseController {
@Autowired
private RuleLevelService ruleLevelService;
@Autowired
private RuleLevelMapper ruleLevelMapper;
/**
* 通过ID查询信息
*
* @param id
* @return
*/
@ApiOperation(value = "获取详细信息", notes = "根据url的id来获取详细信息")
@ApiImplicitParam(name = "id", value = "ID", required = true, dataType = "String", paramType = "path")
@GetMapping("/{id}")
public R getRuleLevelById(@PathVariable String id) {
RuleLevelEntity ruleLevelEntity = ruleLevelService.getRuleLevelById(id);
return R.ok().setData(ruleLevelMapper.toVO(ruleLevelEntity));
}
@ApiOperation(value = "获取列表", notes = "")
@GetMapping("/list")
public R getRuleTypeList() {
List<RuleLevelEntity> list = ruleLevelService.list(Wrappers.emptyWrapper());
return R.ok().setData(list);
}
/**
* 分页查询信息
*
* @param ruleLevelQuery
* @return
*/
@ApiOperation(value = "分页查询", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "ruleLevelQuery", value = "查询实体ruleLevelQuery", required = true, dataTypeClass = RuleLevelQuery.class)
})
@GetMapping("/page")
public R getRuleLevelPage(RuleLevelQuery ruleLevelQuery) {
QueryWrapper<RuleLevelEntity> queryWrapper = new QueryWrapper<>();
IPage<RuleLevelEntity> page = ruleLevelService.page(new Page<>(ruleLevelQuery.getPageNum(), ruleLevelQuery.getPageSize()), queryWrapper);
List<RuleLevelVo> collect = page.getRecords().stream().map(ruleLevelMapper::toVO).collect(Collectors.toList());
JsonPage<RuleLevelVo> jsonPage = new JsonPage<>(page.getCurrent(), page.getSize(), page.getTotal(), collect);
return R.ok().setData(jsonPage);
}
}
......@@ -2,12 +2,15 @@ package cn.datax.service.data.quality.dao;
import cn.datax.common.base.BaseDao;
import cn.datax.service.data.quality.api.entity.CheckReportEntity;
import cn.datax.service.data.quality.api.entity.DataReportEntity;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
* 核查报告信息表 Mapper 接口
......@@ -21,4 +24,8 @@ public interface CheckReportDao extends BaseDao<CheckReportEntity> {
@Override
<E extends IPage<CheckReportEntity>> E selectPage(E page, @Param(Constants.WRAPPER) Wrapper<CheckReportEntity> queryWrapper);
List<DataReportEntity> getReportBySource();
List<DataReportEntity> getReportByType();
}
package cn.datax.service.data.quality.dao;
import cn.datax.common.base.BaseDao;
import cn.datax.service.data.quality.api.entity.RuleLevelEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* 规则级别信息表 Mapper 接口
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
@Mapper
public interface RuleLevelDao extends BaseDao<RuleLevelEntity> {
}
package cn.datax.service.data.quality.mapstruct;
import cn.datax.service.data.quality.api.entity.RuleLevelEntity;
import cn.datax.service.data.quality.api.vo.RuleLevelVo;
import org.mapstruct.Mapper;
import java.util.List;
/**
* <p>
* 规则级别信息表 Mapper 实体映射
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
@Mapper(componentModel = "spring")
public interface RuleLevelMapper {
/**
* 将源对象转换为VO对象
* @param e
* @return D
*/
RuleLevelVo toVO(RuleLevelEntity e);
/**
* 将源对象集合转换为VO对象集合
* @param es
* @return List<D>
*/
List<RuleLevelVo> toVO(List<RuleLevelEntity> es);
}
......@@ -45,7 +45,6 @@ public class QualityTask {
private ScheduleLogService scheduleLogService;
public void task(Map<String, Object> map) {
System.out.println("执行参数:" + map);
// 结果集
List<CheckReportEntity> result = new ArrayList<>();
// 获取可执行的核查规则
......@@ -68,7 +67,6 @@ public class QualityTask {
// 关闭线程池
threadPoolExecutor.shutdown();
// 核查报告
System.out.println(result);
result.stream().forEach(s -> {
// 插入核查结果正常的数据
String status = StrUtil.isBlank(s.getCheckResult()) ? DataConstant.TrueOrFalse.TRUE.getKey() : DataConstant.TrueOrFalse.FALSE.getKey();
......
......@@ -28,10 +28,6 @@ public class TaskHander implements Runnable {
private List<CheckReportEntity> list;
public TaskHander() {
super();
}
public TaskHander(MetadataSourceServiceFeign metadataSourceServiceFeign, DataSourceFactory dataSourceFactory, CheckRuleEntity checkRuleEntity, List<CheckReportEntity> list) {
super();
this.metadataSourceServiceFeign = metadataSourceServiceFeign;
......@@ -42,7 +38,6 @@ public class TaskHander implements Runnable {
@Override
public void run() {
System.out.println(Thread.currentThread().getName() + "线程执行开始");
CheckReportEntity checkReportEntity = new CheckReportEntity();
checkReportEntity.setCheckRuleId(checkRuleEntity.getId());
checkReportEntity.setCheckDate(LocalDateTime.now());
......@@ -97,6 +92,5 @@ public class TaskHander implements Runnable {
throw new DataException("释放数据库连接出错");
}
}
System.out.println(Thread.currentThread().getName() + "线程执行结束");
}
}
......@@ -2,6 +2,9 @@ package cn.datax.service.data.quality.service;
import cn.datax.service.data.quality.api.entity.CheckReportEntity;
import cn.datax.common.base.BaseService;
import cn.datax.service.data.quality.api.entity.DataReportEntity;
import java.util.List;
/**
* <p>
......@@ -14,4 +17,16 @@ import cn.datax.common.base.BaseService;
public interface CheckReportService extends BaseService<CheckReportEntity> {
CheckReportEntity getCheckReportById(String id);
/**
* 按数据源统计
* @return
*/
List<DataReportEntity> getReportBySource();
/**
* 按规则类型统计
* @return
*/
List<DataReportEntity> getReportByType();
}
package cn.datax.service.data.quality.service;
import cn.datax.service.data.quality.api.entity.RuleLevelEntity;
import cn.datax.common.base.BaseService;
/**
* <p>
* 规则级别信息表 服务类
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
public interface RuleLevelService extends BaseService<RuleLevelEntity> {
RuleLevelEntity getRuleLevelById(String id);
}
package cn.datax.service.data.quality.service.impl;
import cn.datax.service.data.quality.api.entity.CheckReportEntity;
import cn.datax.service.data.quality.api.entity.DataReportEntity;
import cn.datax.service.data.quality.api.entity.RuleLevelEntity;
import cn.datax.service.data.quality.dao.RuleLevelDao;
import cn.datax.service.data.quality.service.CheckReportService;
import cn.datax.service.data.quality.mapstruct.CheckReportMapper;
import cn.datax.service.data.quality.dao.CheckReportDao;
import cn.datax.common.base.BaseServiceImpl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 核查报告信息表 服务实现类
......@@ -28,9 +35,47 @@ public class CheckReportServiceImpl extends BaseServiceImpl<CheckReportDao, Chec
@Autowired
private CheckReportMapper checkReportMapper;
@Autowired
private RuleLevelDao ruleLevelDao;
@Override
public CheckReportEntity getCheckReportById(String id) {
CheckReportEntity checkReportEntity = super.getById(id);
return checkReportEntity;
}
@Override
public List<DataReportEntity> getReportBySource() {
List<RuleLevelEntity> ruleLevelList = ruleLevelDao.selectList(Wrappers.emptyWrapper());
List<DataReportEntity> list = checkReportDao.getReportBySource();
// 补全数据
List<DataReportEntity> differenceReportList = new ArrayList<>();
// 补全数据源分组缺失的规则级别数据
Map<String, List<DataReportEntity>> sourceMap = list.stream().collect(Collectors.groupingBy(DataReportEntity::getRuleSourceId));
Iterator<Map.Entry<String, List<DataReportEntity>>> sourceIterator = sourceMap.entrySet().iterator();
while (sourceIterator.hasNext()) {
Map.Entry<String, List<DataReportEntity>> sourceEntry = sourceIterator.next();
List<DataReportEntity> entryValue = sourceEntry.getValue();
DataReportEntity dataReportEntity = entryValue.get(0);
// 差集 (ruleLevelList - entryValue)
ruleLevelList.stream().filter(item -> entryValue.stream().map(DataReportEntity::getRuleLevelId).noneMatch(id -> Objects.equals(item.getId(), id)))
.forEach(s -> {
DataReportEntity report = new DataReportEntity();
report.setRuleSourceId(dataReportEntity.getRuleSourceId());
report.setRuleSourceName(dataReportEntity.getRuleSourceName());
report.setRuleLevelId(s.getId());
report.setRuleLevelName(s.getName());
report.setCheckErrorCount(0);
differenceReportList.add(report);
});
}
list.addAll(differenceReportList);
return list;
}
@Override
public List<DataReportEntity> getReportByType() {
List<DataReportEntity> list = checkReportDao.getReportByType();
return list;
}
}
package cn.datax.service.data.quality.service.impl;
import cn.datax.service.data.quality.api.entity.RuleLevelEntity;
import cn.datax.service.data.quality.service.RuleLevelService;
import cn.datax.service.data.quality.mapstruct.RuleLevelMapper;
import cn.datax.service.data.quality.dao.RuleLevelDao;
import cn.datax.common.base.BaseServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
/**
* <p>
* 规则级别信息表 服务实现类
* </p>
*
* @author yuwei
* @since 2020-10-14
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
public class RuleLevelServiceImpl extends BaseServiceImpl<RuleLevelDao, RuleLevelEntity> implements RuleLevelService {
@Autowired
private RuleLevelDao ruleLevelDao;
@Autowired
private RuleLevelMapper ruleLevelMapper;
@Override
public RuleLevelEntity getRuleLevelById(String id) {
RuleLevelEntity ruleLevelEntity = super.getById(id);
return ruleLevelEntity;
}
}
......@@ -41,4 +41,35 @@
${ew.customSqlSegment}
</select>
<resultMap id="ReportResultMap" type="cn.datax.service.data.quality.api.entity.DataReportEntity">
<result column="rule_type_id" property="ruleTypeId" />
<result column="rule_type_name" property="ruleTypeName" />
<result column="rule_id" property="ruleId" />
<result column="rule_name" property="ruleName" />
<result column="rule_source_id" property="ruleSourceId" />
<result column="rule_source_name" property="ruleSourceName" />
<result column="rule_level_id" property="ruleLevelId" />
<result column="rule_level_name" property="ruleLevelName" />
<result column="check_error_count" property="checkErrorCount" />
</resultMap>
<select id="getReportBySource" resultMap="ReportResultMap">
SELECT temp.*, l.name AS rule_level_name from (
SELECT r.rule_source_id, r.rule_source AS rule_source_name, r.rule_level_id,
COALESCE(SUM(t.check_error_count), 0) AS check_error_count
FROM quality_check_rule r
LEFT JOIN quality_check_report t ON t.check_batch = r.last_check_batch AND t.check_rule_id = r.id
GROUP BY r.rule_source_id, r.rule_source, r.rule_level_id
) temp LEFT JOIN quality_rule_level l ON l.id = temp.rule_level_id
</select>
<select id="getReportByType" resultMap="ReportResultMap">
SELECT type.id AS rule_type_id, type.name AS rule_type_name, rule.id AS rule_id, rule.rule_name,
level.id AS rule_level_id, level.name AS rule_level_name, COALESCE(report.check_error_count, 0) AS check_error_count
FROM quality_check_rule rule
LEFT JOIN quality_check_report report ON report.check_batch = rule.last_check_batch and report.check_rule_id = rule.id
LEFT JOIN quality_rule_type type ON type.id = rule.rule_type_id
LEFT JOIN quality_rule_level level ON level.id = rule.rule_level_id
</select>
</mapper>
......@@ -14,7 +14,7 @@
<result column="remark" property="remark" />
<result column="rule_name" property="ruleName" />
<result column="rule_type_id" property="ruleTypeId" />
<result column="rule_level" property="ruleLevel" />
<result column="rule_level_id" property="ruleLevelId" />
<result column="rule_source_id" property="ruleSourceId" />
<result column="rule_source" property="ruleSource" />
<result column="rule_table_id" property="ruleTableId" />
......@@ -29,6 +29,7 @@
<resultMap id="ExtendResultMap" type="cn.datax.service.data.quality.api.entity.CheckRuleEntity" extends="BaseResultMap">
<result column="rule_type" property="ruleType" />
<result column="rule_level" property="ruleLevel" />
</resultMap>
<!-- 通用查询结果列 -->
......@@ -41,7 +42,7 @@
update_by,
update_time,
remark,
rule_name, rule_type_id, rule_level, rule_source_id, rule_source, rule_table_id, rule_table, rule_table_comment
rule_name, rule_type_id, rule_level_id, rule_source_id, rule_source, rule_table_id, rule_table, rule_table_comment
rule_column_id, rule_column, rule_column_comment, rule_sql, last_check_batch
</sql>
......@@ -54,15 +55,16 @@
${alias}.update_by,
${alias}.update_time,
${alias}.remark,
${alias}.rule_name, ${alias}.rule_type_id, ${alias}.rule_level, ${alias}.rule_source_id, ${alias}.rule_source,
${alias}.rule_name, ${alias}.rule_type_id, ${alias}.rule_level_id, ${alias}.rule_source_id, ${alias}.rule_source,
${alias}.rule_table_id, ${alias}.rule_table, ${alias}.rule_table_comment, ${alias}.rule_column_id, ${alias}.rule_column, ${alias}.rule_column_comment, ${alias}.rule_sql, ${alias}.last_check_batch
</sql>
<select id="selectPage" resultMap="ExtendResultMap">
SELECT t.name as rule_type,
SELECT t.name as rule_type, l.name as rule_level
<include refid="Rule_Column_List"><property name="alias" value="r"/></include>
FROM quality_check_rule r
LEFT JOIN quality_rule_type t ON t.id = r.rule_type_id
LEFT JOIN quality_rule_level l ON l.id = r.rule_level_id
${ew.customSqlSegment}
</select>
......
<?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="cn.datax.service.data.quality.dao.RuleLevelDao">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.datax.service.data.quality.api.entity.RuleLevelEntity">
<result column="id" property="id" />
<result column="code" property="code" />
<result column="name" property="name" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id,
code, name
</sql>
</mapper>
......@@ -8,6 +8,14 @@ export function listRuleType(data) {
})
}
export function listRuleLevel(data) {
return request({
url: '/data/quality/ruleLevels/list',
method: 'get',
params: data
})
}
export function pageCheckRule(data) {
return request({
url: '/data/quality/checkRules/page',
......
......@@ -12,14 +12,15 @@
<el-form-item label="规则名称" prop="ruleName">
<el-input v-model="form.ruleName" placeholder="请输入规则名称" />
</el-form-item>
<el-form-item label="规则级别" prop="ruleLevel">
<el-radio-group v-model="form.ruleLevel">
<el-radio
v-for="dict in ruleLevelOptions"
:key="dict.id"
:label="dict.itemText"
>{{ dict.itemValue }}</el-radio>
</el-radio-group>
<el-form-item label="规则级别" prop="ruleLevelId">
<el-select v-model="form.ruleLevelId" placeholder="请选择规则级别">
<el-option
v-for="item in ruleLevelOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="数据源" prop="ruleSourceId">
<el-select v-model="form.ruleSourceId" placeholder="请选择数据源" @change="sourceSelectChanged">
......@@ -74,7 +75,7 @@
</template>
<script>
import { addCheckRule } from '@/api/quality/checkrule'
import { listRuleLevel, addCheckRule } from '@/api/quality/checkrule'
import { listDataSource } from '@/api/metadata/datasource'
import { listDataTable } from '@/api/metadata/datatable'
import { listDataColumn } from '@/api/metadata/datacolumn'
......@@ -109,7 +110,8 @@ export default {
// 表单参数
form: {
ruleName: undefined,
ruleLevel: '1',
ruleTypeId: undefined,
ruleLevelId: undefined,
ruleSourceId: undefined,
ruleSource: undefined,
ruleTableId: undefined,
......@@ -124,6 +126,9 @@ export default {
ruleName: [
{ required: true, message: '规则名称不能为空', trigger: 'blur' }
],
ruleLevelId: [
{ required: true, message: '规则级别不能为空', trigger: 'change' }
],
ruleSourceId: [
{ required: true, message: '数据源不能为空', trigger: 'change' }
],
......@@ -151,17 +156,20 @@ export default {
this.statusOptions = response.data
}
})
this.getDicts('data_check_rule_level').then(response => {
if (response.success) {
this.ruleLevelOptions = response.data
}
})
this.getRuleLevelList()
this.getDataSourceList()
},
methods: {
showCard() {
this.$emit('showCard', this.showOptions)
},
getRuleLevelList() {
listRuleLevel().then(response => {
if (response.success) {
this.ruleLevelOptions = response.data
}
})
},
getDataSourceList() {
listDataSource().then(response => {
if (response.success) {
......
......@@ -12,13 +12,14 @@
<el-input v-model="form.ruleName" />
</el-form-item>
<el-form-item label="规则级别">
<el-radio-group v-model="form.ruleLevel">
<el-radio
v-for="dict in ruleLevelOptions"
:key="dict.id"
:label="dict.itemText"
>{{ dict.itemValue }}</el-radio>
</el-radio-group>
<el-select v-model="form.ruleLevelId">
<el-option
v-for="item in ruleLevelOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="数据源">
<el-select v-model="form.ruleSourceId">
......@@ -73,7 +74,7 @@
</template>
<script>
import { getCheckRule } from '@/api/quality/checkrule'
import { listRuleLevel, getCheckRule } from '@/api/quality/checkrule'
import { listDataSource } from '@/api/metadata/datasource'
import { listDataTable } from '@/api/metadata/datatable'
import { listDataColumn } from '@/api/metadata/datacolumn'
......@@ -117,11 +118,7 @@ export default {
this.statusOptions = response.data
}
})
this.getDicts('data_check_rule_level').then(response => {
if (response.success) {
this.ruleLevelOptions = response.data
}
})
this.getRuleLevelList()
this.getDataSourceList()
},
mounted() {
......@@ -149,6 +146,13 @@ export default {
}
}) || []
},
getRuleLevelList() {
listRuleLevel().then(response => {
if (response.success) {
this.ruleLevelOptions = response.data
}
})
},
getDataSourceList() {
listDataSource().then(response => {
if (response.success) {
......
......@@ -12,14 +12,15 @@
<el-form-item label="规则名称" prop="ruleName">
<el-input v-model="form.ruleName" placeholder="请输入规则名称" />
</el-form-item>
<el-form-item label="规则级别" prop="ruleLevel">
<el-radio-group v-model="form.ruleLevel">
<el-radio
v-for="dict in ruleLevelOptions"
:key="dict.id"
:label="dict.itemText"
>{{ dict.itemValue }}</el-radio>
</el-radio-group>
<el-form-item label="规则级别" prop="ruleLevelId">
<el-select v-model="form.ruleLevelId" placeholder="请选择规则级别">
<el-option
v-for="item in ruleLevelOptions"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
<el-form-item label="数据源" prop="ruleSourceId">
<el-select v-model="form.ruleSourceId" placeholder="请选择数据源" @change="sourceSelectChanged">
......@@ -74,7 +75,7 @@
</template>
<script>
import { getCheckRule, updateCheckRule } from '@/api/quality/checkrule'
import { listRuleLevel, getCheckRule, updateCheckRule } from '@/api/quality/checkrule'
import { listDataSource } from '@/api/metadata/datasource'
import { listDataTable } from '@/api/metadata/datatable'
import { listDataColumn } from '@/api/metadata/datacolumn'
......@@ -113,6 +114,9 @@ export default {
ruleName: [
{ required: true, message: '规则名称不能为空', trigger: 'blur' }
],
ruleLevelId: [
{ required: true, message: '规则级别不能为空', trigger: 'change' }
],
ruleSourceId: [
{ required: true, message: '数据源不能为空', trigger: 'change' }
],
......@@ -139,11 +143,7 @@ export default {
this.statusOptions = response.data
}
})
this.getDicts('data_check_rule_level').then(response => {
if (response.success) {
this.ruleLevelOptions = response.data
}
})
this.getRuleLevelList()
this.getDataSourceList()
},
mounted() {
......@@ -171,6 +171,13 @@ export default {
}
})
},
getRuleLevelList() {
listRuleLevel().then(response => {
if (response.success) {
this.ruleLevelOptions = response.data
}
})
},
getDataSourceList() {
listDataSource().then(response => {
if (response.success) {
......
......@@ -186,7 +186,7 @@ export default {
{ prop: 'ruleSource', label: '数据源', show: true },
{ prop: 'ruleTable', label: '数据表', show: true, formatter: this.ruleTableFormatter },
{ prop: 'ruleColumn', label: '核查字段', show: true, formatter: this.ruleColumnFormatter },
{ prop: 'ruleLevel', label: '规则级别', show: true, formatter: this.ruleLevelFormatter },
{ prop: 'ruleLevel', label: '规则级别', show: true },
{
prop: 'status',
label: '状态',
......@@ -216,9 +216,7 @@ export default {
defaultProps: {
children: 'children',
label: 'name'
},
// 规则级别数据字典
ruleLevelOptions: []
}
}
},
created() {
......@@ -227,11 +225,6 @@ export default {
this.statusOptions = response.data
}
})
this.getDicts('data_check_rule_level').then(response => {
if (response.success) {
this.ruleLevelOptions = response.data
}
})
this.getTree()
this.getList()
},
......@@ -376,16 +369,6 @@ export default {
},
ruleColumnFormatter(row, column, cellValue, index) {
return row.ruleColumnComment ? row.ruleColumn + '(' + row.ruleColumnComment + ')' : row.ruleColumn
},
ruleLevelFormatter(row, column, cellValue, index) {
const dictLabel = this.selectDictLabel(this.ruleLevelOptions, cellValue)
if (cellValue === '1') {
return <el-tag type='success'>{dictLabel}</el-tag>
} else if (cellValue === '2') {
return <el-tag type='warning'>{dictLabel}</el-tag>
} else if (cellValue === '3') {
return <el-tag type='danger'>{dictLabel}</el-tag>
}
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment