| | |
| | | import cn.hutool.json.XML; |
| | | import com.fasterxml.jackson.databind.ObjectMapper; |
| | | import com.spire.pdf.tables.table.convert.Convert; |
| | | import com.zt.common.db.query.QueryFilter; |
| | | import com.zt.common.exception.RenException; |
| | | import com.zt.common.service.BaseService; |
| | | import com.zt.common.servlet.Result; |
| | |
| | | import com.zt.life.modules.mainPart.taskReliability.dto.TaskPhaseConstraintDto; |
| | | import com.zt.life.modules.mainPart.taskReliability.model.*; |
| | | import com.zt.life.modules.mainPart.utils.GetStringSpace; |
| | | import com.zt.life.modules.mainPart.utils.OSUtils.ProcessUtils; |
| | | import io.swagger.models.auth.In; |
| | | import org.apache.commons.io.IOUtils; |
| | | import org.apache.commons.lang3.StringUtils; |
| | |
| | | Map<Integer, String> templetsStrMap2 = new HashMap<>(); |
| | | |
| | | private JSONObject xmlJSONObj; |
| | | |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | this.processJSONArray(jsonArray, item, taskId); |
| | | } |
| | | } |
| | | childList.removeIf(item -> item.getStatusList().size() == 0); |
| | | return childList; |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean simulate(SimulatAssess simulatAssess) { |
| | | Boolean result = false; |
| | | // 2. 组装供算法库仿真的模型xml |
| | |
| | | result = callReliaSimLib(simulatAssess); |
| | | |
| | | return result; |
| | | } |
| | | |
| | | public List<SimulatAssess> process(QueryFilter queryFilter) { |
| | | List<SimulatAssess> page = baseDao.getProcessList(queryFilter.getParams()); |
| | | return queryFilter.getPageList(page); |
| | | } |
| | | |
| | | private Boolean callReliaSimLib(SimulatAssess simulatAssess) { |
| | |
| | | } else { |
| | | throw new RenException("暂不支持该操作系统,进行启动算法库计算!"); |
| | | } |
| | | long pid = ProcessUtils.getProcessId(process); |
| | | logger.info("算法库PID:" + pid); |
| | | is = process.getInputStream(); |
| | | // 以命令行方式调用算法库时,接口约定返回的结果是utf-8编码 |
| | | br = new BufferedReader(new InputStreamReader(is, "utf-8")); |
| | |
| | | ReliaSimLibResult rtn = com.alibaba.fastjson.JSONObject.parseObject(line, ReliaSimLibResult.class); |
| | | if ("0".equals(rtn.getCode())) { |
| | | logger.info("启动可靠性仿真评估算法库成功。"); |
| | | newProcess(simulatAssess, pid, command); |
| | | update(simulatAssess); |
| | | result = true; |
| | | } else { |
| | | String errorMsg = rtn.getErrorMsg(); |
| | |
| | | return result; |
| | | } |
| | | |
| | | public void newProcess(SimulatAssess simulatAssess, long pid, String command) { |
| | | simulatAssess.setPid(pid); |
| | | simulatAssess.setCommandLine(command); |
| | | simulatAssess.setProcessIsAlive(true); |
| | | simulatAssess.setProcessStartTime(new Date()); |
| | | simulatAssess.setProgress(0); |
| | | } |
| | | |
| | | private void setParamToRedis(SimulatAssess simulatAssess) { |
| | | String key = simulatAssess.getId().toString() + RELIA_SIM_TASK_TYPE_SIMULATION; |
| | | logger.info("redis key:" + key); |