|
|
@ -85,123 +85,124 @@ public class SceneRoleServiceImpl implements ISceneRoleService { |
|
|
// 连线信息
|
|
|
// 连线信息
|
|
|
String edgeStr = sceneRole.getContent(); |
|
|
String edgeStr = sceneRole.getContent(); |
|
|
JSONObject edgeObj = JSONObject.parseObject(edgeStr); |
|
|
JSONObject edgeObj = JSONObject.parseObject(edgeStr); |
|
|
// 节点坐标, 类型信息 用于下方区分出 开始, 结束, 普通 三种节点类型
|
|
|
if (null != edgeObj) { |
|
|
JSONArray nodeArray = JSONArray.parseArray(edgeObj.get("nodes").toString()); |
|
|
// 节点坐标, 类型信息 用于下方区分出 开始, 结束, 普通 三种节点类型
|
|
|
// 循环节点信息取出开始与结束的id
|
|
|
JSONArray nodeArray = JSONArray.parseArray(edgeObj.get("nodes").toString()); |
|
|
String startId = ""; |
|
|
// 循环节点信息取出开始与结束的id
|
|
|
String endId = ""; |
|
|
String startId = ""; |
|
|
for (int j=0; j<nodeArray.size(); j++) { |
|
|
String endId = ""; |
|
|
JSONObject node = nodeArray.getJSONObject(j); |
|
|
for (int j = 0; j < nodeArray.size(); j++) { |
|
|
if ("snaker:start".equals(node.get("type"))) { |
|
|
JSONObject node = nodeArray.getJSONObject(j); |
|
|
startId = node.get("id").toString(); |
|
|
if ("snaker:start".equals(node.get("type"))) { |
|
|
} else if ("snaker:end".equals(node.get("type"))) { |
|
|
startId = node.get("id").toString(); |
|
|
endId = node.get("id").toString(); |
|
|
} else if ("snaker:end".equals(node.get("type"))) { |
|
|
|
|
|
endId = node.get("id").toString(); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 线坐标, 来源, 目标信息
|
|
|
// 线坐标, 来源, 目标信息
|
|
|
JSONArray edgeArray = JSONArray.parseArray(edgeObj.get("edges").toString()); |
|
|
JSONArray edgeArray = JSONArray.parseArray(edgeObj.get("edges").toString()); |
|
|
// 节点+坐标值信息
|
|
|
// 节点+坐标值信息
|
|
|
String valueArrayStr = sceneRole.getValueArray(); |
|
|
String valueArrayStr = sceneRole.getValueArray(); |
|
|
JSONArray valueArray = JSONArray.parseArray(valueArrayStr); |
|
|
JSONArray valueArray = JSONArray.parseArray(valueArrayStr); |
|
|
|
|
|
|
|
|
List<Map<String, Object>> paramsList = new ArrayList<>(); |
|
|
List<Map<String, Object>> paramsList = new ArrayList<>(); |
|
|
// 在新增的时候进行数据拼装. 避免查询时拼接消耗时间 - 节点拼接
|
|
|
// 在新增的时候进行数据拼装. 避免查询时拼接消耗时间 - 节点拼接
|
|
|
for (int i=0; i<nodeArray.size(); i++) { |
|
|
for (int i = 0; i < nodeArray.size(); i++) { |
|
|
Map<String, Object> tmp = new HashMap<>(); |
|
|
Map<String, Object> tmp = new HashMap<>(); |
|
|
// 以节点做为基础进行拼装
|
|
|
// 以节点做为基础进行拼装
|
|
|
JSONObject node = nodeArray.getJSONObject(i); |
|
|
JSONObject node = nodeArray.getJSONObject(i); |
|
|
tmp.put("questionId", node.getString("id")); |
|
|
tmp.put("questionId", node.getString("id")); |
|
|
// 处理nodeId, 并更改开始与结束
|
|
|
// 处理nodeId, 并更改开始与结束
|
|
|
if (startId.equals(node.getString("id"))) { |
|
|
if (startId.equals(node.getString("id"))) { |
|
|
tmp.put("nodeId", "1"); |
|
|
tmp.put("nodeId", "1"); |
|
|
} else if (endId.equals(node.getString("id"))) { |
|
|
} else if (endId.equals(node.getString("id"))) { |
|
|
tmp.put("nodeId", "-1"); |
|
|
tmp.put("nodeId", "-1"); |
|
|
} else { |
|
|
} else { |
|
|
tmp.put("nodeId", node.getString("id")); |
|
|
tmp.put("nodeId", node.getString("id")); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 循环线信息获取来源, 目标信息
|
|
|
// 循环线信息获取来源, 目标信息
|
|
|
Set tmpSet = new HashSet(); |
|
|
Set tmpSet = new HashSet(); |
|
|
for (int j=0; j<edgeArray.size(); j++) { |
|
|
for (int j = 0; j < edgeArray.size(); j++) { |
|
|
JSONObject edge = edgeArray.getJSONObject(j); |
|
|
JSONObject edge = edgeArray.getJSONObject(j); |
|
|
// 先通过来源id和节点进行匹配 , 匹配上后, 当前id便是节点需要钱我
|
|
|
// 先通过来源id和节点进行匹配 , 匹配上后, 当前id便是节点需要钱我
|
|
|
// 作为 指向 -1 的倒数第二个节点需要单度处理下
|
|
|
// 作为 指向 -1 的倒数第二个节点需要单度处理下
|
|
|
if (edge.get("sourceNodeId").equals(node.get("id"))) { |
|
|
if (edge.get("sourceNodeId").equals(node.get("id"))) { |
|
|
if ("1".equals(tmp.get("nodeId"))) { |
|
|
if ("1".equals(tmp.get("nodeId"))) { |
|
|
tmpSet.add(edge.get("targetNodeId")); |
|
|
tmpSet.add(edge.get("targetNodeId")); |
|
|
} else { |
|
|
} else { |
|
|
tmpSet.add(edge.get("id")); |
|
|
tmpSet.add(edge.get("id")); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
tmp.put("outs", tmpSet); |
|
|
tmp.put("outs", tmpSet); |
|
|
|
|
|
|
|
|
|
|
|
// 填充节点信息的数据
|
|
|
// 填充节点信息的数据
|
|
|
tmp.putAll(this.fillValueJson(valueArray, node.getString("id"))); |
|
|
tmp.putAll(this.fillValueJson(valueArray, node.getString("id"))); |
|
|
paramsList.add(tmp); |
|
|
paramsList.add(tmp); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 在新增的时候进行数据拼装. 避免查询时拼接消耗时间 - 线拼接
|
|
|
// 在新增的时候进行数据拼装. 避免查询时拼接消耗时间 - 线拼接
|
|
|
for (int i=0; i<edgeArray.size(); i++) { |
|
|
for (int i = 0; i < edgeArray.size(); i++) { |
|
|
Map<String, Object> tmp = new HashMap<>(); |
|
|
Map<String, Object> tmp = new HashMap<>(); |
|
|
// 以线做为基础进行拼装
|
|
|
// 以线做为基础进行拼装
|
|
|
JSONObject edge = edgeArray.getJSONObject(i); |
|
|
JSONObject edge = edgeArray.getJSONObject(i); |
|
|
tmp.put("questionId", edge.get("id")); |
|
|
tmp.put("questionId", edge.get("id")); |
|
|
tmp.put("nodeId", edge.get("id")); |
|
|
tmp.put("nodeId", edge.get("id")); |
|
|
|
|
|
|
|
|
// 循环线信息获取来源, 目标信息
|
|
|
// 循环线信息获取来源, 目标信息
|
|
|
Set tmpSet = new HashSet(); |
|
|
Set tmpSet = new HashSet(); |
|
|
for (int j=0; j<edgeArray.size(); j++) { |
|
|
for (int j = 0; j < edgeArray.size(); j++) { |
|
|
JSONObject edge2 = edgeArray.getJSONObject(j); |
|
|
JSONObject edge2 = edgeArray.getJSONObject(j); |
|
|
// 先通过来源id和节点进行匹配 , 匹配上后, 当前id便是节点需要钱我
|
|
|
// 先通过来源id和节点进行匹配 , 匹配上后, 当前id便是节点需要钱我
|
|
|
// 作为 指向 -1 的倒数第二个节点需要单度处理下
|
|
|
// 作为 指向 -1 的倒数第二个节点需要单度处理下
|
|
|
if (edge2.get("id").equals(edge.get("id"))) { |
|
|
if (edge2.get("id").equals(edge.get("id"))) { |
|
|
if ("1".equals(tmp.get("nodeId"))) { |
|
|
if ("1".equals(tmp.get("nodeId"))) { |
|
|
continue; |
|
|
continue; |
|
|
} else { |
|
|
} else { |
|
|
tmpSet.add(edge.get("targetNodeId")); |
|
|
tmpSet.add(edge.get("targetNodeId")); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
tmp.put("outs", tmpSet); |
|
|
tmp.put("outs", tmpSet); |
|
|
|
|
|
|
|
|
|
|
|
// 填充节点信息的数据
|
|
|
// 填充节点信息的数据
|
|
|
tmp.putAll(this.fillValueJson(valueArray, edge.getString("id"))); |
|
|
tmp.putAll(this.fillValueJson(valueArray, edge.getString("id"))); |
|
|
paramsList.add(tmp); |
|
|
paramsList.add(tmp); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 单独处理下 指向 -1 的最后一个节点
|
|
|
// 单独处理下 指向 -1 的最后一个节点
|
|
|
String qId = "-1"; |
|
|
String qId = "-1"; |
|
|
String sId = "-1"; |
|
|
String sId = "-1"; |
|
|
for (Map<String, Object> m : paramsList) { |
|
|
for (Map<String, Object> m : paramsList) { |
|
|
if ("-1".equals(m.get("nodeId"))) { |
|
|
if ("-1".equals(m.get("nodeId"))) { |
|
|
qId = m.get("questionId").toString(); // 07
|
|
|
qId = m.get("questionId").toString(); // 07
|
|
|
for (int j=0; j<edgeArray.size(); j++) { |
|
|
for (int j = 0; j < edgeArray.size(); j++) { |
|
|
JSONObject edge = edgeArray.getJSONObject(j); |
|
|
JSONObject edge = edgeArray.getJSONObject(j); |
|
|
if (edge.get("targetNodeId").equals(qId)) { |
|
|
if (edge.get("targetNodeId").equals(qId)) { |
|
|
// 找到指向结束节点的节点
|
|
|
// 找到指向结束节点的节点
|
|
|
sId = edge.getString("sourceNodeId"); |
|
|
sId = edge.getString("sourceNodeId"); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
// 根据 获得的sId修改节点只接修改指向
|
|
|
// 根据 获得的sId修改节点只接修改指向
|
|
|
for (Map<String, Object> m : paramsList) { |
|
|
for (Map<String, Object> m : paramsList) { |
|
|
if (sId.equals(m.get("questionId").toString())) { |
|
|
if (sId.equals(m.get("questionId").toString())) { |
|
|
Set tp = new HashSet(); |
|
|
Set tp = new HashSet(); |
|
|
tp.add(qId); |
|
|
tp.add(qId); |
|
|
m.put("outs", tp); |
|
|
m.put("outs", tp); |
|
|
} |
|
|
} |
|
|
// 将结束节点node改为 google 减少小程序端代码的修改
|
|
|
// 将结束节点node改为 google 减少小程序端代码的修改
|
|
|
if ("-1".equals(m.get("nodeId"))) { |
|
|
if ("-1".equals(m.get("nodeId"))) { |
|
|
m.put("nodeId", m.get("questionId")); |
|
|
m.put("nodeId", m.get("questionId")); |
|
|
m.put("questionId", "google"); |
|
|
m.put("questionId", "google"); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sceneRole.setResJson(JSON.toJSONString(paramsList)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sceneRole.setResJson(JSON.toJSONString(paramsList)); |
|
|
|
|
|
} |
|
|
UserBean userBean = userApi.getCurrentUser(); |
|
|
UserBean userBean = userApi.getCurrentUser(); |
|
|
if (Objects.nonNull(userBean)) { |
|
|
if (Objects.nonNull(userBean)) { |
|
|
sceneRole.setUpdateBy(userBean.getUserName()); |
|
|
sceneRole.setUpdateBy(userBean.getUserName()); |
|
|
|