| | |
| | | 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; |
| | | |
| | | |
| | | /** |
| | | * 分页查询 |
| | |
| | | currentStatusDto.setX2(nextStatusDto.getX1()); |
| | | statusDtoListNew.add(new TimeDiagramStatusDto(nextStatusDto.getX1(), nextStatusDto.getX2(), nextStatusDto.getStatus())); |
| | | } else if (nextStatusDto.getX1() > currentStatusDto.getX1() && nextStatusDto.getX2() < currentStatusDto.getX2()) { |
| | | currentStatusDto.setX2(nextStatusDto.getX1()); |
| | | statusDtoListNew.add(new TimeDiagramStatusDto(nextStatusDto.getX1(), nextStatusDto.getX2(), nextStatusDto.getStatus())); |
| | | statusDtoListOld.add(new TimeDiagramStatusDto(nextStatusDto.getX2(), currentStatusDto.getX2(), currentStatusDto.getStatus())); |
| | | currentStatusDto.setX2(nextStatusDto.getX1()); |
| | | } |
| | | } else { |
| | | if (nextStatusDto.getX1() >= currentStatusDto.getX2()) { |
| | |
| | | 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) { |
| | |
| | | return failureModel; |
| | | } |
| | | |
| | | private boolean isRepairDirac(boolean repairDiracFlag, TaskPhaseModel taskPhaseModel, Long productId) { |
| | | private boolean isRepairDirac(Boolean repairDiracFlag, TaskPhaseModel taskPhaseModel, Long productId) { |
| | | boolean result = false; |
| | | |
| | | if (repairDiracFlag) { |
| | | if (taskPhaseModel.getPhaseConstraints() != null) { |
| | | if (repairDiracFlag != null && repairDiracFlag) { |
| | | if (taskPhaseModel.getPhaseConstraints() == null) { |
| | | result = true; |
| | | } else { |
| | | List<TaskPhaseConstraintDto> list = taskPhaseModel.getPhaseConstraints().stream().filter(item -> |
| | | productId.equals(item.getProductId())).collect(Collectors.toList()); |
| | | if (list.size() == 0) { |
| | |
| | | private RepairModel createRepairModelDirac(double time) { |
| | | RepairModel repairModel = new RepairModel(); |
| | | repairModel.setId(UUIDUtil.generateId()); |
| | | repairModel.setType(RepairModel.TYPE_DIRAC); |
| | | repairModel.setParam1(0); |
| | | return repairModel; |
| | | } |