Commit 9f5de5a1 authored by sml's avatar sml

Merge branch 'dmp_dev' of http://gitlab.ioubuy.cn/yaobenzhang/jz-dmp-service.git into dmp_dev

parents adbb2fe5 060cb2ef
...@@ -17,3 +17,5 @@ add jaas_address varchar(128) DEFAULT NULL COMMENT 'jaas地址(Kafka)', ...@@ -17,3 +17,5 @@ add jaas_address varchar(128) DEFAULT NULL COMMENT 'jaas地址(Kafka)',
add krb5_address varchar(128) DEFAULT NULL COMMENT 'krb5地址(Kafka)', add krb5_address varchar(128) DEFAULT NULL COMMENT 'krb5地址(Kafka)',
add kudu_master varchar(128) DEFAULT NULL COMMENT 'kkudu_master(Kudu)', add kudu_master varchar(128) DEFAULT NULL COMMENT 'kkudu_master(Kudu)',
add impala_master_fqdn varchar(128) DEFAULT NULL COMMENT 'impala_master_fqdn(Kudu)'; add impala_master_fqdn varchar(128) DEFAULT NULL COMMENT 'impala_master_fqdn(Kudu)';
alter table dmp_realtime_sync_info add online_status char(1) default 'N' comment '上下线状态:Y 上线,N 下线';
...@@ -6,10 +6,13 @@ import com.jz.dmp.modules.model.DmpAgentDatasourceInfo; ...@@ -6,10 +6,13 @@ import com.jz.dmp.modules.model.DmpAgentDatasourceInfo;
public interface DmpDsAgentService { public interface DmpDsAgentService {
//jdbc连接
public DmpAgentResult testConnect(DmpAgentDatasourceInfo ds); public DmpAgentResult testConnect(DmpAgentDatasourceInfo ds);
//获取数据源表库名称
public DmpAgentResult getTableNameList(DmpAgentDatasourceInfo ds); public DmpAgentResult getTableNameList(DmpAgentDatasourceInfo ds);
//获取数据源表字段
public DmpAgentResult getTableColumnList(DmpAgentDatasourceInfo ds, String tableName); public DmpAgentResult getTableColumnList(DmpAgentDatasourceInfo ds, String tableName);
public DmpAgentResult previewData(DmpAgentDatasourceInfo ds, String tableName); public DmpAgentResult previewData(DmpAgentDatasourceInfo ds, String tableName);
......
...@@ -67,6 +67,49 @@ public class JsonResult<T> implements Serializable { ...@@ -67,6 +67,49 @@ public class JsonResult<T> implements Serializable {
this.setMessage(message); 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(String message) {
JsonResult<Object> result = new JsonResult<>();
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(message);
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) { public void setCodes(com.jz.dmp.agent.ResultCode code) {
this.code = code.val(); 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;
}
}
package com.jz.common.exception; package com.jz.common.exception;
import com.jz.common.constant.ResultCode;
public class ServiceException extends Exception { public class ServiceException extends Exception {
private static final long serialVersionUID = 1859731705152111160L; private static final long serialVersionUID = 1859731705152111160L;
......
...@@ -110,6 +110,7 @@ public class SessionUtils { ...@@ -110,6 +110,7 @@ public class SessionUtils {
/** /**
* @Title: getSessionUserId * @Title: getSessionUserId
* @Description: 获取登录用户ID * @Description: 获取登录用户ID
* @Author: Bellamy
* @return String 返回类型 * @return String 返回类型
*/ */
public static String getCurrentUserId(){ public static String getCurrentUserId(){
...@@ -121,6 +122,21 @@ public class SessionUtils { ...@@ -121,6 +122,21 @@ public class SessionUtils {
return userId; return userId;
} }
/**
* @Title: getCurrentUserName
* @Description: 获取登录用户名称
* @Author: Bellamy
* @return String 返回类型
*/
public static String getCurrentUserName(){
String userName = "";
DmpMember user = getSecurityUser();
if(user != null){
userName = user.getUserName();
}
return userName;
}
/** /**
* @Title: getAuthentication * @Title: getAuthentication
* @Description: TODO(获取authentication) * @Description: TODO(获取authentication)
......
...@@ -12,6 +12,8 @@ import io.swagger.annotations.ApiImplicitParam; ...@@ -12,6 +12,8 @@ import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
...@@ -31,6 +33,8 @@ import java.util.Map; ...@@ -31,6 +33,8 @@ import java.util.Map;
@Api(tags = "数据集成--数据源") @Api(tags = "数据集成--数据源")
public class DataSourceController { public class DataSourceController {
private static Logger logger = LoggerFactory.getLogger(DataSourceController.class);
@Autowired @Autowired
private DmpSyncingDatasourceService dmpSyncingDatasourceService; private DmpSyncingDatasourceService dmpSyncingDatasourceService;
...@@ -124,7 +128,16 @@ public class DataSourceController { ...@@ -124,7 +128,16 @@ public class DataSourceController {
@ApiOperation(value = "测试连通性", notes = "测试连通性") @ApiOperation(value = "测试连通性", notes = "测试连通性")
@PostMapping(value = "/testConnection") @PostMapping(value = "/testConnection")
public JsonResult testConnection(@RequestBody @Validated DmpSyncingDatasourceReq saveBody, HttpServletRequest httpRequest) throws Exception { public JsonResult testConnection(@RequestBody @Validated DmpSyncingDatasourceReq saveBody, HttpServletRequest httpRequest) throws Exception {
JsonResult result = dmpSyncingDatasourceService.testConnection(saveBody); if (StringUtils.isEmpty(saveBody.getDatasourceType())) {
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());
}
return result; return result;
} }
...@@ -136,7 +149,7 @@ public class DataSourceController { ...@@ -136,7 +149,7 @@ public class DataSourceController {
*/ */
@ApiOperation(value = "编辑数据源--根据id查询数据回显", notes = "编辑数据源--根据id查询数据回显") @ApiOperation(value = "编辑数据源--根据id查询数据回显", notes = "编辑数据源--根据id查询数据回显")
@GetMapping(value = "/selectDataSourceInfoById") @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 { public JsonResult getDataSourceInfoById(@RequestParam String datasourceId, @RequestParam(value = "projectId", required = false) String projectId) throws Exception {
if (StringUtils.isEmpty(datasourceId)) { if (StringUtils.isEmpty(datasourceId)) {
return new JsonResult(ResultCode.PARAMS_ERROR); return new JsonResult(ResultCode.PARAMS_ERROR);
......
...@@ -34,7 +34,7 @@ public class OfflineSynchController { ...@@ -34,7 +34,7 @@ public class OfflineSynchController {
private OfflineSynchService offlineSynchService; private OfflineSynchService offlineSynchService;
/** /**
* 任务列表分页查询 * 离线同步任务列表分页查询
* *
* @return * @return
* @author Bellamy * @author Bellamy
...@@ -61,7 +61,7 @@ public class OfflineSynchController { ...@@ -61,7 +61,7 @@ public class OfflineSynchController {
*/ */
@ApiOperation(value = "获取源数据库名称-下拉框", notes = "获取源数据库名称") @ApiOperation(value = "获取源数据库名称-下拉框", notes = "获取源数据库名称")
@GetMapping(value = "/sourceDbList") @GetMapping(value = "/sourceDbList")
@ApiImplicitParam(name = "projectId", value = "项目id",required = true) @ApiImplicitParam(name = "projectId", value = "项目id", required = true)
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId) throws Exception { public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId) throws Exception {
JsonResult<List<SourceDbNameListDto>> jsonResult = offlineSynchService.querygSourceDbList(projectId); JsonResult<List<SourceDbNameListDto>> jsonResult = offlineSynchService.querygSourceDbList(projectId);
return jsonResult; return jsonResult;
...@@ -75,7 +75,7 @@ public class OfflineSynchController { ...@@ -75,7 +75,7 @@ public class OfflineSynchController {
*/ */
@ApiOperation(value = "根据源数据库id,获取源数据表-下拉框", notes = "根据源数据库id,获取源数据表") @ApiOperation(value = "根据源数据库id,获取源数据表-下拉框", notes = "根据源数据库id,获取源数据表")
@GetMapping(value = "/sourceTableList") @GetMapping(value = "/sourceTableList")
@ApiImplicitParam(name = "sourceDbId", value = "源数据库id") @ApiImplicitParam(name = "sourceDbId", value = "源数据库id", required = true)
public JsonResult getSourceTableList(@RequestParam Long sourceDbId, @RequestParam(value = "targetName", required = false) String targetName) throws Exception { public JsonResult getSourceTableList(@RequestParam Long sourceDbId, @RequestParam(value = "targetName", required = false) String targetName) throws Exception {
JsonResult list = offlineSynchService.querygSourceTableList(sourceDbId, targetName); JsonResult list = offlineSynchService.querygSourceTableList(sourceDbId, targetName);
return list; return list;
...@@ -99,7 +99,7 @@ public class OfflineSynchController { ...@@ -99,7 +99,7 @@ public class OfflineSynchController {
} }
/** /**
* 根据taskId删除任务 * 根据taskId删除离线任务
* *
* @return * @return
* @author Bellamy * @author Bellamy
......
...@@ -113,7 +113,7 @@ public class RealTimeSyncController { ...@@ -113,7 +113,7 @@ public class RealTimeSyncController {
if (StringUtils.isEmpty(realTaskId)) { if (StringUtils.isEmpty(realTaskId)) {
return new JsonResult(ResultCode.PARAMS_ERROR, "任务id不能为空!"); return new JsonResult(ResultCode.PARAMS_ERROR, "任务id不能为空!");
} }
boolean jsonResult = dmpRealtimeSyncInfoService.deleteById(Integer.valueOf(realTaskId)); boolean jsonResult = dmpRealtimeSyncInfoService.deleteByrealTaskId(realTaskId);
if (jsonResult) { if (jsonResult) {
return new JsonResult(); return new JsonResult();
} else { } else {
...@@ -302,4 +302,31 @@ public class RealTimeSyncController { ...@@ -302,4 +302,31 @@ public class RealTimeSyncController {
JsonResult<RealTimeEditDataEchoDto> jsonResult = dmpRealtimeSyncInfoService.selectRealtimeTaskById(taskId); JsonResult<RealTimeEditDataEchoDto> jsonResult = dmpRealtimeSyncInfoService.selectRealtimeTaskById(taskId);
return jsonResult; return jsonResult;
} }
/**
* 批量上下线
*
* @return
* @author Bellamy
* @since 2021-01-05
*/
@ApiOperation(value = "批量上下线", notes = "批量上下线")
@GetMapping(value = "/batchUptOnlineStatus")
@ApiImplicitParams({@ApiImplicitParam(name = "realTaskId", value = "任务id",required = true),
@ApiImplicitParam(name = "onlineStatus", value = "上下线状态:Y 上线,N 下线",required = true)})
public JsonResult batchUptOnlineStatus(@RequestParam String realTaskId,@RequestParam String onlineStatus) throws Exception {
logger.info("###################请求参数{}taskId=" + realTaskId + "###################");
if (StringUtils.isEmpty(realTaskId)) {
return new JsonResult(ResultCode.PARAMS_ERROR, "任务id不能为空!");
}
if (StringUtils.isEmpty(onlineStatus)) {
return new JsonResult(ResultCode.PARAMS_ERROR, "状态不能为空!");
}
boolean jsonResult = dmpRealtimeSyncInfoService.batchUptOnlineStatus(realTaskId,onlineStatus);
if (jsonResult) {
return JsonResult.ok();
} else {
return JsonResult.error("删除失败!");
}
}
} }
\ No newline at end of file
...@@ -80,6 +80,9 @@ public class RealTimeSyncListDto { ...@@ -80,6 +80,9 @@ public class RealTimeSyncListDto {
@ApiModelProperty(value = "去向数据源类型") @ApiModelProperty(value = "去向数据源类型")
private String targetDatabaseType; private String targetDatabaseType;
@ApiModelProperty(value = "上下线状态:Y 上线,N 下线")
private String onlineStatus;
public String getId() { public String getId() {
return id; return id;
} }
...@@ -167,4 +170,12 @@ public class RealTimeSyncListDto { ...@@ -167,4 +170,12 @@ public class RealTimeSyncListDto {
public void setTargetDatabaseType(String targetDatabaseType) { public void setTargetDatabaseType(String targetDatabaseType) {
this.targetDatabaseType = targetDatabaseType; this.targetDatabaseType = targetDatabaseType;
} }
public String getOnlineStatus() {
return onlineStatus;
}
public void setOnlineStatus(String onlineStatus) {
this.onlineStatus = onlineStatus;
}
} }
...@@ -22,7 +22,7 @@ public class SourceDbNameListDto { ...@@ -22,7 +22,7 @@ public class SourceDbNameListDto {
/* /*
* 源数据库名称 * 源数据库名称
* */ * */
@ApiModelProperty(value = "源数据库名称") @ApiModelProperty(value = "数据源名称")
String datasourceNameOrg; String datasourceNameOrg;
/* /*
...@@ -40,7 +40,7 @@ public class SourceDbNameListDto { ...@@ -40,7 +40,7 @@ public class SourceDbNameListDto {
/* /*
* 源数据库和数据库类型名称 * 源数据库和数据库类型名称
* */ * */
@ApiModelProperty(value = "源数据库和数据库类型名称") @ApiModelProperty(value = "数据源和数据库类型名称")
String datasourceName; String datasourceName;
/* /*
......
...@@ -32,6 +32,12 @@ public class TaskListPageReq extends BasePageBean { ...@@ -32,6 +32,12 @@ public class TaskListPageReq extends BasePageBean {
@ApiModelProperty(value = "创建人") @ApiModelProperty(value = "创建人")
private String createUserId; private String createUserId;
/*
* 任务名称
* */
@ApiModelProperty(value = "任务名称")
private String treeName;
// /* // /*
// * 父类ID // * 父类ID
// * */ // * */
...@@ -83,4 +89,12 @@ public class TaskListPageReq extends BasePageBean { ...@@ -83,4 +89,12 @@ public class TaskListPageReq extends BasePageBean {
public void setCreateUserId(String createUserId) { public void setCreateUserId(String createUserId) {
this.createUserId = createUserId; this.createUserId = createUserId;
} }
public String getTreeName() {
return treeName;
}
public void setTreeName(String treeName) {
this.treeName = treeName;
}
} }
...@@ -21,6 +21,12 @@ public class DataDevTaskListDto { ...@@ -21,6 +21,12 @@ public class DataDevTaskListDto {
@ApiModelProperty(value = "任务ID") @ApiModelProperty(value = "任务ID")
private String taskId; private String taskId;
/*
* treeId
* */
@ApiModelProperty(value = "treeId")
private String treeId;
/* /*
* 任务名称 * 任务名称
* */ * */
...@@ -168,4 +174,12 @@ public class DataDevTaskListDto { ...@@ -168,4 +174,12 @@ public class DataDevTaskListDto {
public void setType(String type) { public void setType(String type) {
this.type = type; this.type = type;
} }
public String getTreeId() {
return treeId;
}
public void setTreeId(String treeId) {
this.treeId = treeId;
}
} }
...@@ -27,16 +27,16 @@ public class DataDevTaskListReq extends BasePageBean { ...@@ -27,16 +27,16 @@ public class DataDevTaskListReq extends BasePageBean {
private String projectId; private String projectId;
/* /*
* 节点名称或id * 任务名称或id
* */ * */
@ApiModelProperty(value = "节点名称或id") @ApiModelProperty(value = "任务名称或id")
private String treeIdOrName; private String treeIdOrName;
/* /*
* 节点id * 任务id
* */ * */
@ApiModelProperty(value = "节点id") @ApiModelProperty(value = "任务id")
private String treeId; private String taskId;
/* /*
* 任务类型 * 任务类型
...@@ -60,12 +60,12 @@ public class DataDevTaskListReq extends BasePageBean { ...@@ -60,12 +60,12 @@ public class DataDevTaskListReq extends BasePageBean {
this.treeIdOrName = treeIdOrName; this.treeIdOrName = treeIdOrName;
} }
public String getTreeId() { public String getTaskId() {
return treeId; return taskId;
} }
public void setTreeId(String treeId) { public void setTaskId(String taskId) {
this.treeId = treeId; this.taskId = taskId;
} }
public String getTaskType() { public String getTaskType() {
......
package com.jz.dmp.modules.controller.dataService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.dmp.modules.controller.dataService.bean.*;
import com.jz.dmp.modules.service.DmpApiMangeService;
import com.jz.dmp.modules.service.DmpOrgMangeService;
import io.swagger.annotations.Api;
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.*;
import javax.servlet.http.HttpServletRequest;
/**
* 数据服务Api管理--调用gateway 接口
*
* @author Bellamy
* @since 2021-01-18 10:56:18
*/
@RestController
@RequestMapping("/apiMange")
@Api(tags = "数据服务-Api管理")
public class DmpApiMangeController {
private static Logger logger = LoggerFactory.getLogger(DmpApiMangeController.class);
/**
* 服务对象
*/
@Autowired
private DmpApiMangeService dmpApiMangeService;
/**
* 授权给他人的API-列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation(value = "授权给他人的API-列表分页查询", notes = "列表分页查询")
@PostMapping(value = "/apiAuthListPage")
public JsonResult getApiAuthListPage(@RequestBody @Validated AuthListInfoReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.queryApiAuthListPage(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 取消授权
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation(value = "取消授权", notes = "取消授权")
@GetMapping(value = "/cancelApiAuth")
@ApiImplicitParam(name = "id", value = "授权id", required = true)
public JsonResult getCancelApiAuth(@RequestParam String id, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "授权id不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.cancelApiAuth(id);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 发布的API-API列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation(value = "发布的API-API列表分页查询", notes = "列表分页查询")
@PostMapping(value = "/listPage")
public JsonResult getApiListPage(@RequestBody @Validated ApiInterfaceInfoListReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.queryApiListPage(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 删除api
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation(value = "删除api", notes = "删除api")
@GetMapping(value = "/delApiInfo")
@ApiImplicitParams({@ApiImplicitParam(name = "apiKey", value = "apiKey", required = true),
@ApiImplicitParam(name = "type", value = "类型", required = false)})
public JsonResult delApiInfo(@RequestParam String apiKey, @RequestParam(required = false) String type, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(apiKey)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "apiKey不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.delApiInfo(apiKey, type);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 根据apiid获取API详情
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "获取API详情", notes = "获取API详情")
@GetMapping(value = "/getApiInfo")
@ApiImplicitParam(name = "id", value = "ApiId", required = true)
public JsonResult getApiInfoByApiId(@RequestParam String id, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(id)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "apiId不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.queryApiInfoByApiId(id);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 授权给组织-提交保存
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "授权给组织-提交保存", notes = "授权给组织-提交保存")
@PostMapping(value = "/addApiAuthToOrg")
public JsonResult addApiAuthToOrg(@RequestBody @Validated AuthUserApiReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.addApiAuthToOrg(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* API测试
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "API测试", notes = "API测试")
@GetMapping(value = "/apiTestInfo")
@ApiImplicitParam(name = "apiKey", value = "apiKey", required = true)
public JsonResult getApiTestInfo(@RequestParam String apiKey, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(apiKey)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "apiKey不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.apiTestInfo(apiKey);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 查看日志
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "查看日志", notes = "查看日志")
@PostMapping(value = "/checkApiLogInfo")
public JsonResult checkApiLogInfo(@RequestBody LogInfoListReq req, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(req.getApiKey())) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "apiKey不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.checkApiLogInfo(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 授权模糊查询组织信息
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "授权模糊查询组织信息", notes = "授权模糊查询组织信息")
@GetMapping(value = "/authOrgList")
@ApiImplicitParam(name = "key", value = "key", required = true)
public JsonResult getAuthOrgList(@RequestParam String key, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(key)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "key不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.getAuthOrgList(key);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
}
\ No newline at end of file
package com.jz.dmp.modules.controller.dataService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.DataIntegration.bean.SoureAndTargetColumnsReq;
import com.jz.dmp.modules.controller.dataService.bean.*;
import com.jz.dmp.modules.service.DmpApiMangeService;
import com.jz.dmp.modules.service.DmpApiServiceMangeService;
import com.jz.dmp.modules.service.OfflineSynchService;
import io.swagger.annotations.Api;
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.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
/**
* 数据服务-服务管理--调用gateway 接口
*
* @author Bellamy
* @since 2021-01-18 10:56:18
*/
@RestController
@RequestMapping("/apiService")
@Api(tags = "数据服务-服务管理")
public class DmpApiServiceMangeController {
private static Logger logger = LoggerFactory.getLogger(DmpApiServiceMangeController.class);
/**
* 服务对象
*/
@Autowired
private DmpApiServiceMangeService dmpApiServiceMangeService;
@Autowired
private DmpApiMangeService dmpApiMangeService;
@Autowired
private OfflineSynchService offlineSynchService;
/**
* 保存API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "保存API(第三方)", notes = "保存API(第三方)")
@PostMapping(value = "/saveApi")
public JsonResult saveApiInfo(@RequestBody @Validated ApiInterfaceReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.saveApiInfo(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 保存API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "保存API(大数据查询/标签查询)", notes = "保存API(大数据查询/标签查询)")
@PostMapping(value = "/saveApiBigData")
public JsonResult saveApiBigDataInfo(@RequestBody @Validated MakeBigDataApiReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.saveApiBigDataInfo(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 编辑API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-20
*/
@ApiOperation(value = "编辑API(第三方)", notes = "编辑API(第三方)")
@PostMapping(value = "/updataApi")
public JsonResult updateApiInfo(@RequestBody @Validated ApiInterfaceReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.updateApiInfo(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 编辑API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "编辑API(大数据查询/标签查询)", notes = "编辑API(大数据查询/标签查询)")
@PostMapping(value = "/updateApiBigData")
public JsonResult updateApiBigDataInfo(@RequestBody @Validated MakeBigDataApiReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.updateApiBigDataInfo(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* API计量调用次数和执行时长
*
* @author Bellamy
* @since 2021-01-20
*/
@ApiOperation(value = "API计量--调用次数和执行时长", notes = "API计量调用次数和执行时长")
@GetMapping(value = "/countAPiCallStat")
//@ApiImplicitParam(name = "date", value = "date", required = true)
public JsonResult countAPiCallStat(HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.getCountAPiCallStat();
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* API计量--API列表
*
* @author Bellamy
* @since 2021-01-19
*/
@ApiOperation(value = "API计量--API列表", notes = "API计量--API列表")
@PostMapping(value = "/apiCountListPage")
public JsonResult apiCountListPage(@RequestBody @Validated ApiInterfaceInfoListReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.queryApiListPage(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 获取数据源库——下拉框
*
* @return
* @author Bellamy
*/
@ApiOperation(value = "获取数据源库-下拉框", notes = "获取数据源库")
@GetMapping(value = "/sourceDbList")
@ApiImplicitParams({@ApiImplicitParam(name = "projectId", value = "项目id", required = true),
@ApiImplicitParam(name = "dbName", value = "数据源类型名称", required = true)})
public JsonResult<List<SourceDbNameListDto>> getSourceDbList(@RequestParam Integer projectId,@RequestParam String dbName) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiServiceMangeService.querygSourceDbList(projectId,dbName);
} catch (Exception e) {
jsonResult.setMessage("查询失败");
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 配置数据源——下拉框
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@ApiOperation(value = "配置数据源-下拉框", notes = "配置数据源")
@GetMapping(value = "/sourceSetting")
public JsonResult getSourceSetting() throws Exception {
return dmpApiServiceMangeService.getSourceSetting();
}
/**
* 根据数据源库id,获取数据源表——下拉框
*
* @return
* @author Bellamy
*/
@ApiOperation(value = "根据数据源库id,获取数据源表-下拉框", notes = "根据数据源库id,获取数据源表")
@GetMapping(value = "/sourceTableList")
@ApiImplicitParam(name = "sourceDbId", value = "数据源库id", required = true)
public JsonResult getSourceTableList(@RequestParam Long sourceDbId, @RequestParam(value = "targetName", required = false) String targetName) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = offlineSynchService.querygSourceTableList(sourceDbId, targetName);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 获取数据源表字段
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
@PostMapping(value = "/getTableColumns")
public JsonResult getTableColumns(@RequestBody @Validated SoureTableColumnsReq req) throws Exception {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = offlineSynchService.querySoureTableColumns(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
}
\ No newline at end of file
package com.jz.dmp.modules.controller.dataService;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.dmp.modules.controller.dataOperation.bean.DataDevTaskListDto;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq;
import com.jz.dmp.modules.service.DmpOrgMangeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
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.*;
import javax.servlet.http.HttpServletRequest;
/**
* 数据服务组织管理--调用gateway 接口
*
* @author Bellamy
* @since 2020-12-24 10:56:18
*/
@RestController
@RequestMapping("/orgMange")
@Api(tags = "数据服务-组织管理")
public class DmpOrgMangeController {
private static Logger logger = LoggerFactory.getLogger(DmpOrgMangeController.class);
/**
* 服务对象
*/
@Autowired
private DmpOrgMangeService dmpOrgMangeService;
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "列表分页查询", notes = "列表分页查询")
@PostMapping(value = "/listPage")
public JsonResult getOrgListPage(@RequestBody @Validated OrganizationManageListQueryReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.queryOrgListPage(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "删除组织", notes = "删除组织")
@GetMapping(value = "/delOrg")
@ApiImplicitParam(name = "id", value = "组织id", required = true)
public JsonResult delOrgById(@RequestParam long id, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.delOrgById(id);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "新增组织", notes = "新增组织")
@PostMapping(value = "/addOrg")
public JsonResult addOrg(@RequestBody @Validated OrganizationManageAddReq req, HttpServletRequest httpRequest) {
if (StringUtils.isEmpty(req.getOrgName())) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "组织名称不能为空!");
}
if (StringUtils.isEmpty(req.getOrgType())) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "组织类型不能为空!");
}
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.addOrg(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@ApiOperation(value = "编辑组织", notes = "编辑组织")
@PostMapping(value = "/updateOrg")
public JsonResult updateOrg(@RequestBody @Validated OrganizationManageUpdateReq req, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpOrgMangeService.updateOrg(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
/**
* 根据组织id获取组织详情
*
* @author Bellamy
* @since 2021-01-18
*/
@ApiOperation(value = "根据组织id获取组织详情", notes = "根据组织id获取组织详情")
@GetMapping(value = "/orgInfo")
@ApiImplicitParam(name = "id", value = "组织id", required = true)
public JsonResult getOrgInfoByOrgId(@RequestParam String id, HttpServletRequest httpRequest) {
JsonResult jsonResult = new JsonResult();
if (StringUtils.isEmpty(id)) {
return JsonResult.error(ResultCode.PARAMS_ERROR, "组织id不能为空!");
}
try {
jsonResult = dmpOrgMangeService.getOrgInfoByOrgId(id);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
}
\ No newline at end of file
package com.jz.dmp.modules.controller.dataService.bean;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName: ApiInterfaceInfoListReq
* @Description: 发布的API-APi列表请求对象
* @Author: Bellamy
* @Date 2021/1/18
* @Version 1.0
*/
@Data
@ApiModel("发布的API-APi列表请求对象")
public class ApiInterfaceInfoListReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "状态:SUCCEED 请求成功, FAIL 请求失败")
private String status;
@ApiModelProperty(value = "ApiKey")
private String apiKey;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: ApiInterfaceReq
* @Description: api基本信息
* @Author: Bellamy
* @Date 2021/1/19
* @Version 1.0
*/
@Data
@ApiModel(value = "api基本信息")
public class ApiInterfaceReq implements Serializable {
@ApiModelProperty(value = "接口描述", required = false)
public String apiDesc;
@ApiModelProperty(value = "传输方式:http https", required = true)
@NotNull(message = "传输方式不能为空")
public String transMode;
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA", required = true)
@NotNull(message = "加密方式不能为空")
public String signType;
@ApiModelProperty(value = "接入类型:对应字典表key", required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
@ApiModelProperty(value = "目标地址", required = true)
@NotNull(message = "目标地址不能为空")
public String targetUrl;
@ApiModelProperty(value = "超时时间", required = true)
@NotNull(message = "超时时间不能为空")
public String timeout;
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年", required = true)
@NotNull(message = "限流类型不能为空")
public String reqType;
@ApiModelProperty(value = "限制次数", required = false)
public Long reqFrequency;
@ApiModelProperty(value = "api描述", required = false)
public String apiFunction;
@ApiModelProperty(value = "父类文件id,一级文件夹传入0", required = false)
public Long parentId;
@ApiModelProperty(value = "文件id", required = false)
public Long fileId;
@ApiModelProperty(value = "项目id", required = true)
@NotNull(message = "项目id不能为空")
public Long projectId;
@ApiModelProperty(value = "状态", required = false)
public String status;
@ApiModelProperty(value = "更新时传入api自增id", required = false)
public Long id;
@ApiModelProperty(value = "创建用户")
public String createUser;
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义", hidden = true)
public String apiType;
@ApiModelProperty(value = "请求方式")
public String reqMethod;
}
package com.jz.dmp.modules.controller.dataService.bean;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName: AuthListInfoReq
* @Description: 授权认证信息列表请求对象
* @Author: Bellamy
* @Date 2021/1/18
* @Version 1.0
*/
@Data
@ApiModel("授权认证信息列表请求对象")
public class AuthListInfoReq extends BasePageBean implements Serializable {
private static final long serialVersionUID = 6807722745717042029L;
@ApiModelProperty(value = "apiKey api唯一标识", required = false)
private String apiKey;
@ApiModelProperty(value = "授权码", required = false)
private String authCode;
@ApiModelProperty(value = "API名称", required = false)
private String apiName;
@ApiModelProperty(value = "项目id")
private String projectId;
@ApiModelProperty(value = "文件id")
private String fileId;
}
package com.jz.dmp.modules.controller.dataService.bean;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.Date;
/**
* @ClassName: AuthUserApiReq
* @Description: API认证授权
* @Author: Bellamy
* @Date 2021/1/19
* @Version 1.0
*/
@Data
@ApiModel("API认证授权")
public class AuthUserApiReq implements Serializable {
@ApiModelProperty(value = "apiKey唯一标识",required = true)
@NotNull(message = "apiKey唯一标识不能为空")
@NotEmpty(message = "apiKey唯一标识不能为空")
private String apiKey;
@ApiModelProperty(value = "组织编码",required = true)
@NotNull(message = "组织编码不能为空")
@NotEmpty(message = "组织编码不能为空")
private String orgCode;
@ApiModelProperty(value = "授权方式:POWER_CALL_MODE 按次调用 ,RECORD_TIME_MODE 按时间调用,PERMANENT_TIME_MODE 永久有效",required = true)
@NotNull(message = "授权方式不能为空")
private String authMode;
@ApiModelProperty(value = "创建用户",required = false)
private String createUser;
}
package com.jz.dmp.modules.controller.dataService.bean;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName: AuthListInfoReq
* @Description: 日志信息列表请求对象
* @Author: Bellamy
* @Date 2021/1/18
* @Version 1.0
*/
@Data
@ApiModel("日志信息列表请求对象")
public class LogInfoListReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "ApiKey")
private String apiKey;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
import java.util.Map;
/**
* @ClassName: MakeBigDataApiReq
* @Description: Api制作大数据查询
* @Author: Bellamy
* @Date 2021/1/19
* @Version 1.0
*/
@Data
@ApiModel("Api制作大数据查询/标签查询请求体")
public class MakeBigDataApiReq implements Serializable {
@ApiModelProperty(value = "接口描述",required = false)
public String apiDesc;
@ApiModelProperty(value = "传输方式:http https",required = true)
@NotNull(message = "传输方式不能为空")
public String transMode;
@ApiModelProperty(value = "加密方式0 无,1:MD5 2:RSA",required = true)
@NotNull(message = "加密方式不能为空")
public String signType;
@ApiModelProperty(value = "接入类型:对应字典表key",required = true)
@NotNull(message = "接入类型不能为空")
public String joinType;
@ApiModelProperty(value = "目标地址",required = true)
@NotNull(message="目标地址不能为空")
public String targetUrl;
@ApiModelProperty(value = "超时时间",required = true)
@NotNull(message="超时时间不能为空")
public String timeout;
@ApiModelProperty(value = "限流类型:DAY 按天,MONTH 按月, YEAR 按年",required = true)
@NotNull(message = "限流类型不能为空")
public String reqType;
@ApiModelProperty(value = "限制次数",required = false)
public Long reqFrequency;
@ApiModelProperty(value = "api描述",required = false)
public String apiFunction;
@ApiModelProperty(value = "父类文件id,一级文件夹传入0",required = false)
public Long parentId;
@ApiModelProperty(value = "文件id",required = false)
public Long fileId;
@ApiModelProperty(value = "项目id",required = true)
@NotNull(message="项目id不能为空")
public Long projectId;
@ApiModelProperty(value = "状态",required = false)
public String status;
@ApiModelProperty(value = "更新时传入api自增id",required = false)
public Long id;
@ApiModelProperty(value = "api类型:1.数据银行制作大数据表 " +
"2 数据银行制作数据包,3,数据银行制作自定义API " +
"4 API实时接入 6 标签查询 9自定义",hidden = true)
public String apiType;
@ApiModelProperty(value = "apiKey",required = false)
public String apiKey;
@ApiModelProperty(value = "数据源Id",required = true)
@NotNull(message = "数据源Id不能为空")
private String esDataSource;
@ApiModelProperty(value = "源库名称",required = true)
@NotNull(message = "源库名称不能为空")
private String esDataBase;
@ApiModelProperty(value = "源表名称",required = true)
@NotNull(message = "源表名称不能为空")
private String esTable;
@ApiModelProperty(value = "处理类型",required = true)
@NotNull(message = "处理类型不能为空")
private String handleType;
@ApiModelProperty(value = "请求参数",required = true)
@NotNull(message = "请求参数不能为空")
private String requestParam;
@ApiModelProperty(value = "返回参数",required = true)
@NotNull(message = "返回参数不能为空")
private String responseParam;
@ApiModelProperty(value = "段列表",required = true)
@NotNull(message = "字段列表不能为空")
private String tableFields;
@ApiModelProperty(value = "创建用户",required = false)
public String createUser;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: OrganizationManageAddReq
* @Description: 新增组织管理请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel("新增组织管理详情请求体")
public class OrganizationManageAddReq implements Serializable {
private static final long serialVersionUID = 3131683881168540907L;
@ApiModelProperty(value = "组织类型:INT 内部组织 OUT 外部组织", required = true)
@NotNull(message = "组织类型不能为空!")
@NotEmpty(message = "组织类型不能为空!")
private String orgType;
@ApiModelProperty(value = "组织名称", required = true)
@NotNull(message = "组织名称不能为空")
@NotEmpty(message = "组织名称不能为空!")
private String orgName;
@ApiModelProperty(value = "组织描述")
private String orgDesc;
@ApiModelProperty(value = "组织英文名称")
private String orgCnName;
@ApiModelProperty(value = "组织邮箱")
private String orgMail;
@ApiModelProperty(value = "联系方式", required = true)
@NotEmpty(message = "联系方式不能为空!")
private String orgPhone;
@ApiModelProperty(value = "联系人")
private String linkman;
@ApiModelProperty(value = "状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)", required = true)
private Boolean status;
@ApiModelProperty(value = "创建人")
private String createUser;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author ZC
* @PACKAGE_NAME: com.jz.dm.models.req
* @PROJECT_NAME: jz-dm-parent
* @NAME: OrganizationManageListQueryReq
* @DATE: 2020-12-24/10:34
* @DAY_NAME_SHORT: 周四
* @Description:
**/
@Data
@ApiModel("组织管理详情请求体")
public class OrganizationManageDetailQueryReq implements Serializable {
@ApiModelProperty(value = "组织id",required = true)
@NotNull(message = "组织id不能为空")
private Long id;
}
package com.jz.dmp.modules.controller.dataService.bean;
import com.jz.common.bean.BasePageBean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @ClassName: DmpOrgMangeService
* @Description: 组织管理列表查询请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel("组织管理列表查询请求体")
public class OrganizationManageListQueryReq extends BasePageBean implements Serializable {
@ApiModelProperty(value = "组织名称")
private String orgName;
@ApiModelProperty(value = "组织编码(组织唯一标识)")
private String orgCode;
@ApiModelProperty(value = "联系人")
private String linkman;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: OrganizationManageUpdateReq
* @Description: 更新组织管理请求体
* @Author: Bellamy
* @Date 2021/1/16
* @Version 1.0
*/
@Data
@ApiModel("更新组织管理请求体")
public class OrganizationManageUpdateReq implements Serializable {
@ApiModelProperty(value = "组织id",required = true)
@NotNull(message = "组织id不能为空")
private Long id;
@ApiModelProperty(value = "组织类型:INT 内部组织 OUT 外部组织", required = true)
@NotNull(message = "组织类型不能为空!")
@NotEmpty(message = "组织类型不能为空!")
private String orgType;
@ApiModelProperty(value = "组织名称", required = true)
@NotNull(message = "组织名称不能为空")
@NotEmpty(message = "组织名称不能为空!")
private String orgName;
@ApiModelProperty(value = "组织描述")
private String orgDesc;
@ApiModelProperty(value = "组织英文名称")
private String orgCnName;
@ApiModelProperty(value = "组织邮箱")
private String orgMail;
@ApiModelProperty(value = "联系方式", required = true)
@NotEmpty(message = "联系方式不能为空!")
private String orgPhone;
@ApiModelProperty(value = "联系人")
private String linkman;
@ApiModelProperty(value = "状态(NORMAL-正常 FREEZE-冻结 CANCEL-注销)", required = true)
private Boolean status;
@ApiModelProperty(value = "创建人")
private String createUser;
}
package com.jz.dmp.modules.controller.dataService.bean;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @ClassName: SoureTableColumnsReq
* @Description: 获取数据源表字段
* @Author:Bellamy
* @Date 2020/12/21
* @Version 1.0
*/
@ApiModel(value = "获取数据源表字段-请求参数对象", description = "获取数据源表字段-请求参数对象")
public class SoureTableColumnsReq implements Serializable {
private static final long serialVersionUID = -3931329194480499602L;
/*
* 源数据库ID
* */
@NotNull(message = "源数据库ID不能为空")
@ApiModelProperty(value = "源数据库ID")
private Long sourceDbId;
@NotNull(message = "表名称不能为空")
@NotEmpty(message = "表名称不能为空")
@ApiModelProperty(value = "表名称")
private String targetTableName;
private String fileType;
private String csvDelimiter;
private String csvIsHaveHeader;
public Long getSourceDbId() {
return sourceDbId;
}
public void setSourceDbId(Long sourceDbId) {
this.sourceDbId = sourceDbId;
}
public String getTargetTableName() {
return targetTableName;
}
public void setTargetTableName(String targetTableName) {
this.targetTableName = targetTableName;
}
public String getFileType() {
return fileType;
}
public void setFileType(String fileType) {
this.fileType = fileType;
}
public String getCsvDelimiter() {
return csvDelimiter;
}
public void setCsvDelimiter(String csvDelimiter) {
this.csvDelimiter = csvDelimiter;
}
public String getCsvIsHaveHeader() {
return csvIsHaveHeader;
}
public void setCsvIsHaveHeader(String csvIsHaveHeader) {
this.csvIsHaveHeader = csvIsHaveHeader;
}
}
...@@ -177,4 +177,12 @@ public interface DmpRealtimeSyncInfoDao { ...@@ -177,4 +177,12 @@ public interface DmpRealtimeSyncInfoDao {
* @since 2021-01-12 * @since 2021-01-12
*/ */
List<Map> selectRealtimeTaskById(@Param("taskId") String taskId) throws Exception; 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 { ...@@ -97,7 +97,7 @@ public interface DmpSyncingDatasourceDao {
* @return * @return
* @author Bellamy * @author Bellamy
*/ */
void delDataSourceById(@Param("ids") String[] ids) throws Exception; void delDataSourceById(Map map) throws Exception;
/** /**
* 获取数据源类型-下拉框 * 获取数据源类型-下拉框
......
...@@ -29,5 +29,11 @@ public interface OfflineSynchDao { ...@@ -29,5 +29,11 @@ public interface OfflineSynchDao {
List<CheckJyRlueStatusDto> selectCheckJyStatusInfo(@Param("executionId") String executionId) throws Exception; List<CheckJyRlueStatusDto> selectCheckJyStatusInfo(@Param("executionId") String executionId) throws Exception;
/**
* 离线同步任务列表分页查询
*
* @return
* @author Bellamy
*/
List<TaskListPageDto> selectOfflineTaskInfo(TaskListPageReq taskListPageReq) throws Exception; List<TaskListPageDto> selectOfflineTaskInfo(TaskListPageReq taskListPageReq) throws Exception;
} }
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.controller.dataService.bean.*;
/**
* @ClassName: DmpApiMangeService
* @Description: 数据服务Api管理
* @Author: Bellamy
* @Date 2021/1/18
* @Version 1.0
*/
public interface DmpApiMangeService {
/**
* 授权给他人的API-列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult queryApiAuthListPage(AuthListInfoReq req) throws Exception;
/**
* 取消授权
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult cancelApiAuth(String id) throws Exception;
/**
* 发布的API-API列表分页查询
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult queryApiListPage(ApiInterfaceInfoListReq req) throws Exception;
/**
* 删除api
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult delApiInfo(String apiKey, String type) throws Exception;
/**
* 根据apiid获取API详情
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult queryApiInfoByApiId(String id) throws Exception;
/**
* 授权给组织-提交保存
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult addApiAuthToOrg(AuthUserApiReq req) throws Exception;
/**
* API测试
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult apiTestInfo(String apiKey) throws Exception;
/**
* 查看日志
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult checkApiLogInfo(LogInfoListReq req) throws Exception;
/**
* 授权模糊查询组织信息
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult getAuthOrgList(String key) throws Exception;
}
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.controller.dataService.bean.ApiInterfaceReq;
import com.jz.dmp.modules.controller.dataService.bean.MakeBigDataApiReq;
import com.jz.dmp.modules.model.DvRuleT;
import java.util.List;
/**
* 数据服务-服务管理--调用gateway 接口
*
* @author Bellamy
* @since 2021-01-18 10:56:18
*/
public interface DmpApiServiceMangeService {
/**
* 保存API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult saveApiInfo(ApiInterfaceReq req) throws Exception;
/**
* 保存API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
JsonResult saveApiBigDataInfo(MakeBigDataApiReq req) throws Exception;
/**
* 编辑API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-20
*/
JsonResult updateApiInfo(ApiInterfaceReq req) throws Exception;
/**
* 编辑API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-20
*/
JsonResult updateApiBigDataInfo(MakeBigDataApiReq req) throws Exception;
/**
* API计量调用次数和执行时长
*
* @author Bellamy
* @since 2021-01-20
*/
JsonResult getCountAPiCallStat() throws Exception;
/**
* 获取数据源库——下拉框
*
* @return
* @author Bellamy
*/
JsonResult querygSourceDbList(Integer projectId,String dbName) throws Exception;
/**
* 配置数据源——下拉框
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
JsonResult getSourceSetting() throws Exception;
}
\ No newline at end of file
package com.jz.dmp.modules.service;
import com.jz.common.constant.JsonResult;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq;
/**
* @ClassName: DmpOrgMangeService
* @Description: 数据服务组织管理
* @Author: Bellamy
* @Date 2021/1/15
* @Version 1.0
*/
public interface DmpOrgMangeService {
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult queryOrgListPage(OrganizationManageListQueryReq req) throws Exception;
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult delOrgById(long id) throws Exception;
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult addOrg(OrganizationManageAddReq req) throws Exception;
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception;
/**
* 根据组织id获取组织详情
*
* @author Bellamy
* @since 2021-01-18
*/
JsonResult getOrgInfoByOrgId(String id) throws Exception;
}
...@@ -127,4 +127,21 @@ public interface DmpRealtimeSyncInfoService { ...@@ -127,4 +127,21 @@ public interface DmpRealtimeSyncInfoService {
* @since 2021-01-12 * @since 2021-01-12
*/ */
JsonResult<RealTimeEditDataEchoDto> selectRealtimeTaskById(String taskId) throws Exception; JsonResult<RealTimeEditDataEchoDto> selectRealtimeTaskById(String taskId) throws Exception;
/**
* 批量删除数据源
*
* @return
* @author Bellamy
*/
boolean deleteByrealTaskId(String realTaskId) throws Exception;
/**
* 批量上下线
*
* @return
* @author Bellamy
* @since 2021-01-05
*/
boolean batchUptOnlineStatus(String realTaskId, String onlineStatus) throws Exception;
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import com.jz.common.constant.JsonResult; ...@@ -4,6 +4,7 @@ import com.jz.common.constant.JsonResult;
import com.jz.common.page.BasePageBean; import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse; import com.jz.common.page.PageInfoResponse;
import com.jz.dmp.modules.controller.DataIntegration.bean.*; import com.jz.dmp.modules.controller.DataIntegration.bean.*;
import com.jz.dmp.modules.controller.dataService.bean.SoureTableColumnsReq;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.List; import java.util.List;
...@@ -17,26 +18,88 @@ import java.util.Map; ...@@ -17,26 +18,88 @@ import java.util.Map;
* @Version 1.0 * @Version 1.0
*/ */
public interface OfflineSynchService { public interface OfflineSynchService {
/**
* 离线同步任务列表分页查询
*
* @return
* @author Bellamy
*/
PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception; PageInfoResponse<TaskListPageDto> queryTaskListPage(TaskListPageReq taskListPageReq) throws Exception;
/**
* 获取源数据库名称——下拉框
*
* @return
* @author Bellamy
*/
JsonResult querygSourceDbList(Integer projectId) throws Exception; JsonResult querygSourceDbList(Integer projectId) throws Exception;
/**
* 根据源数据库id,获取源数据表——下拉框
*
* @return
* @author Bellamy
*/
JsonResult querygSourceTableList(Long sourceDbId, String targetName) throws Exception; JsonResult querygSourceTableList(Long sourceDbId, String targetName) throws Exception;
/**
* 任务立即运行
*
* @return
* @author Bellamy
*/
JsonResult taskRunNowByTaskId(String taskId) throws Exception; JsonResult taskRunNowByTaskId(String taskId) throws Exception;
/**
* 根据taskId删除离线任务
*
* @return
* @author Bellamy
*/
JsonResult delTaskByTaskId(String taskId) throws Exception; JsonResult delTaskByTaskId(String taskId) throws Exception;
JsonResult<List<CheckTaskStatusPageDto>> queryCheckTaskStatusListPage(CheckTaskStatusPageReq checkTaskStatusPageReq) throws Exception; JsonResult<List<CheckTaskStatusPageDto>> queryCheckTaskStatusListPage(CheckTaskStatusPageReq checkTaskStatusPageReq) throws Exception;
PageInfoResponse<CheckJyRlueStatusDto> selectCheckJyStatusInfo(CheckJyRlueStatusReq checkJyRlueStatusReq) throws Exception; PageInfoResponse<CheckJyRlueStatusDto> selectCheckJyStatusInfo(CheckJyRlueStatusReq checkJyRlueStatusReq) throws Exception;
/**
* 获取源表和目标表的字段
*
* @return
* @author Bellamy
*/
JsonResult querySoureAndTargetColumnsByParams(SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception; JsonResult querySoureAndTargetColumnsByParams(SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception;
/**
* 校验规则
*
* @return
* @author Bellamy
*/
PageInfoResponse<DvRuleTDto> queryJyRuleListPage(BasePageBean basePageBean, HttpServletRequest httpRequest) throws Exception; PageInfoResponse<DvRuleTDto> queryJyRuleListPage(BasePageBean basePageBean, HttpServletRequest httpRequest) throws Exception;
/**
* 保存离线任务数据
*
* @return
* @author Bellamy
*/
JsonResult addSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception; JsonResult addSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception;
/**
* 编辑离线任务数据
*
* @return
* @author Bellamy
*/
JsonResult updateSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception; JsonResult updateSyncTask(SyncDmpTaskAddReq syncDmpTaskAddReq) throws Exception;
/**
* 获取数据源表字段
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
JsonResult querySoureTableColumns(SoureTableColumnsReq req) throws Exception;
} }
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.utils.DateUtils;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.common.utils.web.SessionUtils;
import com.jz.dmp.modules.controller.DataIntegration.bean.SourceDbNameListDto;
import com.jz.dmp.modules.controller.dataService.bean.ApiInterfaceReq;
import com.jz.dmp.modules.controller.dataService.bean.MakeBigDataApiReq;
import com.jz.dmp.modules.dao.DvRuleTDao;
import com.jz.dmp.modules.dao.OfflineSynchDao;
import com.jz.dmp.modules.model.DvRuleT;
import com.jz.dmp.modules.service.DmpApiServiceMangeService;
import com.jz.dmp.modules.service.DvRuleTService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* @ClassName: DmpApiServiceMangeServiceImpl
* @Description: 数据服务-服务管理--调用gateway 接口
* @Author: Bellamy
* @Date 2021/1/19
* @Version 1.0
*/
@Service("dmpApiServiceMangeService")
public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService {
private static Logger logger = LoggerFactory.getLogger(DmpApiServiceMangeServiceImpl.class);
//保存API(第三方)基本信息url
private static final String addApiInfo = "/api/producer/addCustomApi";
//保存API(大数据查询/标签查询)url
private static final String addApiBigData = "/api/producer/makeBigDataApi";
//编辑API(第三方)基本信息url
private static final String updateApiInfo = "/api/producer/saveUpdate";
//API计量调用次数和执行时长url
private static final String countAPiCallStat = "/api/logging/countAPiCallStat";
@Value("${spring.gateway-url}")
private String gatewayUrl;
@Value("${spring.api-bigData-setting}")
private String apiBigSetting;
@Autowired
private OfflineSynchDao offlineSynchDao;
/**
* 保存API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-19
*/
@Override
public JsonResult saveApiInfo(ApiInterfaceReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + addApiInfo;
req.setCreateUser(SessionUtils.getCurrentUserName());
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("保存失败!");
}
logger.info("#################响应结果数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
Map apiKey = JSONObject.parseObject(jsonObject.get("data").toString());
result.setData(apiKey.get("data")); // 新增API数据的apiKey
return result;
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(jsonObject.get("message").toString());
}
return result;
}
/**
* 保存API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-19
*/
@Override
public JsonResult saveApiBigDataInfo(MakeBigDataApiReq req) throws Exception {
JsonResult result = new JsonResult();
ApiInterfaceReq baseInfo = new ApiInterfaceReq();
BeanUtils.copyProperties(req, baseInfo);
//保存API基本信息
JsonResult apiKeyData = saveApiInfo(baseInfo);
String apiKey = apiKeyData.getData().toString();
if (StringUtils.isNotEmpty(apiKey)) {
logger.info("######apiKey=" + apiKey);
req.setApiKey(apiKey);
req.setCreateUser(SessionUtils.getCurrentUserName());
String url = gatewayUrl + addApiBigData;//保存API(大数据查询/标签查询)
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("保存失败!");
}
logger.info("#################响应结果数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
return result;
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(jsonObject.get("message").toString());
}
}
return result;
}
/**
* 编辑API(第三方)基本信息
*
* @author Bellamy
* @since 2021-01-20
*/
@Override
public JsonResult updateApiInfo(ApiInterfaceReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + updateApiInfo;
req.setCreateUser(SessionUtils.getCurrentUserName());
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("编辑失败!");
}
logger.info("#################响应结果数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
return result;
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(jsonObject.get("message").toString());
}
return result;
}
/**
* 编辑API(大数据查询/标签查询)
*
* @author Bellamy
* @since 2021-01-20
*/
@Override
public JsonResult updateApiBigDataInfo(MakeBigDataApiReq req) throws Exception {
ApiInterfaceReq baseApi = new ApiInterfaceReq();
BeanUtils.copyProperties(req, baseApi);
//编辑API基本信息
JsonResult baseRes = updateApiInfo(baseApi);
if (!"200".equals(baseRes.getCode())) {
throw new RuntimeException(baseRes.getMessage());
}
//编辑API(大数据查询/标签查询)
JsonResult result = new JsonResult();
req.setCreateUser(SessionUtils.getCurrentUserName());
String url = gatewayUrl + addApiBigData;
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("编辑失败!");
}
logger.info("#################响应结果数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
return result;
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
result.setMessage(jsonObject.get("message").toString());
}
return result;
}
/**
* API计量调用次数和执行时长
*
* @author Bellamy
* @since 2021-01-20
*/
@Override
public JsonResult getCountAPiCallStat() throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + countAPiCallStat;
Map params = new HashMap();
params.put("date", DateUtils.currentDate());
String returnData = HttpClientUtils.getJsonForParam(url, params);
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok(map.get("data"));
}
}
if (map.containsKey("message")) {
logger.info(map.get("message").toString());
result.setMessage(map.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result;
}
/**
* 获取数据源库——下拉框
*
* @return
* @author Bellamy
*/
@Override
public JsonResult querygSourceDbList(Integer projectId,String dbName) throws Exception {
Map map = new HashMap();
map.put("projectId", projectId); //项目id
map.put("dbName", dbName);
List<SourceDbNameListDto> list = offlineSynchDao.querygSourceDbList(map);
return JsonResult.ok(list);
}
/**
* 配置数据源——下拉框
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@Override
public JsonResult getSourceSetting() throws Exception {
String[] arr = apiBigSetting.split(",");
List<String> list = Arrays.asList(arr);
return JsonResult.ok(list);
}
}
\ No newline at end of file
package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.jcraft.jsch.Session;
import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode;
import com.jz.common.utils.web.HttpClientUtils;
import com.jz.common.utils.web.SessionUtils;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageAddReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageDetailQueryReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageListQueryReq;
import com.jz.dmp.modules.controller.dataService.bean.OrganizationManageUpdateReq;
import com.jz.dmp.modules.service.DmpOrgMangeService;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName: DmpOrgMangeServiceImpl
* @Description: 数据服务组织管理
* @Author: Bellamy
* @Date 2021/1/15
* @Version 1.0
*/
@Service("dmpOrgMangeService")
public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
private static Logger logger = LoggerFactory.getLogger(DmpOrgMangeServiceImpl.class);
//列表分页查询url
private static final String orgListPage = "/api/organization/listOrg";
//删除组织url
private static final String delOrg = "/api/organization/logoutOrg";
//新增组织url
private static final String addOrg = "/api/organization/add";
//编辑组织url
private static final String updateOrg = "/api/organization/update";
//根据组织id获取组织详情url
private static final String orgDetail = "/api/organization/getOrgDetail";
@Value("${spring.gateway-url}")
private String gatewayUrl;
/**
* 列表分页查询
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult queryOrgListPage(OrganizationManageListQueryReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + orgListPage;
if (StringUtils.isNotEmpty(req.getOrgName())) {
req.setOrgName(req.getOrgName().trim());
}
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################组织管理列数据{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) {
return JsonResult.ok(jsonObject.get("data"));
}
}
if (jsonObject.containsKey("message")) {
logger.info(jsonObject.get("message").toString());
result.setMessage(jsonObject.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result;
}
/**
* 删除组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult delOrgById(long id) throws Exception {
Map params = new HashMap();
params.put("id", id);
String url = gatewayUrl + delOrg;
String returnData = HttpClientUtils.getJsonForParam(url, params);
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("删除失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
return JsonResult.error("删除失败!");
}
/**
* 新增组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult addOrg(OrganizationManageAddReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + addOrg;
req.setCreateUser(SessionUtils.getCurrentUserName());
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("新增失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
if (map.containsKey("message")) {
logger.info(map.get("message").toString());
result.setMessage(map.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result;
}
/**
* 编辑组织
*
* @return
* @author Bellamy
* @since 2021-01-16
*/
@Override
public JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + addOrg;
req.setCreateUser(SessionUtils.getCurrentUserName());
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("编辑失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok();
}
}
if (map.containsKey("message")) {
logger.info(map.get("message").toString());
result.setMessage(map.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result;
}
/**
* 根据组织id获取组织详情
*
* @author Bellamy
* @since 2021-01-18
*/
@Override
public JsonResult getOrgInfoByOrgId(String id) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + orgDetail;
OrganizationManageDetailQueryReq req = new OrganizationManageDetailQueryReq();
req.setId(Long.valueOf(id));
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req));
if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("查询失败!");
}
logger.info("#################响应结果{}" + returnData);
Map map = JSONObject.parseObject(returnData);
if (map.containsKey("code")) {
if ("200".equals(map.get("code").toString())) {
return JsonResult.ok(map.get("data"));
}
}
if (map.containsKey("message")) {
logger.info(map.get("message").toString());
result.setMessage(map.get("message").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result;
}
}
...@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper; ...@@ -6,6 +6,7 @@ import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.jz.common.constant.JsonResult; import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode; import com.jz.common.constant.ResultCode;
import com.jz.common.enums.DelFlagEnum;
import com.jz.common.page.PageInfoResponse; import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService; import com.jz.common.persistence.BaseService;
import com.jz.common.utils.realTime.DBUtil; import com.jz.common.utils.realTime.DBUtil;
...@@ -821,4 +822,36 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic ...@@ -821,4 +822,36 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
} }
return new JsonResult(returnModel); 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;
}
/**
* 批量上下线
*
* @return
* @author Bellamy
* @since 2021-01-05
*/
@Override
public boolean batchUptOnlineStatus(String realTaskId, String onlineStatus) throws Exception {
Map map = new HashMap();
String[] ids = realTaskId.split(",");
map.put("ids", ids);
map.put("onlineStatus", onlineStatus);
return dmpRealtimeSyncInfoDao.deleteByrealTaskId(map) > 0;
}
} }
\ No newline at end of file
package com.jz.dmp.modules.service.impl; package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.amazonaws.services.dynamodbv2.xspec.M;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.jz.agent.service.DmpDsAgentService; import com.jz.agent.service.DmpDsAgentService;
import com.jz.common.constant.JsonResult; import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode; import com.jz.common.constant.ResultCode;
import com.jz.common.enums.DelFlagEnum;
import com.jz.common.enums.TestConnectStatusEnum; import com.jz.common.enums.TestConnectStatusEnum;
import com.jz.common.exception.ServiceException;
import com.jz.common.page.PageInfoResponse; import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService; import com.jz.common.persistence.BaseService;
import com.jz.common.utils.JsonMapper; import com.jz.common.utils.JsonMapper;
...@@ -151,8 +154,11 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ ...@@ -151,8 +154,11 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
@Override @Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED) @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRED)
public JsonResult delDataSourceById(String datasourceId) throws Exception { public JsonResult delDataSourceById(String datasourceId) throws Exception {
Map map = new HashMap();
String[] ids = datasourceId.split(","); String[] ids = datasourceId.split(",");
dmpSyncingDatasourceDao.delDataSourceById(ids); map.put("ids", ids);
map.put("dataStatus", DelFlagEnum.YES.getValue());
dmpSyncingDatasourceDao.delDataSourceById(map);
return new JsonResult(); return new JsonResult();
} }
...@@ -303,11 +309,12 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ ...@@ -303,11 +309,12 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
DmpAgentDatasourceInfo ds = this.dsInfoDTO(saveBody); //查询数据源 对应的 数据库信息 DmpAgentDatasourceInfo ds = this.dsInfoDTO(saveBody); //查询数据源 对应的 数据库信息
DmpAgentResult rst = dmpDsAgentServiceImp.testConnect(ds); //连接测试 DmpAgentResult rst = dmpDsAgentServiceImp.testConnect(ds); //连接测试
if (!rst.getCode().val().equals("200")) { if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage()); return new JsonResult(ResultCode.INTERNAL_SERVER_ERROR, "连接测试失败!");
} else { } else {
//连接测试成功 //连接测试成功
rst.setResult(JsonMapper.fromJsonString(rst.getMessage(), Boolean.class)); Object flag = JsonMapper.fromJsonString(rst.getMessage(), Boolean.class);
return new JsonResult(ResultCode.SUCCESS, rst); //rst.setResult(JsonMapper.fromJsonString(rst.getMessage(), Boolean.class));
return new JsonResult(ResultCode.SUCCESS, "连接测试成功!");
} }
} }
...@@ -423,6 +430,10 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ ...@@ -423,6 +430,10 @@ public class DmpSyncingDatasourceServiceImpl implements DmpSyncingDatasourceServ
ds.setDefaultFs(body.getDefaultFs()); ds.setDefaultFs(body.getDefaultFs());
DmpProjectSystemInfo info = dmpProjectDao.queryProjectSystemInfo(Long.valueOf(body.getProjectId())); DmpProjectSystemInfo info = dmpProjectDao.queryProjectSystemInfo(Long.valueOf(body.getProjectId()));
if (info == null) {
//throw new RuntimeException("未查询到对应的项目系统配置信息");
throw new ServiceException("未查询到对应的项目系统配置信息");
}
ds.setKerberosIsenable(info.getKerberosIsenable()); ds.setKerberosIsenable(info.getKerberosIsenable());
ds.setKerberosJaasConf(info.getKerberosJaasConf()); ds.setKerberosJaasConf(info.getKerberosJaasConf());
ds.setKerberosKrb5Conf(info.getKerberosKrb5Conf()); ds.setKerberosKrb5Conf(info.getKerberosKrb5Conf());
......
package com.jz.dmp.modules.service.impl; package com.jz.dmp.modules.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.jz.agent.service.DmpDsAgentService; import com.jz.agent.service.DmpDsAgentService;
import com.jz.common.constant.JsonResult; import com.jz.common.constant.JsonResult;
import com.jz.common.constant.ResultCode; import com.jz.common.constant.ResultCode;
import com.jz.common.enums.DelFlagEnum;
import com.jz.common.page.BasePageBean; import com.jz.common.page.BasePageBean;
import com.jz.common.page.PageInfoResponse; import com.jz.common.page.PageInfoResponse;
import com.jz.common.persistence.BaseService; import com.jz.common.persistence.BaseService;
...@@ -17,6 +19,7 @@ import com.jz.common.utils.web.XmlUtils; ...@@ -17,6 +19,7 @@ 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.controller.dataService.bean.SoureTableColumnsReq;
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.DmpDevelopTaskService;
...@@ -28,6 +31,7 @@ import org.slf4j.Logger; ...@@ -28,6 +31,7 @@ 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.security.access.method.P;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -87,6 +91,12 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -87,6 +91,12 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
@Autowired @Autowired
private DvTaskRuleTService dvTaskRuleTService; private DvTaskRuleTService dvTaskRuleTService;
/**
* 离线同步任务列表分页查询
*
* @return
* @author Bellamy
*/
@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<>();
...@@ -120,6 +130,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -120,6 +130,9 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
public JsonResult querygSourceTableList(Long sourceDbId, String targetName) throws Exception { public JsonResult querygSourceTableList(Long sourceDbId, String targetName) throws Exception {
//通过源数据库id ,查询数据源配置 //通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(sourceDbId); DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(sourceDbId);
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
//解码源数据库密码 //解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) { if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey)); dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
...@@ -133,13 +146,15 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -133,13 +146,15 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return new JsonResult(rst.getCode(), rst.getMessage()); return new JsonResult(rst.getCode(), rst.getMessage());
} else { } else {
//成功 //成功
rst.setResult(JsonMapper.fromJsonString(rst.getMessage(), List.class)); //rst.setResult(JsonMapper.fromJsonString(rst.getMessage(), List.class));
return new JsonResult(ResultCode.SUCCESS, rst); return new JsonResult(ResultCode.SUCCESS, JsonMapper.fromJsonString(rst.getMessage(), List.class));
} }
} }
/** /**
* 立即运行 * 立即运行
*
* @author Bellamy
*/ */
@Override @Override
public JsonResult taskRunNowByTaskId(String taskId) throws Exception { public JsonResult taskRunNowByTaskId(String taskId) throws Exception {
...@@ -223,20 +238,28 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -223,20 +238,28 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
} }
/** /**
* 删除任务 * 批量删除离线任务
*
* @author Bellamy
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW)
public JsonResult delTaskByTaskId(String taskId) throws Exception { 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,查询任务和资源是否存在 //通过taskId,查询任务和资源是否存在
Map map = dmpDevelopTaskDao.getDmpTaskAndTreeInfo(taskId); /*Map map = dmpDevelopTaskDao.getDmpTaskAndTreeInfo(taskId);
if (map.size() == 0 || map == null) { if (map == null) {
return new JsonResult(ResultCode.OPERATION_DATA_NO_EXIST); return new JsonResult(ResultCode.OPERATION_DATA_NO_EXIST);
} }
if (StringUtils.isEmpty(map.get("treeId").toString())) { if (StringUtils.isEmpty(map.get("treeId").toString())) {
return new JsonResult(ResultCode.OPERATION_DATA_NO_EXIST); 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); return new JsonResult(ResultCode.SUCCESS);
} }
...@@ -292,6 +315,12 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -292,6 +315,12 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
return pageInfoResponse; return pageInfoResponse;
} }
/**
* 获取源表和目标表的字段
*
* @return
* @author Bellamy
*/
@Override @Override
public JsonResult querySoureAndTargetColumnsByParams(SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception { public JsonResult querySoureAndTargetColumnsByParams(SoureAndTargetColumnsReq soureAndTargetColumnsReq) throws Exception {
//通过源数据库id ,查询数据源配置 //通过源数据库id ,查询数据源配置
...@@ -526,15 +555,15 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -526,15 +555,15 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
dmpNavigationTreeDao.update(dmpNavigationTree); //更新节点 树 dmpNavigationTreeDao.update(dmpNavigationTree); //更新节点 树
logger.info("################################## 更新节点 树 结束 ############################################"); logger.info("################################## 更新节点 树 结束 ############################################");
//更新规则信息 //更新规则信息
List<DvTaskRuleT> list =new ArrayList<>(); List<DvTaskRuleT> list = new ArrayList<>();
//查询TaskRuleID 集合 //查询TaskRuleID 集合
List<Long> listRules= dvTaskRuleTService.getTaskRuleIdsList(taskId); List<Long> listRules = dvTaskRuleTService.getTaskRuleIdsList(taskId);
if (CollectionUtils.isNotEmpty(listRules)){ if (CollectionUtils.isNotEmpty(listRules)) {
//批量删除rule信息 //批量删除rule信息
dvTaskRuleTService.delRulesByIds(listRules); dvTaskRuleTService.delRulesByIds(listRules);
List<Map> taskRules = (List<Map>)reqParam.get("taskRules"); List<Map> taskRules = (List<Map>) reqParam.get("taskRules");
//保存dmp数据校验规则信息 //保存dmp数据校验规则信息
settRuleInfo(String.valueOf(taskId),taskRules,list); settRuleInfo(String.valueOf(taskId), taskRules, list);
} }
//保存时提交XML //保存时提交XML
dmpDevelopTaskService.submitSyncing(task); dmpDevelopTaskService.submitSyncing(task);
...@@ -666,4 +695,43 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -666,4 +695,43 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
//批量新增任务与规则关系表 //批量新增任务与规则关系表
dvTaskRuleTService.saveRule(list); dvTaskRuleTService.saveRule(list);
} }
/**
* 获取数据源表字段
*
* @return
* @author Bellamy
* @since 2021-01-21
*/
@Override
public JsonResult querySoureTableColumns(SoureTableColumnsReq req) throws Exception {
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(req.getSourceDbId());
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
dsInfo.setFileType(req.getFileType());
dsInfo.setDelimiter(req.getCsvDelimiter());
dsInfo.setIsHaveHeader(req.getCsvIsHaveHeader());
//解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
//创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, req.getTargetTableName());
if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage());
} else {
//成功
List<Map> returnList = (List<Map>) JsonMapper.fromJsonString(rst.getMessage(), List.class);
if (returnList != null && returnList.size() > 0) {
for (int i = 0; i < returnList.size(); i++) {
Map map = returnList.get(i);
map.put("id", i + 1);
}
}
return JsonResult.ok(returnList);
}
}
} }
...@@ -42,7 +42,7 @@ ...@@ -42,7 +42,7 @@
, src_database_type, src_database_name, connector_url, target_database_type, target_database_name, src_datasource_name , 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 , target_datasource_name, store_type, status, create_time, update_time, cre_person, upt_person
from dmp_realtime_sync_info from dmp_realtime_sync_info
where id = #{id} where data_status='1' and id = #{id}
</select> </select>
<!--查询指定行数据--> <!--查询指定行数据-->
...@@ -321,12 +321,13 @@ ...@@ -321,12 +321,13 @@
t1.src_database_type as srcDatabaseType, t1.src_database_type as srcDatabaseType,
t1.target_datasource_id as targetDatasourceId, t1.target_datasource_id as targetDatasourceId,
t1.target_datasource_name as targetDatasourceName, t1.target_datasource_name as targetDatasourceName,
t1.target_database_type as targetDatabaseType t1.target_database_type as targetDatabaseType,
t1.online_status as onlineStatus
FROM dmp_realtime_sync_info t1 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 t3 ON t1.src_datasource_id = t3.ID
left join dmp_syncing_datasource t4 ON t1.target_datasource_id = t4.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="taskStatus != null and taskStatus != '' "> AND t1.status = #{taskStatus} </if>
<if test="treeId != null and treeId != '' "> AND t1.id = #{treeId} </if> <if test="treeId != null and treeId != '' "> AND t1.id = #{treeId} </if>
<if test="targetDatabaseTypeId != null and targetDatabaseTypeId != '' "> AND t4.DATASOURCE_TYPE = #{targetDatabaseTypeId} </if> <if test="targetDatabaseTypeId != null and targetDatabaseTypeId != '' "> AND t4.DATASOURCE_TYPE = #{targetDatabaseTypeId} </if>
...@@ -344,7 +345,7 @@ ...@@ -344,7 +345,7 @@
, src_database_type, src_database_name, connector_url, target_database_type, target_database_name, src_datasource_name , 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 , target_datasource_name, store_type, status, create_time, update_time, cre_person, upt_person
from dmp_realtime_sync_info 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=")"> <foreach collection="ids" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
...@@ -392,7 +393,7 @@ ...@@ -392,7 +393,7 @@
desensitization_field as desensitizationField, desensitization_field as desensitizationField,
arithmetic arithmetic
from dmp_realtime_sync_info 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} and src_datasource_id = #{srcDatasourceId}
<if test="targetDatasourceId != null"> and target_datasource_id = #{targetDatasourceId} </if> <if test="targetDatasourceId != null"> and target_datasource_id = #{targetDatasourceId} </if>
<if test="sourceTableName != null and sourceTableName !=''"> and src_table_name = #{sourceTableName} </if> <if test="sourceTableName != null and sourceTableName !=''"> and src_table_name = #{sourceTableName} </if>
...@@ -421,7 +422,7 @@ ...@@ -421,7 +422,7 @@
t1.target_database_type as targetDatabaseType t1.target_database_type as targetDatabaseType
FROM dmp_realtime_sync_info t1 FROM dmp_realtime_sync_info t1
left join dmp_navigation_tree t2 on t1.tree_id=t2.id 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="projectId !=null">and t1.project_id=#{projectId}</if>
<if test="taskStatus != null and taskStatus != '' "> AND t1.status = #{taskStatus} </if> <if test="taskStatus != null and taskStatus != '' "> AND t1.status = #{taskStatus} </if>
<if test="treeId != null and treeId != '' "> AND t1.id = #{treeId} </if> <if test="treeId != null and treeId != '' "> AND t1.id = #{treeId} </if>
...@@ -513,6 +514,23 @@ ...@@ -513,6 +514,23 @@
left join dmp_realtime_sync_blacklist_table_info t2 ON t1.id = t2.realtime_id 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 left join dmp_realtime_sync_select_table t3 on t1.id=t3.realtime_id
WHERE WHERE
1 = 1 and id = #{taskId} 1 = 1 and t1.data_status='1' and id = #{taskId}
</select> </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>
<if test="onlineStatus != null and onlineStatus != ''">
online_status = #{onlineStatus},
</if>
</trim>
where id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</update>
</mapper> </mapper>
\ No newline at end of file
...@@ -302,13 +302,18 @@ ...@@ -302,13 +302,18 @@
</select> </select>
<!--批量删除--> <!--批量删除-->
<delete id="delDataSourceById" parameterType="map"> <update id="delDataSourceById" parameterType="map">
delete from dmp_syncing_datasource update dmp_syncing_datasource
<trim prefix="SET" suffixOverrides=",">
<if test="dataStatus != null">
data_status = #{dataStatus},
</if>
</trim>
where ID in where ID in
<foreach collection="ids" item="item" open="(" separator="," close=")"> <foreach collection="ids" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</delete> </update>
<!--查询数据源类型名称--> <!--查询数据源类型名称-->
<select id="queryDatasourceType" resultType="map"> <select id="queryDatasourceType" resultType="map">
......
...@@ -49,17 +49,11 @@ ...@@ -49,17 +49,11 @@
dsdt.datasource_catecode as datasourceCatecode dsdt.datasource_catecode as datasourceCatecode
from dmp_syncing_datasource ds from dmp_syncing_datasource ds
inner join dmp_syncing_datasource_type dsdt on ds.datasource_type = dsdt.id inner join dmp_syncing_datasource_type dsdt on ds.datasource_type = dsdt.id
<if test = 'isEnableSource != null and isEnableSource == "1"'> <if test = 'isEnableSource != null and isEnableSource == "1"'> and dsdt.is_enable_source = '1' </if>
and dsdt.is_enable_source = '1' <if test = "isEnableTarget != null and isEnableTarget=='1'.toString()"> and dsdt.is_enable_target = '1' </if>
</if> where ds.data_status = '1' and ds.project_id = #{projectId}
<if test = "isEnableTarget != null and isEnableTarget=='1'.toString()"> <if test="dbName != null and dbName !='' "> and dsdt.datasource = #{dbName} </if>
and dsdt.is_enable_target = '1' <if test = 'datasourceType != null and datasourceType > 0 '> and ds.DATASOURCE_TYPE = #{datasourceType} </if>
</if>
where ds.data_status = '1'
and ds.project_id = #{projectId}
<if test = 'datasourceType != null and datasourceType > 0 '>
and ds.DATASOURCE_TYPE = #{datasourceType}
</if>
</select> </select>
<!--主键查询数据源--> <!--主键查询数据源-->
...@@ -144,7 +138,7 @@ ...@@ -144,7 +138,7 @@
from dmp_develop_task t1 from dmp_develop_task t1
inner 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_project_system_info t3 on t2.PROJECT_ID=t3.PROJECT_ID and t3.data_status = '1' 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> </select>
<!-- 根据执行实例id查询规则执行结果表 --> <!-- 根据执行实例id查询规则执行结果表 -->
...@@ -171,23 +165,23 @@ ...@@ -171,23 +165,23 @@
</if> </if>
</select> </select>
<!--离线同步列表-->
<select id="selectOfflineTaskInfo" resultType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto" <select id="selectOfflineTaskInfo" resultType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageDto"
parameterType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq"> parameterType="com.jz.dmp.modules.controller.DataIntegration.bean.TaskListPageReq">
SELECT SELECT
ddt.id AS taskId, ddt.id AS taskId,
ddt.tree_id AS treeId, ddt.tree_id AS treeId,
dnt.NAME AS treeName, dnt.NAME AS treeName,
dnt.CREATE_USER_ID as createUserId, t3.real_name as createUserId,
DATE_FORMAT( ddt.create_time, '%Y-%m-%d %H:%i:%s' ) AS createTime, 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.update_time, '%Y-%m-%d %H:%i:%s' ) AS updateTime
FROM dmp_develop_task AS ddt FROM dmp_develop_task ddt
INNER JOIN dmp_navigation_tree AS dnt ON ddt.TREE_ID = dnt.ID INNER join dmp_navigation_tree 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_member t3 on ddt.create_user_id=t3.user_id
WHERE ddt.data_status ='1' AND ddt.TYPE='3' AND ddt.TASK_TYPE ='2' left join dmp_syncing_datasource dsd ON instr(script,concat('"targetDbConnection":"',dsd.datasource_name,'"'))>0
AND dnt.CATEGORY='2' AND dnt.TYPE ='3' WHERE ddt.data_status ='1' and dnt.TYPE ='01' and dnt.IS_LEVEL ='1'
AND dnt.IS_LEVEL ='1' and dnt.PROJECT_ID =#{projectId}
AND dnt.PROJECT_ID =31 <if test="treeName != null and treeName != ''">dnt.NAME like concat('%',#{treeName},'%') </if>
AND dsd.PROJECT_ID=31
ORDER BY ddt.create_time DESC ORDER BY ddt.create_time DESC
</select> </select>
</mapper> </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