| | |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | @Scheduled(cron = "0/10 * * * * ? ") |
| | | public void refreshPseudocodeDaily() { |
| | | try { |
| | | initMainProcessPseudocode(); |
| | |
| | | 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<>(); |
| | |
| | | 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生成伪代码成功"); |
| | | } |
| | | } |
| | | |
| | | } |