From 3ecb68c427a627ad8e90d8c555655e7724be2d96 Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期五, 06 九月 2024 11:06:12 +0800
Subject: [PATCH] 修改

---
 modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java |  175 +++++++++-------------------------------------------------
 1 files changed, 28 insertions(+), 147 deletions(-)

diff --git a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java
index 01bd97e..adc3692 100644
--- a/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java
+++ b/modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/ModelLineService.java
@@ -7,24 +7,16 @@
 import com.zt.common.utils.UUIDUtil;
 import com.zt.life.modules.mainPart.basicInfo.dao.ParamDataDao;
 import com.zt.life.modules.mainPart.basicInfo.dao.XhProductModelDao;
-import com.zt.life.modules.mainPart.basicInfo.model.ParamData;
 import com.zt.life.modules.mainPart.basicInfo.model.ProductImg;
-import com.zt.life.modules.mainPart.basicInfo.model.XhProductModel;
 import com.zt.life.modules.mainPart.taskReliability.dao.*;
-import com.zt.life.modules.mainPart.taskReliability.dto.ModelLinePair;
+import com.zt.life.modules.mainPart.taskReliability.dto.ModelLinePairDto;
 import com.zt.life.modules.mainPart.taskReliability.model.*;
 import org.apache.commons.lang3.StringUtils;
-import org.dom4j.DocumentHelper;
-import org.dom4j.Document;
-import org.dom4j.Element;
-import org.dom4j.io.OutputFormat;
-import org.dom4j.io.XMLWriter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.zt.common.db.query.QueryFilter;
 import org.springframework.transaction.annotation.Transactional;
 
-import java.io.StringWriter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -138,7 +130,7 @@
 
         // 6. 杞崲涓虹畻娉曞簱鎺ュ彛XML
         if (result) {
-            result = createIfXmlFromRbd(modelRbd, algorithmList, modelNodeAndVnodeList);
+//           result = createIfXmlFromRbd(modelRbd, algorithmList, modelNodeAndVnodeList);
         }
 
         // 7. 淇濆瓨妯″瀷
@@ -187,134 +179,6 @@
         }
         modelNodeList.addAll(nodesToAdd);
         modelLineList.addAll(linesToAdd);
