From e48a56c2171f023f1978b0b6aec9befd43e7a9dc Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期一, 04 十一月 2024 08:45:22 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java |   62 ++++++++++++++++++++++--------
 1 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java
index b93cfba..2212a70 100644
--- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java
+++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ReliabilityAssessService.java
@@ -38,6 +38,8 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.multipart.MultipartFile;
 
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -157,9 +159,9 @@
                     String nameValue = jsonArray.getJSONObject(i).get("name").toString();
                     if (nameValue.contains(assess.getId().toString())) {
                         // 鑾峰彇瀵瑰簲鐨勫��
-                        if (jsonArray.getJSONObject(i).get("value") instanceof Double){
-                            result1 = (Double)  jsonArray.getJSONObject(i).get("value");
-                        }else{
+                        if (jsonArray.getJSONObject(i).get("value") instanceof Double) {
+                            result1 = (Double) jsonArray.getJSONObject(i).get("value");
+                        } else {
                             String[] values = jsonArray.getJSONObject(i).get("value").toString().split(",");
                             result1 = Double.valueOf(values[1]);
                         }
@@ -377,16 +379,16 @@
             String ToEStr = "";
             String FStr = "";
 //            for (ModelNode node : nodeList) {
-                List<ReliabilityAssess> assessDatas = assessDataList.stream().filter(item ->
-                        dataId.equals(item.getId())).collect(Collectors.toList());
-                NoEStr += ",";
-                ToEStr += ",";
-                FStr += ",";
-                if (assessDatas.size() > 0) {
-                    NoEStr += assessDatas.get(0).getRunNum() != null ? assessDatas.get(0).getRunNum().toString() : "0";
-                    ToEStr += assessDatas.get(0).getRunTimes() != null ? assessDatas.get(0).getRunTimes().toString() : "0";
-                    FStr += assessDatas.get(0).getFailNum() != null ? assessDatas.get(0).getFailNum().toString() : "0";
-                }
+            List<ReliabilityAssess> assessDatas = assessDataList.stream().filter(item ->
+                    dataId.equals(item.getId())).collect(Collectors.toList());
+            NoEStr += ",";
+            ToEStr += ",";
+            FStr += ",";
+            if (assessDatas.size() > 0) {
+                NoEStr += assessDatas.get(0).getRunNum() != null ? assessDatas.get(0).getRunNum().toString() : "0";
+                ToEStr += assessDatas.get(0).getRunTimes() != null ? assessDatas.get(0).getRunTimes().toString() : "0";
+                FStr += assessDatas.get(0).getFailNum() != null ? assessDatas.get(0).getFailNum().toString() : "0";
+            }
 //            }
             NoEStr = NoEStr.substring(1);
             ToEStr = ToEStr.substring(1);
@@ -397,7 +399,7 @@
             vCounter.put("v", counter);
             Element sameNameGroupTag = parent.addElement("logic");
             sameNameGroupTag.addAttribute("name",
-                    "v"+counter);
+                    "v" + counter);
             if ("parallel".equals(sameNameGroupAlgorithmType)) {
                 sameNameGroupTag.addAttribute("type", "parallel");
             } else {
@@ -406,7 +408,7 @@
             sameNameGroupTag.addAttribute("nums", String.valueOf(nodeList.size()));
             Element nodeTag = sameNameGroupTag.addElement("node");
             nodeTag.addAttribute("name",
-                    nodeList.stream().map(item -> item.getDataId().toString()+"-"+item.getDeviceNo().toString()).
+                    nodeList.stream().map(item -> item.getDataId().toString() + "-" + item.getDeviceNo().toString()).
                             collect(Collectors.joining(",")));
             nodeTag.addAttribute("real_name", product.getSameSbName());
             nodeTag.addAttribute("name_path", product.getNamePath());
@@ -690,7 +692,7 @@
         FStr = FStr.substring(1);
 
         nodeTag.addAttribute("name",
-                nodes.stream().map(item -> item.getDataId().toString()+"-"+item.getDeviceNo().toString()).
+                nodes.stream().map(item -> item.getDataId().toString() + "-" + item.getDeviceNo().toString()).
                         collect(Collectors.joining(",")));
         if (distTypes.get(0) == 3) {
             // 浜岄」鍒嗗竷
@@ -746,7 +748,7 @@
                 ReliaSimLibResult rtn = com.alibaba.fastjson.JSONObject.parseObject(line, ReliaSimLibResult.class);
                 if ("0".equals(rtn.getCode())) {
                     logger.info("鍚姩鍙潬鎬ц瘎瀹氱畻娉曞簱鎴愬姛銆�");
-                    if (exitCode ==0) {
+                    if (exitCode == 0) {
                         deleteAssessInfoInRedis(assessResult.getId());
                         result = Result.ok();
                     } else {
@@ -936,4 +938,30 @@
         return baseDao.getAssessDataList(productId);
     }
 
+    public void downloadXml(HttpServletRequest request, HttpServletResponse response, Long productId, Long taskId, Long itemId, Integer xml) {
+        Long assessId = baseDao.getAssessId(itemId, productId, taskId);
+        String json="";
+        if (xml == 1) {
+            json = baseDao.getxml(assessId);
+        } else {
+            String filePath = path + "/" + assessId + "/" + "result.xml";
+            InputStream in = null;
+            File file = new File(filePath);
+            if (file.exists()) {
+                try {
+                    in = new FileInputStream(filePath);
+                    json = IOUtils.toString(in);
+                } catch (IOException e) {
+                    throw new RenException("鏂囦欢涓嶅瓨鍦ㄦ垨鑰呮枃浠舵墦涓嶅紑");
+                } finally {
+                    try {
+                        in.close();
+                    } catch (IOException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }
+        simulatAssessService.writeToTxt(request, response, json, "璇勫畾");
+    }
 }

--
Gitblit v1.9.1