Commit 8fd23e42 authored by mcb's avatar mcb

校验规则

parent 22caccbc
......@@ -2,6 +2,7 @@ package com.jz.dmp.modules.controller.DataIntegration;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.service.OfflineSynchService;
......@@ -13,6 +14,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -141,6 +143,7 @@ public class OfflineSynchController {
/**
* 获取源表和目标表的字段
*
* @return
*/
@ApiOperation(value = "获取源表和目标表的字段", notes = "获取源表和目标表的字段")
......@@ -149,4 +152,23 @@ public class OfflineSynchController {
JsonResult list = offlineSynchService.querySoureAndTargetColumnsByParams(soureAndTargetColumnsReq);
return list;
}
/**
* 校验规则
*
* @return
*/
@ApiOperation(value = "校验规则", notes = "校验规则")
@PostMapping(value = "/findListJyRule")
public PageInfoResponse<DvRuleTDto> findListJyRule(@RequestBody BasePageBean basePageBean, HttpServletRequest httpRequest) throws Exception {
PageInfoResponse<DvRuleTDto> pageInfo = new PageInfoResponse<DvRuleTDto>();
try {
pageInfo = offlineSynchService.queryJyRuleListPage(basePageBean,httpRequest);
} catch (Exception e) {
pageInfo.setMessage("查询失败");
pageInfo.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return pageInfo;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/**
* @ClassName: DvRuleTDto
* @Description: 校验规则
* @Author:Bellamy
* @Date 2020/12/24
* @Version 1.0
*/
@ApiModel(value = "校验规则返回参数", description = "校验规则")
public class DvRuleTDto implements Serializable {
private static final long serialVersionUID = 6133889347349373723L;
/**
* 规则ID
*/
@ApiModelProperty(value = "规则ID")
private Long ruleId;
/**
* 规则名称
*/
@ApiModelProperty(value = "规则名称")
private String ruleName;
/**
* content(json)
*/
@ApiModelProperty(value = "content(json)")
private String ruleContent;
/**
* 创建时间
*/
@ApiModelProperty(value = "创建时间")
private String createTime;
/**
* 更新时间
*/
@ApiModelProperty(value = "更新时间")
private String updateTime;
/**
* 规则校验JSON
*/
@ApiModelProperty(value = "规则校验JSON")
private JSONObject ruleContentJson;
public Long getRuleId() {
return ruleId;
}
public void setRuleId(Long ruleId) {
this.ruleId = ruleId;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getRuleContent() {
return ruleContent;
}
public void setRuleContent(String ruleContent) {
this.ruleContent = ruleContent;
}
public String getCreateTime() {
return createTime;
}
public void setCreateTime(String createTime) {
this.createTime = createTime;
}
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
public JSONObject getRuleContentJson() {
return ruleContentJson;
}
public void setRuleContentJson(JSONObject ruleContentJson) {
this.ruleContentJson = ruleContentJson;
}
}
package com.jz.dmp.modules.controller;
import com.jz.dmp.modules.model.DvRuleT;
import com.jz.dmp.modules.service.DvRuleTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* ???(DvRuleT)表控制层
*
* @author Bellamy
* @since 2020-12-24 10:56:18
*/
@RestController
@RequestMapping("/dvRuleT")
public class DvRuleTController {
/**
* 服务对象
*/
@Autowired
private DvRuleTService dvRuleTService;
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("selectOne")
public DvRuleT selectOne(Long id) {
return this.dvRuleTService.queryById(id);
}
}
\ No newline at end of file
package com.jz.dmp.modules.dao;
import com.jz.dmp.modules.controller.DataIntegration.bean.DvRuleTDto;
import com.jz.dmp.modules.model.DvRuleT;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* ???(DvRuleT)表数据库访问层
*
* @author Bellamy
* @since 2020-12-24 10:56:17
*/
public interface DvRuleTDao {
/**
* 通过ID查询单条数据
*
* @param ruleId 主键
* @return 实例对象
*/
DvRuleT queryById(Long ruleId);
/**
* 查询指定行数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<DvRuleT> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit);
/**
* 通过实体作为筛选条件查询
*
* @param dvRuleT 实例对象
* @return 对象列表
*/
List<DvRuleT> queryAll(DvRuleT dvRuleT);
/**
* 新增数据
*
* @param dvRuleT 实例对象
* @return 影响行数
*/
int insert(DvRuleT dvRuleT);
/**
* 批量新增数据(MyBatis原生foreach方法)
*
* @param entities List<DvRuleT> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<DvRuleT> entities);
/**
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
*
* @param entities List<DvRuleT> 实例对象列表
* @return 影响行数
*/
int insertOrUpdateBatch(@Param("entities") List<DvRuleT> entities);
/**
* 修改数据
*
* @param dvRuleT 实例对象
* @return 影响行数
*/
int update(DvRuleT dvRuleT);
/**
* 通过主键删除数据
*
* @param ruleId 主键
* @return 影响行数
*/
int deleteById(Long ruleId);
List<DvRuleTDto> queryJyRuleListPage(DvRuleT dvRuleT) throws Exception;
}
\ No newline at end of file
package com.jz.dmp.modules.model;
import java.io.Serializable;
import java.util.Date;
/**
* ???(DvRuleT)实体类
*
* @author makejava
* @since 2020-12-24 10:56:15
*/
public class DvRuleT implements Serializable {
private static final long serialVersionUID = 821364288257644972L;
/**
* 规则ID
*/
private Long ruleId;
/**
* 规则名称
*/
private String ruleName;
/**
* is_opt_field_flag:是否选择字段 is_opt_mult_field_flag:是否选择多字段 is_input_value_flag:是否输入值域数据 is_time_filter_field_flag:是否选择时间过滤
*/
private String ruleContent;
/**
* 是否删除状态 0-删除 1-未删除
*/
private Object delFlag;
/**
* 创建时间
*/
private Date createTime;
/**
* 创建人
*/
private String createBy;
/**
* 最后更新人
*/
private String updateBy;
/**
* 更新时间
*/
private Date updateTime;
public Long getRuleId() {
return ruleId;
}
public void setRuleId(Long ruleId) {
this.ruleId = ruleId;
}
public String getRuleName() {
return ruleName;
}
public void setRuleName(String ruleName) {
this.ruleName = ruleName;
}
public String getRuleContent() {
return ruleContent;
}
public void setRuleContent(String ruleContent) {
this.ruleContent = ruleContent;
}
public Object getDelFlag() {
return delFlag;
}
public void setDelFlag(Object delFlag) {
this.delFlag = delFlag;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getCreateBy() {
return createBy;
}
public void setCreateBy(String createBy) {
this.createBy = createBy;
}
public String getUpdateBy() {
return updateBy;
}
public void setUpdateBy(String updateBy) {
this.updateBy = updateBy;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
}
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.dmp.modules.model.DvRuleT;
import java.util.List;
/**
* ???(DvRuleT)表服务接口
*
* @author Bellamy
* @since 2020-12-24 10:56:17
*/
public interface DvRuleTService {
/**
* 通过ID查询单条数据
*
* @param ruleId 主键
* @return 实例对象
*/
DvRuleT queryById(Long ruleId);
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<DvRuleT> queryAllByLimit(int offset, int limit);
/**
* 新增数据
*
* @param dvRuleT 实例对象
* @return 实例对象
*/
DvRuleT insert(DvRuleT dvRuleT);
/**
* 修改数据
*
* @param dvRuleT 实例对象
* @return 实例对象
*/
DvRuleT update(DvRuleT dvRuleT);
/**
* 通过主键删除数据
*
* @param ruleId 主键
* @return 是否成功
*/
boolean deleteById(Long ruleId);
}
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
......@@ -31,4 +33,6 @@ public interface OfflineSynchService {
PageInfoResponse<CheckJyRlueStatusDto> selectCheckJyStatusInfo(CheckJyRlueStatusReq checkJyRlueStatusReq) throws Exception;
JsonResult querySoureAndTargetColumnsByParams(SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception;
PageInfoResponse<DvRuleTDto> queryJyRuleListPage(BasePageBean basePageBean, HttpServletRequest httpRequest) throws Exception;
}
package com.jz.dmp.modules.service.impl;
import com.jz.dmp.modules.dao.DvRuleTDao;
import com.jz.dmp.modules.model.DvRuleT;
import com.jz.dmp.modules.service.DvRuleTService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* ???(DvRuleT)表服务实现类
*
* @author Bellamy
* @since 2020-12-24 10:56:18
*/
@Service("dvRuleTService")
public class DvRuleTServiceImpl implements DvRuleTService {
@Autowired
private DvRuleTDao dvRuleTDao;
/**
* 通过ID查询单条数据
*
* @param ruleId 主键
* @return 实例对象
*/
@Override
public DvRuleT queryById(Long ruleId) {
return this.dvRuleTDao.queryById(ruleId);
}
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
@Override
public List<DvRuleT> queryAllByLimit(int offset, int limit) {
return this.dvRuleTDao.queryAllByLimit(offset, limit);
}
/**
* 新增数据
*
* @param dvRuleT 实例对象
* @return 实例对象
*/
@Override
public DvRuleT insert(DvRuleT dvRuleT) {
this.dvRuleTDao.insert(dvRuleT);
return dvRuleT;
}
/**
* 修改数据
*
* @param dvRuleT 实例对象
* @return 实例对象
*/
@Override
public DvRuleT update(DvRuleT dvRuleT) {
this.dvRuleTDao.update(dvRuleT);
return this.queryById(dvRuleT.getRuleId());
}
/**
* 通过主键删除数据
*
* @param ruleId 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Long ruleId) {
return this.dvRuleTDao.deleteById(ruleId) > 0;
}
}
\ No newline at end of file
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.agent.service.DmpDsAgentService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService;
import com.jz.common.utils.AzkabanApiUtils2;
......@@ -26,6 +28,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -67,6 +70,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
@Autowired
private DmpTableColumnDao dmpTableColumnDao;
@Autowired
private DvRuleTDao dvRuleTDao;
@Override
public PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception {
PageInfoResponse<TaskListPageDto> pageInfoResponse = new PageInfoResponse<>();
......@@ -316,9 +322,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
DmpTableFieldSchema schema = new DmpTableFieldSchema(); //项目表字段类型
schema.setDsId(Integer.valueOf(dsInfo.getDatasourceTypeId()));
List<DmpTableFieldSchema> sourceFieldSchema = dmpTableFieldSchemaDao.queryAll(schema); //源字段类型
List<DmpTableFieldSchema> sourceFieldSchema = dmpTableFieldSchemaDao.queryAll(schema); //源字段架构
schema.setDsId(Integer.valueOf(dsInfo.getDatasourceTypeId()));
List<DmpTableFieldSchema> targetFieldSchema = dmpTableFieldSchemaDao.queryAll(schema); //目标字段类型
List<DmpTableFieldSchema> targetFieldSchema = dmpTableFieldSchemaDao.queryAll(schema); //目标字段架构
if (sourceFieldSchema != null && sourceFieldSchema.size() > 0) {
Map<String, Integer> ftm = new HashMap<String, Integer>();
for (DmpTableFieldSchema s : sourceFieldSchema) { //便利源字段类型
......@@ -380,14 +386,34 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
targetFieldColumns.add(targetFieldColumn);
}
Map<String, Object> bak = new HashMap<String, Object>();
bak.put("SOURCE_FIELD_SCHEMA", sourceFieldSchema);
bak.put("SOURCE_FIELD_COLUMNS", sourceFieldColumns);
bak.put("TARGET_FIELD_SCHEMA", targetFieldSchema);
bak.put("TARGET_FIELD_COLUMNS", targetFieldColumns);
//bak.put("sourceFieldSchema", sourceFieldSchema);
bak.put("sourceFieldColumns", sourceFieldColumns);
//bak.put("targetFieldSchema", targetFieldSchema);
bak.put("targetFieldColumns", targetFieldColumns);
dmpTableDao.deleteById(table.getId());
dmpTableColumnDao.deleteByTableId(table.getId());
return new JsonResult(ResultCode.SUCCESS, bak);
}
@Override
public PageInfoResponse<DvRuleTDto> queryJyRuleListPage(BasePageBean basePageBean, HttpServletRequest httpRequest) throws Exception {
PageInfoResponse<DvRuleTDto> pageInfoResponse = new PageInfoResponse<>();
PageHelper.startPage(basePageBean.getPageNum(), basePageBean.getPageSize());
DvRuleT dvRuleT = new DvRuleT();
List<DvRuleTDto> list = dvRuleTDao.queryJyRuleListPage(dvRuleT);
if (list.size() > 0 && list != null) {
for(DvRuleTDto dto : list){
dto.setRuleContentJson(JSON.parseObject(dto.getRuleContent()));
}
}
PageInfo<DvRuleTDto> pageInfo = new PageInfo<>(list);
pageInfoResponse.setCode(ResultCode.SUCCESS);
pageInfoResponse.setMessage("查询成功");
pageInfoResponse.setData(pageInfo);
return pageInfoResponse;
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jz.dmp.modules.dao.DvRuleTDao">
<resultMap type="com.jz.dmp.modules.model.DvRuleT" id="DvRuleTMap">
<result property="ruleId" column="rule_id" jdbcType="INTEGER"/>
<result property="ruleName" column="rule_name" jdbcType="VARCHAR"/>
<result property="ruleContent" column="rule_content" jdbcType="VARCHAR"/>
<result property="delFlag" column="del_flag" jdbcType="OTHER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="createBy" column="create_by" jdbcType="VARCHAR"/>
<result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<!--查询单个-->
<select id="queryById" resultMap="DvRuleTMap">
select
rule_id, rule_name, rule_content, del_flag, create_time, create_by, update_by, update_time
from dv_rule_t
where rule_id = #{ruleId}
</select>
<!--查询指定行数据-->
<select id="queryAllByLimit" resultMap="DvRuleTMap">
select
rule_id, rule_name, rule_content, del_flag, create_time, create_by, update_by, update_time
from dv_rule_t
limit #{offset}, #{limit}
</select>
<!--通过实体作为筛选条件查询-->
<select id="queryAll" resultMap="DvRuleTMap">
select
rule_id, rule_name, rule_content, del_flag, create_time, create_by, update_by, update_time
from dv_rule_t
<where>
<if test="ruleId != null">
and rule_id = #{ruleId}
</if>
<if test="ruleName != null and ruleName != ''">
and rule_name = #{ruleName}
</if>
<if test="ruleContent != null and ruleContent != ''">
and rule_content = #{ruleContent}
</if>
<if test="delFlag != null">
and del_flag = #{delFlag}
</if>
<if test="createTime != null">
and create_time = #{createTime}
</if>
<if test="createBy != null and createBy != ''">
and create_by = #{createBy}
</if>
<if test="updateBy != null and updateBy != ''">
and update_by = #{updateBy}
</if>
<if test="updateTime != null">
and update_time = #{updateTime}
</if>
</where>
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="ruleId" useGeneratedKeys="true">
insert into dv_rule_t(rule_name, rule_content, del_flag, create_time, create_by, update_by, update_time)
values (#{ruleName}, #{ruleContent}, #{delFlag}, #{createTime}, #{createBy}, #{updateBy}, #{updateTime})
</insert>
<insert id="insertBatch" keyProperty="ruleId" useGeneratedKeys="true">
insert into dv_rule_t(rule_name, rule_content, del_flag, create_time, create_by, update_by, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.ruleName}, #{entity.ruleContent}, #{entity.delFlag}, #{entity.createTime}, #{entity.createBy},
#{entity.updateBy}, #{entity.updateTime})
</foreach>
</insert>
<insert id="insertOrUpdateBatch" keyProperty="ruleId" useGeneratedKeys="true">
insert into dv_rule_t(rule_name, rule_content, del_flag, create_time, create_by, update_by, update_time)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.ruleName}, #{entity.ruleContent}, #{entity.delFlag}, #{entity.createTime}, #{entity.createBy},
#{entity.updateBy}, #{entity.updateTime})
</foreach>
on duplicate key update
rule_name = values(rule_name) , rule_content = values(rule_content) , del_flag = values(del_flag) , create_time
= values(create_time) , create_by = values(create_by) , update_by = values(update_by) , update_time =
values(update_time)
</insert>
<!--通过主键修改数据-->
<update id="update">
update dv_rule_t
<set>
<if test="ruleName != null and ruleName != ''">
rule_name = #{ruleName},
</if>
<if test="ruleContent != null and ruleContent != ''">
rule_content = #{ruleContent},
</if>
<if test="delFlag != null">
del_flag = #{delFlag},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="createBy != null and createBy != ''">
create_by = #{createBy},
</if>
<if test="updateBy != null and updateBy != ''">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</set>
where rule_id = #{ruleId}
</update>
<!--通过主键删除-->
<delete id="deleteById">
delete from dv_rule_t where rule_id = #{ruleId}
</delete>
<!--通过实体作为筛选条件查询-->
<select id="queryJyRuleListPage" resultType="com.jz.dmp.modules.controller.DataIntegration.bean.DvRuleTDto" parameterType="dvRuleT">
select
rule_id as ruleId,
rule_name as ruleName,
rule_content as ruleContent,
date_format(create_time,'%Y-%m-%d %H:%i:%s') as createTime,
date_format(update_time,'%Y-%m-%d %H:%i:%s') as updateTime
from dv_rule_t
<where>
<if test="ruleId != null"> and rule_id = #{ruleId} </if>
<if test="ruleName != null and ruleName != ''"> and rule_name = #{ruleName} </if>
<if test="ruleContent != null and ruleContent != ''"> and rule_content = #{ruleContent} </if>
</where>
</select>
</mapper>
\ No newline at end of file
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