Compare commits

..

79 Commits

Author SHA1 Message Date
huangrun
3ae0984495 提交注释 2025-12-11 16:45:02 +08:00
xu
37d444800a Merge branch 'refs/heads/release-20250328-master-xc' into test1031 2025-11-10 16:47:49 +08:00
xu
8ff8703576 【bug:SZX-1155】在线课程管理列表中,增加两列:审核人和审核时间。 2025-11-05 15:50:44 +08:00
xu
d5b774a9ad 社招新员工数据迁移。 2025-11-04 15:09:42 +08:00
liu.zixi
770f467523 [DAT] 配合业务处理挡板 2025-10-31 10:37:28 +08:00
liu.zixi
70a537781c [DAT] 对话接口加新的apiCode 2025-10-31 10:37:27 +08:00
liu.zixi
918d444f36 [DAT] 数据挡板:业务处理失败 2025-10-31 10:37:25 +08:00
liu.zixi
ef28650966 [DAT] 数据挡板:更新时,删除成功新增失败 2025-10-31 10:37:24 +08:00
liu.zixi
8188810f5d [DAT] 重试时根据上一次执行步骤来决定 2025-10-31 10:37:23 +08:00
liu.zixi
ad981eb49d [DAT] 数据挡板:接口调用失败挡板去除 2025-10-31 10:37:21 +08:00
liu.zixi
dae2e29b93 [DAT] 数据挡板:更改时新增失败 2025-10-31 10:37:20 +08:00
liu.zixi
6a73dc60dd [DAT] 数据挡板:新增、删除、更改全挡 2025-10-31 10:37:19 +08:00
liu.zixi
66cbf57387 [DAT] from改为带@的全称 2025-10-31 10:37:18 +08:00
liu.zixi
fafb584213 [DAT] 告警邮件配置 2025-10-31 10:37:17 +08:00
liu.zixi
50cf9fa4fb [DAT] 增加白名单配置 2025-10-31 10:37:15 +08:00
liu.zixi
e4ada3e3c5 [DAT] email更换 2025-10-31 10:37:14 +08:00
liu.zixi
7eb98eece4 [DAT] 去挡板 2025-10-31 10:37:13 +08:00
liu.zixi
c103ea2605 [DAT] 接口失败时,业务状态设为null 2025-10-31 10:37:12 +08:00
liu.zixi
9616c819b3 [DAT] upload时应当为接口失败 2025-10-31 10:37:11 +08:00
liu.zixi
93d5b30489 [DAT] upload加挡板 2025-10-31 10:37:09 +08:00
liu.zixi
cd3bb38390 [DAT] 文档去重 2025-10-31 10:37:08 +08:00
liu.zixi
dab0efb010 [DAT] 显示摘要 2025-10-31 10:37:07 +08:00
liu.zixi
d7acd100b5 [DAT] 去挡板 2025-10-31 10:37:06 +08:00
liu.zixi
abb6cf5516 [DAT] 修复时间错误的问题;尝试修复发邮件 2025-10-31 10:37:04 +08:00
liu.zixi
4fab87998d [DAT] 接口调用失败的数据挡板2 2025-10-31 10:37:03 +08:00
liu.zixi
ceaeda8614 [DAT] 接口调用失败的数据挡板 2025-10-31 10:37:02 +08:00
liu.zixi
636d67165d [DAT] 发邮件增加日志打印 2025-10-31 10:37:01 +08:00
liu.zixi
253eb4ee2e [DAT] 放开重试挡板 2025-10-31 10:36:59 +08:00
liu.zixi
a811b675e7 [DAT] 打日志查看 2025-10-31 10:36:58 +08:00
liu.zixi
1f28daedc5 [DAT] 新增失败时发邮件 2025-10-31 10:36:57 +08:00
liu.zixi
147b74d99c [DAT] 批处理更改responseBody 2025-10-31 10:36:56 +08:00
liu.zixi
4b0a5a8761 [DAT] 去掉com.sun.mail依赖 2025-10-31 10:36:54 +08:00
liu.zixi
b90da03486 [DAT] 发送邮件实现方式再次修改 2025-10-31 10:36:53 +08:00
liu.zixi
4c8e228fa2 [DAT] 发送邮件实现方式修改 2025-10-31 10:36:51 +08:00
liu.zixi
a0a22ead1b [DAT] 调用时间查询逻辑修改 2025-10-31 10:36:50 +08:00
liu.zixi
8a03b3a983 [DAT] 修改update方法调试 2025-10-31 10:36:49 +08:00
liu.zixi
f864e8ba66 [DAT] 删除时修改数据查询条件 2025-10-31 10:36:48 +08:00
liu.zixi
5c4234a3b7 [DAT] 修改update方法只删除不上传的错误 2025-10-31 10:36:46 +08:00
liu.zixi
27c84faa48 [DAT] 照原型数据更新 2025-10-31 10:36:45 +08:00
liu.zixi
0304fc10f1 DAT测试配合 2025-10-31 10:36:44 +08:00
liu.zixi
a12c1f410b 案例专家:增加部分情况下的日志记录 2025-10-31 10:36:42 +08:00
liu.zixi
7b08d26da6 案例专家:修正调用逻辑 2025-10-31 10:36:41 +08:00
liu.zixi
d143ceeb4c 案例专家:新数据处理 2025-10-31 10:36:40 +08:00
liu.zixi
45192a3140 换日志级别,调试 2025-10-31 10:36:38 +08:00
liu.zixi
98f4356a49 延长 Spring Boot 异步请求超时 2025-10-31 10:36:37 +08:00
liu.zixi
8f0b579f6b okhttp的超时时长调到300秒 2025-10-31 10:36:36 +08:00
liu.zixi
6a8a9e5c87 整理es相关代码;增加手动调试用接口 2025-10-31 10:36:34 +08:00
liu.zixi
1898252fc1 案例专家:是否深度思考做成入参,先关闭思考 2025-10-31 10:36:33 +08:00
liu.zixi
cb448a09a3 案例专家:es修改索引格式、添加event-stream专属线程池 2025-10-31 10:36:32 +08:00
liu.zixi
c48c0a0f86 案例专家:yml中的用户列表加双引号 2025-10-31 10:36:31 +08:00
liu.zixi
cb103442e7 案例专家:修改白名单校验逻辑 2025-10-31 10:36:29 +08:00
liu.zixi
24bc40b6ec 案例专家:修改yml文件一个配置的写法 2025-10-31 10:36:28 +08:00
liu.zixi
d75dc2b7b5 案例专家:日志等级修改 2025-10-31 10:36:26 +08:00
liu.zixi
75478cbda7 案例专家:增加手动刷新索引功能 2025-10-31 10:36:25 +08:00
liu.zixi
bf555b1070 案例专家:userId更换成code 2025-10-31 10:36:24 +08:00
liu.zixi
8ae8a650fd 案例专家:userId更换成code 2025-10-31 10:36:23 +08:00
liu.zixi
f7f7a928b2 案例专家:打印入参,调试用 2025-10-31 10:36:22 +08:00
liu.zixi
f465c39b83 案例专家:修改log等级,观察联调 2025-10-31 10:36:20 +08:00
liu.zixi
a2f65a8a29 案例专家:修改批处理问题 2025-10-31 10:36:18 +08:00
liu.zixi
28c3812260 案例专家:邮件告警逻辑 2025-10-31 10:36:17 +08:00
liu.zixi
fa125b29cc 批处理:JobHandler开发 2025-10-31 10:36:15 +08:00
liu.zixi
f35ab10bd2 批处理:JobHandler开发 2025-10-31 10:36:14 +08:00
liu.zixi
d0af06b572 案例助手:代码整理和部分问题修复 2025-10-31 10:36:12 +08:00
liu.zixi
5610289893 案例助手:修复找不到旧会话的bug 2025-10-31 10:36:11 +08:00
liu.zixi
b4103bd4e5 案例助手:聊天接口兼容application/json 2025-10-31 10:36:10 +08:00
liu.zixi
72399eff18 案例助手:增加@Transactional注解 2025-10-31 10:36:08 +08:00
liu.zixi
952301b095 案例助手:增加字段,增加白名单机制等 2025-10-31 10:36:07 +08:00
liu.zixi
0eff0123ca 案例助手:聊天增加上传时间和企业信息 2025-10-31 10:36:05 +08:00
liu.zixi
4d3d4978aa 修复清空日志的bug 2025-10-31 10:36:03 +08:00
liu.zixi
abb036d769 三方接口异步处理 2025-10-31 10:36:02 +08:00
liu.zixi
fe2422574c 返回conversationId 2025-10-31 10:36:00 +08:00
liu.zixi
efe17f3b72 文件读取逻辑纠正 2025-10-31 10:35:58 +08:00
liu.zixi
1aa804118e 修正AI接口的数据入库逻辑 2025-10-31 10:35:56 +08:00
liu.zixi
bd2b372333 修改不同环境回调地址 2025-10-31 10:35:54 +08:00
liu.zixi
8ba8651988 修正编译错误 2025-10-31 10:35:53 +08:00
liu.zixi
ece950fddc 修正编译错误;
增加临时接口
2025-10-31 10:35:52 +08:00
liu.zixi
622c3bdd5b AI调用日志 重试功能补完 2025-10-31 10:35:50 +08:00
liu.zixi
278336c9f7 案例专家功能提交 2025-10-31 10:35:49 +08:00
670788339
264a581df8 Merge branch 'master-20251023-tag' into test1031
# Conflicts:
#	servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseManageApi.java
#	servers/boe-server-all/src/main/java/com/xboe/module/course/service/impl/CourseServiceImpl.java
2025-10-31 10:20:09 +08:00
80 changed files with 1142 additions and 4103 deletions

View File

@@ -266,10 +266,6 @@
<artifactId>xxl-job-core</artifactId>
<version>2.3.0</version> <!-- 请根据实际需求选择版本 -->
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
</dependency>
</dependencies>
<build>

View File

