From 3c2e46fef0e866901cbb5de889166b6fda748e5d Mon Sep 17 00:00:00 2001 From: xyc <jc_xiong@hotmail.com> Date: 星期二, 22 十月 2024 14:39:09 +0800 Subject: [PATCH] 同类设备有多个的修改 --- modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java | 47 +++++++++++++++++++++++++++++------------------ 1 files changed, 29 insertions(+), 18 deletions(-) diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java index fc4a743..0f94aaa 100644 --- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java +++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java @@ -185,7 +185,7 @@ JSONObject jsonObject3 = new JSONObject(templetStr); JSONArray jsonArray3 = jsonObject3.getJSONArray("cells"); - this.getPetsInfo(); + String modelStr2 = this.getPetsInfo(); double x1 = 0; double x2 = 0; int y = -10; @@ -379,7 +379,7 @@ } parentStatusDtoList.add(new TimeDiagramStatusDto(x1, x2, lastStatus)); - JSONObject jsonObject2 = new JSONObject(templetStr); + JSONObject jsonObject2 = new JSONObject(modelStr2); JSONArray jsonArray2 = jsonObject2.getJSONArray("cells"); List<List<TimeDiagramStatusDto>> smallStatusDtoList = new ArrayList<>(); smallStatusDtoList.add(parentStatusDtoList); @@ -389,24 +389,25 @@ for (int i = 0; i < smallStatusDtoList.size(); i++) { for (TimeDiagramStatusDto status : smallStatusDtoList.get(i)) { JSONObject lineJson = new JSONObject(templetsStrMap2.get(status.getStatus())); - setlineXy(lineJson, status.getX1(), y, status.getX2()+5, y, ""); + setlineXy(lineJson, status.getX1(), y, status.getX2() + 5, y, ""); JsonUtils2.setJsonValueByPath(lineJson, "data/status".split("/"), status.getStatus()); JsonUtils2.setJsonValueByPath(lineJson, "id".split("/"), UUIDUtil.generateId().toString()); jsonArray2.add(lineJson); } - y = y + 10; + y = y + 25; } //鍥句緥 int spaceWitdth = 80; x1 = 0; x2 = spaceWitdth - 11; + y = 60; String[] tlArr = "O,F,I,S,M".split(","); for (String s : tlArr) { JSONObject f = templetsMap.get(s); x1 = x1 + spaceWitdth; x2 = x2 + spaceWitdth; - setlineXy(f, x1, y+10, x2, y+10, null); + setlineXy(f, x1, y, x2, y, null); jsonArray2.add(f); } timeDiagramDto.setDiagramJson(jsonObject.toString()); @@ -451,12 +452,14 @@ } } - public void getPetsInfo() { + public String getPetsInfo() { Map<String, Object> params = new HashMap<String, Object>(); params.put("projectId", 10000); params.put("diagramId", 10000); + String modelStr2 = ""; List<TimeDiagram> list_style = baseDao.getTimeDiagram(params); if (list_style.size() > 0) { + modelStr2 = list_style.get(0).getContent2(); String modelStr = list_style.get(0).getContent(); JSONObject modelJson = new JSONObject(modelStr); JSONArray modelJsonArray = modelJson.getJSONArray("cells"); @@ -529,6 +532,7 @@ } } } + return modelStr2; } public List<ProductStatusDto> getStatusData(Long productId, Long taskId) { @@ -608,7 +612,7 @@ List<TaskModelCheckResultDto> chkResult = taskService.checkTaskModel(simulatAssess.getProductId(), simulatAssess.getTaskModelId()); if (chkResult.size() > 0) { - result = Result.error("妯″瀷涓嶅畬鏁达紝璇锋鏌ユā鍨嬪畾涔夊強鍙傛暟閰嶇疆銆�"); + result = Result.ok(chkResult); return result; } @@ -626,7 +630,11 @@ InputStream is = null; BufferedReader br = null; try { - setParamToRedis(simulatAssess); + try { + setParamToRedis(simulatAssess); + } catch (Exception e) { + throw new RenException("璁块棶Redis澶辫触銆傝妫�鏌edis鏄惁宸插惎鍔ㄣ��"); + } Process process = null; String command = "python " + reliaSimMain; @@ -638,7 +646,7 @@ } else if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1) { process = Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", command}); } else { - throw new Exception("鏆備笉鏀寔璇ユ搷浣滅郴缁燂紝杩涜鍚姩绠楁硶搴撹绠楋紒"); + throw new RenException("鏆備笉鏀寔璇ユ搷浣滅郴缁燂紝杩涜鍚姩绠楁硶搴撹绠楋紒"); } is = process.getInputStream(); // 浠ュ懡浠よ鏂瑰紡璋冪敤绠楁硶搴撴椂锛屾帴鍙g害瀹氳繑鍥炵殑缁撴灉鏄痷tf-8缂栫爜 @@ -649,17 +657,17 @@ if (line != null) { ReliaSimLibResult rtn = com.alibaba.fastjson.JSONObject.parseObject(line, ReliaSimLibResult.class); if ("0".equals(rtn.getCode())) { - logger.info("鍚姩绠楁硶搴撴垚鍔熴��"); + logger.info("鍚姩鍙潬鎬т豢鐪熻瘎浼扮畻娉曞簱鎴愬姛銆�"); result = Result.ok(); } else { String errorMsg = rtn.getErrorMsg(); - throw new RuntimeException("鍚姩绠楁硶搴撳け璐�: errorMsg=" + errorMsg); + throw new RenException("鍚姩鍙潬鎬т豢鐪熻瘎浼扮畻娉曞簱澶辫触: errorMsg=" + errorMsg); } } - } catch (Exception e) { - logger.error("鍚姩绠楁硶搴撲豢鐪熸椂鍙戠敓Exception锛�", e); + } catch (IOException e) { + logger.error("鍚姩鍙潬鎬т豢鐪熻瘎浼扮畻娉曞簱浠跨湡鏃跺彂鐢烢xception锛�", e); e.printStackTrace(); - result = Result.error(e.getMessage()); + throw new RenException("鍚姩鍙潬鎬т豢鐪熻瘎浼扮畻娉曞簱澶辫触: errorMsg=" + e.getMessage()); } finally { if (is != null) { try { @@ -764,7 +772,7 @@ insert(simulatAssess); } catch (Exception e) { e.printStackTrace(); - throw new RuntimeException("缁勮绠楁硶搴撲豢鐪熻绠楃敤妯″瀷XML澶辫触: " + e.getMessage()); + throw new RenException("缁勮绠楁硶搴撲豢鐪熻绠楃敤妯″瀷XML澶辫触: " + e.getMessage()); } } @@ -1000,9 +1008,10 @@ failureModels, repairModels); } else if ("5".equals(product.getProductType())) { // 璁惧 + Integer deviceNo = node.getDeviceNo(); Element nodeTag = parent.addElement("node"); - nodeTag.addAttribute("name", dataId.toString()); - nodeTag.addAttribute("real_name", product.getName()); + nodeTag.addAttribute("name", deviceNo == 0 ? dataId.toString() : dataId.toString()+"-"+deviceNo); + nodeTag.addAttribute("real_name", deviceNo == 0 ? product.getName() : product.getName()+"-"+deviceNo); nodeTag.addAttribute("name_path", product.getNamePath()); nodeTag.addAttribute("type", "node"); @@ -1061,6 +1070,7 @@ element.addAttribute("k", algo.getVoteNum().toString()); } else if ("switch".equals(algo.getAlgorithmType())) { element.addAttribute("type", "standby"); + element.addAttribute("k", algo.getVoteNum().toString()); } else if ("bridge".equals(algo.getAlgorithmType())) { element.addAttribute("type", "bridge"); } @@ -1103,7 +1113,8 @@ break; case 3: // 浜岄」鍒嗗竷 - if (taskBinoParam.getSimulatTimes().intValue() == taskBinoParam.getSuccessTimes().intValue()) { + if ((taskBinoParam.getSimulatTimes() == null && taskBinoParam.getSuccessTimes() == null) || + (taskBinoParam.getSimulatTimes().intValue() == taskBinoParam.getSuccessTimes().intValue())) { // 鐩哥瓑鍒欎负鎴愯触鍨� failureModel.setType(FailureModel.TYPE_FIX); failureModel.setParam1(taskBinoParam.getSuccessRate()); -- Gitblit v1.9.1