logs = midjourneyLogService.selectAllDoing().stream().filter(log -> Objects.nonNull(log.getRoomId())).collect(Collectors.toList());//找到超时任务进行关闭List failLogs = logs.stream().filter(log -> System.currentTimeMillis() - log.getCreateTime().getTime() > MAX_WAIT_TIME).collect(Collectors.toList());failLogs.forEach(this::sendBuildFail);//剩余任务整理出来房间号logs.removeAll(failLogs);Set roomSet = logs.stream().map(MidjourneyLog::getRoomId).collect(Collectors.toSet());//轮询当前进度for (Integer roomId : roomSet) {RoomInfo roomInfo = roomInfoService.findById(roomId);if (Objects.isNull(roomInfo)) {log.error("[room没找到] roomId:{} 没找到对应房间 , 看一下是不是挂了", roomId);continue;}Discord discord = discordService.findById(roomInfo.getDiscordId());List midMsgs = readNowList(roomInfo, discord);log.info("[消息列表] {}", midMsgs);checkAndSendMsg(midMsgs, logs, roomInfo);}}private void cleanRoomNumber() {List roomInfos = roomInfoService.findAll();for (RoomInfo roomInfo : roomInfos) {int count = midjourneyLogService.selectRoomOnUse(roomInfo.getId());roomInfo.setNowNumber(count);roomInfoService.update(roomInfo);}}private void checkAndSendMsg(List midMsgs, List logs, RoomInfo roomInfo) {List roomLogs = logs.stream().filter(log -> log.getRoomId().equals(roomInfo.getId())).collect(Collectors.toList());midMsgs.stream().filter(this::isPrintOk).forEach(m -> roomLogs.forEach(midjourey -> {if (m.getContent().startsWith(MID_JOURNEY_HEAD + filterHead(midjourey.getPrompt()))) {log.info("[Midjourney 配对] msg:{}key:{}", m, midjourey.getPrompt());String wxid = memberService.selectWxidById(midjourey.getMemberId());String url = m.getAttachments().get(0).getUrl();String localPath = Constant.FILE_PATH + UUID.randomUUID() + "." + FileUtil.getSuffix(url);ImgDownUtil.getImage(url.replace("https://", "http://"), localPath);localPath = localPath.replace("\\", "/");if ("webp".equals(FileUtil.getSuffix(localPath))) {com.example.midjourney.util.ImgUtil.webpToPng(localPath, localPath + ".png");localPath = localPath + ".png";}String mediaId = weChatBiz.sendImg(localPath, midjourey.getChannel());log.info("[mediaId] {}", mediaId);if (Strings.isNotEmpty(mediaId)) {weChatBiz.sendImgMsg(wxid, mediaId, midjourey.getChannel());weChatBiz.sendTextMsg(wxid, "下载高清大图口令:\n\n☆左上图回复:U1\n\n☆右上图回复:U2" +"\n\n☆左下图回复:U3\n\n☆右下图回复:U4\n\n下载大图也会扣电量哦~", midjourey.getChannel());midjourey.setImgFile(localPath);midjourneyLogService.updateFinish(midjourey);}}}));}private String filterHead(String prompt) {return Lists.newArrayList(Splitter.on("--").split(prompt)).stream().findFirst().orElse("").trim();}private boolean isPrintOk(MidMsg midMsg) {if (Objects.isNull(midMsg)|| Strings.isEmpty(midMsg.getContent())|| !midMsg.getContent().contains(MID_FIND_LEFT)) {return false;}String str = midMsg.getContent().substring(midMsg.getContent().indexOf(MID_FIND_LEFT));return !str.contains("%") && !str.contains("Waiting");}private boolean isBlackWord(String msg) {msg = msg.toLowerCase();for (String s : Constant.MidjourneyBlackWord) {if (msg.contains(s.toLowerCase())) {return true;}}return false;}private void sendSensitive(MidjourneyLog midjourneyLog) {String wxid = memberService.selectWxidById(midjourneyLog.getMemberId());midjourneyLogService.updateSensitive(midjourneyLog);weChatBiz.sendTextMsg(wxid, "【违规提示】输入内容包含违禁词 , 依法进行屏蔽 。", midjourneyLog.getChannel());}/*** 审核不通过通知用户*/private void sendSensitive(MidjourneyLog midjourneyLog, BaiduTextCensor censor) {String reason = Joiner.on("、").join(Safes.of(censor.getData()).stream().map(BaiduTextCensorData::getMsg).collect(Collectors.toList()));reason = Strings.isEmpty(reason) ? "包含敏感信息" : reason;String fullText = "【违规提示】输入内容因 " + reason + " , 依法进行屏蔽 。(百度提供审核能力)";String wxid = memberService.selectWxidById(midjourneyLog.getMemberId());midjourneyLogService.updateSensitive(midjourneyLog);weChatBiz.sendTextMsg(wxid, fullText, midjourneyLog.getChannel());}public List