@@ -60,9 +60,6 @@ public class ThirdApi {
@Value("${orgTree.orgChildTreeList}")
private String orgChildTreeListUrl;
@Value("${userBasic.getUserBasicInfo}")
private String getUserBasicInfo;
@Autowired
UserDao userDao;
@@ -369,62 +366,6 @@ public class ThirdApi {
}
/**
* 虽然当前已存在接口查询用户基本信息目前仅仅包括用户名、工号、用户ID
*/
public List<UserBasicInfoVo> getUserBasicInfoByWorkNums(List<String> workNums) {
UserBasicInfoDto userBasicInfoDto = new UserBasicInfoDto();
userBasicInfoDto.setWorkNums(workNums);
Response<List<UserAccount>> response = userRemoteClient.getUserBasicInfo(userBasicInfoDto);
String respStr = JSON.toJSONString(response);
UserBasicInfoResultVo userBasicInfoResult = JSONUtil.parseObj(respStr).toBean(UserBasicInfoResultVo.class);
List<UserBasicInfoVo> basicInfos = userBasicInfoResult.getResult();
return basicInfos;
}
public List<UserBasicInfoVo> getUserBasicInfoByWorkNums2(String workNum, String token) {
try {
// 参数校验
if (StringUtils.isBlank(workNum)) {
log.warn("getUserBasicInfoByWorkNums2 workNum为空");
return Collections.emptyList();
}
// 构建URL参数将单个workNum作为列表参数传递
Map<String, Object> params = new HashMap<>();
params.put("workNums", Collections.singletonList(workNum));
log.info("getUserBasicInfoByWorkNums2 请求参数: workNum={}, url={}", workNum, getUserBasicInfo);
// 发送HTTP GET请求
String responseStr = HttpRequest.get(getUserBasicInfo)
.form(params)
.header("token", token)
.execute()
.body();
log.info("getUserBasicInfoByWorkNums2 响应结果: {}", responseStr);
// 解析响应
UserBasicInfoResultVo resultVo = JSONUtil.parseObj(responseStr).toBean(UserBasicInfoResultVo.class);
log.info("getUserBasicInfoByWorkNums2 解析结果: {}", resultVo);
if (resultVo != null && resultVo.getStatus() == 200 && resultVo.getResult() != null) {
return resultVo.getResult();
} else {
log.error("getUserBasicInfoByWorkNums2 请求失败: status={}, message={}",
resultVo != null ? resultVo.getStatus() : "null",
resultVo != null ? resultVo.getMessage() : "响应为空");
return Collections.emptyList();
}
} catch (Exception e) {
log.error("getUserBasicInfoByWorkNums2 HTTP请求异常: workNum={}", workNum, e);
return Collections.emptyList();
}
}
public void updateOrSaveCourse(CourseParam param, String token){
log.info("---------------准备同步在线课到讲师管理完毕 ------- param " + param);
String resp = Optional.ofNullable(

View File

@@ -1,35 +0,0 @@
package com.xboe.api.vo;
import cn.hutool.json.JSONUtil;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
import java.util.List;
@Data
@Slf4j
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UserBasicInfoResultVo {
private String error;
private String message;
private String permissions;
private List<UserBasicInfoVo> result;
private int status;
private Date timestamp;
public UserBasicInfoResultVo success() {
if (this.status != 200) {
log.error("获取用户基本信息失败----{}", JSONUtil.toJsonPrettyStr(this));
return null;
}
return this;
}
}

View File

@@ -1,27 +0,0 @@
package com.xboe.api.vo;
import lombok.Data;
@Data
public class UserBasicInfoVo {
/**
* 用户ID
*/
private String userId;
/**
* 用户名。
*/
private String userName;
/**
* 工号。
*/
private String workNum;
/**
* 邮箱
*/
private String email;
}

View File

@@ -1,39 +0,0 @@
package com.xboe.config;
import org.apache.activemq.command.ActiveMQTopic;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jms.annotation.EnableJms;
import org.springframework.jms.config.DefaultJmsListenerContainerFactory;
import org.springframework.jms.config.JmsListenerContainerFactory;
import javax.jms.ConnectionFactory;
import javax.jms.Topic;
@EnableJms
@Configuration
public class MqConfig {
@Value("${activemq.topic.name}")
private String topicName;
/**
* 配置topic
*/
@Bean
public Topic broadcastTopic() {
return new ActiveMQTopic(topicName);
}
// 配置JmsListenerContainerFactory为发布/订阅模式
@Bean
public JmsListenerContainerFactory<?> jmsListenerContainerFactory(ConnectionFactory connectionFactory) {
DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
factory.setConnectionFactory(connectionFactory);
factory.setPubSubDomain(true); // 设置为发布/订阅模式
factory.setSubscriptionDurable(false); // 非持久订阅
return factory;
}
}

View File

@@ -65,24 +65,6 @@ public class ThreadPoolConfig {
return executor;
}
/**
* 异步存会话数据线程池
* @return
*/
@Bean(name = "esChatExecutor")
public ThreadPoolTaskExecutor esChatExecutor() {
ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
executor.setCorePoolSize(10);
executor.setMaxPoolSize(500);
executor.setQueueCapacity(10);
executor.setThreadNamePrefix("es-chat-");
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());

View File

@@ -7,8 +7,4 @@ public class CaseAiConstants {
public static final String CASE_DOC_UPLOAD_INTERFACE_NAME = "文档上传";
public static final String CASE_DOC_DELETE_INTERFACE_NAME = "文档删除";
public static final String CHAT_SYS_ERR_MSG = "当前无法获取回答,请稍后重试";
public static final String CHAT_NET_ERR_MSG = "网络异常,请稍后再试";
}

View File

@@ -163,7 +163,7 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
//老师信息
//if(u.getUserType()!=null && u.getUserType()==2) {
/*if ((user.getTeacher() != null && user.getTeacher()) || (user.getUserType() != null && user.getUserType() == 2)) {
if ((user.getTeacher() != null && user.getTeacher()) || (user.getUserType() != null && user.getUserType() == 2)) {
Teacher t = teacherDao.get(user.getId());
log.info("用户有教师身份,处理教师身份");
if (t == null) {
@@ -182,7 +182,7 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
} else {
log.info("教师身份已存在,不再添加");
}
}*/
}
log.info("同步用户完成");
}

View File

@@ -1,33 +0,0 @@
package com.xboe.enums;
import lombok.Getter;
import java.util.Arrays;
/**
* 错误码枚举
*/
@Getter
public enum CaseAiChatErrCodeEnum {
SUCCESS(0, "成功"),
INTERNAL_ERROR(1, "内部错误"),
AIOT_ERROR(2, "AIoT平台错误"),
;
private final int code;
private final String label;
CaseAiChatErrCodeEnum(int code, String label) {
this.code = code;
this.label = label;
}
public static CaseAiChatErrCodeEnum getByCode(int code) {
return Arrays.stream(values()).filter(e -> e.code == code)
.findFirst().orElse(SUCCESS);
}
}

View File

@@ -56,11 +56,12 @@ public class EmailServiceImpl implements IEmailService {
String cfgWord=SysConstant.getConfigValue("xboe.email.security");
Map<String,Object> data=new HashMap<String,Object>();
// php剥离不再使用老系统发邮件使用基础服务的发邮件功能
data.put("email",to);
data.put("title",subject);
data.put("to",to);
data.put("subject",subject);
data.put("content", htmlMsg);
data.put("userName", cfgUser);
data.put("fromName", cfgFrom);
data.put("cc", "");
data.put("type", 0);
ObjectMapper mapper=new ObjectMapper();
String json=mapper.writeValueAsString(data);

View File

@@ -1,7 +1,6 @@
package com.xboe.module.assistance.service.impl;
import java.util.Date;
import java.util.List;
import java.util.Properties;
import javax.mail.Authenticator;
@@ -23,13 +22,12 @@ import com.xboe.module.assistance.service.ISmtpEmailService;
@Slf4j
public class SmtpEmailServiceImpl implements ISmtpEmailService {
//region 默认SMTP服务器配置信息
// 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_PASSWORD = "boeLms20250814Syse";
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 {
@@ -45,7 +43,6 @@ public class SmtpEmailServiceImpl implements ISmtpEmailService {
if (StringUtils.isBlank(htmlMsg)) {
throw new Exception("发送邮件失败,未指定邮件内容");
}
// 初始化配置项
// 设置SMTP属性
Properties props = new Properties();

View File

@@ -3,16 +3,12 @@ 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.dto.CaseAiMsgLikeDto;
import com.xboe.module.boecase.dto.EsFieldDTO;
import com.xboe.module.boecase.dto.GetCaseAiMsgDto;
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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
@@ -20,14 +16,12 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.servlet.http.HttpServletResponse;
import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* AI对话管理API
*/
@Slf4j(topic = "caseAiChatLogger")
@Slf4j
@RestController
@RequestMapping(value = "/xboe/m/boe/case/ai")
public class CaseAiChatApi extends ApiBaseController {
@@ -47,25 +41,6 @@ public class CaseAiChatApi extends ApiBaseController {
@Autowired
private IElasticSearchIndexService elasticSearchIndexService;
/**
* 初始化会话
* @return 会话id
*/
@GetMapping("/initChat")
public JsonResponse<String> initChat() {
try {
String conversationId = caseAiChatService.initChat(getCurrent());
if (StringUtils.isNotBlank(conversationId)) {
return success(conversationId, "初始化会话成功");
} else {
return success(conversationId, "初始化会话失败");
}
} catch (Exception e) {
log.error("初始化会话异常", e);
return error("初始化会话失败", e.getMessage());
}
}
/**
* 聊天
* @param caseAiChatDto
@@ -81,84 +56,7 @@ public class CaseAiChatApi extends ApiBaseController {
// 获取当前用户
return caseAiChatService.chat(caseAiChatDto, getCurrent());
}
/**
* 停止当前聊天输出
* @param conversationId 会话ID
* @return 是否成功停止
*/
@GetMapping("/stop")
public JsonResponse<Boolean> stopChat(@RequestParam String conversationId) {
try {
boolean result = caseAiChatService.stopChatOutput(conversationId);
if (result) {
return success(true, "成功停止输出");
} else {
return success(false, "未找到对应的会话或会话已结束");
}
} catch (Exception e) {
log.error("停止聊天输出异常", e);
return error("停止输出失败", e.getMessage());
}
}
/**
* 赞消息
* @param caseAiMsgLikeDto
* @return
*/
@PostMapping("/likeMsg")
public JsonResponse<Boolean> likeMsg(@RequestBody CaseAiMsgLikeDto caseAiMsgLikeDto) {
try {
caseAiMsgLikeDto.setOperation(true);
if (caseAiChatService.msgFeedback(caseAiMsgLikeDto)) {
return success(true, "保存成功");
} else {
return success(false, "保存失败");
}
} catch (Exception e) {
log.error("消息赞/踩操作保存异常", e);
return error("保存失败", e.getMessage());
}
}
/**
* 消息问题反馈保存
* @param caseAiMsgLikeDto
* @return
*/
@PostMapping("/msgFeedback")
public JsonResponse<Boolean> msgFeedback(@RequestBody CaseAiMsgLikeDto caseAiMsgLikeDto) {
try {
caseAiMsgLikeDto.setOperation(false);
if (caseAiChatService.msgFeedback(caseAiMsgLikeDto)) {
return success(true, "保存成功");
} else {
return success(false, "保存失败");
}
} catch (Exception e) {
log.error("消息问题反馈保存异常", e);
return error("保存失败", e.getMessage());
}
}
/**
* 获取消息
*
* @param getCaseAiMsgDto
*/
@PostMapping("/getCaseAiMsg")
public JsonResponse<List<CaseAiMessageVo>> getCaseAiMsgDetail(@RequestBody GetCaseAiMsgDto getCaseAiMsgDto) {
try {
List<CaseAiMessageVo> caseAiMessageVoList = caseAiChatService.getCaseAiMsg(getCaseAiMsgDto);
return success(caseAiMessageVoList);
} catch (Exception e) {
log.error("获取消息详情异常", e);
return error("获取失败", e.getMessage());
}
}
/**
* 根据conversationId查看会话内消息记录
* @param conversationId 会话ID
@@ -175,22 +73,6 @@ public class CaseAiChatApi extends ApiBaseController {
}
}
/**
* 导出会话记录为Excel
* @param startTime 开始时间
* @param endTime 结束时间
* @param response HTTP响应
*/
@GetMapping("/export-conversations")
public void downloadConversationExcel(@RequestParam String startTime,
@RequestParam String endTime,
HttpServletResponse response) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
LocalDate startDate = LocalDate.parse(startTime, formatter);
LocalDate endDate = LocalDate.parse(endTime, formatter);
caseAiChatService.getConversationExcel(startDate.atStartOfDay(), endDate.atTime(23, 59, 59), response);
}
/**
* 判断当前登录用户是否显示"案例专家"功能入口
* @return 是否显示功能入口
@@ -200,10 +82,7 @@ public class CaseAiChatApi extends ApiBaseController {
try {
String currentUserCode = getCurrent().getCode();
boolean shouldShow = caseAiPermissionService.shouldShowCaseAiEntrance(currentUserCode);
// return success(shouldShow);
JsonResponse<Boolean> result = success(shouldShow);
result.setMessage(currentUserCode);
return result;
return success(shouldShow);
} catch (Exception e) {
log.error("判断案例专家功能入口显示权限异常", e);
return error("判断失败", e.getMessage());
@@ -228,17 +107,6 @@ public class CaseAiChatApi extends ApiBaseController {
return error("刷新失败");
}
/**
* 添加索引字段
* @param esFieldDTO
* @return
*/
@PostMapping("/index/add_field")
public JsonResponse<String> addField(@RequestBody EsFieldDTO esFieldDTO) {
boolean result = elasticSearchIndexService.updateIndex(esFieldDTO.getFieldName(), esFieldDTO.getIndexProperties());
return result ? success("添加成功") : error("添加失败");
}
@PostMapping("/es/create")
public JsonResponse<String> createNewConversation(@RequestBody CaseAiMessageVo caseAiMessageVo,
@RequestParam String conversationId,
@@ -250,9 +118,9 @@ public class CaseAiChatApi extends ApiBaseController {
aiChatConversationData.setCaseRefers(caseAiMessageVo.getCaseRefer());
aiChatConversationData.setSuggestions(caseAiMessageVo.getSuggestions());
aiChatConversationData.setUserId(userId);
if (elasticSearchIndexService.createData(aiChatConversationData) != null) {
if (elasticSearchIndexService.createData(aiChatConversationData)) {
return success("创建成功");
}
return error("创建失败");
}
}
}

View File

@@ -1,6 +1,5 @@
package com.xboe.module.boecase.api;
import com.xboe.module.boecase.task.CaseUploadTask;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
@@ -21,21 +20,14 @@ 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(CaseUploadTask.CASE_UPLOAD_LAST_ID_KEY);
log.info("已清除上次处理位置标记");
}
/**
* 清除处理位置标记,使下次任务从头开始执行
*/
@PostMapping("/reload/reset")
public void resetReloadProcessedId() {
stringRedisTemplate.delete(CaseUploadTask.CASE_RELOAD_LAST_ID_KEY);
stringRedisTemplate.delete(CASE_UPLOAD_LAST_ID_KEY);
log.info("已清除上次处理位置标记");
}
}

View File

@@ -17,11 +17,6 @@ public class CaseAiDocumentAsyncHandler {
private final AtomicInteger currentTaskCount = new AtomicInteger(0);
/**
* 限流默认QPS 40
*/
private final TokenBucketRateLimiter rateLimiter = new TokenBucketRateLimiter(40);
@Autowired
@Qualifier("aiDocExecutor")
private ThreadPoolTaskExecutor aiDocExecutor;
@@ -32,7 +27,7 @@ public class CaseAiDocumentAsyncHandler {
public void process(CaseDocumentLogOptTypeEnum optTypeEnum, Cases... caseList) {
for (Cases cases : caseList) {
// 控制并发数量
while (currentTaskCount.get() >= 5) {
while (currentTaskCount.get() >= 15) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
@@ -44,13 +39,8 @@ public class CaseAiDocumentAsyncHandler {
currentTaskCount.incrementAndGet();
aiDocExecutor.submit(() -> {
try {
// 限流
rateLimiter.acquire();
processCases(cases, optTypeEnum);
} finally {
currentTaskCount.decrementAndGet();
}
processCases(cases, optTypeEnum);
currentTaskCount.decrementAndGet();
});
}
}

View File

@@ -1,55 +0,0 @@
package com.xboe.module.boecase.async;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
/**
* 令牌桶限流算法实现
*/
public class TokenBucketRateLimiter {
private final double permitsPerSecond; // 每秒生成的令牌数(即 TPS
private final AtomicLong nextFreeTicketMicros = new AtomicLong(0); // 下一个令牌可用的时间(微秒)
private final AtomicLong storedPermits = new AtomicLong(0); // 当前桶中存储的令牌数(本简化版不支持突发,可省略)
private static final long MICROSECONDS_PER_SECOND = 1_000_000L;
public TokenBucketRateLimiter(double permitsPerSecond) {
this.permitsPerSecond = permitsPerSecond;
this.nextFreeTicketMicros.set(System.nanoTime() / 1000); // 初始化为当前时间(微秒)
}
/**
* 获取一个令牌,阻塞直到可用
*/
public void acquire() {
long waitMicros = reserve(1);
if (waitMicros > 0) {
try {
long waitNanos = waitMicros * 1000; // 转为纳秒
TimeUnit.NANOSECONDS.sleep(waitNanos);
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
}
}
}
/**
* 预留 1 个令牌,返回需要等待的微秒数
*/
private long reserve(int permits) {
long nowMicros = System.nanoTime() / 1000;
long nextFreeTicket = nextFreeTicketMicros.get();
long waitMicros = Math.max(0, nextFreeTicket - nowMicros);
long newNextFreeTicket = nowMicros + waitMicros + (long) (permits * MICROSECONDS_PER_SECOND / permitsPerSecond);
while (!nextFreeTicketMicros.compareAndSet(nextFreeTicket, newNextFreeTicket)) {
// CAS 失败,说明其他线程修改了时间,重试
nowMicros = System.nanoTime() / 1000;
nextFreeTicket = nextFreeTicketMicros.get();
waitMicros = Math.max(0, nextFreeTicket - nowMicros);
newNextFreeTicket = nowMicros + waitMicros + (long) (permits * MICROSECONDS_PER_SECOND / permitsPerSecond);
}
return waitMicros;
}
}

View File

@@ -1,32 +0,0 @@
package com.xboe.module.boecase.dto;
import lombok.Data;
@Data
public class CaseAiMsgLikeDto {
/**
* 文档id
*/
private String docId;
/**
* 点赞状态:
* -1 踩
* 1 赞
* 0/null 无操作
*/
private String likeStatus;
/**
* 反馈
*/
private String feedback;
/**
* 操作
* true: 点踩
* false: 反馈
* 为空:其他情况
*/
private Boolean operation;
}

View File

@@ -1,49 +0,0 @@
package com.xboe.module.boecase.dto;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
@Data
public class EsFieldDTO {
/**
* 字段名称
*/
private String fieldName;
/**
* 字段属性
*/
private Properties properties;
public Map<String, Object> getIndexProperties() {
Map<String, Object> indexProperties = new HashMap<>();
if (properties != null) {
indexProperties.put("type", properties.type);
if (properties.index != null) {
indexProperties.put("index", properties.index);
}
if (StringUtils.isNotBlank(properties.analyzer)) {
indexProperties.put("analyzer", properties.analyzer);
}
if (StringUtils.isNotBlank(properties.searchAnalyzer)) {
indexProperties.put("search_analyzer", properties.searchAnalyzer);
}
}
return indexProperties;
}
@Data
public static class Properties {
private String type;
private Boolean index;
private String analyzer;
private String searchAnalyzer;
}
}

View File

@@ -1,16 +0,0 @@
package com.xboe.module.boecase.dto;
import lombok.Data;
@Data
public class GetCaseAiMsgDto {
/**
* 会话Id
*/
private String conversationId;
/**
* ES DocId
*/
private String docId;
}

View File

@@ -34,19 +34,6 @@ public class AiChatConversationData {
*/
private StringBuilder answer = new StringBuilder();
/**
* 状态
* 0-正常
* 1-系统错误
* 2-AIoT平台错误
*/
private Integer status;
/**
* 错误信息
*/
private String errorMsg;
/**
* 案例引用列表
*/
@@ -57,20 +44,6 @@ public class AiChatConversationData {
*/
private List<String> suggestions = new ArrayList<>();
/**
* 用户点赞状态
* -1: 踩
* 1
* 0/null 无操作
*/
private String likeStatus;
/**
* 用户踩的时候, 可以填写反馈意见
* 反馈意见
*/
private String feedback;
/**
* 用户ID
*/
@@ -81,27 +54,28 @@ public class AiChatConversationData {
*/
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();
this.timestamp = LocalDateTime.now();
}
public AiChatConversationData(String conversationId, String query, String answer,
List<CaseReferVo> caseRefers, List<String> suggestions,
String userId) {
this.conversationId = conversationId;
this.query = query;
this.answer = new StringBuilder(answer != null ? answer : "");
this.caseRefers = caseRefers != null ? caseRefers : new ArrayList<>();
this.suggestions = suggestions != null ? suggestions : new ArrayList<>();
this.userId = userId;
this.timestamp = LocalDateTime.now();
}
// ================== 便捷方法 ==================

View File

@@ -93,12 +93,4 @@ public class CaseDocumentLog extends BaseEntity {
*/
@Column(name = "execute_duration")
private Long executeDuration;
/**
* 元数据处理状态
* 0-未处理
* 1-已处理
*/
@Column(name = "metadata_status")
private Integer metadataStatus;
}

View File

@@ -1,27 +0,0 @@
package com.xboe.module.boecase.mq;
import com.xboe.module.boecase.service.ICaseAiChatService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class BroadcastMessageConsumer {
@Autowired
private ICaseAiChatService iCaseAiChatService;
/**
* 接收会话终止广播消息
*
* @param conversationId 会话ID
*/
@JmsListener(destination = "${activemq.topic.name}")
public void receiveSessionTerminationBroadcastMessage(String conversationId) {
log.info("收到会话终止广播消息:{}", conversationId);
iCaseAiChatService.eventSourceCancel(conversationId);
}
}

View File

@@ -48,11 +48,6 @@ public class CaseAiProperties {
*/
private String defaultUploadUser;
/**
* 案例详情页面地址
*/
private String caseDetailUrlBase;
/**
* 文件上传是否使用回调接口
*/
@@ -77,14 +72,4 @@ public class CaseAiProperties {
* AI处理失败告警邮件收件人列表
*/
private List<String> alertEmailRecipients;
/**
* 是否发送AI对话记录到邮箱
*/
private boolean aiChatDataSendEmail;
/**
* AI对话记录保存根路径
*/
private String aiChatRootPath;
}

View File

@@ -2,14 +2,10 @@ package com.xboe.module.boecase.service;
import com.xboe.core.CurrentUser;
import com.xboe.module.boecase.dto.CaseAiChatDto;
import com.xboe.module.boecase.dto.CaseAiMsgLikeDto;
import com.xboe.module.boecase.dto.GetCaseAiMsgDto;
import com.xboe.module.boecase.entity.CaseAiConversations;
import com.xboe.module.boecase.vo.CaseAiMessageVo;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -17,16 +13,8 @@ import java.util.List;
*/
public interface ICaseAiChatService {
/**
* 初始化会话
*
* @return {@link String } 会话id
*/
String initChat(CurrentUser currentUser);
/**
* 聊天
*
* @param caseAiChatDto
* @param currentUser
* @return
@@ -35,8 +23,7 @@ public interface ICaseAiChatService {
/**
* 创建新的AI对话会话
*
* @param userId 用户ID
* @param userId 用户ID
* @param conversationName 对话名称
* @return 创建的会话信息
*/
@@ -44,56 +31,8 @@ public interface ICaseAiChatService {
/**
* 根据conversationId查看会话内消息记录
*
* @param conversationId 会话ID
* @return 消息记录列表
*/
List<CaseAiMessageVo> getConversationMessages(String conversationId);
/**
* 导出会话记录为Excel
* @param startTime 开始时间
* @param endTime 结束时间
* @param response
*/
void getConversationExcel(LocalDateTime startTime, LocalDateTime endTime, HttpServletResponse response);
/**
* 导出会话记录为Excel
*
* @param startTime 开始时间
* @param endTime 结束时间
*/
void downloadConversationExcel(LocalDateTime startTime, LocalDateTime endTime);
/**
* 停止当前聊天输出
*
* @param conversationId 会话ID
* @return 是否成功停止
*/
boolean stopChatOutput(String conversationId);
/**
* 取消eventSource
*
* @param conversationId 会话ID
*/
void eventSourceCancel(String conversationId);
/**
* 消息反馈保存
* likeStatus: 踩/赞
* feedBack: 反馈消息内容
*
* @param caseAiMsgLikeDto
*/
boolean msgFeedback(CaseAiMsgLikeDto caseAiMsgLikeDto);
/**
* 获取消息
*
* @param getCaseAiMsgDto
*/
List<CaseAiMessageVo> getCaseAiMsg(GetCaseAiMsgDto getCaseAiMsgDto);
}

View File

@@ -4,7 +4,6 @@ import com.xboe.module.boecase.entity.AiChatConversationData;
import com.xboe.module.boecase.vo.CaseAiMessageVo;
import java.util.List;
import java.util.Map;
/**
* es索引
@@ -13,35 +12,30 @@ public interface IElasticSearchIndexService {
/**
* 查看索引是否存在
* @param indexName
* @return
*/
boolean checkIndexExists();
/**
* 创建索引
* @param indexName
*/
boolean createIndex();
/**
* 删除索引
* @param indexName
* @return
*/
boolean deleteIndex();
/**
* 更新索引:添加索引字段
* @param fieldName
* @param fieldProperties
* @return
*/
boolean updateIndex(String fieldName, Map<String, Object> fieldProperties);
/**
* 新增数据
* @param data
* @return
*/
String createData(AiChatConversationData data);
boolean createData(AiChatConversationData data);
/**
* 查询数据
@@ -49,20 +43,4 @@ public interface IElasticSearchIndexService {
* @return
*/
List<CaseAiMessageVo> queryData(String conversationId);
/**
* 更新数据
* @param docId
* @param data
* @return
*/
boolean updateData(String docId, AiChatConversationData data);
/**
* 通过docId查询数据
*
* @param docId ES docId
* @return
*/
List<CaseAiMessageVo> queryDataByDocId(String docId);
}

View File

@@ -22,7 +22,7 @@ import java.util.concurrent.TimeUnit;
@EnableConfigurationProperties({CaseAiProperties.class})
@Service
@Slf4j(topic = "caseAiChatLogger")
@Slf4j
public class AiAccessTokenServiceImpl implements IAiAccessTokenService {
private static final String ACCESS_TOKEN_CACHE_KEY = "case_ai_access_token";

View File

@@ -17,15 +17,11 @@ import com.xboe.enums.CaseDocumentLogRunStatusEnum;
import com.xboe.module.assistance.service.ISmtpEmailService;
import com.xboe.module.boecase.dao.CaseDocumentLogDao;
import com.xboe.module.boecase.dao.CasesDao;
import com.xboe.module.boecase.dao.CasesMajorTypeDao;
import com.xboe.module.boecase.entity.CaseDocumentLog;
import com.xboe.module.boecase.entity.Cases;
import com.xboe.module.boecase.entity.CasesMajorType;
import com.xboe.module.boecase.properties.CaseAiProperties;
import com.xboe.module.boecase.service.IAiAccessTokenService;
import com.xboe.module.boecase.service.ICaseKnowledgeService;
import com.xboe.module.dict.entity.DictItem;
import com.xboe.module.dict.service.ISysDictionaryService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
@@ -48,8 +44,6 @@ import java.io.File;
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/**
* 案例-知识库Service实现类
@@ -69,15 +63,9 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
@Resource
private CaseDocumentLogDao caseDocumentLogDao;
@Resource
private CasesMajorTypeDao casesMajorTypeDao;
@Resource
private XFileUploader fileUploader;
@Autowired
private ISysDictionaryService sysDictionaryService;
@Autowired
private IAiAccessTokenService aiAccessTokenService;
@@ -137,7 +125,10 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
}
// 4. 构建上传参数
String fileName = file.getName();
String fileName = cases.getFileName();
if (StringUtil.isBlank(fileName)) {
fileName = file.getName();
}
String fileType = getFileType(fileName);
@@ -154,60 +145,6 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN);
requestBody.put("fileType", fileType);
builder.addTextBody("parseType", "AUTO", ContentType.TEXT_PLAIN);
String url = caseAiProperties.getCaseDetailUrlBase() + caseId;
requestBody.put("url", url);
String downloadUrl = fileUploader.getHttpPath() + cases.getFilePath();
requestBody.put("downloadUrl", downloadUrl);
builder.addTextBody("url", url, ContentType.TEXT_PLAIN);
builder.addTextBody("downloadUrl", downloadUrl, ContentType.TEXT_PLAIN);
// metadata
JSONObject fileMetaData = new JSONObject();
fileMetaData.put("标题", cases.getTitle());
fileMetaData.put("作者", cases.getAuthorName());
fileMetaData.put("年份", String.valueOf(cases.getSysCreateTime().getYear()));
fileMetaData.put("摘要", cases.getSummary());
// 组织领域orgDomainParent
String orgDomainParent = cases.getOrgDomainParent();
List<DictItem> orgDomainParentItems = sysDictionaryService.findByKey("org_domain");
Optional<DictItem> orgDomainParentItem = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(orgDomainParent, item.getCode()))
.findFirst();
if (orgDomainParentItem.isPresent()) {
StringBuilder sb = new StringBuilder();
sb.append(orgDomainParentItem.get().getName());
if (StringUtils.isNotBlank(cases.getOrgDomainParent2())) {
Optional<DictItem> orgDomainParent2Item = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(cases.getOrgDomainParent2(), item.getCode()))
.findFirst();
orgDomainParent2Item.ifPresent(dictItem -> sb.append(" - ").append(dictItem.getName()));
if (StringUtils.isNotBlank(cases.getOrgDomainParent3())) {
Optional<DictItem> orgDomainParent3Item = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(cases.getOrgDomainParent3(), item.getCode()))
.findFirst();
orgDomainParent3Item.ifPresent(dictItem -> sb.append(" - ").append(dictItem.getName()));
}
}
fileMetaData.put("组织领域", sb.toString());
}
// 分类majorIds
List<CasesMajorType> cmtList = casesMajorTypeDao.findList(FieldFilters.eq("caseId", cases.getId()));
if (cmtList != null && !cmtList.isEmpty()) {
List<String> majorIds = cmtList.stream().map(CasesMajorType::getMajorId).collect(Collectors.toList());
List<DictItem> majorItems = sysDictionaryService.findByKey("major_type");
if (majorItems != null && !majorItems.isEmpty()) {
List<String> majorNames = majorItems.stream()
.filter(item -> majorIds.contains(item.getCode()))
.map(DictItem::getName)
.collect(Collectors.toList());
fileMetaData.put("组织领域", String.join(", ", majorNames));
}
}
ContentType contentType = ContentType.create("text/plain", StandardCharsets.UTF_8);
builder.addTextBody("fileMetaData", fileMetaData.toJSONString(), contentType);
requestBody.put("fileMetaData", fileMetaData);
// 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态
if (caseAiProperties.isFileUploadUseCallback()) {
builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN);
@@ -246,9 +183,12 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
String taskId = data.getString("taskId");
// 保存成功的CaseDocumentLog记录
// saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.CREATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
// requestBody.toJSONString(), responseBody,
// CaseDocumentLogRunStatusEnum.RUNNING.getCode(), null, null, taskId);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.CREATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), responseBody,
CaseDocumentLogRunStatusEnum.RUNNING.getCode(), null, null, taskId);
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), CaseDocumentLogCaseStatusEnum.FAILED.getCode(), taskId);
log.info("上传案例文档成功,等待文档状态变更. caseId: {}, taskId: {}, 尝试次数: {}", caseId, taskId, attempt);
return true;
@@ -381,8 +321,9 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 接口调用成功,检查业务处理结果
JSONObject data = result.getJSONObject("data");
Boolean deleteSuccess = data.getBoolean(taskId);
int caseStatus = (deleteSuccess != null && deleteSuccess) ?
CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode();
// int caseStatus = (deleteSuccess != null && deleteSuccess) ?
// CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode();
int caseStatus = CaseDocumentLogCaseStatusEnum.FAILED.getCode();
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.DELETE.getCode(), CaseAiConstants.CASE_DOC_DELETE_INTERFACE_NAME,
params, responseBody,
@@ -475,7 +416,10 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
}
// 4. 构建上传参数
String fileName = file.getName();
String fileName = cases.getFileName();
if (StringUtil.isBlank(fileName)) {
fileName = file.getName();
}
String fileType = getFileType(fileName);
@@ -492,60 +436,6 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN);
requestBody.put("fileType", fileType);
builder.addTextBody("parseType", "AUTO", ContentType.TEXT_PLAIN);
String url = caseAiProperties.getCaseDetailUrlBase() + caseId;
requestBody.put("url", url);
String downloadUrl = fileUploader.getHttpPath() + cases.getFilePath();
requestBody.put("downloadUrl", downloadUrl);
builder.addTextBody("url", url, ContentType.TEXT_PLAIN);
builder.addTextBody("downloadUrl", downloadUrl, ContentType.TEXT_PLAIN);
// metadata
JSONObject fileMetaData = new JSONObject();
fileMetaData.put("标题", cases.getTitle());
fileMetaData.put("作者", cases.getAuthorName());
fileMetaData.put("年份", String.valueOf(cases.getSysCreateTime().getYear()));
fileMetaData.put("摘要", cases.getSummary());
// 组织领域orgDomainParent
String orgDomainParent = cases.getOrgDomainParent();
List<DictItem> orgDomainParentItems = sysDictionaryService.findByKey("org_domain");
Optional<DictItem> orgDomainParentItem = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(orgDomainParent, item.getCode()))
.findFirst();
if (orgDomainParentItem.isPresent()) {
StringBuilder sb = new StringBuilder();
sb.append(orgDomainParentItem.get().getName());
if (StringUtils.isNotBlank(cases.getOrgDomainParent2())) {
Optional<DictItem> orgDomainParent2Item = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(cases.getOrgDomainParent2(), item.getCode()))
.findFirst();
orgDomainParent2Item.ifPresent(dictItem -> sb.append(" - ").append(dictItem.getName()));
if (StringUtils.isNotBlank(cases.getOrgDomainParent3())) {
Optional<DictItem> orgDomainParent3Item = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(cases.getOrgDomainParent3(), item.getCode()))
.findFirst();
orgDomainParent3Item.ifPresent(dictItem -> sb.append(" - ").append(dictItem.getName()));
}
}
fileMetaData.put("组织领域", sb.toString());
}
// 分类majorIds
List<CasesMajorType> cmtList = casesMajorTypeDao.findList(FieldFilters.eq("caseId", cases.getId()));
if (cmtList != null && !cmtList.isEmpty()) {
List<String> majorIds = cmtList.stream().map(CasesMajorType::getMajorId).collect(Collectors.toList());
List<DictItem> majorItems = sysDictionaryService.findByKey("major_type");
if (majorItems != null && !majorItems.isEmpty()) {
List<String> majorNames = majorItems.stream()
.filter(item -> majorIds.contains(item.getCode()))
.map(DictItem::getName)
.collect(Collectors.toList());
fileMetaData.put("组织领域", String.join(", ", majorNames));
}
}
ContentType contentType = ContentType.create("text/plain", StandardCharsets.UTF_8);
builder.addTextBody("fileMetaData", fileMetaData.toJSONString(), contentType);
requestBody.put("fileMetaData", fileMetaData);
// 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态
if (caseAiProperties.isFileUploadUseCallback()) {
builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN);
@@ -652,8 +542,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
.findList(CaseDocumentLog.class, 1,
OrderCondition.desc("sysCreateTime"),
FieldFilters.eq("caseId", caseId),
FieldFilters.eq("requestUrl", CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME),
FieldFilters.eq("caseStatus", CaseDocumentLogCaseStatusEnum.SUCCESS.getCode()));
FieldFilters.eq("requestUrl", CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME));
if (logList.isEmpty()) {
log.info("删除案例文档失败未找到相关的日志记录caseId: {}", caseId);
@@ -713,21 +602,22 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 接口调用成功,检查业务处理结果
JSONObject data = result.getJSONObject("data");
Boolean deleteSuccess = data.getBoolean(deleteTaskId);
int caseStatus = (deleteSuccess != null && deleteSuccess) ?
CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode();
// int caseStatus = (deleteSuccess != null && deleteSuccess) ?
// CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode();
int caseStatus = CaseDocumentLogCaseStatusEnum.FAILED.getCode();
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_DELETE_INTERFACE_NAME,
params, responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), caseStatus, null);
if (deleteSuccess != null && deleteSuccess) {
log.info("删除案例文档成功caseId: {}, taskId: {}, 尝试次数: {}", caseId, deleteTaskId, attempt);
break; // 删除成功,跳出重试循环
} else {
// 业务处理失败,不重试
log.error("删除案例文档业务处理失败不重试caseId: {}, taskId: {}", caseId, deleteTaskId);
// if (deleteSuccess != null && deleteSuccess) {
// log.info("删除案例文档成功caseId: {}, taskId: {}, 尝试次数: {}", caseId, deleteTaskId, attempt);
// break; // 删除成功,跳出重试循环
// } else {
// // 业务处理失败,不重试
// log.error("删除案例文档业务处理失败不重试caseId: {}, taskId: {}", caseId, deleteTaskId);
return false;
}
// }
} else {
// 业务处理失败,不重试
log.error("删除案例文档业务处理失败不重试response: {}", responseBody);
@@ -765,191 +655,135 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
}
}
if (StringUtils.equals(cases.getConfidentialityLevel(), "内部")) {
JSONObject requestBody = new JSONObject();
String userId = getCurrentUserId();
requestBody.put("userId", userId);
requestBody.put("kId", caseAiProperties.getCaseKnowledgeId());
requestBody.put("parseType", "AUTO");
// 2. 检查文件路径
if (StringUtil.isBlank(cases.getFilePath())) {
log.error("上传案例文档失败案例文件路径为空caseId: {}", caseId);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "上传案例文档失败,案例文件路径为空",
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
return false;
}
JSONObject requestBody = new JSONObject();
String userId = getCurrentUserId();
requestBody.put("userId", userId);
requestBody.put("kId", caseAiProperties.getCaseKnowledgeId());
requestBody.put("parseType", "AUTO");
// 2. 检查文件路径
if (StringUtil.isBlank(cases.getFilePath())) {
log.error("上传案例文档失败案例文件路径为空caseId: {}", caseId);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "上传案例文档失败,案例文件路径为空",
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
return false;
}
String savePath = fileUploader.getSavePath();
String filePath = savePath + cases.getFilePath();
File file = new File(filePath);
if (!file.exists()) {
log.error("上传案例文档失败案例文件不存在filePath: {}", filePath);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "上传案例文档失败案例文件不存在filePath: " + filePath,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
return false;
}
String savePath = fileUploader.getSavePath();
String filePath = savePath + cases.getFilePath();
File file = new File(filePath);
if (!file.exists()) {
log.error("上传案例文档失败案例文件不存在filePath: {}", filePath);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "上传案例文档失败案例文件不存在filePath: " + filePath,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
return false;
}
// 4. 构建上传参数
String fileName = file.getName();
// 4. 构建上传参数
String fileName = cases.getFileName();
if (StringUtil.isBlank(fileName)) {
fileName = file.getName();
}
String fileType = getFileType(fileName);
String fileType = getFileType(fileName);
// 5. 重试逻辑最多3次机会
int uploadMaxRetries = 3;
// 5. 重试逻辑最多3次机会
int uploadMaxRetries = 3;
// 构建multipart/form-data请求体
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("file", file);
builder.addTextBody("userId", userId, ContentType.TEXT_PLAIN);
builder.addTextBody("kId", caseAiProperties.getCaseKnowledgeId(), ContentType.TEXT_PLAIN);
builder.addTextBody("fileName", fileName, ContentType.TEXT_PLAIN);
requestBody.put("fileName", fileName);
builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN);
requestBody.put("fileType", fileType);
builder.addTextBody("parseType", "AUTO", ContentType.TEXT_PLAIN);
// 构建multipart/form-data请求体
MultipartEntityBuilder builder = MultipartEntityBuilder.create();
builder.addBinaryBody("file", file);
builder.addTextBody("userId", userId, ContentType.TEXT_PLAIN);
builder.addTextBody("kId", caseAiProperties.getCaseKnowledgeId(), ContentType.TEXT_PLAIN);
builder.addTextBody("fileName", fileName, ContentType.TEXT_PLAIN);
requestBody.put("fileName", fileName);
builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN);
requestBody.put("fileType", fileType);
builder.addTextBody("parseType", "AUTO", ContentType.TEXT_PLAIN);
// 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态
if (caseAiProperties.isFileUploadUseCallback()) {
builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN);
requestBody.put("callbackUrl", caseAiProperties.getFileUploadCallbackUrl());
}
String url = caseAiProperties.getCaseDetailUrlBase() + caseId;
requestBody.put("url", url);
String downloadUrl = fileUploader.getHttpPath() + cases.getFilePath();
requestBody.put("downloadUrl", downloadUrl);
builder.addTextBody("url", url, ContentType.TEXT_PLAIN);
builder.addTextBody("downloadUrl", downloadUrl, ContentType.TEXT_PLAIN);
// metadata
JSONObject fileMetaData = new JSONObject();
fileMetaData.put("标题", cases.getTitle());
fileMetaData.put("作者", cases.getAuthorName());
fileMetaData.put("年份", String.valueOf(cases.getSysCreateTime().getYear()));
fileMetaData.put("摘要", cases.getSummary());
// 组织领域orgDomainParent
String orgDomainParent = cases.getOrgDomainParent();
List<DictItem> orgDomainParentItems = sysDictionaryService.findByKey("org_domain");
Optional<DictItem> orgDomainParentItem = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(orgDomainParent, item.getCode()))
.findFirst();
if (orgDomainParentItem.isPresent()) {
StringBuilder sb = new StringBuilder();
sb.append(orgDomainParentItem.get().getName());
if (StringUtils.isNotBlank(cases.getOrgDomainParent2())) {
Optional<DictItem> orgDomainParent2Item = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(cases.getOrgDomainParent2(), item.getCode()))
.findFirst();
orgDomainParent2Item.ifPresent(dictItem -> sb.append(" - ").append(dictItem.getName()));
if (StringUtils.isNotBlank(cases.getOrgDomainParent3())) {
Optional<DictItem> orgDomainParent3Item = orgDomainParentItems.stream()
.filter(item -> StringUtils.equals(cases.getOrgDomainParent3(), item.getCode()))
.findFirst();
orgDomainParent3Item.ifPresent(dictItem -> sb.append(" - ").append(dictItem.getName()));
}
}
fileMetaData.put("组织领域", sb.toString());
}
// 分类majorIds
List<CasesMajorType> cmtList = casesMajorTypeDao.findList(FieldFilters.eq("caseId", cases.getId()));
if (cmtList != null && !cmtList.isEmpty()) {
List<String> majorIds = cmtList.stream().map(CasesMajorType::getMajorId).collect(Collectors.toList());
String uploadUrl = caseAiProperties.getBaseUrl() + "/apigateway/knowledge/v1/file/upload";
List<DictItem> majorItems = sysDictionaryService.findByKey("major_type");
if (majorItems != null && !majorItems.isEmpty()) {
List<String> majorNames = majorItems.stream()
.filter(item -> majorIds.contains(item.getCode()))
.map(DictItem::getName)
.collect(Collectors.toList());
fileMetaData.put("组织领域", String.join(", ", majorNames));
}
}
// 3. 获取access_token
String accessToken = aiAccessTokenService.getAccessToken();
if (StringUtil.isBlank(accessToken)) {
log.error("上传案例文档失败获取access_token失败");
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "上传案例文档失败获取access_token失败",
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
return false;
}
for (int attempt = 1; attempt <= uploadMaxRetries; attempt++) {
log.info("上传案例文档第{}次尝试caseId: {}", attempt, caseId);
ContentType contentType = ContentType.create("text/plain", StandardCharsets.UTF_8);
builder.addTextBody("fileMetaData", fileMetaData.toJSONString(), contentType);
requestBody.put("fileMetaData", fileMetaData);
// 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态
if (caseAiProperties.isFileUploadUseCallback()) {
builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN);
requestBody.put("callbackUrl", caseAiProperties.getFileUploadCallbackUrl());
}
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(uploadUrl);
httpPost.setHeader("X-AI-ApiCode", caseAiProperties.getAiApiCode());
httpPost.setHeader("access_token", accessToken);
String uploadUrl = caseAiProperties.getBaseUrl() + "/apigateway/knowledge/v1/file/upload";
HttpEntity multipart = builder.build();
httpPost.setEntity(multipart);
// 3. 获取access_token
String accessToken = aiAccessTokenService.getAccessToken();
if (StringUtil.isBlank(accessToken)) {
log.error("上传案例文档失败获取access_token失败");
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "上传案例文档失败获取access_token失败",
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
return false;
}
for (int attempt = 1; attempt <= uploadMaxRetries; attempt++) {
log.info("上传案例文档第{}次尝试caseId: {}", attempt, caseId);
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
int statusCode = response.getStatusLine().getStatusCode();
String responseBody = EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
try (CloseableHttpClient httpClient = HttpClients.createDefault()) {
HttpPost httpPost = new HttpPost(uploadUrl);
httpPost.setHeader("X-AI-ApiCode", caseAiProperties.getAiApiCode());
httpPost.setHeader("access_token", accessToken);
if (statusCode == 200) {
JSONObject result = JSON.parseObject(responseBody);
if (result.getBooleanValue("success")) {
// 业务处理成功
JSONObject data = result.getJSONObject("data");
String taskId = data.getString("taskId");
HttpEntity multipart = builder.build();
httpPost.setEntity(multipart);
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 = JSON.parseObject(responseBody);
if (result.getBooleanValue("success")) {
// 业务处理成功
JSONObject data = result.getJSONObject("data");
String taskId = data.getString("taskId");
// 保存成功的CaseDocumentLog记录
// 保存成功的CaseDocumentLog记录
// saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
// requestBody.toJSONString(), responseBody,
// CaseDocumentLogRunStatusEnum.RUNNING.getCode(), null, null, taskId);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), CaseDocumentLogCaseStatusEnum.FAILED.getCode(), taskId);
log.info("上传案例文档成功,等待文档状态变更. caseId: {}, taskId: {}, 尝试次数: {}", caseId, taskId, attempt);
return true;
} else {
// 业务处理失败,不重试
log.error("上传案例文档业务处理失败不重试response: {}", responseBody);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), CaseDocumentLogCaseStatusEnum.FAILED.getCode(), null);
return false;
}
} else {
// 接口调用失败
log.error("上传案例文档接口调用失败,第{}次尝试status: {}, response: {}", attempt, statusCode, responseBody);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
if (attempt == uploadMaxRetries) {
// 最后一次尝试仍然失败
return false;
}
// 继续下一次重试
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), CaseDocumentLogCaseStatusEnum.FAILED.getCode(), taskId);
log.info("上传案例文档成功,等待文档状态变更. caseId: {}, taskId: {}, 尝试次数: {}", caseId, taskId, attempt);
return true;
} else {
// 业务处理失败,不重试
log.error("上传案例文档业务处理失败不重试response: {}", responseBody);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), CaseDocumentLogCaseStatusEnum.FAILED.getCode(), null);
return false;
}
} else {
// 接口调用失败
log.error("上传案例文档接口调用失败,第{}次尝试status: {}, response: {}", attempt, statusCode, responseBody);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
if (attempt == uploadMaxRetries) {
// 最后一次尝试仍然失败
return false;
}
// 继续下一次重试
}
} catch (Exception e) {
// 接口调用异常
log.error("上传案例文档接口调用异常,第{}次尝试", attempt, e);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "接口调用异常: " + e.getMessage(),
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
if (attempt == uploadMaxRetries) {
// 最后一次尝试仍然异常
log.error("上传案例文档最终失败,已重试{}次", uploadMaxRetries);
return false;
}
// 继续下一次重试
}
} catch (Exception e) {
// 接口调用异常
log.error("上传案例文档接口调用异常,第{}次尝试", attempt, e);
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), "接口调用异常: " + e.getMessage(),
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.FAILED.getCode(), null, null);
if (attempt == uploadMaxRetries) {
// 最后一次尝试仍然异常
log.error("上传案例文档最终失败,已重试{}次", uploadMaxRetries);
return false;
}
// 继续下一次重试
}
} else {
log.info("非【内部】密级案例,不进行上传");
return true;
}
return false;
@@ -1033,7 +867,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
@Override
public void batchCheckFileStatus() {
// log.info("开始批量检查文件状态");
log.info("开始批量检查文件状态");
// 1. 查询CaseDocumentLog表中前10条run_status等于0的数据并按创建时间升序排序
PageList<CaseDocumentLog> runningLogPage = caseDocumentLogDao.getGenericDao()
@@ -1043,11 +877,11 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 2. 如果没有符合条件的数据,完成
if (runningLogs == null || runningLogs.isEmpty()) {
// log.info("没有需要检查状态的文档,批量检查完成");
log.info("没有需要检查状态的文档,批量检查完成");
return;
}
// log.info("找到{}条需要检查状态的文档记录", runningLogs.size());
log.info("找到{}条需要检查状态的文档记录", runningLogs.size());
// 3. 把这些数据的taskId聚合成一个List<String>
List<String> taskIds = runningLogs.stream()
@@ -1057,11 +891,11 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
.collect(java.util.stream.Collectors.toList());
if (taskIds.isEmpty()) {
// log.error("所有运行中的记录都没有有效的taskId");
log.error("所有运行中的记录都没有有效的taskId");
return;
}
// log.info("需要检查状态的taskId数量: {}", taskIds.size());
log.info("需要检查状态的taskId数量: {}", taskIds.size());
// 4. 获取access_token
String accessToken = aiAccessTokenService.getAccessToken();
@@ -1101,7 +935,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
log.error("批量检查文件状态异常", e);
}
// log.info("批量检查文件状态完成");
log.info("批量检查文件状态完成");
}
/**
@@ -1367,9 +1201,8 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
caseLog.setRunStatus(CaseDocumentLogRunStatusEnum.COMPLETED.getCode());
caseLog.setOptStatus(CaseDocumentLogOptStatusEnum.SUCCESS.getCode());
caseLog.setCaseStatus(CaseDocumentLogCaseStatusEnum.SUCCESS.getCode());
caseLog.setMetadataStatus(1);
needUpdate = true;
// log.info("文档向量化成功更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
log.info("文档向量化成功更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
} else if ("failed".equals(fileStatus)) {
// 状态为failedrun_status、opt_status变更为1case_status变更为2
caseLog.setRunStatus(CaseDocumentLogRunStatusEnum.COMPLETED.getCode());
@@ -1377,20 +1210,20 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
caseLog.setCaseStatus(CaseDocumentLogCaseStatusEnum.FAILED.getCode());
needUpdate = true;
needToSendEmail = true;
// log.error("文档处理失败需要发送邮件更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
log.error("文档处理失败需要发送邮件更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
} else {
// 其他状态uploaded、texted、vectoring不做数据变更
// log.info("文档状态为{}暂不更新数据库taskId: {}", fileStatus, caseLog.getTaskId());
log.info("文档状态为{}暂不更新数据库taskId: {}", fileStatus, caseLog.getTaskId());
}
// 如果需要更新执行update操作
if (needUpdate) {
caseLog.setSysUpdateTime(LocalDateTime.now());
caseDocumentLogDao.save(caseLog);
// log.info("更新CaseDocumentLog成功logId: {}, taskId: {}, fileStatus: {}",
// caseLog.getId(), caseLog.getTaskId(), fileStatus);
// } else {
// log.info("无需更新CaseDocumentLogtaskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus);
log.info("更新CaseDocumentLog成功logId: {}, taskId: {}, fileStatus: {}",
caseLog.getId(), caseLog.getTaskId(), fileStatus);
} else {
log.info("无需更新CaseDocumentLogtaskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus);
}
} catch (Exception e) {
log.error("更新日志状态异常taskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus, e);
@@ -1407,7 +1240,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 使用配置的收件人列表
List<String> recipients = caseAiProperties.getAlertEmailRecipients();
// log.info("使用配置的收件人列表:{}", recipients);
log.info("使用配置的收件人列表:{}", recipients);
if (recipients != null && !recipients.isEmpty()) {
try {
String to = String.join(",", recipients);

View File

@@ -8,43 +8,31 @@ 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.apache.commons.lang3.StringUtils;
import org.elasticsearch.ElasticsearchException;
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.action.update.UpdateRequest;
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.client.indices.PutMappingRequest;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.rest.RestStatus;
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.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.time.Duration;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
@@ -133,40 +121,10 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
}
@Override
public boolean updateIndex(String fieldName, Map<String, Object> fieldProperties) {
if (elasticsearchClient == null) {
log.error("ElasticSearch客户端未配置");
return false;
}
// 执行新增字段请求
JSONObject newField = new JSONObject();
newField.put(fieldName, fieldProperties);
JSONObject properties = new JSONObject();
properties.put("properties", newField);
PutMappingRequest request = new PutMappingRequest(CaseAiConstants.CASE_AI_INDEX_NAME);
request.source(properties.toJSONString(), XContentType.JSON);
try {
AcknowledgedResponse response = elasticsearchClient.indices().putMapping(request, RequestOptions.DEFAULT);
if (response.isAcknowledged()) {
log.info("成功更新Elasticsearch索引: {}, 新增字段: {}", CaseAiConstants.CASE_AI_INDEX_NAME, fieldName);
return true;
} else {
log.error("更新索引 [{}] 未被确认(可能部分节点未响应)", CaseAiConstants.CASE_AI_INDEX_NAME);
return false;
}
} catch (Exception e) {
log.error("更新ElasticSearch索引时发生异常", e);
return false;
}
}
@Override
public String createData(AiChatConversationData conversationData) {
public boolean createData(AiChatConversationData conversationData) {
if (elasticsearchClient == null) {
log.error("未配置Elasticsearch客户端无法保存对话记录");
return null;
return false;
}
try {
@@ -176,14 +134,7 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
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());
esData.put("status", conversationData.getStatus());
esData.put("errorMsg", conversationData.getErrorMsg());
esData.put("timestamp", LocalDateTime.now().toString());
// 构建 caseRefer 数据
JSONArray caseReferArray = new JSONArray();
@@ -209,10 +160,10 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
IndexResponse indexResponse = elasticsearchClient.index(indexRequest, RequestOptions.DEFAULT);
log.info("保存对话记录到ES成功文档ID: {}", indexResponse.getId());
return indexResponse.getId();
return true;
} catch (Exception e) {
log.error("保存对话记录到ES异常", e);
return null;
return false;
}
}
@@ -238,7 +189,6 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
Map<String, Object> sourceMap = hit.getSourceAsMap();
CaseAiMessageVo data = parseMessageFromES(sourceMap);
if (data != null) {
data.setDocId(hit.getId());
list.add(data);
}
}
@@ -254,72 +204,37 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
private CaseAiMessageVo parseMessageFromES(Map<String, Object> sourceMap) {
try {
CaseAiMessageVo messageVo = new CaseAiMessageVo();
messageVo.setConversationId((String) sourceMap.get("conversationId"));
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((Integer) sourceMap.get("durationSeconds"));
}
// 解析 suggestions
if (sourceMap.containsKey("suggestions")) {
Object suggestionsObj = sourceMap.get("suggestions");
if (suggestionsObj instanceof List) {
messageVo.setSuggestions((List<String>) suggestionsObj);
}
}
if (sourceMap.containsKey("status")) {
Object statusObj = sourceMap.get("status");
if (statusObj != null) {
messageVo.setStatus(Integer.valueOf(statusObj.toString()));
}
}
if (sourceMap.containsKey("errorMsg")) {
Object errorMsgObj = sourceMap.get("errorMsg");
if (errorMsgObj != null) {
messageVo.setErrorMsg(errorMsgObj.toString());
}
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;
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"));
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);
// 解析 keywords
Object keywordsObj = caseReferMap.get("keywords");
if (keywordsObj instanceof List) {
caseRefer.setKeywords((List<String>) keywordsObj);
}
messageVo.setCaseRefer(caseReferList);
}
}
// 解析点赞状态
if (sourceMap.containsKey("likeStatus")) {
messageVo.setLikeStatus((String) sourceMap.get("likeStatus"));
}
// 解析反馈信息
if (sourceMap.containsKey("feedback")) {
messageVo.setFeedback((String) sourceMap.get("feedback"));
caseReferList.add(caseRefer);
}
messageVo.setCaseRefer(caseReferList);
}
return messageVo;
@@ -329,79 +244,6 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
}
}
@Override
public boolean updateData(String docId, AiChatConversationData data) {
if (elasticsearchClient == null) {
log.error("未配置Elasticsearch客户端无法更新对话记录");
return false;
}
try{
UpdateRequest updateRequest = new UpdateRequest(CaseAiConstants.CASE_AI_INDEX_NAME, docId);
JSONObject esData = new JSONObject();
// 目前只支持更新点赞状态和反馈信息
if (StringUtils.isNotBlank(data.getLikeStatus())) {
// 进行点赞/踩或取消操作是, 将feedback字段置空
esData.put("likeStatus", data.getLikeStatus());
esData.put("feedback", "");
}
if (StringUtils.isNotBlank(data.getFeedback())) {
esData.put("feedback", data.getFeedback());
}
updateRequest.doc(esData.toJSONString(), XContentType.JSON);
elasticsearchClient.update(updateRequest, RequestOptions.DEFAULT);
return true;
} catch (ElasticsearchException e) {
if (e.status() == RestStatus.NOT_FOUND) {
log.error("文档不存在", e);
}
return false;
} catch (Exception e) {
log.error("更新对话记录异常", e);
return false;
}
}
/**
* 通过docId查询数据
*
* @param docId 会话ID
* @return
*/
@Override
public List<CaseAiMessageVo> queryDataByDocId(String docId) {
List<CaseAiMessageVo> list = new ArrayList<>();
if (elasticsearchClient == null) {
log.error("未配置Elasticsearch客户端无法查询消息记录");
return list;
}
try {
SearchRequest searchRequest = new SearchRequest(CaseAiConstants.CASE_AI_INDEX_NAME);
SearchSourceBuilder searchSourceBuilder = new SearchSourceBuilder();
searchSourceBuilder.query(QueryBuilders.matchQuery("_id", docId));
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) {
data.setDocId(hit.getId());
list.add(data);
}
}
log.info("从 ES 中查询到 {} 条消息记录", list.size());
} catch (Exception e) {
log.error("从 ES 查询消息异常", e);
}
return list;
}
/**
* 获取ai_chat_messages索引的字段映射配置
* 根据项目中的会话消息数据结构规范定义映射
@@ -409,15 +251,70 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
* @return JSON格式的映射配置
*/
private String getAiChatMessagesMapping() {
InputStream inputStream = getClass().getClassLoader().getResourceAsStream("case_ai_index.json");
if (inputStream != null) {
try (InputStreamReader isr = new InputStreamReader(inputStream);
BufferedReader reader = new BufferedReader(isr)) {
return reader.lines().collect(Collectors.joining(System.lineSeparator()));
} catch (IOException e) {
throw new RuntimeException("Resource read error: case_ai_index.json", e);
}
}
throw new RuntimeException("Resource not found: case_ai_index.json");
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" +
"}";
}
}

View File

@@ -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);
}
}

View File

@@ -20,8 +20,8 @@ public class CaseDocumentLogTask {
*/
@XxlJob("batchCheckFileStatusJob")
public void batchCheckFileStatusJob() {
// log.info("开始批量查询文件状态");
log.info("开始批量查询文件状态");
caseKnowledgeService.batchCheckFileStatus();
// log.info("结束批量查询文件状态");
log.info("结束批量查询文件状态");
}
}

View File

@@ -1,13 +1,6 @@
package com.xboe.module.boecase.task;
import com.xboe.common.OrderCondition;
import com.xboe.constants.CaseAiConstants;
import com.xboe.core.orm.FieldFilters;
import com.xboe.core.orm.QueryBuilder;
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;
@@ -15,7 +8,6 @@ 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;
@@ -24,8 +16,6 @@ import javax.annotation.Resource;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 旧案例上传
@@ -46,59 +36,25 @@ public class CaseUploadTask {
@Autowired
private StringRedisTemplate stringRedisTemplate;
public static final String CASE_UPLOAD_LAST_ID_KEY = "case:upload:last:id";
public static final String CASE_RELOAD_LAST_ID_KEY = "case:reload:last:id";
@XxlJob("reloadJob")
public void reloadJob() {
String currentLastId = null;
try {
// 从Redis获取上次处理的最后一条记录ID
String lastProcessedId = stringRedisTemplate.opsForValue().get(CASE_RELOAD_LAST_ID_KEY);
// 查询需要重新加载的案例
List<CaseDocumentLog> logsToReload = listToReload(lastProcessedId);
if (logsToReload.isEmpty()) {
return;
}
currentLastId = logsToReload.get(logsToReload.size() - 1).getId();
for (CaseDocumentLog log : logsToReload) {
String caseId = log.getCaseId();
Cases cases = casesDao.get(caseId);
if (cases != null && StringUtils.isNotBlank(cases.getFilePath())) {
// 更新
caseAiDocumentAsyncHandler.process(CaseDocumentLogOptTypeEnum.UPDATE, cases);
}
}
} catch (Exception e) {
log.error("[reload]执行重新上传任务时发生异常", e);
} finally {
if (currentLastId != null) {
stringRedisTemplate.opsForValue().set(CASE_RELOAD_LAST_ID_KEY, currentLastId);
log.info("[reload] 已重新上传案例最后一条caseDocumentLogId 已更新为: {}", currentLastId);
}
}
}
private static final String CASE_UPLOAD_LAST_ID_KEY = "case:upload:last:id";
@XxlJob("oldDataUploadJob")
public void oldDataUploadJob() {
String currentLastId = null;
try {
// log.info("开始执行旧案例上传任务");
log.info("开始执行旧案例上传任务");
// 从Redis获取上次处理的最后一条记录ID
String lastProcessedId = stringRedisTemplate.opsForValue().get(CASE_UPLOAD_LAST_ID_KEY);
// log.info("上次处理的最后一条记录ID: {}", lastProcessedId);
log.info("上次处理的最后一条记录ID: {}", lastProcessedId);
// 查询符合条件的案例数据
List<Cases> casesToProcess = findCasesToProcess(lastProcessedId);
// log.info("查询到待处理案例数量: {}", casesToProcess.size());
log.info("查询到待处理案例数量: {}", casesToProcess.size());
if (casesToProcess.isEmpty()) {
// log.info("没有需要处理的案例数据");
log.info("没有需要处理的案例数据");
return;
}
currentLastId = casesToProcess.get(casesToProcess.size() - 1).getId();
// 批量检查这些案例是否已在CaseDocumentLog中存在记录提升性能
List<String> caseIds = new ArrayList<>();
@@ -114,59 +70,35 @@ public class CaseUploadTask {
// 过滤出未在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);
// }
List<CaseDocumentLog> thisCaseLogs = existingLogs.stream()
.filter(log -> cases.getId().equals(log.getCaseId()))
.collect(Collectors.toList());
if (thisCaseLogs == null || thisCaseLogs.isEmpty()) {
casesList.add(cases);
} else if (thisCaseLogs.stream()
.noneMatch(caseLog -> {
// 1. 是否存在已上传完成的案例
boolean hasCompleted = StringUtils.equals(caseLog.getRequestUrl(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME)
&& Objects.equals(caseLog.getRunStatus(), CaseDocumentLogRunStatusEnum.COMPLETED.getCode())
&& Objects.equals(caseLog.getOptStatus(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode())
&& Objects.equals(caseLog.getRunStatus(), CaseDocumentLogCaseStatusEnum.SUCCESS.getCode());
// 2. 是否存在上传中的案例
boolean hasUploading = StringUtils.equals(caseLog.getRequestUrl(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME)
&& Objects.equals(caseLog.getRunStatus(), CaseDocumentLogRunStatusEnum.RUNNING.getCode());
return hasCompleted || hasUploading;
})) {
boolean exists = false;
for (CaseDocumentLog log : existingLogs) {
if (cases.getId().equals(log.getCaseId())) {
exists = true;
break;
}
}
if (!exists) {
casesList.add(cases);
}
}
// log.info("过滤后需要处理的案例数量: {}", casesList.size());
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("没有新的案例需要处理");
}
// 将当前处理的最后一条数据ID存入Redis
// log.info("旧案例上传任务执行完成");
log.info("旧案例上传任务执行完成");
} catch (Exception e) {
log.error("执行旧案例上传任务时发生异常", e);
} finally {
if (currentLastId != null) {
fixOnLastCase(currentLastId);
}
}
}
@@ -177,46 +109,22 @@ public class CaseUploadTask {
* @return 案例列表
*/
private List<Cases> findCasesToProcess(String lastProcessedId) {
QueryBuilder queryBuilder = QueryBuilder.from(Cases.class);
queryBuilder.addFilter(FieldFilters.eq("deleted", false));
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(FieldFilters.isNotNull("filePath"));
queryBuilder.addFilter(FieldFilters.ne("filePath", ""));
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(FieldFilters.gt("id", lastProcessedId));
queryBuilder.addFilter(com.xboe.core.orm.FieldFilters.gt("id", lastProcessedId));
}
// 按创建时间升序排序
queryBuilder.addOrder(OrderCondition.asc("id"));
queryBuilder.addOrder(com.xboe.common.OrderCondition.asc("id"));
// 限制每次处理的数量,避免一次性处理太多数据
queryBuilder.setPageSize(100);
return casesDao.findList(queryBuilder.builder());
}
/**
* 获取需要重新加载的案例
* @param lastProcessedId
* @return
*/
private List<CaseDocumentLog> listToReload(String lastProcessedId) {
QueryBuilder queryBuilder = QueryBuilder.from(CaseDocumentLog.class);
queryBuilder.addFilter(FieldFilters.eq("deleted", false));
queryBuilder.addFilter(FieldFilters.eq("requestUrl", CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME));
queryBuilder.addFilter(FieldFilters.eq("caseStatus", CaseDocumentLogCaseStatusEnum.SUCCESS.getCode()));
queryBuilder.addFilter(FieldFilters.eq("metadataStatus", 0));
if (lastProcessedId != null && !lastProcessedId.isEmpty()) {
queryBuilder.addFilter(FieldFilters.gt("id", lastProcessedId));
}
queryBuilder.addOrder(OrderCondition.asc("id"));
queryBuilder.setPageSize(100);
return caseDocumentLogDao.findList(queryBuilder.builder());
}
private void fixOnLastCase(String currentLastId) {
stringRedisTemplate.opsForValue().set(CASE_UPLOAD_LAST_ID_KEY, currentLastId);
log.info("已处理案例最后一条记录ID已更新为: {}", currentLastId);
}
}

View File

@@ -2,7 +2,6 @@ package com.xboe.module.boecase.vo;
import lombok.Data;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -10,15 +9,6 @@ import java.util.List;
*/
@Data
public class CaseAiMessageVo {
/**
* ES docId
*/
private String docId;
/**
* 会话ID
*/
private String conversationId;
/**
* 用户提问内容
@@ -30,16 +20,6 @@ public class CaseAiMessageVo {
*/
private String answer;
/**
* 会话开始时间
*/
private LocalDateTime startTime;
/**
* 会话时长(秒)
*/
private Integer durationSeconds;
/**
* 案例引用列表
*/
@@ -49,31 +29,4 @@ public class CaseAiMessageVo {
* 建议列表
*/
private List<String> suggestions;
/**
* 状态
* 0-正常
* 1-系统错误
* 2-AIoT平台错误
*/
private Integer status;
/**
* 错误信息
*/
private String errorMsg;
/**
* 用户点赞状态
* -1: 踩
* 1
* 0/null 无操作
*/
private String likeStatus;
/**
* 用户踩的时候, 可以填写反馈意见
* 反馈意见
*/
private String feedback;
}

View File

@@ -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;
}

View File

@@ -1,6 +1,5 @@
package com.xboe.module.course.api;
import java.io.IOException;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
@@ -8,25 +7,10 @@ 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.util.CollectionUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -45,10 +29,6 @@ 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;
@@ -80,12 +60,6 @@ public class CourseAuditApi extends ApiBaseController{
@Resource
private ICourseTagService tagService;
@Value("${kjb.aicoreUrl}")
private String aicoreUrl;
@Value("${kjb.videoUrlPrefix}")
private String videoUrlPerfix;
/**
* 教师需要审核的课程
* @param pager
@@ -450,21 +424,10 @@ 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("-----课程提审--- 标签相关结束 -------");
// log.info("-------- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId());
// Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId());
// tagService.updateTags(oldCourse,dto.getCourse(),cuser);
// log.info("-------- 标签相关结束 -------");
courseService.submitAndPublish(dto,cuser.getAccountId(),cuser.getName());
log.info("---------------在线课开始同步到讲师管理 ------- token = " + token);
@@ -474,84 +437,16 @@ public class CourseAuditApi extends ApiBaseController{
param.setOrgName(dto.getCourse().getOrgName());
thirdApi.updateOrSaveCourse(param,token);
log.info("---------------在线课同步到讲师管理完毕 -------");
//AI视频处理-调用接口
//需求调整-课程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();
if(!CollectionUtils.isEmpty(teachers)){
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() ;
if(cclist != null && !cclist.isEmpty()){
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
@@ -582,4 +477,5 @@ public class CourseAuditApi extends ApiBaseController{
}
}

View File

@@ -15,8 +15,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.MultimediaInfo;
import org.apache.commons.lang3.StringUtils;
import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.web.bind.annotation.GetMapping;
@@ -48,6 +46,8 @@ import com.xboe.module.scorm.SCORMParser;
import com.xboe.standard.BaseConstant;
import com.xboe.standard.enums.BoedxCourseFileType;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.MultimediaInfo;
import lombok.extern.slf4j.Slf4j;
/**
@@ -256,7 +256,7 @@ public class CourseFileApi extends ApiBaseController {
}
String fileFullPath = SysConstant.getConfigValue(BaseConstant.CONFIG_UPLOAD_FILES_SAVEPATH) + file.getFilePath();
if ("mp3,mp4".indexOf(file.getFileType()) > -1){
log.info("上传 "+file.getFileType()+"文件:"+file.getFilePath());
log.info("上传 "+file.getFileType()+"文件:"+file.getFilePath());
Encoder encoder = new Encoder();
try {
//System.out.println(fileFullPath);
@@ -278,8 +278,8 @@ public class CourseFileApi extends ApiBaseController {
}
}
} catch (Exception e) {
log.error("读取视频时长错误", e);
return error("视频解析失败,尝试重新上传或联系管理员", "视频解析失败,尝试重新上传或联系管理员");
log.error("读取视频时长错误");
// e.printStackTrace();
}
}

View File

@@ -7,28 +7,19 @@ 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;
@@ -50,7 +41,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
//课程AI设置
@Slf4j
@RestController
@RequestMapping(value="/xboe/m/course/fulltext")
@@ -83,9 +74,6 @@ public class CourseFullTextApi extends ApiBaseController{
@Autowired
StringRedisTemplate redisTemplate;
@Value("${kjb.aicoreUrl}")
private String aicoreUrl;
/**
@@ -277,16 +265,14 @@ public class CourseFullTextApi extends ApiBaseController{
courseIds = String.join(",", courseIdList);
}
// String courseIds = String.join(",", courseId);
// 只查已发布,且仅查询 source=2 的课程
dto.setPublish(true);
//只是查询已发布的
dto.setPublish(true);
if(this.fullTextSearch==null) {
log.error("未实现全文检索的接口 ICourseFullTextSearch");
return badRequest("当前查询不可用,未实现检索接口");
}
CourseFullText paras=new CourseFullText();
//php剥离进行后java系统不再获取es中来自老系统的课程
paras.setSource(2);
CourseFullText paras=new CourseFullText();
//paras.setAudience("");//权限查询,先不处理
paras.setDuration(minDuration);
paras.setMaxDuration(maxDuration);
@@ -325,30 +311,14 @@ 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));
String tagName = paras.getKeywords();
if (tagName != null && tagName != ""){
CourseTag courseTag = courseTagService.getTagByName(tagName);
if (courseTag != null){
paras.setTags(courseTag.getId().toString()+",");
}
}
}
@@ -363,8 +333,6 @@ public class CourseFullTextApi extends ApiBaseController{
if(c.getSource()==2) {
cids.add(c.getId());
}
log.info("---- KJB 开始获取课程摘要信息 ---");
this.getCourseFromKJB(c,new Course());
}
List<Course> clist=null;
if(!cids.isEmpty()) {
@@ -445,7 +413,7 @@ public class CourseFullTextApi extends ApiBaseController{
c.setKeywordsList(keywordsList);
}
}
if (StringUtils.isNotBlank(c.getTags()) && c.getTags().matches("[0-9,]+")) {
if (StringUtils.isNotBlank(c.getTags()) ){
List<CourseTag> tagList = courseTagService.getTagsByIds(c.getTags());
List<String> tags = tagList.stream().map(CourseTag::getTagName).collect(Collectors.toList());
c.setTagsList(tags);
@@ -462,48 +430,6 @@ public class CourseFullTextApi extends ApiBaseController{
}
public void getCourseFromKJB(CourseFullText courseFull,Course course){
String courseId = courseFull.getId();
log.info("------------KJB---获取课程详情 start ---------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());
courseFull.setAiSet(boeaiCourseDto.get(0).getAiSet());
courseFull.setAiDraft(boeaiCourseDto.get(0).getAiDraft());
courseFull.setAiTranslate(boeaiCourseDto.get(0).getAiTranslate());
courseFull.setLanguageStatus(boeaiCourseDto.get(0).getLanguageStatus());
courseFull.setLanguageCode(boeaiCourseDto.get(0).getLanguageCode() == null ? new ArrayList<>() :Arrays.asList(boeaiCourseDto.get(0).getLanguageCode().split(",")));
course.setAiSet(boeaiCourseDto.get(0).getAiSet());
course.setAiAbstract(boeaiCourseDto.get(0).getAiAbstract());
//course.setSummaryStatus(boeaiCourseDto.get(0).getSummaryStatus());
course.setSummaryContent(boeaiCourseDto.get(0).getSummaryContent());
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(",")));
}
log.info("------------KJB---获取课程详情 end ---------");
}
private void getTeacherStatusByCode(String token, PageList<CourseFullText> coursePageList) {
log.info("获取教师信息通过工号 ");
List<String> teacherCoeds = new ArrayList<>();

View File

@@ -7,17 +7,15 @@ import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
import com.boe.feign.api.infrastructure.entity.Dict;
import com.xboe.api.ThirdApi;
import com.xboe.api.vo.UserBasicInfoVo;
import com.xboe.module.course.dto.*;
import com.xboe.module.course.entity.*;
import com.xboe.module.course.service.*;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
@@ -35,6 +33,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;
@@ -43,7 +54,7 @@ import com.xboe.system.user.entity.User;
import com.xboe.system.user.service.IUserService;
import lombok.extern.slf4j.Slf4j;
//开启AI设置
/**
* 课程管理的接口处理<br/>
@@ -94,12 +105,7 @@ public class CourseManageApi extends ApiBaseController{
IDataUserSyncService userSyncService;
@Resource
private ThirdApi thirdApi;
@Resource
CourseAuditApi courseAuditApi;
@Resource
CourseFullTextApi courseFullTextApi;
// @PostMapping("/test")
// public JsonResponse<PageList<Course>> findTest(Pagination pager,CourseQueryDto dto){
// //dto.setOrgAid("7003708665807110150");
@@ -144,10 +150,22 @@ public class CourseManageApi extends ApiBaseController{
dto.setOrgIds(ids);
dto.setReadIds(userOrgIds.getReadIds());
PageList<Course> coursePageList = courseService.findPage(pager.getPageIndex(), pager.getPageSize(),dto);
//补充审核人,审核时间字段
if(CollectionUtils.isNotEmpty(coursePageList.getList())){
fullAuditInfo(coursePageList.getList());
}
// 补充审核人审核时间(取最近一条审核记录)- 批量查询优化
if (coursePageList != null && coursePageList.getList() != null && !coursePageList.getList().isEmpty()) {
List<String> courseIds = coursePageList.getList().stream().map(Course::getId).collect(Collectors.toList());
Map<String, CourseHRBPAudit> latestAuditMap = hrbpAuditService.findLatestByCourseIds(courseIds);
for (Course c : coursePageList.getList()) {
try {
CourseHRBPAudit latest = latestAuditMap.get(c.getId());
if (latest != null) {
c.setAuditUser(latest.getAuditUser());
c.setAuditTime(latest.getAuditTime());
}
} catch (Exception ignore) {
// ignore single course enrich error
}
}
}
return success(coursePageList);
}catch(Exception e) {
log.error("管理课程列表查询错误",e);
@@ -155,45 +173,7 @@ public class CourseManageApi extends ApiBaseController{
}
}
public void fullAuditInfo(List<Course> list){
List<String> courseIdList = list.stream().map(Course::getId).collect(Collectors.toList());
List<CourseHRBPAudit> auditList = hrbpAuditService.listByCourseIds(courseIdList);
Map<String,CourseHRBPAudit> map = new HashMap<>();
for(CourseHRBPAudit audit : auditList){
CourseHRBPAudit r = map.get(audit.getCourseId());
//可能存在多个审核记录,取时间最新的那一条
if(r == null || r.getAddTime().isBefore(audit.getAddTime())){
map.put(audit.getCourseId(),audit);
}
}
list.forEach(item ->{
CourseHRBPAudit audit = map.get(item.getId());
if(audit != null){
//公开课审核完成取公开课的审核信息
if(StringUtils.isNotEmpty(audit.getLastAname())){
item.setAuditUser(audit.getLastAname());
item.setAuditTime(audit.getLastTime());
}else if(CourseHRBPAudit.FORWARD_TEACHER == audit.getForward()){
//转发到教师审核取教师审核信息
item.setAuditUser(audit.getToName());
}else if (CourseHRBPAudit.FORWARD_TO_FINISH == audit.getForward()){
//老师审核完成
item.setAuditUser(audit.getAuditUser());
if(CourseHRBPAudit.STATUS_NOPASS ==audit.getStatus()){
//老师审核不通过时取老师的审核时间
item.setAuditTime(audit.getToAuditTime());
}
}else {
item.setAuditUser(audit.getAuditUser());
item.setAuditTime(audit.getAuditTime());
}
}
});
}
@GetMapping("/detail")
public JsonResponse<Map<String,Object>> detail(String id){
if(StringUtils.isBlank(id)) {
@@ -222,15 +202,8 @@ public class CourseManageApi extends ApiBaseController{
isPermission = dicts.contains(course.getOrgId());
rs.put("dicts",dicts);
}
//void getCourseFromKJB(CourseFullText courseFull,Course course){
log.info("-------课程详情(KJB)查询开始-------");
CourseFullText courseFull = new CourseFullText();
courseFull.setId(course.getId());
courseFullTextApi.getCourseFromKJB(courseFull,course);
log.info("-------课程详情(KJB)查询结束-------");
log.error("-------是否仅内网查看 = " + isPermission);
if (StringUtils.isNotBlank(course.getTags()) && course.getTags().matches("[0-9,]+")){
if (StringUtils.isNotBlank(course.getTags())){
List<CourseTag> tagList = tagService.getTagsByIds(course.getTags());
rs.put("tagList", tagList);
}
@@ -265,7 +238,7 @@ public class CourseManageApi extends ApiBaseController{
}
return success(rs);
}
/**
* 管理员审核列表教师的审核不在这里此审核也应该移动CourseAuditApi中去
* @param pager
@@ -354,7 +327,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("无课程信息");
}
@@ -375,26 +347,11 @@ 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());
// log.info("-------- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId());
// CurrentUser userInfo = getCurrent();
// Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId());
// tagService.updateTags(oldCourse,dto.getCourse(),userInfo);
// log.info("-------- 标签相关结束 -------");
if(StringUtils.isBlank(dto.getCourse().getId())) {
//只有在第一次添加保存时才会这样
@@ -414,11 +371,6 @@ public class CourseManageApi extends ApiBaseController{
param.setOrgName(dto.getCourse().getOrgName());
thirdApi.updateOrSaveCourse(param,token);
log.info("---------------在线课同步到讲师管理完毕 -------");
//AI视频处理-调用接口
log.info("---------------AI视频处理-调用接口开始 -------");
courseAuditApi.sendMessageToKJB(dto);
log.info("---------------AI视频处理-调用接口结束 -------");
return success(dto);
} catch (Exception e) {
log.error("整体保存课程信息错误",e);
@@ -428,6 +380,8 @@ public class CourseManageApi extends ApiBaseController{
/***
* 仅仅是保存
* @param dto
* @return
*/
@PostMapping("/save-only-course")
@AutoLog(module = "课程",action = "保存课程基本信息",info = "")
@@ -454,39 +408,13 @@ 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);
return error("保存失败",e.getMessage());
}
}
@PostMapping("/benchAiSet")
@AutoLog(module = "课程",action = "批量课程AI设置",info = "")
public JsonResponse<CourseFullDto> benchAiSet(@RequestBody CourseFullDto dto){
log.info("--------------- 批量课程AI设置 ----------");
if(CollectionUtils.isEmpty(dto.getCourseList())) {
return badRequest("请选择要设置的课程");
}
try {
CourseFullDto item;
for (Course course : dto.getCourseList()) {
item = new CourseFullDto();
item.setCourse(course);
courseAuditApi.sendMessageToKJB(item);
}
return success(dto);
} catch (Exception e) {
log.error("批量课程AI设置错误",e);
return error("保存失败",e.getMessage());
}
}
private String checkForSubmit(Course c) {
String error=null;
if(StringUtils.isBlank(c.getName())) {
@@ -547,7 +475,7 @@ public class CourseManageApi extends ApiBaseController{
@PostMapping("/submit")
@AutoLog(module = "课程",action = "提交课程",info = "")
public JsonResponse<CourseFullDto> submitCourseFull(HttpServletRequest request, @RequestBody CourseFullDto dto){
public JsonResponse<CourseFullDto> submitCourseFull(@RequestBody CourseFullDto dto){
if(dto.getCourse()==null){
return badRequest("无课程信息");
}
@@ -668,10 +596,7 @@ public class CourseManageApi extends ApiBaseController{
dto.getCourse().getOrgName(),
dto.getCourse().getSysCreateBy(),dto.getCourse().getName());
//邮件发送
String email= this.getEmail(dto.getAuditUser().getCode(), request);
if (StringUtils.isBlank( email)) {
email=dto.getAuditUser().getEmail();
}
String email=dto.getAuditUser().getEmail();
if(!isLocalDevelopment()) {
//只是非开发模式下才可以发送
service.sendMail(email,""+dto.getCourse().getName()+"》课程审核提醒", htmlEmail,"数字化学习平台");
@@ -689,39 +614,7 @@ public class CourseManageApi extends ApiBaseController{
return error("提交课程处理失败",e.getMessage());
}
}
private String getEmail(String code, HttpServletRequest request) {
String token = request.getHeader("Xboe-Access-Token");
if (StringUtils.isEmpty(token)) {
token = request.getHeader("token");
}
if (StringUtils.isEmpty(token)) {
token = request.getHeader("x-access-token");
}
log.info("审批获取邮箱新 code{}", code);
if (StringUtils.isBlank( code)) {
return null;
}
try {
log.info("审批获取邮箱 workNums{}", code);
List<UserBasicInfoVo> userBasicInfoVoList = thirdApi.getUserBasicInfoByWorkNums2(code, token);
log.info("审批获取邮箱 userBasicInfoVoList{}", userBasicInfoVoList);
if (CollectionUtils.isEmpty(userBasicInfoVoList)) {
return null;
}
String email = userBasicInfoVoList.get(0).getEmail();
log.info("审批获取邮箱 userBasicInfoVoList.get(0).getEmail(){}", email);
return email;
} catch (Exception e) {
log.error("获取用户邮箱错误",e);
}
return null;
}
private String createEmailHtml(String name,String orgId, String orgName,String createBy,String courseName) throws Exception {
StringBuffer htmlMsg=new StringBuffer("<div style=\"line-height:30px;border:2px solid #2990ca;padding:20px\">");
@@ -832,10 +725,6 @@ public class CourseManageApi extends ApiBaseController{
//邮件发送
if(!isLocalDevelopment()) {
//只是非高度环境上才会发送
String newEmail = getEmail(ucode,request);
if (StringUtils.isNotBlank(newEmail)) {
email = newEmail;
}
service.sendMail(email,""+course.getName()+"》课程审核提醒",htmlEmail,"数字化学习平台");
}
@@ -869,6 +758,7 @@ public class CourseManageApi extends ApiBaseController{
/**
* 审核课程,这个是管理人员的审核。老师审核不在这里处理.
* @param id
* @param title
* @param pass
* @param remark
@@ -902,6 +792,7 @@ public class CourseManageApi extends ApiBaseController{
/**
* 审核并发布,未完成的处理,
* @param id
* @param title
* @param pass
* @param remark
@@ -945,6 +836,10 @@ public class CourseManageApi extends ApiBaseController{
/**
* 发布课程信息,已经没有单独的发布了
* @param id
* @param title
* @param pass
* @param remark
* @return
*/
@Deprecated
@@ -1342,10 +1237,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);
}
}

View File

@@ -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) {

View File

@@ -26,7 +26,6 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
/**
* @ClassName:CourseTagApi
@@ -154,6 +153,9 @@ public class CourseTagApi extends ApiBaseController {
CurrentUser cuser = getCurrent();
String aid = cuser.getAccountId();
log.info(" searchTags cuser name = " + cuser.getName() + " , NickName = " + cuser.getNickName() + " , LoginName = " + cuser.getLoginName());
log.info(" 参数 tagName = " + tagName + " , typeId = " + typeId + " , aid = " + aid);
log.info(" searchTags aid = " + aid);
List<CourseTag> courseTagList = courseTagService.searchTags(tagName,aid,typeId);
return success(courseTagList);
}
@@ -165,14 +167,8 @@ public class CourseTagApi extends ApiBaseController {
*/
@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("创建标签失败!");

View File

@@ -42,10 +42,10 @@ public class CourseTagDao extends BaseDao<CourseTag> {
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" +
"on t.id = r.tag_id\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
"order by t.last_set_hot_time desc,relation_count desc"; // 数据库字段为last_set_hot_time
// 创建原生查询并指定结果映射到CourseTag实体
javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class);
@@ -105,7 +105,7 @@ public class CourseTagDao extends BaseDao<CourseTag> {
}
public CourseTag getTagByName(String tagName) {
CourseTag courseTag = this.findOne(FieldFilters.eq("tag_name", tagName),FieldFilters.eq("deleted", false),FieldFilters.eq("status", 0));
CourseTag courseTag = this.findOne((FieldFilters.eq("tag_name", tagName)));
return courseTag;
}
@@ -129,31 +129,36 @@ public class CourseTagDao extends BaseDao<CourseTag> {
// 只查询实际存在的字段
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 ");
sql.append(" WHERE deleted = 0 AND is_public = 0 AND status = 0 ");
if (StringUtils.isNotBlank(tagName)) {
sql.append(" AND tag_name LIKE ? ");
parameters.add("%" + tagName + "%");
}
sql.append(" UNION ALL ");
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 = 1 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(") AS all_tags ");
sql.append("ORDER BY ");
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 ");
@@ -162,13 +167,13 @@ public class CourseTagDao extends BaseDao<CourseTag> {
sql.append(" OR sys_type2 = ? ");
sql.append(" OR sys_type3 = ?) ");
sql.append(" GROUP BY tag_id ");
sql.append(" ) THEN 0 ELSE 1 END ");
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");
sql.append(" sys_create_time DESC");
log.info("查询标签 searchTags sql = {} ", sql);
// 不使用实体类映射,手动处理结果集
Query query = entityManager.createNativeQuery(sql.toString());

View File

@@ -113,18 +113,4 @@ public class CourseTagRelationDao extends BaseDao<CourseTagRelation> {
.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();
}
}

View File

@@ -1,20 +0,0 @@
package com.xboe.module.course.dao;
import com.xboe.core.orm.BaseDao;
import com.xboe.module.course.entity.ModifyLog;
import org.springframework.stereotype.Repository;
@Repository
public class ModifyLogDao extends BaseDao<ModifyLog> {
public void insert(String requestId, String location, String body, String remark) {
ModifyLog entity = new ModifyLog();
entity.setRequestId(requestId);
entity.setLocation(location);
entity.setBody(body);
entity.setRemark(remark);
save(entity);
}
}

View File

@@ -1,9 +0,0 @@
package com.xboe.module.course.dao;
import com.xboe.core.orm.BaseDao;
import com.xboe.module.course.entity.ThreadLog;
import org.springframework.stereotype.Repository;
@Repository
public class ThreadLogDao extends BaseDao<ThreadLog> {
}

View File

@@ -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> {
}

View File

@@ -1,86 +0,0 @@
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;
}

View File

@@ -1,103 +0,0 @@
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;
}

View File

@@ -1,15 +0,0 @@
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;
}

View File

@@ -1,80 +0,0 @@
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字幕文件URLOSS地址
*/
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;
}

View File

@@ -1,88 +0,0 @@
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;
}

View File

@@ -31,11 +31,6 @@ public class CourseFullDto {
* 课程的信息
*/
private Course course;
/**
* 批量课程AI设置课
*/
private List<Course> courseList;
/**
* 课程资源信息

View File

@@ -1,7 +1,6 @@
package com.xboe.module.course.entity;
import java.time.LocalDateTime;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Entity;
@@ -217,47 +216,6 @@ 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审核完成
@@ -441,20 +399,16 @@ public class Course extends BaseEntity {
@Transient
private String teacher;
/**
* 新增在线课时是否需要标签提示
*/
@Transient
private Boolean isTip;
/**审核人名称(列表展示用)*/
@Transient
private String auditUser;
@Transient
/**审核时间(列表展示用)*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Transient
private LocalDateTime auditTime;
public Course(String id,String name,String summary,String coverImg,String sysCreateAid,String sysCreateBy,Integer type,LocalDateTime publishTime){
super.setId(id);
this.name=name;

View File

@@ -8,12 +8,9 @@ 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;
/**
* 课程内容表
* */
@@ -96,9 +93,6 @@ public class CourseContent extends BaseEntity {
/**用于学习时的状态显示,非存储字段*/
@Transient
private Integer status;
@Transient
List<BoeaiSubtitleRsp> boeaiSubtitleRspList;
public CourseContent() {

View File

@@ -57,8 +57,4 @@ public class CourseTeacher extends IdBaseEntity {
@Transient
private Integer teacherType;
/**讲师头像*/
@Transient
private String photo;
}

View File

@@ -1,45 +0,0 @@
package com.xboe.module.course.entity;
import com.xboe.core.SysConstant;
import com.xboe.core.orm.IdBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.persistence.Entity;
import javax.persistence.Table;
/**
* 讲师删除记录表
* 为了监控PngCode-SZX-1227问题临时创建的表
*
* @author guo jia
*/
@Data
@Entity
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Table(name = SysConstant.TABLE_PRE + "modify_log")
public class ModifyLog extends IdBaseEntity {
/**
* 请求ID
*/
private String requestId;
/**
* 位置
*/
private String location;
/**
* 请求body
*/
private String body;
/**
* 备注信息
*/
private String remark;
}

View File

@@ -1,120 +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.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import java.time.LocalDateTime;
/**
* 线程日志表实体
*/
@Data
@Entity
@EqualsAndHashCode(callSuper = false)
@Table(name = SysConstant.TABLE_PRE + "thread_log")
public class ThreadLog {
/**
* 主键ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id", columnDefinition = "BIGINT UNSIGNED COMMENT '主键'")
private Long id;
/**
* 系统/子系统标识
*/
@Column(name = "system_name", nullable = false, length = 64)
private String systemName;
/**
* 功能模块
*/
@Column(name = "module_name", nullable = false, length = 64)
private String moduleName;
/**
* 具体动作/事件
*/
@Column(name = "action_name", nullable = false, length = 64)
private String actionName;
/**
* 日志级别(INFO/WARN/ERROR/DEBUG等)
*/
@Column(name = "level", nullable = false, length = 16)
private String level;
/**
* 日志正文/描述
*/
@Column(name = "content", columnDefinition = "TEXT COMMENT '日志正文/描述'")
private String content;
/**
* 线程名称
*/
@Column(name = "thread_name", length = 64)
private String threadName;
/**
* 结构化扩展信息(JSON)
* 注用String接收JSON字符串如需反序列化可自行处理如使用ObjectMapper转换为Map/自定义DTO
*/
@Column(name = "extra_data", columnDefinition = "JSON COMMENT '结构化扩展信息(JSON)'")
private String extraData;
/**
* 备注
*/
@Column(name = "remark", length = 255)
private String remark;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "create_time", nullable = false)
private LocalDateTime createTime;
/**
* 创建人ID
*/
@Column(name = "create_id", columnDefinition = "BIGINT COMMENT '创建人ID'")
private Long createId;
/**
* 创建人姓名
*/
@Column(name = "create_name", length = 128)
private String createName;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Column(name = "update_time", nullable = false)
private LocalDateTime updateTime;
/**
* 更新人ID
*/
@Column(name = "update_id", columnDefinition = "BIGINT COMMENT '更新人ID'")
private Long updateId;
/**
* 更新人姓名
*/
@Column(name = "update_name", length = 128)
private String updateName;
}

View File

@@ -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;
}

View File

@@ -2,6 +2,7 @@ package com.xboe.module.course.service;
import java.util.List;
import java.util.Map;
import com.xboe.common.PageList;
import com.xboe.module.course.dto.CourseHRBPAuditDto;
@@ -55,8 +56,11 @@ public interface ICourseHRBPAuditService {
* @return
*/
PageList<CourseHRBPAudit> pageList(Integer pageIndex, Integer pageSize,int userType, CourseHRBPAudit info);
/**
* 查询一组课程的最近一次审核记录返回键为courseId的映射。
*/
Map<String, CourseHRBPAudit> findLatestByCourseIds(List<String> courseIds);
List<CourseHRBPAudit> listByCourseIds(List<String> courseIdList);
}

View File

@@ -344,11 +344,5 @@ 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();
void getPhpCourseData();
}

View File

@@ -92,6 +92,4 @@ public interface ICourseTagService {
CourseTag getTagByName(String tagName);
void updateTags(Course oldCourse,Course newCourse,CurrentUser userInfo);
List<CourseTag> getAllTags();
}

View File

@@ -1,7 +1,9 @@
package com.xboe.module.course.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
@@ -263,7 +265,27 @@ public class CourseHRBPAuditServiceImpl implements ICourseHRBPAuditService {
return courseHRBPAuditDao.get(id);
}
public List<CourseHRBPAudit> listByCourseIds(List<String> courseIdList){
return courseHRBPAuditDao.findList(FieldFilters.in("courseId",courseIdList));
}
@Override
public Map<String, CourseHRBPAudit> findLatestByCourseIds(List<String> courseIds) {
Map<String, CourseHRBPAudit> result = new HashMap<String, CourseHRBPAudit>();
if (courseIds == null || courseIds.isEmpty()) {
return result;
}
try {
// 按 addTime 倒序使首次出现的courseId即为该课程的最近一条审核记录
List<CourseHRBPAudit> audits = courseHRBPAuditDao.findList(
OrderCondition.desc("addTime"),
FieldFilters.in("courseId", courseIds)
);
for (CourseHRBPAudit a : audits) {
if (!result.containsKey(a.getCourseId())) {
result.put(a.getCourseId(), a);
}
}
} catch (Exception e) {
log.error("批量查询课程审核记录错误", e.getMessage());
}
return result;
}
}

View File

@@ -17,26 +17,19 @@ 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.JSONObject;
import com.alibaba.fastjson2.JSON;
//import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
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;
@@ -48,7 +41,6 @@ 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;
@@ -62,6 +54,9 @@ 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;
@@ -128,18 +123,10 @@ public class CourseServiceImpl implements ICourseService {
@Resource
RestHighLevelClient restHighLevelClient;
@Resource
private TipDao tipDao;
@Resource
private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao;
@Resource
private ModifyLogDao modifyLogDao;
@Value("${kjb.aicoreUrl}")
private String aicoreUrl;
/**
* 生成过滤条件
*
@@ -453,26 +440,19 @@ public class CourseServiceImpl implements ICourseService {
});
//将需要隐藏的做标记
listByFilters2.forEach(e -> {
if ((seache.contains(e.getId()) || dto.getReadIds().contains(e.getOrgId())) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
if ((seache.contains(e.getId())||dto.getReadIds().contains(e.getOrgId())) && !finalStrings.contains(e.getOrgId()) && !dto.getOrgAid().equals(e.getSysCreateAid())) {
e.setIsPermission(false);
} else {
e.setIsPermission(true);
}
});
listByFilters2.sort(Comparator.comparing(Course::getIsPermission).reversed());
} else {
List<Course> collect = listByFilters2.stream().filter(e -> dto.getReadIds().contains(e.getOrgId()) || dto.getOrgAid().equals(e.getSysCreateAid()) || finalStrings.contains(e.getOrgId())).collect(Collectors.toList());
}else{
List<Course> collect = listByFilters2.stream().filter(e ->dto.getReadIds().contains(e.getOrgId())||dto.getOrgAid().equals(e.getSysCreateAid())||finalStrings.contains(e.getOrgId())).collect(Collectors.toList());
List<Course> paginate = paginate(collect, pageIndex, pageSize);
PageList<Course> rs = new PageList<>();
rs.setCount(collect.size());
rs.setList(paginate);
//log.info("78888888888888888888 "+paginate.isEmpty());
if (paginate != null && !paginate.isEmpty()) {
log.info("-----KJB------ getCourse");
for (Course course : paginate) {
this.getCourseFromKJB(course);
}
}
return rs;
}
}
@@ -482,46 +462,9 @@ public class CourseServiceImpl implements ICourseService {
rs.setCount(listByFilters2.size());
rs.setPageSize(pageSize);
rs.setList(paginate);
if (paginate != null && !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<>();
@@ -977,7 +920,6 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId());
courseTeacherDao.save(ct);
addBoeCourseTeacherModifyLog(ct, "M1位置讲师名修改", JSONUtil.toJsonStr(ct), null);
}
}
if (full.getCrowds() != null && !full.getCrowds().isEmpty()) {
@@ -1056,7 +998,7 @@ public class CourseServiceImpl implements ICourseService {
if (c.getVisible() == null) {
c.setVisible(true);
}
/*if (c.getTags() != null && !c.getTags().isEmpty()){
if (c.getTags() != null && !c.getTags().isEmpty()){
CourseTagRelationDto courseTagRelationDto = new CourseTagRelationDto();
courseTagRelationDto.setCourseId(c.getId());
courseTagRelationDto.setSysType1(c.getSysType1());
@@ -1070,15 +1012,7 @@ public class CourseServiceImpl implements ICourseService {
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());
@@ -1091,7 +1025,6 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId());
courseTeacherDao.saveOrUpdate(ct);
addBoeCourseTeacherModifyLog(ct, "M2位置讲师名修改", JSONUtil.toJsonStr(ct), null);
}
}
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
@@ -1148,7 +1081,6 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId());
courseTeacherDao.saveOrUpdate(ct);
addBoeCourseTeacherModifyLog(ct, "M3位置讲师名修改", JSONUtil.toJsonStr(ct), null);
}
}
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
@@ -1164,7 +1096,6 @@ public class CourseServiceImpl implements ICourseService {
hrbpAudit.setCourseId(c.getId());
hrbpAudit.setAddTime(LocalDateTime.now());
hrbpAudit.setAid(full.getAuditUser().getAid());
hrbpAudit.setAuditUser(full.getAuditUser().getName());//提前保存审核hrbp的名字用于显示下一步审核人
hrbpAudit.setAuditRemark("");
hrbpAudit.setForward(CourseHRBPAudit.FORWARD_NONE);
hrbpAudit.setStatus(CourseHRBPAudit.STATUS_NONE);
@@ -1175,16 +1106,12 @@ public class CourseServiceImpl implements ICourseService {
public void submitAndPublish(CourseFullDto full, String aid, String aname) throws Exception {
Course c = full.getCourse();//当前的课程信息
log.info(" 课程 c = " + c.getId());
log.info(" 课程 c = " + c);
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);
log.info(" 课程 c = " + c.getId());
// 兼容处理,记录下删除的关联数据
createCourseTeacherDeletedRecord(c.getId());
@@ -1194,7 +1121,6 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId());
courseTeacherDao.saveOrUpdate(ct);
addBoeCourseTeacherModifyLog(ct, "M4位置讲师名修改", JSONUtil.toJsonStr(ct), null);
}
}
//先清空受众信息,受众信息如果不一样了,也要加入到日志中
@@ -1254,7 +1180,7 @@ public class CourseServiceImpl implements ICourseService {
/***
* 发布全文索引
* @param
* @param c
*/
// private void fullTextPublish(Course c) {
// if(fullTextSearch==null) {
@@ -2097,7 +2023,108 @@ public class CourseServiceImpl implements ICourseService {
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)", ids);
}
private class Result{
private Boolean success;
private Data data;
private class Data{
private List<Map<String,Object>> result;
public List<Map<String, Object>> getResult() {
return result;
}
public void setResult(List<Map<String, Object>> result) {
this.result = result;
}
}
public void setData(Data data) {
this.data = data;
}
public Boolean getSuccess() {
return success;
}
public void setSuccess(Boolean success) {
this.success = success;
}
public Data getData() {
return data;
}
}
@Override
public void getPhpCourseData() {
HttpRequest request = HttpUtil.createGet("https://u.boe.com/api/b1/new-employee/course-list");
HttpResponse response = request.execute();
String body = response.body();
Result result = JSON.parseObject(body,Result.class);
log.info("php课程数据获取成功");
List<Map<String,Object>> phpCourseDataList = result.getData().getResult();
for (Map<String, Object> phpCourseData : phpCourseDataList){
log.info("开始同步数据:"+phpCourseData.get("course_name"));
}
List<Map<String,Object>> phpStudyCourseList = null;
// 查询数据库中是否存在php课程数据
for (int i = 0; i < phpCourseDataList.size(); i++) {
// 查询php的课程数据在数据库中是否已经存在
String phpCourseName = (String) phpCourseDataList.get(i).get("course_name");
Boolean exist = isCourseName(phpCourseName,"");
if (!exist){
log.info(phpCourseName+"不存在,开始同步");
Course newCourse = new Course();
// 设置学习人数
int studys = Integer.parseInt(phpCourseDataList.get(i).get("learned_number").toString());
newCourse.setStudys(studys);
// 设置系统版本
int version = Integer.parseInt(phpCourseDataList.get(i).get("version").toString());
newCourse.setSysVersion(version);
// 设置电脑端还是手机端可见
int pcDevice = Integer.parseInt(phpCourseDataList.get(i).get("is_display_pc").toString());
int mobileDevice = Integer.parseInt(phpCourseDataList.get(i).get("is_display_mobile").toString());
if (pcDevice == 1 && mobileDevice == 1){
newCourse.setDevice(3);
} else if (pcDevice == 0 && mobileDevice == 1) {
newCourse.setDevice(2);
}else if(pcDevice == 1 && mobileDevice == 0){
newCourse.setDevice(1);
}
// 判断是否按照顺序学习
int orderStudy = Integer.parseInt(phpCourseDataList.get(i).get("mod_type").toString());
newCourse.setOrderStudy(orderStudy == 1 ? true : false);
// 设置课程简介
String summary = (String) phpCourseDataList.get(i).get("course_desc_nohtml");
newCourse.setSummary(summary);
// 设置课程类型
int courseType = Integer.parseInt(phpCourseDataList.get(i).get("course_type").toString());
newCourse.setType(courseType == 0 ? 20 : 30);
// 设置学习时长
int courseTime = Integer.parseInt(phpCourseDataList.get(i).get("course_period").toString());
newCourse.setStudyTime(courseTime);
// 设置课程封面
newCourse.setCoverImg("https://u.boe.com/pc/images/bgimg/course.png");
newCourse.setName(phpCourseName);
newCourse.setStatus(5);
newCourse.setComments(0);
newCourse.setDeleted(false);
newCourse.setEnabled(true);
newCourse.setFavorites(0);
newCourse.setIsTop(false);
newCourse.setViews(0);
newCourse.setPraises(0);
newCourse.setTrampleCount(0);
newCourse.setShares(0);
newCourse.setScore(0f);
courseDao.save(newCourse);
}else {
log.info(phpCourseName+"存在");
}
}
}
@Override
public void deletedStudyResourceBatchByCourseIdAndType(String courseId, Integer courseType) {
DeleteByQueryRequest request = new DeleteByQueryRequest("new_study_resource");
@@ -2132,46 +2159,4 @@ public class CourseServiceImpl implements ICourseService {
}
}
/**
* 增加boe_course_teacher的teacher_name字段被改为"BOE教师"的监控
*/
private void addBoeCourseTeacherModifyLog(CourseTeacher ct, String location, String body, String remark) {
try {
if (ct == null) {
return;
}
if (Objects.equals(ct.getTeacherName(), "BOE教师")) {
modifyLogDao.insert(null, location, body, remark);
}
} catch (Exception e) {
log.error("创建boe_course_teacher记录失败", e);
}
}
@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);
}
}

View File

@@ -388,15 +388,13 @@ public class CourseTagServiceImpl implements ICourseTagService {
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 如果该标签不存在 或私有标签,则新建标签
if (courseTagList==null || courseTagList.isEmpty()){//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;
@@ -410,13 +408,11 @@ public class CourseTagServiceImpl implements ICourseTagService {
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()) {
log.info(" --- 旧标签 oldTagIds = {} " , oldTagIds);
log.info(" --- 新修改 newTagIds = {} " , newTagIds);
if (oldCourse == null) {
// 新增课程 - 处理所有新标签
handleNewCourseTags(newCourse, newTagIds, userInfo);
} else {
@@ -426,17 +422,6 @@ public class CourseTagServiceImpl implements ICourseTagService {
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列表
*/
@@ -589,7 +574,6 @@ public class CourseTagServiceImpl implements ICourseTagService {
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());
@@ -616,12 +600,13 @@ public class CourseTagServiceImpl implements ICourseTagService {
// 恢复已删除的关联关系
CourseTagRelation relation = existingRelations.get(0);
if (relation.getDeleted()) {
courseTagRelationDao.reTagRelDelStatus(relation.getId(),userInfo.getName());
// relation.setDeleted(false);
relation.setDeleted(false);
// 设置更新信息
// relation.setSysUpdateBy(userInfo.getName());
// relation.setSysUpdateTime(now);
// courseTagRelationDao.saveOrUpdate(relation);
relation.setSysUpdateBy(userInfo.getName());
relation.setSysUpdateTime(now);
courseTagRelationDao.saveOrUpdate(relation);
}
}
log.debug("完成课程-标签关联关系创建: courseId={}, tagId={}", courseId, tag != null ? tag.getId() : "null");
@@ -665,7 +650,6 @@ public class CourseTagServiceImpl implements ICourseTagService {
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());
@@ -694,12 +678,13 @@ public class CourseTagServiceImpl implements ICourseTagService {
// 恢复已删除的关联关系
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);
relation.setDeleted(false);
// 设置更新信息
relation.setSysUpdateBy(userInfo.getName());
relation.setSysUpdateTime(now);
courseTypeTagRelationDao.saveOrUpdate(relation);
}
}
}
@@ -808,7 +793,7 @@ public class CourseTagServiceImpl implements ICourseTagService {
LocalDateTime now = LocalDateTime.now();
// 检查是否满足设置为公共标签的条件
if (activeCount >= 3 && tag.getLastSetPublicTime() != null) {
if (activeCount >= 3 && tag.getLastSetPublicTime() == null) {
// 只有从未手动关闭过公共标签的才自动开启
tag.setIsPublic(true);
tag.setLastSetPublicTime(now);

View File

@@ -1,49 +0,0 @@
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:{}",message,url);
// 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);
}
}
}

View File

@@ -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;
}

View File

@@ -44,7 +44,7 @@ public class PhpOnlineStudyRecordScheduledTasks {
RestHighLevelClient restHighLevelClient;
// todo 定时、分批、数据库名
//@XxlJob("phpOnlineStudyRecordSyncEsTask")
@XxlJob("phpOnlineStudyRecordSyncEsTask")
public List<String> phpOnlineStudyRecordSyncEs(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
log.info("开始同步PHP学习记录到ES");

View File

@@ -9,30 +9,18 @@ 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.api.CourseFullTextApi;
import com.xboe.module.course.dto.AiVideoResourceRsp;
import com.xboe.module.course.dto.BoeaiSubtitleRsp;
import com.xboe.module.course.dto.CourseFullText;
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;
@@ -48,6 +36,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;
@@ -71,7 +64,7 @@ import lombok.extern.slf4j.Slf4j;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
//添加AI课程学习内容
/**
* 课程学习的内容
*/
@@ -109,14 +102,6 @@ public class StudyCourseApi extends ApiBaseController{
@Autowired
StringRedisTemplate redisTemplate;
@Resource
private ICourseTagService courseTagService;
@Autowired
CourseFullTextApi courseFullTextApi;
@Value("${kjb.aicoreUrl}")
private String aicoreUrl;
/**
* 用于查询课程的学习记录
@@ -184,22 +169,8 @@ 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);
}
//获取课程AI详情
log.info("---- KJB 获取课程详情 ---");
CourseFullText courseFullText = new CourseFullText();
courseFullText.setId(cid);
courseFullTextApi.getCourseFromKJB(courseFullText,course);
rs.put("course",course1);
//rs.put("course",course);
rs.put("course",course);
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(cid);
if(crowd!=null && crowd) {
rs.put("crowds",courseCrowdList);
@@ -235,14 +206,7 @@ public class StudyCourseApi extends ApiBaseController{
List<CourseContent> cclist=contentService.getByCourseId(cid);
List<CourseSection> sectionlist=sectionService.getByCourseId(cid);
List<CourseTeacher> teachers=courseService.findTeachersByCourseId(cid);
if(cclist!=null && !cclist.isEmpty()){
for (CourseContent cc : cclist) {
log.info("根据视频信息查询AI字幕数据cc = " + cc.toString());
this.getVtt( cid , cc);
}
}
//获取教师的介绍信息,因为一门课程 的教师不会太多,所以这里简单直接遍历查询,后续再优化
for(CourseTeacher ct : teachers) {
Teacher t = teacherService.get(ct.getTeacherId());
@@ -250,7 +214,6 @@ public class StudyCourseApi extends ApiBaseController{
ct.setRemark(t.getDescription());
ct.setSupplier(t.getSupplier());
ct.setTeacherType(t.getTeacherType());
ct.setPhoto(t.getPhoto());
}
if(redisTemplate.opsForValue().get(ct.getTeacherId())==null){
List<String>list=new ArrayList<>();
@@ -268,7 +231,6 @@ public class StudyCourseApi extends ApiBaseController{
}
}
rs.put("isCrowd",pass);
rs.put("contents",cclist);
rs.put("sections",sectionlist);
@@ -358,35 +320,6 @@ 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>
@@ -423,8 +356,7 @@ public class StudyCourseApi extends ApiBaseController{
*/
@PostMapping("/study")
public JsonResponse<String> study(@RequestBody StudyContentDto sci, HttpServletRequest request){
log.info("study已进入");
if(StringUtils.isBlank(sci.getStudyId())){
return error("参数错误");
}

View File

@@ -240,17 +240,17 @@ public class StudyCourseESApi extends ApiBaseController{
* @return
* @throws IOException
*/
// @PostMapping("/phpOnlineStudyRecordSyncEs")
// public JsonResponse<List<String>> phpOnlineStudyRecordSyncEs(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
// List<String> courseStudyDtoList = phpOnlineStudyRecordScheduledTasks.phpOnlineStudyRecordSyncEs(syncTimePointOfBegin, syncTimePointOfEnd, isOnlyRead);
// return success(courseStudyDtoList);
// }
//
// @PostMapping("/phpOnlineStudyRecordSyncEsOfFull")
// public JsonResponse<List<String>> phpOnlineStudyRecordSyncEsOfFull(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
// List<String> courseStudyDtoList = phpOnlineStudyRecordScheduledTasks.phpOnlineStudyRecordSyncEsOfFull(syncTimePointOfBegin, syncTimePointOfEnd, isOnlyRead);
// return success(courseStudyDtoList);
// }
@PostMapping("/phpOnlineStudyRecordSyncEs")
public JsonResponse<List<String>> phpOnlineStudyRecordSyncEs(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
List<String> courseStudyDtoList = phpOnlineStudyRecordScheduledTasks.phpOnlineStudyRecordSyncEs(syncTimePointOfBegin, syncTimePointOfEnd, isOnlyRead);
return success(courseStudyDtoList);
}
@PostMapping("/phpOnlineStudyRecordSyncEsOfFull")
public JsonResponse<List<String>> phpOnlineStudyRecordSyncEsOfFull(Long syncTimePointOfBegin, Long syncTimePointOfEnd, Integer isOnlyRead) throws IOException {
List<String> courseStudyDtoList = phpOnlineStudyRecordScheduledTasks.phpOnlineStudyRecordSyncEsOfFull(syncTimePointOfBegin, syncTimePointOfEnd, isOnlyRead);
return success(courseStudyDtoList);
}
}

View File

@@ -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);
}
}

View File

@@ -4,11 +4,8 @@ import java.time.LocalDateTime;
import java.util.List;
import java.util.concurrent.TimeUnit;
import com.alibaba.fastjson.JSONObject;
import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName;
import com.xboe.module.course.dao.ThreadLogDao;
import com.xboe.school.study.dto.StudyContentDto;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -35,8 +32,7 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
StudyCourseItemDao scItemDao;
@Autowired
StringRedisTemplate redisTemplate;
@Autowired
private ThreadLogDao threadLogDao;
@Resource
private ThirdApi thirdApi;
@@ -49,8 +45,6 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
public void finishCheck(String studyId,String courseId,Integer total,String token){
if(StringUtils.isNotEmpty(redisTemplate.opsForValue().get(studyId + "_" + courseId + "_" + total))){
log.info("进入埋点finishCheck");
saveThreadLog(studyId, courseId, total, token);
return ;
}
@@ -79,8 +73,6 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
UpdateBuilder.create("finishTime",now),
UpdateBuilder.create("status",StudyCourse.STATUS_FINISH));
redisTemplate.opsForValue().set(studyId + "_" + courseId + "_" + total, "100", 24, TimeUnit.HOURS);
log.info("进入埋点finishCheck");
saveThreadLog(studyId, courseId, total, token);
}else {
super.updateMultiFieldById(studyId,
UpdateBuilder.create("progress",percent),
@@ -93,41 +85,6 @@ public class StudyCourseDao extends BaseDao<StudyCourse> {
log.info("在线课学习记录"+allUserList);
}
private void saveThreadLog(String studyId,String courseId,Integer total,String token) {
try {
JSONObject extraData = new JSONObject();
extraData.put("studyId", studyId);
extraData.put("courseId", courseId);
extraData.put("total", total);
extraData.put("token", token);
LocalDateTime now = LocalDateTime.now();
String threadName = Thread.currentThread().getName();
String sql = "INSERT INTO boe_thread_log (system_name,module_name,action_name,level,content,thread_name,extra_data,remark,create_time,create_id,create_name,update_time,update_id,update_name) "
+ "VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14)";
threadLogDao.sqlUpdate(sql,
"学习",
"学习进度更新",
"更新StudyCourse进度完成",
"info",
null,
threadName,
extraData.toJSONString(),
null,
now,
null,
null,
now,
null,
null);
log.info("saveThreadLog插入成功");
} catch (Exception ex) {
log.error("保存线程日志失败", ex);
}
}
public void finishCheck1(String studyId,String courseId,Integer total){
LocalDateTime now=LocalDateTime.now();
//已完成的内容

View File

@@ -10,13 +10,11 @@ import java.util.Map;
import javax.transaction.Transactional;
import com.xboe.module.course.dao.ThreadLogDao;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSONObject;
import com.xboe.common.OrderCondition;
import com.xboe.common.PageList;
import com.xboe.core.orm.FieldFilters;
@@ -54,8 +52,6 @@ public class StudyServiceImpl implements IStudyService{
@Autowired
StringRedisTemplate redisTemplate;
@Autowired
private ThreadLogDao threadLogDao;
@Override
public StudyCourseItem checkHas(String studyId,String contentId) {
@@ -86,8 +82,6 @@ public class StudyServiceImpl implements IStudyService{
sci.setStudyDuration(0);
sci.setCourseId(dto.getCourseId());
sci.setCsectionId(dto.getCsectionId());
log.info("saveStudyInfo进入埋点");
saveThreadLog(dto);
}
//进度状态
if(dto.getProgress()==null) {
@@ -500,52 +494,4 @@ public class StudyServiceImpl implements IStudyService{
scDao.finishCheck(studyId,courseId,cnum,token);
}
private void saveThreadLog(StudyContentDto dto) {
try {
JSONObject extraData = new JSONObject();
extraData.put("studyId", dto.getStudyId());
extraData.put("contentId", dto.getContentId());
extraData.put("aid", dto.getAid());
LocalDateTime now = LocalDateTime.now();
Long creatorId = parseLong(dto.getAid());
String creatorName = dto.getAname();
String threadName = Thread.currentThread().getName();
String sql = "INSERT INTO boe_thread_log (system_name,module_name,action_name,level,content,thread_name,extra_data,remark,create_time,create_id,create_name,update_time,update_id,update_name) "
+ "VALUES (?1,?2,?3,?4,?5,?6,?7,?8,?9,?10,?11,?12,?13,?14)";
threadLogDao.sqlUpdate(sql,
"学习",
"学习进度更新",
"新增StudyCourseItem",
"info",
null,
threadName,
extraData.toJSONString(),
null,
now,
creatorId,
creatorName,
now,
creatorId,
creatorName);
log.info("saveStudyInfo埋点插入成功");
} catch (Exception ex) {
log.error("保存线程日志失败 studyId={}, contentId={}, aid={}", dto.getStudyId(), dto.getContentId(), dto.getAid(), ex);
}
}
private Long parseLong(String value) {
if(StringUtils.isBlank(value)) {
return null;
}
try {
return Long.valueOf(value);
}catch (NumberFormatException ex){
log.warn("无法解析为数字的aid: {}", value);
return null;
}
}
}

View File

@@ -11,22 +11,22 @@ spring:
cloud:
nacos:
discovery:
server-addr: 192.168.10.74:8848
server-addr: 192.168.0.253:8848
config:
server-addr: 192.168.10.74:8848
server-addr: 192.168.0.253:8848
redis:
database: 2
host: 39.104.123.58
password: Ebiz2020
port: 6378
database: 1
host: 192.168.0.253
password: boe@123
port: 6379
jpa:
hibernate:
ddl-auto: none
datasource:
driverClassName: com.mysql.jdbc.Driver
url: jdbc:mysql://rm-hp3cpkk0u50q90eu9vo.mysql.huhehaote.rds.aliyuncs.com:3306/ebiz_doc_manage?characterEncoding=utf8&useUnicode=true&serverTimezone=Asia/Shanghai&useSSL=false&allowMultiQueries=true
username: ebiz_ai
password: ebiz_ai123
url: jdbc:mysql://192.168.0.253:3306/boe_base?useSSL=false&useUnicode=true&characterEncoding=UTF8&zeroDateTimeBehavior=convertToNull
username: root
password: boe#1234A
type: com.zaxxer.hikari.HikariDataSource
hikari:
auto-commit: true
@@ -35,12 +35,6 @@ spring:
connection-timeout: 30000
max-lifetime: 1800000
maximum-pool-size: 20
activemq:
broker-url: tcp://192.168.10.74:61616
user: admin
password: admin
jms:
pub-sub-domain: true
logging:
level:
org:
@@ -113,7 +107,7 @@ aop-log-record:
#不进行拦截的包或者类
excludeClassNames:
activemq:
broker-url: tcp://192.168.10.74:61616
broker-url: tcp://192.168.0.253:61616
user: admin
password: admin
elasticsearch:

View File

@@ -40,12 +40,6 @@ spring:
web:
resources:
static-locations: file:E:/Projects/BOE/10/static
activemq:
broker-url: tcp://10.251.129.51:61616
user: admin
password: admin
jms:
pub-sub-domain: true
server:
port: 9090
tomcat:

View File

@@ -33,12 +33,6 @@ spring:
connection-timeout: 30000
max-lifetime: 1800000
maximum-pool-size: 20
activemq:
broker-url: tcp://10.251.113.100:61616
user: admin
password: admin
jms:
pub-sub-domain: true
logging:
level:
org:
@@ -72,7 +66,7 @@ xboe:
user:
password:
email:
url: http://u.boe.com/infrasApi/sendMsg/sendMail
url: https://u.boe.com/api/b1/email/send
from: boeu_learning@boe.com.cn
user:
security:
@@ -85,15 +79,13 @@ xboe:
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
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: 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
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff
file-upload-callback-url: http://10.251.113.95:9090/xboe/m/boe/caseDocumentLog/uploadCallback
use-white-list: true
white-user-code-list:
- "00004409"
@@ -116,210 +108,10 @@ xboe:
- "00005011"
- "10827857"
- "11339772"
- "pctest06"
# 20251202 新增天使用户
- "30103141"
- "60001391"
- "61001278"
- "30101301"
- "10444837"
- "50102190"
- "10745030"
- "11417101"
- "11305432"
- "10103037"
- "10035168"
- "30118060"
- "11490910"
- "11402931"
- "50102196"
- "00004896"
- "98050025"
- "15014359"
- "98000758"
- "10111538"
- "62000137"
- "10621476"
- "11698996"
- "10626304"
- "1215826"
- "30101887"
- "10111915"
- "11456852"
- "126458"
- "30141438"
- "10209179"
- "22BT15420"
- "21BB2053"
- "10449861"
- "130325"
- "11331818"
- "10117022"
- "10105891"
- "121649"
- "110338"
- "1217784"
- "30105038"
- "98000792"
- "60001146"
- "11698607"
- "11493629"
- "10164819"
- "11463452"
- "10412122"
- "11677116"
- "98000780"
- "61004269"
- "1218902"
- "111038"
- "10056775"
- "50125311"
- "50100445"
- "00003320"
- "11672602"
- "30129421"
- "11433296"
- "11759796"
- "10063656"
- "10829939"
- "98050190"
- "10061076"
- "60001460"
- "10415155"
- "60000626"
- "110791"
- "60000984"
- "62000025"
- "11794394"
- "11681568"
- "00002915"
- "1210874"
- "132046"
- "10157955"
- "00004409"
- "10773520"
- "102403"
- "10119108"
- "10062300"
- "10334899"
- "10111689"
- "10258267"
- "60000327"
- "50100096"
- "10075741"
- "1000477"
- "1218405"
- "132666"
- "10183064"
- "50101990"
- "120869"
- "11291711"
- "11670020"
- "11321710"
- "10855714"
- "11331449"
- "50108923"
- "66001553"
- "81011081"
- "11098405"
- "10158509"
- "11327800"
- "10065717"
- "10897206"
- "30135784"
- "1200373"
- "10048566"
- "10059710"
- "11834720"
- "1200384"
- "60000973"
- "11282207"
- "40865"
- "10811920"
- "00003324"
- "00003937"
- "10031853"
- "1201730"
- "00004615"
- "10613607"
- "10166435"
- "11407507"
- "21BB0031"
- "00002198"
- "30104243"
- "10840493"
- "10046158"
- "132164"
- "11257354"
- "11753398"
- "10230265"
- "11293165"
- "10114925"
- "S638"
- "10833174"
- "10926203"
- "124046"
- "201181"
- "11319329"
- "10884794"
- "10331955"
- "60000847"
- "1411"
- "126581"
- "00003375"
- "132539"
- "98050455"
- "10053666"
- "11697194"
- "61002398"
- "00002971"
- "14157"
- "132989"
- "50103467"
- "37315"
- "10088583"
- "11048954"
- "110202"
- "30141433"
- "1000079"
- "11783149"
- "10025448"
- "98000579"
- "10614158"
- "30104381"
- "60000122"
- "11074875"
- "10009047"
- "10228087"
- "10875722"
- "10041401"
- "110679"
- "11167945"
- "11288196"
- "00003111"
- "11780879"
- "10836255"
- "10753364"
- "50102132"
- "10711537"
- "15001329"
- "11733703"
- "10450632"
- "98050011"
- "10224644"
- "120931"
- "10743223"
- "107873"
- "11141942"
- "120434"
- "126466"
- "98050020"
- "10928732"
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
@@ -343,8 +135,4 @@ aop-log-record:
password: admin
elasticsearch:
host: 10.251.88.218
port: 9200
kjb:
aicoreUrl: http://10.232.28.95:8080
videoUrlPrefix: https://u.boe.com/upload
port: 9200

View File

@@ -40,12 +40,6 @@ spring:
web:
resources:
static-locations: file:E:/Projects/BOE/10/static
activemq:
broker-url: tcp://10.251.129.25:61616
user: admin
password: admin
jms:
pub-sub-domain: true
server:
port: 9090
tomcat:
@@ -110,7 +104,7 @@ xboe:
user: elastic
password: Boe@es123
email:
url: http://127.0.0.1/infrasApi/sendMsg/sendMail
url: http://10.251.186.27/api/b1/email/send
from: boeu_learning@boe.com.cn
user:
security:
@@ -125,7 +119,6 @@ xboe:
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:
@@ -151,7 +144,6 @@ xboe:
- "11339772"
alert-email-recipients:
- chengmeng@boe.com.cn
ai-chat-root-path: /home/www/elearning/upload/ai/chat
jasypt:
encryptor:
algorithm: PBEWithMD5AndDES
@@ -160,10 +152,6 @@ jasypt:
boe:
domain: http://10.251.186.27
kjb:
aicoreUrl: http://10.251.186.27:8088
videoUrlPrefix: https://u-pre.boe.com/upload
ok:
http:
connect-timeout: 30

View File

@@ -50,9 +50,6 @@ ok:
write-timeout: 300
max-idle-connections: 200
keep-alive-duration: 300
activemq:
topic:
name: case_ai_chat_stop_topic
boe:
domain: http://127.0.0.1
orgTree:

View File

@@ -1,82 +0,0 @@
{
"properties": {
"conversationId": {
"type": "keyword",
"index": true
},
"query": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"answer": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"caseRefer": {
"type": "nested",
"properties": {
"caseId": {
"type": "keyword",
"index": true
},
"title": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"authorName": {
"type": "keyword",
"index": true
},
"keywords": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"content": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
}
}
},
"suggestions": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"userId": {
"type": "keyword",
"index": true
},
"timestamp": {
"type": "date",
"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"
},
"status": {
"type": "integer"
},
"errorMsg": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
},
"likeStatus": {
"type": "keyword",
"index": true
},
"feedback": {
"type": "text",
"analyzer": "ik_max_word",
"search_analyzer": "ik_smart"
}
}
}

View File

@@ -31,42 +31,26 @@
</encoder>
</appender>
<appender name="caseAiChat"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<!-- Log file error output -->
<appender name="error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/error.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>${log.path}/%d{yyyy-MM}/error.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>
<maxFileSize>50MB</maxFileSize>
<maxHistory>30</maxHistory>
</rollingPolicy>
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<file>${log.path}/caseAiChat.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>${log.path}/caseAiChat.%d{yyyy-MM-dd}.log</fileNamePattern>
</rollingPolicy>
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
<level>ERROR</level>
</filter>
</appender>
<!-- Log file error output -->
<!-- <appender name="caseAiChat" class="ch.qos.logback.core.rolling.RollingFileAppender">-->
<!-- <file>${log.path}/caseAiChat.log</file>-->
<!-- <rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">-->
<!-- <fileNamePattern>${log.path}/%d{yyyy-MM}/caseAiChat.%d{yyyy-MM-dd}.%i.log.gz</fileNamePattern>-->
<!-- <maxFileSize>50MB</maxFileSize>-->
<!-- <maxHistory>30</maxHistory>-->
<!-- </rollingPolicy>-->
<!-- <encoder>-->
<!-- <pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>-->
<!-- </encoder>-->
<!-- <filter class="ch.qos.logback.classic.filter.ThresholdFilter">-->
<!-- <level>ERROR</level>-->
<!-- </filter>-->
<!-- </appender>-->
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="info"/>
<!-- <appender-ref ref="console"/>-->
<!-- <appender-ref ref="error"/> -->
</root>
<logger name="caseAiChatLogger" additivity="false" level="INFO">
<appender-ref ref="caseAiChat"/>
</logger>
</configuration>

View File

@@ -47,26 +47,10 @@
</filter>
</appender>
<appender name="caseAiChat"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<encoder>
<pattern>%date [%thread] %-5level [%logger{50}] %file:%line - %msg%n</pattern>
<charset>UTF-8</charset>
</encoder>
<File>${log.path}/caseAiChat.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>${log.path}/caseAiChat.%d{yyyy-MM-dd}.log</FileNamePattern>
</rollingPolicy>
</appender>
<!-- Level: FATAL 0 ERROR 3 WARN 4 INFO 6 DEBUG 7 -->
<root level="INFO">
<appender-ref ref="debug"/>
<appender-ref ref="error"/>
<appender-ref ref="console"/>
</root>
<logger name="caseAiChatLogger" additivity="false" level="INFO">
<appender-ref ref="caseAiChat"/>
</logger>
</configuration>

View File

@@ -0,0 +1,215 @@
-- 数据迁移SQL项目与报名
-- 执行顺序:
-- 1.1 查看项目数据量
-- 1.2 预览项目数据
-- 1.3 迁移项目信息
-- 1.4 验证项目迁移结果
-- 2.1 查看报名数据量按项目ID
-- 2.2 预览报名数据
-- 2.3 获取新项目ID
-- 2.4 写入报名数据使用新项目ID
-- 2.5 验证报名迁移结果
-- 任务1项目数据迁移eln_boe_mixture_project -> boe_new.project_info条件is_deleted='0' AND program_name='社招新员工在线入职学习'
-- 步骤1.1:查看符合条件的数据量(执行前验证)
SELECT COUNT(*) AS data_count
FROM elearninglms.eln_boe_mixture_project
WHERE is_deleted = '0'
AND program_name = '社招新员工在线入职学习';
-- 步骤1.2:查看要迁移的数据详情(执行前验证)
SELECT *
FROM elearninglms.eln_boe_mixture_project
WHERE is_deleted = '0'
AND program_name = '社招新员工在线入职学习';
-- 步骤1.3执行数据迁移INSERT INTO ... SELECT
INSERT INTO boe_new.project_info (
name,
pic_url,
type,
begin_time,
end_time,
manager_id,
remark,
status,
num_value,
introduction,
new_type,
deleted,
unlock_mode,
rank_flag,
attach_switch,
bpm_flag,
load_flag,
create_time,
create_id,
update_time,
update_id
)
SELECT
p.program_name AS name,
p.theme_url AS pic_url,
1 AS type, -- 项目类别固定为1
CASE
WHEN p.open_start_time IS NOT NULL AND p.open_start_time > 0
THEN FROM_UNIXTIME(p.open_start_time)
WHEN p.start_time IS NOT NULL AND p.start_time > 0
THEN FROM_UNIXTIME(p.start_time)
ELSE NULL
END AS begin_time,
CASE
WHEN p.open_end_time IS NOT NULL AND p.open_end_time > 0
THEN FROM_UNIXTIME(p.open_end_time)
WHEN p.end_time IS NOT NULL AND p.end_time > 0
THEN FROM_UNIXTIME(p.end_time)
ELSE NULL
END AS end_time,
p.project_manager_id AS manager_id,
COALESCE(p.program_desc, p.program_desc_nohtml, '') AS remark,
CASE
WHEN p.status = '0' THEN 0 -- 临时 → 草稿
WHEN p.status = '1' THEN 1 -- 正常 → 已发布
WHEN p.status = '2' THEN -1 -- 停用 → 已结束
ELSE 0
END AS status,
p.program_code AS num_value,
COALESCE(p.program_desc_nohtml, p.program_desc, '') AS introduction,
2 AS new_type, -- 学习项目
0 AS deleted, -- 未删除
1 AS unlock_mode, -- 自由模式
0 AS rank_flag, -- 不显示积分排行榜
1 AS attach_switch, -- 共享文档开启
0 AS bpm_flag, -- 报名审批关闭
0 AS load_flag, -- 下载成绩关闭
FROM_UNIXTIME(p.created_at) AS create_time,
CAST(p.created_by AS UNSIGNED) AS create_id,
FROM_UNIXTIME(COALESCE(p.updated_at, p.created_at)) AS update_time,
CAST(COALESCE(p.updated_by, p.created_by) AS UNSIGNED) AS update_id
FROM elearninglms.eln_boe_mixture_project p
WHERE p.is_deleted = '0'
AND p.program_name = '社招新员工在线入职学习'
AND NOT EXISTS (
-- 防止重复插入:如果项目名称已存在则跳过
SELECT 1
FROM boe_new.project_info pi
WHERE pi.name = p.program_name
AND pi.deleted = 0
);
-- 步骤1.4:验证迁移结果
SELECT
COUNT(*) AS migrated_count,
name,
status,
begin_time,
end_time
FROM boe_new.project_info
WHERE name = '社招新员工在线入职学习'
AND deleted = 0
GROUP BY name, status, begin_time, end_time;
-- 任务2项目报名数据迁移eln_boe_mixture_project_enroll -> boe_base.boe_study_course
-- 迁移全部报名数据(包括已删除记录,按 is_deleted 映射状态)
-- 步骤2.1:查看符合条件的数据量(执行前验证)
-- 注意:需要先将 '123xxx' 替换为实际的项目IDkid
SELECT COUNT(*) AS enroll_count
FROM elearninglms.eln_boe_mixture_project_enroll
WHERE program_id = '123xxx'; -- 请替换为实际的项目IDkid
-- 步骤2.2:查看要迁移的数据详情(执行前验证)
SELECT *
FROM elearninglms.eln_boe_mixture_project_enroll
WHERE program_id = '123xxx' -- 请替换为实际的项目IDkid
LIMIT 100;
-- 步骤2.3获取新项目ID
SET @new_project_id = (
SELECT id FROM boe_new.project_info
WHERE name = '社招新员工在线入职学习' AND deleted = 0
ORDER BY id DESC LIMIT 1
);
-- 步骤2.4写入报名数据使用新项目ID
INSERT INTO boe_base.boe_study_course (
course_id,
course_type,
course_name,
aid,
aname,
source,
add_time,
start_time,
last_score,
status,
progress,
remark
)
SELECT
pi.id AS course_id, -- 使用新项目表的自增ID
90 AS course_type,
COALESCE(pi.name, p.program_name, '') AS course_name,
e.user_id AS aid,
COALESCE(u.real_name, '') AS aname,
CASE
WHEN e.enroll_method = 'self' THEN 1
WHEN e.enroll_method = 'admin' THEN 2
WHEN e.enroll_method = 'manager' THEN 3
ELSE 1
END AS source,
FROM_UNIXTIME(e.enroll_time) AS add_time,
FROM_UNIXTIME(e.enroll_time) AS start_time,
NULL AS last_score,
CASE
WHEN e.enroll_type = '1' AND e.approved_state = '1' AND e.is_deleted = '0' THEN 2
WHEN e.enroll_type = '3' THEN 8
WHEN e.cancel_state = '1' THEN 8
WHEN e.is_deleted = '1' THEN 8
ELSE 1
END AS status,
0 AS progress,
CONCAT('迁移自项目报名表报名ID', e.kid) AS remark
FROM elearninglms.eln_boe_mixture_project_enroll e
LEFT JOIN elearninglms.eln_boe_mixture_project p
ON e.program_id = p.kid
LEFT JOIN boe_new.project_info pi
ON p.program_name = pi.name AND pi.deleted = 0
LEFT JOIN elearninglms.eln_fw_user u
ON e.user_id = u.kid
WHERE e.program_id = '123xxx' -- 请替换为实际的项目IDkid
AND pi.id = @new_project_id -- 使用新项目ID
AND NOT EXISTS (
SELECT 1
FROM boe_base.boe_study_course sc
WHERE sc.course_id = @new_project_id
AND sc.aid = e.user_id
);
-- 步骤2.5:验证迁移结果
SELECT
COUNT(*) AS migrated_count,
status,
COUNT(CASE WHEN last_score IS NOT NULL THEN 1 END) AS has_score_count
FROM boe_base.boe_study_course
WHERE course_id = @new_project_id
GROUP BY status;
-- 回滚SQL
-- 回滚步骤R1确认新项目ID如变量丢失可重新获取
--SET @new_project_id = (
-- SELECT id FROM boe_new.project_info
-- WHERE name = '社招新员工在线入职学习' AND deleted = 0
-- ORDER BY id DESC LIMIT 1
--);
--
---- 回滚步骤R2回滚报名数据按备注标记仅删除本次迁移写入的数据
--DELETE FROM boe_base.boe_study_course
--WHERE course_id = @new_project_id
-- AND remark LIKE '迁移自项目报名表%';
--
---- 回滚步骤R3回滚项目信息谨慎执行确认仅影响本次迁移记录
--DELETE FROM boe_new.project_info
--WHERE id = @new_project_id
-- AND name = '社招新员工在线入职学习'
-- AND deleted = 0;

View File

@@ -0,0 +1,187 @@
# 数据迁移方案文档
## 一、迁移概述
本次迁移涉及两个数据迁移任务:
1. **项目数据迁移**:从 `elearninglms.eln_boe_mixture_project` 迁移到 `boe_new.project_info`
2. **项目报名数据迁移**:从 `elearninglms.eln_boe_mixture_project_enroll` 迁移到 `boe_base.boe_study_course`
---
## 二、任务1项目数据迁移
### 2.1 迁移信息
- **源表**`elearninglms.eln_boe_mixture_project`
- **目标表**`boe_new.project_info`
- **迁移条件**`is_deleted='0'` AND `program_name='社招新员工在线入职学习'`
### 2.2 字段映射关系
| 源表字段 | 目标表字段 | 说明 | 转换规则 |
|---------|-----------|------|---------|
| `kid` | - | 项目IDvarchar | 不直接映射目标表id为自增 |
| `program_name` | `name` | 项目名称 | 直接映射 |
| `program_desc` | `remark` | 项目描述/说明 | 直接映射 |
| `theme_url` | `pic_url` | 封面图地址 | 直接映射 |
| `start_time` / `open_start_time` | `begin_time` | 开始时间 | 优先使用 `open_start_time`,空则用 `start_time`,需转换为 timestamp |
| `end_time` / `open_end_time` | `end_time` | 结束时间 | 优先使用 `open_end_time`,空则用 `end_time`,需转换为 timestamp |
| `project_manager_id` | `manager_id` | 项目经理ID | 直接映射 |
| `status` | `status` | 状态 | 需要转换:'0'→0(草稿), '1'→1(已发布), '2'→-1(已结束) |
| `created_at` | `create_time` | 创建时间 | 需转换为 timestamp |
| `created_by` | `create_id` | 创建人ID | 需转换为 bigint |
| `updated_at` | `update_time` | 更新时间 | 需转换为 timestamp |
| `updated_by` | `update_id` | 更新人ID | 需转换为 bigint |
| `program_code` | `num_value` | 项目编号 | 直接映射 |
| `program_desc` / `program_desc_nohtml` | `introduction` | 项目介绍 | 优先使用 `program_desc_nohtml` |
### 2.3 默认值设置
- `type`: 1项目类别
- `new_type`: 2学习项目
- `deleted`: 0未删除
- `unlock_mode`: 1自由模式
- `rank_flag`: 0不显示积分排行榜
- `attach_switch`: 1共享文档开启
- `bpm_flag`: 0报名审批关闭
- `load_flag`: 0下载成绩关闭
### 2.4 注意事项
1. 目标表的 `id` 字段为自增主键,无需手动设置
2. 时间字段需要从 int时间戳转换为 timestamp
3. 状态字段需要根据源表的值进行映射转换
4. 如果源表中存在多条符合条件的记录,需要确认是否全部迁移或仅迁移最新的一条
---
## 三、任务2项目报名数据迁移
### 3.1 迁移信息
- **源表**`elearninglms.eln_boe_mixture_project_enroll`
- **目标表**`boe_base.boe_study_course`
- **迁移条件**`program_id='123xxx'`注意实际执行时需要替换为真实的项目ID
- **重要说明****迁移全部报名数据包括已删除的记录is_deleted='1'**。已删除的记录在状态映射时会被标记为"终止"状态status=8
### 3.2 字段映射关系
| 源表字段 | 目标表字段 | 说明 | 转换规则 |
|---------|-----------|------|---------|
| `program_id` | `course_id` | 项目ID作为课程ID | 直接映射 |
| `user_id` | `aid` | 学员ID | 直接映射 |
| - | `last_score` | 学习成绩 | 初始设置为 NULL后续需要从成绩表关联更新 |
| `enroll_type` + `approved_state` | `status` | 完成状态 | 根据业务规则映射(见下方) |
| `enroll_time` | `add_time` | 加入时间(报名时间) | 需转换为 datetime |
| `enroll_time` | `start_time` | 开始学习时间 | 需转换为 datetime |
### 3.3 状态映射规则
根据 `boe_study_course` 表的 status 定义:
- `STATUS_NOSTUDY = 1`(未开始学习)
- `STATUS_STUDYING = 2`(学习中)
- `STATUS_ABORTED = 8`(终止)
- `STATUS_FINISH = 9`(学习完成)
**状态映射逻辑**
```sql
CASE
WHEN enroll_type = '1' AND approved_state = '1' AND is_deleted = '0' THEN 2 -- 报名成功且审批同意 → 学习中
WHEN enroll_type = '3' THEN 8 -- 拒绝报名 → 终止
WHEN cancel_state = '1' THEN 8 -- 取消审批同意 → 终止
WHEN is_deleted = '1' THEN 8 -- 已删除 → 终止
ELSE 1 -- 其他情况 → 未开始
END AS status
```
### 3.4 其他字段设置
- `course_type`: 需要根据项目类型设置(默认为项目类型对应的课程类型)
- `course_name`: 需要关联项目表获取项目名称
- `aname`: 需要关联用户表获取学员姓名
- `source`: 根据 `enroll_method` 映射('self'→1, 'admin'→2, 'manager'→3
- `progress`: 初始设置为 0 或 NULL
- `last_score`: 初始设置为 NULL需要后续从成绩表更新
### 3.5 注意事项
1. **学习成绩last_score**:源表中没有直接的成绩字段,需要:
- 方案A从其他成绩表`eln_ln_examination_result_user`)关联获取
- 方案B先设置为 NULL后续通过业务逻辑更新
2. **完成状态status**:需要根据业务逻辑判断,当前映射规则仅供参考,实际使用时需要根据业务需求调整
3. **项目ID替换**SQL中的 `'123xxx'` 需要替换为实际的项目ID
4. **数据去重**:确保 `(course_id, aid)` 组合的唯一性,避免重复插入
5. **关联查询**:可能需要关联用户表获取学员姓名等信息
6. **全部数据迁移**:本次迁移会包含所有符合条件的报名记录,包括已删除的记录。已删除的记录会根据 `is_deleted='1'` 映射为终止状态status=8
---
## 四、执行步骤
### 4.1 执行前准备
1. **备份数据**:执行迁移前,务必备份源表和目标表
2. **验证条件**确认迁移条件是否正确特别是项目名称和项目ID
3. **数据检查**:检查源表中符合条件的数据量
4. **环境确认**:确认目标数据库连接和权限
### 4.2 执行顺序
1. **先执行任务1**:迁移项目数据
2. **获取新项目ID**记录迁移后的项目ID如果需要
3. **更新任务2的SQL**将项目ID替换为实际值
4. **执行任务2**:迁移项目报名数据
### 4.3 执行后验证
1. **数据量核对**:对比源表和目标表的记录数
2. **关键字段验证**:抽查关键字段是否正确迁移
3. **业务功能验证**:在系统中验证迁移后的数据是否正常
---
## 五、风险评估与回滚方案
### 5.1 风险点
1. **数据量**:如果数据量较大,可能影响系统性能
2. **字段类型不匹配**:时间戳转换、状态值转换可能出错
3. **数据完整性**:关联字段可能缺失或无效
4. **业务逻辑**:状态映射规则可能与实际业务不符
### 5.2 回滚方案
1. **备份恢复**:使用备份数据恢复目标表
2. **删除迁移数据**:根据迁移条件删除已迁移的数据
3. **数据修复**:手动修复错误的数据
---
## 六、附录
### 6.1 相关表结构
- `elearninglms.eln_boe_mixture_project`:源项目表
- `boe_new.project_info`:目标项目表
- `elearninglms.eln_boe_mixture_project_enroll`:源报名表
- `boe_base.boe_study_course`:目标课程学习表
### 6.2 状态值对照表
**项目状态映射**
- '0'(临时)→ 0草稿
- '1'(正常)→ 1已发布
- '2'(停用)→ -1已结束
**学习状态映射**
- 1未开始学习
- 2学习中
- 8终止
- 9学习完成
---