mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-07 18:06:50 +08:00
Compare commits
21 Commits
757279e7ba
...
player-202
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80b444c188 | ||
|
|
b0a0725373 | ||
|
|
59e42cda4f | ||
|
|
ec6d9100c2 | ||
|
|
562a4cc862 | ||
|
|
ae11017d67 | ||
|
|
fd473445de | ||
|
|
bfdbd4d38e | ||
|
|
640786391d | ||
|
|
71b00372f6 | ||
|
|
2e4b04d1d1 | ||
|
|
bffb85848f | ||
|
|
a9e34e42b9 | ||
|
|
84bd63ec0e | ||
|
|
1aba83a1b8 | ||
|
|
2b1211c83d | ||
|
|
fe3e8df37c | ||
|
|
8d9b360654 | ||
|
|
3379acdd1e | ||
|
|
9a3b394e03 | ||
|
|
7beb046d6d |
@@ -161,21 +161,11 @@
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpmime</artifactId>
|
||||
<version>4.5.13</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.mail</groupId>
|
||||
<artifactId>javax.mail-api</artifactId>
|
||||
<version>1.5.6</version>
|
||||
</dependency>
|
||||
<!-- <dependency>-->
|
||||
<!-- <groupId>com.sun.mail</groupId>-->
|
||||
<!-- <artifactId>javax.mail</artifactId>-->
|
||||
<!-- <version>1.5.6</version>-->
|
||||
<!-- </dependency>-->
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -237,23 +227,6 @@
|
||||
<artifactId>elasticsearch-rest-high-level-client</artifactId>
|
||||
<version>7.9.0</version> <!-- 请根据实际需求选择合适的版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp-sse</artifactId>
|
||||
<version>4.2.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>2.0.31</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.xboe</groupId>
|
||||
@@ -266,6 +239,10 @@
|
||||
<artifactId>xxl-job-core</artifactId>
|
||||
<version>2.3.0</version> <!-- 请根据实际需求选择版本 -->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
<build>
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.xboe.config;
|
||||
|
||||
import com.xboe.module.boecase.service.IElasticSearchIndexService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.event.ApplicationReadyEvent;
|
||||
import org.springframework.context.event.EventListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* ElasticSearch索引初始化器
|
||||
* 在Spring Boot启动完成并监听到配置文件加载完毕后,检查并创建所需的ES索引
|
||||
*
|
||||
* @author AI Assistant
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class ElasticSearchIndexInitializer {
|
||||
|
||||
@Autowired
|
||||
private IElasticSearchIndexService elasticSearchIndexService;
|
||||
|
||||
/**
|
||||
* 监听Spring Boot应用启动完成事件
|
||||
* ApplicationReadyEvent在应用启动完成、所有配置加载完毕后触发
|
||||
*/
|
||||
@EventListener(ApplicationReadyEvent.class)
|
||||
public void initializeElasticSearchIndices() {
|
||||
if (elasticSearchIndexService.checkIndexExists()) {
|
||||
log.info("ElasticSearch索引 ai_chat_messages 已存在");
|
||||
} else {
|
||||
log.info("ElasticSearch索引 ai_chat_messages 不存在,开始创建...");
|
||||
elasticSearchIndexService.createIndex();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
package com.xboe.config;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.Dispatcher;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
/**
|
||||
* 线程池配置类
|
||||
*/
|
||||
@Configuration
|
||||
@Slf4j
|
||||
public class ThreadPoolConfig {
|
||||
|
||||
/**
|
||||
* 执行AI文档接口的的线程池
|
||||
* 策略:单线程等待队列
|
||||
*/
|
||||
@Bean(name = "aiDocExecutor")
|
||||
public ThreadPoolTaskExecutor aiDocExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
// 设置核心线程数
|
||||
int corePoolSize = Runtime.getRuntime().availableProcessors();
|
||||
executor.setCorePoolSize(Math.max(4, corePoolSize));
|
||||
// 设置最大线程数
|
||||
executor.setMaxPoolSize(Math.max(16, corePoolSize * 2));
|
||||
// 设置队列容量(确保任务排队)
|
||||
executor.setQueueCapacity(100);
|
||||
// keepalive
|
||||
executor.setKeepAliveSeconds(30);
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
executor.setAwaitTerminationSeconds(30);
|
||||
// 设置线程名称前缀
|
||||
executor.setThreadNamePrefix("ai_doc_task-");
|
||||
// 设置拒绝策略(当队列满时,由调用线程处理该任务)
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
// 初始化线程池
|
||||
executor.initialize();
|
||||
log.info("AI文档线程池初始化完成 - 核心线程: {}, 最大线程: {}, 队列容量: {}",
|
||||
executor.getCorePoolSize(),
|
||||
executor.getMaxPoolSize(),
|
||||
executor.getQueueCapacity());
|
||||
return executor;
|
||||
}
|
||||
|
||||
/**
|
||||
* event-stream线程池
|
||||
* @return
|
||||
*/
|
||||
@Bean(name = "eventStreamExecutor")
|
||||
public ThreadPoolTaskExecutor eventStreamExecutor() {
|
||||
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
|
||||
executor.setCorePoolSize(10);
|
||||
executor.setMaxPoolSize(500);
|
||||
executor.setQueueCapacity(10);
|
||||
executor.setThreadNamePrefix("event-stream-");
|
||||
executor.setKeepAliveSeconds(300);
|
||||
executor.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
executor.setWaitForTasksToCompleteOnShutdown(true);
|
||||
executor.initialize();
|
||||
return executor;
|
||||
}
|
||||
|
||||
@Bean(name = "customDispatcher")
|
||||
public Dispatcher customDispatcher(@Qualifier("eventStreamExecutor") ThreadPoolTaskExecutor eventStreamExecutor) {
|
||||
return new Dispatcher(eventStreamExecutor.getThreadPoolExecutor());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.xboe.constants;
|
||||
|
||||
public class CaseAiConstants {
|
||||
|
||||
public static final String CASE_AI_INDEX_NAME = "ai_chat_messages";
|
||||
|
||||
public static final String CASE_DOC_UPLOAD_INTERFACE_NAME = "文档上传";
|
||||
|
||||
public static final String CASE_DOC_DELETE_INTERFACE_NAME = "文档删除";
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
package com.xboe.enums;
|
||||
|
||||
public enum CaseAiChatStatusEnum {
|
||||
|
||||
REFERS(0, "引用文档"),
|
||||
|
||||
CHAT(1, "聊天中"),
|
||||
|
||||
CHAT_COMPLETED(2, "聊天完成"),
|
||||
|
||||
SUGGESTIONS(3, "建议"),
|
||||
|
||||
API_COMPLETED(4, "接口完成"),
|
||||
;
|
||||
|
||||
private final int code;
|
||||
|
||||
private final String label;
|
||||
|
||||
CaseAiChatStatusEnum(int code, String label) {
|
||||
this.code = code;
|
||||
this.label = label;
|
||||
}
|
||||
|
||||
public static CaseAiChatStatusEnum getByCode(int code) {
|
||||
for (CaseAiChatStatusEnum value : values()) {
|
||||
if (value.code == code) {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
return API_COMPLETED;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getLabel() {
|
||||
return label;
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.xboe.enums;
|
||||
|
||||
/**
|
||||
* AI调用日志业务处理状态枚举
|
||||
*/
|
||||
public enum CaseDocumentLogCaseStatusEnum {
|
||||
|
||||
SUCCESS(1, "处理成功"),
|
||||
FAILED(2, "处理失败");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
CaseDocumentLogCaseStatusEnum(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取描述
|
||||
*/
|
||||
public static String getDescByCode(Integer code) {
|
||||
for (CaseDocumentLogCaseStatusEnum statusEnum : values()) {
|
||||
if (statusEnum.getCode().equals(code)) {
|
||||
return statusEnum.getDesc();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static CaseDocumentLogCaseStatusEnum getByCode(Integer code) {
|
||||
for (CaseDocumentLogCaseStatusEnum statusEnum : values()) {
|
||||
if (statusEnum.getCode().equals(code)) {
|
||||
return statusEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
package com.xboe.enums;
|
||||
|
||||
/**
|
||||
* AI调用日志接口调用状态枚举
|
||||
*/
|
||||
public enum CaseDocumentLogOptStatusEnum {
|
||||
|
||||
CALLING(0, "调用中"),
|
||||
SUCCESS(1, "调用成功"),
|
||||
FAILED(2, "调用失败");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
CaseDocumentLogOptStatusEnum(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取描述
|
||||
*/
|
||||
public static String getDescByCode(Integer code) {
|
||||
for (CaseDocumentLogOptStatusEnum statusEnum : values()) {
|
||||
if (statusEnum.getCode().equals(code)) {
|
||||
return statusEnum.getDesc();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static CaseDocumentLogOptStatusEnum getByCode(Integer code) {
|
||||
for (CaseDocumentLogOptStatusEnum statusEnum : values()) {
|
||||
if (statusEnum.getCode().equals(code)) {
|
||||
return statusEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.xboe.enums;
|
||||
|
||||
/**
|
||||
* AI调用日志操作类型枚举
|
||||
*/
|
||||
public enum CaseDocumentLogOptTypeEnum {
|
||||
|
||||
CREATE("create", "新增"),
|
||||
DELETE("delete", "删除"),
|
||||
UPDATE("update", "更改");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
|
||||
CaseDocumentLogOptTypeEnum(String code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取描述
|
||||
*/
|
||||
public static String getDescByCode(String code) {
|
||||
for (CaseDocumentLogOptTypeEnum typeEnum : values()) {
|
||||
if (typeEnum.getCode().equals(code)) {
|
||||
return typeEnum.getDesc();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
package com.xboe.enums;
|
||||
|
||||
/**
|
||||
* AI调用日志接口运行状态枚举
|
||||
*/
|
||||
public enum CaseDocumentLogRunStatusEnum {
|
||||
|
||||
RUNNING(0, "运行中"),
|
||||
COMPLETED(1, "运行完成");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
CaseDocumentLogRunStatusEnum(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取描述
|
||||
*/
|
||||
public static String getDescByCode(Integer code) {
|
||||
for (CaseDocumentLogRunStatusEnum statusEnum : values()) {
|
||||
if (statusEnum.getCode().equals(code)) {
|
||||
return statusEnum.getDesc();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static CaseDocumentLogRunStatusEnum getByCode(Integer code) {
|
||||
for (CaseDocumentLogRunStatusEnum statusEnum : values()) {
|
||||
if (statusEnum.getCode().equals(code)) {
|
||||
return statusEnum;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.xboe.module.assistance.service;
|
||||
|
||||
/**
|
||||
* SMTP邮件服务接口
|
||||
*/
|
||||
public interface ISmtpEmailService {
|
||||
|
||||
/**
|
||||
* 使用SMTP直接发送邮件
|
||||
* @param to 收件人邮箱
|
||||
* @param subject 邮件主题
|
||||
* @param htmlMsg 邮件内容(HTML格式)
|
||||
* @param from 发件人邮箱
|
||||
* @throws Exception 发送异常
|
||||
*/
|
||||
void sendMailBySmtp(String to, String subject, String htmlMsg, String from) throws Exception;
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package com.xboe.module.assistance.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import javax.mail.Authenticator;
|
||||
import javax.mail.Message;
|
||||
import javax.mail.MessagingException;
|
||||
import javax.mail.PasswordAuthentication;
|
||||
import javax.mail.Session;
|
||||
import javax.mail.Transport;
|
||||
import javax.mail.internet.InternetAddress;
|
||||
import javax.mail.internet.MimeMessage;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.xboe.module.assistance.service.ISmtpEmailService;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SmtpEmailServiceImpl implements ISmtpEmailService {
|
||||
|
||||
//region 默认SMTP服务器配置信息
|
||||
private static final String SMTP_HOST = "mail.boe.com.cn";
|
||||
private static final String SMTP_USERNAME = "boeu_learning@boe.com.cn";
|
||||
private static final String SMTP_PASSWORD = "boeLms20251112Syse";
|
||||
private static final String SMTP_PORT = "465";
|
||||
private static final String SMTP_ENCRYPTION = "ssl";
|
||||
//endregion
|
||||
|
||||
@Override
|
||||
public void sendMailBySmtp(String to, String subject, String htmlMsg, String from) throws Exception {
|
||||
// 检查参数
|
||||
if (StringUtils.isBlank(to)) {
|
||||
throw new Exception("发送邮件失败,未指定收件人");
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(subject)) {
|
||||
throw new Exception("发送邮件失败,未指定邮件主题");
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(htmlMsg)) {
|
||||
throw new Exception("发送邮件失败,未指定邮件内容");
|
||||
}
|
||||
// 初始化配置项
|
||||
|
||||
// 设置SMTP属性
|
||||
Properties props = new Properties();
|
||||
props.put("mail.smtp.host", SMTP_HOST);
|
||||
props.put("mail.smtp.port", SMTP_PORT);
|
||||
props.put("mail.smtp.auth", "true");
|
||||
|
||||
if ("ssl".equalsIgnoreCase(SMTP_ENCRYPTION)) {
|
||||
props.put("mail.smtp.ssl.enable", "true");
|
||||
props.put("mail.smtp.ssl.trust", SMTP_HOST);
|
||||
// props.put("mail.smtp.ssl.protocols", "TLSv1.2");
|
||||
} else if ("tls".equalsIgnoreCase(SMTP_ENCRYPTION)) {
|
||||
props.put("mail.smtp.starttls.enable", "true");
|
||||
}
|
||||
|
||||
Authenticator authenticator = new Authenticator() {
|
||||
@Override
|
||||
protected PasswordAuthentication getPasswordAuthentication() {
|
||||
return new PasswordAuthentication(SMTP_USERNAME, SMTP_PASSWORD);
|
||||
}
|
||||
};
|
||||
// 创建会话
|
||||
Session session = Session.getInstance(props, authenticator);
|
||||
session.setDebug(true); // 查看调试信息
|
||||
|
||||
try {
|
||||
// 创建邮件消息
|
||||
Message message = new MimeMessage(session);
|
||||
|
||||
// 设置发件人
|
||||
message.setFrom(new InternetAddress(SMTP_USERNAME));
|
||||
|
||||
// 设置收件人
|
||||
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(to));
|
||||
|
||||
// 设置邮件主题
|
||||
message.setSubject(subject);
|
||||
|
||||
// 设置邮件内容
|
||||
message.setContent(htmlMsg, "text/html;charset=UTF-8");
|
||||
|
||||
// 发送日期
|
||||
message.setSentDate(new Date());
|
||||
|
||||
// 发送邮件
|
||||
log.info("发送邮件. 发件人: {}, 收件人: {}, 标题: {}", SMTP_USERNAME, to, subject);
|
||||
Transport.send(message);
|
||||
|
||||
} catch (MessagingException e) {
|
||||
throw new Exception("发送邮件失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
package com.xboe.module.boecase.api;
|
||||
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.module.boecase.dto.CaseAiChatDto;
|
||||
import com.xboe.module.boecase.entity.AiChatConversationData;
|
||||
import com.xboe.module.boecase.service.ICaseAiChatService;
|
||||
import com.xboe.module.boecase.service.ICaseAiPermissionService;
|
||||
import com.xboe.module.boecase.service.IElasticSearchIndexService;
|
||||
import com.xboe.module.boecase.vo.CaseAiMessageVo;
|
||||
import com.xboe.module.excel.ExportsExcelSenderUtil;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI对话管理API
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value = "/xboe/m/boe/case/ai")
|
||||
public class CaseAiChatApi extends ApiBaseController {
|
||||
|
||||
/**
|
||||
* 聊天
|
||||
* @param caseAiChatDto
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@Autowired
|
||||
private ICaseAiChatService caseAiChatService;
|
||||
|
||||
@Autowired
|
||||
private ICaseAiPermissionService caseAiPermissionService;
|
||||
|
||||
@Autowired
|
||||
private IElasticSearchIndexService elasticSearchIndexService;
|
||||
|
||||
/**
|
||||
* 聊天
|
||||
* @param caseAiChatDto
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/chat", produces = MediaType.TEXT_EVENT_STREAM_VALUE)
|
||||
public SseEmitter chat(@RequestBody CaseAiChatDto caseAiChatDto,
|
||||
HttpServletResponse response) {
|
||||
response.setContentType("text/event-stream");
|
||||
response.setCharacterEncoding(StandardCharsets.UTF_8.name());
|
||||
|
||||
// 获取当前用户
|
||||
return caseAiChatService.chat(caseAiChatDto, getCurrent());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据conversationId查看会话内消息记录
|
||||
* @param conversationId 会话ID
|
||||
* @return 消息记录列表
|
||||
*/
|
||||
@GetMapping("/messages")
|
||||
public JsonResponse<List<CaseAiMessageVo>> getConversationMessages(@RequestParam String conversationId) {
|
||||
try {
|
||||
List<CaseAiMessageVo> messages = caseAiChatService.getConversationMessages(conversationId);
|
||||
return success(messages);
|
||||
} catch (Exception e) {
|
||||
log.error("查询会话消息记录异常", e);
|
||||
return error("查询失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出会话记录为Excel
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
* @param response HTTP响应
|
||||
*/
|
||||
@GetMapping("/export-conversations")
|
||||
public void downloadConversationExcel(@RequestParam String startTime,
|
||||
@RequestParam String endTime,
|
||||
HttpServletResponse response) {
|
||||
try {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
LocalDateTime start = LocalDateTime.parse(startTime, formatter);
|
||||
LocalDateTime end = LocalDateTime.parse(endTime, formatter);
|
||||
|
||||
// TODO: 这里需要修改为实际返回数据的方法
|
||||
caseAiChatService.downloadConversationExcel(start, end);
|
||||
|
||||
response.setContentType("application/vnd.ms-excel");
|
||||
response.setHeader("Content-Disposition", "attachment; filename=conversations.xls");
|
||||
|
||||
// 示例数据,实际应该从Service获取
|
||||
LinkedHashMap<String, String> headers = new LinkedHashMap<>();
|
||||
headers.put("会话ID", "conversationId");
|
||||
headers.put("会话名称", "conversationName");
|
||||
headers.put("用户", "user");
|
||||
headers.put("开始时间", "startTime");
|
||||
headers.put("会话时长", "duration");
|
||||
|
||||
List<ConversationExcelVo> dataList = new ArrayList<>();
|
||||
// 这里应该填充实际数据
|
||||
|
||||
ExportsExcelSenderUtil.export(headers, dataList, response.getOutputStream(), "yyyy-MM-dd HH:mm:ss");
|
||||
} catch (Exception e) {
|
||||
log.error("导出会话记录为Excel异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前登录用户是否显示"案例专家"功能入口
|
||||
* @return 是否显示功能入口
|
||||
*/
|
||||
@GetMapping("/show-entrance")
|
||||
public JsonResponse<Boolean> showCaseAiEntrance() {
|
||||
try {
|
||||
String currentUserCode = getCurrent().getCode();
|
||||
boolean shouldShow = caseAiPermissionService.shouldShowCaseAiEntrance(currentUserCode);
|
||||
// return success(shouldShow);
|
||||
JsonResponse<Boolean> result = success(shouldShow);
|
||||
result.setMessage(currentUserCode);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("判断案例专家功能入口显示权限异常", e);
|
||||
return error("判断失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 手动刷新索引
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/index/refresh")
|
||||
public JsonResponse<String> deleteAndCreateEsIndex() {
|
||||
if (elasticSearchIndexService.checkIndexExists()) {
|
||||
boolean deleteResult = elasticSearchIndexService.deleteIndex();
|
||||
if (deleteResult) {
|
||||
elasticSearchIndexService.createIndex();
|
||||
return success("刷新成功");
|
||||
}
|
||||
} else {
|
||||
elasticSearchIndexService.createIndex();
|
||||
}
|
||||
return error("刷新失败");
|
||||
}
|
||||
|
||||
@PostMapping("/es/create")
|
||||
public JsonResponse<String> createNewConversation(@RequestBody CaseAiMessageVo caseAiMessageVo,
|
||||
@RequestParam String conversationId,
|
||||
@RequestParam String userId) {
|
||||
AiChatConversationData aiChatConversationData = new AiChatConversationData();
|
||||
aiChatConversationData.setConversationId(conversationId);
|
||||
aiChatConversationData.setQuery(caseAiMessageVo.getQuery());
|
||||
aiChatConversationData.appendAnswer(caseAiMessageVo.getAnswer());
|
||||
aiChatConversationData.setCaseRefers(caseAiMessageVo.getCaseRefer());
|
||||
aiChatConversationData.setSuggestions(caseAiMessageVo.getSuggestions());
|
||||
aiChatConversationData.setUserId(userId);
|
||||
if (elasticSearchIndexService.createData(aiChatConversationData)) {
|
||||
return success("创建成功");
|
||||
}
|
||||
return error("创建失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 用于Excel导出的VO类
|
||||
*/
|
||||
@Data
|
||||
static class ConversationExcelVo {
|
||||
private String conversationId;
|
||||
private String conversationName;
|
||||
private String user;
|
||||
private String startTime;
|
||||
private String duration;
|
||||
}
|
||||
}
|
||||
@@ -1,331 +0,0 @@
|
||||
package com.xboe.module.boecase.api;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.core.log.AutoLog;
|
||||
import com.xboe.module.boecase.dto.CaseDocumentLogQueryDto;
|
||||
import com.xboe.module.boecase.service.ICaseDocumentLogService;
|
||||
import com.xboe.module.boecase.service.ICaseKnowledgeService;
|
||||
import com.xboe.module.boecase.service.ICasesService;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import java.time.LocalDateTime;
|
||||
import com.xboe.module.boecase.vo.CaseDocumentLogVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* AI调用日志管理API
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value = "/xboe/m/boe/caseDocumentLog")
|
||||
public class CaseDocumentLogApi extends ApiBaseController {
|
||||
|
||||
@Resource
|
||||
private ICaseDocumentLogService caseDocumentLogService;
|
||||
|
||||
@Resource
|
||||
private ICaseKnowledgeService caseKnowledgeService;
|
||||
|
||||
@Resource
|
||||
private ICasesService casesService;
|
||||
|
||||
/**
|
||||
* AI调用日志分页查询
|
||||
*
|
||||
* @param queryDto 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
@PostMapping("/pageQuery")
|
||||
@AutoLog(module = "AI调用日志", action = "分页查询", info = "AI调用日志分页查询")
|
||||
public JsonResponse<PageList<CaseDocumentLogVo>> pageQuery(@RequestBody CaseDocumentLogQueryDto queryDto) {
|
||||
try {
|
||||
PageList<CaseDocumentLogVo> result = caseDocumentLogService.pageQuery(
|
||||
queryDto.getPageIndex(),
|
||||
queryDto.getPageSize(),
|
||||
queryDto
|
||||
);
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
log.error("AI调用日志分页查询失败", e);
|
||||
return error("查询失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 清空日志(根据筛选条件)
|
||||
*
|
||||
* @param queryDto 查询条件
|
||||
* @return 删除结果
|
||||
*/
|
||||
@PostMapping("/clearLogs")
|
||||
@AutoLog(module = "AI调用日志", action = "清空日志", info = "AI调用日志清空操作")
|
||||
public JsonResponse<Integer> clearLogs(@RequestBody CaseDocumentLogQueryDto queryDto) {
|
||||
try {
|
||||
int deletedCount = caseDocumentLogService.clearLogsByCondition(queryDto);
|
||||
return success(deletedCount);
|
||||
} catch (Exception e) {
|
||||
log.error("AI调用日志清空失败", e);
|
||||
return error("清空失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试AI调用
|
||||
*
|
||||
* @param request 重试请求参数
|
||||
* @return 重试结果
|
||||
*/
|
||||
@PostMapping("/retry")
|
||||
@AutoLog(module = "AI调用日志", action = "重试调用", info = "AI调用日志重试操作")
|
||||
public JsonResponse<Boolean> retry(@RequestBody RetryRequest request) {
|
||||
try {
|
||||
boolean result = caseDocumentLogService.retryByLogId(request.getLogId());
|
||||
return success(result);
|
||||
} catch (Exception e) {
|
||||
log.error("AI调用重试失败", e);
|
||||
return error("重试失败", e.getMessage());
|
||||
}
|
||||
// 先走挡板
|
||||
// return success(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据案例ID上传案例文档到知识库
|
||||
*
|
||||
* @param request 上传请求参数
|
||||
* @return 上传结果
|
||||
*/
|
||||
@PostMapping("/uploadCaseByID")
|
||||
@AutoLog(module = "案例文档管理", action = "根据案例ID上传文档", info = "根据案例ID查询案例信息并上传文档到知识库")
|
||||
public JsonResponse<Boolean> uploadCaseById(@RequestBody UploadCaseRequest request) {
|
||||
try {
|
||||
String caseId = request.getCaseId();
|
||||
if (StringUtil.isBlank(caseId)) {
|
||||
return badRequest("案例ID不能为空");
|
||||
}
|
||||
|
||||
// 查询案例信息
|
||||
Cases caseInfo = casesService.selectById(caseId, false);
|
||||
if (caseInfo == null || caseInfo.getDeleted()) {
|
||||
return badRequest("案例不存在或已删除");
|
||||
}
|
||||
|
||||
log.info("开始上传案例文档到知识库,案例ID: {}, 案例标题: {}", caseId, caseInfo.getTitle());
|
||||
|
||||
// 调用ICaseKnowledgeService的uploadCaseDocument方法
|
||||
boolean result = caseKnowledgeService.uploadCaseDocument(caseId);
|
||||
|
||||
if (result) {
|
||||
log.info("案例文档上传成功,案例ID: {}", caseId);
|
||||
return success(result, "案例文档上传成功");
|
||||
} else {
|
||||
log.warn("案例文档上传失败,案例ID: {}", caseId);
|
||||
return success(result, "案例文档上传失败");
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("根据案例ID上传文档失败", e);
|
||||
return error("上传失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 直接创建CaseDocumentLog数据
|
||||
*
|
||||
* @param logData 日志数据
|
||||
* @return 创建结果
|
||||
*/
|
||||
@PostMapping("/createLog")
|
||||
@AutoLog(module = "案例文档日志", action = "创建日志记录", info = "直接创建一条CaseDocumentLog数据")
|
||||
public JsonResponse<String> createLog(@RequestBody CaseDocumentLog logData) {
|
||||
try {
|
||||
// 参数校验
|
||||
if (StringUtil.isBlank(logData.getCaseId())) {
|
||||
return badRequest("案例ID不能为空");
|
||||
}
|
||||
if (StringUtil.isBlank(logData.getOptType())) {
|
||||
return badRequest("操作类型不能为空");
|
||||
}
|
||||
|
||||
// 设置必要的默认值
|
||||
if (StringUtil.isBlank(logData.getId())) {
|
||||
logData.setId(IDGenerator.generate());
|
||||
}
|
||||
if (logData.getOptTime() == null) {
|
||||
logData.setOptTime(LocalDateTime.now());
|
||||
}
|
||||
if (logData.getOptStatus() == null) {
|
||||
logData.setOptStatus(0); // 默认为调用中
|
||||
}
|
||||
if (logData.getDeleted() == null) {
|
||||
logData.setDeleted(false);
|
||||
}
|
||||
|
||||
// 如果提供了案例ID但没有案例标题,尝试查询案例信息补充标题
|
||||
if (StringUtil.isBlank(logData.getCaseTitle()) && StringUtil.isNotBlank(logData.getCaseId())) {
|
||||
try {
|
||||
Cases caseInfo = casesService.selectById(logData.getCaseId(), false);
|
||||
if (caseInfo != null) {
|
||||
logData.setCaseTitle(caseInfo.getTitle());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("查询案例标题失败,案例ID: {}", logData.getCaseId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("创建CaseDocumentLog记录,案例ID: {}, 操作类型: {}",
|
||||
logData.getCaseId(), logData.getOptType());
|
||||
|
||||
// 保存日志记录
|
||||
caseDocumentLogService.save(logData);
|
||||
|
||||
log.info("CaseDocumentLog记录创建成功,日志ID: {}", logData.getId());
|
||||
return success(logData.getId(), "日志记录创建成功");
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("创建CaseDocumentLog记录失败", e);
|
||||
return error("创建失败", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 文档上传回调接口
|
||||
*
|
||||
* @param request 回调请求参数
|
||||
* @return 回调结果
|
||||
*/
|
||||
@PostMapping("/uploadCallback")
|
||||
@AutoLog(module = "AI调用日志", action = "文档上传回调", info = "文档上传回调接口")
|
||||
public CallbackResponse uploadCallback(@RequestBody CallbackRequest request) {
|
||||
try {
|
||||
log.info("收到文档上传回调,taskId: {}, fileStatus: {}, message: {}",
|
||||
request.getTaskId(), request.getFileStatus(), request.getMessage());
|
||||
|
||||
boolean result = caseKnowledgeService.handleUploadCallback(
|
||||
request.getTaskId(),
|
||||
request.getMessage(),
|
||||
request.getFileStatus()
|
||||
);
|
||||
|
||||
CallbackResponse response = new CallbackResponse();
|
||||
response.setSuccess(result);
|
||||
response.setCode(result ? 0 : -1);
|
||||
response.setMessage(result ? "回调处理成功" : "回调处理失败");
|
||||
|
||||
return response;
|
||||
} catch (Exception e) {
|
||||
log.error("文档上传回调处理失败", e);
|
||||
|
||||
CallbackResponse response = new CallbackResponse();
|
||||
response.setSuccess(false);
|
||||
response.setCode(-1);
|
||||
response.setMessage("回调处理异常: " + e.getMessage());
|
||||
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调请求参数
|
||||
*/
|
||||
public static class CallbackRequest {
|
||||
private String taskId;
|
||||
private String message;
|
||||
private String fileStatus;
|
||||
|
||||
public String getTaskId() {
|
||||
return taskId;
|
||||
}
|
||||
|
||||
public void setTaskId(String taskId) {
|
||||
this.taskId = taskId;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
public String getFileStatus() {
|
||||
return fileStatus;
|
||||
}
|
||||
|
||||
public void setFileStatus(String fileStatus) {
|
||||
this.fileStatus = fileStatus;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 回调响应参数
|
||||
*/
|
||||
public static class CallbackResponse {
|
||||
private boolean success;
|
||||
private int code;
|
||||
private String message;
|
||||
|
||||
public boolean isSuccess() {
|
||||
return success;
|
||||
}
|
||||
|
||||
public void setSuccess(boolean success) {
|
||||
this.success = success;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public void setCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
return message;
|
||||
}
|
||||
|
||||
public void setMessage(String message) {
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传案例请求参数
|
||||
*/
|
||||
public static class UploadCaseRequest {
|
||||
private String caseId;
|
||||
|
||||
public String getCaseId() {
|
||||
return caseId;
|
||||
}
|
||||
|
||||
public void setCaseId(String caseId) {
|
||||
this.caseId = caseId;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 重试请求参数
|
||||
*/
|
||||
public static class RetryRequest {
|
||||
private String logId;
|
||||
|
||||
public String getLogId() {
|
||||
return logId;
|
||||
}
|
||||
|
||||
public void setLogId(String logId) {
|
||||
this.logId = logId;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.xboe.module.boecase.api;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 案例上传任务API
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/xboe/m/boe/caseUpload")
|
||||
public class CaseUploadTaskApi {
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
private static final String CASE_UPLOAD_LAST_ID_KEY = "case:upload:last:id";
|
||||
|
||||
/**
|
||||
* 清除处理位置标记,使下次任务从头开始执行
|
||||
*/
|
||||
@PostMapping("/reset")
|
||||
public void resetLastProcessedId() {
|
||||
stringRedisTemplate.delete(CASE_UPLOAD_LAST_ID_KEY);
|
||||
log.info("已清除上次处理位置标记");
|
||||
}
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package com.xboe.module.boecase.async;
|
||||
|
||||
import com.xboe.enums.CaseDocumentLogOptTypeEnum;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xboe.module.boecase.service.ICaseKnowledgeService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CaseAiDocumentAsyncHandler {
|
||||
|
||||
private final AtomicInteger currentTaskCount = new AtomicInteger(0);
|
||||
|
||||
@Autowired
|
||||
@Qualifier("aiDocExecutor")
|
||||
private ThreadPoolTaskExecutor aiDocExecutor;
|
||||
|
||||
@Autowired
|
||||
private ICaseKnowledgeService caseKnowledgeService;
|
||||
|
||||
public void process(CaseDocumentLogOptTypeEnum optTypeEnum, Cases... caseList) {
|
||||
for (Cases cases : caseList) {
|
||||
// 控制并发数量
|
||||
while (currentTaskCount.get() >= 15) {
|
||||
try {
|
||||
Thread.sleep(100);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
currentTaskCount.incrementAndGet();
|
||||
|
||||
aiDocExecutor.submit(() -> {
|
||||
processCases(cases, optTypeEnum);
|
||||
currentTaskCount.decrementAndGet();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void processCases(Cases cases, CaseDocumentLogOptTypeEnum optTypeEnum) {
|
||||
try {
|
||||
switch (optTypeEnum) {
|
||||
case UPDATE:
|
||||
caseKnowledgeService.updateCaseDocument(cases);
|
||||
break;
|
||||
case DELETE:
|
||||
caseKnowledgeService.deleteCaseDocument(cases);
|
||||
break;
|
||||
case CREATE:
|
||||
default:
|
||||
caseKnowledgeService.uploadCaseDocument(cases);
|
||||
break;
|
||||
}
|
||||
log.info("处理案例成功,caseId: {}, 操作类型: {}", cases.getId(), optTypeEnum.getDesc());
|
||||
} catch (Exception e) {
|
||||
log.error("处理案例失败,caseId: {}, 操作类型: {}", cases.getId(), optTypeEnum.getDesc(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package com.xboe.module.boecase.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.module.boecase.entity.CaseAiConversations;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 案例AI会话信息DAO
|
||||
*/
|
||||
@Repository
|
||||
public class CaseAiConversationsDao extends BaseDao<CaseAiConversations> {
|
||||
|
||||
/**
|
||||
* 根据主键ID查询AI会话ID
|
||||
* @param conversationId 主键ID
|
||||
* @return AI会话ID
|
||||
*/
|
||||
public String findAiConversationIdById(String conversationId) {
|
||||
CaseAiConversations conversation = this.getGenericDao().findOne(CaseAiConversations.class,
|
||||
FieldFilters.eq("ai_conversation_id", conversationId));
|
||||
return conversation != null ? conversation.getAiConversationId() : conversationId;
|
||||
}
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
package com.xboe.module.boecase.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* AI调用日志DAO
|
||||
*/
|
||||
@Repository
|
||||
@Slf4j
|
||||
public class CaseDocumentLogDao extends BaseDao<CaseDocumentLog> {
|
||||
|
||||
/**
|
||||
* 根据taskId查询文档日志
|
||||
* @param taskId 任务ID
|
||||
* @return 文档日志
|
||||
*/
|
||||
public CaseDocumentLog findByTaskId(String taskId) {
|
||||
return this.getGenericDao().findOne(CaseDocumentLog.class,
|
||||
FieldFilters.eq("taskId", taskId));
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.xboe.module.boecase.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* AI对话入参
|
||||
*/
|
||||
@Data
|
||||
public class CaseAiChatDto {
|
||||
|
||||
/**
|
||||
* 对话id
|
||||
* 如果是新对话,传空
|
||||
*/
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* 提问内容
|
||||
*/
|
||||
private String query;
|
||||
|
||||
/**
|
||||
* 是否开启思考
|
||||
* 0-否 1-是
|
||||
*/
|
||||
private Integer enableThinking;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package com.xboe.module.boecase.dto;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI调用日志查询条件DTO
|
||||
*/
|
||||
@Data
|
||||
public class CaseDocumentLogQueryDto extends PageDto {
|
||||
|
||||
/**
|
||||
* 案例标题(模糊查询)
|
||||
*/
|
||||
private String caseTitle;
|
||||
|
||||
/**
|
||||
* 操作类型(create-新增,delete-删除,update-更改)
|
||||
*/
|
||||
private String optType;
|
||||
|
||||
/**
|
||||
* 调用时间开始
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime optTimeStart;
|
||||
|
||||
/**
|
||||
* 调用时间结束
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime optTimeEnd;
|
||||
|
||||
/**
|
||||
* 接口调用状态
|
||||
* 0-调用中, 1-调用成功, 2-调用失败
|
||||
*/
|
||||
private Integer optStatus;
|
||||
|
||||
/**
|
||||
* 业务处理状态
|
||||
* 1-处理成功, 2-处理失败
|
||||
*/
|
||||
private Integer caseStatus;
|
||||
}
|
||||
@@ -1,115 +0,0 @@
|
||||
package com.xboe.module.boecase.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.module.boecase.vo.CaseReferVo;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI聊天会话数据实体
|
||||
* 纯数据容器,不与数据库交互
|
||||
*
|
||||
* @author AI Assistant
|
||||
*/
|
||||
@Data
|
||||
@Slf4j
|
||||
public class AiChatConversationData {
|
||||
|
||||
/**
|
||||
* 会话ID
|
||||
*/
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* 用户提问内容
|
||||
*/
|
||||
private String query;
|
||||
|
||||
/**
|
||||
* AI回答内容(使用StringBuilder收集流式数据)
|
||||
*/
|
||||
private StringBuilder answer = new StringBuilder();
|
||||
|
||||
/**
|
||||
* 案例引用列表
|
||||
*/
|
||||
private List<CaseReferVo> caseRefers = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 建议列表
|
||||
*/
|
||||
private List<String> suggestions = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String userName;
|
||||
|
||||
/**
|
||||
* 消息时间戳
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 消息时间戳
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime timestamp;
|
||||
|
||||
/**
|
||||
* 聊天时长(秒)
|
||||
*/
|
||||
private Integer durationSeconds;
|
||||
|
||||
// ================== 构造函数 ==================
|
||||
|
||||
public AiChatConversationData() {
|
||||
this.startTime = LocalDateTime.now();
|
||||
}
|
||||
|
||||
// ================== 便捷方法 ==================
|
||||
|
||||
/**
|
||||
* 获取回答内容的字符串形式
|
||||
*/
|
||||
public String getAnswerAsString() {
|
||||
return this.answer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 追加回答内容
|
||||
*/
|
||||
public void appendAnswer(String content) {
|
||||
if (content != null) {
|
||||
this.answer.append(content);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加案例引用
|
||||
*/
|
||||
public void addCaseRefer(CaseReferVo caseRefer) {
|
||||
if (caseRefer != null) {
|
||||
this.caseRefers.add(caseRefer);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加建议
|
||||
*/
|
||||
public void addSuggestion(String suggestion) {
|
||||
if (suggestion != null && !suggestion.trim().isEmpty()) {
|
||||
this.suggestions.add(suggestion);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package com.xboe.module.boecase.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* 案例AI会话信息表
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE + "case_ai_conversations")
|
||||
public class CaseAiConversations extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 会话ID(由AI平台提供)
|
||||
*/
|
||||
@Column(name = "ai_conversation_id", length = 100)
|
||||
private String aiConversationId;
|
||||
|
||||
/**
|
||||
* 会话名称
|
||||
*/
|
||||
@Column(name = "conversation_name", length = 200)
|
||||
private String conversationName;
|
||||
|
||||
/**
|
||||
* 会话对应用户ID
|
||||
*/
|
||||
@Column(name = "conversation_user", length = 50)
|
||||
private String conversationUser;
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
package com.xboe.module.boecase.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 案例文档日志信息表
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = SysConstant.TABLE_PRE + "case_document_log")
|
||||
public class CaseDocumentLog extends BaseEntity {
|
||||
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
@Column(name = "task_id", length = 20)
|
||||
private String taskId;
|
||||
|
||||
/**
|
||||
* 案例id
|
||||
*/
|
||||
@Column(name = "case_id", length = 20)
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 案例标题
|
||||
*/
|
||||
@Column(name = "case_title", length = 200)
|
||||
private String caseTitle;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
@Column(name = "opt_type")
|
||||
private String optType;
|
||||
|
||||
/**
|
||||
* 请求地址
|
||||
*/
|
||||
@Column(name = "request_url", length = 500)
|
||||
private String requestUrl;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
@Column(name = "request_body", length = 4000)
|
||||
private String requestBody;
|
||||
|
||||
/**
|
||||
* 响应参数
|
||||
*/
|
||||
@Column(name = "response_body", length = 4000)
|
||||
private String responseBody;
|
||||
|
||||
/**
|
||||
* 调用时间
|
||||
*/
|
||||
@Column(name = "opt_time")
|
||||
private LocalDateTime optTime;
|
||||
|
||||
/**
|
||||
* 接口运行状态
|
||||
* 0-运行中, 1-运行完毕
|
||||
*/
|
||||
@Column(name = "run_status")
|
||||
private Integer runStatus;
|
||||
|
||||
/**
|
||||
* 接口调用状态
|
||||
* 0-调用中, 1-调用成功, 2-调用失败
|
||||
*/
|
||||
@Column(name = "opt_status")
|
||||
private Integer optStatus;
|
||||
|
||||
/**
|
||||
* 业务处理状态
|
||||
* 1-处理成功, 2-处理失败
|
||||
*/
|
||||
@Column(name = "case_status")
|
||||
private Integer caseStatus;
|
||||
|
||||
/**
|
||||
* 执行时间(ms)
|
||||
*/
|
||||
@Column(name = "execute_duration")
|
||||
private Long executeDuration;
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
package com.xboe.module.boecase.properties;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 案例专家AI相关配置项
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "xboe.case.ai")
|
||||
@Data
|
||||
public class CaseAiProperties {
|
||||
|
||||
/**
|
||||
* 接口地址
|
||||
*/
|
||||
private String baseUrl;
|
||||
|
||||
/**
|
||||
* appKey
|
||||
*/
|
||||
private String appKey;
|
||||
|
||||
/**
|
||||
* appSecret
|
||||
*/
|
||||
private String secretKey;
|
||||
|
||||
/**
|
||||
* ai接口的apiCode
|
||||
*/
|
||||
private String aiApiCode;
|
||||
|
||||
/**
|
||||
* 对话接口的apiCode
|
||||
*/
|
||||
private String chatApiCode;
|
||||
|
||||
/**
|
||||
* 案例知识库id
|
||||
*/
|
||||
private String caseKnowledgeId;
|
||||
|
||||
/**
|
||||
* 默认上传用户
|
||||
* 当获取不到当前登录用户信息时会取这个
|
||||
*/
|
||||
private String defaultUploadUser;
|
||||
|
||||
/**
|
||||
* 案例详情页面地址
|
||||
*/
|
||||
private String caseDetailUrlBase;
|
||||
|
||||
/**
|
||||
* 文件上传是否使用回调接口
|
||||
*/
|
||||
private boolean fileUploadUseCallback;
|
||||
|
||||
/**
|
||||
* 文档上传回调接口地址
|
||||
*/
|
||||
private String fileUploadCallbackUrl;
|
||||
|
||||
/**
|
||||
* 是否启用白名单
|
||||
*/
|
||||
private boolean useWhiteList;
|
||||
|
||||
/**
|
||||
* 白名单用户列表
|
||||
*/
|
||||
private List<String> whiteUserCodeList;
|
||||
|
||||
/**
|
||||
* AI处理失败告警邮件收件人列表
|
||||
*/
|
||||
private List<String> alertEmailRecipients;
|
||||
|
||||
/**
|
||||
* 是否发送AI对话记录到邮箱
|
||||
*/
|
||||
private boolean aiChatDataSendEmail;
|
||||
|
||||
/**
|
||||
* AI对话记录保存根路径
|
||||
*/
|
||||
private String aiChatRootPath;
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
package com.xboe.module.boecase.service;
|
||||
|
||||
/**
|
||||
* 获取accesstoken
|
||||
*/
|
||||
public interface IAiAccessTokenService {
|
||||
|
||||
/**
|
||||
* 获取accesstoken
|
||||
* @return
|
||||
*/
|
||||
String getAccessToken();
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
package com.xboe.module.boecase.service;
|
||||
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.module.boecase.dto.CaseAiChatDto;
|
||||
import com.xboe.module.boecase.entity.CaseAiConversations;
|
||||
import com.xboe.module.boecase.vo.CaseAiMessageVo;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI案例对话
|
||||
*/
|
||||
public interface ICaseAiChatService {
|
||||
|
||||
/**
|
||||
* 聊天
|
||||
* @param caseAiChatDto
|
||||
* @param currentUser
|
||||
* @return
|
||||
*/
|
||||
SseEmitter chat(CaseAiChatDto caseAiChatDto, CurrentUser currentUser);
|
||||
|
||||
/**
|
||||
* 创建新的AI对话会话
|
||||
* @param userId 用户ID
|
||||
* @param conversationName 对话名称
|
||||
* @return 创建的会话信息
|
||||
*/
|
||||
CaseAiConversations createNewConversation(String userId, String conversationName);
|
||||
|
||||
/**
|
||||
* 根据conversationId查看会话内消息记录
|
||||
* @param conversationId 会话ID
|
||||
* @return 消息记录列表
|
||||
*/
|
||||
List<CaseAiMessageVo> getConversationMessages(String conversationId);
|
||||
|
||||
/**
|
||||
* 导出会话记录为Excel
|
||||
* @param startTime 开始时间
|
||||
* @param endTime 结束时间
|
||||
*/
|
||||
void downloadConversationExcel(LocalDateTime startTime, LocalDateTime endTime);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.xboe.module.boecase.service;
|
||||
|
||||
/**
|
||||
* 案例AI权限服务接口
|
||||
*/
|
||||
public interface ICaseAiPermissionService {
|
||||
|
||||
/**
|
||||
* 判断指定用户是否显示"案例专家"功能入口
|
||||
* @param userCode 用户编码
|
||||
* @return 是否显示功能入口
|
||||
*/
|
||||
boolean shouldShowCaseAiEntrance(String userCode);
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.xboe.module.boecase.service;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.module.boecase.dto.CaseDocumentLogQueryDto;
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
import com.xboe.module.boecase.vo.CaseDocumentLogVo;
|
||||
|
||||
/**
|
||||
* AI调用日志Service接口
|
||||
*/
|
||||
public interface ICaseDocumentLogService {
|
||||
|
||||
/**
|
||||
* 分页查询AI调用日志
|
||||
*
|
||||
* @param pageIndex 页码
|
||||
* @param pageSize 每页大小
|
||||
* @param queryDto 查询条件
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageList<CaseDocumentLogVo> pageQuery(int pageIndex, int pageSize, CaseDocumentLogQueryDto queryDto);
|
||||
|
||||
/**
|
||||
* 根据查询条件清空日志
|
||||
* 仅删除当前筛选条件下的日志记录,非筛选范围内的日志不受影响
|
||||
*
|
||||
* @param queryDto 查询条件
|
||||
* @return 删除的记录数
|
||||
*/
|
||||
int clearLogsByCondition(CaseDocumentLogQueryDto queryDto);
|
||||
|
||||
/**
|
||||
* 根据logId重试AI调用
|
||||
* 查询原始日志数据,重试执行后添加新的日志记录
|
||||
*
|
||||
* @param logId 日志ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean retryByLogId(String logId);
|
||||
|
||||
/**
|
||||
* 保存日志记录
|
||||
*
|
||||
* @param log 日志对象
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean save(CaseDocumentLog log);
|
||||
|
||||
}
|
||||
@@ -1,75 +0,0 @@
|
||||
package com.xboe.module.boecase.service;
|
||||
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 案例-知识库
|
||||
*/
|
||||
public interface ICaseKnowledgeService {
|
||||
|
||||
/**
|
||||
* 上传案例文档
|
||||
*
|
||||
* @param caseId 案例ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean uploadCaseDocument(String caseId);
|
||||
|
||||
/**
|
||||
* 上传案例文档
|
||||
*
|
||||
* @param cases 案例
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean uploadCaseDocument(Cases cases);
|
||||
|
||||
/**
|
||||
* 删除案例文档
|
||||
*
|
||||
* @param caseId 案例ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteCaseDocument(String caseId);
|
||||
|
||||
/**
|
||||
* 删除案例文档
|
||||
*
|
||||
* @param cases 案例
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteCaseDocument(Cases cases);
|
||||
|
||||
/**
|
||||
* 更新案例文档
|
||||
*
|
||||
* @param caseId 案例ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean retryCaseDocument(String caseId, CaseDocumentLog originalLog);
|
||||
|
||||
/**
|
||||
* 更新案例文档
|
||||
*
|
||||
* @param cases 案例
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updateCaseDocument(Cases cases);
|
||||
|
||||
/**
|
||||
* 处理文档上传回调
|
||||
*
|
||||
* @param taskId 任务ID
|
||||
* @param message 回调信息
|
||||
* @param fileStatus 文件状态(vectored: 成功, failed: 失败)
|
||||
* @return 是否处理成功
|
||||
*/
|
||||
boolean handleUploadCallback(String taskId, String message, String fileStatus);
|
||||
|
||||
/**
|
||||
* 批量检查文件状态
|
||||
*/
|
||||
@Transactional(rollbackFor = Throwable.class)
|
||||
void batchCheckFileStatus();
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.xboe.module.boecase.service;
|
||||
|
||||
import com.xboe.module.boecase.entity.AiChatConversationData;
|
||||
import com.xboe.module.boecase.vo.CaseAiMessageVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* es索引
|
||||
*/
|
||||
public interface IElasticSearchIndexService {
|
||||
|
||||
/**
|
||||
* 查看索引是否存在
|
||||
* @return
|
||||
*/
|
||||
boolean checkIndexExists();
|
||||
|
||||
/**
|
||||
* 创建索引
|
||||
*/
|
||||
boolean createIndex();
|
||||
|
||||
/**
|
||||
* 删除索引
|
||||
* @return
|
||||
*/
|
||||
boolean deleteIndex();
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
boolean createData(AiChatConversationData data);
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
* @param conversationId
|
||||
* @return
|
||||
*/
|
||||
List<CaseAiMessageVo> queryData(String conversationId);
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
package com.xboe.module.boecase.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.module.boecase.properties.CaseAiProperties;
|
||||
import com.xboe.module.boecase.service.IAiAccessTokenService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.net.URLEncoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@EnableConfigurationProperties({CaseAiProperties.class})
|
||||
@Service
|
||||
@Slf4j
|
||||
public class AiAccessTokenServiceImpl implements IAiAccessTokenService {
|
||||
|
||||
private static final String ACCESS_TOKEN_CACHE_KEY = "case_ai_access_token";
|
||||
|
||||
@Autowired
|
||||
private CaseAiProperties caseAiProperties;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public String getAccessToken() {
|
||||
// 1. 先从Redis缓存中获取
|
||||
String cachedToken = stringRedisTemplate.opsForValue().get(ACCESS_TOKEN_CACHE_KEY);
|
||||
if (StringUtil.isNotBlank(cachedToken)) {
|
||||
return cachedToken;
|
||||
}
|
||||
|
||||
// 2. 缓存中没有,重新获取
|
||||
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||
String tokenUrl = caseAiProperties.getBaseUrl() + "/apigateway/secret/getAppAccessToken" +
|
||||
"?appKey=" + URLEncoder.encode(caseAiProperties.getAppKey(), StandardCharsets.UTF_8.name()) +
|
||||
"&secretKey=" + URLEncoder.encode(caseAiProperties.getSecretKey(), StandardCharsets.UTF_8.name());
|
||||
|
||||
HttpGet httpGet = new HttpGet(tokenUrl);
|
||||
|
||||
try (CloseableHttpResponse response = httpClient.execute(httpGet)) {
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
|
||||
if (statusCode == 200) {
|
||||
JSONObject result = JSON.parseObject(responseBody);
|
||||
if (result.getIntValue("code") == 0 && result.getBooleanValue("success")) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String accessToken = data.getString("accessToken");
|
||||
Integer expiresIn = data.getInteger("expiresIn");
|
||||
if (expiresIn == null) {
|
||||
expiresIn = 7200;
|
||||
}
|
||||
|
||||
// 3. 存储到Redis,设置过期时间(提前5分钟过期)
|
||||
int cacheSeconds = Math.max(expiresIn - 300, 60);
|
||||
stringRedisTemplate.opsForValue().set(ACCESS_TOKEN_CACHE_KEY, accessToken,
|
||||
cacheSeconds, TimeUnit.SECONDS);
|
||||
|
||||
log.info("获取access_token成功,过期时间: {}秒", expiresIn);
|
||||
return accessToken;
|
||||
} else {
|
||||
log.error("获取access_token失败,接口返回失败,response: {}", responseBody);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
log.error("获取access_token失败,HTTP请求失败,status: {}, response: {}",
|
||||
statusCode, responseBody);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取access_token异常", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,729 +0,0 @@
|
||||
package com.xboe.module.boecase.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.enums.CaseAiChatStatusEnum;
|
||||
import com.xboe.module.boecase.dao.CaseAiConversationsDao;
|
||||
import com.xboe.module.boecase.dao.CaseDocumentLogDao;
|
||||
import com.xboe.module.boecase.dao.CasesDao;
|
||||
import com.xboe.module.boecase.dto.CaseAiChatDto;
|
||||
import com.xboe.module.boecase.entity.CaseAiConversations;
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xboe.module.boecase.properties.CaseAiProperties;
|
||||
import com.xboe.module.boecase.service.IAiAccessTokenService;
|
||||
import com.xboe.module.boecase.service.ICaseAiChatService;
|
||||
import com.xboe.module.boecase.service.IElasticSearchIndexService;
|
||||
import com.xboe.module.boecase.vo.CaseAiMessageVo;
|
||||
import com.xboe.module.boecase.vo.CaseReferVo;
|
||||
import com.xboe.module.boecase.entity.AiChatConversationData;
|
||||
import com.xboe.module.boecase.vo.ConversationExcelVo;
|
||||
import com.xboe.system.organization.vo.OrgSimpleVo;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
import lombok.Data;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import okhttp3.*;
|
||||
import okhttp3.sse.EventSource;
|
||||
import okhttp3.sse.EventSourceListener;
|
||||
import okhttp3.sse.EventSources;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.SearchHits;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@EnableConfigurationProperties({CaseAiProperties.class})
|
||||
@Service
|
||||
@Slf4j
|
||||
public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
|
||||
@Autowired
|
||||
private CaseAiProperties caseAiProperties;
|
||||
|
||||
@Autowired
|
||||
@Qualifier("customDispatcher")
|
||||
private Dispatcher dispatcher;
|
||||
|
||||
@Autowired
|
||||
private IAiAccessTokenService aiAccessTokenService;
|
||||
|
||||
@Autowired
|
||||
private IUserService userService;
|
||||
|
||||
@Autowired
|
||||
private CaseAiConversationsDao caseAiConversationsDao;
|
||||
|
||||
@Autowired
|
||||
private IElasticSearchIndexService elasticSearchIndexService;
|
||||
|
||||
@Autowired
|
||||
private CaseDocumentLogDao caseDocumentLogDao;
|
||||
|
||||
@Autowired
|
||||
private CasesDao casesDao;
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public SseEmitter chat(CaseAiChatDto caseAiChatDto, CurrentUser currentUser) {
|
||||
// 创建SSE响应器
|
||||
SseEmitter sseEmitter = new SseEmitter();
|
||||
// 1. 获取conversationId
|
||||
String conversationId;
|
||||
try {
|
||||
conversationId = getOrCreateConversationId(caseAiChatDto, currentUser);
|
||||
} catch (Exception e) {
|
||||
log.error("获取会话ID失败", e);
|
||||
errMessage(sseEmitter, "服务繁忙,请稍后再试。");
|
||||
sseEmitter.complete();
|
||||
return sseEmitter;
|
||||
}
|
||||
|
||||
// 2. 查询历史
|
||||
List<CaseAiMessageVo> historyMessages = elasticSearchIndexService.queryData(conversationId);
|
||||
|
||||
// 3. 构建请求参数
|
||||
String userId = currentUser.getCode();
|
||||
String kId = caseAiProperties.getCaseKnowledgeId();
|
||||
JSONObject chatParam = new JSONObject();
|
||||
chatParam.put("userId", userId);
|
||||
JSONArray kIds = new JSONArray();
|
||||
kIds.add(kId);
|
||||
chatParam.put("kIds", kIds);
|
||||
chatParam.put("query", caseAiChatDto.getQuery());
|
||||
chatParam.put("conversationId", conversationId);
|
||||
chatParam.put("enableThinking", Objects.equals(caseAiChatDto.getEnableThinking(), 1));
|
||||
if (historyMessages != null && !historyMessages.isEmpty()) {
|
||||
// 最多10条历史,从后往前
|
||||
JSONArray historyList = new JSONArray();
|
||||
int size = historyMessages.size();
|
||||
int startIndex = Math.max(0, size - 10);
|
||||
for (int i = startIndex; i < size; i++) {
|
||||
JSONObject conversationDetail = new JSONObject();
|
||||
CaseAiMessageVo message = historyMessages.get(i);
|
||||
conversationDetail.put("query", message.getQuery());
|
||||
conversationDetail.put("content", message.getAnswer());
|
||||
historyList.add(conversationDetail);
|
||||
}
|
||||
chatParam.put("historyList", historyList);
|
||||
}
|
||||
String chatParamStr = chatParam.toJSONString();
|
||||
log.info("案例问答接口请求参数: [{}]", chatParamStr);
|
||||
|
||||
// 4. 设置请求头
|
||||
String accessToken;
|
||||
try {
|
||||
accessToken = aiAccessTokenService.getAccessToken();
|
||||
} catch (Exception e) {
|
||||
log.error("获取access_token失败", e);
|
||||
errMessage(sseEmitter, "服务繁忙,请稍后再试。");
|
||||
sseEmitter.complete();
|
||||
return sseEmitter;
|
||||
}
|
||||
String apiCode = caseAiProperties.getChatApiCode();
|
||||
Request.Builder builder = new Request.Builder();
|
||||
builder.url(caseAiProperties.getBaseUrl() + "/apigateway/chat/knowledge/v1/chat/completions");
|
||||
builder.addHeader("access_token", accessToken);
|
||||
builder.addHeader("X-AI-ApiCode", apiCode);
|
||||
RequestBody bodyRequestBody = RequestBody.create(chatParamStr, MediaType.parse("application/json"));
|
||||
builder.post(bodyRequestBody);
|
||||
Request request = builder.build();
|
||||
|
||||
|
||||
// 6. 用于收集对话数据的容器
|
||||
AiChatConversationData conversationData = new AiChatConversationData();
|
||||
conversationData.setQuery(caseAiChatDto.getQuery());
|
||||
conversationData.setConversationId(conversationId);
|
||||
conversationData.setUserId(userId);
|
||||
|
||||
// 7. 创建事件监听器
|
||||
EventSourceListener listener = new EventSourceListener() {
|
||||
@Override
|
||||
public void onOpen(@NotNull EventSource eventSource, @NotNull Response response) {
|
||||
log.info("调用接口 [{}] 接口开始监听", request.url());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClosed(@NotNull EventSource eventSource) {
|
||||
log.info("调用接口 [{}] 接口关闭", request.url());
|
||||
// 对话完成,保存到ES
|
||||
elasticSearchIndexService.createData(conversationData);
|
||||
sseEmitter.complete();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(@NotNull EventSource eventSource, @Nullable String id, @Nullable String type, @NotNull String data) {
|
||||
log.info("调用接口 [{}] 监听数据 id: [{}] type: [{}] data: [{}]", request.url(), id, type, data);
|
||||
|
||||
try {
|
||||
// 解析返回的数据
|
||||
JSONObject jsonData = JSONObject.parseObject(data);
|
||||
if (jsonData.getBooleanValue("success") && jsonData.getIntValue("code") == 0) {
|
||||
JSONObject responseData = jsonData.getJSONObject("data");
|
||||
Integer status = responseData.getInteger("status");
|
||||
|
||||
if (status != null) {
|
||||
CaseAiChatStatusEnum statusEnum = CaseAiChatStatusEnum.getByCode(status);
|
||||
if (statusEnum == CaseAiChatStatusEnum.REFERS) { // 返回引用文件
|
||||
// 处理文件引用并构建返给前端的数据
|
||||
JSONObject modifiedData = handleFileReferAndBuildResponse(responseData, conversationData);
|
||||
if (modifiedData != null) {
|
||||
// 发送修改后的数据给前端
|
||||
sseEmitter.send(modifiedData.toJSONString());
|
||||
return; // 早期返回,不发送原始数据
|
||||
}
|
||||
} else if (statusEnum == CaseAiChatStatusEnum.CHAT) { // 流式对话中
|
||||
String content = responseData.getString("content");
|
||||
if (content != null) {
|
||||
conversationData.appendAnswer(content);
|
||||
}
|
||||
} else if (statusEnum == CaseAiChatStatusEnum.SUGGESTIONS) { // 返回建议
|
||||
handleSuggestions(responseData, conversationData);
|
||||
} else if (statusEnum == CaseAiChatStatusEnum.CHAT_COMPLETED || statusEnum == CaseAiChatStatusEnum.API_COMPLETED) { // 接口交互完成
|
||||
// 不做特殊处理
|
||||
} else {
|
||||
// 异常问题,取message内容
|
||||
String message = jsonData.getString("message");
|
||||
errMessage(sseEmitter, message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
sseEmitter.send(responseData.toJSONString());
|
||||
} else {
|
||||
sseEmitter.send(data);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("调用接口处理监听数据时发生异常", e);
|
||||
} catch (Exception e) {
|
||||
log.error("解析EventStream数据异常", e);
|
||||
try {
|
||||
sseEmitter.send(data); // 即使解析失败也要发送原始数据
|
||||
} catch (IOException ioException) {
|
||||
log.error("发送数据到前端失败", ioException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(@NotNull EventSource eventSource, @Nullable Throwable e, @Nullable Response response) {
|
||||
log.error("调用接口 [{}] 接口异常", request.url(), e);
|
||||
|
||||
// 如果是 content-type 错误,尝试作为普通 HTTP 请求处理
|
||||
if (e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().contains("Invalid content-type")) {
|
||||
log.warn("服务器返回的 Content-Type 不是 text/event-stream,尝试作为普通 HTTP 请求处理");
|
||||
handleAsRegularHttpRequest(request, sseEmitter, conversationData);
|
||||
return;
|
||||
}
|
||||
|
||||
if (e != null) {
|
||||
sseEmitter.completeWithError(e);
|
||||
} else {
|
||||
sseEmitter.completeWithError(new RuntimeException("调用接口异常, 异常未捕获"));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 8. 执行HTTP请求
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(60, TimeUnit.SECONDS)
|
||||
.writeTimeout(600, TimeUnit.SECONDS)
|
||||
.readTimeout(600, TimeUnit.SECONDS)
|
||||
.callTimeout(600, TimeUnit.SECONDS)
|
||||
.dispatcher(dispatcher)
|
||||
.build();
|
||||
EventSource.Factory factory = EventSources.createFactory(client);
|
||||
factory.newEventSource(request, listener);
|
||||
|
||||
return sseEmitter;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取或创建会话ID
|
||||
*/
|
||||
private String getOrCreateConversationId(CaseAiChatDto caseAiChatDto, CurrentUser currentUser) {
|
||||
String conversationId = caseAiChatDto.getConversationId();
|
||||
|
||||
if (StringUtils.isEmpty(conversationId)) {
|
||||
// 新会话,调用创建会话接口
|
||||
String conversationName = "AI案例咨询-" + LocalDateTime.now().toString();
|
||||
CaseAiConversations newConversation = createNewConversation(currentUser.getCode(), conversationName);
|
||||
return newConversation.getAiConversationId();
|
||||
} else {
|
||||
// 已存在会话,从数据库查询
|
||||
return caseAiConversationsDao.findAiConversationIdById(conversationId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public CaseAiConversations createNewConversation(String userId, String conversationName) {
|
||||
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||
String url = caseAiProperties.getBaseUrl() + "/apigateway/knowledge/v1/conversation";
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
|
||||
// 设置请求头
|
||||
String accessToken = aiAccessTokenService.getAccessToken();
|
||||
String apiCode = caseAiProperties.getChatApiCode();
|
||||
httpPost.setHeader("access_token", accessToken);
|
||||
httpPost.setHeader("X-AI-ApiCode", apiCode);
|
||||
httpPost.setHeader("Content-Type", "application/json");
|
||||
|
||||
// 设置请求体
|
||||
JSONObject requestBody = new JSONObject();
|
||||
requestBody.put("userId", userId);
|
||||
requestBody.put("name", conversationName);
|
||||
StringEntity entity = new StringEntity(requestBody.toJSONString(), StandardCharsets.UTF_8);
|
||||
httpPost.setEntity(entity);
|
||||
|
||||
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
|
||||
|
||||
if (statusCode == 200) {
|
||||
JSONObject result = JSONObject.parseObject(responseBody);
|
||||
if (result.getIntValue("code") == 0 && result.getBooleanValue("success")) {
|
||||
JSONObject data = result.getJSONObject("data");
|
||||
String aiConversationId = data.getString("id");
|
||||
String name = data.getString("name");
|
||||
|
||||
// 保存到数据库
|
||||
CaseAiConversations conversation = new CaseAiConversations();
|
||||
conversation.setAiConversationId(aiConversationId);
|
||||
conversation.setConversationName(name);
|
||||
conversation.setConversationUser(userId);
|
||||
caseAiConversationsDao.save(conversation);
|
||||
|
||||
log.info("创建AI会话成功,aiConversationId: {}, name: {}", aiConversationId, name);
|
||||
return conversation;
|
||||
} else {
|
||||
log.error("创建AI会话失败,接口返回失败,response: {}", responseBody);
|
||||
throw new RuntimeException("创建AI会话失败: " + result.getString("message"));
|
||||
}
|
||||
} else {
|
||||
log.error("创建AI会话失败,HTTP请求失败,status: {}, response: {}", statusCode, responseBody);
|
||||
throw new RuntimeException("创建AI会话失败,HTTP状态码: " + statusCode);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("创建AI会话异常", e);
|
||||
throw new RuntimeException("创建AI会话异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CaseAiMessageVo> getConversationMessages(String conversationId) {
|
||||
if (StringUtils.isEmpty(conversationId)) {
|
||||
log.warn("conversationId 为空, 不查询");
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return elasticSearchIndexService.queryData(conversationId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadConversationExcel(LocalDateTime startTime, LocalDateTime endTime) {
|
||||
// 1. 根据startTime和endTime,查询在这个时间区间内的CaseAiConversations数据
|
||||
List<CaseAiConversations> conversations = caseAiConversationsDao.getGenericDao().findList(
|
||||
CaseAiConversations.class,
|
||||
FieldFilters.ge("sysCreateTime", startTime),
|
||||
FieldFilters.le("sysCreateTime", endTime)
|
||||
);
|
||||
|
||||
// 准备Excel数据
|
||||
List<ConversationExcelVo> excelDataList = new ArrayList<>();
|
||||
|
||||
// 2. 遍历这组数据,根据aiConversationId从es中查询数据(可调用getConversationMessages()方法)
|
||||
for (CaseAiConversations conversation : conversations) {
|
||||
String aiConversationId = conversation.getAiConversationId();
|
||||
String conversationName = conversation.getConversationName();
|
||||
String conversationUser = conversation.getConversationUser();
|
||||
|
||||
List<CaseAiMessageVo> messages = getConversationMessages(aiConversationId);
|
||||
|
||||
// 计算会话时长
|
||||
long duration = 0; // 默认为0,如果需要精确计算,需要从消息中提取时间信息
|
||||
|
||||
// 3. 写入Excel,包括每个会话的用户,会话标题,会话内的问答记录,每次对话时长等
|
||||
ConversationExcelVo excelData = new ConversationExcelVo();
|
||||
excelData.setConversationId(aiConversationId);
|
||||
excelData.setConversationName(conversationName);
|
||||
excelData.setUser(conversationUser);
|
||||
excelData.setMessages(messages);
|
||||
|
||||
excelDataList.add(excelData);
|
||||
}
|
||||
|
||||
// 写入Excel文件
|
||||
Workbook workbook = new XSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet("AI会话数据");
|
||||
// 标题行
|
||||
Row headerRow = sheet.createRow(0);
|
||||
headerRow.createCell(0).setCellValue("会话ID");
|
||||
headerRow.createCell(1).setCellValue("会话名称");
|
||||
headerRow.createCell(2).setCellValue("用户");
|
||||
headerRow.createCell(3).setCellValue("提问");
|
||||
headerRow.createCell(4).setCellValue("回答");
|
||||
headerRow.createCell(5).setCellValue("开始时间");
|
||||
headerRow.createCell(6).setCellValue("问答时长(秒)");
|
||||
|
||||
// 内容行
|
||||
if (!excelDataList.isEmpty()) {
|
||||
int rowNum = 1; // 从第二行开始写入数据
|
||||
for (ConversationExcelVo excelData : excelDataList) {
|
||||
List<CaseAiMessageVo> messages = excelData.getMessages();
|
||||
|
||||
if (messages != null && !messages.isEmpty()) {
|
||||
// 记录起始行号,用于后续合并单元格
|
||||
int startRow = rowNum;
|
||||
|
||||
// 遍历每个消息
|
||||
for (CaseAiMessageVo message : messages) {
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
// 填充每行数据
|
||||
row.createCell(0).setCellValue(excelData.getConversationId());
|
||||
row.createCell(1).setCellValue(excelData.getConversationName());
|
||||
row.createCell(2).setCellValue(excelData.getUser());
|
||||
row.createCell(3).setCellValue(message.getQuery() != null ? message.getQuery() : "");
|
||||
row.createCell(4).setCellValue(message.getAnswer() != null ? message.getAnswer() : "");
|
||||
row.createCell(5).setCellValue(""); // 开始时间字段暂留空
|
||||
row.createCell(6).setCellValue(message.getDurationSeconds() != null ? message.getDurationSeconds() : 0);
|
||||
}
|
||||
|
||||
// 合并单元格(会话ID、会话名称、用户三列)
|
||||
// 参数说明:起始行号,结束行号,起始列号,结束列号
|
||||
if (rowNum > startRow + 1) { // 只有当有多行时才合并
|
||||
sheet.addMergedRegion(new CellRangeAddress(startRow, rowNum - 1, 0, 0));
|
||||
sheet.addMergedRegion(new CellRangeAddress(startRow, rowNum - 1, 1, 1));
|
||||
sheet.addMergedRegion(new CellRangeAddress(startRow, rowNum - 1, 2, 2));
|
||||
}
|
||||
} else {
|
||||
// 如果没有消息,则仍然创建一行显示基本信息
|
||||
Row row = sheet.createRow(rowNum++);
|
||||
row.createCell(0).setCellValue(excelData.getConversationId());
|
||||
row.createCell(1).setCellValue(excelData.getConversationName());
|
||||
row.createCell(2).setCellValue(excelData.getUser());
|
||||
}
|
||||
}
|
||||
}
|
||||
// 3. 创建Excel文件并保存
|
||||
if (caseAiProperties.isAiChatDataSendEmail()) {
|
||||
// TODO 发送邮件附件
|
||||
} else {
|
||||
// 保存文件
|
||||
String dirPath = caseAiProperties.getAiChatRootPath() + File.separator + startTime.format(DateTimeFormatter.ofPattern("yyyyMM"));
|
||||
Path dir = Paths.get(dirPath);
|
||||
if (!Files.exists(dir)) {
|
||||
try {
|
||||
Files.createDirectories(dir);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
String fileName = "AI会话数据-" + startTime.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + "-" + System.currentTimeMillis() + ".xlsx";
|
||||
Path filePath = dir.resolve(fileName);
|
||||
try (OutputStream out = Files.newOutputStream(filePath)) {
|
||||
workbook.write(out);
|
||||
out.flush();
|
||||
} catch (IOException e) {
|
||||
log.error("保存文件错误", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从 ES 数据中解析消息对象
|
||||
* @param sourceMap ES数据
|
||||
* @return 消息对象
|
||||
*/
|
||||
private CaseAiMessageVo parseMessageFromES(Map<String, Object> sourceMap) {
|
||||
try {
|
||||
CaseAiMessageVo messageVo = new CaseAiMessageVo();
|
||||
messageVo.setQuery((String) sourceMap.get("query"));
|
||||
messageVo.setAnswer((String) sourceMap.get("answer"));
|
||||
|
||||
// 解析 suggestions
|
||||
Object suggestionsObj = sourceMap.get("suggestions");
|
||||
if (suggestionsObj instanceof List) {
|
||||
messageVo.setSuggestions((List<String>) suggestionsObj);
|
||||
}
|
||||
|
||||
// 解析 caseRefer
|
||||
Object caseReferObj = sourceMap.get("caseRefer");
|
||||
if (caseReferObj instanceof List) {
|
||||
List<CaseReferVo> caseReferList = new ArrayList<>();
|
||||
List<Map<String, Object>> caseReferMaps = (List<Map<String, Object>>) caseReferObj;
|
||||
|
||||
for (Map<String, Object> caseReferMap : caseReferMaps) {
|
||||
CaseReferVo caseRefer = new CaseReferVo();
|
||||
caseRefer.setCaseId((String) caseReferMap.get("caseId"));
|
||||
caseRefer.setTitle((String) caseReferMap.get("title"));
|
||||
caseRefer.setAuthorName((String) caseReferMap.get("authorName"));
|
||||
caseRefer.setContent((String) caseReferMap.get("content"));
|
||||
|
||||
// 解析 keywords
|
||||
Object keywordsObj = caseReferMap.get("keywords");
|
||||
if (keywordsObj instanceof List) {
|
||||
caseRefer.setKeywords((List<String>) keywordsObj);
|
||||
}
|
||||
|
||||
caseReferList.add(caseRefer);
|
||||
}
|
||||
messageVo.setCaseRefer(caseReferList);
|
||||
}
|
||||
|
||||
return messageVo;
|
||||
} catch (Exception e) {
|
||||
log.error("解析ES消息数据异常", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文件引用并构建返给前端的响应数据
|
||||
*/
|
||||
private JSONObject handleFileReferAndBuildResponse(JSONObject responseData, AiChatConversationData conversationData) {
|
||||
try {
|
||||
// 先处理文件引用,收集CaseReferVo数据
|
||||
List<CaseReferVo> currentCaseRefers = new ArrayList<>();
|
||||
Set<String> docIds = new HashSet<>();
|
||||
|
||||
JSONObject fileRefer = responseData.getJSONObject("fileRefer");
|
||||
if (fileRefer != null && fileRefer.containsKey("files")) {
|
||||
JSONArray files = fileRefer.getJSONArray("files");
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
JSONObject file = files.getJSONObject(i);
|
||||
String docId = file.getString("docId");
|
||||
if (docId != null) {
|
||||
// 根据docId从 case_document_log 表查询案例数据
|
||||
CaseReferVo caseRefer = getCaseReferByDocId(docId);
|
||||
if (caseRefer != null && !docIds.contains(docId)) {
|
||||
docIds.add(docId);
|
||||
currentCaseRefers.add(caseRefer);
|
||||
conversationData.addCaseRefer(caseRefer); // 也添加到总的收集器中
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 构建返给前端的数据结构
|
||||
JSONObject data = new JSONObject();
|
||||
data.put("status", 0);
|
||||
data.put("conversationId", conversationData.getConversationId());
|
||||
data.put("content", responseData.getString("content"));
|
||||
|
||||
// 添加处理后的案例引用数据
|
||||
JSONArray caseReferArray = new JSONArray();
|
||||
for (CaseReferVo caseRefer : currentCaseRefers) {
|
||||
JSONObject caseReferObj = new JSONObject();
|
||||
caseReferObj.put("caseId", caseRefer.getCaseId());
|
||||
caseReferObj.put("title", caseRefer.getTitle());
|
||||
caseReferObj.put("authorName", caseRefer.getAuthorName());
|
||||
caseReferObj.put("keywords", caseRefer.getKeywords());
|
||||
caseReferObj.put("content", caseRefer.getContent());
|
||||
// 使用指定的时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
caseReferObj.put("uploadTime", caseRefer.getUploadTime() != null ? caseRefer.getUploadTime().format(formatter) : null);
|
||||
|
||||
caseReferArray.add(caseReferObj);
|
||||
}
|
||||
|
||||
// 构建新的fileRefer结构,包含案例引用
|
||||
JSONObject newFileRefer = new JSONObject();
|
||||
newFileRefer.put("caseRefers", caseReferArray);
|
||||
|
||||
// 保留原始的docs和files信息(如果需要)
|
||||
if (fileRefer != null) {
|
||||
if (fileRefer.containsKey("docs")) {
|
||||
newFileRefer.put("docs", fileRefer.get("docs"));
|
||||
}
|
||||
if (fileRefer.containsKey("files")) {
|
||||
newFileRefer.put("files", fileRefer.get("files"));
|
||||
}
|
||||
}
|
||||
|
||||
data.put("fileRefer", newFileRefer);
|
||||
data.put("suggestions", responseData.get("suggestions"));
|
||||
|
||||
log.info("处理文件引用成功,返回 {} 个案例引用", currentCaseRefers.size());
|
||||
return data;
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("处理文件引用并构建响应数据异常", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文件引用(原方法,保留用于数据收集)
|
||||
*/
|
||||
private void handleFileRefer(JSONObject responseData, AiChatConversationData conversationData) {
|
||||
try {
|
||||
JSONObject fileRefer = responseData.getJSONObject("fileRefer");
|
||||
if (fileRefer != null && fileRefer.containsKey("files")) {
|
||||
JSONArray files = fileRefer.getJSONArray("files");
|
||||
for (int i = 0; i < files.size(); i++) {
|
||||
JSONObject file = files.getJSONObject(i);
|
||||
String docId = file.getString("docId");
|
||||
if (docId != null) {
|
||||
// 根据docId从 case_document_log 表查询案例数据
|
||||
CaseReferVo caseRefer = getCaseReferByDocId(docId);
|
||||
if (caseRefer != null) {
|
||||
conversationData.addCaseRefer(caseRefer);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("处理文件引用异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理建议
|
||||
*/
|
||||
private void handleSuggestions(JSONObject responseData, AiChatConversationData conversationData) {
|
||||
try {
|
||||
JSONArray suggestions = responseData.getJSONArray("suggestions");
|
||||
if (suggestions != null) {
|
||||
for (int i = 0; i < suggestions.size(); i++) {
|
||||
String suggestion = suggestions.getString(i);
|
||||
if (suggestion != null) {
|
||||
conversationData.addSuggestion(suggestion);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("处理建议异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据docId查询案例引用信息
|
||||
*/
|
||||
private CaseReferVo getCaseReferByDocId(String docId) {
|
||||
try {
|
||||
// 从 case_document_log 表查询案例信息(docId对应task_id)
|
||||
CaseDocumentLog docLog = caseDocumentLogDao.findByTaskId(docId);
|
||||
if (docLog == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 根据 case_id 查询案例详情
|
||||
Cases caseEntity = casesDao.get(docLog.getCaseId());
|
||||
if (caseEntity == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
String authorUserId = caseEntity.getAuthorId();
|
||||
OrgSimpleVo authorOrg = userService.findOrgByUserId(authorUserId);
|
||||
// 构建 CaseReferVo
|
||||
CaseReferVo caseRefer = new CaseReferVo();
|
||||
caseRefer.setCaseId(caseEntity.getId());
|
||||
caseRefer.setTitle(caseEntity.getTitle());
|
||||
caseRefer.setAuthorName(caseEntity.getAuthorName());
|
||||
caseRefer.setContent(caseEntity.getSummary());
|
||||
caseRefer.setUploadTime(caseEntity.getSysCreateTime());
|
||||
caseRefer.setOrgInfo(authorOrg.getName());
|
||||
|
||||
// 构建关键词列表
|
||||
List<String> keywords = new ArrayList<>();
|
||||
if (caseEntity.getKeyword1() != null) keywords.add(caseEntity.getKeyword1());
|
||||
if (caseEntity.getKeyword2() != null) keywords.add(caseEntity.getKeyword2());
|
||||
if (caseEntity.getKeyword3() != null) keywords.add(caseEntity.getKeyword3());
|
||||
if (caseEntity.getKeyword4() != null) keywords.add(caseEntity.getKeyword4());
|
||||
if (caseEntity.getKeyword5() != null) keywords.add(caseEntity.getKeyword5());
|
||||
caseRefer.setKeywords(keywords);
|
||||
|
||||
return caseRefer;
|
||||
} catch (Exception e) {
|
||||
log.error("根据docId查询案例引用信息异常", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 当 SSE 失败时,作为普通 HTTP 请求处理
|
||||
*/
|
||||
private void handleAsRegularHttpRequest(Request request, SseEmitter sseEmitter, AiChatConversationData conversationData) {
|
||||
try {
|
||||
OkHttpClient client = new OkHttpClient.Builder()
|
||||
.connectTimeout(60, TimeUnit.SECONDS)
|
||||
.writeTimeout(60, TimeUnit.SECONDS)
|
||||
.readTimeout(60, TimeUnit.SECONDS)
|
||||
.build();
|
||||
|
||||
Response response = client.newCall(request).execute();
|
||||
if (response.isSuccessful()) {
|
||||
String responseBody = response.body().string();
|
||||
log.info("作为普通 HTTP 请求处理成功,将响应原封不动推送给前端");
|
||||
|
||||
// 将响应内容原封不动地推送到 SseEmitter
|
||||
JSONObject responseData = JSONObject.parseObject(responseBody);
|
||||
if (responseBody.contains("message")) {
|
||||
errMessage(sseEmitter, responseData.getString("message"));
|
||||
sseEmitter.complete();
|
||||
return;
|
||||
}
|
||||
sseEmitter.send(responseBody);
|
||||
sseEmitter.complete();
|
||||
} else {
|
||||
log.error("普通 HTTP 请求失败,状态码: {}", response.code());
|
||||
sseEmitter.completeWithError(new RuntimeException("HTTP 请求失败,状态码: " + response.code()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("处理普通 HTTP 请求异常", e);
|
||||
sseEmitter.completeWithError(e);
|
||||
}
|
||||
}
|
||||
|
||||
private void errMessage(SseEmitter sseEmitter, String message) {
|
||||
JSONObject jsonData = new JSONObject();
|
||||
jsonData.put("status", 1);
|
||||
jsonData.put("content", message);
|
||||
try {
|
||||
sseEmitter.send(jsonData.toJSONString());
|
||||
} catch (IOException e) {
|
||||
log.error("发送错误信息异常", e);
|
||||
sseEmitter.completeWithError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
package com.xboe.module.boecase.service.impl;
|
||||
|
||||
import com.xboe.module.boecase.properties.CaseAiProperties;
|
||||
import com.xboe.module.boecase.service.ICaseAiPermissionService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 案例AI权限服务实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class CaseAiPermissionServiceImpl implements ICaseAiPermissionService {
|
||||
|
||||
@Autowired
|
||||
private CaseAiProperties caseAiProperties;
|
||||
|
||||
/**
|
||||
* 判断指定用户是否显示"案例专家"功能入口
|
||||
* @param userCode 用户编码
|
||||
* @return 是否显示功能入口
|
||||
*/
|
||||
@Override
|
||||
public boolean shouldShowCaseAiEntrance(String userCode) {
|
||||
log.info("判断用户[{}]是否显示案例专家功能入口", userCode);
|
||||
|
||||
// 如果不启用白名单,直接返回true
|
||||
if (!caseAiProperties.isUseWhiteList()) {
|
||||
log.info("未启用白名单,所有用户都显示功能入口");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 启用白名单时,判断当前用户是否在白名单中
|
||||
List<String> whiteUserCodeList = caseAiProperties.getWhiteUserCodeList();
|
||||
log.info("白名单列表:{}", whiteUserCodeList);
|
||||
boolean isInWhiteList = whiteUserCodeList != null
|
||||
&& whiteUserCodeList.stream().anyMatch(userCode::equals);
|
||||
|
||||
log.info("用户[{}]{}在白名单中", userCode, isInWhiteList ? "" : "不");
|
||||
return isInWhiteList;
|
||||
}
|
||||
}
|
||||
@@ -1,307 +0,0 @@
|
||||
package com.xboe.module.boecase.service.impl;
|
||||
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.LikeMatchMode;
|
||||
import com.xboe.enums.CaseDocumentLogRunStatusEnum;
|
||||
import com.xboe.module.boecase.dao.CaseDocumentLogDao;
|
||||
import com.xboe.module.boecase.dto.CaseDocumentLogQueryDto;
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
import com.xboe.module.boecase.service.ICaseDocumentLogService;
|
||||
import com.xboe.module.boecase.service.ICaseKnowledgeService;
|
||||
import com.xboe.module.boecase.vo.CaseDocumentLogVo;
|
||||
import com.xboe.enums.CaseDocumentLogOptTypeEnum;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* AI调用日志Service实现类
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class CaseDocumentLogServiceImpl implements ICaseDocumentLogService {
|
||||
|
||||
@Resource
|
||||
private CaseDocumentLogDao caseDocumentLogDao;
|
||||
|
||||
@Resource
|
||||
private ICaseKnowledgeService caseKnowledgeService;
|
||||
|
||||
@Resource(name = "aiDocExecutor")
|
||||
private ThreadPoolTaskExecutor aiDocExecutor;
|
||||
|
||||
@Override
|
||||
public PageList<CaseDocumentLogVo> pageQuery(int pageIndex, int pageSize, CaseDocumentLogQueryDto queryDto) {
|
||||
// 构建查询条件
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
|
||||
// 运行状态过滤
|
||||
filters.add(FieldFilters.eq("runStatus", CaseDocumentLogRunStatusEnum.COMPLETED.getCode()));
|
||||
|
||||
// 案例标题模糊查询
|
||||
if (StringUtil.isNotBlank(queryDto.getCaseTitle())) {
|
||||
filters.add(FieldFilters.like("caseTitle", LikeMatchMode.ANYWHERE, queryDto.getCaseTitle()));
|
||||
}
|
||||
|
||||
// 操作类型精确查询
|
||||
if (StringUtil.isNotBlank(queryDto.getOptType())) {
|
||||
filters.add(FieldFilters.eq("optType", queryDto.getOptType()));
|
||||
}
|
||||
|
||||
// 调用时间区间查询
|
||||
if (queryDto.getOptTimeStart() != null) {
|
||||
filters.add(FieldFilters.ge("optTime", queryDto.getOptTimeStart()));
|
||||
}
|
||||
if (queryDto.getOptTimeEnd() != null) {
|
||||
// 将结束时间调整为当天的23:59:59
|
||||
LocalDateTime optTimeEnd = queryDto.getOptTimeEnd().withHour(23).withMinute(59).withSecond(59);
|
||||
filters.add(FieldFilters.le("optTime", optTimeEnd));
|
||||
}
|
||||
|
||||
// 接口调用状态
|
||||
if (queryDto.getOptStatus() != null) {
|
||||
filters.add(FieldFilters.eq("optStatus", queryDto.getOptStatus()));
|
||||
}
|
||||
|
||||
// 业务处理状态
|
||||
if (queryDto.getCaseStatus() != null) {
|
||||
filters.add(FieldFilters.eq("caseStatus", queryDto.getCaseStatus()));
|
||||
}
|
||||
|
||||
// 删除标识过滤
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
|
||||
// 按创建时间降序排序
|
||||
OrderCondition order = OrderCondition.desc("sysCreateTime");
|
||||
|
||||
// 执行分页查询
|
||||
PageList<CaseDocumentLog> pageResult = caseDocumentLogDao.getGenericDao()
|
||||
.findPage(pageIndex, pageSize, CaseDocumentLog.class, filters, order);
|
||||
|
||||
// 转换为VO对象
|
||||
List<CaseDocumentLogVo> voList = pageResult.getList().stream()
|
||||
.map(this::convertToVo)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 构建返回结果
|
||||
PageList<CaseDocumentLogVo> result = new PageList<>();
|
||||
result.setList(voList);
|
||||
result.setCount(pageResult.getCount());
|
||||
result.setPageSize(pageResult.getPageSize());
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int clearLogsByCondition(CaseDocumentLogQueryDto queryDto) {
|
||||
// 构建查询条件(与分页查询相同的逻辑)
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
|
||||
// 运行状态过滤
|
||||
filters.add(FieldFilters.eq("runStatus", CaseDocumentLogRunStatusEnum.COMPLETED.getCode()));
|
||||
|
||||
// 案例标题模糊查询
|
||||
if (StringUtil.isNotBlank(queryDto.getCaseTitle())) {
|
||||
filters.add(FieldFilters.like("caseTitle", LikeMatchMode.ANYWHERE, queryDto.getCaseTitle()));
|
||||
}
|
||||
|
||||
// 操作类型精确查询
|
||||
if (StringUtil.isNotBlank(queryDto.getOptType())) {
|
||||
filters.add(FieldFilters.eq("optType", queryDto.getOptType()));
|
||||
}
|
||||
|
||||
// 调用时间区间查询
|
||||
if (queryDto.getOptTimeStart() != null) {
|
||||
filters.add(FieldFilters.ge("optTime", queryDto.getOptTimeStart()));
|
||||
}
|
||||
if (queryDto.getOptTimeEnd() != null) {
|
||||
// 将结束时间调整为当天的23:59:59
|
||||
LocalDateTime optTimeEnd = queryDto.getOptTimeEnd().withHour(23).withMinute(59).withSecond(59);
|
||||
filters.add(FieldFilters.le("optTime", optTimeEnd));
|
||||
}
|
||||
|
||||
// 接口调用状态
|
||||
if (queryDto.getOptStatus() != null) {
|
||||
filters.add(FieldFilters.eq("optStatus", queryDto.getOptStatus()));
|
||||
}
|
||||
|
||||
// 业务处理状态
|
||||
if (queryDto.getCaseStatus() != null) {
|
||||
filters.add(FieldFilters.eq("caseStatus", queryDto.getCaseStatus()));
|
||||
}
|
||||
|
||||
// 删除标识过滤
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
|
||||
// 查询符合条件的所有记录
|
||||
IFieldFilter[] filtersArray = filters.toArray(new IFieldFilter[0]);
|
||||
List<CaseDocumentLog> logsToDelete = caseDocumentLogDao.getGenericDao()
|
||||
.findList(CaseDocumentLog.class, filtersArray);
|
||||
|
||||
if (logsToDelete.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// 批量设置删除标识为true(逻辑删除)
|
||||
int deletedCount = 0;
|
||||
for (CaseDocumentLog log : logsToDelete) {
|
||||
log.setDeleted(true);
|
||||
caseDocumentLogDao.update(log);
|
||||
deletedCount++;
|
||||
}
|
||||
|
||||
log.info("清空日志操作完成,共删除{}条记录", deletedCount);
|
||||
return deletedCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retryByLogId(String logId) {
|
||||
if (StringUtil.isBlank(logId)) {
|
||||
log.error("重试失败,logId不能为空");
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1. 根据logId查询原始日志数据
|
||||
CaseDocumentLog originalLog = caseDocumentLogDao.get(logId);
|
||||
if (originalLog == null || originalLog.getDeleted()) {
|
||||
log.error("重试失败,未找到有效的日志记录,logId: {}", logId);
|
||||
return false;
|
||||
}
|
||||
|
||||
log.info("开始异步重试AI调用,原始日志ID: {}, 案例标题: {}, 操作类型: {}",
|
||||
logId, originalLog.getCaseTitle(), originalLog.getOptType());
|
||||
|
||||
// 2. 使用线程池异步执行AI调用重试逻辑
|
||||
String optType = originalLog.getOptType();
|
||||
String caseId = originalLog.getCaseId();
|
||||
|
||||
aiDocExecutor.execute(() -> executeRetryLogic(optType, caseId, originalLog));
|
||||
|
||||
// 立即返回true表示重试请求已接受,具体结果通过日志异步处理
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 执行AI调用重试逻辑
|
||||
* @param optType 操作类型
|
||||
* @param caseId 案例ID
|
||||
*/
|
||||
private void executeRetryLogic(String optType, String caseId, CaseDocumentLog originalLog) {
|
||||
boolean retrySuccess = false;
|
||||
|
||||
try {
|
||||
if (StringUtil.isBlank(caseId)) {
|
||||
throw new IllegalArgumentException("案例ID不能为空");
|
||||
}
|
||||
|
||||
log.info("[异步任务] 正在执行AI调用重试,操作类型: {}, caseId: {}", optType, caseId);
|
||||
|
||||
// 根据操作类型执行对应的方法(这些方法内部会自动创建日志记录)
|
||||
if (CaseDocumentLogOptTypeEnum.CREATE.getCode().equals(optType)) {
|
||||
// 上传案例文档
|
||||
retrySuccess = caseKnowledgeService.uploadCaseDocument(caseId);
|
||||
log.info("[异步任务] 执行上传案例文档重试,caseId: {}, 结果: {}", caseId, retrySuccess);
|
||||
|
||||
} else if (CaseDocumentLogOptTypeEnum.DELETE.getCode().equals(optType)) {
|
||||
// 删除案例文档
|
||||
retrySuccess = caseKnowledgeService.deleteCaseDocument(caseId);
|
||||
log.info("[异步任务] 执行删除案例文档重试,caseId: {}, 结果: {}", caseId, retrySuccess);
|
||||
|
||||
} else if (CaseDocumentLogOptTypeEnum.UPDATE.getCode().equals(optType)) {
|
||||
// 更新案例文档
|
||||
retrySuccess = caseKnowledgeService.retryCaseDocument(caseId, originalLog);
|
||||
log.info("[异步任务] 执行更新案例文档重试,caseId: {}, 结果: {}", caseId, retrySuccess);
|
||||
|
||||
} else {
|
||||
throw new IllegalArgumentException("不支持的操作类型: " + optType);
|
||||
}
|
||||
|
||||
if (retrySuccess) {
|
||||
log.info("[异步任务] AI调用重试成功,操作类型: {}, caseId: {}", optType, caseId);
|
||||
} else {
|
||||
log.warn("[异步任务] AI调用重试失败,操作类型: {}, caseId: {}", optType, caseId);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("[异步任务] AI调用重试异常,操作类型: {}, caseId: {}",
|
||||
optType, caseId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean save(CaseDocumentLog caseDocumentLog) {
|
||||
try {
|
||||
caseDocumentLogDao.save(caseDocumentLog);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("保存CaseDocumentLog失败", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 实体转换为VO
|
||||
*/
|
||||
private CaseDocumentLogVo convertToVo(CaseDocumentLog entity) {
|
||||
CaseDocumentLogVo vo = new CaseDocumentLogVo();
|
||||
BeanUtils.copyProperties(entity, vo);
|
||||
|
||||
// 操作类型转换为中文描述
|
||||
vo.setOptType(CaseDocumentLogOptTypeEnum.getDescByCode(entity.getOptType()));
|
||||
|
||||
// 接口调用状态转换
|
||||
vo.setOptStatusText(getOptStatusText(entity.getOptStatus()));
|
||||
|
||||
// 业务处理状态转换
|
||||
vo.setCaseStatusText(getCaseStatusText(entity.getCaseStatus()));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取接口调用状态描述
|
||||
*/
|
||||
private String getOptStatusText(Integer optStatus) {
|
||||
if (optStatus == null) {
|
||||
return "";
|
||||
}
|
||||
switch (optStatus) {
|
||||
case 1:
|
||||
return "调用成功";
|
||||
case 2:
|
||||
return "调用失败";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取业务处理状态描述
|
||||
*/
|
||||
private String getCaseStatusText(Integer caseStatus) {
|
||||
if (caseStatus == null) {
|
||||
return "";
|
||||
}
|
||||
switch (caseStatus) {
|
||||
case 1:
|
||||
return "处理成功";
|
||||
case 2:
|
||||
return "处理失败";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -19,9 +19,7 @@ import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.enums.CaseDocumentLogOptTypeEnum;
|
||||
import com.xboe.enums.CasesRankEnum;
|
||||
import com.xboe.module.boecase.async.CaseAiDocumentAsyncHandler;
|
||||
import com.xboe.module.boecase.dao.*;
|
||||
import com.xboe.module.boecase.dto.*;
|
||||
import com.xboe.module.boecase.entity.*;
|
||||
@@ -92,9 +90,6 @@ public class CasesServiceImpl implements ICasesService {
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
|
||||
@Autowired
|
||||
private CaseAiDocumentAsyncHandler caseAiDocumentAsyncHandler;
|
||||
|
||||
/**
|
||||
* 案例分页查询,用于门户的查询
|
||||
*/
|
||||
@@ -804,11 +799,7 @@ public class CasesServiceImpl implements ICasesService {
|
||||
*/
|
||||
@Override
|
||||
public void delete(String id) {
|
||||
Cases cases = casesDao.get(id);
|
||||
// 原删除
|
||||
casesDao.setDeleted(id);
|
||||
// 增加逻辑
|
||||
caseAiDocumentAsyncHandler.process(CaseDocumentLogOptTypeEnum.DELETE, cases);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -995,8 +986,6 @@ public class CasesServiceImpl implements ICasesService {
|
||||
cases.setMajorIds(majorIds);
|
||||
cases.setMajorType(stringBuffer.toString());
|
||||
casesDao.save(cases);
|
||||
// 增加逻辑
|
||||
caseAiDocumentAsyncHandler.process(CaseDocumentLogOptTypeEnum.CREATE, cases);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1020,8 +1009,6 @@ public class CasesServiceImpl implements ICasesService {
|
||||
cases.setMajorIds(majorIds);
|
||||
cases.setMajorType(stringBuffer.toString());
|
||||
casesDao.update(cases);
|
||||
// 增加逻辑
|
||||
caseAiDocumentAsyncHandler.process(CaseDocumentLogOptTypeEnum.UPDATE, cases);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,336 +0,0 @@
|
||||
package com.xboe.module.boecase.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.xboe.constants.CaseAiConstants;
|
||||
import com.xboe.module.boecase.entity.AiChatConversationData;
|
||||
import com.xboe.module.boecase.service.IElasticSearchIndexService;
|
||||
import com.xboe.module.boecase.vo.CaseAiMessageVo;
|
||||
import com.xboe.module.boecase.vo.CaseReferVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.elasticsearch.action.admin.indices.delete.DeleteIndexRequest;
|
||||
import org.elasticsearch.action.index.IndexRequest;
|
||||
import org.elasticsearch.action.index.IndexResponse;
|
||||
import org.elasticsearch.action.search.SearchRequest;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.support.master.AcknowledgedResponse;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.client.indices.CreateIndexRequest;
|
||||
import org.elasticsearch.client.indices.CreateIndexResponse;
|
||||
import org.elasticsearch.client.indices.GetIndexRequest;
|
||||
import org.elasticsearch.common.settings.Settings;
|
||||
import org.elasticsearch.common.xcontent.XContentType;
|
||||
import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.search.SearchHit;
|
||||
import org.elasticsearch.search.SearchHits;
|
||||
import org.elasticsearch.search.builder.SearchSourceBuilder;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService {
|
||||
|
||||
@Autowired(required = false)
|
||||
private RestHighLevelClient elasticsearchClient;
|
||||
|
||||
@Override
|
||||
public boolean checkIndexExists() {
|
||||
if (elasticsearchClient == null) {
|
||||
log.error("ElasticSearch客户端未配置");
|
||||
return false;
|
||||
}
|
||||
// 检查索引是否存在
|
||||
GetIndexRequest getIndexRequest = new GetIndexRequest(CaseAiConstants.CASE_AI_INDEX_NAME);
|
||||
try {
|
||||
return elasticsearchClient.indices().exists(getIndexRequest, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
log.error("查询ElasticSearch索引时发生异常", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createIndex() {
|
||||
if (elasticsearchClient == null) {
|
||||
log.error("ElasticSearch客户端未配置");
|
||||
return false;
|
||||
}
|
||||
// 创建索引
|
||||
CreateIndexRequest createIndexRequest = new CreateIndexRequest(CaseAiConstants.CASE_AI_INDEX_NAME);
|
||||
|
||||
// 设置索引配置
|
||||
createIndexRequest.settings(Settings.builder()
|
||||
.put("index.number_of_shards", 1)
|
||||
.put("index.number_of_replicas", 0)
|
||||
.put("index.analysis.analyzer.ik_max_word.tokenizer", "ik_max_word")
|
||||
.put("index.analysis.analyzer.ik_smart.tokenizer", "ik_smart")
|
||||
);
|
||||
|
||||
// 设置字段映射
|
||||
String mapping = getAiChatMessagesMapping();
|
||||
createIndexRequest.mapping(mapping, XContentType.JSON);
|
||||
|
||||
// 执行创建索引请求
|
||||
CreateIndexResponse createIndexResponse = null;
|
||||
try {
|
||||
createIndexResponse = elasticsearchClient.indices()
|
||||
.create(createIndexRequest, RequestOptions.DEFAULT);
|
||||
} catch (IOException e) {
|
||||
log.error("创建ElasticSearch索引时发生异常", e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (createIndexResponse.isAcknowledged()) {
|
||||
log.info("ElasticSearch索引 [{}] 创建成功", CaseAiConstants.CASE_AI_INDEX_NAME);
|
||||
return true;
|
||||
} else {
|
||||
log.error("ElasticSearch索引 [{}] 创建可能失败,响应未确认", CaseAiConstants.CASE_AI_INDEX_NAME);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteIndex() {
|
||||
if (elasticsearchClient == null) {
|
||||
log.error("ElasticSearch客户端未配置");
|
||||
return false;
|
||||
}
|
||||
// 执行删除索引请求
|
||||
DeleteIndexRequest deleteRequest = new DeleteIndexRequest(CaseAiConstants.CASE_AI_INDEX_NAME);
|
||||
try {
|
||||
AcknowledgedResponse deleteResponse = elasticsearchClient.indices().delete(deleteRequest, RequestOptions.DEFAULT);
|
||||
if (deleteResponse.isAcknowledged()) {
|
||||
log.info("成功删除Elasticsearch索引: {}", CaseAiConstants.CASE_AI_INDEX_NAME);
|
||||
return true;
|
||||
} else {
|
||||
log.error("删除索引 [{}] 未被确认(可能部分节点未响应)", CaseAiConstants.CASE_AI_INDEX_NAME);
|
||||
return false;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("删除ElasticSearch索引时发生异常", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createData(AiChatConversationData conversationData) {
|
||||
if (elasticsearchClient == null) {
|
||||
log.error("未配置Elasticsearch客户端,无法保存对话记录");
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
// 构建要保存的数据
|
||||
JSONObject esData = new JSONObject();
|
||||
esData.put("query", conversationData.getQuery());
|
||||
esData.put("answer", conversationData.getAnswerAsString());
|
||||
esData.put("conversationId", conversationData.getConversationId());
|
||||
esData.put("userId", conversationData.getUserId());
|
||||
// 持续时间
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
esData.put("startTime", conversationData.getStartTime().toString());
|
||||
esData.put("timestamp", now.toString());
|
||||
esData.put("durationSeconds", Duration.between(conversationData.getStartTime(), now).getSeconds());
|
||||
|
||||
// 构建 caseRefer 数据
|
||||
JSONArray caseReferArray = new JSONArray();
|
||||
for (CaseReferVo caseRefer : conversationData.getCaseRefers()) {
|
||||
JSONObject caseReferObj = new JSONObject();
|
||||
caseReferObj.put("caseId", caseRefer.getCaseId());
|
||||
caseReferObj.put("title", caseRefer.getTitle());
|
||||
caseReferObj.put("authorName", caseRefer.getAuthorName());
|
||||
caseReferObj.put("keywords", caseRefer.getKeywords());
|
||||
caseReferObj.put("content", caseRefer.getContent());
|
||||
caseReferArray.add(caseReferObj);
|
||||
}
|
||||
esData.put("caseRefer", caseReferArray);
|
||||
|
||||
// 添加建议
|
||||
esData.put("suggestions", conversationData.getSuggestions());
|
||||
|
||||
// 保存到ES
|
||||
IndexRequest indexRequest = new IndexRequest("ai_chat_messages");
|
||||
String dataStr = esData.toJSONString();
|
||||
log.info("保存对话记录到ES:{}", dataStr);
|
||||
indexRequest.source(dataStr, XContentType.JSON);
|
||||
|
||||
IndexResponse indexResponse = elasticsearchClient.index(indexRequest, RequestOptions.DEFAULT);
|
||||
log.info("保存对话记录到ES成功,文档ID: {}", indexResponse.getId());
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("保存对话记录到ES异常", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CaseAiMessageVo> queryData(String conversationId) {
|
||||
List<CaseAiMessageVo> list = new ArrayList<>();
|
||||
if (elasticsearchClient == null) {
|
||||
log.error("未配置Elasticsearch客户端,无法查询对话记录");
|
||||
return list;
|
||||
}
|
||||
try {
|
||||
// 从 ES 中查询消息记录
|
||||
SearchRequest searchRequest = new SearchRequest(CaseAiConstants.CASE_AI_INDEX_NAME); // ES索引名,可以根据实际情况调整
|
||||
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
|
||||
searchSourceBuilder.query(QueryBuilders.termQuery("conversationId", conversationId));
|
||||
searchSourceBuilder.size(1000); // 设置最大返回数量
|
||||
searchRequest.source(searchSourceBuilder);
|
||||
|
||||
SearchResponse searchResponse = elasticsearchClient.search(searchRequest, RequestOptions.DEFAULT);
|
||||
SearchHits hits = searchResponse.getHits();
|
||||
|
||||
for (SearchHit hit : hits) {
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
CaseAiMessageVo data = parseMessageFromES(sourceMap);
|
||||
if (data != null) {
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("从 ES 中查询到 {} 条消息记录", list.size());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("从 ES 查询会话消息记录异常", e);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
private CaseAiMessageVo parseMessageFromES(Map<String, Object> sourceMap) {
|
||||
try {
|
||||
CaseAiMessageVo messageVo = new CaseAiMessageVo();
|
||||
messageVo.setQuery((String) sourceMap.get("query"));
|
||||
messageVo.setAnswer((String) sourceMap.get("answer"));
|
||||
if (sourceMap.containsKey("startTime")) {
|
||||
String startTimeStr = (String) sourceMap.get("startTime");
|
||||
messageVo.setStartTime(LocalDateTime.parse(startTimeStr));
|
||||
}
|
||||
if (sourceMap.containsKey("durationSeconds")) {
|
||||
messageVo.setDurationSeconds((Long) sourceMap.get("durationSeconds"));
|
||||
}
|
||||
|
||||
// 解析 suggestions
|
||||
if (sourceMap.containsKey("suggestions")) {
|
||||
Object suggestionsObj = sourceMap.get("suggestions");
|
||||
if (suggestionsObj instanceof List) {
|
||||
messageVo.setSuggestions((List<String>) suggestionsObj);
|
||||
}
|
||||
}
|
||||
|
||||
// 解析 caseRefer
|
||||
if (sourceMap.containsKey("caseRefer")) {
|
||||
Object caseReferObj = sourceMap.get("caseRefer");
|
||||
if (caseReferObj instanceof List) {
|
||||
List<CaseReferVo> caseReferList = new ArrayList<>();
|
||||
List<Map<String, Object>> caseReferMaps = (List<Map<String, Object>>) caseReferObj;
|
||||
|
||||
for (Map<String, Object> caseReferMap : caseReferMaps) {
|
||||
CaseReferVo caseRefer = new CaseReferVo();
|
||||
caseRefer.setCaseId((String) caseReferMap.get("caseId"));
|
||||
caseRefer.setTitle((String) caseReferMap.get("title"));
|
||||
caseRefer.setAuthorName((String) caseReferMap.get("authorName"));
|
||||
caseRefer.setContent((String) caseReferMap.get("content"));
|
||||
|
||||
// 解析 keywords
|
||||
Object keywordsObj = caseReferMap.get("keywords");
|
||||
if (keywordsObj instanceof List) {
|
||||
caseRefer.setKeywords((List<String>) keywordsObj);
|
||||
}
|
||||
|
||||
caseReferList.add(caseRefer);
|
||||
}
|
||||
messageVo.setCaseRefer(caseReferList);
|
||||
}
|
||||
}
|
||||
|
||||
return messageVo;
|
||||
} catch (Exception e) {
|
||||
log.error("解析ES消息数据异常", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ai_chat_messages索引的字段映射配置
|
||||
* 根据项目中的会话消息数据结构规范定义映射
|
||||
*
|
||||
* @return JSON格式的映射配置
|
||||
*/
|
||||
private String getAiChatMessagesMapping() {
|
||||
return "{\n" +
|
||||
" \"properties\": {\n" +
|
||||
" \"conversationId\": {\n" +
|
||||
" \"type\": \"keyword\",\n" +
|
||||
" \"index\": true\n" +
|
||||
" },\n" +
|
||||
" \"query\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"analyzer\": \"ik_max_word\",\n" +
|
||||
" \"search_analyzer\": \"ik_smart\",\n" +
|
||||
" \"fields\": {\n" +
|
||||
" \"keyword\": {\n" +
|
||||
" \"type\": \"keyword\",\n" +
|
||||
" \"ignore_above\": 256\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"answer\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"analyzer\": \"ik_max_word\",\n" +
|
||||
" \"search_analyzer\": \"ik_smart\"\n" +
|
||||
" },\n" +
|
||||
" \"caseRefer\": {\n" +
|
||||
" \"type\": \"nested\",\n" +
|
||||
" \"properties\": {\n" +
|
||||
" \"caseId\": {\n" +
|
||||
" \"type\": \"keyword\",\n" +
|
||||
" \"index\": true\n" +
|
||||
" },\n" +
|
||||
" \"title\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"analyzer\": \"ik_max_word\",\n" +
|
||||
" \"search_analyzer\": \"ik_smart\"\n" +
|
||||
" },\n" +
|
||||
" \"authorName\": {\n" +
|
||||
" \"type\": \"keyword\",\n" +
|
||||
" \"index\": true\n" +
|
||||
" },\n" +
|
||||
" \"keywords\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"analyzer\": \"ik_max_word\",\n" +
|
||||
" \"search_analyzer\": \"ik_smart\"\n" +
|
||||
" },\n" +
|
||||
" \"content\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"analyzer\": \"ik_max_word\",\n" +
|
||||
" \"search_analyzer\": \"ik_smart\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
" },\n" +
|
||||
" \"suggestions\": {\n" +
|
||||
" \"type\": \"text\",\n" +
|
||||
" \"analyzer\": \"ik_max_word\",\n" +
|
||||
" \"search_analyzer\": \"ik_smart\"\n" +
|
||||
" },\n" +
|
||||
" \"userId\": {\n" +
|
||||
" \"type\": \"keyword\",\n" +
|
||||
" \"index\": true\n" +
|
||||
" },\n" +
|
||||
" \"timestamp\": {\n" +
|
||||
" \"type\": \"date\",\n" +
|
||||
" \"format\": \"yyyy-MM-dd HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss||yyyy-MM-dd'T'HH:mm:ss.SSS||yyyy-MM-dd'T'HH:mm:ss.SSS'Z'||epoch_millis\"\n" +
|
||||
" }\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.xboe.module.boecase.task;
|
||||
|
||||
import com.xboe.module.boecase.service.ICaseAiChatService;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.YearMonth;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CaseAiChatDataTask {
|
||||
|
||||
@Autowired
|
||||
private ICaseAiChatService caseAiChatService;
|
||||
|
||||
|
||||
/**
|
||||
* 查询上月聊天数据并下载
|
||||
* cron: 0/10 * * * * ?
|
||||
*/
|
||||
@XxlJob("chatDataExcelDownloadJob")
|
||||
public void chatDataExcelDownload(String param) {
|
||||
LocalDateTime startTime;
|
||||
LocalDateTime endTime;
|
||||
|
||||
if (param != null && !param.isEmpty()) {
|
||||
// 解析参数,格式应为 "startTime,endTime",例如 "2023-01-01T00:00:00,2023-01-31T23:59:59"
|
||||
String[] times = param.split(",");
|
||||
if (times.length == 2) {
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss");
|
||||
try {
|
||||
startTime = LocalDateTime.parse(times[0], formatter);
|
||||
endTime = LocalDateTime.parse(times[1], formatter);
|
||||
log.info("使用参数指定的时间范围: {} 到 {}", startTime, endTime);
|
||||
} catch (Exception e) {
|
||||
log.error("解析时间参数失败,使用默认时间范围", e);
|
||||
// 使用默认逻辑
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
YearMonth lastMonth = YearMonth.from(now).minusMonths(1);
|
||||
startTime = now.minusMonths(1)
|
||||
.withDayOfMonth(1)
|
||||
.withHour(0)
|
||||
.withMinute(0)
|
||||
.withSecond(0);
|
||||
endTime = lastMonth.atEndOfMonth().atTime(23, 59, 59);
|
||||
}
|
||||
} else {
|
||||
// 使用默认逻辑
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
YearMonth lastMonth = YearMonth.from(now).minusMonths(1);
|
||||
startTime = now.minusMonths(1)
|
||||
.withDayOfMonth(1)
|
||||
.withHour(0)
|
||||
.withMinute(0)
|
||||
.withSecond(0);
|
||||
endTime = lastMonth.atEndOfMonth().atTime(23, 59, 59);
|
||||
}
|
||||
} else {
|
||||
// 使用默认逻辑
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
YearMonth lastMonth = YearMonth.from(now).minusMonths(1);
|
||||
startTime = now.minusMonths(1)
|
||||
.withDayOfMonth(1)
|
||||
.withHour(0)
|
||||
.withMinute(0)
|
||||
.withSecond(0);
|
||||
endTime = lastMonth.atEndOfMonth().atTime(23, 59, 59);
|
||||
}
|
||||
|
||||
// 执行
|
||||
caseAiChatService.downloadConversationExcel(startTime, endTime);
|
||||
}
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.xboe.module.boecase.task;
|
||||
|
||||
import com.xboe.module.boecase.service.ICaseKnowledgeService;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CaseDocumentLogTask {
|
||||
|
||||
@Autowired
|
||||
private ICaseKnowledgeService caseKnowledgeService;
|
||||
|
||||
/**
|
||||
* 批量查询文件状态并修改
|
||||
* 目前每次查看10条数据,批处理拟每10秒一次,每分钟可运行6次,60条数据
|
||||
* cron: 0/10 * * * * ?
|
||||
*/
|
||||
@XxlJob("batchCheckFileStatusJob")
|
||||
public void batchCheckFileStatusJob() {
|
||||
// log.info("开始批量查询文件状态");
|
||||
caseKnowledgeService.batchCheckFileStatus();
|
||||
// log.info("结束批量查询文件状态");
|
||||
}
|
||||
}
|
||||
@@ -1,140 +0,0 @@
|
||||
package com.xboe.module.boecase.task;
|
||||
|
||||
import com.xboe.constants.CaseAiConstants;
|
||||
import com.xboe.enums.CaseDocumentLogCaseStatusEnum;
|
||||
import com.xboe.enums.CaseDocumentLogOptStatusEnum;
|
||||
import com.xboe.enums.CaseDocumentLogOptTypeEnum;
|
||||
import com.xboe.enums.CaseDocumentLogRunStatusEnum;
|
||||
import com.xboe.module.boecase.async.CaseAiDocumentAsyncHandler;
|
||||
import com.xboe.module.boecase.dao.CaseDocumentLogDao;
|
||||
import com.xboe.module.boecase.dao.CasesDao;
|
||||
import com.xboe.module.boecase.entity.CaseDocumentLog;
|
||||
import com.xboe.module.boecase.entity.Cases;
|
||||
import com.xxl.job.core.handler.annotation.XxlJob;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 旧案例上传
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CaseUploadTask {
|
||||
|
||||
@Resource
|
||||
private CasesDao casesDao;
|
||||
|
||||
@Resource
|
||||
private CaseDocumentLogDao caseDocumentLogDao;
|
||||
|
||||
@Autowired
|
||||
private CaseAiDocumentAsyncHandler caseAiDocumentAsyncHandler;
|
||||
|
||||
@Autowired
|
||||
private StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
private static final String CASE_UPLOAD_LAST_ID_KEY = "case:upload:last:id";
|
||||
|
||||
@XxlJob("oldDataUploadJob")
|
||||
public void oldDataUploadJob() {
|
||||
try {
|
||||
// log.info("开始执行旧案例上传任务");
|
||||
|
||||
// 从Redis获取上次处理的最后一条记录ID
|
||||
String lastProcessedId = stringRedisTemplate.opsForValue().get(CASE_UPLOAD_LAST_ID_KEY);
|
||||
// log.info("上次处理的最后一条记录ID: {}", lastProcessedId);
|
||||
|
||||
// 查询符合条件的案例数据
|
||||
List<Cases> casesToProcess = findCasesToProcess(lastProcessedId);
|
||||
// log.info("查询到待处理案例数量: {}", casesToProcess.size());
|
||||
|
||||
if (casesToProcess.isEmpty()) {
|
||||
// log.info("没有需要处理的案例数据");
|
||||
return;
|
||||
}
|
||||
|
||||
// 批量检查这些案例是否已在CaseDocumentLog中存在记录,提升性能
|
||||
List<String> caseIds = new ArrayList<>();
|
||||
for (Cases cases : casesToProcess) {
|
||||
caseIds.add(cases.getId());
|
||||
}
|
||||
|
||||
// 一次性查询所有相关案例的记录
|
||||
List<CaseDocumentLog> existingLogs = caseDocumentLogDao.getGenericDao()
|
||||
.findList(CaseDocumentLog.class,
|
||||
com.xboe.core.orm.FieldFilters.in("caseId", caseIds));
|
||||
|
||||
// 过滤出未在CaseDocumentLog中存在的案例
|
||||
List<Cases> casesList = new ArrayList<>();
|
||||
for (Cases cases : casesToProcess) {
|
||||
boolean exists = false;
|
||||
for (CaseDocumentLog log : existingLogs) {
|
||||
if (cases.getId().equals(log.getCaseId())
|
||||
&& StringUtils.equals(log.getRequestUrl(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME)
|
||||
&& Objects.equals(log.getRunStatus(), CaseDocumentLogRunStatusEnum.COMPLETED.getCode())
|
||||
&& Objects.equals(log.getOptStatus(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode())
|
||||
&& Objects.equals(log.getRunStatus(), CaseDocumentLogCaseStatusEnum.SUCCESS.getCode())) {
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!exists) {
|
||||
casesList.add(cases);
|
||||
}
|
||||
}
|
||||
|
||||
// log.info("过滤后需要处理的案例数量: {}", casesList.size());
|
||||
|
||||
if (!casesList.isEmpty()) {
|
||||
// 调用异步处理方法
|
||||
caseAiDocumentAsyncHandler.process(CaseDocumentLogOptTypeEnum.CREATE, casesList.toArray(new Cases[0]));
|
||||
|
||||
// 将当前处理的最后一条数据ID存入Redis
|
||||
String currentLastId = casesList.get(casesList.size() - 1).getId();
|
||||
stringRedisTemplate.opsForValue().set(CASE_UPLOAD_LAST_ID_KEY, currentLastId);
|
||||
log.info("已处理案例,最后一条记录ID已更新为: {}", currentLastId);
|
||||
} else {
|
||||
log.info("没有新的案例需要处理");
|
||||
}
|
||||
|
||||
// log.info("旧案例上传任务执行完成");
|
||||
} catch (Exception e) {
|
||||
log.error("执行旧案例上传任务时发生异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询需要处理的案例数据
|
||||
*
|
||||
* @param lastProcessedId 上次处理的最后一条记录ID
|
||||
* @return 案例列表
|
||||
*/
|
||||
private List<Cases> findCasesToProcess(String lastProcessedId) {
|
||||
com.xboe.core.orm.QueryBuilder queryBuilder = com.xboe.core.orm.QueryBuilder.from(Cases.class);
|
||||
queryBuilder.addFilter(com.xboe.core.orm.FieldFilters.eq("deleted", false));
|
||||
// 只处理有文件路径的案例
|
||||
queryBuilder.addFilter(com.xboe.core.orm.FieldFilters.isNotNull("filePath"));
|
||||
queryBuilder.addFilter(com.xboe.core.orm.FieldFilters.ne("filePath", ""));
|
||||
|
||||
// 如果有上次处理的ID,则从该ID之后开始查询
|
||||
if (lastProcessedId != null && !lastProcessedId.isEmpty()) {
|
||||
queryBuilder.addFilter(com.xboe.core.orm.FieldFilters.gt("id", lastProcessedId));
|
||||
}
|
||||
|
||||
// 按创建时间升序排序
|
||||
queryBuilder.addOrder(com.xboe.common.OrderCondition.asc("id"));
|
||||
// 限制每次处理的数量,避免一次性处理太多数据
|
||||
queryBuilder.setPageSize(100);
|
||||
|
||||
return casesDao.findList(queryBuilder.builder());
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* AI会话记录
|
||||
*/
|
||||
@Data
|
||||
public class CaseAiConversationVo {
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AI会话消息记录VO
|
||||
*/
|
||||
@Data
|
||||
public class CaseAiMessageVo {
|
||||
|
||||
/**
|
||||
* 用户提问内容
|
||||
*/
|
||||
private String query;
|
||||
|
||||
/**
|
||||
* AI回答内容
|
||||
*/
|
||||
private String answer;
|
||||
|
||||
/**
|
||||
* 会话开始时间
|
||||
*/
|
||||
private LocalDateTime startTime;
|
||||
|
||||
/**
|
||||
* 会话时长(秒)
|
||||
*/
|
||||
private Long durationSeconds;
|
||||
|
||||
/**
|
||||
* 案例引用列表
|
||||
*/
|
||||
private List<CaseReferVo> caseRefer;
|
||||
|
||||
/**
|
||||
* 建议列表
|
||||
*/
|
||||
private List<String> suggestions;
|
||||
}
|
||||
@@ -1,76 +0,0 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* AI调用日志列表展示VO
|
||||
*/
|
||||
@Data
|
||||
public class CaseDocumentLogVo {
|
||||
|
||||
/**
|
||||
* 日志ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 案例标题
|
||||
*/
|
||||
private String caseTitle;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private String optType;
|
||||
|
||||
/**
|
||||
* 调用接口名称
|
||||
*/
|
||||
private String requestUrl;
|
||||
|
||||
/**
|
||||
* 调用时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime optTime;
|
||||
|
||||
/**
|
||||
* 请求参数
|
||||
*/
|
||||
private String requestBody;
|
||||
|
||||
/**
|
||||
* 响应参数
|
||||
*/
|
||||
private String responseBody;
|
||||
|
||||
/**
|
||||
* 接口调用结果
|
||||
* 0-调用中, 1-调用成功, 2-调用失败
|
||||
*/
|
||||
private Integer optStatus;
|
||||
|
||||
/**
|
||||
* 接口调用结果描述
|
||||
*/
|
||||
private String optStatusText;
|
||||
|
||||
/**
|
||||
* 业务处理结果
|
||||
* 1-处理成功, 2-处理失败
|
||||
*/
|
||||
private Integer caseStatus;
|
||||
|
||||
/**
|
||||
* 业务处理结果描述
|
||||
*/
|
||||
private String caseStatusText;
|
||||
|
||||
/**
|
||||
* 执行时间(ms)
|
||||
*/
|
||||
private Long executeDuration;
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 案例引用信息VO
|
||||
*/
|
||||
@Data
|
||||
public class CaseReferVo {
|
||||
|
||||
/**
|
||||
* 案例ID
|
||||
*/
|
||||
private String caseId;
|
||||
|
||||
/**
|
||||
* 案例标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 作者姓名
|
||||
*/
|
||||
private String authorName;
|
||||
|
||||
/**
|
||||
* 组织信息
|
||||
*/
|
||||
private String orgInfo;
|
||||
|
||||
/**
|
||||
* 上传时间
|
||||
*/
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private LocalDateTime uploadTime;
|
||||
|
||||
/**
|
||||
* 关键词列表
|
||||
*/
|
||||
private List<String> keywords;
|
||||
|
||||
/**
|
||||
* 案例内容
|
||||
*/
|
||||
private String content;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
package com.xboe.module.boecase.vo;
|
||||
|
||||
import lombok.Data;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会话Excel导出VO
|
||||
*/
|
||||
@Data
|
||||
public class ConversationExcelVo {
|
||||
/**
|
||||
* 会话ID
|
||||
*/
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* 会话名称
|
||||
*/
|
||||
private String conversationName;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*/
|
||||
private String user;
|
||||
|
||||
/**
|
||||
* 问答记录
|
||||
*/
|
||||
private List<CaseAiMessageVo> messages;
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.xboe.module.course.api;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -7,10 +8,22 @@ import java.util.List;
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.module.course.dto.CourseParam;
|
||||
import com.xboe.module.course.service.*;
|
||||
import com.xboe.module.course.dto.*;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -22,13 +35,10 @@ import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.core.log.AutoLog;
|
||||
import com.xboe.module.course.dto.CourseFullDto;
|
||||
import com.xboe.module.course.dto.CourseHRBPAuditDto;
|
||||
import com.xboe.module.course.dto.CourseQueryDto;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseAudit;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.module.course.entity.CourseHRBPAudit;
|
||||
import com.xboe.module.course.service.ICourseAuditService;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseHRBPAuditService;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.standard.enums.BoedxContentType;
|
||||
import com.xboe.standard.enums.BoedxCourseType;
|
||||
|
||||
@@ -57,8 +67,10 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
private ICourseContentService ccontentService;
|
||||
@Resource
|
||||
private ThirdApi thirdApi;
|
||||
@Resource
|
||||
private ICourseTagService tagService;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 教师需要审核的课程
|
||||
@@ -424,21 +436,6 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
dto.getCourse().setEnabled(true);//设置启用状态问题
|
||||
dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态
|
||||
try {
|
||||
log.info("------课程提审-- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId());
|
||||
Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId());
|
||||
if(oldCourse!=null && StringUtils.isNotEmpty(oldCourse.getTags())){
|
||||
String[] tagArray = oldCourse.getTags().split(",");
|
||||
// 检查每个元素是否为纯数字
|
||||
for (String tag : tagArray) {
|
||||
if (!tag.matches("\\d+")) { // 使用正则表达式检查是否为纯数字
|
||||
log.info("-------- 不是纯数字 ------- tag = {} " , tag);
|
||||
oldCourse.setTags(null); // 兼容
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
tagService.updateTags(oldCourse,dto.getCourse(),cuser);
|
||||
log.info("-----课程提审--- 标签相关结束 -------");
|
||||
|
||||
courseService.submitAndPublish(dto,cuser.getAccountId(),cuser.getName());
|
||||
log.info("---------------在线课开始同步到讲师管理 ------- token = " + token);
|
||||
@@ -448,16 +445,79 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
param.setOrgName(dto.getCourse().getOrgName());
|
||||
thirdApi.updateOrSaveCourse(param,token);
|
||||
log.info("---------------在线课同步到讲师管理完毕 -------");
|
||||
//AI视频处理-调用接口
|
||||
this.sendMessageToKJB(dto);
|
||||
log.info("---------------AI视频处理-调用接口完毕 -------");
|
||||
return success(true);
|
||||
} catch (Exception e) {
|
||||
log.error("默认管理员提交直接发布处理失败",e);
|
||||
e.printStackTrace();
|
||||
return error("发布课程失败",e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public void sendMessageToKJB(CourseFullDto dto) throws JsonProcessingException {
|
||||
Course course = dto.getCourse();
|
||||
log.info("---------------AI视频处理-调用接口 -------");
|
||||
log.info("aiSet:"+course.getAiSet()+",aiAbstract:"+course.getAiAbstract()+",aiDraft:"+course.getAiDraft()+",aiTranslate:"+course.getAiTranslate()+",languageCode:"+course.getLanguageCode());
|
||||
List<CourseTeacher> teachers = dto.getTeachers();
|
||||
StringBuilder teacherNames = new StringBuilder();
|
||||
for (CourseTeacher teacher : teachers) {
|
||||
teacherNames.append(teacher.getTeacherName()).append(",");
|
||||
}
|
||||
List<CourseContent> cclist = ccontentService.getByCourseId(course.getId());
|
||||
List<String> languageCode = course.getLanguageCode();
|
||||
String code = String.join(",", languageCode);
|
||||
List<BoeaiCourseDto> courseDtos = new ArrayList<>();
|
||||
BoeaiCourseDto boeaiCourseDto = new BoeaiCourseDto();
|
||||
List<BoeaiVideoResourceDto> videoList = new ArrayList<>();
|
||||
boeaiCourseDto = BoeaiCourseDto.builder()
|
||||
.courseId(course.getId())
|
||||
.title(course.getName())
|
||||
.description(course.getSummary())
|
||||
.instructor(teacherNames.toString())
|
||||
.chapterCount(1) //章节数
|
||||
.languageCode(code) //语言
|
||||
.aiTranslate(course.getAiTranslate())
|
||||
.aiAbstract(course.getAiAbstract())
|
||||
.aiDraft(course.getAiDraft())
|
||||
.aiSet(course.getAiSet())
|
||||
.languageStatus(course.getLanguageStatus())
|
||||
.build() ;
|
||||
for (CourseContent cc : cclist) {
|
||||
//筛选视频资源
|
||||
if(cc.getContentType() == 10 ){
|
||||
JSONObject json = JSONObject.parseObject(cc.getContent());
|
||||
if(json == null || json.getString("url") == null) {
|
||||
continue;
|
||||
}
|
||||
String videoUrl = json.getString("url");
|
||||
String videoUrlPerfix = "https://u-pre.boe.com/upload"; //测试
|
||||
//String videoUrlPerfix = "https://u.boe.com/upload"; //生产
|
||||
String videoType = videoUrl.substring(videoUrl.lastIndexOf(".")+1);
|
||||
videoList.add(BoeaiVideoResourceDto.builder()
|
||||
.courseId(cc.getCourseId())
|
||||
.videoId(cc.getId())
|
||||
.title(cc.getContentName())
|
||||
.originalUrl(videoUrlPerfix+videoUrl)
|
||||
.duration(cc.getDuration())
|
||||
.format(videoType)
|
||||
.build());
|
||||
}
|
||||
}
|
||||
boeaiCourseDto.setBoeaiVideoResourceReqList(videoList);
|
||||
boeaiCourseDto.setVideoCount(videoList.size());
|
||||
|
||||
courseDtos.add(boeaiCourseDto);
|
||||
BoeaiCourseParamsReq paramReq = new BoeaiCourseParamsReq();
|
||||
paramReq.setBoeaiCourseReqList(courseDtos);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
String message = objectMapper.writeValueAsString(paramReq);
|
||||
String url = aicoreUrl +"/aiVideo/saveCourse";
|
||||
HttpUtils.sendMessage(message,url);
|
||||
}
|
||||
|
||||
|
||||
/***
|
||||
* 审核
|
||||
* @param dto
|
||||
@@ -488,5 +548,4 @@ public class CourseAuditApi extends ApiBaseController{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -7,22 +7,23 @@ import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.Opt;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.boe.feign.api.serverall.entity.UserData;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.module.course.entity.CourseTag;
|
||||
import com.xboe.module.course.service.*;
|
||||
import com.xboe.module.course.dto.BoeaiCourseDto;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import com.xboe.school.study.service.IStudyCourseService;
|
||||
import com.xboe.system.organization.service.IOrganizationService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -39,6 +40,11 @@ import com.xboe.module.course.dto.CourseTeacherDto;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseCrowd;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.service.CourseToCourseFullText;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.course.service.ICourseTeacherService;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -63,8 +69,7 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
ICourseFullTextSearch fullTextSearch;
|
||||
@Resource
|
||||
IOrganizationService organizationService;
|
||||
@Autowired
|
||||
ICourseTagService courseTagService;
|
||||
|
||||
@Resource
|
||||
IStudyCourseService IStudyCourseService;
|
||||
|
||||
@@ -77,7 +82,8 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 课程的初始化
|
||||
@@ -313,34 +319,7 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
}
|
||||
|
||||
paras.setDevice(dto.getDevice());
|
||||
String tagIds = dto.getTags();
|
||||
log.info("课程查询 tagIds = " + tagIds);
|
||||
if (tagIds != null && tagIds != ""){
|
||||
paras.setTags(tagIds);
|
||||
}else {
|
||||
String tagName = dto.getKeyword();
|
||||
log.info("课程查询 关键字 = " + tagName);
|
||||
if (StringUtils.isNotEmpty(tagName)){
|
||||
//精准查询
|
||||
// CourseTag courseTag = courseTagService.getTagByName(tagName);
|
||||
// log.info("课程查询 关键字对应标签 = " + courseTag);
|
||||
// if (courseTag != null){
|
||||
// paras.setTags(courseTag.getId());
|
||||
// }
|
||||
// 获取所有标签并进行模糊匹配
|
||||
List<CourseTag> allTags = courseTagService.getAllTags();
|
||||
List<String> matchedTagIds = new ArrayList<>();
|
||||
for (CourseTag tag : allTags) {
|
||||
// 使用模糊匹配(不区分大小写)
|
||||
if (tag.getTagName() != null && tag.getTagName().toLowerCase().contains(tagName.toLowerCase())) {
|
||||
matchedTagIds.add(tag.getId());
|
||||
}
|
||||
}
|
||||
if (!matchedTagIds.isEmpty()) {
|
||||
paras.setTags(String.join(",", matchedTagIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
//后续会根据当前用户的资源归属查询
|
||||
PageList<CourseFullText> coursePageList = fullTextSearch.search(ICourseFullTextSearch.DEFAULT_INDEX_NAME,pager.getStartRow(), pager.getPageSize(),paras);
|
||||
@@ -352,6 +331,8 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
if(c.getSource()==2) {
|
||||
cids.add(c.getId());
|
||||
}
|
||||
log.info("---- KJB 开始获取课程摘要信息 ---");
|
||||
this.getCourseFromKJB(c);
|
||||
}
|
||||
List<Course> clist=null;
|
||||
if(!cids.isEmpty()) {
|
||||
@@ -432,12 +413,6 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
c.setKeywordsList(keywordsList);
|
||||
}
|
||||
}
|
||||
if (StringUtils.isNotBlank(c.getTags()) && c.getTags().matches("[0-9,]+")) {
|
||||
List<CourseTag> tagList = courseTagService.getTagsByIds(c.getTags());
|
||||
List<String> tags = tagList.stream().map(CourseTag::getTagName).collect(Collectors.toList());
|
||||
c.setTagsList(tags);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -449,6 +424,33 @@ public class CourseFullTextApi extends ApiBaseController{
|
||||
|
||||
}
|
||||
|
||||
public void getCourseFromKJB(CourseFullText courseFull){
|
||||
String courseId = courseFull.getId();
|
||||
log.info("------------KJB---获取课程摘要信息---------;courseId = " + courseId);
|
||||
//String url = env.getProperty("kjb.url") + "/api/course/getCourseFromKJB?courseId=" + courseId;
|
||||
String url = aicoreUrl + "/aiVideo/getCourseList";
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray courseIds = new JSONArray();
|
||||
courseIds.add(courseId);
|
||||
jsonObject.put("courseIds", courseIds);
|
||||
String result = HttpUtils.sendMessage(jsonObject.toJSONString(), url);
|
||||
|
||||
//将返回string 转为json对象
|
||||
log.info("---KJB --摘要接口返回结果result: "+result);
|
||||
JSONObject jsonResult = JSONObject.parseObject(result);
|
||||
String data = jsonResult.getString("rows");
|
||||
//json字符串转为实体对象
|
||||
// 直接解析为 List<Course>
|
||||
List<BoeaiCourseDto> boeaiCourseDto = JSON.parseArray(data, BoeaiCourseDto.class);
|
||||
//List<BoeaiCourseDto> aiVideoResourceRsp = Collections.singletonList(JSON.parseObject(data, BoeaiCourseDto.class));
|
||||
if(boeaiCourseDto != null && !boeaiCourseDto.isEmpty()){
|
||||
log.info("KJB摘要信息:"+boeaiCourseDto.get(0).getSummaryContent());
|
||||
courseFull.setAiAbstract(boeaiCourseDto.get(0).getAiAbstract());
|
||||
courseFull.setSummaryContent(boeaiCourseDto.get(0).getSummaryContent());
|
||||
}
|
||||
}
|
||||
|
||||
private void getTeacherStatusByCode(String token, PageList<CourseFullText> coursePageList) {
|
||||
log.info("获取教师信息通过工号 ");
|
||||
List<String> teacherCoeds = new ArrayList<>();
|
||||
|
||||
@@ -12,8 +12,6 @@ import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
|
||||
import com.boe.feign.api.infrastructure.entity.Dict;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.module.course.dto.*;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.service.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -33,6 +31,19 @@ import com.xboe.data.dto.UserOrgIds;
|
||||
import com.xboe.data.outside.IOutSideDataService;
|
||||
import com.xboe.data.service.IDataUserSyncService;
|
||||
import com.xboe.module.assistance.service.IEmailService;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.module.course.entity.CourseCrowd;
|
||||
import com.xboe.module.course.entity.CourseHRBPAudit;
|
||||
import com.xboe.module.course.entity.CourseSection;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.entity.CourseUpdateLog;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseCrowdService;
|
||||
import com.xboe.module.course.service.ICourseHRBPAuditService;
|
||||
import com.xboe.module.course.service.ICourseSectionService;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.course.service.ICourseTeacherService;
|
||||
import com.xboe.module.excel.ExportsExcelSenderUtil;
|
||||
import com.xboe.standard.enums.BoedxContentType;
|
||||
import com.xboe.standard.enums.BoedxCourseType;
|
||||
@@ -83,8 +94,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
|
||||
@Resource
|
||||
private ICourseHRBPAuditService hrbpAuditService;
|
||||
@Resource
|
||||
private ICourseTagService tagService;
|
||||
|
||||
@Resource
|
||||
IOutSideDataService outSideDataService;
|
||||
|
||||
@@ -174,12 +184,6 @@ public class CourseManageApi extends ApiBaseController{
|
||||
rs.put("dicts",dicts);
|
||||
}
|
||||
log.error("-------是否仅内网查看 = " + isPermission);
|
||||
if (StringUtils.isNotBlank(course.getTags()) && course.getTags().matches("[0-9,]+")){
|
||||
List<CourseTag> tagList = tagService.getTagsByIds(course.getTags());
|
||||
rs.put("tagList", tagList);
|
||||
}
|
||||
|
||||
|
||||
rs.put("course",course);
|
||||
rs.put("contents",cclist);
|
||||
rs.put("sections",sectionlist);
|
||||
@@ -209,7 +213,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
}
|
||||
return success(rs);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 管理员审核列表,教师的审核不在这里,此审核也应该移动CourseAuditApi中去
|
||||
* @param pager
|
||||
@@ -298,7 +302,6 @@ public class CourseManageApi extends ApiBaseController{
|
||||
@PostMapping("/save")
|
||||
@AutoLog(module = "课程",action = "保存课程基本信息",info = "")
|
||||
public JsonResponse<CourseFullDto> saveCourseFull(@RequestBody CourseFullDto dto, HttpServletRequest request){
|
||||
log.info("-------- 保存课程的全部信息 ------- 课程信息 = {} " , dto.getCourse());
|
||||
if(dto.getCourse()==null){
|
||||
return badRequest("无课程信息");
|
||||
}
|
||||
@@ -319,27 +322,6 @@ public class CourseManageApi extends ApiBaseController{
|
||||
|
||||
//填充必要的信息
|
||||
try {
|
||||
log.info("-------- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId());
|
||||
log.info("-------- 标签相关开始 ------- 课程TAG = {} " , dto.getCourse().getTags());
|
||||
CurrentUser userInfo = getCurrent();
|
||||
Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId());
|
||||
log.info("-------- 标签相关 ------- oldtags = {} " , oldCourse.getTags());
|
||||
if(oldCourse!=null && StringUtils.isNotEmpty(oldCourse.getTags())){
|
||||
String[] tagArray = oldCourse.getTags().split(",");
|
||||
// 检查每个元素是否为纯数字
|
||||
for (String tag : tagArray) {
|
||||
if (!tag.matches("\\d+")) { // 使用正则表达式检查是否为纯数字
|
||||
log.info("-------- 不是纯数字 -------oldtags tag = {} " , tag);
|
||||
oldCourse.setTags(null); // 兼容
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("-------- 标签相关 updateTags ------- oldtags = {} " , oldCourse.getTags());
|
||||
log.info("-------- 标签相关 updateTags ------- newtags = {} " , dto.getCourse().getTags());
|
||||
tagService.updateTags(oldCourse,dto.getCourse(),userInfo);
|
||||
log.info("-------- 标签相关结束 ------newtags = {} " , dto.getCourse().getTags());
|
||||
|
||||
if(StringUtils.isBlank(dto.getCourse().getId())) {
|
||||
//只有在第一次添加保存时才会这样
|
||||
fillCourseData(dto.getCourse());
|
||||
@@ -367,6 +349,8 @@ public class CourseManageApi extends ApiBaseController{
|
||||
|
||||
/***
|
||||
* 仅仅是保存
|
||||
* @param dto
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/save-only-course")
|
||||
@AutoLog(module = "课程",action = "保存课程基本信息",info = "")
|
||||
@@ -393,10 +377,6 @@ public class CourseManageApi extends ApiBaseController{
|
||||
//修改后重置,重新提交审核,重新发布
|
||||
courseService.update(course,true);
|
||||
}
|
||||
//查询是否需要标签提示
|
||||
String aid=getCurrent().getAccountId();
|
||||
Boolean isTip = courseService.getCourseTip(aid);
|
||||
course.setIsTip(isTip);
|
||||
return success(course);
|
||||
} catch (Exception e) {
|
||||
log.error("整体保存课程信息错误",e);
|
||||
@@ -747,6 +727,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
|
||||
/**
|
||||
* 审核课程,这个是管理人员的审核。老师审核不在这里处理.
|
||||
* @param id
|
||||
* @param title
|
||||
* @param pass
|
||||
* @param remark
|
||||
@@ -780,6 +761,7 @@ public class CourseManageApi extends ApiBaseController{
|
||||
|
||||
/**
|
||||
* 审核并发布,未完成的处理,
|
||||
* @param id
|
||||
* @param title
|
||||
* @param pass
|
||||
* @param remark
|
||||
@@ -823,6 +805,10 @@ public class CourseManageApi extends ApiBaseController{
|
||||
|
||||
/**
|
||||
* 发布课程信息,已经没有单独的发布了
|
||||
* @param id
|
||||
* @param title
|
||||
* @param pass
|
||||
* @param remark
|
||||
* @return
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -1220,10 +1206,5 @@ public class CourseManageApi extends ApiBaseController{
|
||||
return success(courses);
|
||||
}
|
||||
|
||||
@PostMapping("/saveTip")
|
||||
public JsonResponse<Boolean> saveTip(){
|
||||
String aid=getCurrent().getAccountId();
|
||||
courseService.saveTip(aid);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,10 @@ import com.xboe.module.course.dto.CourseTeacherDto;
|
||||
import com.xboe.module.course.dto.RankingDto;
|
||||
import com.xboe.module.course.dto.TeacherCourseDto;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.service.*;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseSectionService;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.course.service.ICourseTeacherService;
|
||||
import com.xboe.module.course.vo.CourseStudyVo;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.teacher.entity.Teacher;
|
||||
@@ -30,7 +33,6 @@ import com.xboe.system.user.entity.User;
|
||||
import com.xboe.system.user.service.IUserService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -95,8 +97,6 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private ICourseTagService courseTagService;
|
||||
|
||||
/**
|
||||
* 根据多个课程id返回对应的课程的图片.返回结果如下,
|
||||
@@ -261,14 +261,7 @@ public class CoursePortalApi extends ApiBaseController{
|
||||
if(course==null || course.getDeleted()){
|
||||
return badRequest("课程不存在或已被删除");
|
||||
}
|
||||
Course course1 = new Course();
|
||||
BeanUtils.copyProperties(course,course1);
|
||||
if (StringUtils.isNotBlank(course.getTags()) && course.getTags().matches("[0-9,]+")) {
|
||||
List<CourseTag> tagList = courseTagService.getTagsByIds(course.getTags());
|
||||
String tags = tagList.stream().map(CourseTag::getTagName).collect(Collectors.joining(","));
|
||||
course1.setTags(tags);
|
||||
}
|
||||
rs.put("course",course1);
|
||||
rs.put("course",course);
|
||||
|
||||
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(id);
|
||||
if(crowd!=null && crowd) {
|
||||
|
||||
@@ -1,192 +0,0 @@
|
||||
package com.xboe.module.course.api;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.common.Pagination;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.module.article.entity.Article;
|
||||
import com.xboe.module.article.service.IArticleService;
|
||||
import com.xboe.module.course.dto.CourseTagQueryDto;
|
||||
import com.xboe.module.course.dto.CourseTagRelationDto;
|
||||
import com.xboe.module.course.entity.CourseTag;
|
||||
import com.xboe.module.course.entity.CourseTagRelation;
|
||||
import com.xboe.module.course.service.ICourseTagService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTagApi
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2614:27
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping(value="/xboe/m/coursetag")
|
||||
public class CourseTagApi extends ApiBaseController {
|
||||
|
||||
@Resource
|
||||
ICourseTagService courseTagService;
|
||||
|
||||
/**
|
||||
* 标签列表:分页查询
|
||||
* @param pager
|
||||
* @param courseTagQueryDto
|
||||
* @return
|
||||
*/
|
||||
/* @RequestMapping(value="/page",method= {RequestMethod.GET,RequestMethod.POST})
|
||||
public JsonResponse<PageList<CourseTag>> find(Pagination pager, CourseTagQueryDto courseTagQueryDto){
|
||||
log.info("标签列表:分页查询 pager = " + pager);
|
||||
log.info("标签列表:分页查询 courseTagQueryDto = " + courseTagQueryDto);
|
||||
List<IFieldFilter> filters=new ArrayList<IFieldFilter>();
|
||||
OrderCondition order = null;
|
||||
if (courseTagQueryDto != null){
|
||||
String tagId = courseTagQueryDto.getId();
|
||||
String tagName = courseTagQueryDto.getTagName();
|
||||
Boolean isHot = courseTagQueryDto.getIsHot();
|
||||
String orderField = courseTagQueryDto.getOrderField();
|
||||
Boolean isAsc = courseTagQueryDto.getOrderAsc();
|
||||
if (StringUtils.isNotBlank(tagId)){
|
||||
filters.add(FieldFilters.eq("id",tagId));
|
||||
}
|
||||
//课程标签名称:模糊查询
|
||||
if (StringUtils.isNotBlank(tagName)){
|
||||
filters.add(FieldFilters.like("tagName",tagName));
|
||||
}
|
||||
// 构建排序条件:支持先按lastSetHotTime降序,再按动态字段升/降序排列
|
||||
if (isHot !=null ){
|
||||
filters.add(FieldFilters.eq("isHot",isHot));
|
||||
//order = OrderCondition.desc("lastSetHotTime");//固定降序
|
||||
}
|
||||
// 动态排序处理
|
||||
if (StringUtils.isNotBlank(orderField)) {
|
||||
if (order == null) {
|
||||
order = isAsc ? OrderCondition.asc(orderField) : OrderCondition.desc(orderField);
|
||||
} else {
|
||||
order = isAsc ? order.asc(orderField) : order.desc(orderField); // 链式追加排序条件
|
||||
}
|
||||
}
|
||||
}
|
||||
log.info("标签列表:分页查询 调用接口 filters = " + filters);
|
||||
log.info("标签列表:分页查询 调用接口 order = " + order);
|
||||
PageList<CourseTag> list=courseTagService.query(pager.getPageIndex(),pager.getPageSize(),filters,order);
|
||||
return success(list);
|
||||
}
|
||||
*/
|
||||
/**
|
||||
* 修改指定id的课程标签的公共属性
|
||||
* @param id
|
||||
* @param isPublic
|
||||
* @return
|
||||
*/
|
||||
/*
|
||||
@RequestMapping(value="/changePublicStatus",method= RequestMethod.POST)
|
||||
public JsonResponse<Void> changePublicStatus(Long id,Boolean isPublic){
|
||||
courseTagService.changePublicStatus(id,isPublic);
|
||||
return success(null);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 修改指定id的课程标签的热点属性
|
||||
* @param id
|
||||
* @param isHot
|
||||
* @return
|
||||
*/
|
||||
/* @RequestMapping(value="/changeHotStatus",method= RequestMethod.POST)
|
||||
public JsonResponse<Void> changeHotStatus(Long id,Boolean isHot){
|
||||
courseTagService.changeHotStatus(id,isHot);
|
||||
return success(null);
|
||||
}*/
|
||||
|
||||
/**
|
||||
* 分页查询:指定id的标签关联的所有课程
|
||||
* @param courseTagQueryDto
|
||||
* @return
|
||||
*/
|
||||
/*
|
||||
@RequestMapping(value="/showCourseByTag",method= RequestMethod.POST)
|
||||
public JsonResponse<PageList<CourseTagRelationDto>> showCourseByTag(Pagination pager, CourseTagQueryDto courseTagQueryDto){
|
||||
PageList<CourseTagRelationDto> list=null;
|
||||
if (courseTagQueryDto != null) {
|
||||
Long tagId = Long.valueOf(courseTagQueryDto.getId());
|
||||
Boolean isAsc = courseTagQueryDto.getOrderAsc()!=null?courseTagQueryDto.getOrderAsc():false;
|
||||
list=courseTagService.getCourseByTag(pager.getPageIndex(),pager.getPageSize(),tagId,isAsc);
|
||||
}
|
||||
return success(list);
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 解除指定id的课程和某个标签之间的关联关系
|
||||
* @return
|
||||
*/
|
||||
/*
|
||||
@RequestMapping(value="/unbind",method= RequestMethod.POST)
|
||||
public JsonResponse<Void> unbindCourseTagRelation(CourseTagRelationDto courseTagRelationDto){
|
||||
if (courseTagRelationDto!=null){
|
||||
courseTagService.unbind(courseTagRelationDto.getId());
|
||||
return success(null);
|
||||
}
|
||||
return error("解绑失败!");
|
||||
}
|
||||
*/
|
||||
|
||||
/**
|
||||
* 模糊检索标签
|
||||
* @return 符合检索条件的所有公共标签
|
||||
*/
|
||||
@RequestMapping(value="/searchTags",method= RequestMethod.POST)
|
||||
public JsonResponse<List<CourseTag>> searchTags(String tagName,String typeId ,HttpServletRequest request){
|
||||
|
||||
CurrentUser cuser = getCurrent();
|
||||
String aid = cuser.getAccountId();
|
||||
List<CourseTag> courseTagList = courseTagService.searchTags(tagName,aid,typeId);
|
||||
return success(courseTagList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新标签,并与当前课程绑定
|
||||
* @param courseTagRelationDto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/createTag",method= RequestMethod.POST)
|
||||
public JsonResponse<CourseTag> createTag(CourseTagRelationDto courseTagRelationDto){
|
||||
if (StringUtils.isNotBlank(courseTagRelationDto.getTagName()) && !Pattern.matches("^[\\u4e00-\\u9fa5a-zA-Z0-9_-]+$", courseTagRelationDto.getTagName())) {
|
||||
return error("标签名称只能包含中文、英文、数字、下划线和中横线");
|
||||
}
|
||||
if (courseTagRelationDto!=null){
|
||||
CourseTag courseTag = courseTagService.createTag(courseTagRelationDto);
|
||||
if (courseTag == null ){
|
||||
return error("创建标签失败!");
|
||||
}
|
||||
return success(courseTag);
|
||||
}
|
||||
return error("创建标签失败!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新标签,并与当前课程绑定
|
||||
* @param courseTagRelationDto
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value="/getHotTagList",method= RequestMethod.POST)
|
||||
public JsonResponse<List<CourseTag>> getHotTagList(CourseTagRelationDto courseTagRelationDto){
|
||||
List<CourseTag> hotTagList = courseTagService.getHotTagList(courseTagRelationDto);
|
||||
return success(hotTagList);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.IQuery;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseFile;
|
||||
import com.xboe.module.course.entity.CourseTag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTagDao
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2516:50
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class CourseTagDao extends BaseDao<CourseTag> {
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
/**
|
||||
* 获取热门标签列表(前10条)
|
||||
* @return 热门标签列表
|
||||
*/
|
||||
public List<CourseTag> getHotTagList() {
|
||||
// 原生SQL:注意表名和列名需与数据库实际一致
|
||||
String sql = "select t.*,COUNT(r.tag_id) AS relation_count\n" +
|
||||
"from boe_course_tag t\n" +
|
||||
"left join boe_course_tag_relation r\n" +
|
||||
"on t.id = r.tag_id AND r.deleted =0 \n" +
|
||||
"where t.deleted =0 and t.is_hot = true and t.status =0 \n" +
|
||||
"GROUP BY t.id\n" +
|
||||
"order by t.last_set_hot_time desc"; // 数据库字段为last_set_hot_time
|
||||
|
||||
// 创建原生查询并指定结果映射到CourseTag实体
|
||||
javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class);
|
||||
|
||||
// 分页:取前10条
|
||||
query.setFirstResult(0);
|
||||
query.setMaxResults(10);
|
||||
|
||||
// 执行查询并返回结果(已映射为CourseTag类型)
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据课程类型获取热门标签列表(前10条)
|
||||
* @param sysType1 系统类型1
|
||||
* @param sysType2 系统类型2
|
||||
* @param sysType3 系统类型3
|
||||
* @return 热门标签列表
|
||||
*/
|
||||
public List<CourseTag> getHotTagListBySysTypes(String sysType1, String sysType2, String sysType3) {
|
||||
// 原生SQL:注意表名和列名需与数据库实际一致(此处假设表名为course_tag、course_type_tag_relation)
|
||||
String sql = "SELECT DISTINCT c.* FROM boe_course_tag c " +
|
||||
"JOIN boe_course_type_tag_relation r ON c.id = r.tag_id " +
|
||||
"WHERE r.deleted = 0 and c.status =0 " +
|
||||
"AND c.is_hot = true "; // 假设数据库字段为is_hot(与实体属性isHot对应)
|
||||
if (StringUtils.isNotBlank(sysType1)){
|
||||
sql += "AND r.sys_type1 = ?1 ORDER BY c.last_set_hot_time DESC";
|
||||
}else if(StringUtils.isNotBlank(sysType2)){
|
||||
sql += "AND r.sys_type2 = ?1 ORDER BY c.last_set_hot_time DESC";
|
||||
}else {
|
||||
sql += "AND r.sys_type3 = ?1 ORDER BY c.last_set_hot_time DESC";
|
||||
}
|
||||
// 创建原生查询并指定结果映射到CourseTag实体
|
||||
javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class);
|
||||
|
||||
// 绑定参数(注意参数索引从1开始)
|
||||
if (StringUtils.isNotBlank(sysType1)){
|
||||
query.setParameter(1, sysType1);
|
||||
} else if (StringUtils.isNotBlank(sysType2)) {
|
||||
query.setParameter(1, sysType2);
|
||||
}else {
|
||||
query.setParameter(1, sysType3);
|
||||
}
|
||||
// 分页:取前10条
|
||||
query.setFirstResult(0);
|
||||
query.setMaxResults(10);
|
||||
|
||||
// 执行查询并返回结果(已映射为CourseTag类型)
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
public List<CourseTag> getTagsByIds(String id) {
|
||||
String sql = "select * from " + SysConstant.TABLE_PRE + "course_tag where id in (" + id + "0)";
|
||||
// 创建原生查询并指定结果映射到CourseTag实体
|
||||
javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class);
|
||||
return query.getResultList();
|
||||
}
|
||||
|
||||
public CourseTag getTagByName(String tagName) {
|
||||
CourseTag courseTag = this.findOne(FieldFilters.eq("tag_name", tagName),FieldFilters.eq("deleted", false),FieldFilters.eq("status", 0));
|
||||
return courseTag;
|
||||
}
|
||||
|
||||
public PageList<CourseTag> getList() {
|
||||
log.info("------- getList ----------- ");
|
||||
String sql = "select * from boe_course_tag order by sys_create_time desc limit 10";
|
||||
javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class);
|
||||
log.info("------- getList -----------getResultList = " + query.getResultList() );
|
||||
PageList<CourseTag> pageList = new PageList<>();
|
||||
pageList.setCount(query.getResultList().size());
|
||||
pageList.setPageSize(1);
|
||||
pageList.setList(query.getResultList());
|
||||
|
||||
return pageList;
|
||||
}
|
||||
|
||||
public List<CourseTag> searchTags(String tagName, String userId, String typeId) {
|
||||
StringBuilder sql = new StringBuilder();
|
||||
List<Object> parameters = new ArrayList<>();
|
||||
|
||||
// 只查询实际存在的字段
|
||||
sql.append("SELECT id, tag_name, is_public, is_hot, use_count, last_set_public_time, last_set_hot_time, deleted, sys_create_time ");
|
||||
sql.append("FROM ( ");
|
||||
sql.append(" SELECT t.id, t.tag_name, t.is_public, t.is_hot, t.use_count, t.last_set_public_time, t.last_set_hot_time, t.deleted, t.sys_create_time ");
|
||||
sql.append(" FROM boe_course_tag_relation r ");
|
||||
sql.append(" INNER JOIN boe_course_tag t ON r.tag_id = t.id ");
|
||||
sql.append(" WHERE r.deleted = 0 AND t.deleted = 0 AND t.is_public = 0 AND t.status = 0 ");
|
||||
if (StringUtils.isNotBlank(userId)) {
|
||||
sql.append(" AND r.sys_create_aid = ? ");
|
||||
parameters.add(Long.valueOf(userId));
|
||||
}
|
||||
if (StringUtils.isNotBlank(tagName)) {
|
||||
sql.append(" AND t.tag_name LIKE ? ");
|
||||
parameters.add("%" + tagName + "%");
|
||||
}
|
||||
sql.append(" GROUP BY t.id, t.tag_name, t.is_public, t.is_hot, t.use_count, t.last_set_public_time, t.last_set_hot_time, t.deleted, t.sys_create_time ");
|
||||
sql.append(" UNION ALL ");
|
||||
sql.append(" SELECT id, tag_name, is_public, is_hot, use_count, last_set_public_time, last_set_hot_time, deleted, sys_create_time ");
|
||||
sql.append(" FROM boe_course_tag ");
|
||||
sql.append(" WHERE deleted = 0 AND is_public = 1 AND status = 0 ");
|
||||
if (StringUtils.isNotBlank(tagName)) {
|
||||
sql.append(" AND tag_name LIKE ? ");
|
||||
parameters.add("%" + tagName + "%");
|
||||
}
|
||||
sql.append(") AS all_tags ");
|
||||
|
||||
if (StringUtils.isNotBlank(typeId)) {
|
||||
sql.append("ORDER BY ");
|
||||
sql.append(" CASE WHEN id IN ( ");
|
||||
sql.append(" SELECT tag_id ");
|
||||
sql.append(" FROM boe_course_type_tag_relation ");
|
||||
sql.append(" WHERE deleted = 0 ");
|
||||
sql.append(" AND (sys_type1 = ? ");
|
||||
sql.append(" OR sys_type2 = ? ");
|
||||
sql.append(" OR sys_type3 = ?) ");
|
||||
sql.append(" GROUP BY tag_id ");
|
||||
sql.append(" ) THEN 0 ELSE 1 END ");
|
||||
parameters.add(Long.valueOf(typeId));
|
||||
parameters.add(Long.valueOf(typeId));
|
||||
parameters.add(Long.valueOf(typeId));
|
||||
}
|
||||
|
||||
// sql.append(" sys_update_time DESC");
|
||||
log.info("查询标签 searchTags sql = {} ", sql);
|
||||
// 不使用实体类映射,手动处理结果集
|
||||
Query query = entityManager.createNativeQuery(sql.toString());
|
||||
|
||||
for (int i = 0; i < parameters.size(); i++) {
|
||||
query.setParameter(i + 1, parameters.get(i));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object[]> results = query.getResultList();
|
||||
List<CourseTag> courseTags = new ArrayList<>();
|
||||
|
||||
for (Object[] result : results) {
|
||||
CourseTag tag = new CourseTag();
|
||||
// 设置基本字段
|
||||
if (result[0] != null) tag.setId(String.valueOf(result[0]));
|
||||
if (result[1] != null) tag.setTagName(String.valueOf(result[1]));
|
||||
if (result[2] != null) tag.setIsPublic(Boolean.valueOf(String.valueOf(result[2])));
|
||||
if (result[3] != null) tag.setIsHot(Boolean.valueOf(String.valueOf(result[3])));
|
||||
if (result[4] != null) tag.setUseCount(Integer.valueOf(String.valueOf(result[4])));
|
||||
courseTags.add(tag);
|
||||
}
|
||||
|
||||
return courseTags;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.dto.CourseTagRelationDto;
|
||||
import com.xboe.module.course.entity.CourseTagRelation;
|
||||
import org.springframework.stereotype.Repository;
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.PersistenceContext;
|
||||
import javax.persistence.Query;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTagRelationDao
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2815:09
|
||||
*/
|
||||
@Repository
|
||||
public class CourseTagRelationDao extends BaseDao<CourseTagRelation> {
|
||||
|
||||
@PersistenceContext
|
||||
private EntityManager entityManager;
|
||||
|
||||
private String sqlStr = "SELECT " +
|
||||
" r1.id as id, " +
|
||||
" c.id as courseId, " +
|
||||
" r1.tag_id as tagId, " +
|
||||
" c.`name` as courseName, " +
|
||||
" r1.sys_create_by as sysCreateBy, " +
|
||||
" r1.sys_create_time as sysCreateTime, " +
|
||||
" COALESCE(GROUP_CONCAT(DISTINCT t.tag_name ORDER BY t.tag_name), '') AS otherTags " +
|
||||
"FROM " +
|
||||
" boe_course c " +
|
||||
"JOIN " +
|
||||
" boe_course_tag_relation r1 ON c.id = r1.course_id " +
|
||||
"LEFT JOIN " +
|
||||
" ( " +
|
||||
" boe_course_tag_relation r2 " +
|
||||
" JOIN boe_course_tag t ON r2.tag_id = t.id AND t.deleted = 0 " +
|
||||
" ) " +
|
||||
" ON c.id = r2.course_id AND r2.tag_id != r1.tag_id " +
|
||||
"WHERE " +
|
||||
" r1.tag_id = :tagId AND r1.deleted = 0 " +
|
||||
" AND c.id IN ( " +
|
||||
" SELECT course_id " +
|
||||
" FROM boe_course_tag_relation " +
|
||||
" WHERE tag_id = :tagId " +
|
||||
" ) " +
|
||||
"GROUP BY " +
|
||||
" c.id, c.`name` ";
|
||||
|
||||
public PageList<CourseTagRelationDto> findCoursesWithRelatedTagsDesc(Integer pageIndex, Integer pageSize, Long tagId){
|
||||
String sql = sqlStr + " ORDER BY r1.sys_create_time DESC";
|
||||
Query query = entityManager.createNativeQuery(sql);
|
||||
query.setParameter("tagId", tagId);
|
||||
query.setFirstResult((pageIndex - 1) * pageSize); // 设置起始位置
|
||||
query.setMaxResults(pageSize); // 设置每页大小
|
||||
|
||||
Query countQuery = entityManager.createNativeQuery(sql);
|
||||
countQuery.setParameter("tagId", tagId);
|
||||
List<Object[]> totalresults = countQuery.getResultList();
|
||||
|
||||
List<Object[]> results = query.getResultList();
|
||||
List<CourseTagRelationDto> list = results.stream()
|
||||
.map(row -> {
|
||||
String id = String.valueOf(row[0]);
|
||||
String courseId = String.valueOf(row[1]);
|
||||
String tagId2 = String.valueOf(row[2]);
|
||||
return new CourseTagRelationDto(
|
||||
id,
|
||||
courseId,
|
||||
tagId2,
|
||||
(String) row[3],
|
||||
(String) row[4],
|
||||
(Date) row[5],
|
||||
(String) row[6]
|
||||
);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return new PageList<CourseTagRelationDto>(list,totalresults!=null?totalresults.size():0);
|
||||
}
|
||||
|
||||
public PageList<CourseTagRelationDto> findCoursesWithRelatedTagsAsc(Integer pageIndex, Integer pageSize, Long tagId) {
|
||||
String sql = sqlStr + " ORDER BY r1.sys_create_time ASC";
|
||||
Query query = entityManager.createNativeQuery(sql);
|
||||
query.setParameter("tagId", tagId);
|
||||
query.setFirstResult((pageIndex - 1) * pageSize); // 设置起始位置
|
||||
query.setMaxResults(pageSize); // 设置每页大小
|
||||
|
||||
Query countQuery = entityManager.createNativeQuery(sql);
|
||||
countQuery.setParameter("tagId", tagId);
|
||||
List<Object[]> totalresults = countQuery.getResultList();
|
||||
|
||||
List<Object[]> results = query.getResultList();
|
||||
List<CourseTagRelationDto> list = results.stream()
|
||||
.map(row ->{
|
||||
String id = String.valueOf(row[0]);
|
||||
String courseId = String.valueOf(row[1]);
|
||||
String tagId2 = String.valueOf(row[2]);
|
||||
return new CourseTagRelationDto(
|
||||
id,
|
||||
courseId,
|
||||
tagId2,
|
||||
(String) row[3],
|
||||
(String) row[4],
|
||||
(Date) row[5],
|
||||
(String) row[6]
|
||||
);
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
return new PageList<CourseTagRelationDto>(list,totalresults!=null?totalresults.size():0);
|
||||
}
|
||||
|
||||
public void reTagRelDelStatus(String id,String name) {
|
||||
String sql = "UPDATE boe_course_tag_relation SET deleted = FALSE, sys_update_by = '" + name +
|
||||
"', sys_update_time = NOW() WHERE id = " + id;
|
||||
Query query = entityManager.createNativeQuery(sql);
|
||||
query.executeUpdate();
|
||||
}
|
||||
|
||||
public void reTypeTagRelDelStatus(String id,String name) {
|
||||
String sql = "UPDATE boe_course_type_tag_relation SET deleted = FALSE, sys_update_by = '" + name +
|
||||
"', sys_update_time = NOW() WHERE id = " + id;
|
||||
Query query = entityManager.createNativeQuery(sql);
|
||||
query.executeUpdate();
|
||||
}
|
||||
}
|
||||
@@ -1,17 +0,0 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.CourseTagRelation;
|
||||
import com.xboe.module.course.entity.CourseTypeTagRelation;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTypeTagRelationDao
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/8/113:42
|
||||
*/
|
||||
@Repository
|
||||
public class CourseTypeTagRelationDao extends BaseDao<CourseTypeTagRelation> {
|
||||
|
||||
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.xboe.module.course.dao;
|
||||
|
||||
import com.xboe.core.orm.BaseDao;
|
||||
import com.xboe.module.course.entity.Tip;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@Repository
|
||||
public class TipDao extends BaseDao<Tip> {
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Huang Run
|
||||
* @date 2025年11月04日
|
||||
*/
|
||||
@Data
|
||||
public class AiVideoResourceRsp {
|
||||
//多语言字幕信息
|
||||
List<BoeaiSubtitleRsp> boeaiSubtitleRspList;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 视频业务ID
|
||||
*/
|
||||
private String videoId;
|
||||
/**
|
||||
* 视频语言编码 如 zh-CN, en-US
|
||||
*/
|
||||
//private String languageCode;
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
private String courseId;
|
||||
|
||||
/**
|
||||
* 视频标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 原始视频URL
|
||||
*/
|
||||
private String originalUrl;
|
||||
|
||||
/**
|
||||
* 视频时长(秒)
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 文件大小(字节)
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 视频格式 mp4/avi等
|
||||
*/
|
||||
private String format;
|
||||
|
||||
/**
|
||||
* 状态 0-待处理 1-处理中 2-已完成 3-失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否已审核 0-否 1-是
|
||||
*/
|
||||
private Integer isReviewed;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
private String reviewerId;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date reviewedAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Transient;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2025年11月18日
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BoeaiCourseDto {
|
||||
List<BoeaiVideoResourceDto> boeaiVideoResourceReqList;
|
||||
|
||||
|
||||
List<String> courseVideoIds;
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
private String courseId;
|
||||
/**
|
||||
* 视频ID
|
||||
*/
|
||||
private String videoId;
|
||||
|
||||
/**
|
||||
* 课程标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 讲师名称
|
||||
*/
|
||||
private String instructor;
|
||||
|
||||
/**
|
||||
* 章节数
|
||||
*/
|
||||
private Integer chapterCount;
|
||||
|
||||
/**
|
||||
* 视频数
|
||||
*/
|
||||
private Integer videoCount;
|
||||
|
||||
/**
|
||||
* 总时长(秒)
|
||||
*/
|
||||
private Integer totalDuration;
|
||||
|
||||
private Date createdAt;
|
||||
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 课程描述
|
||||
*/
|
||||
private String description;
|
||||
/**
|
||||
* 视频语言编码 如 zh-CN, en-US
|
||||
*/
|
||||
private String languageCode;
|
||||
|
||||
/**
|
||||
* 0:关闭;1:打开;
|
||||
* */
|
||||
|
||||
private Integer aiSet;
|
||||
/**
|
||||
* 摘要 0:上架;1:下架;
|
||||
* */
|
||||
|
||||
private Integer aiAbstract;
|
||||
/**
|
||||
* 文稿 0:上架;1:下架;
|
||||
* */
|
||||
|
||||
private Integer aiDraft;
|
||||
/**
|
||||
* 翻译 0:上架;1:下架;
|
||||
* */
|
||||
|
||||
private Integer aiTranslate;
|
||||
|
||||
private Integer languageStatus;
|
||||
//摘要
|
||||
private String summaryContent;
|
||||
//摘要状态 0:下架;1:上架
|
||||
private Integer summaryStatus;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Huang Run
|
||||
* @date 2025年11月19日
|
||||
*/
|
||||
@Data
|
||||
public class BoeaiCourseParamsReq implements Serializable {
|
||||
List<BoeaiCourseDto> boeaiCourseReqList;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* 视频字幕表
|
||||
*/
|
||||
@Data
|
||||
public class BoeaiSubtitleRsp implements Serializable {
|
||||
/**
|
||||
* 主键ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联视频ID
|
||||
*/
|
||||
private String videoId;
|
||||
|
||||
/**
|
||||
* 字幕语言(如 zh-CN, en-US)
|
||||
*/
|
||||
private String language;
|
||||
|
||||
/**
|
||||
* WebVTT字幕文件URL(OSS地址)
|
||||
*/
|
||||
private String subtitleUrl;
|
||||
|
||||
/**
|
||||
* 是否原始字幕 0-翻译 1-原始
|
||||
*/
|
||||
private Byte isOriginal;
|
||||
|
||||
/**
|
||||
* 源语言/翻译来源(如 zh-CN)
|
||||
*/
|
||||
private String sourceLanguage;
|
||||
|
||||
/**
|
||||
* 翻译引擎(llm/google/deepl)
|
||||
*/
|
||||
private String translateEngine;
|
||||
|
||||
/**
|
||||
* 状态(0-待生成 1-生成中 2-已完成 3-失败)
|
||||
*/
|
||||
private Boolean status;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
private Date updatedAt;
|
||||
|
||||
/**
|
||||
* 字幕数据(JSON 数组格式,包含时间戳和翻译文本)
|
||||
*/
|
||||
private String subtitleData;
|
||||
|
||||
/**
|
||||
* WebVTT 格式字幕内容
|
||||
*/
|
||||
private String vttContent;
|
||||
|
||||
/**
|
||||
* 错误信息
|
||||
*/
|
||||
private String errorMsg;
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2025年11月18日
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class BoeaiVideoResourceDto {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 视频业务ID
|
||||
*/
|
||||
private String videoId;
|
||||
/**
|
||||
* 课程ID
|
||||
*/
|
||||
private String courseId;
|
||||
|
||||
/**
|
||||
* 视频标题
|
||||
*/
|
||||
private String title;
|
||||
|
||||
/**
|
||||
* 原始视频URL
|
||||
*/
|
||||
private String originalUrl;
|
||||
|
||||
/**
|
||||
* 视频时长(秒)
|
||||
*/
|
||||
private Integer duration;
|
||||
|
||||
/**
|
||||
* 文件大小(字节)
|
||||
*/
|
||||
private Long fileSize;
|
||||
|
||||
/**
|
||||
* 视频格式 mp4/avi等
|
||||
*/
|
||||
private String format;
|
||||
|
||||
/**
|
||||
* 状态 0-待处理 1-处理中 2-已完成 3-失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 是否已审核 0-否 1-是
|
||||
*/
|
||||
private Integer isReviewed;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
private String reviewerId;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private Date reviewedAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date createdAt;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Date updatedAt;
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import com.xboe.module.course.entity.CourseTag;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
@@ -141,6 +140,4 @@ public class CourseQueryDto {
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
private String tags;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 课程标签查询的条件对象
|
||||
* @ClassName:CourseTagQueryDto
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2517:02
|
||||
*/
|
||||
@Data
|
||||
public class CourseTagQueryDto {
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 标签名称
|
||||
*/
|
||||
private String tagName;
|
||||
|
||||
|
||||
/**
|
||||
* 是否热点标签( 0-否(默认) 1-是)
|
||||
*/
|
||||
private Boolean isHot;
|
||||
|
||||
/**
|
||||
* 排序字段
|
||||
*/
|
||||
private String orderField;
|
||||
|
||||
/**
|
||||
* 排序顺序
|
||||
*/
|
||||
private Boolean orderAsc;
|
||||
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
package com.xboe.module.course.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTagRelationDto
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2815:00
|
||||
*/
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class CourseTagRelationDto{
|
||||
|
||||
private String id;
|
||||
private String courseId;
|
||||
private String tagId;
|
||||
private String tagName;
|
||||
private String courseName;
|
||||
private String sysCreateBy;
|
||||
private Date sysCreateTime;
|
||||
private String otherTags; // 改为字符串类型,与 GROUP_CONCAT 结果匹配
|
||||
private String sysType1;
|
||||
private String sysType2;
|
||||
private String sysType3;
|
||||
|
||||
// 添加匹配查询字段顺序的构造函数
|
||||
public CourseTagRelationDto(
|
||||
String id,
|
||||
String courseId,
|
||||
String tagId,
|
||||
String courseName,
|
||||
String sysCreateBy,
|
||||
Date sysCreateTime,
|
||||
String otherTags
|
||||
) {
|
||||
this.id = id;
|
||||
this.courseId = courseId;
|
||||
this.tagId = tagId;
|
||||
this.courseName = courseName;
|
||||
this.sysCreateBy = sysCreateBy;
|
||||
this.sysCreateTime = sysCreateTime;
|
||||
this.otherTags = otherTags;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
@@ -216,6 +217,47 @@ public class Course extends BaseEntity {
|
||||
@Column(name = "device",length = 1)
|
||||
private Integer device;
|
||||
|
||||
|
||||
/**
|
||||
* 0:关闭;1:打开;
|
||||
* */
|
||||
// @Column(name = "ai_set",length = 1)
|
||||
@Transient
|
||||
private Integer aiSet;
|
||||
/**
|
||||
* 摘要 0:上架;1:下架;
|
||||
* */
|
||||
//@Column(name = "ai_abstract",length = 1)
|
||||
@Transient
|
||||
private Integer aiAbstract;
|
||||
/**
|
||||
* 文稿 0:上架;1:下架;
|
||||
* */
|
||||
// @Column(name = "ai_draft",length = 1)
|
||||
@Transient
|
||||
private Integer aiDraft;
|
||||
/**
|
||||
* 翻译 0:上架;1:下架;
|
||||
* */
|
||||
//@Column(name = "ai_translate",length = 1)
|
||||
@Transient
|
||||
private Integer aiTranslate;
|
||||
@Transient
|
||||
private Integer languageStatus;
|
||||
/**
|
||||
* 语言 zh-CN,en-US,ja-JP,ko-KR
|
||||
* */
|
||||
//Column(name = "language_code",length = 120)
|
||||
@Transient
|
||||
private List<String> languageCode;
|
||||
|
||||
//摘要
|
||||
@Transient
|
||||
private String summaryContent;
|
||||
//摘要状态 0:下架;1:上架
|
||||
@Transient
|
||||
private Integer summaryStatus;
|
||||
|
||||
/**
|
||||
* 课程状态,多人审核机制,所以这里并没有审核通过与不通过的状态了
|
||||
* 课程状态 1:未提交(草稿);2:已提交;3: 审核未通过,5审核完成
|
||||
@@ -399,13 +441,7 @@ public class Course extends BaseEntity {
|
||||
|
||||
@Transient
|
||||
private String teacher;
|
||||
|
||||
/**
|
||||
* 新增在线课时是否需要标签提示
|
||||
*/
|
||||
@Transient
|
||||
private Boolean isTip;
|
||||
|
||||
|
||||
public Course(String id,String name,String summary,String coverImg,String sysCreateAid,String sysCreateBy,Integer type,LocalDateTime publishTime){
|
||||
super.setId(id);
|
||||
this.name=name;
|
||||
|
||||
@@ -8,9 +8,12 @@ import javax.persistence.Transient;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
|
||||
import com.xboe.module.course.dto.BoeaiSubtitleRsp;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 课程内容表
|
||||
* */
|
||||
@@ -93,6 +96,9 @@ public class CourseContent extends BaseEntity {
|
||||
/**用于学习时的状态显示,非存储字段*/
|
||||
@Transient
|
||||
private Integer status;
|
||||
|
||||
@Transient
|
||||
List<BoeaiSubtitleRsp> boeaiSubtitleRspList;
|
||||
|
||||
public CourseContent() {
|
||||
|
||||
|
||||
@@ -1,98 +0,0 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 在线课程的标签类
|
||||
* @ClassName:CourseTag
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/25 16:37
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE+"course_tag")
|
||||
public class CourseTag extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 标签名称
|
||||
*/
|
||||
@Column(name = "tag_name",nullable=false, length = 50)
|
||||
private String tagName;
|
||||
|
||||
/**
|
||||
* 是否设置为公共标签
|
||||
*/
|
||||
@Column(name = "is_public",length = 1)
|
||||
private Boolean isPublic;
|
||||
|
||||
/**
|
||||
* 是否设置为热点标签
|
||||
*/
|
||||
@Column(name = "is_hot",length = 1)
|
||||
private Boolean isHot;
|
||||
|
||||
/**
|
||||
* 使用次数(关联课程数)
|
||||
*/
|
||||
@Column(name = "use_count",length = 1)
|
||||
private Integer useCount;
|
||||
|
||||
/**
|
||||
* 1临时, 0正式
|
||||
*/
|
||||
@Column(name = "status",length = 1)
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 最近设置为公共标签的时间
|
||||
*/
|
||||
@Column(name = "last_set_public_time", nullable = true)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastSetPublicTime;
|
||||
|
||||
/**
|
||||
* 最近设置为热点标签的时间
|
||||
*/
|
||||
@Column(name = "last_set_hot_time", nullable = true)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime lastSetHotTime;
|
||||
|
||||
public CourseTag() {
|
||||
|
||||
}
|
||||
public CourseTag(Long id, Boolean isPublic,Boolean isHot) {
|
||||
this.setId(String.valueOf(id));
|
||||
this.isPublic=isPublic;
|
||||
this.isHot=isHot;
|
||||
}
|
||||
|
||||
|
||||
public CourseTag(String id,String tagName,String sysCreateBy,String sysCreateAid,LocalDateTime sysCreateTime,
|
||||
Boolean isPublic,Boolean isHot,Integer useCount,LocalDateTime lastSetPublicTime,LocalDateTime lastSetHotTime,Boolean deleted){
|
||||
this.setId(id);
|
||||
this.setTagName(tagName);
|
||||
super.setSysCreateBy(sysCreateBy);
|
||||
super.setSysCreateAid(sysCreateAid);
|
||||
super.setSysCreateTime(sysCreateTime);
|
||||
this.isPublic = isPublic;
|
||||
this.isHot = isHot;
|
||||
this.useCount = useCount;
|
||||
this.lastSetPublicTime = lastSetPublicTime;
|
||||
this.lastSetHotTime = lastSetHotTime;
|
||||
super.setDeleted(deleted);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTagRelation
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2814:54
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE+"course_tag_relation")
|
||||
public class CourseTagRelation extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 课程Id
|
||||
*/
|
||||
@Column(name = "course_id",length = 20)
|
||||
private Long courseId;
|
||||
|
||||
/**
|
||||
* 标签id
|
||||
*/
|
||||
@Column(name = "tag_id",length = 20)
|
||||
private Long tagId;
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.xboe.core.SysConstant;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.Column;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTypeTagRelation
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/8/111:02
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Entity
|
||||
@Table(name = SysConstant.TABLE_PRE+"course_type_tag_relation")
|
||||
public class CourseTypeTagRelation extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Column(name = "sys_type1",length = 20)
|
||||
private String sysType1;
|
||||
|
||||
@Column(name = "sys_type2",length = 20)
|
||||
private String sysType2;
|
||||
|
||||
@Column(name = "sys_type3",length = 20)
|
||||
private String sysType3;
|
||||
|
||||
@Column(name = "tag_id",length = 20)
|
||||
private String tagId;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.xboe.module.course.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.xboe.core.SysConstant;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author by lyc
|
||||
* @date 2025/11/10
|
||||
*/
|
||||
@Data
|
||||
@Entity
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Table(name = "tip")
|
||||
public class Tip {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
@Column(name = "id", length = 20)
|
||||
private Long id;
|
||||
|
||||
@Column(name = "aid", length = 30)
|
||||
private String aid;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Column(name = "create_time", length = 30)
|
||||
private LocalDateTime create_time;
|
||||
|
||||
// 0 标签提示
|
||||
@Column(name = "type", length = 3)
|
||||
private Integer type;
|
||||
|
||||
}
|
||||
@@ -52,7 +52,6 @@ public class CourseToCourseFullText {
|
||||
cft.setTeacher("");
|
||||
cft.setTeacherCode("");
|
||||
cft.setType(c.getType());
|
||||
cft.setTags(c.getTags());
|
||||
if(c.getOpenCourse()==null) {
|
||||
cft.setOpenCourse(0);
|
||||
}else {
|
||||
|
||||
@@ -343,12 +343,4 @@ public interface ICourseService {
|
||||
|
||||
List<Course> findByIds(List<String> courseIds);
|
||||
void deletedStudyResourceBatchByCourseIdAndType(String courseId,Integer courseType);
|
||||
|
||||
void saveTip(String aid);
|
||||
|
||||
Boolean getCourseTip(String aid);
|
||||
|
||||
void rePublish(String courseId);
|
||||
|
||||
// void getPhpCourseData();
|
||||
}
|
||||
|
||||
@@ -1,97 +0,0 @@
|
||||
package com.xboe.module.course.service;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.module.article.entity.Article;
|
||||
import com.xboe.module.course.dto.CourseTagQueryDto;
|
||||
import com.xboe.module.course.dto.CourseTagRelationDto;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseTag;
|
||||
import com.xboe.module.course.entity.CourseTagRelation;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @InterfaceName:ICourseTagService
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2516:53
|
||||
*/
|
||||
public interface ICourseTagService {
|
||||
|
||||
/**
|
||||
* 分页查询标签列表,使用自定义filter
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
PageList<CourseTag> query(Integer pageIndex, Integer pageSize, List<IFieldFilter> filters, OrderCondition order);
|
||||
|
||||
/**
|
||||
* 分页查询指定id标签关联的课程列表,使用自定义filter
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @return
|
||||
*/
|
||||
PageList<CourseTagRelationDto> getCourseByTag(Integer pageIndex, Integer pageSize, Long tagId, Boolean isAsc);
|
||||
|
||||
/**
|
||||
* 修改指定id的课程标签的公共属性
|
||||
* @param id
|
||||
* @param isPublic
|
||||
* @return
|
||||
*/
|
||||
void changePublicStatus(Long id,Boolean isPublic);
|
||||
|
||||
/**
|
||||
* 修改指定id的课程标签的热点属性
|
||||
* @param id
|
||||
* @param isHot
|
||||
* @return
|
||||
*/
|
||||
void changeHotStatus(Long id,Boolean isHot);
|
||||
|
||||
/**
|
||||
* 解除指定id的课程和某个标签之间的关联关系
|
||||
* @return
|
||||
*/
|
||||
void unbind(String id);
|
||||
|
||||
/**
|
||||
* 根据标签名称进行检索(模糊查询)
|
||||
* @param tagName
|
||||
* @return 符合检索条件的所有公共标签
|
||||
*/
|
||||
List<CourseTag> searchTags(String tagName,String userId,String typeId);
|
||||
|
||||
/**
|
||||
* 创建新标签,并与当前课程绑定
|
||||
* @param courseTagRelationDto
|
||||
* @return
|
||||
*/
|
||||
CourseTag createTag(CourseTagRelationDto courseTagRelationDto);
|
||||
|
||||
/**
|
||||
* 根据课程类型获取热点标签
|
||||
* @param courseTagRelationDto
|
||||
* @return
|
||||
*/
|
||||
List<CourseTag> getHotTagList(CourseTagRelationDto courseTagRelationDto);
|
||||
|
||||
/**
|
||||
* 根据多个id获取标签
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
List<CourseTag> getTagsByIds(String id);
|
||||
|
||||
CourseTag getTagByName(String tagName);
|
||||
|
||||
void updateTags(Course oldCourse,Course newCourse,CurrentUser userInfo);
|
||||
|
||||
List<CourseTag> getAllTags();
|
||||
}
|
||||
@@ -18,24 +18,18 @@ import javax.management.Query;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.core.orm.*;
|
||||
import com.xboe.module.course.dao.*;
|
||||
import com.xboe.module.course.dto.*;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.dao.*;
|
||||
import com.xboe.module.course.dto.CourseTagRelationDto;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.service.ICourseTagService;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.study.entity.StudyCourse;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.http.client.HttpClient;
|
||||
import org.elasticsearch.client.RequestOptions;
|
||||
import org.elasticsearch.client.RestHighLevelClient;
|
||||
import org.elasticsearch.index.query.BoolQueryBuilder;
|
||||
@@ -43,6 +37,7 @@ import org.elasticsearch.index.query.QueryBuilders;
|
||||
import org.elasticsearch.index.reindex.DeleteByQueryRequest;
|
||||
import org.hibernate.mapping.IdGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
@@ -56,9 +51,6 @@ import com.xboe.common.beans.KeyValue;
|
||||
import com.xboe.common.utils.IDGenerator;
|
||||
import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.event.IEventDataSender;
|
||||
import com.xboe.module.course.dto.CourseFullDto;
|
||||
import com.xboe.module.course.dto.CourseQueryDto;
|
||||
import com.xboe.module.course.dto.RankingDto;
|
||||
import com.xboe.module.course.service.ICourseFullTextSearch;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.interaction.service.ICourseGradeService;
|
||||
@@ -98,8 +90,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
|
||||
@Resource
|
||||
private CourseHRBPAuditDao courseHRBPAuditDao;
|
||||
@Resource
|
||||
private ICourseTagService courseTagService;
|
||||
|
||||
|
||||
@Resource
|
||||
private SysLogAuditDao logAuditDao;//审核日志记录
|
||||
@@ -125,8 +116,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
|
||||
@Resource
|
||||
RestHighLevelClient restHighLevelClient;
|
||||
@Resource
|
||||
private TipDao tipDao;
|
||||
|
||||
@Resource
|
||||
private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao;
|
||||
@@ -134,6 +123,9 @@ public class CourseServiceImpl implements ICourseService {
|
||||
@Resource
|
||||
private ModifyLogDao modifyLogDao;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 生成过滤条件
|
||||
*
|
||||
@@ -288,13 +280,13 @@ public class CourseServiceImpl implements ICourseService {
|
||||
//// Set<String>list=new HashSet<>();
|
||||
//// if(s!=null&&!s.isEmpty()){
|
||||
//// list=Arrays.stream(s.split(",")).collect(Collectors.toSet());
|
||||
//// }else {
|
||||
//// }else {
|
||||
//// Set<String> ss = getSeache(dto);
|
||||
//// String courseSearch=String.join(",",ss);
|
||||
//// redisTemplate.opsForValue().set("course_search",courseSearch);
|
||||
//// //设置过期时间为1分钟
|
||||
//// redisTemplate.expire("course_search", 1, TimeUnit.MINUTES);
|
||||
//// }
|
||||
//// }
|
||||
// Set<String> list = getSeache(dto);
|
||||
// //有权限的查询,也同时查询出创建人的数据,在权限上
|
||||
// if(TempFilterConfig.Manager_CourseFile_ByOrgIds) {
|
||||
@@ -374,8 +366,9 @@ public class CourseServiceImpl implements ICourseService {
|
||||
// // 使用distinct()配合自定义的去重条件
|
||||
// .filter(distinctByKey(c -> c.getId()))
|
||||
// .collect(Collectors.toList());
|
||||
//// PageList<Course> rs=courseDao.findPage(pageIndex, pageSize, filters, oc);
|
||||
//// long endTime = System.nanoTime();
|
||||
|
||||
/// / PageList<Course> rs=courseDao.findPage(pageIndex, pageSize, filters, oc);
|
||||
/// / long endTime = System.nanoTime();
|
||||
// //log.info("查询出的条数:"+rs.getCount());
|
||||
// if(!mergedList.isEmpty()){
|
||||
// //去掉未发布的课程
|
||||
@@ -469,9 +462,45 @@ public class CourseServiceImpl implements ICourseService {
|
||||
rs.setCount(listByFilters2.size());
|
||||
rs.setPageSize(pageSize);
|
||||
rs.setList(paginate);
|
||||
if (!paginate.isEmpty()) {
|
||||
log.info("-----KJB------ getCourse");
|
||||
for (Course course : paginate) {
|
||||
this.getCourseFromKJB(course);
|
||||
}
|
||||
}
|
||||
return rs;
|
||||
}
|
||||
|
||||
public void getCourseFromKJB(Course course){
|
||||
String courseId = course.getId();
|
||||
log.info("------------KJB---获取课程信息---------: courseId = " + courseId);
|
||||
//String url = env.getProperty("kjb.url") + "/api/course/getCourseFromKJB?courseId=" + courseId;
|
||||
String url = aicoreUrl + "/aiVideo/getCourseList";
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
JSONArray courseIds = new JSONArray();
|
||||
courseIds.add(courseId);
|
||||
jsonObject.put("courseIds", courseIds);
|
||||
String result = HttpUtils.sendMessage(jsonObject.toJSONString(), url);
|
||||
log.info("---KJB --getCourseList 接口返回结果result: "+result);
|
||||
JSONObject jsonResult = JSONObject.parseObject(result);
|
||||
String data = jsonResult.getString("rows");
|
||||
|
||||
List<BoeaiCourseDto> boeaiCourseDto = JSON.parseArray(data, BoeaiCourseDto.class);
|
||||
//List<BoeaiCourseDto> aiVideoResourceRsp = Collections.singletonList(JSON.parseObject(data, BoeaiCourseDto.class));
|
||||
if(boeaiCourseDto != null && !boeaiCourseDto.isEmpty()){
|
||||
log.info("KJB摘要信息:"+boeaiCourseDto.get(0).getSummaryContent());
|
||||
course.setSummaryContent(boeaiCourseDto.get(0).getSummaryContent());
|
||||
course.setSummaryStatus(boeaiCourseDto.get(0).getSummaryStatus());
|
||||
course.setAiSet(boeaiCourseDto.get(0).getAiSet());
|
||||
course.setAiAbstract(boeaiCourseDto.get(0).getAiAbstract());
|
||||
course.setAiDraft(boeaiCourseDto.get(0).getAiDraft());
|
||||
course.setAiTranslate(boeaiCourseDto.get(0).getAiTranslate());
|
||||
course.setLanguageStatus(boeaiCourseDto.get(0).getLanguageStatus());
|
||||
course.setLanguageCode(boeaiCourseDto.get(0).getLanguageCode() == null ? new ArrayList<>() :Arrays.asList(boeaiCourseDto.get(0).getLanguageCode().split(",")));
|
||||
}
|
||||
}
|
||||
|
||||
private Set<String> getSeache(CourseQueryDto dto) {
|
||||
//需要设置为隐藏的课程id
|
||||
Set<String> list = new HashSet<>();
|
||||
@@ -1006,29 +1035,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
if (c.getVisible() == null) {
|
||||
c.setVisible(true);
|
||||
}
|
||||
/*if (c.getTags() != null && !c.getTags().isEmpty()){
|
||||
CourseTagRelationDto courseTagRelationDto = new CourseTagRelationDto();
|
||||
courseTagRelationDto.setCourseId(c.getId());
|
||||
courseTagRelationDto.setSysType1(c.getSysType1());
|
||||
courseTagRelationDto.setSysType2(c.getSysType2());
|
||||
courseTagRelationDto.setSysType3(c.getSysType3());
|
||||
String tags = c.getTags();
|
||||
List<CourseTag> tagList = courseTagService.getTagsByIds(tags);
|
||||
if (ObjectUtil.isNotEmpty(tagList)){
|
||||
for (CourseTag tag : tagList) {
|
||||
courseTagRelationDto.setTagName(tag.getTagName());
|
||||
courseTagService.createTag(courseTagRelationDto);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
if (!nowCourse.getSysVersion().equals(c.getSysVersion())) {
|
||||
log.warn(" - 课程ID: {}, 期望版本: {}, 实际版本: {}",
|
||||
c.getId(), c.getSysVersion(), nowCourse.getSysVersion());
|
||||
// 基本无概率同时修改同一课程 如有 以最后提交为准
|
||||
c.setSysVersion(courseDao.getVersion(c.getId()));
|
||||
}
|
||||
log.info("-------- 课程保存 update ------- tag = {} " , c.getTags());
|
||||
courseDao.update(c);
|
||||
c.setSysVersion(courseDao.getVersion(c.getId()));
|
||||
full.getCourse().setSysVersion(c.getSysVersion());
|
||||
@@ -1126,13 +1132,6 @@ public class CourseServiceImpl implements ICourseService {
|
||||
Course c = full.getCourse();//当前的课程信息
|
||||
c.setPublished(true);
|
||||
c.setPublishTime(LocalDateTime.now());
|
||||
Course nowCourse = courseDao.get(c.getId());
|
||||
if (!nowCourse.getSysVersion().equals(c.getSysVersion())) {
|
||||
log.warn(" - 课程ID: {}, 期望版本: {}, 实际版本: {}",
|
||||
c.getId(), c.getSysVersion(), nowCourse.getSysVersion());
|
||||
// 基本无概率同时修改同一课程 如有 以最后提交为准
|
||||
c.setSysVersion(courseDao.getVersion(c.getId()));
|
||||
}
|
||||
courseDao.update(c);
|
||||
|
||||
// 兼容处理,记录下删除的关联数据
|
||||
@@ -1203,7 +1202,7 @@ public class CourseServiceImpl implements ICourseService {
|
||||
|
||||
/***
|
||||
* 发布全文索引
|
||||
* @param
|
||||
* @param c
|
||||
*/
|
||||
// private void fullTextPublish(Course c) {
|
||||
// if(fullTextSearch==null) {
|
||||
@@ -2097,30 +2096,4 @@ public class CourseServiceImpl implements ICourseService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void saveTip(String aid) {
|
||||
Tip item = new Tip();
|
||||
item.setAid(aid);
|
||||
item.setType(0);
|
||||
item.setCreate_time(LocalDateTime.now());
|
||||
tipDao.save(item);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getCourseTip(String aid) {
|
||||
log.info("getCourseTip aid = {} ",aid);
|
||||
List<Tip> list = tipDao.findList(FieldFilters.eq("aid", aid));
|
||||
log.info("getCourseTip list = {} ",list);
|
||||
if (list != null && !list.isEmpty()){
|
||||
return false;//已提示
|
||||
}
|
||||
return true; //用户需要提示
|
||||
}
|
||||
|
||||
@Override
|
||||
public void rePublish(String courseId) {
|
||||
Course c = courseDao.get(courseId);
|
||||
publishUtil.fullTextPublish(c);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,879 +0,0 @@
|
||||
package com.xboe.module.course.service.impl;
|
||||
|
||||
import com.xboe.common.OrderCondition;
|
||||
import com.xboe.common.PageList;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.orm.BaseEntity;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
import com.xboe.core.orm.IFieldFilter;
|
||||
import com.xboe.core.orm.QueryBuilder;
|
||||
import com.xboe.module.course.dao.CourseDao;
|
||||
import com.xboe.module.course.dao.CourseTagDao;
|
||||
import com.xboe.module.course.dao.CourseTagRelationDao;
|
||||
import com.xboe.module.course.dao.CourseTypeTagRelationDao;
|
||||
import com.xboe.module.course.dto.CourseTagRelationDto;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseTag;
|
||||
import com.xboe.module.course.entity.CourseTagRelation;
|
||||
import com.xboe.module.course.entity.CourseTypeTagRelation;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.course.service.ICourseTagService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @ClassName:CourseTagServiceImpl
|
||||
* @author:zhengge@oracle.com
|
||||
* @since:2025/7/2516:55
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Transactional
|
||||
public class CourseTagServiceImpl implements ICourseTagService {
|
||||
|
||||
@Resource
|
||||
private CourseTagDao courseTagDao;
|
||||
@Resource
|
||||
PublishCourseUtil publishUtil;
|
||||
@Resource
|
||||
private CourseTagRelationDao courseTagRelationDao;
|
||||
|
||||
@Resource
|
||||
private CourseTypeTagRelationDao courseTypeTagRelationDao;
|
||||
@Resource
|
||||
private CourseDao courseDao;
|
||||
|
||||
/**
|
||||
* 课程标签分页查询
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param filters
|
||||
* @param order
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageList<CourseTag> query(Integer pageIndex, Integer pageSize, List<IFieldFilter> filters, OrderCondition order) {
|
||||
try {
|
||||
/* QueryBuilder query=QueryBuilder.from(CourseTag.class);
|
||||
query.setPageIndex(pageIndex);
|
||||
query.setPageSize(pageSize);
|
||||
filters.add(FieldFilters.eq("deleted",false));
|
||||
query.addFilters(filters);
|
||||
if(order!=null) {
|
||||
query.addOrder(order);
|
||||
}else {
|
||||
query.addOrder(OrderCondition.desc("sysCreateTime"));
|
||||
}
|
||||
log.info("标签列表:分页查询 调用接口IMPL query = " + query.builder().toString());
|
||||
return courseTagDao.findPage(query.builder());*/
|
||||
|
||||
if(pageSize==100){
|
||||
log.info("--- 11 ----------------------");
|
||||
return courseTagDao.getList();
|
||||
}else{
|
||||
log.info("--- 22 ----------------------");
|
||||
QueryBuilder query = QueryBuilder.from(CourseTag.class);
|
||||
query.setPageIndex(pageIndex);
|
||||
query.setPageSize(pageSize);
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
// query.addFilters(filters);
|
||||
query.addOrder(OrderCondition.desc("sysCreateTime"));
|
||||
return courseTagDao.findPage(query.builder());
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("课程标签分页查询异常 = " + e.getMessage());
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询指定id标签关联的课程
|
||||
* @param pageIndex
|
||||
* @param pageSize
|
||||
* @param tagId
|
||||
* @param isAsc
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PageList<CourseTagRelationDto> getCourseByTag(Integer pageIndex, Integer pageSize, Long tagId, Boolean isAsc) {
|
||||
PageList<CourseTagRelationDto> list = null;
|
||||
if(isAsc) {
|
||||
list = courseTagRelationDao.findCoursesWithRelatedTagsAsc(pageIndex,pageSize,tagId);
|
||||
}else {
|
||||
list = courseTagRelationDao.findCoursesWithRelatedTagsDesc(pageIndex,pageSize,tagId);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改指定id的课程标签的公共属性
|
||||
* @param id
|
||||
* @param isPublic
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void changePublicStatus(Long id, Boolean isPublic) {
|
||||
CourseTag courseTag = courseTagDao.findOne(FieldFilters.eq("id", String.valueOf(id)));
|
||||
if (courseTag!=null){
|
||||
courseTag.setIsPublic(isPublic);
|
||||
courseTag.setLastSetPublicTime(isPublic?LocalDateTime.now():null);
|
||||
courseTagDao.update(courseTag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改指定id的课程标签的热点属性
|
||||
* @param id
|
||||
* @param isHot
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void changeHotStatus(Long id, Boolean isHot) {
|
||||
CourseTag courseTag = courseTagDao.findOne(FieldFilters.eq("id", String.valueOf(id)));
|
||||
if (courseTag!=null){
|
||||
courseTag.setIsHot(isHot);
|
||||
courseTag.setLastSetHotTime(isHot?LocalDateTime.now():null);
|
||||
courseTagDao.update(courseTag);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解除指定id的课程和某个标签之间的关联关系
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public void unbind(String id) {
|
||||
//根据主键查询关联关系
|
||||
CourseTagRelation courseTagRelation = courseTagRelationDao.findOne(FieldFilters.eq("id", id));
|
||||
if (courseTagRelation != null){
|
||||
//修改该标签关联课程数
|
||||
CourseTag courseTag = courseTagDao.findOne(FieldFilters.eq("id", String.valueOf(courseTagRelation.getTagId())));
|
||||
if (courseTag != null){
|
||||
courseTag.setUseCount(courseTag.getUseCount()>1?courseTag.getUseCount()-1:0);
|
||||
courseTagDao.updateFieldById(courseTag.getId(),"useCount",courseTag.getUseCount());
|
||||
}
|
||||
//解绑(删除关联关系)
|
||||
courseTagRelationDao.setDeleted(id);
|
||||
Course course = courseDao.get(courseTagRelation.getCourseId().toString());
|
||||
String tags = course.getTags();
|
||||
if (StringUtils.isNotBlank(tags)){
|
||||
String[] tagIds = tags.split(",");
|
||||
List<String> tagIdList = new ArrayList<>();
|
||||
for (String tagId : tagIds){
|
||||
if (!tagId.equals(courseTagRelation.getTagId().toString())){
|
||||
tagIdList.add(tagId);
|
||||
}
|
||||
}
|
||||
// 数据格式:1,2,3
|
||||
String s = StringUtils.join(tagIdList, ",");
|
||||
if (!"".equals(s)){
|
||||
s+=",";
|
||||
}
|
||||
course.setTags(s);
|
||||
}
|
||||
// 同步ES
|
||||
publishUtil.fullTextPublish(course);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据标签名称进行检索(模糊查询)
|
||||
* @param tagName
|
||||
* @return 符合检索条件的所有公共标签
|
||||
*/
|
||||
public List<CourseTag> searchTags(String tagName){
|
||||
QueryBuilder query=QueryBuilder.from(CourseTag.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted",false));//未删除
|
||||
filters.add(FieldFilters.eq("isPublic",true));//公共标签
|
||||
filters.add(FieldFilters.like("tagName",tagName));//模糊检索
|
||||
query.addFilters(filters);
|
||||
List<CourseTag> courseTagList = courseTagDao.findList(query.builder());
|
||||
return courseTagList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CourseTag> searchTags(String tagName,String userId,String typeId){
|
||||
List<CourseTag> tagList = courseTagDao.searchTags(tagName,userId,typeId);
|
||||
return tagList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建新标签,并与指定课程绑定
|
||||
* @return
|
||||
*/
|
||||
/*@Override
|
||||
public CourseTag createTag(CourseTagRelationDto courseTagRelationDto) {
|
||||
CourseTag courseTag = null;
|
||||
String tagName = courseTagRelationDto.getTagName();
|
||||
Long courseId = Long.valueOf(courseTagRelationDto.getCourseId());
|
||||
//1.创建标签:先判断是否已经存在该标签
|
||||
QueryBuilder query=QueryBuilder.from(CourseTag.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("tagName",tagName));//精确匹配
|
||||
query.addFilters(filters);
|
||||
List<CourseTag> courseTagList = courseTagDao.findList(query.builder());
|
||||
if (courseTagList==null || courseTagList.size()==0){//1.1 如果该标签不存在,则新建标签
|
||||
courseTag = new CourseTag();
|
||||
courseTag.setTagName(tagName);
|
||||
courseTag.setIsPublic(false);
|
||||
courseTag.setIsHot(false);
|
||||
courseTag.setUseCount(1);
|
||||
courseTagDao.save(courseTag);
|
||||
//新建一条标签和课程的关联关系
|
||||
CourseTagRelation courseTagRelation = new CourseTagRelation();
|
||||
courseTagRelation.setTagId(Long.valueOf(courseTag.getId()));
|
||||
courseTagRelation.setCourseId(courseId);
|
||||
courseTagRelationDao.save(courseTagRelation);
|
||||
}else {//1.2 否则修改标签
|
||||
courseTag=courseTagList.get(0);
|
||||
// 当同一标签被3个及以上课管创建时,默认开启这个标签的公共化
|
||||
if(courseTag.getUseCount() >= 3){
|
||||
courseTag.setIsPublic(true);
|
||||
}
|
||||
courseTag.setDeleted(false);//有可能是之前被删除的标签,这里恢复为有效
|
||||
//查找改课程与这个标签是否已经建立关联关系
|
||||
query=QueryBuilder.from(CourseTagRelation.class);
|
||||
filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("tagId",Long.valueOf(courseTag.getId())));//精确匹配
|
||||
filters.add(FieldFilters.eq("courseId",courseId));//精确匹配
|
||||
query.addFilters(filters);
|
||||
List<CourseTagRelation> courseTagRelationList = courseTagRelationDao.findList(query.builder());
|
||||
//1.2.1 如果还未建立关联关系,则新建一条标签和课程的关联关系
|
||||
if (courseTagRelationList==null || courseTagRelationList.size()==0){
|
||||
CourseTagRelation courseTagRelation = new CourseTagRelation();
|
||||
courseTagRelation.setTagId(Long.valueOf(courseTag.getId()));
|
||||
courseTagRelation.setCourseId(courseId);
|
||||
courseTagRelationDao.save(courseTagRelation);
|
||||
//更新该标签的关联课程数量
|
||||
courseTag.setUseCount(courseTag.getUseCount()+1);
|
||||
}else {//1.2.2 否则修改该标签和课程的关联关系
|
||||
CourseTagRelation courseTagRelation = courseTagRelationList.get(0);
|
||||
if (courseTagRelation.getDeleted()){//之前"解绑",这里恢复为有效
|
||||
courseTagRelation.setDeleted(false);
|
||||
courseTagRelationDao.saveOrUpdate(courseTagRelation);
|
||||
//更新该标签的关联课程数量
|
||||
courseTag.setUseCount(courseTag.getUseCount()+1);
|
||||
}
|
||||
}
|
||||
courseTagDao.saveOrUpdate(courseTag);
|
||||
}
|
||||
//2.创建该标签和课程分类之间的关联关系
|
||||
courseTagRelationDto.setTagId(courseTag.getId());
|
||||
createCourseTypeAndTagRelation(courseTagRelationDto);
|
||||
return courseTag;
|
||||
}
|
||||
*/
|
||||
@Override
|
||||
public CourseTag getTagByName(String tagName) {
|
||||
CourseTag courseTag = courseTagDao.getTagByName(tagName);
|
||||
return courseTag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CourseTag> getTagsByIds(String id) {
|
||||
// id=17,18
|
||||
List<CourseTag> courseTagList = courseTagDao.getTagsByIds(id);
|
||||
return courseTagList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取热门标签
|
||||
* @param courseTagRelationDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<CourseTag> getHotTagList(CourseTagRelationDto courseTagRelationDto) {
|
||||
List<CourseTag> hotTagList = null;
|
||||
if (StringUtils.isNotBlank(courseTagRelationDto.getSysType1()) ||
|
||||
StringUtils.isNotBlank(courseTagRelationDto.getSysType2()) ||
|
||||
StringUtils.isNotBlank(courseTagRelationDto.getSysType3())){
|
||||
String sysType1 = courseTagRelationDto.getSysType1();
|
||||
String sysType2 = courseTagRelationDto.getSysType2();
|
||||
String sysType3 = courseTagRelationDto.getSysType3();
|
||||
hotTagList = courseTagDao.getHotTagListBySysTypes(sysType1,sysType2,sysType3);
|
||||
}else {
|
||||
hotTagList = courseTagDao.getHotTagList();
|
||||
}
|
||||
return hotTagList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建标签和课程分类之间的关联关系
|
||||
* @param courseTagRelationDto
|
||||
*/
|
||||
private void createCourseTypeAndTagRelation(CourseTagRelationDto courseTagRelationDto){
|
||||
String sysType1 = courseTagRelationDto!=null?courseTagRelationDto.getSysType1():null;
|
||||
String tagId = courseTagRelationDto!=null?courseTagRelationDto.getTagId():null;
|
||||
if (StringUtils.isNotBlank(sysType1) && StringUtils.isNotBlank(tagId)){
|
||||
String sysType2 = courseTagRelationDto.getSysType2();
|
||||
String sysType3 = courseTagRelationDto.getSysType3();
|
||||
//判断数据库中该课程分类和标签是否已经存在关联关系
|
||||
if (!isHadCourseTypeAndTagRelation(courseTagRelationDto,true)){//不存在,则新建
|
||||
CourseTypeTagRelation courseTypeTagRelation = new CourseTypeTagRelation();
|
||||
courseTypeTagRelation.setSysType1(sysType1);
|
||||
courseTypeTagRelation.setSysType2(StringUtils.isNotBlank(sysType2)?sysType2:"0");
|
||||
courseTypeTagRelation.setSysType3(StringUtils.isNotBlank(sysType3)?sysType3:"0");
|
||||
courseTypeTagRelation.setTagId(tagId);
|
||||
courseTypeTagRelationDao.save(courseTypeTagRelation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断数据库制定的课程分类和标签是否已经存在关联关系
|
||||
* @param courseTagRelationDto
|
||||
* @param clearFlag 清理标识 true:清理已存在的数据,只保留一条有效数据
|
||||
* @return true:已存在;false:不存在
|
||||
*/
|
||||
private Boolean isHadCourseTypeAndTagRelation(CourseTagRelationDto courseTagRelationDto,Boolean clearFlag){
|
||||
QueryBuilder query=QueryBuilder.from(CourseTypeTagRelation.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("sysType1",courseTagRelationDto.getSysType1()));//一级分类
|
||||
filters.add(FieldFilters.eq("sysType2",courseTagRelationDto.getSysType1()));//二级分类
|
||||
filters.add(FieldFilters.eq("sysType3",courseTagRelationDto.getSysType1()));//三级分类
|
||||
filters.add(FieldFilters.eq("tagId",courseTagRelationDto.getTagId()));
|
||||
List<CourseTypeTagRelation> courseTypeTagRelList = courseTypeTagRelationDao.findList(query.addFilters(filters).builder());
|
||||
Boolean isExist = (courseTypeTagRelList!=null && courseTypeTagRelList.size()>0)?true:false;
|
||||
if (isExist && clearFlag ){
|
||||
List<CourseTypeTagRelation> toRemove = new ArrayList<>();
|
||||
for (CourseTypeTagRelation courseTypeTagRel : courseTypeTagRelList) {
|
||||
if (courseTypeTagRel.getDeleted()) {//如果是逻辑删的本次物理删除
|
||||
courseTypeTagRelationDao.getGenericDao().delete(courseTypeTagRel);
|
||||
toRemove.add(courseTypeTagRel);
|
||||
}
|
||||
}
|
||||
courseTypeTagRelList.removeAll(toRemove);//移除逻辑删的数据
|
||||
//如果还存在有效数据
|
||||
if (courseTypeTagRelList!=null && courseTypeTagRelList.size()>0){
|
||||
//只保留一条有效数据,其余物理删除
|
||||
for (int i = courseTypeTagRelList.size() - 1; i >= 1; i--) {
|
||||
CourseTypeTagRelation courseTypeTagRel = courseTypeTagRelList.get(i);
|
||||
if (courseTypeTagRel.getDeleted()) {
|
||||
courseTypeTagRelationDao.getGenericDao().delete(courseTypeTagRel);
|
||||
courseTypeTagRelList.remove(i); // 倒序删除不影响未遍历的索引
|
||||
}
|
||||
}
|
||||
isExist = true;//存在一条有效数据
|
||||
}else {
|
||||
isExist = false;//不存在有效数据了
|
||||
}
|
||||
}
|
||||
return isExist;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 创建新标签
|
||||
* @param courseTagRelationDto
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public CourseTag createTag(CourseTagRelationDto courseTagRelationDto) {
|
||||
CourseTag courseTag = null;
|
||||
String tagName = courseTagRelationDto.getTagName();
|
||||
//1.创建标签:先判断是否已经存在该标签
|
||||
QueryBuilder query=QueryBuilder.from(CourseTag.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("tagName",tagName));//精确匹配
|
||||
filters.add(FieldFilters.eq("status",0));//正式
|
||||
filters.add(FieldFilters.eq("deleted",false));//未删除的
|
||||
query.addFilters(filters);
|
||||
List<CourseTag> courseTagList = courseTagDao.findList(query.builder());
|
||||
if (courseTagList==null || courseTagList.isEmpty() || !courseTagList.get(0).getIsPublic()){//1.1 如果该标签不存在 或私有标签,则新建标签
|
||||
courseTag = new CourseTag();
|
||||
courseTag.setTagName(tagName);
|
||||
courseTag.setIsPublic(false);
|
||||
courseTag.setIsHot(false);
|
||||
courseTag.setStatus(1);
|
||||
courseTag.setUseCount(1);
|
||||
//初始给个时间, 变更公共会更新时间 关闭公共会设置null 后续不在自动变更为公共
|
||||
courseTag.setLastSetPublicTime(LocalDateTime.now());
|
||||
courseTagDao.save(courseTag);
|
||||
}
|
||||
return courseTag;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateTags(Course oldCourse, Course newCourse, CurrentUser userInfo) {
|
||||
log.info(" --- 标签修改 --- 在线课参数 oldCourse = {} " , oldCourse);
|
||||
log.info(" --- 标签修改 --- 在线课参数 newCourse = {} " , newCourse);
|
||||
log.info(" --- 标签修改 --- 用户信息 userInfo = {} " , userInfo);
|
||||
|
||||
// 获取新旧课程的标签ID列表
|
||||
log.info(" --- 旧标签1 oldTagIds = {} " , oldCourse.getTags());
|
||||
log.info(" --- 新修改1 newTagIds = {} " , newCourse.getTags());
|
||||
List<String> oldTagIds = getTagIdsFromCourse(oldCourse);
|
||||
List<String> newTagIds = getTagIdsFromCourse(newCourse);
|
||||
log.info(" --- 旧标签2 oldTagIds = {} " , oldTagIds);
|
||||
log.info(" --- 新修改2 newTagIds = {} " , newTagIds);
|
||||
if (oldCourse == null || oldTagIds.isEmpty()) {
|
||||
// 新增课程 - 处理所有新标签
|
||||
handleNewCourseTags(newCourse, newTagIds, userInfo);
|
||||
} else {
|
||||
// 编辑课程 - 比较差异并处理
|
||||
handleEditCourseTags(oldCourse, newCourse, oldTagIds, newTagIds, userInfo);
|
||||
}
|
||||
log.info("完成课程标签更新: courseId={}", newCourse != null ? newCourse.getId() : "null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CourseTag> getAllTags() {
|
||||
QueryBuilder query=QueryBuilder.from(CourseTag.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("deleted",false));//未删除
|
||||
filters.add(FieldFilters.eq("status",0));//正式标签
|
||||
query.addFilters(filters);
|
||||
List<CourseTag> courseTagList = courseTagDao.findList(query.builder());
|
||||
return courseTagList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从课程对象中提取标签ID列表
|
||||
*/
|
||||
private List<String> getTagIdsFromCourse(Course course) {
|
||||
if (course == null || StringUtils.isBlank(course.getTags())) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
String tags = course.getTags();
|
||||
// 去除结尾的逗号并分割
|
||||
if (tags.endsWith(",")) {
|
||||
tags = tags.substring(0, tags.length() - 1);
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(tags)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
return Arrays.asList(tags.split(","));
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理新增课程的标签逻辑
|
||||
*/
|
||||
private void handleNewCourseTags(Course newCourse, List<String> newTagIds, CurrentUser userInfo) {
|
||||
log.info("处理新增课程的标签逻辑: courseId={}, tagCount={}", newCourse != null ? newCourse.getId() : "null", newTagIds.size());
|
||||
String courseId = newCourse.getId();
|
||||
|
||||
for (String tagId : newTagIds) {
|
||||
if (StringUtils.isBlank(tagId)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取标签信息
|
||||
CourseTag tag = courseTagDao.findOne(FieldFilters.eq("id", tagId.trim()));
|
||||
if (tag == null) {
|
||||
log.warn("标签不存在: {}", tagId);
|
||||
continue;
|
||||
}
|
||||
|
||||
//合并临时标签
|
||||
tag = mergeTag(tag);
|
||||
|
||||
// 创建课程-标签关联关系
|
||||
createCourseTagRelation(courseId, tag, userInfo);
|
||||
|
||||
// 创建分类-标签关联关系
|
||||
createCourseTypeTagRelations(newCourse, tag, userInfo);
|
||||
|
||||
// 更新标签使用计数并检查是否设置为公共标签
|
||||
updateTagUseCountAndPublicStatus(tag, userInfo);
|
||||
}
|
||||
log.info("完成新增课程标签处理: courseId={}", newCourse != null ? newCourse.getId() : "null");
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理编辑课程的标签逻辑
|
||||
*/
|
||||
private void handleEditCourseTags(Course oldCourse, Course newCourse,
|
||||
List<String> oldTagIds, List<String> newTagIds, CurrentUser userInfo) {
|
||||
log.info("处理编辑课程的标签逻辑: courseId={}, oldTagCount={}, newTagCount={}, toRemove={}, toAdd={}",
|
||||
newCourse != null ? newCourse.getId() : "null",
|
||||
oldTagIds.size(), newTagIds.size(),
|
||||
oldTagIds.stream().filter(tagId -> !newTagIds.contains(tagId)).count(),
|
||||
newTagIds.stream().filter(tagId -> !oldTagIds.contains(tagId)).count());
|
||||
|
||||
String courseId = newCourse.getId();
|
||||
|
||||
// 找出需要删除的标签(存在于旧课程但不在新课程中)
|
||||
List<String> tagsToRemove = oldTagIds.stream()
|
||||
.filter(tagId -> !newTagIds.contains(tagId))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 找出需要新增的标签(存在于新课程但不在旧课程中)
|
||||
List<String> tagsToAdd = newTagIds.stream()
|
||||
.filter(tagId -> !oldTagIds.contains(tagId))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 处理标签删除
|
||||
for (String tagId : tagsToRemove) {
|
||||
removeCourseTagRelation(courseId, tagId, userInfo);
|
||||
}
|
||||
|
||||
// 处理标签新增
|
||||
for (String tagId : tagsToAdd) {
|
||||
CourseTag tag = courseTagDao.findOne(FieldFilters.eq("id", tagId.trim()));
|
||||
if (tag == null) {
|
||||
log.warn("标签不存在: {}", tagId);
|
||||
continue;
|
||||
}
|
||||
//如果已有同名的正式标签 则需要合并
|
||||
//合并临时标签
|
||||
tag = mergeTag(tag);
|
||||
|
||||
// 创建课程-标签关联关系
|
||||
createCourseTagRelation(courseId, tag, userInfo);
|
||||
|
||||
// 创建分类-标签关联关系
|
||||
createCourseTypeTagRelations(newCourse, tag, userInfo);
|
||||
|
||||
// 更新标签使用计数并检查是否设置为公共标签
|
||||
updateTagUseCountAndPublicStatus(tag, userInfo);
|
||||
}
|
||||
|
||||
// 处理分类变化导致的标签关联关系更新
|
||||
if (hasCourseTypeChanged(oldCourse, newCourse)) {
|
||||
updateCourseTypeTagRelations(oldCourse, newCourse, newTagIds, userInfo);
|
||||
}
|
||||
log.info("完成编辑课程标签处理: courseId={}", newCourse != null ? newCourse.getId() : "null");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 合并标签
|
||||
*/
|
||||
private CourseTag mergeTag(CourseTag tag){
|
||||
//只处理临时标签 正式的忽略
|
||||
if (tag.getStatus()==1){
|
||||
QueryBuilder query=QueryBuilder.from(CourseTag.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("tagName",tag.getTagName()));//精确匹配
|
||||
filters.add(FieldFilters.eq("status",0));//正式
|
||||
filters.add(FieldFilters.eq("deleted",false));//未删除的
|
||||
query.addFilters(filters);
|
||||
List<CourseTag> courseTagList = courseTagDao.findList(query.builder());
|
||||
log.info("标签合并 createTag courseTagList = {} " , courseTagList);
|
||||
//如果无同名正式标签 则转正
|
||||
//有同名正式标签 则合并
|
||||
if (courseTagList != null && !courseTagList.isEmpty()) {
|
||||
//删除临时标签
|
||||
tag.setSysUpdateBy("系统合并删除");
|
||||
tag.setSysUpdateTime(LocalDateTime.now());
|
||||
courseTagDao.setDeleted(tag.getId());
|
||||
//返回同名正式标签
|
||||
tag = courseTagList.get(0);
|
||||
}
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建课程-标签关联关系
|
||||
*/
|
||||
private void createCourseTagRelation(String courseId, CourseTag tag, CurrentUser userInfo) {
|
||||
log.debug("创建课程-标签关联关系: courseId={}, tagId={}, tagName={}",
|
||||
courseId, tag != null ? tag.getId() : "null", tag != null ? tag.getTagName() : "null");
|
||||
|
||||
// 检查是否已存在关联关系
|
||||
QueryBuilder query = QueryBuilder.from(CourseTagRelation.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("courseId", Long.valueOf(courseId)));
|
||||
filters.add(FieldFilters.eq("tagId", Long.valueOf(tag.getId())));
|
||||
// filters.add(FieldFilters.eq("deleted", false));
|
||||
query.addFilters(filters);
|
||||
|
||||
List<CourseTagRelation> existingRelations = courseTagRelationDao.findList(query.builder());
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
if (existingRelations.isEmpty()) {
|
||||
// 新建关联关系
|
||||
CourseTagRelation relation = new CourseTagRelation();
|
||||
relation.setCourseId(Long.valueOf(courseId));
|
||||
relation.setTagId(Long.valueOf(tag.getId()));
|
||||
|
||||
// 设置创建信息
|
||||
relation.setSysCreateAid(userInfo.getAccountId());
|
||||
relation.setSysCreateBy(userInfo.getName());
|
||||
relation.setSysCreateTime(now);
|
||||
|
||||
// 设置更新信息
|
||||
relation.setSysUpdateBy(userInfo.getName());
|
||||
relation.setSysUpdateTime(now);
|
||||
|
||||
courseTagRelationDao.save(relation);
|
||||
} else {
|
||||
// 恢复已删除的关联关系
|
||||
CourseTagRelation relation = existingRelations.get(0);
|
||||
if (relation.getDeleted()) {
|
||||
courseTagRelationDao.reTagRelDelStatus(relation.getId(),userInfo.getName());
|
||||
// relation.setDeleted(false);
|
||||
// 设置更新信息
|
||||
// relation.setSysUpdateBy(userInfo.getName());
|
||||
// relation.setSysUpdateTime(now);
|
||||
// courseTagRelationDao.saveOrUpdate(relation);
|
||||
}
|
||||
}
|
||||
log.debug("完成课程-标签关联关系创建: courseId={}, tagId={}", courseId, tag != null ? tag.getId() : "null");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建分类-标签关联关系
|
||||
*/
|
||||
private void createCourseTypeTagRelations(Course course, CourseTag tag, CurrentUser userInfo) {
|
||||
log.debug("创建分类-标签关联关系: courseId={}, tagId={}, sysType1={}, sysType2={}, sysType3={}",
|
||||
course != null ? course.getId() : "null",
|
||||
tag != null ? tag.getId() : "null",
|
||||
course != null ? course.getSysType1() : "null",
|
||||
course != null ? course.getSysType2() : "null",
|
||||
course != null ? course.getSysType3() : "null");
|
||||
|
||||
String sysType1 = course.getSysType1();
|
||||
String sysType2 = course.getSysType2();
|
||||
String sysType3 = course.getSysType3();
|
||||
|
||||
// 根据分类级别创建相应的关联关系
|
||||
if (StringUtils.isNotBlank(sysType3)) {
|
||||
createSingleCourseTypeTagRelation(sysType1, sysType2, sysType3, tag.getId(), userInfo);
|
||||
}else if (StringUtils.isNotBlank(sysType2)) {
|
||||
createSingleCourseTypeTagRelation(sysType1, sysType2, "0", tag.getId(), userInfo);
|
||||
}else if (StringUtils.isNotBlank(sysType1)) {
|
||||
createSingleCourseTypeTagRelation(sysType1, "0", "0", tag.getId(), userInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建单个分类-标签关联关系
|
||||
*/
|
||||
private void createSingleCourseTypeTagRelation(String sysType1, String sysType2, String sysType3,
|
||||
String tagId, CurrentUser userInfo) {
|
||||
// 检查是否已存在关联关系
|
||||
QueryBuilder query = QueryBuilder.from(CourseTypeTagRelation.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("sysType1", sysType1));
|
||||
filters.add(FieldFilters.eq("sysType2", sysType2));
|
||||
filters.add(FieldFilters.eq("sysType3", sysType3));
|
||||
filters.add(FieldFilters.eq("tagId", tagId));
|
||||
// filters.add(FieldFilters.eq("deleted", false));
|
||||
query.addFilters(filters);
|
||||
|
||||
List<CourseTypeTagRelation> existingRelations = courseTypeTagRelationDao.findList(query.builder());
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
if (existingRelations.isEmpty()) {
|
||||
// 新建关联关系
|
||||
CourseTypeTagRelation relation = new CourseTypeTagRelation();
|
||||
relation.setSysType1(sysType1);
|
||||
relation.setSysType2(sysType2);
|
||||
relation.setSysType3(sysType3);
|
||||
relation.setTagId(tagId);
|
||||
|
||||
// 设置创建信息
|
||||
relation.setSysCreateAid(userInfo.getAccountId());
|
||||
relation.setSysCreateBy(userInfo.getName());
|
||||
relation.setSysCreateTime(now);
|
||||
|
||||
// 设置更新信息
|
||||
relation.setSysUpdateBy(userInfo.getName());
|
||||
relation.setSysUpdateTime(now);
|
||||
|
||||
courseTypeTagRelationDao.save(relation);
|
||||
} else {
|
||||
// 恢复已删除的关联关系
|
||||
CourseTypeTagRelation relation = existingRelations.get(0);
|
||||
if (relation.getDeleted()) {
|
||||
courseTagRelationDao.reTypeTagRelDelStatus(relation.getId(),userInfo.getName());
|
||||
// relation.setDeleted(false);
|
||||
// // 设置更新信息
|
||||
// relation.setSysUpdateBy(userInfo.getName());
|
||||
// relation.setSysUpdateTime(now);
|
||||
// courseTypeTagRelationDao.saveOrUpdate(relation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除课程-标签关联关系
|
||||
*/
|
||||
private void removeCourseTagRelation(String courseId, String tagId, CurrentUser userInfo) {
|
||||
log.debug("移除课程-标签关联关系: courseId={}, tagId={}", courseId, tagId);
|
||||
// 查找关联关系
|
||||
QueryBuilder query = QueryBuilder.from(CourseTagRelation.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("courseId", Long.valueOf(courseId)));
|
||||
filters.add(FieldFilters.eq("tagId", Long.valueOf(tagId)));
|
||||
query.addFilters(filters);
|
||||
|
||||
List<CourseTagRelation> relations = courseTagRelationDao.findList(query.builder());
|
||||
|
||||
if (!relations.isEmpty()) {
|
||||
CourseTagRelation relation = relations.get(0);
|
||||
|
||||
// 设置更新信息
|
||||
relation.setSysUpdateBy(userInfo.getName());
|
||||
relation.setSysUpdateTime(LocalDateTime.now());
|
||||
|
||||
// 逻辑删除关联关系
|
||||
courseTagRelationDao.setDeleted(relation.getId());
|
||||
|
||||
// 更新标签使用计数
|
||||
CourseTag tag = courseTagDao.findOne(FieldFilters.eq("id", tagId));
|
||||
if (tag != null) {
|
||||
tag.setUseCount(Math.max(0, tag.getUseCount() - 1));
|
||||
|
||||
// 设置更新信息
|
||||
tag.setSysUpdateBy(userInfo.getName());
|
||||
tag.setSysUpdateTime(LocalDateTime.now());
|
||||
|
||||
courseTagDao.update(tag);
|
||||
}
|
||||
|
||||
// 检查是否需要删除分类-标签关联关系
|
||||
checkAndRemoveCourseTypeTagRelation(tagId, userInfo);
|
||||
}
|
||||
log.debug("完成课程-标签关联关系移除: courseId={}, tagId={}", courseId, tagId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查并删除分类-标签关联关系(如果没有其他课程使用)
|
||||
*/
|
||||
private void checkAndRemoveCourseTypeTagRelation(String tagId, CurrentUser userInfo) {
|
||||
// 检查是否还有其他课程使用这个标签
|
||||
QueryBuilder query = QueryBuilder.from(CourseTagRelation.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("tagId", Long.valueOf(tagId)));
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
query.addFilters(filters);
|
||||
|
||||
List<CourseTagRelation> activeRelations = courseTagRelationDao.findList(query.builder());
|
||||
|
||||
// 如果没有其他活跃的关联关系,删除分类-标签关联
|
||||
if (activeRelations.isEmpty()) {
|
||||
QueryBuilder typeQuery = QueryBuilder.from(CourseTypeTagRelation.class);
|
||||
List<IFieldFilter> typeFilters = new ArrayList<>();
|
||||
typeFilters.add(FieldFilters.eq("tagId", tagId));
|
||||
typeQuery.addFilters(typeFilters);
|
||||
|
||||
List<CourseTypeTagRelation> typeRelations = courseTypeTagRelationDao.findList(typeQuery.builder());
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
for (CourseTypeTagRelation relation : typeRelations) {
|
||||
// 设置更新信息
|
||||
relation.setSysUpdateBy(userInfo.getName());
|
||||
relation.setSysUpdateTime(now);
|
||||
|
||||
courseTypeTagRelationDao.setDeleted(relation.getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新标签使用计数并检查公共标签状态
|
||||
*/
|
||||
private void updateTagUseCountAndPublicStatus(CourseTag tag, CurrentUser userInfo) {
|
||||
log.debug("更新标签使用计数和公共状态: tagId={}, tagName={}, beforeUseCount={}",
|
||||
tag != null ? tag.getId() : "null",
|
||||
tag != null ? tag.getTagName() : "null",
|
||||
tag != null ? tag.getUseCount() : "null");
|
||||
|
||||
// 将标签状态设置为正式(status=0)
|
||||
if (tag != null && tag.getStatus() == 1) {
|
||||
tag.setStatus(0); // 正式标签
|
||||
}
|
||||
// 统计当前活跃的关联关系数量
|
||||
QueryBuilder query = QueryBuilder.from(CourseTagRelation.class);
|
||||
List<IFieldFilter> filters = new ArrayList<>();
|
||||
filters.add(FieldFilters.eq("tagId", Long.valueOf(tag.getId())));
|
||||
filters.add(FieldFilters.eq("deleted", false));
|
||||
query.addFilters(filters);
|
||||
|
||||
List<CourseTagRelation> activeRelations = courseTagRelationDao.findList(query.builder());
|
||||
int activeCount = activeRelations.size();
|
||||
|
||||
tag.setUseCount(activeCount);
|
||||
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
|
||||
// 检查是否满足设置为公共标签的条件
|
||||
if (activeCount >= 3 && tag.getLastSetPublicTime() != null) {
|
||||
// 只有从未手动关闭过公共标签的才自动开启
|
||||
tag.setIsPublic(true);
|
||||
tag.setLastSetPublicTime(now);
|
||||
}
|
||||
|
||||
// 设置更新信息
|
||||
tag.setSysUpdateBy(userInfo.getName());
|
||||
tag.setSysUpdateTime(now);
|
||||
|
||||
courseTagDao.update(tag);
|
||||
log.debug("完成标签使用计数和公共状态更新: tagId={}, tagName={}, afterUseCount={}, isPublic={}",
|
||||
tag != null ? tag.getId() : "null",
|
||||
tag != null ? tag.getTagName() : "null",
|
||||
tag != null ? tag.getUseCount() : "null",
|
||||
tag != null ? tag.getIsPublic() : "null");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查课程分类是否发生变化
|
||||
*/
|
||||
private boolean hasCourseTypeChanged(Course oldCourse, Course newCourse) {
|
||||
return !Objects.equals(oldCourse.getSysType1(), newCourse.getSysType1()) ||
|
||||
!Objects.equals(oldCourse.getSysType2(), newCourse.getSysType2()) ||
|
||||
!Objects.equals(oldCourse.getSysType3(), newCourse.getSysType3());
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新分类-标签关联关系(当分类变化时)
|
||||
*/
|
||||
private void updateCourseTypeTagRelations(Course oldCourse, Course newCourse,
|
||||
List<String> tagIds, CurrentUser userInfo) {
|
||||
// 移除旧的分类-标签关联关系
|
||||
for (String tagId : tagIds) {
|
||||
checkAndRemoveCourseTypeTagRelation(tagId, userInfo);
|
||||
}
|
||||
|
||||
// 创建新的分类-标签关联关系
|
||||
for (String tagId : tagIds) {
|
||||
CourseTag tag = courseTagDao.findOne(FieldFilters.eq("id", tagId.trim()));
|
||||
if (tag != null) {
|
||||
createCourseTypeTagRelations(newCourse, tag, userInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置实体的创建信息(新增时使用)
|
||||
*/
|
||||
private void setCreateInfo(BaseEntity entity, CurrentUser userInfo) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
entity.setSysCreateAid(userInfo.getAccountId());
|
||||
entity.setSysCreateBy(userInfo.getName());
|
||||
entity.setSysCreateTime(now);
|
||||
entity.setSysUpdateBy(userInfo.getName());
|
||||
entity.setSysUpdateTime(now);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置实体的更新信息(编辑时使用)
|
||||
*/
|
||||
private void setUpdateInfo(BaseEntity entity, CurrentUser userInfo) {
|
||||
entity.setSysUpdateBy(userInfo.getName());
|
||||
entity.setSysUpdateTime(LocalDateTime.now());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
package com.xboe.module.course.utils;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @date 2025年11月18日
|
||||
*/
|
||||
@Slf4j
|
||||
public class HttpUtils {
|
||||
public static String sendMessage(String message,String url) {
|
||||
log.info("----------------发送消息开始 -------");
|
||||
//log.info("----------------发送消息url -------{}",url);
|
||||
log.info("----------------发送消息参数 -------{}",message);
|
||||
// POST 请求
|
||||
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
|
||||
// POST 请求
|
||||
HttpPost httpPost = new HttpPost(url);
|
||||
//HttpPost httpPost = new HttpPost("https://jsonplaceholder.typicode.com/posts");
|
||||
httpPost.setEntity(new StringEntity(message, StandardCharsets.UTF_8));
|
||||
httpPost.setHeader("Content-Type", "application/json; charset=utf-8");
|
||||
httpPost.setHeader("Accept", "application/json");
|
||||
CloseableHttpResponse response = httpClient.execute(httpPost);
|
||||
|
||||
HttpEntity responseEntity = response.getEntity();
|
||||
String responseBody = "";
|
||||
if (responseEntity != null) {
|
||||
responseBody = EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
|
||||
System.out.println("Response Body: " + responseBody);
|
||||
}
|
||||
log.info("---------------发送消息响应 -------{}",responseBody);
|
||||
return responseBody;
|
||||
// System.out.println("状态码: " + response.getCode());
|
||||
// System.out.println("响应体: " + EntityUtils.toString(response.getEntity()));
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("KJB-发送消息错误",e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package com.xboe.module.course.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @date 2025/11/17
|
||||
*/
|
||||
@Data
|
||||
public class RePublishVo {
|
||||
/**
|
||||
* 课程id
|
||||
* */
|
||||
private String courseId;
|
||||
}
|
||||
@@ -9,21 +9,25 @@ import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.shaded.com.google.common.util.concurrent.RateLimiter;
|
||||
import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
|
||||
import com.boe.feign.api.infrastructure.entity.Dict;
|
||||
import com.xboe.api.ThirdApi;
|
||||
import com.xboe.constants.CacheName;
|
||||
import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.service.ICourseTagService;
|
||||
import com.xboe.module.course.dto.AiVideoResourceRsp;
|
||||
import com.xboe.module.course.dto.BoeaiSubtitleRsp;
|
||||
import com.xboe.module.course.utils.HttpUtils;
|
||||
import com.xboe.module.course.vo.TeacherVo;
|
||||
import com.xboe.module.usergroup.service.IUserGroupService;
|
||||
import com.xboe.school.study.dao.StudyCourseDao;
|
||||
import com.xboe.school.vo.StudyTimeVo;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -39,6 +43,11 @@ import com.xboe.common.utils.StringUtil;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.module.course.entity.Course;
|
||||
import com.xboe.module.course.entity.CourseContent;
|
||||
import com.xboe.module.course.entity.CourseCrowd;
|
||||
import com.xboe.module.course.entity.CourseSection;
|
||||
import com.xboe.module.course.entity.CourseTeacher;
|
||||
import com.xboe.module.course.service.ICourseContentService;
|
||||
import com.xboe.module.course.service.ICourseSectionService;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
@@ -100,8 +109,9 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
|
||||
@Autowired
|
||||
StringRedisTemplate redisTemplate;
|
||||
@Resource
|
||||
private ICourseTagService courseTagService;
|
||||
|
||||
@Value("${kjb.aicoreUrl}")
|
||||
private String aicoreUrl;
|
||||
|
||||
/**
|
||||
* 用于查询课程的学习记录
|
||||
@@ -169,14 +179,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
if(course==null || course.getDeleted()){
|
||||
return badRequest("课程不存在或已被删除");
|
||||
}
|
||||
Course course1 = new Course();
|
||||
BeanUtils.copyProperties(course,course1);
|
||||
if (StringUtils.isNotBlank(course.getTags()) && course.getTags().matches("[0-9,]+")) {
|
||||
List<CourseTag> tagList = courseTagService.getTagsByIds(course.getTags());
|
||||
String tags = tagList.stream().map(CourseTag::getTagName).collect(Collectors.joining(","));
|
||||
course1.setTags(tags);
|
||||
}
|
||||
rs.put("course",course1);
|
||||
rs.put("course",course);
|
||||
|
||||
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(cid);
|
||||
if(crowd!=null && crowd) {
|
||||
@@ -213,6 +216,11 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
List<CourseContent> cclist=contentService.getByCourseId(cid);
|
||||
List<CourseSection> sectionlist=sectionService.getByCourseId(cid);
|
||||
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(cid);
|
||||
|
||||
for (CourseContent cc : cclist) {
|
||||
log.info("根据视频信息查询AI字幕数据:cc = " + cc.toString());
|
||||
this.getVtt( cid , cc);
|
||||
}
|
||||
|
||||
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
|
||||
for(CourseTeacher ct : teachers) {
|
||||
@@ -238,6 +246,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
rs.put("isCrowd",pass);
|
||||
rs.put("contents",cclist);
|
||||
rs.put("sections",sectionlist);
|
||||
@@ -327,6 +336,35 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
return success(rs);
|
||||
}
|
||||
|
||||
public void getVtt(String couirseId, CourseContent cc){
|
||||
log.info("------KJB --------- getVtt couirseId = " + couirseId + " videoId = " + cc.getId());
|
||||
String url = aicoreUrl + "/aiVideo/getVideoVtt";
|
||||
JSONObject message = new JSONObject();
|
||||
message.put("courseId", couirseId);
|
||||
message.put("videoId", cc.getId());
|
||||
String result = HttpUtils.sendMessage(message.toJSONString(), url);
|
||||
if(StringUtils.isBlank(result)){
|
||||
log.error("未获取到AI字幕信息");
|
||||
return;
|
||||
}
|
||||
//将返回string 转为json对象
|
||||
JSONObject jsonObject = JSONObject.parseObject(result);
|
||||
String data = jsonObject.getString("data");
|
||||
//json字符串转为实体对象
|
||||
AiVideoResourceRsp aiVideoResourceRsp = JSON.parseObject(data, AiVideoResourceRsp.class);
|
||||
log.info("aiVideoResourceRsp:"+aiVideoResourceRsp);
|
||||
//循环json对象
|
||||
if(aiVideoResourceRsp != null){
|
||||
cc.setBoeaiSubtitleRspList(aiVideoResourceRsp.getBoeaiSubtitleRspList());
|
||||
// for (int i = 0; i < rows.size(); i++) {
|
||||
// JSONObject row = rows.getJSONObject(i);
|
||||
// //将json对象转为实体对象 CourseContentVtt
|
||||
// BoeaiSubtitleRsp vtt = row.toJavaObject(BoeaiSubtitleRsp.class);
|
||||
// boeaiSubtitleRspList.add(vtt);
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 在打开课程详细页面的时候,调用此接口,返回学习课程信息,上次学习的位置。<br/>
|
||||
* 如果没有就返回空<br>
|
||||
|
||||
@@ -4,8 +4,6 @@ import com.xboe.common.beans.IdName;
|
||||
import com.xboe.common.beans.KeyValue;
|
||||
import com.xboe.core.JsonResponse;
|
||||
import com.xboe.core.api.ApiBaseController;
|
||||
import com.xboe.module.course.service.ICourseService;
|
||||
import com.xboe.module.course.vo.RePublishVo;
|
||||
import com.xboe.school.study.dto.BatchSignup;
|
||||
import com.xboe.school.study.entity.StudySignup;
|
||||
import com.xboe.school.study.service.IStudySignupService;
|
||||
@@ -34,8 +32,7 @@ public class StudySignupRpcController extends ApiBaseController {
|
||||
|
||||
@Resource
|
||||
IStudySignupService signupService;
|
||||
@Resource
|
||||
ICourseService courseService;
|
||||
|
||||
/**
|
||||
* 批量添加学员
|
||||
*
|
||||
@@ -109,18 +106,4 @@ public class StudySignupRpcController extends ApiBaseController {
|
||||
return StringUtils.isBlank(string);
|
||||
}
|
||||
|
||||
@PostMapping("/rePublish")
|
||||
public JsonResponse<Boolean> rePublish(@RequestBody RePublishVo vo) {
|
||||
if(vo==null || StringUtils.isBlank(vo.getCourseId())) {
|
||||
return error("未指定id");
|
||||
}
|
||||
try {
|
||||
courseService.rePublish(vo.getCourseId());
|
||||
} catch (Exception e) {
|
||||
log.error("解绑重新发布", e);
|
||||
return error("解绑重新发布失败,请与管理员联系", e.getMessage());
|
||||
}
|
||||
return success(true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -79,16 +79,6 @@ xboe:
|
||||
image:
|
||||
course:
|
||||
default: http://192.168.0.253/pc/images/bgimg/course.png
|
||||
case:
|
||||
ai:
|
||||
base-url: http://10.10.181.114:30003
|
||||
app-key: 6e9be45319184ac793aa127c362b0f0b
|
||||
secret-key: db4d24279e3d6dbf1524af42cd0bedd2
|
||||
ai-api-code: 30800
|
||||
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff
|
||||
file-upload-callback-url: http://192.168.0.253:9090/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
alert-email-recipients:
|
||||
- liu.zixi@ebiz-digits.com
|
||||
xxl:
|
||||
job:
|
||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||
|
||||
@@ -111,16 +111,6 @@ xboe:
|
||||
image:
|
||||
course:
|
||||
default: http://10.251.132.75/pc/images/bgimg/course.png
|
||||
case:
|
||||
ai:
|
||||
base-url: http://10.10.181.114:30003
|
||||
app-key: 6e9be45319184ac793aa127c362b0f0b
|
||||
secret-key: db4d24279e3d6dbf1524af42cd0bedd2
|
||||
ai-api-code: 30800
|
||||
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff
|
||||
file-upload-callback-url: http://10.251.132.75:9090/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
alert-email-recipients:
|
||||
- liu.zixi@ebiz-digits.com
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
|
||||
@@ -77,45 +77,6 @@ xboe:
|
||||
image:
|
||||
course:
|
||||
default: https://u.boe.com/pc/images/bgimg/course.png
|
||||
case:
|
||||
ai:
|
||||
base-url: https://gateway-internal.boe.com
|
||||
# base-url: https://gateway-pro.boe.com
|
||||
app-key: 3edef300b25642da949ccddf58441a0f
|
||||
secret-key: 43bc8003a811a7f9c89cbecbfe4bbb22
|
||||
ai-api-code: 30800
|
||||
chat-api-code: 32065
|
||||
case-knowledge-id: f062c9e4-c6ad-437b-b5ca-bbb9fed9b442
|
||||
caseDetailUrlBase: https://u.boe.com/pc/case/detail?id=
|
||||
file-upload-callback-url: https://u.boe.com/systemapi/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
use-white-list: true
|
||||
white-user-code-list:
|
||||
- "00004409"
|
||||
- "10361430"
|
||||
- "10867319"
|
||||
- "00004746"
|
||||
- "00004701"
|
||||
- "00004471"
|
||||
- "11311660"
|
||||
- "10157955"
|
||||
- "10726944"
|
||||
- "110408"
|
||||
- "10768019"
|
||||
- "137812"
|
||||
- "107863"
|
||||
- "10046607"
|
||||
- "110858"
|
||||
- "98000352"
|
||||
- "101215"
|
||||
- "00005011"
|
||||
- "10827857"
|
||||
- "11339772"
|
||||
- "pctest06"
|
||||
alert-email-recipients:
|
||||
- chengmeng@boe.com.cn
|
||||
- liyubing@boe.com.cn
|
||||
- lijian-hq@boe.com.cn
|
||||
ai-chat-root-path: /home/www/elearning/upload/ai/chat
|
||||
xxl:
|
||||
job:
|
||||
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0
|
||||
|
||||
@@ -111,41 +111,6 @@ xboe:
|
||||
image:
|
||||
course:
|
||||
default: https://u-pre.boe.com/pc/images/bgimg/course.png
|
||||
case:
|
||||
ai:
|
||||
base-url: http://10.10.181.114:30003
|
||||
app-key: 6e9be45319184ac793aa127c362b0f0b
|
||||
secret-key: db4d24279e3d6dbf1524af42cd0bedd2
|
||||
ai-api-code: 30800
|
||||
chat-api-code: 32065
|
||||
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff
|
||||
caseDetailUrlBase: https://u-pre.boe.com/pc/case/detail?id=
|
||||
file-upload-callback-url: http://10.251.186.27:9090/xboe/m/boe/caseDocumentLog/uploadCallback
|
||||
use-white-list: true
|
||||
white-user-code-list:
|
||||
- "00004409"
|
||||
- "10361430"
|
||||
- "10867319"
|
||||
- "00004746"
|
||||
- "00004701"
|
||||
- "00004471"
|
||||
- "11311660"
|
||||
- "10157955"
|
||||
- "10726944"
|
||||
- "110408"
|
||||
- "10768019"
|
||||
- "137812"
|
||||
- "107863"
|
||||
- "10046607"
|
||||
- "110858"
|
||||
- "98000352"
|
||||
- "101215"
|
||||
- "00005011"
|
||||
- "10827857"
|
||||
- "11339772"
|
||||
alert-email-recipients:
|
||||
- chengmeng@boe.com.cn
|
||||
ai-chat-root-path: /home/www/elearning/upload/ai/chat
|
||||
jasypt:
|
||||
encryptor:
|
||||
algorithm: PBEWithMD5AndDES
|
||||
@@ -154,11 +119,14 @@ jasypt:
|
||||
boe:
|
||||
domain: http://10.251.186.27
|
||||
|
||||
kjb:
|
||||
aicoreUrl: http://10.251.186.27:8088
|
||||
|
||||
ok:
|
||||
http:
|
||||
connect-timeout: 30
|
||||
read-timeout: 300
|
||||
write-timeout: 300
|
||||
read-timeout: 30
|
||||
write-timeout: 30
|
||||
max-idle-connections: 200
|
||||
keep-alive-duration: 300
|
||||
|
||||
|
||||
@@ -15,8 +15,6 @@ spring:
|
||||
time-zone: GMT+8
|
||||
mvc:
|
||||
static-path-pattern: /cdn/**
|
||||
async:
|
||||
request-timeout: 600000
|
||||
jpa:
|
||||
database: MYSQL
|
||||
show-sql: false
|
||||
@@ -46,8 +44,8 @@ server:
|
||||
ok:
|
||||
http:
|
||||
connect-timeout: 30
|
||||
read-timeout: 300
|
||||
write-timeout: 300
|
||||
read-timeout: 30
|
||||
write-timeout: 30
|
||||
max-idle-connections: 200
|
||||
keep-alive-duration: 300
|
||||
boe:
|
||||
|
||||
Reference in New Issue
Block a user