Commit e4d163f7 authored by mcb's avatar mcb

commit

parent aaf004b1
......@@ -786,36 +786,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
}
List<SynchTableColumnsReq> list = req.get("params");
for (SynchTableColumnsReq str : list) {
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
BeanUtils.copyProperties(dsInfos, dsInfo);
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
//解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
if (null != str.getSourceDbId() && null != str.getTargetTableName()) {
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
BeanUtils.copyProperties(dsInfos, dsInfo);
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
//解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
//创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.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", ++len);
map.put("fieldAlias", map.get("name")); //字段别名
map.put("isPk", 0); //主键
map.put("isPt", 0); //分区
//实时同步:脱敏算法
map.put("arithmetic", "HmacSHA256");
returnData.add(map);
//创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.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", ++len);
map.put("fieldAlias", map.get("name")); //字段别名
map.put("isPk", 0); //主键
map.put("isPt", 0); //分区
//实时同步:脱敏算法
map.put("arithmetic", "HmacSHA256");
returnData.add(map);
}
}
}
}
......@@ -1051,36 +1053,38 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
int num = 0;
for (SynchTableColumnsReq str : list) {
num++;
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
BeanUtils.copyProperties(dsInfos, dsInfo);
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
//解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
if (null != str.getSourceDbId() && null != str.getTargetTableName()) {
//通过源数据库id ,查询数据源配置
DmpAgentDatasourceInfo dsInfos = offlineSynchDao.querySourceDbInfoBySourceId(str.getSourceDbId());
DmpAgentDatasourceInfo dsInfo = new DmpAgentDatasourceInfo();
BeanUtils.copyProperties(dsInfos, dsInfo);
if (dsInfo == null) {
throw new RuntimeException("数据源配置信息不存在!");
}
//解码源数据库密码
if (StringUtils.isNotBlank(dsInfo.getPassword())) {
dsInfo.setPassword(new BaseService().decode(dsInfo.getPassword(), publicKey));
}
//创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.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", ++len);
map.put("fieldAlias", map.get("name")); //字段别名
map.put("isPk", 0); //主键
map.put("isPt", 0); //分区
returnData.add(map);
if (num == 1) {
syncData.add(map);
//创建jdbc,获取数据源表字段
DmpAgentResult rst = dmpDsAgentServiceImp.getTableColumnList(dsInfo, str.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", ++len);
map.put("fieldAlias", map.get("name")); //字段别名
map.put("isPk", 0); //主键
map.put("isPt", 0); //分区
returnData.add(map);
if (num == 1) {
syncData.add(map);
}
}
}
}
......@@ -1100,9 +1104,39 @@ public class OfflineSynchServiceImpl implements OfflineSynchService {
*/
@Override
public JsonResult querySyncTaskInfoById(String id) throws Exception {
Map returnMap = new HashMap();
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