Commit 7f78a584 authored by mcb's avatar mcb

no message

parent a7e7a9de
......@@ -67,6 +67,42 @@ public class JsonResult<T> implements Serializable {
this.setMessage(message);
}
public static JsonResult<Object> ok() {
JsonResult<Object> result = new JsonResult<>();
result.setCode(ResultCode.SUCCESS);
result.setMessage("成功!");
return result;
}
public static JsonResult<Object> ok(String message) {
JsonResult<Object> result = new JsonResult<>();
result.setCode(ResultCode.SUCCESS);
result.setMessage(message);
return result;
}
public static JsonResult<Object> ok(Object data) {
JsonResult<Object> result = new JsonResult<>();
result.setCode(ResultCode.SUCCESS);
result.setMessage("成功!");
result.setData(data);
return result;
}
public static JsonResult<Object> error() {
JsonResult<Object> result = new JsonResult<>();
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(ResultCode.INTERNAL_SERVER_ERROR.msg());
return result;
}
public static JsonResult<Object> error(ResultCode code, String message) {
JsonResult<Object> result = new JsonResult<>();
result.setCode(code);
result.setMessage(message);
return result;
}
public void setCodes(com.jz.dmp.agent.ResultCode code) {
this.code = code.val();
}
......
package com.jz.common.enums;
/**
* 删除标识
*
* @author Bellamy
* @since 2020-11-30 14:30:23
*/
public enum DelFlagEnum {
/**
* 删除
*/
YES("YES", "0"),
/**
* 未删除
*/
NO("NO", "1"),
;
private String code;
private String value;
private DelFlagEnum(String code, String value) {
this.code = code;
this.value = value;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public static DelFlagEnum get(String code) {
if (code == null) {
return null;
}
for (DelFlagEnum status : values()) {
if (status.getCode().equalsIgnoreCase(code)) {
return status;
}
}
return null;
}
}
......@@ -12,6 +12,8 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
......@@ -31,6 +33,8 @@ import java.util.Map;
@Api(tags = "数据集成--数据源")
public class DataSourceController {
private static Logger logger = LoggerFactory.getLogger(DataSourceController.class);
@Autowired
private DmpSyncingDatasourceService dmpSyncingDatasourceService;
......@@ -125,9 +129,15 @@ public class DataSourceController {
@PostMapping(value = "/testConnection")
public JsonResult testConnection(@RequestBody @Validated DmpSyncingDatasourceReq saveBody, HttpServletRequest httpRequest) throws Exception {
if (StringUtils.isEmpty(saveBody.getDatasourceType())) {
return new JsonResult(ResultCode.PARAMS_ERROR,"数据源类型ID不能为空");
return new JsonResult(ResultCode.PARAMS_ERROR, "数据源类型ID不能为空");
}
JsonResult result = new JsonResult();
try {
result = dmpSyncingDatasourceService.testConnection(saveBody);
} catch (Exception e) {
logger.info("###################" + e.getMessage() + "###################");
return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR,e.getMessage());
}
JsonResult result = dmpSyncingDatasourceService.testConnection(saveBody);
return result;
}
......@@ -139,7 +149,7 @@ public class DataSourceController {
*/
@ApiOperation(value = "编辑数据源--根据id查询数据回显", notes = "编辑数据源--根据id查询数据回显")
@GetMapping(value = "/selectDataSourceInfoById")
@ApiImplicitParams({@ApiImplicitParam(name = "datasourceId", value = "数据源id" ,required = true),@ApiImplicitParam(name = "projectId", value = "项目id")})
@ApiImplicitParams({@ApiImplicitParam(name = "datasourceId", value = "数据源id", required = true), @ApiImplicitParam(name = "projectId", value = "项目id")})
public JsonResult getDataSourceInfoById(@RequestParam String datasourceId, @RequestParam(value = "projectId", required = false) String projectId) throws Exception {
if (StringUtils.isEmpty(datasourceId)) {
return new JsonResult(ResultCode.PARAMS_ERROR);
......
......@@ -99,7 +99,7 @@ public class OfflineSynchController {
}
/**
* 根据taskId删除任务
* 根据taskId删除离线任务
*
* @return
* @author Bellamy
......
......@@ -113,7 +113,7 @@ public class RealTimeSyncController {
if (StringUtils.isEmpty(realTaskId)) {
return new JsonResult(ResultCode.PARAMS_ERROR, "任务id不能为空!");
}
boolean jsonResult = dmpRealtimeSyncInfoService.deleteById(Integer.valueOf(realTaskId));
boolean jsonResult = dmpRealtimeSyncInfoService.deleteByrealTaskId(realTaskId);
if (jsonResult) {
return new JsonResult();
} else {
......
......@@ -16,7 +16,12 @@ public interface DmpDevelopTaskDao {
Map getDmpTaskAndTreeInfo(String taskId) throws Exception;
int deleteTaskByTaskId(String taskId) throws Exception;
/**
* 批量删除离线任务
*
* @author Bellamy
*/
int deleteTaskByTaskId(Map params) throws Exception;
int deleteNavigationTreeByTreeId(String treeId) throws Exception;
......
......@@ -177,4 +177,12 @@ public interface DmpRealtimeSyncInfoDao {
* @since 2021-01-12
*/
List<Map> selectRealtimeTaskById(@Param("taskId") String taskId) throws Exception;
/**
* 批量删除数据源
*
* @return
* @author Bellamy
*/
int deleteByrealTaskId(Map map) throws Exception;
}
\ No newline at end of file
......@@ -97,7 +97,7 @@ public interface DmpSyncingDatasourceDao {
* @return
* @author Bellamy
*/
void delDataSourceById(@Param("ids") String[] ids) throws Exception;
void delDataSourceById(Map map) throws Exception;
/**
* 获取数据源类型-下拉框
......
......@@ -127,4 +127,12 @@ public interface DmpRealtimeSyncInfoService {
* @since 2021-01-12
*/
JsonResult<RealTimeEditDataEchoDto> selectRealtimeTaskById(String taskId) throws Exception;
/**
* 批量删除数据源
*
* @return
* @author Bellamy
*/
boolean deleteByrealTaskId(String realTaskId) throws Exception;
}
\ No newline at end of file
......@@ -25,23 +25,71 @@ public interface OfflineSynchService {
*/
PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception;
/**
* 获取源数据库名称——下拉框
*
* @return
* @author Bellamy
*/
JsonResult querygSourceDbList(Integer projectId) throws Exception;
/**
* 根据源数据库id,获取源数据表——下拉框
*
* @return
* @author Bellamy
*/
JsonResult querygSourceTableList(Long sourceDbId, String targetName) throws Exception;
/**
* 任务立即运行
*
* @return
* @author Bellamy
*/
JsonResult taskRunNowByTaskId(String taskId) throws Exception;
/**
* 根据taskId删除离线任务
*
* @return
* @author Bellamy
*/
JsonResult delTaskByTaskId(String taskId) throws Exception;
JsonResult<List<CheckTaskStatusPageDto>> queryCheckTaskStatusListPage(CheckTaskStatusPageReq checkTaskStatusPageReq) throws Exception;
PageInfoResponse<CheckJyRlueStatusDto> selectCheckJyStatusInfo(CheckJyRlueStatusReq checkJyRlueStatusReq) throws Exception;
/**
* 获取源表和目标表的字段
*
* @return
* @author Bellamy
*/
JsonResult querySoureAndTargetColumnsByParams(SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception;
/**
* 校验规则
*
* @return
* @author Bellamy
*/
PageInfoResponse<DvRuleTDto> queryJyRuleListPage(BasePageBean basePageBean, HttpServletRequest httpRequest) throws Exception;
/**
* 保存离线任务数据
*
* @return
* @author Bellamy
*/
JsonResult addSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception;
/**
* 编辑离线任务数据
*
* @return
* @author Bellamy
*/
JsonResult updateSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception;
}
......@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.enums.DelFlagEnum;
import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService;
import com.jz.common.utils.realTime.DBUtil;
......@@ -821,4 +822,20 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
}
return new JsonResult(returnModel);
}
/**
* 批量删除数据源
*
* @return
* @author Bellamy
*/
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public boolean deleteByrealTaskId(String realTaskId) throws Exception {
Map map = new HashMap();
String[] ids = realTaskId.split(",");
map.put("ids", ids);
map.put("dataStatus", DelFlagEnum.YES.getValue());
return dmpRealtimeSyncInfoDao.deleteByrealTaskId(map) > 0;
}
}
\ No newline at end of file
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.amazonaws.services.dynamodbv2.xspec.M;
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.enums.DelFlagEnum;
import com.jz.common.enums.TestConnectStatusEnum;
import com.jz.common.exception.ServiceException;
import com.jz.common.page.PageInfoResponse;
......@@ -152,8 +154,11 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public JsonResult delDataSourceById(String datasourceId) throws Exception {
Map map = new HashMap();
String[] ids = datasourceId.split(",");
dmpSyncingDatasourceDao.delDataSourceById(ids);
map.put("ids", ids);
map.put("dataStatus", DelFlagEnum.YES.getValue());
dmpSyncingDatasourceDao.delDataSourceById(map);
return new JsonResult();
}
......@@ -304,7 +309,7 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
DmpAgentDatasourceInfo ds = this.dsInfoDTO(saveBody); //查询数据源 对应的 数据库信息
DmpAgentResult rst = dmpDsAgentServiceImp.testConnect(ds); //连接测试
if (!rst.getCode().val().equals("200")) {
return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR,"连接测试失败!");
return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR, "连接测试失败!");
} else {
//连接测试成功
Object flag = JsonMapper.fromJsonString(rst.getMessage(), Boolean.class);
......@@ -425,7 +430,7 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
ds.setDefaultFs(body.getDefaultFs());
DmpProjectSystemInfo info = dmpProjectDao.queryProjectSystemInfo(Long.valueOf(body.getProjectId()));
if(info == null){
if (info == null) {
//throw new RuntimeException("未查询到对应的项目系统配置信息");
throw new ServiceException("未查询到对应的项目系统配置信息");
}
......
......@@ -6,6 +6,7 @@ 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.enums.DelFlagEnum;
import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService;
......@@ -28,6 +29,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.access.method.P;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
......@@ -146,6 +148,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
/**
* 立即运行
*
* @author Bellamy
*/
@Override
public JsonResult taskRunNowByTaskId(String taskId) throws Exception {
......@@ -229,20 +233,28 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
}
/**
* 删除任务
* 批量删除离线任务
*
* @author Bellamy
*/
@Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public JsonResult delTaskByTaskId(String taskId) throws Exception {
Map params = new HashMap();
String[] ids = taskId.split(",");
params.put("ids", ids);
params.put("dataStatus", DelFlagEnum.YES.getValue());
dmpDevelopTaskDao.deleteTaskByTaskId(params);
//通过taskId,查询任务和资源是否存在
Map map = dmpDevelopTaskDao.getDmpTaskAndTreeInfo(taskId);
if (map.size() == 0 || map == null) {
/*Map map = dmpDevelopTaskDao.getDmpTaskAndTreeInfo(taskId);
if (map == null) {
return new JsonResult(ResultCode.OPERATION_DATA_NO_EXIST);
}
if (StringUtils.isEmpty(map.get("treeId").toString())) {
return new JsonResult(ResultCode.OPERATION_DATA_NO_EXIST);
}
dmpDevelopTaskDao.deleteTaskByTaskId(taskId);
dmpDevelopTaskDao.deleteNavigationTreeByTreeId(map.get("treeId").toString());
}*/
//dmpDevelopTaskDao.deleteNavigationTreeByTreeId(map.get("treeId").toString());
return new JsonResult(ResultCode.SUCCESS);
}
......@@ -298,6 +310,12 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return pageInfoResponse;
}
/**
* 获取源表和目标表的字段
*
* @return
* @author Bellamy
*/
@Override
public JsonResult querySoureAndTargetColumnsByParams(SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception {
//通过源数据库id ,查询数据源配置
......@@ -532,15 +550,15 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
dmpNavigationTreeDao.update(dmpNavigationTree); //更新节点 树
logger.info("################################## 更新节点 树 结束 ############################################");
//更新规则信息
List<DvTaskRuleT> list =new ArrayList<>();
List<DvTaskRuleT> list = new ArrayList<>();
//查询TaskRuleID 集合
List<Long> listRules= dvTaskRuleTService.getTaskRuleIdsList(taskId);
if (CollectionUtils.isNotEmpty(listRules)){
List<Long> listRules = dvTaskRuleTService.getTaskRuleIdsList(taskId);
if (CollectionUtils.isNotEmpty(listRules)) {
//批量删除rule信息
dvTaskRuleTService.delRulesByIds(listRules);
List<Map> taskRules = (List<Map>)reqParam.get("taskRules");
List<Map> taskRules = (List<Map>) reqParam.get("taskRules");
//保存dmp数据校验规则信息
settRuleInfo(String.valueOf(taskId),taskRules,list);
settRuleInfo(String.valueOf(taskId), taskRules, list);
}
//保存时提交XML
dmpDevelopTaskService.submitSyncing(task);
......
......@@ -37,13 +37,22 @@
t1.TREE_ID as treeId
from dmp_develop_task t1
left join dmp_navigation_tree t2 on t1.TREE_ID=t2.ID
where 1=1 and t1.id = #{taskId}
where 1=1 and t1.data_status ='1' and t1.id = #{taskId}
</select>
<!--根据主键删除任务-->
<delete id="deleteTaskByTaskId" parameterType="string">
delete from dmp_develop_task where id = #{taskId}
</delete>
<update id="deleteTaskByTaskId" parameterType="java.util.Map">
update dmp_develop_task
<trim prefix="SET" suffixOverrides=",">
<if test="dataStatus != null">
data_status = #{dataStatus},
</if>
</trim>
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
<!--根据主键删除资源树-->
<delete id="deleteNavigationTreeByTreeId" parameterType="string">
......@@ -142,7 +151,7 @@
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}
where data_status ='1' and TREE_ID = #{treeId}
</select>
<!--数据运维-数据开发任务列表分页查询-->
......@@ -159,7 +168,7 @@
t3.real_name as userName
from
dmp_navigation_tree t1
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID and t2.data_status ='1'
left join dmp_member t3 on t1.create_user_id=t3.user_id
where 1=1 and t1.type='01'
and t1.project_id = #{projectId}
......@@ -194,7 +203,7 @@
(case when t1.type='01' then '离线同步' when t1.type='02' then '实时同步' when t1.type='03' then '数据开发' end) as type
from
dmp_navigation_tree t1
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID
left join dmp_develop_task t2 on t2.TREE_ID=t1.ID and t2.data_status ='1'
left join dmp_member t3 on t1.create_user_id=t3.user_id
where 1=1 and t1.type='01'
and t1.project_id = #{projectId}
......
......@@ -42,7 +42,7 @@
, src_database_type, src_database_name, connector_url, target_database_type, target_database_name, src_datasource_name
, target_datasource_name, store_type, status, create_time, update_time, cre_person, upt_person
from dmp_realtime_sync_info
where id = #{id}
where data_status='1' and id = #{id}
</select>
<!--查询指定行数据-->
......@@ -323,10 +323,10 @@
t1.target_datasource_name as targetDatasourceName,
t1.target_database_type as targetDatabaseType
FROM dmp_realtime_sync_info t1
left join dmp_navigation_tree t2 on t1.tree_id=t2.id
inner join dmp_navigation_tree t2 on t1.tree_id=t2.id
left join dmp_syncing_datasource t3 ON t1.src_datasource_id = t3.ID
left join dmp_syncing_datasource t4 ON t1.target_datasource_id = t4.ID
where 1=1 and t1.project_id=#{projectId}
where 1=1 and t1.data_status='1' and t1.project_id=#{projectId}
<if test="taskStatus != null and taskStatus != '' "> AND t1.status = #{taskStatus} </if>
<if test="treeId != null and treeId != '' "> AND t1.id = #{treeId} </if>
<if test="targetDatabaseTypeId != null and targetDatabaseTypeId != '' "> AND t4.DATASOURCE_TYPE = #{targetDatabaseTypeId} </if>
......@@ -344,7 +344,7 @@
, src_database_type, src_database_name, connector_url, target_database_type, target_database_name, src_datasource_name
, target_datasource_name, store_type, status, create_time, update_time, cre_person, upt_person
from dmp_realtime_sync_info
where id in
where 1=1 and data_status='1' and id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
......@@ -392,7 +392,7 @@
desensitization_field as desensitizationField,
arithmetic
from dmp_realtime_sync_info
where 1=1 and type =2
where 1=1 and data_status='1' and type =2
and src_datasource_id = #{srcDatasourceId}
<if test="targetDatasourceId != null"> and target_datasource_id = #{targetDatasourceId} </if>
<if test="sourceTableName != null and sourceTableName !=''"> and src_table_name = #{sourceTableName} </if>
......@@ -421,7 +421,7 @@
t1.target_database_type as targetDatabaseType
FROM dmp_realtime_sync_info t1
left join dmp_navigation_tree t2 on t1.tree_id=t2.id
where 1=1
where 1=1 and t1.data_status='1'
<if test="projectId !=null">and t1.project_id=#{projectId}</if>
<if test="taskStatus != null and taskStatus != '' "> AND t1.status = #{taskStatus} </if>
<if test="treeId != null and treeId != '' "> AND t1.id = #{treeId} </if>
......@@ -513,6 +513,20 @@
left join dmp_realtime_sync_blacklist_table_info t2 ON t1.id = t2.realtime_id
left join dmp_realtime_sync_select_table t3 on t1.id=t3.realtime_id
WHERE
1 = 1 and id = #{taskId}
1 = 1 and t1.data_status='1' and id = #{taskId}
</select>
<!--批量删除-->
<update id="deleteByrealTaskId" parameterType="java.util.Map">
update dmp_realtime_sync_info
<trim prefix="SET" suffixOverrides=",">
<if test="dataStatus != null">
data_status = #{dataStatus},
</if>
</trim>
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper>
\ No newline at end of file
......@@ -302,13 +302,18 @@
</select>
<!--批量删除-->
<delete id="delDataSourceById" parameterType="map">
delete from dmp_syncing_datasource
<update id="delDataSourceById" parameterType="map">
update dmp_syncing_datasource
<trim prefix="SET" suffixOverrides=",">
<if test="dataStatus != null">
data_status = #{dataStatus},
</if>
</trim>
where ID in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</delete>
</update>
<!--查询数据源类型名称-->
<select id="queryDatasourceType" resultType="map">
......
......@@ -144,7 +144,7 @@
from dmp_develop_task t1
inner join dmp_navigation_tree t2 on t1.TREE_ID=t2.ID
left join dmp_project_system_info t3 on t2.PROJECT_ID=t3.PROJECT_ID and t3.data_status = '1'
where 1=1 and t2.id = #{taskId}
where 1=1 and t1.data_status ='1' and t2.id = #{taskId}
</select>
<!-- 根据执行实例id查询规则执行结果表 -->
......
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