Commit c8ead692 authored by mcb's avatar mcb

提交

parent 50ca0000
package com.jz.common.page;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**分页信息封装
* @author ybz
*
*/
@ApiModel(value = "分页参数对象", description = "分页参数对象")
public class BasePageBean {
@ApiModelProperty(value = "当前页码值")
private int pageNum = 1;
@ApiModelProperty(value = "每页条数")
private int pageSize = 10;
public int getPageNum() {
return pageNum;
}
public void setPageNum(int pageNum) {
this.pageNum = pageNum;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
}
package com.jz.common.page;
import com.github.pagehelper.PageInfo;
import com.jz.common.constant.JsonResult;
/**
* @author ybz
*
*/
public class PageInfoResponse<T> extends JsonResult {
private PageInfo<T> data;
public PageInfo<T> getData() {
return data;
}
public void setData(PageInfo<T> data) {
this.data = data;
}
}
package com.jz.dmp.modules.controller.DataIntegration;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import com.jz.dmp.modules.service.AtomBaseCacheService;
import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.HashMap;
import java.util.Map;
/**
* @Description:离线同步
......@@ -30,7 +38,17 @@ public class OfflineSynchController {
*/
@ApiOperation(value = "任务列表分页查询", notes = "任务列表分页查询")
@PostMapping(value = "/taskListPage")
public JsonResult delRedisKeys(@RequestBody @Validated TaskListPageReq taskListPageReq) {
return new JsonResult();
public PageInfoResponse<TaskListPageDto> getTaskListPage(@RequestBody @Validated TaskListPageReq taskListPageReq) {
PageInfoResponse<TaskListPageDto> pageInfo = new PageInfoResponse<TaskListPageDto>();
try {
pageInfo = offlineSynchService.queryTaskListPage(taskListPageReq);
} catch (Exception e) {
pageInfo.setMessage("查询失败");
pageInfo.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return pageInfo;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
/**
* @ClassName: TaskListPageDto
* @Description: 离线同步任务列表返回参数
* @Author
* @Date 2020/12/21
* @Version 1.0
*/
@ApiModel(value = "离线同步--任务列表返回参数对象", description = "任务列表返回参数对象")
public class TaskListPageDto {
/*
* id
* */
@ApiModelProperty(value = "id")
String id;
/*
* treeId
* */
@ApiModelProperty(value = "treeId")
String treeId;
/*
* 同步时间
* */
@ApiModelProperty(value = "同步时间")
String syncTime;
/*
* 同步状态
* */
@ApiModelProperty(value = "同步状态")
String syncResult;
/*
*校验状态
* */
@ApiModelProperty(value = "校验状态")
String chkResult;
/*
* 校验时间
* */
@ApiModelProperty(value = "校验时间")
String chkTime;
/*
* 创建时间
* */
@ApiModelProperty(value = "创建时间")
String creTime;
/*
* 更改时间
* */
@ApiModelProperty(value = "更改时间")
String uptTime;
public String getSyncTime() {
return syncTime;
}
public void setSyncTime(String syncTime) {
this.syncTime = syncTime;
}
public String getSyncResult() {
return syncResult;
}
public void setSyncResult(String syncResult) {
this.syncResult = syncResult;
}
public String getChkResult() {
return chkResult;
}
public void setChkResult(String chkResult) {
this.chkResult = chkResult;
}
public String getChkTime() {
return chkTime;
}
public void setChkTime(String chkTime) {
this.chkTime = chkTime;
}
public String getCreTime() {
return creTime;
}
public void setCreTime(String creTime) {
this.creTime = creTime;
}
public String getUptTime() {
return uptTime;
}
public void setUptTime(String uptTime) {
this.uptTime = uptTime;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getTreeId() {
return treeId;
}
public void setTreeId(String treeId) {
this.treeId = treeId;
}
}
package com.jz.dmp.modules.controller.DataIntegration.bean;
import com.jz.common.page.BasePageBean;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotNull;
/**
......@@ -10,26 +15,46 @@ import javax.validation.constraints.NotNull;
* @Date 2020/12/21
* @Version 1.0
*/
public class TaskListPageReq {
@ApiModel(value = "离线同步--任务列表请求参数对象", description = "任务列表请求参数对象")
public class TaskListPageReq extends BasePageBean {
/*
* 项目ID
* */
@NotNull(message = "项目ID不能空")
@ApiModelProperty(value = "项目ID")
private String projectId;
/*
* 父类ID
* */
//@NotNull(message = "父类ID不能空")
@ApiModelProperty(value = "父类ID")
private String parentId;
/*
* 源数据id
* */
@ApiModelProperty(value = "源数据id")
private String sourceDb;
/*
* 目标数据库id
* */
@ApiModelProperty(value = "目标数据库id")
private String targetDb;
/*
* 源数据库表
* */
@ApiModelProperty(value = "源数据库表")
private String sourceTable;
/*
* 目标数据库表
* */
@ApiModelProperty(value = "目标数据库表")
private String targetTable;
private Integer pageNum = 1;
private Integer pageSize = 30;
public String getProjectId() {
return projectId;
}
......@@ -77,20 +102,4 @@ public class TaskListPageReq {
public void setTargetTable(String targetTable) {
this.targetTable = targetTable;
}
public Integer getPageNum() {
return pageNum;
}
public void setPageNum(Integer pageNum) {
this.pageNum = pageNum;
}
public Integer getPageSize() {
return pageSize;
}
public void setPageSize(Integer pageSize) {
this.pageSize = pageSize;
}
}
package com.jz.dmp.modules.dao;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import java.util.List;
import java.util.Map;
/**
* @author Bellamy
* @since 2020-12-020
*/
public interface OfflineSynchDao {
List<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception;
}
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
/**
* @ClassName: OfflineSynchService
* @Description:
......@@ -8,4 +12,6 @@ package com.jz.dmp.modules.service;
* @Version 1.0
*/
public interface OfflineSynchService {
PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception;
}
package com.jz.dmp.modules.service.impl;
import com.jz.dmp.modules.dao.OfflineSynchDao;
import com.jz.dmp.modules.service.OfflineSynchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @Description:离线同步服务层
* @ClassName: DataGoodsApiParamsServiceImpl
* @Author Bellamy
* @Date 2020/12/20
*/
@Service("offlineSynchService")
@Transactional
public class DataGoodsApiParamsServiceImpl implements OfflineSynchService {
@Autowired
private OfflineSynchDao offlineSynchDao;
}
package com.jz.dmp.modules.service.impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.common.constant.Constants;
import com.jz.common.constant.ResultCode;
import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq;
import com.jz.dmp.modules.dao.OfflineSynchDao;
import com.jz.dmp.modules.service.OfflineSynchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @Description:离线同步服务层
* @ClassName: OfflineSynchServiceImpl
* @Author Bellamy
* @Date 2020/12/20
*/
@Service("offlineSynchService")
@Transactional
public class OfflineSynchServiceImpl implements OfflineSynchService {
@Autowired
private OfflineSynchDao offlineSynchDao;
@Override
public PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception {
PageInfoResponse<TaskListPageDto> pageInfoResponse = new PageInfoResponse<>();
Map param = new HashMap();
//param.put("userId", user.getUserId());
//param.put("pageNum", pageBean.getPageNum());
//param.put("pageSize", pageBean.getPageSize());
PageHelper.startPage(taskListPageReq.getPageNum(), taskListPageReq.getPageSize());
List<TaskListPageDto> list = offlineSynchDao.queryTaskListPage(taskListPageReq);
PageInfo<TaskListPageDto> pageInfo = new PageInfo<>(list);
pageInfoResponse.setCode(ResultCode.SUCCESS);
pageInfoResponse.setMessage("查询成功");
pageInfoResponse.setData(pageInfo);
return pageInfoResponse;
}
}
# 测试环境配置
server:
port: 7180
port: 7181
#contextPath: /resource
management:
......@@ -104,3 +104,15 @@ dmp:
evn:
open: false
name:
#mybatis的配置
#mybatis:
# #配置mapper.xml文件所在路径
# mapper-locations: classpath:mapper.*/*.xml
# #配置映射类所在的包名
# type-aliases-package: com.jz.dmp.modules.model
#日志打印
logging:
level:
com.jz.dmp: debug
<?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.OfflineSynchDao">
<select id="queryTaskListPage" resultType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto"
parameterType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq">
SELECT * FROM (
SELECT cast(ddt.script AS char) AS script,
ddt.chk_result AS chkResult,
ddt.sync_result AS syncResult,
ddt.id AS id,
ddt.tree_id AS treeId,
dnt.name AS treeName,
DATE_FORMAT(ddt.create_time,'%Y-%m-%d %H:%i:%s') AS createTime,
DATE_FORMAT(ddt.update_time ,'%Y-%m-%d %H:%i:%s') AS updateTime,
DATE_FORMAT(ddt.chk_time,'%Y-%m-%d %H:%i:%s') AS chkTime,
DATE_FORMAT(ddt.sync_time,'%Y-%m-%d %H:%i:%s') AS syncTime,
dsdt.datasource_type AS dbType
FROM dmp_develop_task AS ddt
INNER JOIN dmp_navigation_tree AS dnt ON ddt.TREE_ID = dnt.ID
LEFT JOIN dmp_syncing_datasource AS dsd ON
instr(script,concat('"targetDbConnection":"',dsd.datasource_name,'"'))>0
LEFT JOIN dmp_syncing_datasource_type AS dsdt ON dsd.datasource_type = dsdt.id
WHERE ddt.data_status ='1' AND ddt.TYPE='3' AND ddt.TASK_TYPE ='2'
AND dnt.CATEGORY='2' AND dnt.TYPE ='3'
AND dnt.IS_LEVEL ='1'
AND dnt.PROJECT_ID =#{projectId}
AND dsd.PROJECT_ID=#{projectId}
) AS a
WHERE 1=1
<if test="sourceDb !=null and sourceDb !=''">
AND a.SCRIPT LIKE CONCAT('%','"dbConnection":','"',#{sourceDb},'"','%')
</if>
<if test="targetDb !=null and targetDb !=''">
AND a.SCRIPT LIKE CONCAT('%','"targetDbConnection":','"',#{targetDb},'"','%')
</if>
<if test="sourceTable !=null and sourceTable !=''">
AND a.SCRIPT LIKE CONCAT('%','"registerTableName":','"',#{sourceTable},'"','%')
</if>
<if test="targetTable !=null and targetTable !=''">
AND a.SCRIPT LIKE CONCAT('%','"targetTable":','"',#{targetTable},'"','%')
</if>
ORDER BY a.createTime DESC
</select>
</mapper>
\ No newline at end of file
......@@ -16,7 +16,7 @@
<setting name="callSettersOnNulls" value="true"/>
</settings>
<typeAliases>
<package name="cn.jz.tag.modules.model"/>
<package name="com.jz.dmp.modules.model"/>
</typeAliases>
<plugins>
......
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