From 7ec9326ce00d08f9d957981f2edff6df26f24a28 Mon Sep 17 00:00:00 2001
From: jinlin <jinlin>
Date: 星期四, 26 九月 2024 13:25:02 +0800
Subject: [PATCH] 修改
---
modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java | 49 ++++++++++++++++++++++++++++++++-----------------
1 files changed, 32 insertions(+), 17 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 4eccb68..59c2801 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
@@ -14,7 +14,6 @@
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.XhProductModel;
-import com.zt.life.modules.mainPart.basicInfo.service.XhProductModelService;
import com.zt.life.modules.mainPart.taskReliability.dao.*;
import com.zt.common.utils.JsonUtils2;
import com.zt.life.modules.mainPart.taskReliability.dao.SimulatAssessDao;
@@ -579,6 +578,7 @@
private void assembleModelXml(SimulatAssess simulatAssess) {
Long productId = simulatAssess.getProductId();
+ XhProductModel product = xhProductModelDao.getById(productId);
List<XhProductModel> productList = xhProductModelDao.getByShipId(productId);
List<ParamData> paramDataList = paramDataDao.getDeviceParams(productId);
Long taskId = simulatAssess.getTaskModelId();
@@ -604,6 +604,8 @@
addTasksTag(taskPhaseModelAll, root);
addModelsTag(taskId,
productId,
+ product.getName(),
+ product.getNamePath(),
productList,
paramDataList,
taskPhaseModelAll,
@@ -666,7 +668,7 @@
}
}
- private void addTasksTag(List<TaskPhaseModel> taskPhaseModelAll,
+ public void addTasksTag(List<TaskPhaseModel> taskPhaseModelAll,
Element root) {
Element tasksTag = root.addElement("tasks");
for (TaskPhaseModel taskPhaseModel : taskPhaseModelAll) {
@@ -743,7 +745,7 @@
}
}
- private void calcTaskPhaseModelDuration(TaskPhase taskPhase,
+ public void calcTaskPhaseModelDuration(TaskPhase taskPhase,
List<TaskPhaseModel> taskPhaseModelAll) {
List<TaskPhaseModel> taskPhaseModels = taskPhaseModelDao.getListByPhaseId(taskPhase.getId());
double totalRate = taskPhaseModels.stream().mapToDouble(TaskPhaseModel::getOperatConditDurationRate).sum();
@@ -763,7 +765,7 @@
taskPhaseModels.get(taskPhaseModels.size() - 1).setOperatConditDuration(duration + taskPhase.getPhaseDuration() - sum);
}
- private List<TaskPhase> calcTaskPhaseDuration(Task task) {
+ public List<TaskPhase> calcTaskPhaseDuration(Task task) {
List<TaskPhase> taskPhases = taskPhaseDao.getListByTaskId(task.getId());
double totalRate = taskPhases.stream().mapToDouble(TaskPhase::getPhaseDurationRate).sum();
double sum = 0.0;
@@ -781,6 +783,8 @@
private void addModelsTag(Long taskId,
Long productId,
+ String productName,
+ String productNamePath,
List<XhProductModel> productList,
List<ParamData> paramDataList,
List<TaskPhaseModel> taskPhaseModelAll,
@@ -803,11 +807,12 @@
"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);
- XhProductModel product = xhProductModelDao.getById(productId);
node2DOM(taskId,
taskPhaseModel,
gkModelTop.getModelId(),
- product,
+ productId,
+ productName,
+ productNamePath,
productList,
paramDataList,
gkModelsAssembled,
@@ -823,7 +828,9 @@
private void node2DOM(Long taskId,
TaskPhaseModel taskPhaseModel,
Long modelId,
- XhProductModel productTop,
+ Long productId,
+ String productName,
+ String productNamePath,
List<XhProductModel> productList,
List<ParamData> paramDataList,
List<OperatConditModel> gkModelsAssembled,
@@ -851,7 +858,9 @@
node2DOM(taskId,
taskPhaseModel,
gkModel.getModelId(),
- productTop,
+ product.getId(),
+ product.getName(),
+ product.getNamePath(),
productList,
paramDataList,
gkModelsAssembled,
@@ -907,12 +916,12 @@
Algorithm algo = algorithmList.stream().filter(item ->
node.getId().equals(item.getId())).collect(Collectors.toList()).get(0);
Element element = parent.addElement("logic");
- if (null == productTop) {
+ if (null == productId) {
element.addAttribute("name", algo.getId().toString());
} else {
- element.addAttribute("name", productTop.getId().toString());
- element.addAttribute("real_name", productTop.getName());
- element.addAttribute("name_path", productTop.getNamePath());
+ element.addAttribute("name", productId.toString());
+ element.addAttribute("real_name", productName);
+ element.addAttribute("name_path", productNamePath);
}
if ("series".equals(algo.getAlgorithmType())) {
element.addAttribute("type", "series");
@@ -933,6 +942,8 @@
node2DOM(taskId,
taskPhaseModel,
modelId,
+ null,
+ null,
null,
productList,
paramDataList,
@@ -1011,7 +1022,7 @@
String filePath = path + "/" + fzId + "/" + "result.xml";
List<WeakDto> list = new ArrayList<>();
Map<Long, WeakDto> map = new HashMap<>();
- String xml = null;
+ String xml;
InputStream in = null;
try {
in = new FileInputStream(filePath);
@@ -1021,7 +1032,9 @@
throw new RenException("鏂囦欢涓嶅瓨鍦ㄦ垨鑰呮枃浠舵墦涓嶅紑");
} finally {
try {
- in.close();
+ if (in != null) {
+ in.close();
+ }
} catch (IOException e) {
e.printStackTrace();
}
@@ -1035,7 +1048,7 @@
JSONArray jsonArray = xmlJSONObj.getJSONObject("ResultNodes").getJSONArray("ResultNode");
for (int i = 0; i < jsonArray.size(); i++) {
WeakDto data = new WeakDto();
- Long productId1 = null;
+ Long productId1;
Object nameValue = jsonArray.getJSONObject(i).get("name");
if (nameValue instanceof Long) {
productId1 = (Long) nameValue;
@@ -1135,7 +1148,7 @@
this.update(simulatAssess);
}
String filePath = path + "/" + simulatAssess.getId() + "/" + "result.xml";
- String xml = null;
+ String xml;
InputStream in = null;
try {
@@ -1146,7 +1159,9 @@
throw new RenException("鏂囦欢涓嶅瓨鍦ㄦ垨鑰呮枃浠舵墦涓嶅紑");
} finally {
try {
- in.close();
+ if (in != null) {
+ in.close();
+ }
} catch (IOException e) {
e.printStackTrace();
}
--
Gitblit v1.9.1