修复无法远程调用问题
parent
8757da2522
commit
ea4585909a
|
@ -22,11 +22,12 @@ import java.util.List;
|
|||
*/
|
||||
@FeignClient(contextId = "RemoteDataSourceService",
|
||||
value = ServiceNameConstants.SOURCE_SERVICE,
|
||||
url = "http://10.0.2.1:19652/",
|
||||
fallbackFactory = RemoteDataSourceFactory.class)
|
||||
public interface RemoteDataSourceService {
|
||||
|
||||
@PostMapping("/value/findTableValue")
|
||||
public Result<List<DataModel>> findTableValue(@RequestBody DataValueModel dataValueModel);
|
||||
public Result<List<List<DataModel>>> findTableValue(@RequestBody DataValueModel dataValueModel);
|
||||
|
||||
/**
|
||||
* 根据基础表ID和SQL语句查询条数
|
||||
|
|
|
@ -136,12 +136,6 @@ public class TaskController extends BaseController
|
|||
return success();
|
||||
}
|
||||
|
||||
/**
|
||||
* 测试
|
||||
*/
|
||||
@PostMapping("/test")
|
||||
public Result test() {
|
||||
return success(taskService.test());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -49,5 +49,4 @@ public interface TaskService extends IService<Task> {
|
|||
|
||||
String testExecute(List<Node> nodeList);
|
||||
|
||||
String test();
|
||||
}
|
||||
|
|
|
@ -191,13 +191,6 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
|||
return "测试成功,无异常";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String test() {
|
||||
String sql = "SELECT `cloud-ecology`.task_source.task_code,`cloud-ecology`.task_source.task_name,`cloud-ecology`.node_info.node_code,`cloud-ecology`.node_info.node_type,`cloud-ecology`.node_info.node_name FROM `cloud-ecology`.task_source RIGHT JOIN `cloud-ecology`.node_info ON `cloud-ecology`.task_source.task_code = `cloud-ecology`.node_info.task_code LIMIT 10 OFFSET 0";
|
||||
Result<List<DataModel>> tableValue = remoteDataSourceService.findTableValue(new DataValueModel(4L, sql));
|
||||
System.out.println(tableValue);
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行任务第一步: 校验节点规范 并返回初始化节点map
|
||||
|
@ -262,11 +255,11 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task>
|
|||
* 获取新增SQL
|
||||
*/
|
||||
private String getAddSql(HashMap<String, List<Node>> nodeMap, String findSql) {
|
||||
Result<List<DataModel>> tableValue = remoteDataSourceService.findTableValue(new DataValueModel(4L, findSql));
|
||||
Result<List<List<DataModel>>> tableValue = remoteDataSourceService.findTableValue(new DataValueModel(4L, findSql));
|
||||
if (tableValue.getCode() != 200){
|
||||
throw new TaskException(tableValue.getMsg());
|
||||
}
|
||||
List<DataModel> data = tableValue.getData();
|
||||
List<List<DataModel>> data = tableValue.getData();
|
||||
|
||||
|
||||
List<NodeDisposition> dispList = getNodeDisp(nodeMap.get("exportation").get(0));
|
||||
|
|
|
@ -276,7 +276,7 @@ public class NodeUtils {
|
|||
* @param data 查询到的数据
|
||||
* @return 新增sql
|
||||
*/
|
||||
public static String nodeDispExportation(List<NodeDisposition> dispList, List<DataModel> data) {
|
||||
public static String nodeDispExportation(List<NodeDisposition> dispList, List<List<DataModel>> data) {
|
||||
if (data == null){
|
||||
throw new TaskException("查询数据为空");
|
||||
}
|
||||
|
@ -291,7 +291,7 @@ public class NodeUtils {
|
|||
* @param data 查询到的数据
|
||||
* @return 新增sql
|
||||
*/
|
||||
private static String nodeDispExportation(Map<String, List<NodeDisposition>> dispMap, List<DataModel> data) {
|
||||
private static String nodeDispExportation(Map<String, List<NodeDisposition>> dispMap, List<List<DataModel>> data) {
|
||||
// 拼接新增表
|
||||
NodeDisposition db = dispMap.get("toDb").get(0);
|
||||
String dbTable = "`" + db.getDispDesc() + "`." + db.getDispValue();
|
||||
|
@ -302,13 +302,10 @@ public class NodeUtils {
|
|||
StringBuilder insSql = new StringBuilder("INSERT INTO " + dbTable + "( " + join + " ) VALUES ");
|
||||
// 整理需新增数据
|
||||
List<HashMap<String, String>> dataList1 = new ArrayList<>();
|
||||
HashMap<String, String> dataMap = new HashMap<>();
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
if (i % fieldList.size() == 0 && i>0){
|
||||
dataList1.add(dataMap);
|
||||
dataMap = new HashMap<>();
|
||||
}
|
||||
dataMap.put(data.get(i).getKey(), data.get(i).getValue().toString());
|
||||
for (List<DataModel> datum : data) {
|
||||
HashMap<String, String> dataMap = new HashMap<>();
|
||||
datum.forEach(dataModel -> dataMap.put(dataModel.getKey(), dataModel.getValue().toString()));
|
||||
dataList1.add(dataMap);
|
||||
}
|
||||
// 拼接新增语句的值
|
||||
dataList1.forEach(map -> insSql.append("( ").
|
||||
|
|
Loading…
Reference in New Issue