Commit cc0d2675 authored by mcb's avatar mcb

commit

parent dc687f4c
...@@ -202,10 +202,10 @@ public class OfflineSynchController { ...@@ -202,10 +202,10 @@ public class OfflineSynchController {
*/ */
@ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段") @ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
@PostMapping(value = "/getSoureAndTargetColumns") @PostMapping(value = "/getSoureAndTargetColumns")
public JsonResult getSoureAndTargetColumns(@RequestBody @Validated SoureTableColumnsReq soureAndTargetColumnsReq) throws Exception { public JsonResult getSoureAndTargetColumns(@RequestBody @Validated List<SynchTableColumnsReq> req) throws Exception {
JsonResult jsonResult = new JsonResult(); JsonResult jsonResult = new JsonResult();
try { try {
jsonResult = offlineSynchService.querySoureTableColumns(soureAndTargetColumnsReq); jsonResult = offlineSynchService.querySoureTableColumns(req);
} catch (Exception e) { } catch (Exception e) {
jsonResult.setMessage(e.getMessage()); jsonResult.setMessage(e.getMessage());
jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR); jsonResult.setCode(ResultCode.INTERNAL_SERVER_ERROR);
......
package com.jz.dmp.modules.controller.DataIntegration.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: SynchTableColumnsReq
* @Description: 获取表字段-请求对象
* @Author:Bellamy
* @Date 2020/12/21
* @Version 1.0
*/
@ApiModel(value = "获取表字段-请求对象", description = "获取表字段-请求对象")
public class SynchTableColumnsReq implements Serializable {
private static final long serialVersionUID = -2235510265678437967L;
/*
* 源数据库ID
* */
@NotNull(message = "源数据库ID不能为空")
@ApiModelProperty(value = "源数据库ID")
private Long sourceDbId;
@ApiModelProperty(value = "目标表名称")
private String targetTableName;
public Long getSourceDbId() {
return sourceDbId;
}
public String getTargetTableName() {
return targetTableName;
}
public void setTargetTableName(String targetTableName) {
this.targetTableName = targetTableName;
}
public void setSourceDbId(Long sourceDbId) {
this.sourceDbId = sourceDbId;
}
}
...@@ -252,7 +252,7 @@ public class DmpApiServiceMangeController { ...@@ -252,7 +252,7 @@ public class DmpApiServiceMangeController {
* @author Bellamy * @author Bellamy
* @since 2021-01-21 * @since 2021-01-21
*/ */
@ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段") /* @ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
@PostMapping(value = "/getTableColumns") @PostMapping(value = "/getTableColumns")
public JsonResult getTableColumns(@RequestBody @Validated SoureTableColumnsReq req) throws Exception { public JsonResult getTableColumns(@RequestBody @Validated SoureTableColumnsReq req) throws Exception {
JsonResult jsonResult = new JsonResult(); JsonResult jsonResult = new JsonResult();
...@@ -264,6 +264,6 @@ public class DmpApiServiceMangeController { ...@@ -264,6 +264,6 @@ public class DmpApiServiceMangeController {
e.printStackTrace(); e.printStackTrace();
} }
return jsonResult; return jsonResult;
} }*/
} }
\ No newline at end of file
...@@ -101,7 +101,7 @@ public interface OfflineSynchService { ...@@ -101,7 +101,7 @@ public interface OfflineSynchService {
* @author Bellamy * @author Bellamy
* @since 2021-01-21 * @since 2021-01-21
*/ */
JsonResult querySoureTableColumns(SoureTableColumnsReq req) throws Exception; JsonResult querySoureTableColumns(List<SynchTableColumnsReq> req) throws Exception;
/** /**
* 任务停止运行 * 任务停止运行
......
...@@ -19,7 +19,6 @@ import com.jz.common.utils.web.XmlUtils; ...@@ -19,7 +19,6 @@ 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;
...@@ -114,7 +113,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -114,7 +113,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
* 获取源数据库名称——下拉框 * 获取源数据库名称——下拉框
*/ */
@Override @Override
public JsonResult<List<SourceDbNameListDto>> querygSourceDbList(Integer projectId,String datasourceTypeId) throws Exception { public JsonResult<List<SourceDbNameListDto>> querygSourceDbList(Integer projectId, String datasourceTypeId) throws Exception {
Map map = new HashMap(); Map map = new HashMap();
map.put("projectId", projectId); //项目id map.put("projectId", projectId); //项目id
map.put("datasourceTypeId", datasourceTypeId); map.put("datasourceTypeId", datasourceTypeId);
...@@ -703,36 +702,40 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -703,36 +702,40 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
* @since 2021-01-21 * @since 2021-01-21
*/ */
@Override @Override
public JsonResult querySoureTableColumns(SoureTableColumnsReq req) throws Exception { public JsonResult querySoureTableColumns(List<SynchTableColumnsReq> req) throws Exception {
//通过源数据库id ,查询数据源配置 List<Map> returnData = new ArrayList<>();
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(req.getSourceDbId()); int len = 0;
if (dsInfo == null) { if (req.size() == 0 || req == null) {
throw new RuntimeException("数据源配置信息不存在!"); 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,获取数据源表字段 for (SynchTableColumnsReq str : req) {
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, req.getTargetTableName()); //通过源数据库id ,查询数据源配置
if (!rst.getCode().val().equals("200")) { DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
return new JsonResult(rst.getCode(), rst.getMessage()); if (dsInfo == null) {
} else { throw new RuntimeException("数据源配置信息不存在!");
//成功 }
List<Map> returnList = (List<Map>) JsonMapper.fromJsonString(rst.getMessage(), List.class); //解码源数据库密码
if (returnList != null && returnList.size() > 0) { if (StringUtils.isNotBlank(dsInfo.getPassword())) {
for (int i = 0; i < returnList.size(); i++) { dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
Map map = returnList.get(i); }
map.put("id", i + 1);
} //创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.getTargetTableName());
if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage());
} else { } else {
throw new RuntimeException("无数据!"); //成功
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", ++len);
returnData.add(map);
}
}
} }
return JsonResult.ok(returnList);
} }
return JsonResult.ok(returnData);
} }
/** /**
......
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