xyc
2024-10-22 3c2e46fef0e866901cbb5de889166b6fda748e5d
modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java
@@ -612,8 +612,7 @@
        List<TaskModelCheckResultDto> chkResult = taskService.checkTaskModel(simulatAssess.getProductId(),
                simulatAssess.getTaskModelId());
        if (chkResult.size() > 0) {
            result = Result.error("模型不完整,请检查模型定义及参数配置。");
//            result = Result.ok(chkResult);
            result = Result.ok(chkResult);
            return result;
        }
@@ -634,7 +633,7 @@
            try {
                setParamToRedis(simulatAssess);
            } catch (Exception e) {
                throw new RuntimeException("访问Redis失败。请检查Redis是否已启动。");
                throw new RenException("访问Redis失败。请检查Redis是否已启动。");
            }
            Process process = null;
@@ -647,7 +646,7 @@
            } else if (System.getProperty("os.name").toLowerCase().indexOf("linux") > -1) {
                process = Runtime.getRuntime().exec(new String[]{"/bin/sh", "-c", command});
            } else {
                throw new Exception("暂不支持该操作系统,进行启动算法库计算!");
                throw new RenException("暂不支持该操作系统,进行启动算法库计算!");
            }
            is = process.getInputStream();
            // 以命令行方式调用算法库时,接口约定返回的结果是utf-8编码
@@ -658,17 +657,17 @@
            if (line != null) {
                ReliaSimLibResult rtn = com.alibaba.fastjson.JSONObject.parseObject(line, ReliaSimLibResult.class);
                if ("0".equals(rtn.getCode())) {
                    logger.info("启动算法库成功。");
                    logger.info("启动可靠性仿真评估算法库成功。");
                    result = Result.ok();
                } else {
                    String errorMsg = rtn.getErrorMsg();
                    throw new RuntimeException("启动算法库失败: errorMsg=" + errorMsg);
                    throw new RenException("启动可靠性仿真评估算法库失败: errorMsg=" + errorMsg);
                }
            }
        } catch (Exception e) {
            logger.error("启动算法库仿真时发生Exception:", e);
        } catch (IOException e) {
            logger.error("启动可靠性仿真评估算法库仿真时发生Exception:", e);
            e.printStackTrace();
            result = Result.error(e.getMessage());
            throw new RenException("启动可靠性仿真评估算法库失败: errorMsg=" + e.getMessage());
        } finally {
            if (is != null) {
                try {
@@ -773,7 +772,7 @@
            insert(simulatAssess);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("组装算法库仿真计算用模型XML失败: " + e.getMessage());
            throw new RenException("组装算法库仿真计算用模型XML失败: " + e.getMessage());
        }
    }
@@ -1009,9 +1008,10 @@
                        failureModels, repairModels);
            } else if ("5".equals(product.getProductType())) {
                // 设备
                Integer deviceNo = node.getDeviceNo();
                Element nodeTag = parent.addElement("node");
                nodeTag.addAttribute("name", dataId.toString());
                nodeTag.addAttribute("real_name", product.getName());
                nodeTag.addAttribute("name", deviceNo == 0 ? dataId.toString() : dataId.toString()+"-"+deviceNo);
                nodeTag.addAttribute("real_name", deviceNo == 0 ? product.getName() : product.getName()+"-"+deviceNo);
                nodeTag.addAttribute("name_path", product.getNamePath());
                nodeTag.addAttribute("type", "node");
@@ -1113,7 +1113,8 @@
                break;
            case 3:
                // 二项分布
                if (taskBinoParam.getSimulatTimes().intValue() == taskBinoParam.getSuccessTimes().intValue()) {
                if ((taskBinoParam.getSimulatTimes() == null && taskBinoParam.getSuccessTimes() == null) ||
                        (taskBinoParam.getSimulatTimes().intValue() == taskBinoParam.getSuccessTimes().intValue())) {
                    // 相等则为成败型
                    failureModel.setType(FailureModel.TYPE_FIX);
                    failureModel.setParam1(taskBinoParam.getSuccessRate());