| | |
| | | } |
| | | String filePath = path + "/" + simulatAssess.getId() + "/" + "result.xml"; |
| | | String xml = null; |
| | | InputStream in =null; |
| | | try { |
| | | InputStream in = new FileInputStream(filePath); |
| | | in = new FileInputStream(filePath); |
| | | xml = IOUtils.toString(in); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | }finally { |
| | | try { |
| | | in.close(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | xmlJSONObj = XML.toJSONObject(xml); |
| | | simulatAssess.setShowProductId(simulatAssess.getProductId()); |
| | |
| | | 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(" "); |
| | |
| | | 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); |
| | | } |
| | |
| | | @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") |