Compare commits

..

145 Commits

Author SHA1 Message Date
670788339
757279e7ba Merge branch 'merge-20251113-tag' into release-20250328-master 2025-11-19 10:53:28 +08:00
670788339
0b9db10c04 解决增加浏览量时会更新标签的问题 2025-11-19 10:51:40 +08:00
670788339
a6335abcc7 解决课程直接提审问题 2025-11-18 18:17:46 +08:00
670788339
7fd02ac25f 日志打印 2025-11-18 17:56:38 +08:00
670788339
344110fa1f Merge branch 'merge-20251113-tag' into release-20250328-master 2025-11-17 20:47:57 +08:00
670788339
6945b30828 标签解绑重新发布课程 2025-11-17 20:41:07 +08:00
joshen
347421ded4 Merge branch 'release-20250328-master' into release-20251107-master 2025-11-17 19:05:37 +08:00
670788339
2efe56ecda 取消第二排序 2025-11-17 19:03:21 +08:00
670788339
d47c0a891c 取消第二排序 2025-11-17 18:56:42 +08:00
670788339
fcce12aa0e 取消第二排序 2025-11-17 18:48:27 +08:00
liu.zixi
064356a788 邮件配置不取字典 2025-11-17 17:20:03 +08:00
liu.zixi
64034e6b04 邮件配置更新,并改为可获取字典 2025-11-17 17:19:56 +08:00
liu.zixi
71faee28da [prod] 白名单二次确认 2025-11-17 17:19:55 +08:00
670788339
48d82cb7eb Merge branch 'master-20251023-tag' into merge-20251113-tag 2025-11-17 09:35:27 +08:00
670788339
5848f431a4 在线版本 2025-11-14 14:41:10 +08:00
670788339
d30853db33 标签创建移除旧版本部分代码 2025-11-14 09:59:27 +08:00
liu.zixi
8cf20e9681 [prod] 大部分入口先关闭 2025-11-12 22:03:42 +08:00
liu.zixi
ed7ca71434 [prod] 换回正确的baseUrl 2025-11-12 22:03:39 +08:00
liu.zixi
437fc51c15 逻辑修正:已经上传成功过的,才不进行过滤 2025-11-12 22:03:37 +08:00
liu.zixi
b9cf8de52a [prod] 放开部分日志调试 2025-11-12 21:32:53 +08:00
liu.zixi
dc2cdf8b85 [prod] 生产临时修改域名;接口返回用户code 2025-11-12 21:17:20 +08:00
liu.zixi
50a7baa4dd [prod] 增加测试账号白名单 2025-11-12 19:59:52 +08:00
liu.zixi
99a4f9b12a [prod] 去掉批处理的一些日志 2025-11-12 18:31:49 +08:00
liu.zixi
a481dd619f 生产kId变更 2025-11-12 18:31:45 +08:00
liu.zixi
a95271ee36 ai对话错误信息处理2 2025-11-12 18:31:42 +08:00
liu.zixi
db73753c1f ai对话错误信息处理 2025-11-12 18:31:41 +08:00
670788339
31eec36b00 删除方法说明中报错@param 2025-11-12 16:52:42 +08:00
670788339
b628eeae55 Merge branch 'master-20251023-tag' into merge-20251113-tag
# 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-11-12 16:50:21 +08:00
670788339
f4d5dd03df 排序调整 2025-11-12 08:55:25 +08:00
670788339
dcfb929aaf id自增长 2025-11-10 18:30:43 +08:00
670788339
a50a29e33a 日志 2025-11-10 18:21:50 +08:00
670788339
10098e2e84 日志 2025-11-10 18:13:54 +08:00
670788339
16712cc020 标签提示 2025-11-10 17:51:29 +08:00
670788339
91cf87c8de 标签提示 2025-11-10 17:25:41 +08:00
670788339
2a3640b6e8 模糊查询 2025-11-08 15:39:37 +08:00
670788339
f5fc56c2d1 课程库热点标签排序 2025-11-08 15:22:59 +08:00
670788339
001106043c 标签查询排序调整 2025-11-07 11:25:22 +08:00
liu.zixi
ce84ea8121 生产环境配置 2025-11-07 08:59:19 +08:00
liu.zixi
89860eb080 批处理增加入参;
问答增加历史
2025-11-07 08:59:18 +08:00
liu.zixi
c701fae5ef 上传文档时url调整为案例详情页 2025-11-07 08:59:16 +08:00
liu.zixi
abf5642154 上传文档时增加url;
解决文件名错误的问题
2025-11-07 08:59:13 +08:00
liu.zixi
a0bba75f80 案例专家对话增加时长记录,增加任务;
上传文档时增加metadata
2025-11-07 08:59:12 +08:00
liu.zixi
d0e0115f27 [DAT] 业务处理挡板只保留更改时上传挡板 2025-11-07 08:59:10 +08:00
liu.zixi
33e2313eb0 [DAT] 配合业务处理挡板 2025-11-07 08:59:09 +08:00
liu.zixi
b4ca82ae73 [DAT] 对话接口加新的apiCode 2025-11-07 08:59:07 +08:00
liu.zixi
bff8ba166f [DAT] 数据挡板:业务处理失败 2025-11-07 08:59:06 +08:00
liu.zixi
b04a14d3f2 [DAT] 数据挡板:更新时,删除成功新增失败 2025-11-07 08:59:04 +08:00
liu.zixi
acb8d08379 [DAT] 重试时根据上一次执行步骤来决定 2025-11-07 08:59:03 +08:00
liu.zixi
eafcbf8337 [DAT] 数据挡板:接口调用失败挡板去除 2025-11-07 08:59:01 +08:00
liu.zixi
4f9f5711f7 [DAT] 数据挡板:更改时新增失败 2025-11-07 08:59:00 +08:00
liu.zixi
81aae0af37 [DAT] 数据挡板:新增、删除、更改全挡 2025-11-07 08:58:58 +08:00
liu.zixi
4303798fac [DAT] from改为带@的全称 2025-11-07 08:58:57 +08:00
liu.zixi
0b57f016f5 [DAT] 告警邮件配置 2025-11-07 08:58:55 +08:00
liu.zixi
9a04128a23 [DAT] 增加白名单配置 2025-11-07 08:58:54 +08:00
liu.zixi
dd6ad3c7e0 [DAT] email更换 2025-11-07 08:58:52 +08:00
liu.zixi
63e8bd28b3 [DAT] 去挡板 2025-11-07 08:58:51 +08:00
liu.zixi
c38c7b9c80 [DAT] 接口失败时,业务状态设为null 2025-11-07 08:58:50 +08:00
liu.zixi
45eb2e14b2 [DAT] upload时应当为接口失败 2025-11-07 08:58:48 +08:00
liu.zixi
286dc1e6d6 [DAT] upload加挡板 2025-11-07 08:58:46 +08:00
liu.zixi
11ed049a6a [DAT] 文档去重 2025-11-07 08:58:45 +08:00
liu.zixi
f9d2b8e92f [DAT] 显示摘要 2025-11-07 08:58:43 +08:00
liu.zixi
7adb7b6152 [DAT] 去挡板 2025-11-07 08:58:42 +08:00
liu.zixi
7895b1fee9 [DAT] 修复时间错误的问题;尝试修复发邮件 2025-11-07 08:58:40 +08:00
liu.zixi
f4c8e36167 [DAT] 接口调用失败的数据挡板2 2025-11-07 08:58:39 +08:00
liu.zixi
16255d5a88 [DAT] 接口调用失败的数据挡板 2025-11-07 08:58:38 +08:00
liu.zixi
12fea5d288 [DAT] 发邮件增加日志打印 2025-11-07 08:58:36 +08:00
liu.zixi
e4e10ddb73 [DAT] 放开重试挡板 2025-11-07 08:58:35 +08:00
liu.zixi
7284f9cb12 [DAT] 打日志查看 2025-11-07 08:58:33 +08:00
liu.zixi
f06eb9bc7d [DAT] 新增失败时发邮件 2025-11-07 08:58:32 +08:00
liu.zixi
f2a633958e [DAT] 批处理更改responseBody 2025-11-07 08:58:31 +08:00
liu.zixi
b0eb7796da [DAT] 去掉com.sun.mail依赖 2025-11-07 08:58:29 +08:00
liu.zixi
c077123b53 [DAT] 发送邮件实现方式再次修改 2025-11-07 08:58:28 +08:00
liu.zixi
c23c9ddf7c [DAT] 发送邮件实现方式修改 2025-11-07 08:58:26 +08:00
liu.zixi
bcfdf65140 [DAT] 调用时间查询逻辑修改 2025-11-07 08:58:25 +08:00
liu.zixi
e704930bca [DAT] 修改update方法调试 2025-11-07 08:58:23 +08:00
liu.zixi
1edb36622f [DAT] 删除时修改数据查询条件 2025-11-07 08:58:22 +08:00
liu.zixi
ea5c15a290 [DAT] 修改update方法只删除不上传的错误 2025-11-07 08:58:20 +08:00
liu.zixi
124e7bc1a5 [DAT] 照原型数据更新 2025-11-07 08:58:19 +08:00
liu.zixi
69433abc7b DAT测试配合 2025-11-07 08:58:16 +08:00
liu.zixi
e75190eef0 案例专家:增加部分情况下的日志记录 2025-11-07 08:58:15 +08:00
liu.zixi
e8dd77890f 案例专家:修正调用逻辑 2025-11-07 08:58:13 +08:00
liu.zixi
92a17be2f3 案例专家:新数据处理 2025-11-07 08:58:12 +08:00
liu.zixi
a1c718932a 换日志级别,调试 2025-11-07 08:58:11 +08:00
liu.zixi
c6ada98ca1 延长 Spring Boot 异步请求超时 2025-11-07 08:58:09 +08:00
liu.zixi
8f1c5d6943 okhttp的超时时长调到300秒 2025-11-07 08:58:07 +08:00
liu.zixi
4aea688693 整理es相关代码;增加手动调试用接口 2025-11-07 08:58:05 +08:00
liu.zixi
3056921ba6 案例专家:是否深度思考做成入参,先关闭思考 2025-11-07 08:58:03 +08:00
liu.zixi
ca2ff12b03 案例专家:es修改索引格式、添加event-stream专属线程池 2025-11-07 08:58:02 +08:00
liu.zixi
4eeb98d9cd 案例专家:yml中的用户列表加双引号 2025-11-07 08:58:00 +08:00
liu.zixi
6eafd85b9e 案例专家:修改白名单校验逻辑 2025-11-07 08:57:59 +08:00
liu.zixi
83d6a6419e 案例专家:修改yml文件一个配置的写法 2025-11-07 08:57:57 +08:00
liu.zixi
1a7e393710 案例专家:日志等级修改 2025-11-07 08:57:55 +08:00
liu.zixi
e1572a6629 案例专家:增加手动刷新索引功能 2025-11-07 08:57:54 +08:00
liu.zixi
b67c0f811b 案例专家:userId更换成code 2025-11-07 08:57:52 +08:00
liu.zixi
f58c1d4591 案例专家:userId更换成code 2025-11-07 08:57:51 +08:00
liu.zixi
c21bff226c 案例专家:打印入参,调试用 2025-11-07 08:57:49 +08:00
liu.zixi
b793c7dec8 案例专家:修改log等级,观察联调 2025-11-07 08:57:48 +08:00
liu.zixi
69a0866fc7 案例专家:修改批处理问题 2025-11-07 08:57:45 +08:00
liu.zixi
ecf39fe624 案例专家:邮件告警逻辑 2025-11-07 08:57:44 +08:00
liu.zixi
26f3b0bb04 批处理:JobHandler开发 2025-11-07 08:57:42 +08:00
liu.zixi
f0235d5294 批处理:JobHandler开发 2025-11-07 08:57:40 +08:00
liu.zixi
53b6a0203f 案例助手:代码整理和部分问题修复 2025-11-07 08:57:38 +08:00
liu.zixi
cf9ccaa7b9 案例助手:修复找不到旧会话的bug 2025-11-07 08:57:35 +08:00
liu.zixi
43fe31a4ec 案例助手:聊天接口兼容application/json 2025-11-07 08:57:33 +08:00
liu.zixi
88709c15a5 案例助手:增加@Transactional注解 2025-11-07 08:57:29 +08:00
liu.zixi
960de20658 案例助手:增加字段,增加白名单机制等 2025-11-07 08:57:27 +08:00
liu.zixi
7a74f70308 案例助手:聊天增加上传时间和企业信息 2025-11-07 08:57:21 +08:00
liu.zixi
b40469aaae 修复清空日志的bug 2025-11-07 08:57:18 +08:00
liu.zixi
d652e575f7 三方接口异步处理 2025-11-07 08:57:15 +08:00
liu.zixi
fd5d3da4b5 返回conversationId 2025-11-07 08:57:13 +08:00
liu.zixi
fb9d31e2ec 文件读取逻辑纠正 2025-11-07 08:57:10 +08:00
liu.zixi
9b5e3c47f5 修正AI接口的数据入库逻辑 2025-11-07 08:57:08 +08:00
liu.zixi
864a5bb797 修改不同环境回调地址 2025-11-07 08:57:07 +08:00
liu.zixi
e5d0602e56 修正编译错误 2025-11-07 08:57:06 +08:00
liu.zixi
8ca391de56 修正编译错误;
增加临时接口
2025-11-07 08:57:05 +08:00
liu.zixi
57dd8b14fb AI调用日志 重试功能补完 2025-11-07 08:57:04 +08:00
liu.zixi
d09d55d77b 案例专家功能提交 2025-11-07 08:57:03 +08:00
670788339
17999213cf 公共初始给个时间 2025-11-05 15:16:46 +08:00
670788339
9baa4c3595 存在私有也可创建 2025-11-05 14:27:00 +08:00
670788339
9119aa8579 存在私有也可创建 2025-11-05 14:23:03 +08:00
670788339
0b11c2ad9a 标签创建加判断 2025-11-05 14:02:33 +08:00
670788339
cb4eb1b1b6 标签 2025-11-05 13:34:56 +08:00
joshen
07b501742f Merge remote-tracking branch 'nyx/20251103-1282-fix-gj' into release-20250328-master
# Conflicts:
#	servers/boe-server-all/src/main/java/com/xboe/module/course/api/CourseFileApi.java
2025-11-04 16:58:24 +08:00
Caojr
748f7c5913 szx-1282 修改失败提示语 2025-11-04 14:09:26 +08:00
Caojr
5954d54e44 szx-1282 视频解码失败返回 2025-11-04 13:33:12 +08:00
Caojr
4ede914452 szx-1279 增加监控表 2025-11-03 17:53:26 +08:00
Caojr
00527271b6 szx-1283 撤回修改 2025-11-03 16:07:12 +08:00
Caojr
308a16f4b4 szx-1283 修改ffmpeg路径 2025-11-03 15:39:03 +08:00
Caojr
302a673515 szx-1283 修改ffmpeg路径 2025-11-03 15:13:21 +08:00
Caojr
49b69db0bf szx-1283 修改ffmpeg路径 2025-11-03 15:06:27 +08:00
Caojr
8a0b05079a szx-1283 修改依赖 2025-11-03 11:51:31 +08:00
Caojr
eaab48607d szx-1283 修改依赖 2025-11-03 11:45:32 +08:00
Caojr
309599f43f 增加异常日志 2025-11-03 10:57:42 +08:00
670788339
f9528a5705 恢复标签删除状态 2025-11-02 13:52:37 +08:00
670788339
28d84bd484 恢复标签删除状态 2025-11-02 13:35:19 +08:00
670788339
7f7279daa0 查询标签修改 2025-11-02 12:45:41 +08:00
670788339
99042619d2 查询标签修改 2025-11-02 10:30:02 +08:00
670788339
fb29e2b95c 查询标签修改 2025-11-01 17:27:09 +08:00
670788339
6bb4b6c4d5 课程详情页显示标签 2025-10-31 20:29:00 +08:00
670788339
264f31a69f 课程详情页显示标签 2025-10-31 20:08:17 +08:00
670788339
7f3b50b45c 课程查询tags调试 2025-10-31 15:30:50 +08:00
670788339
f315a94c81 课程查询tags 2025-10-31 15:08:45 +08:00
670788339
beeb3688a1 课程查询tags 2025-10-31 14:48:52 +08:00
670788339
5cffd908f5 课程查询tags 2025-10-31 13:53:05 +08:00
670788339
4d0f311bea 注释多余代码
提交审核时创建标签
2025-10-31 10:41:51 +08:00
36 changed files with 1097 additions and 342 deletions

