Commit cc0d2675 authored by mcb's avatar mcb

commit

parent dc687f4c
......@@ -202,10 +202,10 @@ public class OfflineSynchController {
*/
@ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
@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();
try {
jsonResult = offlineSynchService.querySoureTableColumns(soureAndTargetColumnsReq);
jsonResult = offlineSynchService.querySoureTableColumns(req);
} catch (Exception e) {
jsonResult.setMessage(e.getMessage());
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 {
* @author Bellamy
* @since 2021-01-21
*/
@ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
/* @ApiOperation(value = "获取数据源表字段", notes = "获取数据源表字段")
@PostMapping(value = "/getTableColumns")
public JsonResult getTableColumns(@RequestBody @Validated SoureTableColumnsReq req) throws Exception {
JsonResult jsonResult = new JsonResult();
......@@ -264,6 +264,6 @@ public class DmpApiServiceMangeController {
e.printStackTrace();
}
return jsonResult;
}
}*/
}
\ No newline at end of file
......@@ -101,7 +101,7 @@ public interface OfflineSynchService {
* @author Bellamy
* @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;
import com.jz.dmp.agent.DmpAgentResult;
import com.jz.dmp.modules.controller.DataIntegration.bean.*;
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.model.*;
import com.jz.dmp.modules.service.DmpDevelopTaskService;
......@@ -114,7 +113,7 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
* 获取源数据库名称——下拉框
*/
@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.put("projectId", projectId); //项目id
map.put("datasourceTypeId", datasourceTypeId);
......@@ -703,21 +702,25 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
* @since 2021-01-21
*/
@Override
public JsonResult querySoureTableColumns(SoureTableColumnsReq req) throws Exception {
public JsonResult querySoureTableColumns(List<SynchTableColumnsReq> req) throws Exception {
List<Map> returnData = new ArrayList<>();
int len = 0;
if (req.size() == 0 || req == null) {
throw new RuntimeException("请求参数不能为空!");
}
for (SynchTableColumnsReq str : req) {
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(req.getSourceDbId());
DmpAgentDatasourceInfo dsInfo = offlineSynchDao.querySourceDbInfoBySourceId(str.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());
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.getTargetTableName());
if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage());
} else {
......@@ -726,13 +729,13 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
if (returnList != null && returnList.size() > 0) {
for (int i = 0; i < returnList.size(); i++) {
Map map = returnList.get(i);
map.put("id", i + 1);
map.put("id", ++len);
returnData.add(map);
}
}
} else {
throw new RuntimeException("无数据!");
}
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