| | |
| | | package com.zt.life.modules.mainPart.taskReliability.service; |
| | | |
| | | import cn.hutool.json.JSONArray; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.XML; |
| | | import com.zt.common.exception.RenException; |
| | |
| | | } |
| | | } |
| | | JSONObject xmlJSONObj = XML.toJSONObject(xml); |
| | | JSONObject jsonObject = xmlJSONObj.getJSONObject("Results"); |
| | | //JSONObject jsonObject = xmlJSONObj.getJSONObject("Results"); |
| | | JSONArray jsonArray = xmlJSONObj.getJSONObject("Results").getJSONArray("Result"); |
| | | for (ReliabilityAssess assess : list) { |
| | | Double result1 = null; |
| | | // 遍历 JSON 对象的所有键 |
| | | for (String key : jsonObject.keySet()) { |
| | | // 检查键是否包含特定的字符串 |
| | | if (key.contains(assess.getId().toString())) { |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | String nameValue = (String) jsonArray.getJSONObject(i).get("name"); |
| | | if (nameValue.contains(assess.getId().toString())) { |
| | | // 获取对应的值 |
| | | result1 = (Double) jsonObject.get(key); |
| | | result1 = (Double) jsonArray.getJSONObject(i).get("value"); |
| | | break; // 如果找到就退出循环 |
| | | } |
| | | } |