|
|
@ -202,7 +202,7 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService { |
|
|
* @return 场景题目 |
|
|
* @return 场景题目 |
|
|
*/ |
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public Map<String, Object> selectQuestionTree(String guid) { |
|
|
public List<Map<String, Object>> selectQuestionTree(String guid) { |
|
|
SceneRole sceneRole = iSceneRoleService.selectSceneRoleById(guid); |
|
|
SceneRole sceneRole = iSceneRoleService.selectSceneRoleById(guid); |
|
|
JSONObject json = JSON.parseObject(sceneRole.getContent()); |
|
|
JSONObject json = JSON.parseObject(sceneRole.getContent()); |
|
|
JSONObject dataJson = json.getJSONObject("drawflow").getJSONObject("Home").getJSONObject("data"); |
|
|
JSONObject dataJson = json.getJSONObject("drawflow").getJSONObject("Home").getJSONObject("data"); |
|
|
@ -212,12 +212,13 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService { |
|
|
JSONObject data = dataJson.getJSONObject(i+""); |
|
|
JSONObject data = dataJson.getJSONObject(i+""); |
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
params.put("questionId", data.get("name")); |
|
|
params.put("questionId", data.get("name")); |
|
|
|
|
|
params.put("nodeId", data.get("id")); |
|
|
|
|
|
|
|
|
Set outList = new HashSet(); |
|
|
Set<Integer> outList = new HashSet(); |
|
|
JSONArray outs = data.getJSONObject("outputs").getJSONObject("output_1").getJSONArray("connections"); |
|
|
JSONArray outs = data.getJSONObject("outputs").getJSONObject("output_1").getJSONArray("connections"); |
|
|
for (int j=0; j<outs.size(); j++) { |
|
|
for (int j=0; j<outs.size(); j++) { |
|
|
JSONObject ot = outs.getJSONObject(j); |
|
|
JSONObject ot = outs.getJSONObject(j); |
|
|
outList.add(ot.getString("node")); |
|
|
outList.add(ot.getInteger("node")); |
|
|
} |
|
|
} |
|
|
params.put("outs", outList); |
|
|
params.put("outs", outList); |
|
|
|
|
|
|
|
|
@ -231,16 +232,39 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService { |
|
|
} else { |
|
|
} else { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
} else { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
paramsList.add(params); |
|
|
paramsList.add(params); |
|
|
} |
|
|
} |
|
|
System.out.println(paramsList); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// recursionFn(paramsList, root);
|
|
|
|
|
|
|
|
|
return new HashMap<>(); |
|
|
|
|
|
|
|
|
return paramsList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void recursionFn(List<Map<String, Object>> params, Map<String, Object> p) { |
|
|
|
|
|
List<Map<String, Object>> childList = getChildList(params, p); |
|
|
|
|
|
p.put("children", childList); |
|
|
|
|
|
for (Map<String, Object> child : childList) { |
|
|
|
|
|
if (hasChild(params, child)) { |
|
|
|
|
|
recursionFn(params, child); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private List<Map<String, Object>> getChildList(List<Map<String, Object>> params, Map<String, Object> p) { |
|
|
|
|
|
List<Map<String, Object>> list = new ArrayList<>(); |
|
|
|
|
|
for (Map<String, Object> param : params) { |
|
|
|
|
|
if (((Set) p.get("outs")).contains(Integer.parseInt(param.get("nodeId").toString()))) { |
|
|
|
|
|
list.add(param); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return list; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean hasChild(List<Map<String, Object>> params, Map<String, Object> p) { |
|
|
|
|
|
return getChildList(params, p).size() > 0 ? true : false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|