| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.awt.*; |
| | | import java.io.BufferedReader; |
| | | import java.io.InputStream; |
| | | import java.io.InputStreamReader; |
| | | import java.io.StringWriter; |
| | | import java.util.ArrayList; |
| | | import java.util.*; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.util.HashMap; |
| | | import java.util.Hashtable; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | |
| | |
| | | @Service |
| | | public class SimulatAssessService extends BaseService<SimulatAssessDao, SimulatAssess> { |
| | | private static final Logger logger = LoggerFactory.getLogger(SimulatAssessService.class); |
| | | private static final String RELIA_SIM_TASK_TYPE_SIMULATION = "calcreq"; |
| | | public static final String RELIA_SIM_TASK_TYPE_SIMULATION = "calcreq"; |
| | | public static final String RELIA_SIM_TASK_TYPE_PROGRESS = "calcprog"; |
| | | |
| | | @Value("${spring.redis.host}") |
| | | private String redisHost; |
| | |
| | | private String reliaSimMain; |
| | | @Value("${data.reliaSimLib.resultHome}") |
| | | private String resultHome; |
| | | @Value("${data.reliaSimLib.fixedRandomSeed}") |
| | | private String fixedRandomSeed; |
| | | |
| | | @Autowired |
| | | private RedisTemplate redisTemplate; |
| | |
| | | // 采样周期 |
| | | jsonObject.put("timeslice", simulatAssess.getSamplPeriod() / 60.0); // 单位统一换算为小时 |
| | | jsonObject.put("result_home", resultHome); |
| | | jsonObject.put("seed", 1000); |
| | | if (null != fixedRandomSeed && "1".equals(fixedRandomSeed)) { |
| | | // 固定种子 |
| | | jsonObject.put("seed", 1000); |
| | | } else { |
| | | // 随机种子 |
| | | jsonObject.put("seed", new Random().nextInt(1000)); |
| | | } |
| | | redisTemplate.opsForValue().set(key, jsonObject.toJSONString()); |
| | | } |
| | | |
| | | public void deleteSimInfoInRedis(Long simId) { |
| | | redisTemplate.delete(simId.toString() + RELIA_SIM_TASK_TYPE_SIMULATION); |
| | | redisTemplate.delete(simId.toString() + RELIA_SIM_TASK_TYPE_PROGRESS); |
| | | } |
| | | |
| | | private void assembleModelXml(SimulatAssess simulatAssess) { |
| | |
| | | } finally { |
| | | if (xmlWriter != null) xmlWriter.close(); |
| | | } |
| | | // XML存盘 |
| | | update(simulatAssess); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | throw new RuntimeException("组装算法库仿真计算用模型XML失败: " + e.getMessage()); |