View File

@@ -1,6 +1,7 @@
package com.xboe.module.assistance.service.impl; package com.xboe.module.assistance.service.impl;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.Properties; import java.util.Properties;
import javax.mail.Authenticator; import javax.mail.Authenticator;
@@ -22,12 +23,13 @@ import com.xboe.module.assistance.service.ISmtpEmailService;
@Slf4j @Slf4j
public class SmtpEmailServiceImpl implements ISmtpEmailService { public class SmtpEmailServiceImpl implements ISmtpEmailService {
// SMTP服务器配置信息 //region 默认SMTP服务器配置信息
private static final String SMTP_HOST = "mail.boe.com.cn"; 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_USERNAME = "boeu_learning@boe.com.cn";
private static final String SMTP_PASSWORD = "boeLms20250814Syse"; private static final String SMTP_PASSWORD = "boeLms20251112Syse";
private static final String SMTP_PORT = "465"; private static final String SMTP_PORT = "465";
private static final String SMTP_ENCRYPTION = "ssl"; private static final String SMTP_ENCRYPTION = "ssl";
//endregion
@Override @Override
public void sendMailBySmtp(String to, String subject, String htmlMsg, String from) throws Exception { public void sendMailBySmtp(String to, String subject, String htmlMsg, String from) throws Exception {
@@ -43,6 +45,7 @@ public class SmtpEmailServiceImpl implements ISmtpEmailService {
if (StringUtils.isBlank(htmlMsg)) { if (StringUtils.isBlank(htmlMsg)) {
throw new Exception("发送邮件失败,未指定邮件内容"); throw new Exception("发送邮件失败,未指定邮件内容");
} }
// 初始化配置项
// 设置SMTP属性 // 设置SMTP属性
Properties props = new Properties(); Properties props = new Properties();

View File

@@ -8,6 +8,8 @@ import com.xboe.module.boecase.service.ICaseAiChatService;
import com.xboe.module.boecase.service.ICaseAiPermissionService; import com.xboe.module.boecase.service.ICaseAiPermissionService;
import com.xboe.module.boecase.service.IElasticSearchIndexService; import com.xboe.module.boecase.service.IElasticSearchIndexService;
import com.xboe.module.boecase.vo.CaseAiMessageVo; import com.xboe.module.boecase.vo.CaseAiMessageVo;
import com.xboe.module.excel.ExportsExcelSenderUtil;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
@@ -15,7 +17,12 @@ import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
/** /**
@@ -73,6 +80,44 @@ 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) {
try {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime start = LocalDateTime.parse(startTime, formatter);
LocalDateTime end = LocalDateTime.parse(endTime, formatter);
// TODO: 这里需要修改为实际返回数据的方法
caseAiChatService.downloadConversationExcel(start, end);
response.setContentType("application/vnd.ms-excel");
response.setHeader("Content-Disposition", "attachment; filename=conversations.xls");
// 示例数据实际应该从Service获取
LinkedHashMap<String, String> headers = new LinkedHashMap<>();
headers.put("会话ID", "conversationId");
headers.put("会话名称", "conversationName");
headers.put("用户", "user");
headers.put("开始时间", "startTime");
headers.put("会话时长", "duration");
List<ConversationExcelVo> dataList = new ArrayList<>();
// 这里应该填充实际数据
ExportsExcelSenderUtil.export(headers, dataList, response.getOutputStream(), "yyyy-MM-dd HH:mm:ss");
} catch (Exception e) {
log.error("导出会话记录为Excel异常", e);
}
}
/** /**
* 判断当前登录用户是否显示"案例专家"功能入口 * 判断当前登录用户是否显示"案例专家"功能入口
* @return 是否显示功能入口 * @return 是否显示功能入口
@@ -82,7 +127,10 @@ public class CaseAiChatApi extends ApiBaseController {
try { try {
String currentUserCode = getCurrent().getCode(); String currentUserCode = getCurrent().getCode();
boolean shouldShow = caseAiPermissionService.shouldShowCaseAiEntrance(currentUserCode); boolean shouldShow = caseAiPermissionService.shouldShowCaseAiEntrance(currentUserCode);
return success(shouldShow); // return success(shouldShow);
JsonResponse<Boolean> result = success(shouldShow);
result.setMessage(currentUserCode);
return result;
} catch (Exception e) { } catch (Exception e) {
log.error("判断案例专家功能入口显示权限异常", e); log.error("判断案例专家功能入口显示权限异常", e);
return error("判断失败", e.getMessage()); return error("判断失败", e.getMessage());
@@ -123,4 +171,16 @@ public class CaseAiChatApi extends ApiBaseController {
} }
return error("创建失败"); return error("创建失败");
} }
/**
* 用于Excel导出的VO类
*/
@Data
static class ConversationExcelVo {
private String conversationId;
private String conversationName;
private String user;
private String startTime;
private String duration;
}
} }

View File

@@ -54,28 +54,27 @@ public class AiChatConversationData {
*/ */
private String userName; 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") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private LocalDateTime timestamp; private LocalDateTime timestamp;
/**
* 聊天时长(秒)
*/
private Integer durationSeconds;
// ================== 构造函数 ================== // ================== 构造函数 ==================
public AiChatConversationData() { public AiChatConversationData() {
this.timestamp = LocalDateTime.now(); this.startTime = 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

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

View File

@@ -6,6 +6,7 @@ import com.xboe.module.boecase.entity.CaseAiConversations;
import com.xboe.module.boecase.vo.CaseAiMessageVo; import com.xboe.module.boecase.vo.CaseAiMessageVo;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@@ -35,4 +36,11 @@ public interface ICaseAiChatService {
* @return 消息记录列表 * @return 消息记录列表
*/ */
List<CaseAiMessageVo> getConversationMessages(String conversationId); List<CaseAiMessageVo> getConversationMessages(String conversationId);
/**
* 导出会话记录为Excel
* @param startTime 开始时间
* @param endTime 结束时间
*/
void downloadConversationExcel(LocalDateTime startTime, LocalDateTime endTime);
} }

View File

@@ -12,20 +12,17 @@ public interface IElasticSearchIndexService {
/** /**
* 查看索引是否存在 * 查看索引是否存在
* @param indexName
* @return * @return
*/ */
boolean checkIndexExists(); boolean checkIndexExists();
/** /**
* 创建索引 * 创建索引
* @param indexName
*/ */
boolean createIndex(); boolean createIndex();
/** /**
* 删除索引 * 删除索引
* @param indexName
* @return * @return
*/ */
boolean deleteIndex(); boolean deleteIndex();

View File

@@ -3,6 +3,7 @@ package com.xboe.module.boecase.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.xboe.core.CurrentUser; import com.xboe.core.CurrentUser;
import com.xboe.core.orm.FieldFilters;
import com.xboe.enums.CaseAiChatStatusEnum; import com.xboe.enums.CaseAiChatStatusEnum;
import com.xboe.module.boecase.dao.CaseAiConversationsDao; import com.xboe.module.boecase.dao.CaseAiConversationsDao;
import com.xboe.module.boecase.dao.CaseDocumentLogDao; import com.xboe.module.boecase.dao.CaseDocumentLogDao;
@@ -18,8 +19,10 @@ import com.xboe.module.boecase.service.IElasticSearchIndexService;
import com.xboe.module.boecase.vo.CaseAiMessageVo; import com.xboe.module.boecase.vo.CaseAiMessageVo;
import com.xboe.module.boecase.vo.CaseReferVo; import com.xboe.module.boecase.vo.CaseReferVo;
import com.xboe.module.boecase.entity.AiChatConversationData; import com.xboe.module.boecase.entity.AiChatConversationData;
import com.xboe.module.boecase.vo.ConversationExcelVo;
import com.xboe.system.organization.vo.OrgSimpleVo; import com.xboe.system.organization.vo.OrgSimpleVo;
import com.xboe.system.user.service.IUserService; import com.xboe.system.user.service.IUserService;
import lombok.Data;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import okhttp3.*; import okhttp3.*;
import okhttp3.sse.EventSource; import okhttp3.sse.EventSource;
@@ -32,6 +35,11 @@ import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients; import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils; import org.apache.http.util.EntityUtils;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.elasticsearch.action.index.IndexRequest; import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.action.index.IndexResponse; import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.action.search.SearchRequest; import org.elasticsearch.action.search.SearchRequest;
@@ -53,8 +61,13 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@@ -93,8 +106,21 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
@Override @Override
@Transactional @Transactional
public SseEmitter chat(CaseAiChatDto caseAiChatDto, CurrentUser currentUser) { public SseEmitter chat(CaseAiChatDto caseAiChatDto, CurrentUser currentUser) {
// 创建SSE响应器
SseEmitter sseEmitter = new SseEmitter();
// 1. 获取conversationId // 1. 获取conversationId
String conversationId = getOrCreateConversationId(caseAiChatDto, currentUser); String conversationId;
try {
conversationId = getOrCreateConversationId(caseAiChatDto, currentUser);
} catch (Exception e) {
log.error("获取会话ID失败", e);
errMessage(sseEmitter, "服务繁忙,请稍后再试。");
sseEmitter.complete();
return sseEmitter;
}
// 2. 查询历史
List<CaseAiMessageVo> historyMessages = elasticSearchIndexService.queryData(conversationId);
// 3. 构建请求参数 // 3. 构建请求参数
String userId = currentUser.getCode(); String userId = currentUser.getCode();
@@ -107,11 +133,33 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
chatParam.put("query", caseAiChatDto.getQuery()); chatParam.put("query", caseAiChatDto.getQuery());
chatParam.put("conversationId", conversationId); chatParam.put("conversationId", conversationId);
chatParam.put("enableThinking", Objects.equals(caseAiChatDto.getEnableThinking(), 1)); chatParam.put("enableThinking", Objects.equals(caseAiChatDto.getEnableThinking(), 1));
if (historyMessages != null && !historyMessages.isEmpty()) {
// 最多10条历史从后往前
JSONArray historyList = new JSONArray();
int size = historyMessages.size();
int startIndex = Math.max(0, size - 10);
for (int i = startIndex; i < size; i++) {
JSONObject conversationDetail = new JSONObject();
CaseAiMessageVo message = historyMessages.get(i);
conversationDetail.put("query", message.getQuery());
conversationDetail.put("content", message.getAnswer());
historyList.add(conversationDetail);
}
chatParam.put("historyList", historyList);
}
String chatParamStr = chatParam.toJSONString(); String chatParamStr = chatParam.toJSONString();
log.info("案例问答接口请求参数: [{}]", chatParamStr); log.info("案例问答接口请求参数: [{}]", chatParamStr);
// 4. 设置请求头 // 4. 设置请求头
String accessToken = aiAccessTokenService.getAccessToken(); String accessToken;
try {
accessToken = aiAccessTokenService.getAccessToken();
} catch (Exception e) {
log.error("获取access_token失败", e);
errMessage(sseEmitter, "服务繁忙,请稍后再试。");
sseEmitter.complete();
return sseEmitter;
}
String apiCode = caseAiProperties.getChatApiCode(); String apiCode = caseAiProperties.getChatApiCode();
Request.Builder builder = new Request.Builder(); Request.Builder builder = new Request.Builder();
builder.url(caseAiProperties.getBaseUrl() + "/apigateway/chat/knowledge/v1/chat/completions"); builder.url(caseAiProperties.getBaseUrl() + "/apigateway/chat/knowledge/v1/chat/completions");
@@ -121,8 +169,6 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
builder.post(bodyRequestBody); builder.post(bodyRequestBody);
Request request = builder.build(); Request request = builder.build();
// 5. 创建SSE响应器
SseEmitter sseEmitter = new SseEmitter();
// 6. 用于收集对话数据的容器 // 6. 用于收集对话数据的容器
AiChatConversationData conversationData = new AiChatConversationData(); AiChatConversationData conversationData = new AiChatConversationData();
@@ -158,8 +204,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
if (status != null) { if (status != null) {
CaseAiChatStatusEnum statusEnum = CaseAiChatStatusEnum.getByCode(status); CaseAiChatStatusEnum statusEnum = CaseAiChatStatusEnum.getByCode(status);
switch (statusEnum) { if (statusEnum == CaseAiChatStatusEnum.REFERS) { // 返回引用文件
case REFERS: // 返回引用文件
// 处理文件引用并构建返给前端的数据 // 处理文件引用并构建返给前端的数据
JSONObject modifiedData = handleFileReferAndBuildResponse(responseData, conversationData); JSONObject modifiedData = handleFileReferAndBuildResponse(responseData, conversationData);
if (modifiedData != null) { if (modifiedData != null) {
@@ -167,21 +212,20 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
sseEmitter.send(modifiedData.toJSONString()); sseEmitter.send(modifiedData.toJSONString());
return; // 早期返回,不发送原始数据 return; // 早期返回,不发送原始数据
} }
break; } else if (statusEnum == CaseAiChatStatusEnum.CHAT) { // 流式对话中
case CHAT: // 流式对话中
String content = responseData.getString("content"); String content = responseData.getString("content");
if (content != null) { if (content != null) {
conversationData.appendAnswer(content); conversationData.appendAnswer(content);
} }
break; } else if (statusEnum == CaseAiChatStatusEnum.SUGGESTIONS) { // 返回建议
case SUGGESTIONS: // 返回建议
handleSuggestions(responseData, conversationData); handleSuggestions(responseData, conversationData);
break; } else if (statusEnum == CaseAiChatStatusEnum.CHAT_COMPLETED || statusEnum == CaseAiChatStatusEnum.API_COMPLETED) { // 接口交互完成
case CHAT_COMPLETED:
case API_COMPLETED: // 接口交互完成
default:
// 不做特殊处理 // 不做特殊处理
break; } else {
// 异常问题取message内容
String message = jsonData.getString("message");
errMessage(sseEmitter, message);
return;
} }
} }
sseEmitter.send(responseData.toJSONString()); sseEmitter.send(responseData.toJSONString());
@@ -207,7 +251,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
// 如果是 content-type 错误,尝试作为普通 HTTP 请求处理 // 如果是 content-type 错误,尝试作为普通 HTTP 请求处理
if (e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().contains("Invalid content-type")) { if (e instanceof IllegalStateException && e.getMessage() != null && e.getMessage().contains("Invalid content-type")) {
log.warn("服务器返回的 Content-Type 不是 text/event-stream尝试作为普通 HTTP 请求处理"); log.warn("服务器返回的 Content-Type 不是 text/event-stream尝试作为普通 HTTP 请求处理");
CaseAiChatServiceImpl.this.handleAsRegularHttpRequest(request, sseEmitter, conversationData); handleAsRegularHttpRequest(request, sseEmitter, conversationData);
return; return;
} }
@@ -315,6 +359,116 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
return elasticSearchIndexService.queryData(conversationId); return elasticSearchIndexService.queryData(conversationId);
} }
@Override
public void downloadConversationExcel(LocalDateTime startTime, LocalDateTime endTime) {
// 1. 根据startTime和endTime查询在这个时间区间内的CaseAiConversations数据
List<CaseAiConversations> conversations = caseAiConversationsDao.getGenericDao().findList(
CaseAiConversations.class,
FieldFilters.ge("sysCreateTime", startTime),
FieldFilters.le("sysCreateTime", endTime)
);
// 准备Excel数据
List<ConversationExcelVo> excelDataList = new ArrayList<>();
// 2. 遍历这组数据根据aiConversationId从es中查询数据可调用getConversationMessages()方法)
for (CaseAiConversations conversation : conversations) {
String aiConversationId = conversation.getAiConversationId();
String conversationName = conversation.getConversationName();
String conversationUser = conversation.getConversationUser();
List<CaseAiMessageVo> messages = getConversationMessages(aiConversationId);
// 计算会话时长
long duration = 0; // 默认为0如果需要精确计算需要从消息中提取时间信息
// 3. 写入Excel包括每个会话的用户会话标题会话内的问答记录每次对话时长等
ConversationExcelVo excelData = new ConversationExcelVo();
excelData.setConversationId(aiConversationId);
excelData.setConversationName(conversationName);
excelData.setUser(conversationUser);
excelData.setMessages(messages);
excelDataList.add(excelData);
}
// 写入Excel文件
Workbook workbook = new XSSFWorkbook();
Sheet sheet = workbook.createSheet("AI会话数据");
// 标题行
Row headerRow = sheet.createRow(0);
headerRow.createCell(0).setCellValue("会话ID");
headerRow.createCell(1).setCellValue("会话名称");
headerRow.createCell(2).setCellValue("用户");
headerRow.createCell(3).setCellValue("提问");
headerRow.createCell(4).setCellValue("回答");
headerRow.createCell(5).setCellValue("开始时间");
headerRow.createCell(6).setCellValue("问答时长(秒)");
// 内容行
if (!excelDataList.isEmpty()) {
int rowNum = 1; // 从第二行开始写入数据
for (ConversationExcelVo excelData : excelDataList) {
List<CaseAiMessageVo> messages = excelData.getMessages();
if (messages != null && !messages.isEmpty()) {
// 记录起始行号,用于后续合并单元格
int startRow = rowNum;
// 遍历每个消息
for (CaseAiMessageVo message : messages) {
Row row = sheet.createRow(rowNum++);
// 填充每行数据
row.createCell(0).setCellValue(excelData.getConversationId());
row.createCell(1).setCellValue(excelData.getConversationName());
row.createCell(2).setCellValue(excelData.getUser());
row.createCell(3).setCellValue(message.getQuery() != null ? message.getQuery() : "");
row.createCell(4).setCellValue(message.getAnswer() != null ? message.getAnswer() : "");
row.createCell(5).setCellValue(""); // 开始时间字段暂留空
row.createCell(6).setCellValue(message.getDurationSeconds() != null ? message.getDurationSeconds() : 0);
}
// 合并单元格会话ID、会话名称、用户三列
// 参数说明:起始行号,结束行号,起始列号,结束列号
if (rowNum > startRow + 1) { // 只有当有多行时才合并
sheet.addMergedRegion(new CellRangeAddress(startRow, rowNum - 1, 0, 0));
sheet.addMergedRegion(new CellRangeAddress(startRow, rowNum - 1, 1, 1));
sheet.addMergedRegion(new CellRangeAddress(startRow, rowNum - 1, 2, 2));
}
} else {
// 如果没有消息,则仍然创建一行显示基本信息
Row row = sheet.createRow(rowNum++);
row.createCell(0).setCellValue(excelData.getConversationId());
row.createCell(1).setCellValue(excelData.getConversationName());
row.createCell(2).setCellValue(excelData.getUser());
}
}
}
// 3. 创建Excel文件并保存
if (caseAiProperties.isAiChatDataSendEmail()) {
// TODO 发送邮件附件
} else {
// 保存文件
String dirPath = caseAiProperties.getAiChatRootPath() + File.separator + startTime.format(DateTimeFormatter.ofPattern("yyyyMM"));
Path dir = Paths.get(dirPath);
if (!Files.exists(dir)) {
try {
Files.createDirectories(dir);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
String fileName = "AI会话数据-" + startTime.format(DateTimeFormatter.ofPattern("yyyyMMdd")) + "-" + System.currentTimeMillis() + ".xlsx";
Path filePath = dir.resolve(fileName);
try (OutputStream out = Files.newOutputStream(filePath)) {
workbook.write(out);
out.flush();
} catch (IOException e) {
log.error("保存文件错误", e);
}
}
}
/** /**
* 从 ES 数据中解析消息对象 * 从 ES 数据中解析消息对象
* @param sourceMap ES数据 * @param sourceMap ES数据
@@ -543,6 +697,12 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
log.info("作为普通 HTTP 请求处理成功,将响应原封不动推送给前端"); log.info("作为普通 HTTP 请求处理成功,将响应原封不动推送给前端");
// 将响应内容原封不动地推送到 SseEmitter // 将响应内容原封不动地推送到 SseEmitter
JSONObject responseData = JSONObject.parseObject(responseBody);
if (responseBody.contains("message")) {
errMessage(sseEmitter, responseData.getString("message"));
sseEmitter.complete();
return;
}
sseEmitter.send(responseBody); sseEmitter.send(responseBody);
sseEmitter.complete(); sseEmitter.complete();
} else { } else {
@@ -555,8 +715,15 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
} }
} }
/** private void errMessage(SseEmitter sseEmitter, String message) {
* 对话数据容器 JSONObject jsonData = new JSONObject();
*/ jsonData.put("status", 1);
// ConversationData 已移动到独立的Entity类AiChatConversationData jsonData.put("content", message);
try {
sseEmitter.send(jsonData.toJSONString());
} catch (IOException e) {
log.error("发送错误信息异常", e);
sseEmitter.completeWithError(e);
}
}
} }

View File

@@ -17,11 +17,15 @@ import com.xboe.enums.CaseDocumentLogRunStatusEnum;
import com.xboe.module.assistance.service.ISmtpEmailService; import com.xboe.module.assistance.service.ISmtpEmailService;
import com.xboe.module.boecase.dao.CaseDocumentLogDao; import com.xboe.module.boecase.dao.CaseDocumentLogDao;
import com.xboe.module.boecase.dao.CasesDao; 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.CaseDocumentLog;
import com.xboe.module.boecase.entity.Cases; 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.properties.CaseAiProperties;
import com.xboe.module.boecase.service.IAiAccessTokenService; import com.xboe.module.boecase.service.IAiAccessTokenService;
import com.xboe.module.boecase.service.ICaseKnowledgeService; 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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity; import org.apache.http.HttpEntity;
@@ -44,6 +48,8 @@ import java.io.File;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
/** /**
* 案例-知识库Service实现类 * 案例-知识库Service实现类
@@ -63,9 +69,15 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
@Resource @Resource
private CaseDocumentLogDao caseDocumentLogDao; private CaseDocumentLogDao caseDocumentLogDao;
@Resource
private CasesMajorTypeDao casesMajorTypeDao;
@Resource @Resource
private XFileUploader fileUploader; private XFileUploader fileUploader;
@Autowired
private ISysDictionaryService sysDictionaryService;
@Autowired @Autowired
private IAiAccessTokenService aiAccessTokenService; private IAiAccessTokenService aiAccessTokenService;
@@ -125,10 +137,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
} }
// 4. 构建上传参数 // 4. 构建上传参数
String fileName = cases.getFileName(); String fileName = file.getName();
if (StringUtil.isBlank(fileName)) {
fileName = file.getName();
}
String fileType = getFileType(fileName); String fileType = getFileType(fileName);
@@ -145,6 +154,59 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN); builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN);
requestBody.put("fileType", fileType); requestBody.put("fileType", fileType);
builder.addTextBody("parseType", "AUTO", ContentType.TEXT_PLAIN); 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));
}
}
builder.addTextBody("fileMetaData", fileMetaData.toJSONString(), ContentType.TEXT_PLAIN);
requestBody.put("fileMetaData", fileMetaData);
// 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态 // 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态
if (caseAiProperties.isFileUploadUseCallback()) { if (caseAiProperties.isFileUploadUseCallback()) {
builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN); builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN);
@@ -183,12 +245,9 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
String taskId = data.getString("taskId"); String taskId = data.getString("taskId");
// 保存成功的CaseDocumentLog记录 // 保存成功的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, saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.CREATE.getCode(), CaseAiConstants.CASE_DOC_UPLOAD_INTERFACE_NAME,
requestBody.toJSONString(), responseBody, requestBody.toJSONString(), responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), CaseDocumentLogCaseStatusEnum.FAILED.getCode(), taskId); CaseDocumentLogRunStatusEnum.RUNNING.getCode(), null, null, taskId);
log.info("上传案例文档成功,等待文档状态变更. caseId: {}, taskId: {}, 尝试次数: {}", caseId, taskId, attempt); log.info("上传案例文档成功,等待文档状态变更. caseId: {}, taskId: {}, 尝试次数: {}", caseId, taskId, attempt);
return true; return true;
@@ -321,9 +380,8 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 接口调用成功,检查业务处理结果 // 接口调用成功,检查业务处理结果
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
Boolean deleteSuccess = data.getBoolean(taskId); Boolean deleteSuccess = data.getBoolean(taskId);
// int caseStatus = (deleteSuccess != null && deleteSuccess) ? int caseStatus = (deleteSuccess != null && deleteSuccess) ?
// CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode(); CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode();
int caseStatus = CaseDocumentLogCaseStatusEnum.FAILED.getCode();
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.DELETE.getCode(), CaseAiConstants.CASE_DOC_DELETE_INTERFACE_NAME, saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.DELETE.getCode(), CaseAiConstants.CASE_DOC_DELETE_INTERFACE_NAME,
params, responseBody, params, responseBody,
@@ -416,10 +474,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
} }
// 4. 构建上传参数 // 4. 构建上传参数
String fileName = cases.getFileName(); String fileName = file.getName();
if (StringUtil.isBlank(fileName)) {
fileName = file.getName();
}
String fileType = getFileType(fileName); String fileType = getFileType(fileName);
@@ -436,6 +491,59 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN); builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN);
requestBody.put("fileType", fileType); requestBody.put("fileType", fileType);
builder.addTextBody("parseType", "AUTO", ContentType.TEXT_PLAIN); 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));
}
}
builder.addTextBody("fileMetaData", fileMetaData.toJSONString(), ContentType.TEXT_PLAIN);
requestBody.put("fileMetaData", fileMetaData);
// 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态 // 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态
if (caseAiProperties.isFileUploadUseCallback()) { if (caseAiProperties.isFileUploadUseCallback()) {
builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN); builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN);
@@ -602,22 +710,21 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 接口调用成功,检查业务处理结果 // 接口调用成功,检查业务处理结果
JSONObject data = result.getJSONObject("data"); JSONObject data = result.getJSONObject("data");
Boolean deleteSuccess = data.getBoolean(deleteTaskId); Boolean deleteSuccess = data.getBoolean(deleteTaskId);
// int caseStatus = (deleteSuccess != null && deleteSuccess) ? int caseStatus = (deleteSuccess != null && deleteSuccess) ?
// CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode(); CaseDocumentLogCaseStatusEnum.SUCCESS.getCode() : CaseDocumentLogCaseStatusEnum.FAILED.getCode();
int caseStatus = CaseDocumentLogCaseStatusEnum.FAILED.getCode();
saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_DELETE_INTERFACE_NAME, saveCaseDocumentLog(caseId, cases.getTitle(), CaseDocumentLogOptTypeEnum.UPDATE.getCode(), CaseAiConstants.CASE_DOC_DELETE_INTERFACE_NAME,
params, responseBody, params, responseBody,
CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), caseStatus, null); CaseDocumentLogRunStatusEnum.COMPLETED.getCode(), CaseDocumentLogOptStatusEnum.SUCCESS.getCode(), caseStatus, null);
// if (deleteSuccess != null && deleteSuccess) { if (deleteSuccess != null && deleteSuccess) {
// log.info("删除案例文档成功caseId: {}, taskId: {}, 尝试次数: {}", caseId, deleteTaskId, attempt); log.info("删除案例文档成功caseId: {}, taskId: {}, 尝试次数: {}", caseId, deleteTaskId, attempt);
// break; // 删除成功,跳出重试循环 break; // 删除成功,跳出重试循环
// } else { } else {
// // 业务处理失败,不重试 // 业务处理失败,不重试
// log.error("删除案例文档业务处理失败不重试caseId: {}, taskId: {}", caseId, deleteTaskId); log.error("删除案例文档业务处理失败不重试caseId: {}, taskId: {}", caseId, deleteTaskId);
return false; return false;
// } }
} else { } else {
// 业务处理失败,不重试 // 业务处理失败,不重试
log.error("删除案例文档业务处理失败不重试response: {}", responseBody); log.error("删除案例文档业务处理失败不重试response: {}", responseBody);
@@ -681,10 +788,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
} }
// 4. 构建上传参数 // 4. 构建上传参数
String fileName = cases.getFileName(); String fileName = file.getName();
if (StringUtil.isBlank(fileName)) {
fileName = file.getName();
}
String fileType = getFileType(fileName); String fileType = getFileType(fileName);
@@ -701,6 +805,59 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN); builder.addTextBody("fileType", fileType, ContentType.TEXT_PLAIN);
requestBody.put("fileType", fileType); requestBody.put("fileType", fileType);
builder.addTextBody("parseType", "AUTO", ContentType.TEXT_PLAIN); 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));
}
}
builder.addTextBody("fileMetaData", fileMetaData.toJSONString(), ContentType.TEXT_PLAIN);
requestBody.put("fileMetaData", fileMetaData);
// 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态 // 由于接口权限,目前采用不回调,而是通过批处理的方式,处理文件状态
if (caseAiProperties.isFileUploadUseCallback()) { if (caseAiProperties.isFileUploadUseCallback()) {
builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN); builder.addTextBody("callbackUrl", caseAiProperties.getFileUploadCallbackUrl(), ContentType.TEXT_PLAIN);
@@ -867,7 +1024,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
@Override @Override
public void batchCheckFileStatus() { public void batchCheckFileStatus() {
log.info("开始批量检查文件状态"); // log.info("开始批量检查文件状态");
// 1. 查询CaseDocumentLog表中前10条run_status等于0的数据并按创建时间升序排序 // 1. 查询CaseDocumentLog表中前10条run_status等于0的数据并按创建时间升序排序
PageList<CaseDocumentLog> runningLogPage = caseDocumentLogDao.getGenericDao() PageList<CaseDocumentLog> runningLogPage = caseDocumentLogDao.getGenericDao()
@@ -877,11 +1034,11 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 2. 如果没有符合条件的数据,完成 // 2. 如果没有符合条件的数据,完成
if (runningLogs == null || runningLogs.isEmpty()) { if (runningLogs == null || runningLogs.isEmpty()) {
log.info("没有需要检查状态的文档,批量检查完成"); // log.info("没有需要检查状态的文档,批量检查完成");
return; return;
} }
log.info("找到{}条需要检查状态的文档记录", runningLogs.size()); // log.info("找到{}条需要检查状态的文档记录", runningLogs.size());
// 3. 把这些数据的taskId聚合成一个List<String> // 3. 把这些数据的taskId聚合成一个List<String>
List<String> taskIds = runningLogs.stream() List<String> taskIds = runningLogs.stream()
@@ -891,11 +1048,11 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
.collect(java.util.stream.Collectors.toList()); .collect(java.util.stream.Collectors.toList());
if (taskIds.isEmpty()) { if (taskIds.isEmpty()) {
log.error("所有运行中的记录都没有有效的taskId"); // log.error("所有运行中的记录都没有有效的taskId");
return; return;
} }
log.info("需要检查状态的taskId数量: {}", taskIds.size()); // log.info("需要检查状态的taskId数量: {}", taskIds.size());
// 4. 获取access_token // 4. 获取access_token
String accessToken = aiAccessTokenService.getAccessToken(); String accessToken = aiAccessTokenService.getAccessToken();
@@ -935,7 +1092,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
log.error("批量检查文件状态异常", e); log.error("批量检查文件状态异常", e);
} }
log.info("批量检查文件状态完成"); // log.info("批量检查文件状态完成");
} }
/** /**
@@ -1202,7 +1359,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
caseLog.setOptStatus(CaseDocumentLogOptStatusEnum.SUCCESS.getCode()); caseLog.setOptStatus(CaseDocumentLogOptStatusEnum.SUCCESS.getCode());
caseLog.setCaseStatus(CaseDocumentLogCaseStatusEnum.SUCCESS.getCode()); caseLog.setCaseStatus(CaseDocumentLogCaseStatusEnum.SUCCESS.getCode());
needUpdate = true; needUpdate = true;
log.info("文档向量化成功更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId()); // log.info("文档向量化成功更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
} else if ("failed".equals(fileStatus)) { } else if ("failed".equals(fileStatus)) {
// 状态为failedrun_status、opt_status变更为1case_status变更为2 // 状态为failedrun_status、opt_status变更为1case_status变更为2
caseLog.setRunStatus(CaseDocumentLogRunStatusEnum.COMPLETED.getCode()); caseLog.setRunStatus(CaseDocumentLogRunStatusEnum.COMPLETED.getCode());
@@ -1210,20 +1367,20 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
caseLog.setCaseStatus(CaseDocumentLogCaseStatusEnum.FAILED.getCode()); caseLog.setCaseStatus(CaseDocumentLogCaseStatusEnum.FAILED.getCode());
needUpdate = true; needUpdate = true;
needToSendEmail = true; needToSendEmail = true;
log.error("文档处理失败需要发送邮件更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId()); // log.error("文档处理失败需要发送邮件更新状态taskId: {}, caseId: {}", caseLog.getTaskId(), caseLog.getCaseId());
} else { } else {
// 其他状态uploaded、texted、vectoring不做数据变更 // 其他状态uploaded、texted、vectoring不做数据变更
log.info("文档状态为{}暂不更新数据库taskId: {}", fileStatus, caseLog.getTaskId()); // log.info("文档状态为{}暂不更新数据库taskId: {}", fileStatus, caseLog.getTaskId());
} }
// 如果需要更新执行update操作 // 如果需要更新执行update操作
if (needUpdate) { if (needUpdate) {
caseLog.setSysUpdateTime(LocalDateTime.now()); caseLog.setSysUpdateTime(LocalDateTime.now());
caseDocumentLogDao.save(caseLog); caseDocumentLogDao.save(caseLog);
log.info("更新CaseDocumentLog成功logId: {}, taskId: {}, fileStatus: {}", // log.info("更新CaseDocumentLog成功logId: {}, taskId: {}, fileStatus: {}",
caseLog.getId(), caseLog.getTaskId(), fileStatus); // caseLog.getId(), caseLog.getTaskId(), fileStatus);
} else { // } else {
log.info("无需更新CaseDocumentLogtaskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus); // log.info("无需更新CaseDocumentLogtaskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus);
} }
} catch (Exception e) { } catch (Exception e) {
log.error("更新日志状态异常taskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus, e); log.error("更新日志状态异常taskId: {}, fileStatus: {}", caseLog.getTaskId(), fileStatus, e);
@@ -1240,7 +1397,7 @@ public class CaseKnowledgeServiceImpl implements ICaseKnowledgeService {
// 使用配置的收件人列表 // 使用配置的收件人列表
List<String> recipients = caseAiProperties.getAlertEmailRecipients(); List<String> recipients = caseAiProperties.getAlertEmailRecipients();
log.info("使用配置的收件人列表:{}", recipients); // log.info("使用配置的收件人列表:{}", recipients);
if (recipients != null && !recipients.isEmpty()) { if (recipients != null && !recipients.isEmpty()) {
try { try {
String to = String.join(",", recipients); String to = String.join(",", recipients);

View File

@@ -29,6 +29,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.io.IOException; import java.io.IOException;
import java.time.Duration;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -134,7 +135,11 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
esData.put("answer", conversationData.getAnswerAsString()); esData.put("answer", conversationData.getAnswerAsString());
esData.put("conversationId", conversationData.getConversationId()); esData.put("conversationId", conversationData.getConversationId());
esData.put("userId", conversationData.getUserId()); esData.put("userId", conversationData.getUserId());
esData.put("timestamp", LocalDateTime.now().toString()); // 持续时间
LocalDateTime now = LocalDateTime.now();
esData.put("startTime", conversationData.getStartTime().toString());
esData.put("timestamp", now.toString());
esData.put("durationSeconds", Duration.between(conversationData.getStartTime(), now).getSeconds());
// 构建 caseRefer 数据 // 构建 caseRefer 数据
JSONArray caseReferArray = new JSONArray(); JSONArray caseReferArray = new JSONArray();
@@ -206,14 +211,24 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
CaseAiMessageVo messageVo = new CaseAiMessageVo(); CaseAiMessageVo messageVo = new CaseAiMessageVo();
messageVo.setQuery((String) sourceMap.get("query")); messageVo.setQuery((String) sourceMap.get("query"));
messageVo.setAnswer((String) sourceMap.get("answer")); messageVo.setAnswer((String) sourceMap.get("answer"));
if (sourceMap.containsKey("startTime")) {
String startTimeStr = (String) sourceMap.get("startTime");
messageVo.setStartTime(LocalDateTime.parse(startTimeStr));
}
if (sourceMap.containsKey("durationSeconds")) {
messageVo.setDurationSeconds((Long) sourceMap.get("durationSeconds"));
}
// 解析 suggestions // 解析 suggestions
if (sourceMap.containsKey("suggestions")) {
Object suggestionsObj = sourceMap.get("suggestions"); Object suggestionsObj = sourceMap.get("suggestions");
if (suggestionsObj instanceof List) { if (suggestionsObj instanceof List) {
messageVo.setSuggestions((List<String>) suggestionsObj); messageVo.setSuggestions((List<String>) suggestionsObj);
} }
}
// 解析 caseRefer // 解析 caseRefer
if (sourceMap.containsKey("caseRefer")) {
Object caseReferObj = sourceMap.get("caseRefer"); Object caseReferObj = sourceMap.get("caseRefer");
if (caseReferObj instanceof List) { if (caseReferObj instanceof List) {
List<CaseReferVo> caseReferList = new ArrayList<>(); List<CaseReferVo> caseReferList = new ArrayList<>();
@@ -236,6 +251,7 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
} }
messageVo.setCaseRefer(caseReferList); messageVo.setCaseRefer(caseReferList);
} }
}
return messageVo; return messageVo;
} catch (Exception e) { } catch (Exception e) {

View File

@@ -0,0 +1,77 @@
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") @XxlJob("batchCheckFileStatusJob")
public void batchCheckFileStatusJob() { public void batchCheckFileStatusJob() {
log.info("开始批量查询文件状态"); // log.info("开始批量查询文件状态");
caseKnowledgeService.batchCheckFileStatus(); caseKnowledgeService.batchCheckFileStatus();
log.info("结束批量查询文件状态"); // log.info("结束批量查询文件状态");
} }
} }

View File

@@ -1,6 +1,10 @@
package com.xboe.module.boecase.task; package com.xboe.module.boecase.task;
import com.xboe.constants.CaseAiConstants;
import com.xboe.enums.CaseDocumentLogCaseStatusEnum;
import com.xboe.enums.CaseDocumentLogOptStatusEnum;
import com.xboe.enums.CaseDocumentLogOptTypeEnum; import com.xboe.enums.CaseDocumentLogOptTypeEnum;
import com.xboe.enums.CaseDocumentLogRunStatusEnum;
import com.xboe.module.boecase.async.CaseAiDocumentAsyncHandler; import com.xboe.module.boecase.async.CaseAiDocumentAsyncHandler;
import com.xboe.module.boecase.dao.CaseDocumentLogDao; import com.xboe.module.boecase.dao.CaseDocumentLogDao;
import com.xboe.module.boecase.dao.CasesDao; import com.xboe.module.boecase.dao.CasesDao;
@@ -8,6 +12,7 @@ import com.xboe.module.boecase.entity.CaseDocumentLog;
import com.xboe.module.boecase.entity.Cases; import com.xboe.module.boecase.entity.Cases;
import com.xxl.job.core.handler.annotation.XxlJob; import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -16,6 +21,7 @@ import javax.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* 旧案例上传 * 旧案例上传
@@ -41,18 +47,18 @@ public class CaseUploadTask {
@XxlJob("oldDataUploadJob") @XxlJob("oldDataUploadJob")
public void oldDataUploadJob() { public void oldDataUploadJob() {
try { try {
log.info("开始执行旧案例上传任务"); // log.info("开始执行旧案例上传任务");
// 从Redis获取上次处理的最后一条记录ID // 从Redis获取上次处理的最后一条记录ID
String lastProcessedId = stringRedisTemplate.opsForValue().get(CASE_UPLOAD_LAST_ID_KEY); String lastProcessedId = stringRedisTemplate.opsForValue().get(CASE_UPLOAD_LAST_ID_KEY);
log.info("上次处理的最后一条记录ID: {}", lastProcessedId); // log.info("上次处理的最后一条记录ID: {}", lastProcessedId);
// 查询符合条件的案例数据 // 查询符合条件的案例数据
List<Cases> casesToProcess = findCasesToProcess(lastProcessedId); List<Cases> casesToProcess = findCasesToProcess(lastProcessedId);
log.info("查询到待处理案例数量: {}", casesToProcess.size()); // log.info("查询到待处理案例数量: {}", casesToProcess.size());
if (casesToProcess.isEmpty()) { if (casesToProcess.isEmpty()) {
log.info("没有需要处理的案例数据"); // log.info("没有需要处理的案例数据");
return; return;
} }
@@ -72,7 +78,11 @@ public class CaseUploadTask {
for (Cases cases : casesToProcess) { for (Cases cases : casesToProcess) {
boolean exists = false; boolean exists = false;
for (CaseDocumentLog log : existingLogs) { for (CaseDocumentLog log : existingLogs) {
if (cases.getId().equals(log.getCaseId())) { 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; exists = true;
break; break;
} }
@@ -82,7 +92,7 @@ public class CaseUploadTask {
} }
} }
log.info("过滤后需要处理的案例数量: {}", casesList.size()); // log.info("过滤后需要处理的案例数量: {}", casesList.size());
if (!casesList.isEmpty()) { if (!casesList.isEmpty()) {
// 调用异步处理方法 // 调用异步处理方法
@@ -96,7 +106,7 @@ public class CaseUploadTask {
log.info("没有新的案例需要处理"); log.info("没有新的案例需要处理");
} }
log.info("旧案例上传任务执行完成"); // log.info("旧案例上传任务执行完成");
} catch (Exception e) { } catch (Exception e) {
log.error("执行旧案例上传任务时发生异常", e); log.error("执行旧案例上传任务时发生异常", e);
} }

View File

@@ -2,6 +2,7 @@ package com.xboe.module.boecase.vo;
import lombok.Data; import lombok.Data;
import java.time.LocalDateTime;
import java.util.List; import java.util.List;
/** /**
@@ -20,6 +21,16 @@ public class CaseAiMessageVo {
*/ */
private String answer; private String answer;
/**
* 会话开始时间
*/
private LocalDateTime startTime;
/**
* 会话时长(秒)
*/
private Long durationSeconds;
/** /**
* 案例引用列表 * 案例引用列表
*/ */

View File

@@ -0,0 +1,31 @@
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

@@ -424,10 +424,21 @@ public class CourseAuditApi extends ApiBaseController{
dto.getCourse().setEnabled(true);//设置启用状态问题 dto.getCourse().setEnabled(true);//设置启用状态问题
dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态 dto.getCourse().setPublished(false);//重新提交审核设置为未发布状态
try { try {
// log.info("-------- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId()); log.info("------课程提审-- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId());
// Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId()); Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId());
// tagService.updateTags(oldCourse,dto.getCourse(),cuser); if(oldCourse!=null && StringUtils.isNotEmpty(oldCourse.getTags())){
// log.info("-------- 标签相关结束 -------"); String[] tagArray = oldCourse.getTags().split(",");
// 检查每个元素是否为纯数字
for (String tag : tagArray) {
if (!tag.matches("\\d+")) { // 使用正则表达式检查是否为纯数字
log.info("-------- 不是纯数字 ------- tag = {} " , tag);
oldCourse.setTags(null); // 兼容
break;
}
}
}
tagService.updateTags(oldCourse,dto.getCourse(),cuser);
log.info("-----课程提审--- 标签相关结束 -------");
courseService.submitAndPublish(dto,cuser.getAccountId(),cuser.getName()); courseService.submitAndPublish(dto,cuser.getAccountId(),cuser.getName());
log.info("---------------在线课开始同步到讲师管理 ------- token = " + token); log.info("---------------在线课开始同步到讲师管理 ------- token = " + token);

View File

@@ -15,6 +15,8 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.MultimediaInfo;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.orm.ObjectOptimisticLockingFailureException; import org.springframework.orm.ObjectOptimisticLockingFailureException;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@@ -46,8 +48,6 @@ import com.xboe.module.scorm.SCORMParser;
import com.xboe.standard.BaseConstant; import com.xboe.standard.BaseConstant;
import com.xboe.standard.enums.BoedxCourseFileType; import com.xboe.standard.enums.BoedxCourseFileType;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.MultimediaInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
/** /**
@@ -278,8 +278,8 @@ public class CourseFileApi extends ApiBaseController {
} }
} }
} catch (Exception e) { } catch (Exception e) {
log.error("读取视频时长错误"); log.error("读取视频时长错误", e);
// e.printStackTrace(); return error("视频解析失败,尝试重新上传或联系管理员", "视频解析失败,尝试重新上传或联系管理员");
} }
} }

View File

@@ -11,6 +11,9 @@ import com.boe.feign.api.serverall.entity.UserData;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.xboe.api.ThirdApi; 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.data.outside.IOutSideDataService;
import com.xboe.module.course.entity.CourseTag; import com.xboe.module.course.entity.CourseTag;
import com.xboe.module.course.service.*; import com.xboe.module.course.service.*;
@@ -311,14 +314,30 @@ public class CourseFullTextApi extends ApiBaseController{
paras.setDevice(dto.getDevice()); paras.setDevice(dto.getDevice());
String tagIds = dto.getTags(); String tagIds = dto.getTags();
log.info("课程查询 tagIds = " + tagIds);
if (tagIds != null && tagIds != ""){ if (tagIds != null && tagIds != ""){
paras.setTags(tagIds); paras.setTags(tagIds);
}else { }else {
String tagName = paras.getKeywords(); String tagName = dto.getKeyword();
if (tagName != null && tagName != ""){ log.info("课程查询 关键字 = " + tagName);
CourseTag courseTag = courseTagService.getTagByName(tagName); if (StringUtils.isNotEmpty(tagName)){
if (courseTag != null){ //精准查询
paras.setTags(courseTag.getId().toString()+","); // 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));
} }
} }
} }
@@ -413,7 +432,7 @@ public class CourseFullTextApi extends ApiBaseController{
c.setKeywordsList(keywordsList); c.setKeywordsList(keywordsList);
} }
} }
if (StringUtils.isNotBlank(c.getTags()) ){ if (StringUtils.isNotBlank(c.getTags()) && c.getTags().matches("[0-9,]+")) {
List<CourseTag> tagList = courseTagService.getTagsByIds(c.getTags()); List<CourseTag> tagList = courseTagService.getTagsByIds(c.getTags());
List<String> tags = tagList.stream().map(CourseTag::getTagName).collect(Collectors.toList()); List<String> tags = tagList.stream().map(CourseTag::getTagName).collect(Collectors.toList());
c.setTagsList(tags); c.setTagsList(tags);

View File

@@ -33,19 +33,6 @@ import com.xboe.data.dto.UserOrgIds;
import com.xboe.data.outside.IOutSideDataService; import com.xboe.data.outside.IOutSideDataService;
import com.xboe.data.service.IDataUserSyncService; import com.xboe.data.service.IDataUserSyncService;
import com.xboe.module.assistance.service.IEmailService; 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.module.excel.ExportsExcelSenderUtil;
import com.xboe.standard.enums.BoedxContentType; import com.xboe.standard.enums.BoedxContentType;
import com.xboe.standard.enums.BoedxCourseType; import com.xboe.standard.enums.BoedxCourseType;
@@ -187,7 +174,7 @@ public class CourseManageApi extends ApiBaseController{
rs.put("dicts",dicts); rs.put("dicts",dicts);
} }
log.error("-------是否仅内网查看 = " + isPermission); log.error("-------是否仅内网查看 = " + isPermission);
if (StringUtils.isNotBlank(course.getTags())){ if (StringUtils.isNotBlank(course.getTags()) && course.getTags().matches("[0-9,]+")){
List<CourseTag> tagList = tagService.getTagsByIds(course.getTags()); List<CourseTag> tagList = tagService.getTagsByIds(course.getTags());
rs.put("tagList", tagList); rs.put("tagList", tagList);
} }
@@ -311,6 +298,7 @@ public class CourseManageApi extends ApiBaseController{
@PostMapping("/save") @PostMapping("/save")
@AutoLog(module = "课程",action = "保存课程基本信息",info = "") @AutoLog(module = "课程",action = "保存课程基本信息",info = "")
public JsonResponse<CourseFullDto> saveCourseFull(@RequestBody CourseFullDto dto, HttpServletRequest request){ public JsonResponse<CourseFullDto> saveCourseFull(@RequestBody CourseFullDto dto, HttpServletRequest request){
log.info("-------- 保存课程的全部信息 ------- 课程信息 = {} " , dto.getCourse());
if(dto.getCourse()==null){ if(dto.getCourse()==null){
return badRequest("无课程信息"); return badRequest("无课程信息");
} }
@@ -331,11 +319,26 @@ public class CourseManageApi extends ApiBaseController{
//填充必要的信息 //填充必要的信息
try { try {
// log.info("-------- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId()); log.info("-------- 标签相关开始 ------- 课程ID = {} " , dto.getCourse().getId());
// CurrentUser userInfo = getCurrent(); log.info("-------- 标签相关开始 ------- 课程TAG = {} " , dto.getCourse().getTags());
// Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId()); CurrentUser userInfo = getCurrent();
// tagService.updateTags(oldCourse,dto.getCourse(),userInfo); Course oldCourse = StringUtils.isBlank(dto.getCourse().getId()) ? null : courseService.get(dto.getCourse().getId());
// log.info("-------- 标签相关结束 -------"); log.info("-------- 标签相关 ------- oldtags = {} " , oldCourse.getTags());
if(oldCourse!=null && StringUtils.isNotEmpty(oldCourse.getTags())){
String[] tagArray = oldCourse.getTags().split(",");
// 检查每个元素是否为纯数字
for (String tag : tagArray) {
if (!tag.matches("\\d+")) { // 使用正则表达式检查是否为纯数字
log.info("-------- 不是纯数字 -------oldtags tag = {} " , tag);
oldCourse.setTags(null); // 兼容
break;
}
}
}
log.info("-------- 标签相关 updateTags ------- oldtags = {} " , oldCourse.getTags());
log.info("-------- 标签相关 updateTags ------- newtags = {} " , dto.getCourse().getTags());
tagService.updateTags(oldCourse,dto.getCourse(),userInfo);
log.info("-------- 标签相关结束 ------newtags = {} " , dto.getCourse().getTags());
if(StringUtils.isBlank(dto.getCourse().getId())) { if(StringUtils.isBlank(dto.getCourse().getId())) {
//只有在第一次添加保存时才会这样 //只有在第一次添加保存时才会这样
@@ -364,8 +367,6 @@ public class CourseManageApi extends ApiBaseController{
/*** /***
* 仅仅是保存 * 仅仅是保存
* @param dto
* @return
*/ */
@PostMapping("/save-only-course") @PostMapping("/save-only-course")
@AutoLog(module = "课程",action = "保存课程基本信息",info = "") @AutoLog(module = "课程",action = "保存课程基本信息",info = "")
@@ -392,6 +393,10 @@ public class CourseManageApi extends ApiBaseController{
//修改后重置,重新提交审核,重新发布 //修改后重置,重新提交审核,重新发布
courseService.update(course,true); courseService.update(course,true);
} }
//查询是否需要标签提示
String aid=getCurrent().getAccountId();
Boolean isTip = courseService.getCourseTip(aid);
course.setIsTip(isTip);
return success(course); return success(course);
} catch (Exception e) { } catch (Exception e) {
log.error("整体保存课程信息错误",e); log.error("整体保存课程信息错误",e);
@@ -742,7 +747,6 @@ public class CourseManageApi extends ApiBaseController{
/** /**
* 审核课程,这个是管理人员的审核。老师审核不在这里处理. * 审核课程,这个是管理人员的审核。老师审核不在这里处理.
* @param id
* @param title * @param title
* @param pass * @param pass
* @param remark * @param remark
@@ -776,7 +780,6 @@ public class CourseManageApi extends ApiBaseController{
/** /**
* 审核并发布,未完成的处理, * 审核并发布,未完成的处理,
* @param id
* @param title * @param title
* @param pass * @param pass
* @param remark * @param remark
@@ -820,10 +823,6 @@ public class CourseManageApi extends ApiBaseController{
/** /**
* 发布课程信息,已经没有单独的发布了 * 发布课程信息,已经没有单独的发布了
* @param id
* @param title
* @param pass
* @param remark
* @return * @return
*/ */
@Deprecated @Deprecated
@@ -1221,5 +1220,10 @@ public class CourseManageApi extends ApiBaseController{
return success(courses); return success(courses);
} }
@PostMapping("/saveTip")
public JsonResponse<Boolean> saveTip(){
String aid=getCurrent().getAccountId();
courseService.saveTip(aid);
return success(true);
}
} }

View File

@@ -13,10 +13,7 @@ import com.xboe.module.course.dto.CourseTeacherDto;
import com.xboe.module.course.dto.RankingDto; import com.xboe.module.course.dto.RankingDto;
import com.xboe.module.course.dto.TeacherCourseDto; import com.xboe.module.course.dto.TeacherCourseDto;
import com.xboe.module.course.entity.*; import com.xboe.module.course.entity.*;
import com.xboe.module.course.service.ICourseContentService; import com.xboe.module.course.service.*;
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.CourseStudyVo;
import com.xboe.module.course.vo.TeacherVo; import com.xboe.module.course.vo.TeacherVo;
import com.xboe.module.teacher.entity.Teacher; import com.xboe.module.teacher.entity.Teacher;
@@ -33,6 +30,7 @@ import com.xboe.system.user.entity.User;
import com.xboe.system.user.service.IUserService; import com.xboe.system.user.service.IUserService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -97,6 +95,8 @@ public class CoursePortalApi extends ApiBaseController{
@Autowired @Autowired
StringRedisTemplate redisTemplate; StringRedisTemplate redisTemplate;
@Resource
private ICourseTagService courseTagService;
/** /**
* 根据多个课程id返回对应的课程的图片.返回结果如下, * 根据多个课程id返回对应的课程的图片.返回结果如下,
@@ -261,7 +261,14 @@ public class CoursePortalApi extends ApiBaseController{
if(course==null || course.getDeleted()){ if(course==null || course.getDeleted()){
return badRequest("课程不存在或已被删除"); return badRequest("课程不存在或已被删除");
} }
rs.put("course",course); 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);
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(id); List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(id);
if(crowd!=null && crowd) { if(crowd!=null && crowd) {

View File

@@ -26,6 +26,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
/** /**
* @ClassName:CourseTagApi * @ClassName:CourseTagApi
@@ -153,9 +154,6 @@ public class CourseTagApi extends ApiBaseController {
CurrentUser cuser = getCurrent(); CurrentUser cuser = getCurrent();
String aid = cuser.getAccountId(); 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); List<CourseTag> courseTagList = courseTagService.searchTags(tagName,aid,typeId);
return success(courseTagList); return success(courseTagList);
} }
@@ -167,8 +165,14 @@ public class CourseTagApi extends ApiBaseController {
*/ */
@RequestMapping(value="/createTag",method= RequestMethod.POST) @RequestMapping(value="/createTag",method= RequestMethod.POST)
public JsonResponse<CourseTag> createTag(CourseTagRelationDto courseTagRelationDto){ 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){ if (courseTagRelationDto!=null){
CourseTag courseTag = courseTagService.createTag(courseTagRelationDto); CourseTag courseTag = courseTagService.createTag(courseTagRelationDto);
if (courseTag == null ){
return error("创建标签失败!");
}
return success(courseTag); return success(courseTag);
} }
return error("创建标签失败!"); 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" + String sql = "select t.*,COUNT(r.tag_id) AS relation_count\n" +
"from boe_course_tag t\n" + "from boe_course_tag t\n" +
"left join boe_course_tag_relation r\n" + "left join boe_course_tag_relation r\n" +
"on t.id = r.tag_id\n" + "on t.id = r.tag_id AND r.deleted =0 \n" +
"where t.deleted =0 and t.is_hot = true and t.status =0 \n" + "where t.deleted =0 and t.is_hot = true and t.status =0 \n" +
"GROUP BY t.id\n" + "GROUP BY t.id\n" +
"order by t.last_set_hot_time desc,relation_count desc"; // 数据库字段为last_set_hot_time "order by t.last_set_hot_time desc"; // 数据库字段为last_set_hot_time
// 创建原生查询并指定结果映射到CourseTag实体 // 创建原生查询并指定结果映射到CourseTag实体
javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class); javax.persistence.Query query = entityManager.createNativeQuery(sql, CourseTag.class);
@@ -105,7 +105,7 @@ public class CourseTagDao extends BaseDao<CourseTag> {
} }
public CourseTag getTagByName(String tagName) { public CourseTag getTagByName(String tagName) {
CourseTag courseTag = this.findOne((FieldFilters.eq("tag_name", tagName))); CourseTag courseTag = this.findOne(FieldFilters.eq("tag_name", tagName),FieldFilters.eq("deleted", false),FieldFilters.eq("status", 0));
return courseTag; return courseTag;
} }
@@ -129,36 +129,31 @@ 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("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("FROM ( ");
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 = 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(" 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(" FROM boe_course_tag_relation r ");
sql.append(" INNER JOIN boe_course_tag t ON r.tag_id = t.id "); 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 "); sql.append(" WHERE r.deleted = 0 AND t.deleted = 0 AND t.is_public = 0 AND t.status = 0 ");
if (StringUtils.isNotBlank(userId)) { if (StringUtils.isNotBlank(userId)) {
sql.append(" AND r.sys_create_aid = ? "); sql.append(" AND r.sys_create_aid = ? ");
parameters.add(Long.valueOf(userId)); parameters.add(Long.valueOf(userId));
} }
if (StringUtils.isNotBlank(tagName)) { if (StringUtils.isNotBlank(tagName)) {
sql.append(" AND t.tag_name LIKE ? "); sql.append(" AND t.tag_name LIKE ? ");
parameters.add("%" + tagName + "%"); 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(" GROUP BY t.id, t.tag_name, t.is_public, t.is_hot, t.use_count, t.last_set_public_time, t.last_set_hot_time, t.deleted, t.sys_create_time ");
sql.append(" UNION ALL ");
sql.append(" SELECT id, tag_name, is_public, is_hot, use_count, last_set_public_time, last_set_hot_time, deleted, sys_create_time ");
sql.append(" FROM boe_course_tag ");
sql.append(" WHERE deleted = 0 AND is_public = 1 AND status = 0 ");
if (StringUtils.isNotBlank(tagName)) {
sql.append(" AND tag_name LIKE ? ");
parameters.add("%" + tagName + "%");
}
sql.append(") AS all_tags "); sql.append(") AS all_tags ");
sql.append("ORDER BY ");
if (StringUtils.isNotBlank(typeId)) { if (StringUtils.isNotBlank(typeId)) {
sql.append("ORDER BY ");
sql.append(" CASE WHEN id IN ( "); sql.append(" CASE WHEN id IN ( ");
sql.append(" SELECT tag_id "); sql.append(" SELECT tag_id ");
sql.append(" FROM boe_course_type_tag_relation "); sql.append(" FROM boe_course_type_tag_relation ");
@@ -167,13 +162,13 @@ public class CourseTagDao extends BaseDao<CourseTag> {
sql.append(" OR sys_type2 = ? "); sql.append(" OR sys_type2 = ? ");
sql.append(" OR sys_type3 = ?) "); sql.append(" OR sys_type3 = ?) ");
sql.append(" GROUP BY tag_id "); 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)); parameters.add(Long.valueOf(typeId));
parameters.add(Long.valueOf(typeId)); parameters.add(Long.valueOf(typeId));
} }
sql.append(" sys_create_time DESC"); // sql.append(" sys_update_time DESC");
log.info("查询标签 searchTags sql = {} ", sql); log.info("查询标签 searchTags sql = {} ", sql);
// 不使用实体类映射,手动处理结果集 // 不使用实体类映射,手动处理结果集
Query query = entityManager.createNativeQuery(sql.toString()); Query query = entityManager.createNativeQuery(sql.toString());

View File

@@ -113,4 +113,18 @@ public class CourseTagRelationDao extends BaseDao<CourseTagRelation> {
.collect(Collectors.toList()); .collect(Collectors.toList());
return new PageList<CourseTagRelationDto>(list,totalresults!=null?totalresults.size():0); 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

@@ -0,0 +1,20 @@
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

@@ -0,0 +1,12 @@
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

@@ -400,6 +400,12 @@ public class Course extends BaseEntity {
@Transient @Transient
private String teacher; private String teacher;
/**
* 新增在线课时是否需要标签提示
*/
@Transient
private Boolean isTip;
public Course(String id,String name,String summary,String coverImg,String sysCreateAid,String sysCreateBy,Integer type,LocalDateTime publishTime){ public Course(String id,String name,String summary,String coverImg,String sysCreateAid,String sysCreateBy,Integer type,LocalDateTime publishTime){
super.setId(id); super.setId(id);
this.name=name; this.name=name;

View File

@@ -0,0 +1,45 @@
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

@@ -0,0 +1,36 @@
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

@@ -344,5 +344,11 @@ public interface ICourseService {
List<Course> findByIds(List<String> courseIds); List<Course> findByIds(List<String> courseIds);
void deletedStudyResourceBatchByCourseIdAndType(String courseId,Integer courseType); void deletedStudyResourceBatchByCourseIdAndType(String courseId,Integer courseType);
void getPhpCourseData(); void saveTip(String aid);
Boolean getCourseTip(String aid);
void rePublish(String courseId);
// void getPhpCourseData();
} }

View File

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

View File

@@ -17,6 +17,7 @@ import javax.management.Query;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.json.JSONUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest; import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
@@ -27,6 +28,7 @@ import com.xboe.api.ThirdApi;
import com.xboe.core.orm.*; import com.xboe.core.orm.*;
import com.xboe.module.course.dao.*; import com.xboe.module.course.dao.*;
import com.xboe.module.course.entity.*; import com.xboe.module.course.entity.*;
import com.xboe.module.course.dao.*;
import com.xboe.module.course.dto.CourseTagRelationDto; import com.xboe.module.course.dto.CourseTagRelationDto;
import com.xboe.module.course.entity.*; import com.xboe.module.course.entity.*;
import com.xboe.module.course.service.ICourseTagService; import com.xboe.module.course.service.ICourseTagService;
@@ -123,10 +125,15 @@ public class CourseServiceImpl implements ICourseService {
@Resource @Resource
RestHighLevelClient restHighLevelClient; RestHighLevelClient restHighLevelClient;
@Resource
private TipDao tipDao;
@Resource @Resource
private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao; private CourseTeacherDeletedRecordDao courseTeacherDeletedRecordDao;
@Resource
private ModifyLogDao modifyLogDao;
/** /**
* 生成过滤条件 * 生成过滤条件
* *
@@ -920,6 +927,7 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) { for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId()); ct.setCourseId(c.getId());
courseTeacherDao.save(ct); courseTeacherDao.save(ct);
addBoeCourseTeacherModifyLog(ct, "M1位置讲师名修改", JSONUtil.toJsonStr(ct), null);
} }
} }
if (full.getCrowds() != null && !full.getCrowds().isEmpty()) { if (full.getCrowds() != null && !full.getCrowds().isEmpty()) {
@@ -998,7 +1006,7 @@ public class CourseServiceImpl implements ICourseService {
if (c.getVisible() == null) { if (c.getVisible() == null) {
c.setVisible(true); c.setVisible(true);
} }
if (c.getTags() != null && !c.getTags().isEmpty()){ /*if (c.getTags() != null && !c.getTags().isEmpty()){
CourseTagRelationDto courseTagRelationDto = new CourseTagRelationDto(); CourseTagRelationDto courseTagRelationDto = new CourseTagRelationDto();
courseTagRelationDto.setCourseId(c.getId()); courseTagRelationDto.setCourseId(c.getId());
courseTagRelationDto.setSysType1(c.getSysType1()); courseTagRelationDto.setSysType1(c.getSysType1());
@@ -1012,7 +1020,15 @@ public class CourseServiceImpl implements ICourseService {
courseTagService.createTag(courseTagRelationDto); 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); courseDao.update(c);
c.setSysVersion(courseDao.getVersion(c.getId())); c.setSysVersion(courseDao.getVersion(c.getId()));
full.getCourse().setSysVersion(c.getSysVersion()); full.getCourse().setSysVersion(c.getSysVersion());
@@ -1025,6 +1041,7 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) { for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId()); ct.setCourseId(c.getId());
courseTeacherDao.saveOrUpdate(ct); courseTeacherDao.saveOrUpdate(ct);
addBoeCourseTeacherModifyLog(ct, "M2位置讲师名修改", JSONUtil.toJsonStr(ct), null);
} }
} }
//先清空受众信息,受众信息如果不一样了,也要加入到日志中 //先清空受众信息,受众信息如果不一样了,也要加入到日志中
@@ -1081,6 +1098,7 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) { for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId()); ct.setCourseId(c.getId());
courseTeacherDao.saveOrUpdate(ct); courseTeacherDao.saveOrUpdate(ct);
addBoeCourseTeacherModifyLog(ct, "M3位置讲师名修改", JSONUtil.toJsonStr(ct), null);
} }
} }
//先清空受众信息,受众信息如果不一样了,也要加入到日志中 //先清空受众信息,受众信息如果不一样了,也要加入到日志中
@@ -1106,12 +1124,16 @@ public class CourseServiceImpl implements ICourseService {
public void submitAndPublish(CourseFullDto full, String aid, String aname) throws Exception { public void submitAndPublish(CourseFullDto full, String aid, String aname) throws Exception {
Course c = full.getCourse();//当前的课程信息 Course c = full.getCourse();//当前的课程信息
log.info(" 课程 c = " + c.getId());
log.info(" 课程 c = " + c);
c.setPublished(true); c.setPublished(true);
c.setPublishTime(LocalDateTime.now()); 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); courseDao.update(c);
log.info(" 课程 c = " + c.getId());
// 兼容处理,记录下删除的关联数据 // 兼容处理,记录下删除的关联数据
createCourseTeacherDeletedRecord(c.getId()); createCourseTeacherDeletedRecord(c.getId());
@@ -1121,6 +1143,7 @@ public class CourseServiceImpl implements ICourseService {
for (CourseTeacher ct : full.getTeachers()) { for (CourseTeacher ct : full.getTeachers()) {
ct.setCourseId(c.getId()); ct.setCourseId(c.getId());
courseTeacherDao.saveOrUpdate(ct); courseTeacherDao.saveOrUpdate(ct);
addBoeCourseTeacherModifyLog(ct, "M4位置讲师名修改", JSONUtil.toJsonStr(ct), null);
} }
} }
//先清空受众信息,受众信息如果不一样了,也要加入到日志中 //先清空受众信息,受众信息如果不一样了,也要加入到日志中
@@ -1180,7 +1203,7 @@ public class CourseServiceImpl implements ICourseService {
/*** /***
* 发布全文索引 * 发布全文索引
* @param c * @param
*/ */
// private void fullTextPublish(Course c) { // private void fullTextPublish(Course c) {
// if(fullTextSearch==null) { // if(fullTextSearch==null) {
@@ -2023,108 +2046,7 @@ public class CourseServiceImpl implements ICourseService {
return courseDao.findListByHql("Select new Course(id,studys,score) from Course where id in(?1)", ids); 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 @Override
public void deletedStudyResourceBatchByCourseIdAndType(String courseId, Integer courseType) { public void deletedStudyResourceBatchByCourseIdAndType(String courseId, Integer courseType) {
DeleteByQueryRequest request = new DeleteByQueryRequest("new_study_resource"); DeleteByQueryRequest request = new DeleteByQueryRequest("new_study_resource");
@@ -2159,4 +2081,46 @@ 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,13 +388,15 @@ public class CourseTagServiceImpl implements ICourseTagService {
filters.add(FieldFilters.eq("deleted",false));//未删除的 filters.add(FieldFilters.eq("deleted",false));//未删除的
query.addFilters(filters); query.addFilters(filters);
List<CourseTag> courseTagList = courseTagDao.findList(query.builder()); List<CourseTag> courseTagList = courseTagDao.findList(query.builder());
if (courseTagList==null || courseTagList.isEmpty()){//1.1 如果该标签不存在,则新建标签 if (courseTagList==null || courseTagList.isEmpty() || !courseTagList.get(0).getIsPublic()){//1.1 如果该标签不存在 或私有标签,则新建标签
courseTag = new CourseTag(); courseTag = new CourseTag();
courseTag.setTagName(tagName); courseTag.setTagName(tagName);
courseTag.setIsPublic(false); courseTag.setIsPublic(false);
courseTag.setIsHot(false); courseTag.setIsHot(false);
courseTag.setStatus(1); courseTag.setStatus(1);
courseTag.setUseCount(1); courseTag.setUseCount(1);
//初始给个时间, 变更公共会更新时间 关闭公共会设置null 后续不在自动变更为公共
courseTag.setLastSetPublicTime(LocalDateTime.now());
courseTagDao.save(courseTag); courseTagDao.save(courseTag);
} }
return courseTag; return courseTag;
@@ -408,11 +410,13 @@ public class CourseTagServiceImpl implements ICourseTagService {
log.info(" --- 标签修改 --- 用户信息 userInfo = {} " , userInfo); log.info(" --- 标签修改 --- 用户信息 userInfo = {} " , userInfo);
// 获取新旧课程的标签ID列表 // 获取新旧课程的标签ID列表
log.info(" --- 旧标签1 oldTagIds = {} " , oldCourse.getTags());
log.info(" --- 新修改1 newTagIds = {} " , newCourse.getTags());
List<String> oldTagIds = getTagIdsFromCourse(oldCourse); List<String> oldTagIds = getTagIdsFromCourse(oldCourse);
List<String> newTagIds = getTagIdsFromCourse(newCourse); List<String> newTagIds = getTagIdsFromCourse(newCourse);
log.info(" --- 旧标签 oldTagIds = {} " , oldTagIds); log.info(" --- 旧标签2 oldTagIds = {} " , oldTagIds);
log.info(" --- 新修改 newTagIds = {} " , newTagIds); log.info(" --- 新修改2 newTagIds = {} " , newTagIds);
if (oldCourse == null) { if (oldCourse == null || oldTagIds.isEmpty()) {
// 新增课程 - 处理所有新标签 // 新增课程 - 处理所有新标签
handleNewCourseTags(newCourse, newTagIds, userInfo); handleNewCourseTags(newCourse, newTagIds, userInfo);
} else { } else {
@@ -422,6 +426,17 @@ public class CourseTagServiceImpl implements ICourseTagService {
log.info("完成课程标签更新: courseId={}", newCourse != null ? newCourse.getId() : "null"); 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列表 * 从课程对象中提取标签ID列表
*/ */
@@ -574,6 +589,7 @@ public class CourseTagServiceImpl implements ICourseTagService {
List<IFieldFilter> filters = new ArrayList<>(); List<IFieldFilter> filters = new ArrayList<>();
filters.add(FieldFilters.eq("courseId", Long.valueOf(courseId))); filters.add(FieldFilters.eq("courseId", Long.valueOf(courseId)));
filters.add(FieldFilters.eq("tagId", Long.valueOf(tag.getId()))); filters.add(FieldFilters.eq("tagId", Long.valueOf(tag.getId())));
// filters.add(FieldFilters.eq("deleted", false));
query.addFilters(filters); query.addFilters(filters);
List<CourseTagRelation> existingRelations = courseTagRelationDao.findList(query.builder()); List<CourseTagRelation> existingRelations = courseTagRelationDao.findList(query.builder());
@@ -600,13 +616,12 @@ public class CourseTagServiceImpl implements ICourseTagService {
// 恢复已删除的关联关系 // 恢复已删除的关联关系
CourseTagRelation relation = existingRelations.get(0); CourseTagRelation relation = existingRelations.get(0);
if (relation.getDeleted()) { if (relation.getDeleted()) {
relation.setDeleted(false); courseTagRelationDao.reTagRelDelStatus(relation.getId(),userInfo.getName());
// relation.setDeleted(false);
// 设置更新信息 // 设置更新信息
relation.setSysUpdateBy(userInfo.getName()); // relation.setSysUpdateBy(userInfo.getName());
relation.setSysUpdateTime(now); // relation.setSysUpdateTime(now);
// courseTagRelationDao.saveOrUpdate(relation);
courseTagRelationDao.saveOrUpdate(relation);
} }
} }
log.debug("完成课程-标签关联关系创建: courseId={}, tagId={}", courseId, tag != null ? tag.getId() : "null"); log.debug("完成课程-标签关联关系创建: courseId={}, tagId={}", courseId, tag != null ? tag.getId() : "null");
@@ -650,6 +665,7 @@ public class CourseTagServiceImpl implements ICourseTagService {
filters.add(FieldFilters.eq("sysType2", sysType2)); filters.add(FieldFilters.eq("sysType2", sysType2));
filters.add(FieldFilters.eq("sysType3", sysType3)); filters.add(FieldFilters.eq("sysType3", sysType3));
filters.add(FieldFilters.eq("tagId", tagId)); filters.add(FieldFilters.eq("tagId", tagId));
// filters.add(FieldFilters.eq("deleted", false));
query.addFilters(filters); query.addFilters(filters);
List<CourseTypeTagRelation> existingRelations = courseTypeTagRelationDao.findList(query.builder()); List<CourseTypeTagRelation> existingRelations = courseTypeTagRelationDao.findList(query.builder());
@@ -678,13 +694,12 @@ public class CourseTagServiceImpl implements ICourseTagService {
// 恢复已删除的关联关系 // 恢复已删除的关联关系
CourseTypeTagRelation relation = existingRelations.get(0); CourseTypeTagRelation relation = existingRelations.get(0);
if (relation.getDeleted()) { if (relation.getDeleted()) {
relation.setDeleted(false); courseTagRelationDao.reTypeTagRelDelStatus(relation.getId(),userInfo.getName());
// relation.setDeleted(false);
// 设置更新信息 // // 设置更新信息
relation.setSysUpdateBy(userInfo.getName()); // relation.setSysUpdateBy(userInfo.getName());
relation.setSysUpdateTime(now); // relation.setSysUpdateTime(now);
// courseTypeTagRelationDao.saveOrUpdate(relation);
courseTypeTagRelationDao.saveOrUpdate(relation);
} }
} }
} }
@@ -793,7 +808,7 @@ public class CourseTagServiceImpl implements ICourseTagService {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
// 检查是否满足设置为公共标签的条件 // 检查是否满足设置为公共标签的条件
if (activeCount >= 3 && tag.getLastSetPublicTime() == null) { if (activeCount >= 3 && tag.getLastSetPublicTime() != null) {
// 只有从未手动关闭过公共标签的才自动开启 // 只有从未手动关闭过公共标签的才自动开启
tag.setIsPublic(true); tag.setIsPublic(true);
tag.setLastSetPublicTime(now); tag.setLastSetPublicTime(now);

View File

@@ -0,0 +1,14 @@
package com.xboe.module.course.vo;
import lombok.Data;
/**
* @date 2025/11/17
*/
@Data
public class RePublishVo {
/**
* 课程id
* */
private String courseId;
}

View File

@@ -14,12 +14,15 @@ import com.boe.feign.api.infrastructure.entity.CommonSearchVo;
import com.boe.feign.api.infrastructure.entity.Dict; import com.boe.feign.api.infrastructure.entity.Dict;
import com.xboe.api.ThirdApi; import com.xboe.api.ThirdApi;
import com.xboe.constants.CacheName; import com.xboe.constants.CacheName;
import com.xboe.module.course.entity.*;
import com.xboe.module.course.service.ICourseTagService;
import com.xboe.module.course.vo.TeacherVo; import com.xboe.module.course.vo.TeacherVo;
import com.xboe.module.usergroup.service.IUserGroupService; import com.xboe.module.usergroup.service.IUserGroupService;
import com.xboe.school.study.dao.StudyCourseDao; import com.xboe.school.study.dao.StudyCourseDao;
import com.xboe.school.vo.StudyTimeVo; import com.xboe.school.vo.StudyTimeVo;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
@@ -36,11 +39,6 @@ import com.xboe.common.utils.StringUtil;
import com.xboe.core.CurrentUser; import com.xboe.core.CurrentUser;
import com.xboe.core.JsonResponse; import com.xboe.core.JsonResponse;
import com.xboe.core.api.ApiBaseController; 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.ICourseContentService;
import com.xboe.module.course.service.ICourseSectionService; import com.xboe.module.course.service.ICourseSectionService;
import com.xboe.module.course.service.ICourseService; import com.xboe.module.course.service.ICourseService;
@@ -102,6 +100,8 @@ public class StudyCourseApi extends ApiBaseController{
@Autowired @Autowired
StringRedisTemplate redisTemplate; StringRedisTemplate redisTemplate;
@Resource
private ICourseTagService courseTagService;
/** /**
* 用于查询课程的学习记录 * 用于查询课程的学习记录
@@ -169,7 +169,14 @@ public class StudyCourseApi extends ApiBaseController{
if(course==null || course.getDeleted()){ if(course==null || course.getDeleted()){
return badRequest("课程不存在或已被删除"); return badRequest("课程不存在或已被删除");
} }
rs.put("course",course); 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);
List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(cid); List<CourseCrowd> courseCrowdList = courseService.findCrowdByCourseId(cid);
if(crowd!=null && crowd) { if(crowd!=null && crowd) {

View File

@@ -4,6 +4,8 @@ import com.xboe.common.beans.IdName;
import com.xboe.common.beans.KeyValue; import com.xboe.common.beans.KeyValue;
import com.xboe.core.JsonResponse; import com.xboe.core.JsonResponse;
import com.xboe.core.api.ApiBaseController; 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.dto.BatchSignup;
import com.xboe.school.study.entity.StudySignup; import com.xboe.school.study.entity.StudySignup;
import com.xboe.school.study.service.IStudySignupService; import com.xboe.school.study.service.IStudySignupService;
@@ -32,7 +34,8 @@ public class StudySignupRpcController extends ApiBaseController {
@Resource @Resource
IStudySignupService signupService; IStudySignupService signupService;
@Resource
ICourseService courseService;
/** /**
* 批量添加学员 * 批量添加学员
* *
@@ -106,4 +109,18 @@ public class StudySignupRpcController extends ApiBaseController {
return StringUtils.isBlank(string); 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

@@ -79,13 +79,15 @@ xboe:
default: https://u.boe.com/pc/images/bgimg/course.png default: https://u.boe.com/pc/images/bgimg/course.png
case: case:
ai: ai:
base-url: http://10.10.181.114:30003 base-url: https://gateway-internal.boe.com
app-key: 6e9be45319184ac793aa127c362b0f0b # base-url: https://gateway-pro.boe.com
secret-key: db4d24279e3d6dbf1524af42cd0bedd2 app-key: 3edef300b25642da949ccddf58441a0f
secret-key: 43bc8003a811a7f9c89cbecbfe4bbb22
ai-api-code: 30800 ai-api-code: 30800
chat-api-code: 32065 chat-api-code: 32065
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff case-knowledge-id: f062c9e4-c6ad-437b-b5ca-bbb9fed9b442
file-upload-callback-url: http://10.251.113.95:9090/xboe/m/boe/caseDocumentLog/uploadCallback caseDetailUrlBase: https://u.boe.com/pc/case/detail?id=
file-upload-callback-url: https://u.boe.com/systemapi/xboe/m/boe/caseDocumentLog/uploadCallback
use-white-list: true use-white-list: true
white-user-code-list: white-user-code-list:
- "00004409" - "00004409"
@@ -108,10 +110,12 @@ xboe:
- "00005011" - "00005011"
- "10827857" - "10827857"
- "11339772" - "11339772"
- "pctest06"
alert-email-recipients: alert-email-recipients:
- chengmeng@boe.com.cn - chengmeng@boe.com.cn
- liyubing@boe.com.cn - liyubing@boe.com.cn
- lijian-hq@boe.com.cn - lijian-hq@boe.com.cn
ai-chat-root-path: /home/www/elearning/upload/ai/chat
xxl: xxl:
job: job:
accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0 accessToken: 65ddc683-22f5-83b4-de3a-3c97a0a29af0

View File

@@ -119,6 +119,7 @@ xboe:
ai-api-code: 30800 ai-api-code: 30800
chat-api-code: 32065 chat-api-code: 32065
case-knowledge-id: de2e006e-82fb-4ace-8813-f25c316be4ff 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 file-upload-callback-url: http://10.251.186.27:9090/xboe/m/boe/caseDocumentLog/uploadCallback
use-white-list: true use-white-list: true
white-user-code-list: white-user-code-list:
@@ -144,6 +145,7 @@ xboe:
- "11339772" - "11339772"
alert-email-recipients: alert-email-recipients:
- chengmeng@boe.com.cn - chengmeng@boe.com.cn
ai-chat-root-path: /home/www/elearning/upload/ai/chat
jasypt: jasypt:
encryptor: encryptor:
algorithm: PBEWithMD5AndDES algorithm: PBEWithMD5AndDES