| | |
| | | Map<Integer, String> templetsStrMap2 = new HashMap<>(); |
| | | |
| | | private JSONObject xmlJSONObj; |
| | | |
| | | /** |
| | | * 分页查询 |
| | | * |
| | | * @param queryFilter |
| | | * @return |
| | | */ |
| | | /* public List<SimulatAssess> page(QueryFilter queryFilter) { |
| | | return baseDao.getList(queryFilter.getQueryParams()); |
| | | }*/ |
| | | |
| | | |
| | | /** |
| | | * 删除 |
| | |
| | | JsonUtils2.setJsonValueByPath(textJson, "id".split("/"), UUIDUtil.generateId().toString()); |
| | | JsonUtils2.setJsonValueByPath(textJson, "attrs/label/textWrap/text".split("/"), dto.getName()); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/x".split("/"), 20); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/y".split("/"), y - 15); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/y".split("/"), y + 10); |
| | | jsonArray3.add(textJson); |
| | | } |
| | | |
| | |
| | | if (jsonArray3.size() == 0) { |
| | | StatusDto statusDto = new StatusDto(); |
| | | statusDto.setTimes(phaseModelList.get(j).getGkDuration()); |
| | | statusDto.setStatus(""); |
| | | statusDto.setStatus("M"); |
| | | productStatusDto.getStatusList().add(statusDto); |
| | | } else { |
| | | for (int a = 0; a < jsonArray3.size(); a++) { |
| | |
| | | } |
| | | } |
| | | if (status != null || times != null) { |
| | | if (StringUtils.isBlank(status)) { |
| | | status = "M"; |
| | | } |
| | | StatusDto statusDto = new StatusDto(); |
| | | statusDto.setTimes(times); |
| | | statusDto.setStatus(status); |
| | |
| | | ele.addAttribute("value", String.valueOf(failureModel.getParam1())); |
| | | break; |
| | | case FailureModel.TYPE_BIN: |
| | | ele = failureModelTag.addElement("reliability"); |
| | | ele = failureModelTag.addElement("p"); |
| | | ele.addAttribute("value", String.valueOf(failureModel.getParam1())); |
| | | ele = failureModelTag.addElement("n"); |
| | | ele.addAttribute("value", String.valueOf(failureModel.getParam2())); |
| | | ele = failureModelTag.addElement("k"); |
| | | ele = failureModelTag.addElement("m"); |
| | | ele.addAttribute("value", String.valueOf(failureModel.getParam3())); |
| | | break; |
| | | case FailureModel.TYPE_WBL: |
| | |
| | | ParamData paramData = paramDataList.stream().filter(item -> |
| | | dataId.equals(item.getProductId())).collect(Collectors.toList()).get(0); |
| | | Double ratio = paramData.getTaskMtbcfOperatingRatio(); |
| | | if (null != ratio && ratio > 0) { |
| | | // if (null != ratio && ratio > 0) { |
| | | if (null != ratio && ratio != 1.0) { |
| | | // 间断型设备的处理 |
| | | double cycon = taskPhaseModel.getOperatConditDuration() * ratio; |
| | | double cycdown = taskPhaseModel.getOperatConditDuration() - cycon; |
| | |
| | | .filter(item -> dataId.equals(item.getProductId())) |
| | | .collect(Collectors.toList()).get(0); |
| | | } |
| | | FailureModel failureModel = createFailureModel(paramData, taskBinoParam); |
| | | FailureModel failureModel = null; |
| | | if (1 == paramData.getRepairable() && |
| | | isRepairDirac(simulatAssess.getRepairDiracFlag(), taskPhaseModel, product.getId())) { |
| | | failureModel = createFailureModelDirac(); |
| | | } else { |
| | | failureModel = createFailureModel(paramData, taskBinoParam); |
| | | } |
| | | failureModels.add(failureModel); |
| | | Element failureTag = nodeTag.addElement("failure_model"); |
| | | failureTag.addAttribute("name", failureModel.getId().toString()); |
| | |
| | | return failureModel; |
| | | } |
| | | |
| | | private FailureModel createFailureModelDirac() { |
| | | FailureModel failureModel = new FailureModel(); |
| | | failureModel.setId(UUIDUtil.generateId()); |
| | | failureModel.setType(FailureModel.TYPE_FIX); |
| | | failureModel.setParam1(1); |
| | | |
| | | return failureModel; |
| | | } |
| | | |
| | | private boolean isRepairDirac(Boolean repairDiracFlag, TaskPhaseModel taskPhaseModel, Long productId) { |
| | | boolean result = false; |
| | | |
| | |
| | | JSONObject xmlJSONObj = XML.toJSONObject(xml); |
| | | JSONArray jsonArray = xmlJSONObj.getJSONObject("ResultNodes").getJSONArray("ResultNode"); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | | WeakDto data = new WeakDto(); |
| | | Long productId1; |
| | | String nameValue = jsonArray.getJSONObject(i).get("name").toString(); |
| | | if (StringUtils.isNotBlank(nameValue)) { |
| | | productId1 = Convert.toLong(nameValue.split("-")[0]); |
| | | |
| | | Double mtbf = (Double) jsonArray.getJSONObject(i).get("mttf"); |
| | | Double mttr = (Double) jsonArray.getJSONObject(i).get("mttr"); |
| | | Double msr = (Double) jsonArray.getJSONObject(i).get("msr"); |
| | | Double mtbf = null; |
| | | Double mttr = null; |
| | | Double msr = null; |
| | | if (!jsonArray.getJSONObject(i).get("mttf").equals("inf")){ |
| | | mtbf = (Double)jsonArray.getJSONObject(i).get("mttf"); |
| | | }else{ |
| | | mtbf = 0.0; |
| | | } |
| | | if (!jsonArray.getJSONObject(i).get("mttr").equals("inf")){ |
| | | mttr = (Double)jsonArray.getJSONObject(i).get("mttr"); |
| | | }else{ |
| | | mttr = 0.0; |
| | | } |
| | | if (!jsonArray.getJSONObject(i).get("msr").equals("inf")){ |
| | | msr = (Double)jsonArray.getJSONObject(i).get("msr"); |
| | | }else{ |
| | | msr = 0.0; |
| | | } |
| | | |
| | | WeakDto weakDto = new WeakDto(); |
| | | weakDto.setId(productId1); |
| | | weakDto.setMtbf(mtbf); |
| | |
| | | } |
| | | List<WeakDto> productList = baseDao.getProductList(taskId, productId); |
| | | for (WeakDto item : productList) { |
| | | WeakDto dto = map.get(item.getId()); |
| | | item.setMtbf(dto.getMtbf()); |
| | | item.setMttr(dto.getMttr()); |
| | | item.setMsr(dto.getMsr()); |
| | | item.setMtbfTime(dto.getMtbf() / item.getTimeRate()); |
| | | item.setIsWeak(0); |
| | | if (map.get(item.getId()) != null) { |
| | | WeakDto dto = map.get(item.getId()); |
| | | item.setMtbf(dto.getMtbf()); |
| | | item.setMttr(dto.getMttr()); |
| | | item.setMsr(dto.getMsr()); |
| | | item.setMtbfTime(dto.getMtbf() / item.getTimeRate()); |
| | | item.setIsWeak(0); |
| | | } |
| | | } |
| | | |
| | | List<WeakDto> treeList = new ArrayList<>(); |
| | |
| | | private void getIsweak(List<WeakDto> treeList) { |
| | | WeakDto minDto = null; |
| | | for (WeakDto dto : treeList) { |
| | | if (dto.getProductType() == 10) |
| | | continue; |
| | | if (minDto == null) { |
| | | minDto = dto; |
| | | } |
| | | if (dto.getMtbfTime() < minDto.getMtbfTime()) { |
| | | minDto = dto; |
| | | if (dto.getMtbfTime() != null) { |
| | | if (dto.getProductType() == 10) |
| | | continue; |
| | | if (minDto == null) { |
| | | minDto = dto; |
| | | } |
| | | if (dto.getMtbfTime() < minDto.getMtbfTime()) { |
| | | minDto = dto; |
| | | } |
| | | } |
| | | } |
| | | minDto.setIsWeak(1); |
| | |
| | | String[] arr = availability.split(" "); |
| | | // 遍历子字符串数组,将每个元素转换为double并存储到double数组中 |
| | | Double j = 0.0; |
| | | Double b = 100.0; |
| | | for (int a = 0; a < arr.length - 1; a++) { |
| | | if (Convert.toDouble(arr[a]) < Convert.toDouble(arr[a+1])) { |
| | | System.out.println(arr[a]); |
| | | } |
| | | j = samplPeriod + j; |
| | | doubleArray.add(Double.parseDouble(arr[a])); |
| | | if (!StringUtils.isEmpty(arr[a])) { |
| | | doubleArray.add(Double.parseDouble(arr[a])); |
| | | } |
| | | xList.add(j); |
| | | } |
| | | |
| | | param.setXData(xList); |
| | | param.setYData(doubleArray); |
| | | Double mtbf = (Double) jsonArray.getJSONObject(i).get("mttf"); |
| | | Double mttr = (Double) jsonArray.getJSONObject(i).get("mttr"); |
| | | Double msr = (Double) jsonArray.getJSONObject(i).get("msr"); |
| | | |
| | | Double mttfMle = null; |
| | | Double mttrMle = null; |
| | | Double mtbf = null; |
| | | Double mttr = null; |
| | | Double msr = null; |
| | | if (!jsonArray.getJSONObject(i).get("mttf").equals("inf")){ |
| | | mtbf = (Double)jsonArray.getJSONObject(i).get("mttf"); |
| | | }else{ |
| | | mtbf = 0.0; |
| | | } |
| | | if (!jsonArray.getJSONObject(i).get("mttr").equals("inf")){ |
| | | mttr = (Double)jsonArray.getJSONObject(i).get("mttr"); |
| | | }else{ |
| | | mttr = 0.0; |
| | | } |
| | | if (!jsonArray.getJSONObject(i).get("msr").equals("inf")){ |
| | | msr = (Double)jsonArray.getJSONObject(i).get("msr"); |
| | | }else{ |
| | | msr = 0.0; |
| | | } |
| | | |
| | | if (!jsonArray.getJSONObject(i).get("mttr_MLE").equals("inf")){ |
| | | mttrMle = (Double)jsonArray.getJSONObject(i).get("mttr_MLE"); |
| | | }else{ |
| | | mttrMle = 0.0; |
| | | } |
| | | if(!jsonArray.getJSONObject(i).get("mttf_MLE").equals("inf")){ |
| | | mttfMle = (Double) jsonArray.getJSONObject(i).get("mttf_MLE"); |
| | | }else{ |
| | | mttfMle = 0.0; |
| | | } |
| | | data.setMtbf(mtbf); |
| | | data.setMttr(mttr); |
| | | data.setMsr(msr); |
| | | data.setMttfMle(mttfMle); |
| | | data.setMttrMle(mttrMle); |
| | | } |
| | | data.setCurveParam(param); |
| | | } |
| | |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | String jsonStr = null; |
| | | try { |
| | | // 使用 ObjectMapper 的 readValue 方法,将文件中的 JSON 数据转换为一个 Java 对象 |
| | | // 这里使用 Object 类作为泛型参数,表示任意类型的对象 |
| | | Object obj = mapper.readValue(new File(filePath), Object.class); |
| | | // 使用 ObjectMapper 的 writeValueAsString 方法,将 Java 对象转换为 JSON 字符串 |
| | | jsonStr = mapper.writeValueAsString(obj); |
| | | |
| | | } catch (IOException e) { |
| | | // 处理异常 |
| | | e.printStackTrace(); |