From cd7b35b1acc7467deac78ba843b5870a22c9c7f6 Mon Sep 17 00:00:00 2001 From: jinlin <jinlin> Date: 星期二, 06 八月 2024 08:59:12 +0800 Subject: [PATCH] 修改 --- modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/controller/SimulatAssessController.java | 85 ++++++++++++++---------------------------- 1 files changed, 28 insertions(+), 57 deletions(-) diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/controller/SimulatAssessController.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/controller/SimulatAssessController.java index 992308e..99aff53 100644 --- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/controller/SimulatAssessController.java +++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/controller/SimulatAssessController.java @@ -18,11 +18,13 @@ import com.zt.life.modules.mainPart.taskReliability.model.CurveParam; import com.zt.life.modules.mainPart.taskReliability.model.SimulatAssess; import com.zt.life.modules.mainPart.taskReliability.model.Task; +import com.zt.life.modules.mainPart.taskReliability.model.TimeDiagram; import com.zt.life.modules.mainPart.taskReliability.service.SimulatAssessService; import com.zt.life.modules.mainPart.taskReliability.service.TaskService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -52,7 +54,6 @@ public class SimulatAssessController { private static final Logger logger = LoggerFactory.getLogger(SimulatAssessController.class); private static final String taskTypeProgress = "calcprog"; - private List<Map<String, Double>> dialgram = new ArrayList<>(); @Autowired private RedisTemplate redisTemplate; @@ -62,16 +63,15 @@ @Autowired private TaskService taskService; - @Value("${data.reliaSimLib.resultHome}") private String path; + @Autowired private SimulatAssessService simulatAssessService; private JSONObject xmlJSONObj; - private JSONObject dialgramJson; /* @GetMapping("page") @ApiOperation("鍒嗛〉") @@ -149,7 +149,7 @@ public SimulaDataDto getResultData(SimulatAssess simulatAssess) { SimulaDataDto data = new SimulaDataDto(); CurveParam param = new CurveParam(); - Double samplPeriod = simulatAssess.getSamplPeriod().doubleValue(); + Double samplPeriod = Double.valueOf(simulatAssess.getSamplPeriod()); Task task = taskService.get(simulatAssess.getTaskModelId()); samplPeriod = samplPeriod / 60; List<Double> xList = new ArrayList<>(); @@ -174,6 +174,7 @@ availability = (String) jsonArray2.getJSONObject(j).get("availability"); } } + String[] arr = availability.split(" "); // 閬嶅巻瀛愬瓧绗︿覆鏁扮粍锛屽皢姣忎釜鍏冪礌杞崲涓篸ouble骞跺瓨鍌ㄥ埌double鏁扮粍涓� for (int a = 0; a < arr.length; a++) { @@ -191,62 +192,33 @@ } @GetMapping("getStatus") - public Result<List<ProductStatusDto>> getStatus(Long productId, Long taskId, Long fzId) { - String filePath = path + "/" + fzId + "/" + "status.json"; - 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(); - } - dialgramJson = new JSONObject(jsonStr); - List<ProductStatusDto> childList = this.getStatusData(productId, taskId); - return Result.ok(childList); - + public Result<String> getTimeDiagram(Long productId, Long taskId, Long fzId) { + String data = simulatAssessService.getTimeDiagram(productId, taskId, fzId); + return Result.ok(data); } - public List<ProductStatusDto> getStatusData(Long productId, Long taskId) { - List<ProductStatusDto> childList = simulatAssessService.getChildren(productId, taskId); - for (ProductStatusDto item : childList) { - if (dialgram.size() > 0) { - dialgram.clear(); - } - JSONArray jsonArray = dialgramJson.getJSONArray(String.valueOf(item.getId())); - if (jsonArray != null) { - this.processJSONArray(jsonArray, item); - } - } - return childList; + @GetMapping("getDiagram") + @ApiOperation("鏌ヨ娴佺▼鍥�") + @LogOperation("鏌ヨ娴佺▼鍥�") + public Result<TimeDiagram> getDiagram(String projectId, String diagramId, String showType, String isShow, String digramParams, String majorId, Integer winWidth, Integer winHeight) throws Exception { + if (StringUtils.isBlank(diagramId)) + diagramId = projectId; + TimeDiagram diagram = simulatAssessService.getDiagram(projectId, diagramId, showType, isShow, digramParams, majorId, winWidth, winHeight); + return Result.ok(diagram); } - public void processJSONArray(JSONArray jsonArray, ProductStatusDto productStatusDto) { - String status = null; - Double times = null; - for (int i = 0; i < jsonArray.size(); i++) { - Object item = jsonArray.get(i); - if (item instanceof JSONArray) { - processJSONArray((JSONArray) item, productStatusDto); // 閫掑綊璋冪敤 - } else { - if (item instanceof Double) { - times = (Double) item; - } else { - status = String.valueOf(item); - } - } - } - if (status != null || times != null) { - StatusDto statusDto =new StatusDto(); - statusDto.setTimes(times); - statusDto.setStatus(status); - productStatusDto.getStatusList().add(statusDto); - } + @PutMapping("saveDiagram") + @ApiOperation("鏌ヨ娴佺▼鍥�") + @LogOperation("鏌ヨ娴佺▼鍥�") + public Result saveDiagram(@RequestBody TimeDiagram diagram) { + // 鏁堥獙鏁版嵁 + //ValidatorUtils.validateEntity(project.getProject(), UpdateGroup.class, DefaultGroup.class); + if (diagram.getConfigChange() == null) + diagram.setConfigChange(0); + diagram.setSaveStatus(2); + simulatAssessService.updateDiagram(diagram); + //simulatAssessService.combineDiagram(diagram); + return Result.ok(); } @GetMapping("getCalcProgress") @@ -278,7 +250,6 @@ return Result.ok(); } - } -- Gitblit v1.9.1