Commit 688f3c6a authored by mcb's avatar mcb

数据服务代码修改

parent 35a165e6
...@@ -74,13 +74,12 @@ public class GatewayApiConstant { ...@@ -74,13 +74,12 @@ public class GatewayApiConstant {
public static final String listServerApplyApi = "/api/interface/listServerApplyApi"; public static final String listServerApplyApi = "/api/interface/listServerApplyApi";
//获取文件夹树 //获取文件夹树
public static final String folderTree = "/api/producer/getFileCatalog"; public static final String folderTree = "/api/producer/getFileCatalog";
//服务开发---获取ApiId //服务开发---获取ApiId
public static final String getApiId = "/api/producer/getCustomApiId"; public static final String getApiId = "/api/producer/getCustomApiId";
//创建项目文件夹 //创建项目文件夹
public static final String createProjectFolder = "/api/producer/createProjectFolder"; public static final String createProjectFolder = "/api/producer/createProjectFolder";
//授权--组织名称查询
public static final String getOrgNameList = "/api/auth/get-org-list";
private static Logger logger = LoggerFactory.getLogger(GatewayApiConstant.class); private static Logger logger = LoggerFactory.getLogger(GatewayApiConstant.class);
...@@ -93,7 +92,7 @@ public class GatewayApiConstant { ...@@ -93,7 +92,7 @@ public class GatewayApiConstant {
if (StringUtils.isEmpty(resultData)) { if (StringUtils.isEmpty(resultData)) {
throw new RuntimeException("failed!"); throw new RuntimeException("failed!");
} }
logger.info("#################响应结果数据{}" + resultData); logger.info("############## response results{}" + resultData);
Map jsonObject = JSONObject.parseObject(resultData); Map jsonObject = JSONObject.parseObject(resultData);
if (jsonObject.containsKey("code")) { if (jsonObject.containsKey("code")) {
...@@ -121,7 +120,7 @@ public class GatewayApiConstant { ...@@ -121,7 +120,7 @@ public class GatewayApiConstant {
if (StringUtils.isEmpty(returnData)) { if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("failed!"); throw new RuntimeException("failed!");
} }
logger.info("#################响应结果{}" + returnData); logger.info("############## response results{}" + returnData);
Map jsonObject = JSONObject.parseObject(returnData); Map jsonObject = JSONObject.parseObject(returnData);
if (jsonObject.containsKey("code")) { if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) { if ("200".equals(jsonObject.get("code").toString())) {
...@@ -149,7 +148,7 @@ public class GatewayApiConstant { ...@@ -149,7 +148,7 @@ public class GatewayApiConstant {
if (StringUtils.isEmpty(returnData)) { if (StringUtils.isEmpty(returnData)) {
throw new RuntimeException("failed!"); throw new RuntimeException("failed!");
} }
logger.info("#################响应结果{}" + returnData); logger.info("############## response results{}" + returnData);
Map jsonObject = JSONObject.parseObject(returnData); Map jsonObject = JSONObject.parseObject(returnData);
if (jsonObject.containsKey("code")) { if (jsonObject.containsKey("code")) {
if ("200".equals(jsonObject.get("code").toString())) { if ("200".equals(jsonObject.get("code").toString())) {
......
...@@ -28,6 +28,9 @@ public class SynchTableColumnsReq implements Serializable { ...@@ -28,6 +28,9 @@ public class SynchTableColumnsReq implements Serializable {
@ApiModelProperty(value = "目标表名称") @ApiModelProperty(value = "目标表名称")
private String targetTableName; private String targetTableName;
@ApiModelProperty(value = "字段名称")
private String fieldName;
public Long getSourceDbId() { public Long getSourceDbId() {
return sourceDbId; return sourceDbId;
} }
...@@ -44,4 +47,11 @@ public class SynchTableColumnsReq implements Serializable { ...@@ -44,4 +47,11 @@ public class SynchTableColumnsReq implements Serializable {
this.sourceDbId = sourceDbId; this.sourceDbId = sourceDbId;
} }
public String getFieldName() {
return fieldName;
}
public void setFieldName(String fieldName) {
this.fieldName = fieldName;
}
} }
...@@ -370,4 +370,25 @@ public class DmpApiMangeController { ...@@ -370,4 +370,25 @@ public class DmpApiMangeController {
return jsonResult; return jsonResult;
} }
/**
* 授权--组织名称查询
*
* @author Bellamy
* @since 2021-03-02
*/
@ApiOperation(value = "授权--组织名称查询", notes = "授权--组织名称查询")
@GetMapping(value = "/getAuthOrgName")
@ApiImplicitParam(name = "orgName", value = "组织名称", required = true)
public JsonResult getAuthOrgName(@RequestParam String orgName) {
JsonResult jsonResult = new JsonResult();
try {
jsonResult = dmpApiMangeService.getAuthOrgName(orgName);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
e.printStackTrace();
}
return jsonResult;
}
} }
\ No newline at end of file
...@@ -132,4 +132,12 @@ public interface DmpApiMangeService { ...@@ -132,4 +132,12 @@ public interface DmpApiMangeService {
* @since 2021-02-20 * @since 2021-02-20
*/ */
JsonResult logDetails(String id) throws Exception; JsonResult logDetails(String id) throws Exception;
/**
* 授权--组织名称查询
*
* @author Bellamy
* @since 2021-03-02
*/
JsonResult getAuthOrgName(String orgName) throws Exception;
} }
...@@ -425,4 +425,20 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService { ...@@ -425,4 +425,20 @@ public class DmpApiMangeServiceImpl implements DmpApiMangeService {
return result; return result;
} }
/**
* 授权--组织名称查询
*
* @param orgName
* @author Bellamy
* @since 2021-03-02
*/
@Override
public JsonResult getAuthOrgName(String orgName) throws Exception {
String url = gatewayUrl + GatewayApiConstant.getOrgNameList;
Map params = new HashMap();
params.put("orgName", orgName);
JsonResult result = GatewayApiConstant.getRequest2GetData(url,params);
return result;
}
} }
...@@ -270,7 +270,6 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService ...@@ -270,7 +270,6 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
*/ */
@Override @Override
public JsonResult getFolderTree(String projectId, String orgCode) throws Exception { public JsonResult getFolderTree(String projectId, String orgCode) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.folderTree; String url = gatewayUrl + GatewayApiConstant.folderTree;
Map params = new HashMap(); Map params = new HashMap();
...@@ -278,22 +277,7 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService ...@@ -278,22 +277,7 @@ public class DmpApiServiceMangeServiceImpl implements DmpApiServiceMangeService
params.put("projectId", projectId); params.put("projectId", projectId);
} }
params.put("orgCode", orgCode); params.put("orgCode", orgCode);
String returnData = HttpClientUtils.getJsonForParam(url, params); JsonResult result = GatewayApiConstant.getRequest2GetData(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("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result; return result;
} }
......
...@@ -41,29 +41,12 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService { ...@@ -41,29 +41,12 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/ */
@Override @Override
public JsonResult queryOrgListPage(OrganizationManageListQueryReq req) throws Exception { public JsonResult queryOrgListPage(OrganizationManageListQueryReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.orgListPage; String url = gatewayUrl + GatewayApiConstant.orgListPage;
if (StringUtils.isNotEmpty(req.getOrgName())) { if (StringUtils.isNotEmpty(req.getOrgName())) {
req.setOrgName(req.getOrgName().trim()); req.setOrgName(req.getOrgName().trim());
} }
String resultData = HttpClientUtils.post(url, JSONObject.toJSONString(req)); JsonResult result = GatewayApiConstant.postRequest2GetData(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("msg")) {
logger.info(jsonObject.get("msg").toString());
result.setMessage(jsonObject.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result; return result;
} }
...@@ -79,18 +62,8 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService { ...@@ -79,18 +62,8 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
Map params = new HashMap(); Map params = new HashMap();
params.put("id", id); params.put("id", id);
String url = gatewayUrl + GatewayApiConstant.delOrg; String url = gatewayUrl + GatewayApiConstant.delOrg;
String returnData = HttpClientUtils.getJsonForParam(url, params); JsonResult result = GatewayApiConstant.getRequest2GetData(url, params);
if (StringUtils.isEmpty(returnData)) { return result;
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("删除失败!");
} }
/** /**
...@@ -102,26 +75,9 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService { ...@@ -102,26 +75,9 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/ */
@Override @Override
public JsonResult addOrg(OrganizationManageAddReq req) throws Exception { public JsonResult addOrg(OrganizationManageAddReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.addOrg; String url = gatewayUrl + GatewayApiConstant.addOrg;
req.setCreateUser(SessionUtils.getCurrentUserName()); req.setCreateUser(SessionUtils.getCurrentUserName());
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req)); JsonResult result = GatewayApiConstant.postRequest2GetData(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("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result; return result;
} }
...@@ -134,27 +90,10 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService { ...@@ -134,27 +90,10 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/ */
@Override @Override
public JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception { public JsonResult updateOrg(OrganizationManageUpdateReq req) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.addOrg; String url = gatewayUrl + GatewayApiConstant.addOrg;
req.setCreateUser(SessionUtils.getCurrentUserName()); req.setCreateUser(SessionUtils.getCurrentUserName());
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req)); JsonResult result = GatewayApiConstant.postRequest2GetData(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("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result; return result;
} }
...@@ -166,27 +105,10 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService { ...@@ -166,27 +105,10 @@ public class DmpOrgMangeServiceImpl implements DmpOrgMangeService {
*/ */
@Override @Override
public JsonResult getOrgInfoByOrgId(String id) throws Exception { public JsonResult getOrgInfoByOrgId(String id) throws Exception {
JsonResult result = new JsonResult();
String url = gatewayUrl + GatewayApiConstant.orgDetail; String url = gatewayUrl + GatewayApiConstant.orgDetail;
OrganizationManageDetailQueryReq req = new OrganizationManageDetailQueryReq(); OrganizationManageDetailQueryReq req = new OrganizationManageDetailQueryReq();
req.setId(Long.valueOf(id)); req.setId(Long.valueOf(id));
String returnData = HttpClientUtils.post(url, JSONObject.toJSONString(req)); JsonResult result = GatewayApiConstant.postRequest2GetData(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("msg")) {
logger.info(map.get("msg").toString());
result.setMessage(map.get("msg").toString());
result.setCode(ResultCode.INTERNAL_SERVER_ERROR);
}
return result; return result;
} }
} }
...@@ -1002,6 +1002,7 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic ...@@ -1002,6 +1002,7 @@ public class DmpRealtimeSyncInfoServiceImpl implements DmpRealtimeSyncInfoServic
OKHttpUtil.httpPut(url, ""); OKHttpUtil.httpPut(url, "");
//获取任务状态 //获取任务状态
String status = getExecuteShellStatus(statusUrl + "/status", new HashMap<>()); String status = getExecuteShellStatus(statusUrl + "/status", new HashMap<>());
logger.info("response status{}" + status);
//执行后任务状态 :PAUSED 暂停 , RUNNING 运行中 //执行后任务状态 :PAUSED 暂停 , RUNNING 运行中
saveBaby.setStatus(status); saveBaby.setStatus(status);
saveBaby.setUptPerson(SessionUtils.getCurrentUserId()); saveBaby.setUptPerson(SessionUtils.getCurrentUserId());
......
...@@ -553,7 +553,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -553,7 +553,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
task.setId(taskId); task.setId(taskId);
dmpDevelopTaskDao.update(task); //更新任务 dmpDevelopTaskDao.update(task); //更新任务
logger.info("################################## 更新任务数据结束 ############################################"); logger.info("======== edit sync task end ========");
//更新规则信息 //更新规则信息
List<DvTaskRuleT> list = new ArrayList<>(); List<DvTaskRuleT> list = new ArrayList<>();
...@@ -649,7 +649,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -649,7 +649,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
task.setCreateTime(new Date()); task.setCreateTime(new Date());
dmpDevelopTaskDao.insert(task); //新增任务数据 dmpDevelopTaskDao.insert(task); //新增任务数据
this.saveTaskHistory(task); //保存任务历史版本 this.saveTaskHistory(task); //保存任务历史版本
logger.info("################################## 新增离线任务数据结束 ############################################"); logger.info("======== save sync task end ========");
//保存dmp数据校验规则信息 //保存dmp数据校验规则信息
settRuleInfo(taskId, taskRules, list); settRuleInfo(taskId, taskRules, list);
} else { } else {
...@@ -661,8 +661,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -661,8 +661,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
task.setUpdateUserId(SessionUtils.getCurrentUserId()); task.setUpdateUserId(SessionUtils.getCurrentUserId());
task.setId(Integer.valueOf(taskId)); task.setId(Integer.valueOf(taskId));
dmpDevelopTaskDao.update(task); dmpDevelopTaskDao.update(task);
logger.info("======== edit sync task end ========");
this.saveTaskHistory(task); //保存任务历史版本 this.saveTaskHistory(task); //保存任务历史版本
logger.info("################################## 编辑离线任务数据结束 ############################################");
//更新规则信息 //更新规则信息
//查询TaskRuleID 集合 //查询TaskRuleID 集合
List<Long> listRules = dvTaskRuleTService.getTaskRuleIdsList(Integer.valueOf(taskId)); List<Long> listRules = dvTaskRuleTService.getTaskRuleIdsList(Integer.valueOf(taskId));
...@@ -702,7 +702,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -702,7 +702,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
taskHistory.setCreateUserId(Integer.valueOf(SessionUtils.getCurrentUserId())); taskHistory.setCreateUserId(Integer.valueOf(SessionUtils.getCurrentUserId()));
taskHistory.setDataStatus(DelFlagEnum.NO.getValue()); taskHistory.setDataStatus(DelFlagEnum.NO.getValue());
dmpDevelopTaskHistoryMapper.insert(taskHistory); dmpDevelopTaskHistoryMapper.insert(taskHistory);
logger.info("################################## 新增离线任务版本记录结束 ############################################"); logger.info("======== save sync task history end ========");
return JsonResult.ok(); return JsonResult.ok();
} }
...@@ -771,7 +771,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -771,7 +771,8 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
if (req.size() == 0 || req == null) { if (req.size() == 0 || req == null) {
throw new RuntimeException("请求参数不能为空!"); throw new RuntimeException("请求参数不能为空!");
} }
for (SynchTableColumnsReq str : req.get("params")) { List<SynchTableColumnsReq> list = req.get("params");
for (SynchTableColumnsReq str : list) {
//通过源数据库id ,查询数据源配置 //通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId()); DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo(); DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
...@@ -806,9 +807,34 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -806,9 +807,34 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
} }
} }
} }
if (StringUtils.isNotEmpty(list.get(0).getFieldName())) {
List<Map> searchFieldList = getFieldName(returnData, list.get(0).getFieldName());
return JsonResult.ok(searchFieldList);
}
return JsonResult.ok(returnData); return JsonResult.ok(returnData);
} }
/**
* 根据参数搜索表字段
*
* @return
* @author Bellamy
* @since 2021-03-02
*/
public List<Map> getFieldName(List<Map> list, String fieldName) throws Exception {
List<Map> returnList = new ArrayList<>();
if (list.size() > 0 && null != list) {
for (Map str : list) {
String name = (String) str.get("name");
if (name.contains(fieldName)) {
returnList.add(str);
}
}
}
return returnList;
}
/** /**
* 任务停止运行 * 任务停止运行
* *
......
...@@ -82,8 +82,6 @@ ...@@ -82,8 +82,6 @@
{ {
"params": { "params": {
//"version": "1.0", //版本 //"version": "1.0", //版本
"treeId": 669, "treeId": 669,
"projectId": "31", "projectId": "31",
"taskId":"", //任务id "taskId":"", //任务id
...@@ -103,7 +101,6 @@ ...@@ -103,7 +101,6 @@
"driverMemory":"",//分配任务内存 "driverMemory":"",//分配任务内存
"executorCore":"1", //单executor的cpu数 "executorCore":"1", //单executor的cpu数
"driverCore":"1"//单executor的cpu数 "driverCore":"1"//单executor的cpu数
//"fieldMapping":""//字段映射关系
}, },
"reader": { "reader": {
"sourceDbId": "", "sourceDbId": "",
...@@ -130,19 +127,13 @@ ...@@ -130,19 +127,13 @@
"column": [ "column": [
{ {
"name": "host", "name": "host",
"type": "VARCHAR" "type": "VARCHAR",
"fieldAlias" : ""
}, },
{ {
"name": "port", "name": "port",
"type": "VARCHAR" "type": "VARCHAR",
}, "fieldAlias" : ""
{
"name": "user_name",
"type": "VARCHAR"
},
{
"name": "pass_word",
"type": "VARCHAR"
} }
] ]
}, },
...@@ -219,8 +210,10 @@ ...@@ -219,8 +210,10 @@
}, },
"mappingRelation":[ "mappingRelation":[
{ {
"sourceField":"", "sourceFieldId":"",
"targetField":"" "sourceField":"",
"targetFieldId":"",
"targetField":""
} }
] ]
}, },
......
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