| | |
| | | String templetStr = "{\"cells\":[]}"; |
| | | Map<String, JSONObject> templetsMap = new HashMap<>(); |
| | | Map<String, String> templetsStrMap = new HashMap<>(); |
| | | Map<Integer, String> templetsStrMap2 = new HashMap<>(); |
| | | |
| | | private JSONObject xmlJSONObj; |
| | | |
| | |
| | | return baseDao.getChildren(productId, taskId); |
| | | } |
| | | |
| | | public String getTimeDiagram(Long productId, Long taskId, Long fzId) { |
| | | public TimeDiagramDto getTimeDiagram(Long productId, Long taskId, Long fzId, double smallWidth, double minPointNum) { |
| | | TimeDiagramDto timeDiagramDto = new TimeDiagramDto(); |
| | | timeDiagramDto.setSmallWidth(smallWidth); |
| | | timeDiagramDto.setMinPointNum(minPointNum); |
| | | String filePath = path + "/" + fzId + "/" + "status.json"; |
| | | ObjectMapper mapper = new ObjectMapper(); |
| | | String jsonStr = null; |
| | |
| | | JSONObject jsonObject = new JSONObject(templetStr); |
| | | JSONArray jsonArray = jsonObject.getJSONArray("cells"); |
| | | |
| | | JSONObject jsonObject3 = new JSONObject(templetStr); |
| | | JSONArray jsonArray3 = jsonObject3.getJSONArray("cells"); |
| | | |
| | | this.getPetsInfo(); |
| | | double x1 = 0; |
| | | double x2 = 0; |
| | |
| | | int groupHeight = 20; |
| | | |
| | | double pointNumPerHour = 60.0 / simulatAssess.getSamplPeriod(); |
| | | |
| | | //时序图线 |
| | | List<List<TimeDiagramStatusDto>> lineArray = new ArrayList(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | List<TimeDiagramStatusDto> statusDtoList = new ArrayList<>(); |
| | | x1 = 0; |
| | | groupY = groupHeight * i; |
| | | ProductStatusDto dto = list.get(i); |
| | | double startTime = 0.0; |
| | | int status2 = 5; |
| | | for (StatusDto status : dto.getStatusList()) { |
| | | switch (status.getStatus()) { |
| | | case "O": |
| | | y = groupY; |
| | | status2 = 5; |
| | | break; |
| | | case "F": |
| | | y = groupY;// + spaceHeight; |
| | | status2 = 1; |
| | | break; |
| | | case "I": |
| | | y = groupY;// + spaceHeight; |
| | | status2 = 3; |
| | | break; |
| | | case "S": |
| | | y = groupY;// + spaceHeight; |
| | | status2 = 2; |
| | | break; |
| | | case "M": |
| | | y = groupY;// + 2 * spaceHeight; |
| | | status2 = 4; |
| | | break; |
| | | } |
| | | x2 = x1 + status.getTimes() * pointNumPerHour + 5; |
| | | statusDtoList.add(new TimeDiagramStatusDto(x1, x2, status2)); |
| | | JSONObject lineJson = new JSONObject(templetsStrMap.get(status.getStatus())); |
| | | setlineXy(lineJson, x1, y, x2, y, ""); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "data/status".split("/"), status.getStatus()); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "data/startTimes".split("/"), String.format("%.4f", x1)); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "data/endTimes".split("/"), String.format("%.4f", x1 + status.getTimes())); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "data/startTimes".split("/"), String.format("%.1f", startTime)); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "data/endTimes".split("/"), String.format("%.1f", startTime + status.getTimes())); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "id".split("/"), UUIDUtil.generateId().toString()); |
| | | startTime = startTime + status.getTimes(); |
| | | x1 = x2 - 5; |
| | | jsonArray.add(lineJson); |
| | | } |
| | | lineArray.add(statusDtoList); |
| | | |
| | | JSONObject textJson = new JSONObject(templetsStrMap.get("text")); |
| | | 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); |
| | | jsonArray.add(textJson); |
| | | } |
| | | |
| | | //图例 |
| | | int spaceWitdth = 80; |
| | | x1 = -spaceWitdth; |
| | | x2 = -11; |
| | | y = -110; |
| | | 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, x2, y, null); |
| | | jsonArray.add(f); |
| | | jsonArray3.add(textJson); |
| | | } |
| | | |
| | | //阶段模型及刻度 |
| | | x1 = 0; |
| | | x2 = 0; |
| | | double y1 = -80; |
| | | y = -60; |
| | | double y2 = -50; |
| | | double y1 = -60; |
| | | y = -40; |
| | | double y2 = -30; |
| | | |
| | | JSONObject modelJson = new JSONObject(templetsStrMap.get("model")); |
| | | setlineXy(modelJson, 1, y1, 1, y2, null); |
| | |
| | | JSONObject textJson = new JSONObject(templetsStrMap.get("text")); |
| | | JsonUtils2.setJsonValueByPath(textJson, "data/dataId".split("/"), modelId); |
| | | JsonUtils2.setJsonValueByPath(textJson, "id".split("/"), UUIDUtil.generateId().toString()); |
| | | JsonUtils2.setJsonValueByPath(textJson, "attrs/label/textWrap/text".split("/"), "模型"+(i+1)); |
| | | JsonUtils2.setJsonValueByPath(textJson, "attrs/label/textWrap/text".split("/"), "模型" + (i + 1)); |
| | | JsonUtils2.setJsonValueByPath(textJson, "attrs/label/textWrap/modelName".split("/"), modelName); |
| | | |
| | | JsonUtils2.setJsonValueByPath(textJson, "size/width".split("/"), mapSpace.get("width")+10); |
| | | JsonUtils2.setJsonValueByPath(textJson, "size/width".split("/"), mapSpace.get("width") + 10); |
| | | |
| | | double x11 = x1 + ((gkPoint - mapSpace.get("width")+12) / 2); |
| | | double x11 = x1 + ((gkPoint - mapSpace.get("width") + 12) / 2); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/x".split("/"), x11); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/y".split("/"), y1-10); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/y".split("/"), y1 - 10); |
| | | jsonArray.add(textJson); |
| | | x1 = x2; |
| | | } |
| | | |
| | | JSONObject modelJson3 = new JSONObject(templetsStrMap.get("model")); |
| | | setlineXy(modelJson3, 0, y, x2, y, null); |
| | | jsonArray.add(modelJson3); |
| | |
| | | |
| | | double x11 = x - mapSpace.get("width") / 2 - 5; |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/x".split("/"), x11); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/y".split("/"), y2-10); |
| | | JsonUtils2.setJsonValueByPath(textJson, "position/y".split("/"), y2 - 10); |
| | | jsonArray.add(textJson); |
| | | |
| | | curPointHour += periodHour; |
| | | } |
| | | |
| | | timeDiagramDto.setTotalWidth(x2); |
| | | double pointRate = timeDiagramDto.getTotalWidth() / timeDiagramDto.getSmallWidth(); |
| | | |
| | | return jsonObject.toString(); |
| | | List<TimeDiagramStatusDto> subStatusDtoList = new ArrayList<>(); |
| | | int lastStatus = 5; |
| | | boolean isFirst = true; |
| | | x1 = 0; |
| | | for (double i = 0; i < timeDiagramDto.getSmallWidth(); i = i + timeDiagramDto.getMinPointNum()) { |
| | | int netStatus = 5; |
| | | for (int j = 1; j < list.size(); j++) { |
| | | if (i >= 448) { |
| | | System.out.println(111); |
| | | } |
| | | int tmpStatus = getPointStatus(lineArray.get(j), i * pointRate, (i + timeDiagramDto.getMinPointNum()) * pointRate - 1); |
| | | if (tmpStatus < netStatus) { |
| | | netStatus = tmpStatus; |
| | | } |
| | | } |
| | | if (!isFirst) { |
| | | if (lastStatus != netStatus) { |
| | | subStatusDtoList.add(new TimeDiagramStatusDto(x1, x2, lastStatus)); |
| | | lastStatus = netStatus; |
| | | x1 = i; |
| | | } |
| | | } else { |
| | | lastStatus = netStatus; |
| | | isFirst = false; |
| | | } |
| | | x2 = i + timeDiagramDto.getMinPointNum() - 1; |
| | | } |
| | | subStatusDtoList.add(new TimeDiagramStatusDto(x1, x2, lastStatus)); |
| | | |
| | | List<TimeDiagramStatusDto> parentStatusDtoList = new ArrayList<>(); |
| | | lastStatus = 5; |
| | | isFirst = true; |
| | | x1 = 0; |
| | | for (double i = 0; i < timeDiagramDto.getSmallWidth(); i = i + timeDiagramDto.getMinPointNum()) { |
| | | if (i >= 448) { |
| | | System.out.println(111); |
| | | } |
| | | int netStatus = getPointStatus(lineArray.get(0), i * pointRate, (i + timeDiagramDto.getMinPointNum()) * pointRate - 1); |
| | | if (!isFirst) { |
| | | if (lastStatus != netStatus) { |
| | | parentStatusDtoList.add(new TimeDiagramStatusDto(x1, x2, lastStatus)); |
| | | lastStatus = netStatus; |
| | | x1 = i; |
| | | } |
| | | } else { |
| | | lastStatus = netStatus; |
| | | isFirst = false; |
| | | } |
| | | x2 = i + timeDiagramDto.getMinPointNum() - 1; |
| | | } |
| | | parentStatusDtoList.add(new TimeDiagramStatusDto(x1, x2, lastStatus)); |
| | | |
| | | JSONObject jsonObject2 = new JSONObject(templetStr); |
| | | JSONArray jsonArray2 = jsonObject2.getJSONArray("cells"); |
| | | List<List<TimeDiagramStatusDto>> smallStatusDtoList = new ArrayList<>(); |
| | | smallStatusDtoList.add(parentStatusDtoList); |
| | | smallStatusDtoList.add(subStatusDtoList); |
| | | |
| | | y = 10; |
| | | 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, ""); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "data/status".split("/"), status.getStatus()); |
| | | JsonUtils2.setJsonValueByPath(lineJson, "id".split("/"), UUIDUtil.generateId().toString()); |
| | | jsonArray2.add(lineJson); |
| | | } |
| | | y = y + 10; |
| | | } |
| | | |
| | | //图例 |
| | | int spaceWitdth = 80; |
| | | x1 = 0; |
| | | x2 = spaceWitdth - 11; |
| | | 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); |
| | | jsonArray2.add(f); |
| | | } |
| | | timeDiagramDto.setDiagramJson(jsonObject.toString()); |
| | | timeDiagramDto.setSmallDiagramJson(jsonObject2.toString()); |
| | | timeDiagramDto.setTextDiagramJson(jsonObject3.toString()); |
| | | |
| | | return timeDiagramDto; |
| | | } |
| | | |
| | | private int getPointStatus(List<TimeDiagramStatusDto> dtoList, double x1, double x2) { |
| | | int status = 5; |
| | | boolean findStart = false; |
| | | for (int i = 0; i < dtoList.size(); i++) { |
| | | if (x2 <= dtoList.get(i).getX1()) { |
| | | break; |
| | | } |
| | | |
| | | if (!findStart) { |
| | | if (dtoList.get(i).getX1() >= x1 && x1 <= dtoList.get(i).getX2()) { |
| | | status = dtoList.get(i).getStatus(); |
| | | findStart = true; |
| | | } |
| | | } |
| | | |
| | | if (dtoList.get(i).getX2() >= x2) { |
| | | if (dtoList.get(i).getStatus() < status) |
| | | status = dtoList.get(i).getStatus(); |
| | | } |
| | | } |
| | | return status; |
| | | } |
| | | |
| | | |
| | | public void setlineXy(JSONObject lineJson, double x1, double y1, double x2, double y2, String text) { |
| | | JsonUtils2.setJsonValueByPath(lineJson, "source/x".split("/"), x1); |
| | |
| | | if ("运行".equals(nodeMarker)) { |
| | | templetsMap.put("O", jsonObject); |
| | | templetsStrMap.put("O", jsonObject.toString()); |
| | | templetsStrMap2.put(5, jsonObject.toString()); |
| | | } |
| | | if ("故障".equals(nodeMarker)) { |
| | | templetsMap.put("F", jsonObject); |
| | | templetsStrMap.put("F", jsonObject.toString()); |
| | | templetsStrMap2.put(1, jsonObject.toString()); |
| | | } |
| | | if ("空闲".equals(nodeMarker)) { |
| | | templetsMap.put("I", jsonObject); |
| | | templetsStrMap.put("I", jsonObject.toString()); |
| | | templetsStrMap2.put(3, jsonObject.toString()); |
| | | } |
| | | if ("备份".equals(nodeMarker)) { |
| | | templetsMap.put("S", jsonObject); |
| | | templetsStrMap.put("S", jsonObject.toString()); |
| | | templetsStrMap2.put(2, jsonObject.toString()); |
| | | } |
| | | if ("未用".equals(nodeMarker)) { |
| | | templetsMap.put("M", jsonObject); |
| | | templetsStrMap.put("M", jsonObject.toString()); |
| | | templetsStrMap2.put(4, jsonObject.toString()); |
| | | } |
| | | if ("模型".equals(nodeMarker)) { |
| | | JsonUtils2.setJsonValueByPath(tmpJSONObject, "attrs/text/text".split("/"), ""); |
| | |
| | | } |
| | | |
| | | public void addTasksTag(List<TaskPhaseModel> taskPhaseModelAll, |
| | | Element root) { |
| | | Element root) { |
| | | Element tasksTag = root.addElement("tasks"); |
| | | for (TaskPhaseModel taskPhaseModel : taskPhaseModelAll) { |
| | | Element taskTag = tasksTag.addElement("task"); |
| | |
| | | } |
| | | |
| | | public void calcTaskPhaseModelDuration(TaskPhase taskPhase, |
| | | List<TaskPhaseModel> taskPhaseModelAll) { |
| | | List<TaskPhaseModel> taskPhaseModelAll) { |
| | | List<TaskPhaseModel> taskPhaseModels = taskPhaseModelDao.getListByPhaseId(taskPhase.getId()); |
| | | double totalRate = taskPhaseModels.stream().mapToDouble(TaskPhaseModel::getOperatConditDurationRate).sum(); |
| | | double sum = 0.0; |
| | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | } |
| | | |
| | | List<WeakDto> productList = baseDao.getProductList(taskId, productId); |
| | |
| | | Object nameValue = jsonArray.getJSONObject(i).get("name"); |
| | | if (nameValue instanceof Long) { |
| | | productId1 = (Long) nameValue; |
| | | WeakDto weakDto = map.get(productId1); |
| | | Double mtbfTime = null; |
| | | if (map.get(productId1) != null) { |
| | | WeakDto weakDto = map.get(productId1); |
| | | Double mtbfTime = null; |
| | | |
| | | 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 = (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.setMtbf(mtbf); |
| | | data.setMttr(mttr); |
| | | data.setMsr(msr); |
| | | |
| | | if (weakDto != null) { |
| | | data.setId(weakDto.getId()); |
| | | data.setSort(weakDto.getSort()); |
| | | data.setPid(weakDto.getPid()); |
| | | data.setName(weakDto.getName()); |
| | | data.setProductType(weakDto.getProductType()); |
| | | data.setTimeRate(weakDto.getTimeRate()); |
| | | mtbfTime = mtbf / weakDto.getTimeRate(); |
| | | if (weakDto != null) { |
| | | data.setId(weakDto.getId()); |
| | | data.setSort(weakDto.getSort()); |
| | | data.setPid(weakDto.getPid()); |
| | | data.setName(weakDto.getName()); |
| | | data.setProductType(weakDto.getProductType()); |
| | | data.setTimeRate(weakDto.getTimeRate()); |
| | | mtbfTime = mtbf / weakDto.getTimeRate(); |
| | | } |
| | | |
| | | data.setMtbfTime(mtbfTime); |
| | | data.setIsWeak(0); |
| | | |
| | | list.add(data); |
| | | } |
| | | |
| | | data.setMtbfTime(mtbfTime); |
| | | data.setIsWeak(0); |
| | | |
| | | list.add(data); |
| | | } |
| | | } |
| | | List<WeakDto> treeList = TreeUtils.build(list); |
| | | this.getIsweak(treeList.get(0).getChildren()); |
| | | List<WeakDto> treeList = new ArrayList<>(); |
| | | if (list.size() > 0) { |
| | | treeList = TreeUtils.build(list); |
| | | this.getIsweak(treeList.get(0).getChildren()); |
| | | } |
| | | |
| | | return treeList; |
| | | } |
| | | |
| | |
| | | task = taskService.get(taskModelId); |
| | | simulatAssess = this.getByTaskId(taskModelId); |
| | | SimulaDataDto resultData; |
| | | if (showProductId!=null){ |
| | | if (showProductId != null) { |
| | | simulatAssess.setProductId(showProductId); |
| | | resultData =this.getResultXML(simulatAssess); |
| | | }else{ |
| | | resultData = this.getResultXML(simulatAssess); |
| | | } else { |
| | | resultData = this.getResultXML(simulatAssess); |
| | | } |
| | | |