-    }
-
-    private boolean createIfXmlFromRbd(ModelRbd modelRbd,
-                                       List<Algorithm> algorithmList,
-                                       List<ModelNode> modelNodeAndVnodeList) {
-        boolean result = true;
-
-        try {
-            Document document = DocumentHelper.createDocument();
-            // 娣诲姞root鑺傜偣
-            Element root = document.addElement("DES");
-            root.addAttribute("Name", "A System");
-            // 娣诲姞terminal鑺傜偣鍒皉oot1
-            Element terminal = root.addElement("Node");
-            terminal.addAttribute("Name", "Terminal");
-            terminal.addAttribute("Type", "NODE");
-
-            // 灏嗘ā鍨嬭浆鎹负DOM锛屾坊鍔犲埌root
-            Algorithm endAlgo = algorithmList.stream().filter(item ->
-                    "end".equals(item.getAlgorithmType())).collect(Collectors.toList()).get(0);
-            ModelNode computerNode = modelNodeAndVnodeList.stream().filter(item ->
-                    endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0);
-            node2DOM(algorithmList, modelNodeAndVnodeList, computerNode, root);
-
-            // 娣诲姞start鑺傜偣鍒皉oot
-            Element start = root.addElement("Node");
-            start.addAttribute("Name", "Start");
-            start.addAttribute("Type", "NODE");
-            // 娣诲姞link锛堣矾寰勶級鍒皉oot
-            Element link = root.addElement("Link");
-            Element block = link.addElement("Block");
-            block.addAttribute("Name", "Terminal");
-            block = link.addElement("Block");
-            block.addAttribute("Name", computerNode.getId().toString());
-            block = link.addElement("Block");
-            block.addAttribute("Name", "Start");
-
-//            document.setXMLEncoding("UTF-8");
-//            String xmlString = document.asXML();
-            // 杈撳嚭鏍煎紡鍖杧ml
-            XMLWriter xmlWriter = null;
-            try {
-                OutputFormat format = OutputFormat.createPrettyPrint();
-                format.setEncoding("UTF-8");
-                StringWriter writer = new StringWriter();
-                xmlWriter = new XMLWriter(writer, format);
-                xmlWriter.write(document);
-                modelRbd.setPublishedXml(writer.toString());
-            } finally {
-                if (xmlWriter!=null) xmlWriter.close();
-            }
-        } catch (Exception e) {
-            e.printStackTrace();
-            result = false;
-        }
-
-        return result;
-    }
-
-    // 閫掑綊鍑芥暟
-    private void node2DOM(List<Algorithm> algorithmList,
-                          List<ModelNode> modelNodeAndVnodeList,
-                          ModelNode node,
-                          Element parent) {
-        if ("node".equals(node.getNodeType())) {
-            Long dataId = node.getDataId();
-            XhProductModel xhProductModel = xhProductModelDao.getById(dataId);
-            if (xhProductModel == null) return;
-            if ("5".equals(xhProductModel.getProductType())) {
-                // 璁惧
-                ParamData paramData = paramDataDao.getParamData(dataId, "expect");
-                if (paramData == null) return;
-                Element element = parent.addElement("Node");
-                element.addAttribute("Name", dataId.toString());
-                element.addAttribute("Type", "NODE");
-                Element failureTag = element.addElement("Failure");
-                failureTag.addAttribute("Dist", "EXP"); // TODO:闇�璁句负鍏蜂綋鐨勫垎甯�
-                Element argsTag = failureTag.addElement("Args");
-                Double value = new Double(paramData.getTaskMtbcfRegulate());
-                value = 1.0/value;
-                argsTag.addAttribute("value", value.toString());
-                if (1==paramData.getRepairable()) {
-                    Element repairTag = element.addElement("Repair");
-                    repairTag.addAttribute("Dist", "EXP"); // TODO:闇�璁句负鍏蜂綋鐨勫垎甯�
-                    argsTag = repairTag.addElement("Args");
-                    value = new Double(paramData.getRepairMttcr());
-                    value = 1.0/value;
-                    argsTag.addAttribute("value", value.toString());
-                    Element repairTimeLimitTag = element.addElement("RepairTimeLimit");
-                    repairTimeLimitTag.setText(String.valueOf(paramData.getRepairMttcr()));
-                }
-            } else if ("10".equals(xhProductModel.getProductType())) {
-                // 铏氬崟浣�
-                ModelRbd rbdXDY = modelRbdDao.getDiagramOfXDY(dataId);
-                if (rbdXDY == null) return;
-                List<Algorithm> algorithmListXDY = algorithmDao.getListByModelId(rbdXDY.getId());
-                List<ModelNode> modelNodeAndVnodeListXDY =modelNodeAlgorithmDao.getListByModelId(rbdXDY.getId());
-                Algorithm endAlgo = algorithmListXDY.stream().filter(item ->
-                        "end".equals(item.getAlgorithmType())).collect(Collectors.toList()).get(0);
-                ModelNode computerNode = modelNodeAndVnodeListXDY.stream().filter(item ->
-                        endAlgo.getComputerList().equals(item.getId().toString())).collect(Collectors.toList()).get(0);
-                node2DOM(algorithmListXDY, modelNodeAndVnodeListXDY, computerNode, parent);
-            }
-        } else {
-            // vnode锛堣繍绠楄妭鐐癸級
-            Algorithm algo = algorithmList.stream().filter(item ->
-                    node.getId().equals(item.getId())).collect(Collectors.toList()).get(0);
-            Element element = parent.addElement("Logic");
-            element.addAttribute("Name", algo.getId().toString());
-            if ("series".equals(algo.getAlgorithmType())) {
-                element.addAttribute("Type", "SERIES");
-            } else if ("parallel".equals(algo.getAlgorithmType())) {
-                element.addAttribute("Type", "PARALLEL");
-            } else if ("vote".equals(algo.getAlgorithmType())) {
-                element.addAttribute("Type", "VOTE");
-                element.addAttribute("VoteValue", algo.getVoteNum().toString());
-            } else if ("switch".equals(algo.getAlgorithmType())) {
-                element.addAttribute("Type", "STANDBY");
-            } else if ("bridge".equals(algo.getAlgorithmType())) {
-                element.addAttribute("Type", "BRIDGE");
-            }
-            String[] computerNodeListStr = algo.getComputerList().split(",");
-            for (String nodeStr : computerNodeListStr) {
-                ModelNode nd = modelNodeAndVnodeList.stream().filter(item ->
-                        nodeStr.equals(item.getId().toString())).collect(Collectors.toList()).get(0);
-                node2DOM(algorithmList, modelNodeAndVnodeList, nd, element);
-            }
-        }
     }
 
     private boolean getAlgorithmFromRbd(ModelRbd modelRbd,
@@ -864,8 +728,8 @@
             List<ModelLine> lines = modelLineList.stream().filter(item ->
                     item.getEndCell().equals(startNode.getPicId())).collect(Collectors.toList());
             if (lines.size()<2) continue;
-            List<ModelLinePair> linePairs = getLinePairs(lines);
-            for (ModelLinePair linePair : linePairs) {
+            List<ModelLinePairDto> linePairs = getLinePairs(lines);
+            for (ModelLinePairDto linePair : linePairs) {
                 hasSimplifiedMe = simplifyBridgeOneLinePair(modelId, modelNodeList, modelLineList,
                         algorithmList, modelNodeAndVnodeList, startNode, linePair);
                 if (hasSimplifiedMe) {
@@ -884,7 +748,7 @@
                                               List<Algorithm> algorithmList,
                                               List<ModelNode> modelNodeAndVnodeList,
                                               ModelNode startNode,
-                                              ModelLinePair linePair) {
+                                              ModelLinePairDto linePair) {
         ModelNode node1 = null;
         ModelNode node2 = null;
         ModelNode node3 = null;
@@ -1095,11 +959,11 @@
     }
 
     // 鎵惧嚭鎵�鏈�2鏍圭嚎鐨勭粍鍚�
-    private List<ModelLinePair> getLinePairs(List<ModelLine> lines) {
-        List<ModelLinePair> linePairs = new ArrayList<>();
+    private List<ModelLinePairDto> getLinePairs(List<ModelLine> lines) {
+        List<ModelLinePairDto> linePairs = new ArrayList<>();
         for (int i=0; i<lines.size()-1; i++) {
             for (int j=i+1; j<lines.size(); j++) {
-                ModelLinePair linePair = new ModelLinePair();
+                ModelLinePairDto linePair = new ModelLinePairDto();
                 linePair.setLine1(lines.get(i));
                 linePair.setLine2(lines.get(j));
                 linePairs.add(linePair);
@@ -1265,22 +1129,39 @@
                         jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/reliabDistribType".split("/"));
                         if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) {
                             productImg.setReliabDistribType(Integer.valueOf(jsonValue.toString()));
+                            if (3==productImg.getReliabDistribType()) {
+                                // 浜岄」鍒嗗竷
+                                jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/simulatTimes".split("/"));
+                                if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) {
+                                    productImg.setBinomialTotalNum(Integer.valueOf(jsonValue.toString()));
+                                    modelNode.setBinomialTotalNum(Integer.valueOf(jsonValue.toString()));
+                                }
+                                jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/successTimes".split("/"));
+                                if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) {
+                                    productImg.setBinomialSuccessNum(Integer.valueOf(jsonValue.toString()));
+                                    modelNode.setBinomialSuccessNum(Integer.valueOf(jsonValue.toString()));
+                                }
+                            }
                         }
-                        productImg.setTaskMtbcf(JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcf".split("/")).toString());
+                        jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcf".split("/"));
+                        if (null != jsonValue) productImg.setTaskMtbcf(jsonValue.toString());
                         jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcfOtherParams2".split("/"));
                         if (null != jsonValue) productImg.setTaskMtbcfOtherParams2(jsonValue.toString());
                         jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/taskMtbcfOtherParams3".split("/"));
                         if (null != jsonValue) productImg.setTaskMtbcfOtherParams3(jsonValue.toString());
                         jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/isRepair".split("/"));
-                        if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) {
+                        if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString()) && !"null".equals(jsonValue.toString())) {
                             productImg.setIsRepair(Integer.valueOf(jsonValue.toString()));
+                        } else {
+                            productImg.setIsRepair(0);
                         }
                         if (1 == productImg.getIsRepair()) {
                             jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairDistribType".split("/"));
                             if (jsonValue != null && StringUtils.isNotBlank(jsonValue.toString())) {
                                 productImg.setRepairDistribType(Integer.valueOf(jsonValue.toString()));
                             }
-                            productImg.setRepairMttcr(JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcr".split("/")).toString());
+                            jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcr".split("/"));
+                            if (null != jsonValue) productImg.setRepairMttcr(jsonValue.toString());
                             jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcrOtherParams2".split("/"));
                             if (null != jsonValue) productImg.setRepairMttcrOtherParams2(jsonValue.toString());
                             jsonValue = JsonUtils2.getJsonValueByPath(jsonObject, "data/repairMttcrOtherParams3".split("/"));

--
Gitblit v1.9.1