jinlin
2024-08-06 a3e44cefd1d83bde949d14920c9a5d3d17d4386f
modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/controller/SimulatAssessController.java
@@ -131,6 +131,7 @@
        try {
            InputStream in = new FileInputStream(filePath);
            xml = IOUtils.toString(in);
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
@@ -164,24 +165,35 @@
            if (nameValue instanceof Long) {
                productId = (Long) nameValue;
                if (productId.equals(simulatAssess.getShowProductId())) {
                    JSONArray jsonArray2 = jsonArray.getJSONObject(i).getJSONArray("phase");
                    Object object = jsonArray.getJSONObject(i).get("phase");
                    List<Double> doubleArray = new ArrayList<>();
                    String availability = null;
                    for (int j = 0; j < jsonArray2.size(); j++) {
                        if (availability != null) {
                            availability = availability + " " + jsonArray2.getJSONObject(j).get("availability");
                        } else {
                            availability = (String) jsonArray2.getJSONObject(j).get("availability");
                    if (object instanceof JSONArray) {
                        JSONArray jsonArray2 = jsonArray.getJSONObject(i).getJSONArray("phase");
                        for (int j = 0; j < jsonArray2.size(); j++) {
                            if (availability != null) {
                                availability = availability + " " + jsonArray2.getJSONObject(j).get("availability");
                            } else {
                                availability = (String) jsonArray2.getJSONObject(j).get("availability");
                            }
                        }
                    } else {
                        JSONObject jsonObject2 = jsonArray.getJSONObject(i).getJSONObject("phase");
                        availability = (String) jsonObject2.get("availability");
                    }
                    String[] arr = availability.split(" ");
                    // 遍历子字符串数组,将每个元素转换为double并存储到double数组中
                    for (int a = 0; a < arr.length; a++) {
                        doubleArray.add(Double.parseDouble(arr[a]));
                    }
                    param.setYData(doubleArray);
                    data.setMtbf((Double) jsonArray.getJSONObject(i).get("mttf"));
                    data.setMttr((Double) jsonArray.getJSONObject(i).get("mttr"));
                    Double mtbf = (Double) jsonArray.getJSONObject(i).get("mttf");
                    Double mttr = (Double) jsonArray.getJSONObject(i).get("mttr");
                    Double msr = (Double) jsonArray.getJSONObject(i).get("msr");
                    data.setMtbf(mtbf);
                    data.setMttr(mttr);
                    data.setMsr(msr);
                }
                data.setCurveParam(param);
            }
@@ -193,7 +205,7 @@
    @GetMapping("getStatus")
    public Result<String> getTimeDiagram(Long productId, Long taskId, Long fzId) {
        String data = simulatAssessService.getTimeDiagram(productId, taskId, fzId);
        return  Result.ok(data);
        return Result.ok(data);
    }
    @GetMapping("getDiagram")