| | |
| | | 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; |
| | |
| | | |
| | | 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(); |
| | |
| | | addTasksTag(taskPhaseModelAll, root); |
| | | addModelsTag(taskId, |
| | | productId, |
| | | product.getName(), |
| | | product.getNamePath(), |
| | | productList, |
| | | paramDataList, |
| | | taskPhaseModelAll, |
| | |
| | | if (xmlWriter != null) xmlWriter.close(); |
| | | } |
| | | // XML存盘 |
| | | update(simulatAssess); |
| | | insert(simulatAssess); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("组装算法库仿真计算用模型XML失败: " + e.getMessage()); |
| | |
| | | } |
| | | } |
| | | |
| | | private void addTasksTag(List<TaskPhaseModel> taskPhaseModelAll, |
| | | public void addTasksTag(List<TaskPhaseModel> taskPhaseModelAll, |
| | | Element root) { |
| | | Element tasksTag = root.addElement("tasks"); |
| | | for (TaskPhaseModel taskPhaseModel : taskPhaseModelAll) { |
| | |
| | | } |
| | | } |
| | | |
| | | 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(); |
| | |
| | | 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; |
| | |
| | | |
| | | private void addModelsTag(Long taskId, |
| | | Long productId, |
| | | String productName, |
| | | String productNamePath, |
| | | List<XhProductModel> productList, |
| | | List<ParamData> paramDataList, |
| | | List<TaskPhaseModel> taskPhaseModelAll, |
| | |
| | | taskPhaseModel, |
| | | gkModelTop.getModelId(), |
| | | productId, |
| | | productName, |
| | | productNamePath, |
| | | productList, |
| | | paramDataList, |
| | | gkModelsAssembled, |
| | |
| | | TaskPhaseModel taskPhaseModel, |
| | | Long modelId, |
| | | Long productId, |
| | | String productName, |
| | | String productNamePath, |
| | | List<XhProductModel> productList, |
| | | List<ParamData> paramDataList, |
| | | List<OperatConditModel> gkModelsAssembled, |
| | |
| | | taskPhaseModel, |
| | | gkModel.getModelId(), |
| | | product.getId(), |
| | | product.getName(), |
| | | product.getNamePath(), |
| | | productList, |
| | | paramDataList, |
| | | gkModelsAssembled, |
| | |
| | | // 设备 |
| | | Element nodeTag = parent.addElement("node"); |
| | | nodeTag.addAttribute("name", dataId.toString()); |
| | | nodeTag.addAttribute("real_name", product.getName()); |
| | | nodeTag.addAttribute("name_path", product.getNamePath()); |
| | | nodeTag.addAttribute("type", "node"); |
| | | |
| | | ParamData paramData = paramDataList.stream().filter(item -> |
| | |
| | | element.addAttribute("name", algo.getId().toString()); |
| | | } else { |
| | | element.addAttribute("name", productId.toString()); |
| | | element.addAttribute("real_name", productName); |
| | | element.addAttribute("name_path", productNamePath); |
| | | } |
| | | if ("series".equals(algo.getAlgorithmType())) { |
| | | element.addAttribute("type", "series"); |
| | |
| | | node2DOM(taskId, |
| | | taskPhaseModel, |
| | | modelId, |
| | | null, |
| | | null, |
| | | null, |
| | | productList, |
| | | paramDataList, |
| | |
| | | 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); |
| | |
| | | throw new RenException("文件不存在或者文件打不开"); |
| | | } finally { |
| | | try { |
| | | in.close(); |
| | | if (in != null) { |
| | | in.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | |
| | | 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; |
| | |
| | | this.update(simulatAssess); |
| | | } |
| | | String filePath = path + "/" + simulatAssess.getId() + "/" + "result.xml"; |
| | | String xml = null; |
| | | String xml; |
| | | InputStream in = null; |
| | | |
| | | try { |
| | |
| | | throw new RenException("文件不存在或者文件打不开"); |
| | | } finally { |
| | | try { |
| | | in.close(); |
| | | if (in != null) { |
| | | in.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |