jinlin
2024-08-07 38d87eb232eadb24fdcc7602609a6ec3592df7bd
modules/mainPart/src/main/java/com/zt/life/modules/mainPart/taskReliability/service/SimulatAssessService.java
@@ -38,18 +38,13 @@
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;
@@ -62,7 +57,8 @@
@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;
@@ -72,6 +68,8 @@
    private String reliaSimMain;
    @Value("${data.reliaSimLib.resultHome}")
    private String resultHome;
    @Value("${data.reliaSimLib.fixedRandomSeed}")
    private String fixedRandomSeed;
    @Autowired
    private RedisTemplate redisTemplate;
@@ -762,8 +760,19 @@
        // 采样周期
        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) {
@@ -819,6 +828,8 @@
            } finally {
                if (xmlWriter != null) xmlWriter.close();
            }
            // XML存盘
            update(simulatAssess);
        } catch (Exception e) {
            e.printStackTrace();
            throw new RuntimeException("组装算法库仿真计算用模型XML失败: " + e.getMessage());