Commit e4d163f7 authored by mcb's avatar mcb

commit

parent aaf004b1
...@@ -786,36 +786,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -786,36 +786,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
} }
List<SynchTableColumnsReq> list = req.get("params"); List<SynchTableColumnsReq> list = req.get("params");
for (SynchTableColumnsReq str : list) { for (SynchTableColumnsReq str : list) {
//通过源数据库id ,查询数据源配置 if (null != str.getSourceDbId() && null != str.getTargetTableName()) {
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId()); //通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo(); DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
BeanUtils.copyProperties(dsInfos, dsInfo); DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
if (dsInfo == null) { BeanUtils.copyProperties(dsInfos, dsInfo);
throw new RuntimeException("数据源配置信息不存在!"); if (dsInfo == null) {
} throw new RuntimeException("数据源配置信息不存在!");
//解码源数据库密码 }
if (StringUtils.isNotBlank(dsInfo.getPassword())) { //解码源数据库密码
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey)); if (StringUtils.isNotBlank(dsInfo.getPassword())) {
} dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
//创建jdbc,获取数据源表字段 //创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.getTargetTableName()); DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.getTargetTableName());
if (!rst.getCode().val().equals("200")) { if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage()); return new JsonResult(rst.getCode(), rst.getMessage());
} else { } else {
//成功 //成功
List<Map> returnList = (List<Map>) JsonMapper.fromJsonString(rst.getMessage(), List.class); List<Map> returnList = (List<Map>) JsonMapper.fromJsonString(rst.getMessage(), List.class);
if (returnList != null && returnList.size() > 0) { if (returnList != null && returnList.size() > 0) {
for (int i = 0; i < returnList.size(); i++) { for (int i = 0; i < returnList.size(); i++) {
Map map = returnList.get(i); Map map = returnList.get(i);
//离线同步 //离线同步
map.put("id", ++len); map.put("id", ++len);
map.put("fieldAlias", map.get("name")); //字段别名 map.put("fieldAlias", map.get("name")); //字段别名
map.put("isPk", 0); //主键 map.put("isPk", 0); //主键
map.put("isPt", 0); //分区 map.put("isPt", 0); //分区
//实时同步:脱敏算法 //实时同步:脱敏算法
map.put("arithmetic", "HmacSHA256"); map.put("arithmetic", "HmacSHA256");
returnData.add(map); returnData.add(map);
}
} }
} }
} }
...@@ -1051,36 +1053,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -1051,36 +1053,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
int num = 0; int num = 0;
for (SynchTableColumnsReq str : list) { for (SynchTableColumnsReq str : list) {
num++; num++;
//通过源数据库id ,查询数据源配置 if (null != str.getSourceDbId() && null != str.getTargetTableName()) {
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId()); //通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo(); DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
BeanUtils.copyProperties(dsInfos, dsInfo); DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
if (dsInfo == null) { BeanUtils.copyProperties(dsInfos, dsInfo);
throw new RuntimeException("数据源配置信息不存在!"); if (dsInfo == null) {
} throw new RuntimeException("数据源配置信息不存在!");
//解码源数据库密码 }
if (StringUtils.isNotBlank(dsInfo.getPassword())) { //解码源数据库密码
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey)); if (StringUtils.isNotBlank(dsInfo.getPassword())) {
} dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
//创建jdbc,获取数据源表字段 //创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.getTargetTableName()); DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.getTargetTableName());
if (!rst.getCode().val().equals("200")) { if (!rst.getCode().val().equals("200")) {
return new JsonResult(rst.getCode(), rst.getMessage()); return new JsonResult(rst.getCode(), rst.getMessage());
} else { } else {
//成功 //成功
List<Map> returnList = (List<Map>) JsonMapper.fromJsonString(rst.getMessage(), List.class); List<Map> returnList = (List<Map>) JsonMapper.fromJsonString(rst.getMessage(), List.class);
if (returnList != null && returnList.size() > 0) { if (returnList != null && returnList.size() > 0) {
for (int i = 0; i < returnList.size(); i++) { for (int i = 0; i < returnList.size(); i++) {
Map map = returnList.get(i); Map map = returnList.get(i);
//离线同步 //离线同步
map.put("id", ++len); map.put("id", ++len);
map.put("fieldAlias", map.get("name")); //字段别名 map.put("fieldAlias", map.get("name")); //字段别名
map.put("isPk", 0); //主键 map.put("isPk", 0); //主键
map.put("isPt", 0); //分区 map.put("isPt", 0); //分区
returnData.add(map); returnData.add(map);
if (num == 1) { if (num == 1) {
syncData.add(map); syncData.add(map);
}
} }
} }
} }
...@@ -1100,9 +1104,39 @@ public class OfflineSynchServiceImpl implements OfflineSynchService { ...@@ -1100,9 +1104,39 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
*/ */
@Override @Override
public JsonResult querySyncTaskInfoById(String id) throws Exception { public JsonResult querySyncTaskInfoById(String id) throws Exception {
Map returnMap = new HashMap();
DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.selectTaskById(id); DmpDevelopTask dmpDevelopTask = dmpDevelopTaskDao.selectTaskById(id);
if (StringUtils.isNotEmpty(dmpDevelopTask.getScript())) {
Map map = (Map) JSONObject.parse(dmpDevelopTask.getScript());
Map scripts = (Map) map.get("scripts");
Integer projectId = Integer.valueOf((String) map.get("projectId"));
Map reader = (Map) scripts.get("reader");
Map writer = (Map) scripts.get("writer");
String sourceDbType = String.valueOf(reader.get("sourceDbType"));
String sourceDbId = String.valueOf(reader.get("sourceDbId"));
String[] sourceDbName = String.valueOf(reader.get("dbConnection")).split(",");
String targetDbType = String.valueOf(writer.get("targetDbType"));
String targetDbId = String.valueOf(writer.get("targetDbId"));
String targetName = String.valueOf(writer.get("targetDbConnection"));
//数据源
JsonResult sourceDb = querygSourceDbList(projectId, sourceDbType);
returnMap.put("sourceDb", sourceDb.getData());
JsonResult targetDb = querygSourceDbList(projectId, targetDbType);
returnMap.put("targetDb", targetDb.getData());
//表
String[] sourceDbIds = sourceDbId.split(",");
for (int i = 0; i < sourceDbIds.length; i++) {
JsonResult sourceTable = querygSourceTableList(Long.valueOf(sourceDbIds[i]), "");
returnMap.put(sourceDbName[i], sourceTable.getData());
}
JsonResult targetTable = querygSourceTableList(Long.valueOf(targetDbId), "");
returnMap.put(targetName, targetTable.getData());
return JsonResult.ok(dmpDevelopTask); }
returnMap.put("task", dmpDevelopTask);
return JsonResult.ok(returnMap);
} }
} }
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