Commit 2ad4f2a4 authored by mcb's avatar mcb

no message

parent e0fbe06a
package com.jz.common.utils.web;
import com.jz.common.utils.StringUtils;
/**
* Xml文件内容辅助工具类
*/
public class XmlUtils {
/**
* 获取xml属性值(多个取第一个)
*
* @param content xml内容
* @param property 属性名(标签)
* @return 属性值
*/
public static String getPropertyValue(Object content, String property) {
if (null != content && StringUtils.hasLength(content.toString()) && StringUtils.isNotBlank(property)) {
String tagBegin = "<" + property + ">";
String tagEnd = "</" + property + ">";
String ct = content.toString();
int bi = ct.indexOf(tagBegin) + tagBegin.length();
int ei = ct.indexOf(tagEnd);
if (bi != -1 && ei != -1)
return StringUtils.toTrimString(ct.substring(bi, ei));
}
return "";
}
public static void main(String[] args) {
String content = "<target_insert_merge_overwrite>merge</target_insert_merge_overwrite>" +
" <target_db_connection>kudu_tmp</target_db_connection>\n" +
" <target_database>tmp</target_database>\n" +
" <target_table>impala::tmp.rzf_report_rzfyinliu\n" +
" <target_primary_columns></target_table></target_primary_columns>";
System.out.println(content);
String result = getPropertyValue(content, "target_table");
System.out.println("result: " + result);
}
}
\ No newline at end of file
...@@ -35,7 +35,7 @@ public class SwaggerConfiguration { ...@@ -35,7 +35,7 @@ public class SwaggerConfiguration {
return new ApiInfoBuilder() return new ApiInfoBuilder()
.title("数据中台 APIs") .title("数据中台 APIs")
.description("swagger-bootstrap-ui") .description("swagger-bootstrap-ui")
.termsOfServiceUrl("http://localhost:5050/") .termsOfServiceUrl("http://localhost:7181/")
.contact("Bellamy") .contact("Bellamy")
.version("1.0") .version("1.0")
.build(); .build();
......
...@@ -17,13 +17,13 @@ public class SyncDmpTaskAddReq implements Serializable { ...@@ -17,13 +17,13 @@ public class SyncDmpTaskAddReq implements Serializable {
private static final long serialVersionUID = 4286346100382139287L; private static final long serialVersionUID = 4286346100382139287L;
@NotEmpty(message = "入参不能为空") @NotEmpty(message = "入参不能为空")
private List<Map<String, Object>> params; private Map<String, Object> params;
public List<Map<String, Object>> getParams() { public Map<String, Object> getParams() {
return params; return params;
} }
public void setParams(List<Map<String, Object>> params) { public void setParams(Map<String, Object> params) {
this.params = params; this.params = params;
} }
} }
package com.jz.dmp.modules.controller;
import com.jz.dmp.modules.model.DmpNavigationTree;
import com.jz.dmp.modules.service.DmpNavigationTreeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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;
/**
* DMP资源导航树(DmpNavigationTree)表控制层
*
* @author Bellamy
* @since 2020-12-29 15:08:17
*/
@RestController
@RequestMapping("/dmpNavigationTree")
@Api(tags = "DMP资源导航树")
public class DmpNavigationTreeController {
/**
* 服务对象
*/
@Autowired
private DmpNavigationTreeService dmpNavigationTreeService;
/**
* 通过主键查询单条数据
*
* @param id 主键
* @return 单条数据
*/
@GetMapping("/selectOne")
@ApiOperation(value = "通过主键查询单条数据", notes = "通过主键查询单条数据")
public DmpNavigationTree selectOne(Integer id) {
return this.dmpNavigationTreeService.queryById(id);
}
}
\ No newline at end of file
package com.jz.dmp.modules.controller; package com.jz.dmp.modules.controller;
import com.jz.dmp.modules.model.DvRuleT;
import com.jz.dmp.modules.service.DvRuleTService; import com.jz.dmp.modules.service.DvRuleTService;
import org.springframework.beans.factory.annotation.Autowired; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/** /**
* ???(DvRuleT)表控制层 * ???(DvRuleT)表控制层
* *
......
package com.jz.dmp.modules.dao; package com.jz.dmp.modules.dao;
import com.jz.dmp.modules.model.DmpDevelopTask;
import org.apache.ibatis.annotations.Param;
import java.util.Map; import java.util.Map;
public interface DmpDevelopTaskDao { public interface DmpDevelopTaskDao {
...@@ -11,4 +14,10 @@ public interface DmpDevelopTaskDao { ...@@ -11,4 +14,10 @@ public interface DmpDevelopTaskDao {
int deleteTaskByTaskId(String taskId) throws Exception; int deleteTaskByTaskId(String taskId) throws Exception;
int deleteNavigationTreeByTreeId(String treeId) throws Exception; int deleteNavigationTreeByTreeId(String treeId) throws Exception;
Integer getDbInfoByParam(@Param("xmlTdb") String xmlTdb, @Param("projectId") Integer projectId);
int insert(DmpDevelopTask dmpDevelopTask) throws Exception;
DmpDevelopTask selectTaskInfoByParam(@Param("treeId") long treeId) throws Exception;
} }
package com.jz.dmp.modules.dao;
import com.jz.dmp.modules.model.DmpNavigationTree;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* DMP资源导航树(DmpNavigationTree)表数据库访问层
*
* @author makejava
* @since 2020-12-29 15:08:16
*/
public interface DmpNavigationTreeDao{
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
DmpNavigationTree queryById(Integer id);
/**
* 查询指定行数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<DmpNavigationTree> queryAllByLimit(@Param("offset") int offset, @Param("limit") int limit);
/**
* 通过实体作为筛选条件查询
*
* @param dmpNavigationTree 实例对象
* @return 对象列表
*/
List<DmpNavigationTree> queryAll(DmpNavigationTree dmpNavigationTree);
/**
* 新增数据
*
* @param dmpNavigationTree 实例对象
* @return 影响行数
*/
int insert(DmpNavigationTree dmpNavigationTree);
/**
* 批量新增数据(MyBatis原生foreach方法)
*
* @param entities List<DmpNavigationTree> 实例对象列表
* @return 影响行数
*/
int insertBatch(@Param("entities") List<DmpNavigationTree> entities);
/**
* 批量新增或按主键更新数据(MyBatis原生foreach方法)
*
* @param entities List<DmpNavigationTree> 实例对象列表
* @return 影响行数
*/
int insertOrUpdateBatch(@Param("entities") List<DmpNavigationTree> entities);
/**
* 修改数据
*
* @param dmpNavigationTree 实例对象
* @return 影响行数
*/
int update(DmpNavigationTree dmpNavigationTree);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 影响行数
*/
int deleteById(Integer id);
int countTreeByName(DmpNavigationTree tree);
}
\ No newline at end of file
...@@ -103,4 +103,5 @@ public interface DmpSyncingDatasourceDao { ...@@ -103,4 +103,5 @@ public interface DmpSyncingDatasourceDao {
DataSourceListDto selectDataSourceInfoById(Map map) throws Exception; DataSourceListDto selectDataSourceInfoById(Map map) throws Exception;
List<DmpSyncingDatasource> findListByParams(DmpSyncingDatasource ds) throws Exception;
} }
\ No newline at end of file
package com.jz.dmp.modules.model; package com.jz.dmp.modules.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
...@@ -42,7 +45,7 @@ public class DmpDevelopTask implements Serializable { ...@@ -42,7 +45,7 @@ public class DmpDevelopTask implements Serializable {
/** /**
* 脚本 * 脚本
*/ */
private Object script; private String script;
/** /**
* 数据状态 * 数据状态
*/ */
...@@ -92,6 +95,49 @@ public class DmpDevelopTask implements Serializable { ...@@ -92,6 +95,49 @@ public class DmpDevelopTask implements Serializable {
private Integer isGziped; private Integer isGziped;
/**
* 项目id
*/
private Integer projectId;
/*
* 父节点ID
* */
private Integer parentId;
@JsonProperty(access = JsonProperty.Access.WRITE_ONLY)
private byte[] data;
/*
* 源数据库id
* */
@ApiModelProperty(value = "源数据库id")
private String sourceDbId;
/*
* 目标数据库名称
* */
@ApiModelProperty(value = "目标数据库名称")
private String targetDbName;
/*
* 目标数据库表名称
* */
@ApiModelProperty(value = "目标数据库表")
private String targetTableName;
/*
* 源数据库表名称
* */
@ApiModelProperty(value = "源数据库表")
private String sourceDbName;
/*
* 源数据库表名称
* */
@ApiModelProperty(value = "源数据库表")
private String sourceTableName;
public Integer getId() { public Integer getId() {
return id; return id;
...@@ -149,11 +195,11 @@ public class DmpDevelopTask implements Serializable { ...@@ -149,11 +195,11 @@ public class DmpDevelopTask implements Serializable {
this.taskDesc = taskDesc; this.taskDesc = taskDesc;
} }
public Object getScript() { public String getScript() {
return script; return script;
} }
public void setScript(Object script) { public void setScript(String script) {
this.script = script; this.script = script;
} }
...@@ -269,4 +315,67 @@ public class DmpDevelopTask implements Serializable { ...@@ -269,4 +315,67 @@ public class DmpDevelopTask implements Serializable {
this.isGziped = isGziped; this.isGziped = isGziped;
} }
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public byte[] getData() {
return data;
}
public void setData(byte[] data) {
this.data = data;
}
public String getSourceDbId() {
return sourceDbId;
}
public void setSourceDbId(String sourceDbId) {
this.sourceDbId = sourceDbId;
}
public String getTargetDbName() {
return targetDbName;
}
public void setTargetDbName(String targetDbName) {
this.targetDbName = targetDbName;
}
public String getSourceTableName() {
return sourceTableName;
}
public void setSourceTableName(String sourceTableName) {
this.sourceTableName = sourceTableName;
}
public String getTargetTableName() {
return targetTableName;
}
public void setTargetTableName(String targetTableName) {
this.targetTableName = targetTableName;
}
public String getSourceDbName() {
return sourceDbName;
}
public void setSourceDbName(String sourceDbName) {
this.sourceDbName = sourceDbName;
}
} }
\ No newline at end of file
package com.jz.dmp.modules.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serializable;
import java.util.Date;
/**
* DMP资源导航树(DmpNavigationTree)实体类
*
* @author Bellamy
* @since 2020-12-29 15:08:15
*/
@ApiModel(value = "DMP资源导航树", description = "DMP资源导航树")
public class DmpNavigationTree implements Serializable {
private static final long serialVersionUID = -12645974631378172L;
/**
* ID
*/
@ApiModelProperty(value = "ID")
private Integer id;
/**
* 树类别
*/
@ApiModelProperty(value = "树类别")
private String category;
/**
* 树类型
*/
@ApiModelProperty(value = "树类型")
private String type;
/**
* 名称
*/
@ApiModelProperty(value = "名称")
private String name;
/**
* 序号
*/
@ApiModelProperty(value = "序号")
private Integer treeSort;
/**
* 图标
*/
@ApiModelProperty(value = "图标")
private String icon;
/**
* 是否叶子节点
*/
@ApiModelProperty(value = "是否叶子节点")
private String isLevel;
/**
* 是否启用
*/
@ApiModelProperty(value = "是否启用")
private String isEnable;
/**
* 被谁锁定
*/
@ApiModelProperty(value = "被谁锁定")
private String lockByUser;
/**
* 锁定时间
*/
@ApiModelProperty(value = "锁定时间")
private Date lockTime;
/**
* 数据状态
*/
@ApiModelProperty(value = "数据状态")
private String dataStatus;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private String createUserId;
/**
* 数据创建时间
*/
@ApiModelProperty(value = "数据创建时间")
private Date createTime;
/**
* 创建用户ID
*/
@ApiModelProperty(value = "创建用户ID")
private String updateUserId;
/**
* 数据更新时间
*/
@ApiModelProperty(value = "数据更新时间")
private Date updateTime;
/**
* 项目ID
*/
@ApiModelProperty(value = "项目ID")
private Integer projectId;
/**
* 父节点ID
*/
@ApiModelProperty(value = "父节点ID")
private Integer parentId;
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getCategory() {
return category;
}
public void setCategory(String category) {
this.category = category;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getTreeSort() {
return treeSort;
}
public void setTreeSort(Integer treeSort) {
this.treeSort = treeSort;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getIsLevel() {
return isLevel;
}
public void setIsLevel(String isLevel) {
this.isLevel = isLevel;
}
public String getIsEnable() {
return isEnable;
}
public void setIsEnable(String isEnable) {
this.isEnable = isEnable;
}
public String getLockByUser() {
return lockByUser;
}
public void setLockByUser(String lockByUser) {
this.lockByUser = lockByUser;
}
public Date getLockTime() {
return lockTime;
}
public void setLockTime(Date lockTime) {
this.lockTime = lockTime;
}
public String getDataStatus() {
return dataStatus;
}
public void setDataStatus(String dataStatus) {
this.dataStatus = dataStatus;
}
public String getCreateUserId() {
return createUserId;
}
public void setCreateUserId(String createUserId) {
this.createUserId = createUserId;
}
public Date getCreateTime() {
return createTime;
}
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
public String getUpdateUserId() {
return updateUserId;
}
public void setUpdateUserId(String updateUserId) {
this.updateUserId = updateUserId;
}
public Date getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
this.updateTime = updateTime;
}
public Integer getProjectId() {
return projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public Integer getParentId() {
return parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
}
\ No newline at end of file
package com.jz.dmp.modules.service; package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.model.DmpDevelopTask;
/** /**
* 任务开发(DmpDevelopTask)表服务接口 * 任务开发(DmpDevelopTask)表服务接口
* *
...@@ -9,5 +12,5 @@ package com.jz.dmp.modules.service; ...@@ -9,5 +12,5 @@ package com.jz.dmp.modules.service;
public interface DmpDevelopTaskService { public interface DmpDevelopTaskService {
JsonResult submitSyncing(DmpDevelopTask task) throws Exception;
} }
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.dmp.modules.model.DmpNavigationTree;
import java.util.List;
/**
* DMP资源导航树(DmpNavigationTree)表服务接口
*
* @author Bellamy
* @since 2020-12-29 15:08:16
*/
public interface DmpNavigationTreeService {
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
DmpNavigationTree queryById(Integer id);
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
List<DmpNavigationTree> queryAllByLimit(int offset, int limit);
/**
* 新增数据
*
* @param dmpNavigationTree 实例对象
* @return 实例对象
*/
DmpNavigationTree insert(DmpNavigationTree dmpNavigationTree);
/**
* 修改数据
*
* @param dmpNavigationTree 实例对象
* @return 实例对象
*/
DmpNavigationTree update(DmpNavigationTree dmpNavigationTree);
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
boolean deleteById(Integer id);
}
\ No newline at end of file
...@@ -76,4 +76,6 @@ public interface DmpSyncingDatasourceService { ...@@ -76,4 +76,6 @@ public interface DmpSyncingDatasourceService {
JsonResult selectDataSourceInfoById(Map map) throws Exception; JsonResult selectDataSourceInfoById(Map map) throws Exception;
JsonResult updateDatasourceById(DmpSyncingDatasourceReq saveBody) throws Exception; JsonResult updateDatasourceById(DmpSyncingDatasourceReq saveBody) throws Exception;
List<DmpSyncingDatasource> findListByParams(DmpSyncingDatasource ds) throws Exception;
} }
\ No newline at end of file
package com.jz.dmp.modules.service.impl;
import com.jz.dmp.modules.dao.DmpNavigationTreeDao;
import com.jz.dmp.modules.model.DmpNavigationTree;
import com.jz.dmp.modules.service.DmpNavigationTreeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
* DMP资源导航树(DmpNavigationTree)表服务实现类
*
* @author Bellamy
* @since 2020-12-29 15:08:16
*/
@Service("dmpNavigationTreeService")
public class DmpNavigationTreeServiceImpl implements DmpNavigationTreeService {
@Autowired
private DmpNavigationTreeDao dmpNavigationTreeDao;
/**
* 通过ID查询单条数据
*
* @param id 主键
* @return 实例对象
*/
@Override
public DmpNavigationTree queryById(Integer id) {
return this.dmpNavigationTreeDao.queryById(id);
}
/**
* 查询多条数据
*
* @param offset 查询起始位置
* @param limit 查询条数
* @return 对象列表
*/
@Override
public List<DmpNavigationTree> queryAllByLimit(int offset, int limit) {
return this.dmpNavigationTreeDao.queryAllByLimit(offset, limit);
}
/**
* 新增数据
*
* @param dmpNavigationTree 实例对象
* @return 实例对象
*/
@Override
public DmpNavigationTree insert(DmpNavigationTree dmpNavigationTree) {
this.dmpNavigationTreeDao.insert(dmpNavigationTree);
return dmpNavigationTree;
}
/**
* 修改数据
*
* @param dmpNavigationTree 实例对象
* @return 实例对象
*/
@Override
public DmpNavigationTree update(DmpNavigationTree dmpNavigationTree) {
this.dmpNavigationTreeDao.update(dmpNavigationTree);
return this.queryById(dmpNavigationTree.getId());
}
/**
* 通过主键删除数据
*
* @param id 主键
* @return 是否成功
*/
@Override
public boolean deleteById(Integer id) {
return this.dmpNavigationTreeDao.deleteById(id) > 0;
}
}
\ No newline at end of file
...@@ -257,6 +257,11 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ ...@@ -257,6 +257,11 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
} }
} }
@Override
public List<DmpSyncingDatasource> findListByParams(DmpSyncingDatasource ds) throws Exception {
return dmpSyncingDatasourceDao.findListByParams(ds);
}
private DmpAgentDatasourceInfo dsInfoDTO(DmpSyncingDatasourceReq body) throws Exception { private DmpAgentDatasourceInfo dsInfoDTO(DmpSyncingDatasourceReq body) throws Exception {
//数据源类型ID去查询 //数据源类型ID去查询
DmpSyncingDatasourceType type = dmpSyncingDatasourceDao.queryDatasourceTypeById(body.getDatasourceType()); DmpSyncingDatasourceType type = dmpSyncingDatasourceDao.queryDatasourceTypeById(body.getDatasourceType());
......
...@@ -13,23 +13,26 @@ import com.jz.common.utils.AzkabanApiUtils2; ...@@ -13,23 +13,26 @@ import com.jz.common.utils.AzkabanApiUtils2;
import com.jz.common.utils.FileUtils; import com.jz.common.utils.FileUtils;
import com.jz.common.utils.JsonMapper; import com.jz.common.utils.JsonMapper;
import com.jz.common.utils.ZipUtils; import com.jz.common.utils.ZipUtils;
import com.jz.common.utils.web.XmlUtils;
import com.jz.dmp.agent.DmpAgentResult; import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.modules.controller.DataIntegration.bean.*; import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowExecution; import com.jz.dmp.modules.controller.DataIntegration.bean.flow.FlowExecution;
import com.jz.dmp.modules.dao.*; import com.jz.dmp.modules.dao.*;
import com.jz.dmp.modules.model.*; import com.jz.dmp.modules.model.*;
import com.jz.dmp.modules.service.DmpDevelopTaskService;
import com.jz.dmp.modules.service.OfflineSynchService; import com.jz.dmp.modules.service.OfflineSynchService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.io.File; import java.io.File;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
...@@ -73,6 +76,12 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -73,6 +76,12 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
@Autowired @Autowired
private DvRuleTDao dvRuleTDao; private DvRuleTDao dvRuleTDao;
@Autowired
private DmpNavigationTreeDao dmpNavigationTreeDao;
@Autowired
private DmpDevelopTaskService dmpDevelopTaskService;
@Override @Override
public PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception { public PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception {
PageInfoResponse<TaskListPageDto> pageInfoResponse = new PageInfoResponse<>(); PageInfoResponse<TaskListPageDto> pageInfoResponse = new PageInfoResponse<>();
...@@ -400,8 +409,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -400,8 +409,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
DvRuleT dvRuleT = new DvRuleT(); DvRuleT dvRuleT = new DvRuleT();
List<DvRuleTDto> list = dvRuleTDao.queryJyRuleListPage(dvRuleT); List<DvRuleTDto> list = dvRuleTDao.queryJyRuleListPage(dvRuleT);
if (list.size() > 0 && list != null) { if (list.size() > 0 && list != null) {
for(DvRuleTDto dto : list){ for (DvRuleTDto dto : list) {
dto.setRuleContentJson(JSON.parseObject(dto.getRuleContent())); dto.setRuleContentJson(JSON.parseObject(dto.getRuleContent()));
} }
} }
PageInfo<DvRuleTDto> pageInfo = new PageInfo<>(list); PageInfo<DvRuleTDto> pageInfo = new PageInfo<>(list);
...@@ -412,9 +421,102 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -412,9 +421,102 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return pageInfoResponse; return pageInfoResponse;
} }
/**
* 添加保存dmp数据(包含校验数据)
*
* @param syncDmpTaskAddReq
* @return
*/
@Override @Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public JsonResult addSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception { public JsonResult addSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception {
return null; List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> reqParam = syncDmpTaskAddReq.getParams();
if (reqParam.size() > 0 && reqParam != null) {
JsonResult jsonResult = addSyncing(reqParam);
DmpDevelopTask data = (DmpDevelopTask) jsonResult.getData();
//saveRuleInfo(result, reqParam, jsonResult, String.valueOf(data.getId()));
}
return new JsonResult(ResultCode.SUCCESS, result);
} }
/**
* 添加保存离线任务dmp数据
*
* @param body
* @return
*/
public JsonResult addSyncing(Map<String, Object> body) throws Exception {
Integer projectId = (Integer) body.get("projectId");
Integer parentId = (Integer) body.get("parentId"); //父节点ID
String taskName = (String) body.get("taskName"); //任务名称 业务节点名称 一对一
Integer treeId = (Integer) body.get("treeId"); //树节点ID
if (StringUtils.isBlank(taskName)) {
return new JsonResult(ResultCode.PARAMS_ERROR, "任务名称不能为空");
}
Map<String, Object> scriptMap = (Map<String, Object>) body.get("scripts"); //任务json数据
Object content = scriptMap.get("content");
String xmlTdb = XmlUtils.getPropertyValue(content, "target_db_connection");
if (null != content && xmlTdb.length() == 0) { // 包含content但未取出值条件才成立
return new JsonResult(ResultCode.PARAMS_ERROR, "脚本内容中缺失目标数据源(target_db_connection)");
}
/*DmpNavigationTree tree = new DmpNavigationTree();
tree.setName(taskName); //树节点名称
tree.setProjectId(projectId);
tree.setCategory("2"); //树类别
tree.setIsLevel("1"); //是否叶子节点 1 是
int cnt = dmpNavigationTreeDao.countTreeByName(tree);
if (cnt > 0) {
throw new RuntimeException("当前项目已存在同名的任务");
}*/
//保存目标库类型
Integer dataSourceId = null; //数据源ID
Map<String, Object> writer = (Map<String, Object>) scriptMap.get("writer"); // 目标数据
String targetDb = (String) writer.get("targetDbConnection"); // 目标库名称
String targetTable = (String) writer.get("targetTable"); // 目标库表名称
Map<String, Object> reader = (Map<String, Object>) scriptMap.get("reader");//源数据
String sourceDbName = (String) reader.get("dbConnection"); // 源库名称
String sourceTableName = (String) reader.get("registerTableName"); // 源库表名称
if (StringUtils.isNotBlank(targetDb)) {
//根据 目标库和项目id 查询
dataSourceId = dmpDevelopTaskDao.getDbInfoByParam(targetDb, projectId);
}
DmpDevelopTask task = new DmpDevelopTask();
task.setProjectId(projectId);
task.setParentId(parentId);
task.setTaskType("2"); //任务类型
task.setDatasourceId(dataSourceId); //数据源ID
task.setType("3");
//task.setTaskName(taskName);
task.setTaskDesc("Syncing Task"); //任务描述
task.setIsSubmit("0"); //是否已提交
task.setTreeId(treeId);
String script = JsonMapper.toJsonString(body);
byte[] data = null;
try {
data = script.getBytes("utf-8");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
task.setData(data); //json 数据
task.setTargetDbName(targetDb);
task.setTargetTableName(targetTable);
task.setSourceTableName(sourceTableName);
task.setSourceDbName(sourceDbName);
dmpDevelopTaskDao.insert(task); //保存任务数据
//保存时提交XML
/*DmpTaskSchedule schedule = new DmpTaskSchedule();
schedule.setTreeId(task.getTreeId());
schedule.setProjectId(projectId);*/
dmpDevelopTaskService.submitSyncing(task);
return new JsonResult(ResultCode.SUCCESS, task);
}
} }
...@@ -21,4 +21,99 @@ ...@@ -21,4 +21,99 @@
delete from dmp_navigation_tree where id = #{treeId} delete from dmp_navigation_tree where id = #{treeId}
</delete> </delete>
<select id="getDbType" resultType="java.lang.Integer">
SELECT
dsd.id AS id
FROM dmp_syncing_datasource dsd
JOIN dmp_syncing_datasource_type dsdt ON dsd.DATASOURCE_TYPE =dsdt.id
WHERE dsd.DATASOURCE_NAME =#{xmlTdb}
AND dsd.PROJECT_ID=#{projectId}
</select>
<!--新增所有列-->
<insert id="insert" keyProperty="id" useGeneratedKeys="true">
insert into dmp_develop_task(datasource_id, TASK_TYPE, TYPE, SCHEDULE_TYPE, IS_SUBMIT, TASK_DESC, SCRIPT, DATA_STATUS, CREATE_USER_ID, CREATE_TIME,
UPDATE_USER_ID, UPDATE_TIME, TREE_ID, CHK_RESULT, SYNC_RESULT, CHK_TIME, SYNC_TIME, FLOW_HEADER, FLOW_JSON, VERSION, IS_GZIPED,SOURCE_DB_NAME,SOURCE_TABLE_NAME,TARGET_DB_NAME,TARGET_TABLE_NAME)
values (#{datasourceId}, #{taskType}, #{type}, #{scheduleType}, #{isSubmit}, #{taskDesc}, #{data}, #{dataStatus}, #{createUserId}, #{createTime}, #{updateUserId},
#{updateTime}, #{treeId}, #{chkResult}, #{syncResult}, #{chkTime}, #{syncTime}, #{flowHeader}, #{flowJson}, #{version}, #{isGziped}, #{sourceDbName}, #{sourceTableName}, #{targetDbName}, #{targetTableName})
</insert>
<update id="update">
update dmp_develop_task
<set>
<if test="datasourceId != null">
datasource_id = #{datasourceId},
</if>
<if test="taskType != null and taskType != ''">
TASK_TYPE = #{taskType},
</if>
<if test="type != null and type != ''">
TYPE = #{type},
</if>
<if test="scheduleType != null and scheduleType != ''">
SCHEDULE_TYPE = #{scheduleType},
</if>
<if test="isSubmit != null and isSubmit != ''">
IS_SUBMIT = #{isSubmit},
</if>
<if test="taskDesc != null and taskDesc != ''">
TASK_DESC = #{taskDesc},
</if>
<if test="script != null">
SCRIPT = #{script},
</if>
<if test="dataStatus != null and dataStatus != ''">
DATA_STATUS = #{dataStatus},
</if>
<if test="createUserId != null and createUserId != ''">
CREATE_USER_ID = #{createUserId},
</if>
<if test="createTime != null">
CREATE_TIME = #{createTime},
</if>
<if test="updateUserId != null and updateUserId != ''">
UPDATE_USER_ID = #{updateUserId},
</if>
<if test="updateTime != null">
UPDATE_TIME = #{updateTime},
</if>
<if test="treeId != null">
TREE_ID = #{treeId},
</if>
<if test="chkResult != null and chkResult != ''">
CHK_RESULT = #{chkResult},
</if>
<if test="syncResult != null and syncResult != ''">
SYNC_RESULT = #{syncResult},
</if>
<if test="chkTime != null">
CHK_TIME = #{chkTime},
</if>
<if test="syncTime != null">
SYNC_TIME = #{syncTime},
</if>
<if test="flowHeader != null and flowHeader != ''">
FLOW_HEADER = #{flowHeader},
</if>
<if test="flowJson != null">
FLOW_JSON = #{flowJson},
</if>
<if test="version != null and version != ''">
VERSION = #{version},
</if>
<if test="isGziped != null">
IS_GZIPED = #{isGziped},
</if>
</set>
where ID = #{id}
</update>
<select id="selectTaskInfoByParam" parameterType="map">
select
ID, datasource_id, TASK_TYPE, TYPE, SCHEDULE_TYPE, IS_SUBMIT, TASK_DESC, SCRIPT, DATA_STATUS
, CREATE_USER_ID, CREATE_TIME, UPDATE_USER_ID, UPDATE_TIME, TREE_ID, CHK_RESULT, SYNC_RESULT, CHK_TIME, SYNC_TIME, FLOW_HEADER, FLOW_JSON, VERSION, IS_GZIPED
from dmp_develop_task
where TREE_ID = #{treeId}
</select>
</mapper> </mapper>
\ No newline at end of file
This diff is collapsed.
...@@ -349,4 +349,26 @@ ...@@ -349,4 +349,26 @@
<if test="projectId != null and projectId !=''"> and a.project_id = #{projectId}</if> <if test="projectId != null and projectId !=''"> and a.project_id = #{projectId}</if>
</select> </select>
<select id="findListByParams" parameterType="com.jz.dmp.modules.model.DmpSyncingDatasource" resultType="com.jz.dmp.modules.model.DmpSyncingDatasource">
SELECT
id,datasource_type,datasource_name,datasource_desc,jdbc_url,db_name,user_name,password,endpoint,bucket
,access_id,access_key,protocol,host,port,default_fs,table_schema,data_status,create_user_id,create_time,update_user_id,update_time,project_id
FROM dmp_syncing_datasource WHERE 1=1
<if test="datasourceType != null">AND datasource_type = #{datasourceType}</if>
<if test="datasourceName != null">AND datasource_name = #{datasourceName}</if>
<if test="datasourceDesc != null">AND datasource_desc = #{datasourceDesc}</if>
<if test="jdbcUrl != null">AND jdbc_url = #{jdbcUrl}</if>
<if test="dbName != null">AND db_name = #{dbName}</if>
<if test="userName != null">AND user_name = #{userName}</if>
<if test="accessId != null">AND access_id = #{accessId}</if>
<if test="accessKey != null">AND access_key = #{accessKey}</if>
<if test="protocol != null">AND protocol = #{protocol}</if>
<if test="host != null">AND host = #{host}</if>
<if test="port != null">AND port = #{port}</if>
<if test="defaultFs != null">AND default_fs = #{defaultFs}</if>
<if test="tableSchema != null">AND table_schema = #{tableSchema}</if>
<if test="dataStatus != null">AND data_status = #{dataStatus}</if>
<if test="projectId != null">AND project_id = #{projectId}</if>
</select>
</mapper> </mapper>
\ No newline at end of file
This diff is collapsed.
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