|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONException; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.zdxt.auth.dto.RoleBean; |
|
|
|
import com.zdxt.auth.dto.UserBean; |
|
|
|
@ -219,8 +220,18 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService { |
|
|
|
Map<String, Object> root = new HashMap<>(); |
|
|
|
Map<String, Map<String, String>> answerList = new HashMap<>(); |
|
|
|
List<Map<String, Object>> paramsList = new ArrayList<>(); |
|
|
|
for (int i = 1; i <= dataJson.size(); i++) { |
|
|
|
|
|
|
|
// 因不是正常顺序, 并且会出下断层 因此取最大key值做循环底数
|
|
|
|
Set<String> keys = dataJson.keySet(); |
|
|
|
List<Integer> keyNums = new ArrayList<>(); |
|
|
|
for (String key : keys) { |
|
|
|
keyNums.add(Integer.parseInt(key)); |
|
|
|
} |
|
|
|
int maxNum = this.getMax(keyNums); |
|
|
|
// for (int i = 1; i <= dataJson.size(); i++) {
|
|
|
|
for (int i = 1; i <= maxNum; i++) { |
|
|
|
JSONObject data = dataJson.getJSONObject(i + ""); |
|
|
|
if (null == data) { continue; } |
|
|
|
Map<String, Object> params = new HashMap<>(); |
|
|
|
params.put("questionId", data.get("name")); |
|
|
|
params.put("nodeId", data.get("id")); |
|
|
|
@ -332,4 +343,17 @@ public class SceneQuestionServiceImpl implements ISceneQuestionService { |
|
|
|
return getChildList(params, p).size() > 0 ? true : false; |
|
|
|
} |
|
|
|
|
|
|
|
private int getMax(List<Integer> arr){ |
|
|
|
//假设数组第一位是最大值
|
|
|
|
int max = arr.get(0); |
|
|
|
for (int index = 0 ; index < arr.size() ; index ++) { |
|
|
|
// 数组的每一个元素和假设的第一个最大值做比较
|
|
|
|
if(arr.get(index) > max) { |
|
|
|
// 把得到的真正的最大值赋给Max
|
|
|
|
max = arr.get(index); |
|
|
|
} |
|
|
|
} |
|
|
|
return max; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|