#
Junjie
2 天以前 0c5a58771fcf86ad0b562829fbfa440da9392703
src/main/java/com/zy/ai/timer/MakeMainProcessPseudocodeScheduler.java
@@ -25,7 +25,7 @@
    @Autowired
    private RedisUtil redisUtil;
    @Scheduled(cron = "0/3 * * * * ? ")
    @Scheduled(cron = "0/10 * * * * ? ")
    public void refreshPseudocodeDaily() {
        try {
            initMainProcessPseudocode();
@@ -51,6 +51,29 @@
                code = new String(Files.readAllBytes(p), StandardCharsets.UTF_8);
            }
        } catch (Exception ignore) {}
        String crnOperateProcessUtilsCode = null;
        try {
            String utilsClassName = "com.zy.core.utils.CrnOperateProcessUtils";
            String rel = utilsClassName.replace('.', '/') + ".java";
            java.nio.file.Path p = Paths.get(System.getProperty("user.dir"), "src", "main", "java", rel);
            if (Files.exists(p)) {
                crnOperateProcessUtilsCode = new String(Files.readAllBytes(p), StandardCharsets.UTF_8);
                code += crnOperateProcessUtilsCode;
            }
        } catch (Exception ignore) {}
        String StationOperateProcessUtilsCode = null;
        try {
            String utilsClassName = "com.zy.core.utils.StationOperateProcessUtils";
            String rel = utilsClassName.replace('.', '/') + ".java";
            java.nio.file.Path p = Paths.get(System.getProperty("user.dir"), "src", "main", "java", rel);
            if (Files.exists(p)) {
                StationOperateProcessUtilsCode = new String(Files.readAllBytes(p), StandardCharsets.UTF_8);
                code += StationOperateProcessUtilsCode;
            }
        } catch (Exception ignore) {}
        String result = null;
        if (code != null && !code.isEmpty()) {
            List<ChatCompletionRequest.Message> messages = new java.util.ArrayList<>();
@@ -203,8 +226,14 @@
                result = llmChatService.chat(messages, 0.2, 2048);
            } catch (Exception ignore) {}
        }
        redisUtil.set(RedisKeyType.MAIN_PROCESS_PSEUDOCODE.key, result, 60 * 60 * 24);
        News.info("主流程伪代码已刷新");
        if (result == null) {
            redisUtil.set(RedisKeyType.MAIN_PROCESS_PSEUDOCODE.key, "AI生成伪代码失败", 60 * 10);
            News.info("AI生成伪代码失败");
        }else {
            redisUtil.set(RedisKeyType.MAIN_PROCESS_PSEUDOCODE.key, result, 60 * 60 * 24);
            News.info("AI生成伪代码成功");
        }
    }
}