mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/per-boe/java-servers.git
synced 2025-12-13 21:06:48 +08:00
Compare commits
9 Commits
release_20
...
fix_1155
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
06e301ab90 | ||
|
|
c6323e2472 | ||
|
|
ec676aebbe | ||
|
|
e0b061bbf3 | ||
|
|
c056033dbf | ||
|
|
3e06950f8c | ||
|
|
23b5d16614 | ||
|
|
8664cc046b | ||
|
|
099f25c934 |
@@ -8,7 +8,7 @@ public class CaseAiConstants {
|
||||
|
||||
public static final String CASE_DOC_DELETE_INTERFACE_NAME = "文档删除";
|
||||
|
||||
public static final String CHAT_SYS_ERR_MSG = "服务繁忙,请稍后再试。";
|
||||
public static final String CHAT_SYS_ERR_MSG = "当前无法获取回答,请稍后重试";
|
||||
|
||||
public static final String CHAT_NET_ERR_MSG = "网络异常,请稍后再试。";
|
||||
public static final String CHAT_NET_ERR_MSG = "网络异常,请稍后再试";
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
||||
|
||||
//老师信息
|
||||
//if(u.getUserType()!=null && u.getUserType()==2) {
|
||||
if ((user.getTeacher() != null && user.getTeacher()) || (user.getUserType() != null && user.getUserType() == 2)) {
|
||||
/*if ((user.getTeacher() != null && user.getTeacher()) || (user.getUserType() != null && user.getUserType() == 2)) {
|
||||
Teacher t = teacherDao.get(user.getId());
|
||||
log.info("用户有教师身份,处理教师身份");
|
||||
if (t == null) {
|
||||
@@ -182,7 +182,7 @@ public class DataUserSyncServiceImpl implements IDataUserSyncService {
|
||||
} else {
|
||||
log.info("教师身份已存在,不再添加");
|
||||
}
|
||||
}
|
||||
}*/
|
||||
log.info("同步用户完成");
|
||||
|
||||
}
|
||||
|
||||
@@ -230,7 +230,7 @@ public class CaseAiChatApi extends ApiBaseController {
|
||||
aiChatConversationData.setCaseRefers(caseAiMessageVo.getCaseRefer());
|
||||
aiChatConversationData.setSuggestions(caseAiMessageVo.getSuggestions());
|
||||
aiChatConversationData.setUserId(userId);
|
||||
if (elasticSearchIndexService.createData(aiChatConversationData)) {
|
||||
if (elasticSearchIndexService.createData(aiChatConversationData) != null) {
|
||||
return success("创建成功");
|
||||
}
|
||||
return error("创建失败");
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface IElasticSearchIndexService {
|
||||
* @param data
|
||||
* @return
|
||||
*/
|
||||
boolean createData(AiChatConversationData data);
|
||||
String createData(AiChatConversationData data);
|
||||
|
||||
/**
|
||||
* 查询数据
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.xboe.module.boecase.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.xboe.constants.CaseAiConstants;
|
||||
import com.xboe.core.CurrentUser;
|
||||
import com.xboe.core.orm.FieldFilters;
|
||||
@@ -175,22 +176,22 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
if (org.apache.commons.lang3.StringUtils.isBlank(accessToken)) {
|
||||
errMessage(sseEmitter, conversationId, CaseAiConstants.CHAT_SYS_ERR_MSG);
|
||||
// 先响应给前端
|
||||
sseEmitter.complete();
|
||||
conversationData.setStatus(CaseAiChatErrCodeEnum.AIOT_ERROR.getCode());
|
||||
conversationData.setErrorMsg("获取AccessToken时发生异常");
|
||||
conversationData.appendAnswer(CaseAiConstants.CHAT_SYS_ERR_MSG);
|
||||
saveConversationData(conversationData);
|
||||
saveConversationData(sseEmitter, conversationData);
|
||||
sseEmitter.complete();
|
||||
return sseEmitter;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("获取access_token失败", e);
|
||||
errMessage(sseEmitter, conversationId, CaseAiConstants.CHAT_SYS_ERR_MSG);
|
||||
// 先响应给前端
|
||||
sseEmitter.complete();
|
||||
conversationData.setStatus(CaseAiChatErrCodeEnum.AIOT_ERROR.getCode());
|
||||
conversationData.setErrorMsg("获取AccessToken时发生异常" + e.getMessage());
|
||||
conversationData.appendAnswer(CaseAiConstants.CHAT_SYS_ERR_MSG);
|
||||
saveConversationData(conversationData);
|
||||
saveConversationData(sseEmitter, conversationData);
|
||||
sseEmitter.complete();
|
||||
return sseEmitter;
|
||||
}
|
||||
String apiCode = caseAiProperties.getChatApiCode();
|
||||
@@ -239,11 +240,11 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
}
|
||||
|
||||
errMessage(sseEmitter, conversationId, sseContent);
|
||||
sseEmitter.complete();
|
||||
conversationData.setStatus(CaseAiChatErrCodeEnum.AIOT_ERROR.getCode());
|
||||
conversationData.setErrorMsg(sseContent);
|
||||
conversationData.appendAnswer(sseContent);
|
||||
saveConversationData(conversationData);
|
||||
saveConversationData(sseEmitter, conversationData);
|
||||
sseEmitter.complete();
|
||||
// 关闭eventSource
|
||||
eventSource.cancel();
|
||||
return;
|
||||
@@ -256,7 +257,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
public void onClosed(@NotNull EventSource eventSource) {
|
||||
log.info("调用接口 [{}] 接口关闭", request.url());
|
||||
// 对话完成,保存到ES
|
||||
saveConversationData(conversationData);
|
||||
saveConversationData(sseEmitter, conversationData);
|
||||
// 从Map中移除已完成的会话
|
||||
conversationEventSourceMap.remove(conversationId);
|
||||
sseEmitter.complete();
|
||||
@@ -352,14 +353,14 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
}
|
||||
|
||||
errMessage(sseEmitter, conversationId, errorMessage);
|
||||
sseEmitter.complete();
|
||||
// 从Map中移除失败的会话
|
||||
conversationEventSourceMap.remove(conversationId);
|
||||
// 即使失败,也要将已有的对话数据保存到ES
|
||||
conversationData.setStatus(CaseAiChatErrCodeEnum.AIOT_ERROR.getCode());
|
||||
conversationData.setErrorMsg(errorMessage);
|
||||
conversationData.appendAnswer(errorMessage);
|
||||
saveConversationData(conversationData);
|
||||
saveConversationData(sseEmitter, conversationData);
|
||||
sseEmitter.complete();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -407,6 +408,7 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
httpPost.setHeader("access_token", accessToken);
|
||||
httpPost.setHeader("X-AI-ApiCode", apiCode);
|
||||
httpPost.setHeader("Content-Type", "application/json");
|
||||
httpPost.setHeader("X-AI-ApiRawResponse", "true");
|
||||
|
||||
// 设置请求体
|
||||
JSONObject requestBody = new JSONObject();
|
||||
@@ -1005,7 +1007,17 @@ public class CaseAiChatServiceImpl implements ICaseAiChatService {
|
||||
* 异步存储会话数据
|
||||
* @param conversationData
|
||||
*/
|
||||
private void saveConversationData(AiChatConversationData conversationData) {
|
||||
esChatExecutor.execute(() -> elasticSearchIndexService.createData(conversationData));
|
||||
private void saveConversationData(SseEmitter sseEmitter, AiChatConversationData conversationData) {
|
||||
try {
|
||||
String docId = elasticSearchIndexService.createData(conversationData);
|
||||
if (docId != null) {
|
||||
JSONObject responseData = new JSONObject();
|
||||
responseData.put("docId", docId);
|
||||
responseData.put("status", "9");
|
||||
sseEmitter.send(responseData.toJSONString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("docId消息发送失败", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,10 +163,10 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean createData(AiChatConversationData conversationData) {
|
||||
public String createData(AiChatConversationData conversationData) {
|
||||
if (elasticsearchClient == null) {
|
||||
log.error("未配置Elasticsearch客户端,无法保存对话记录");
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -209,10 +209,10 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
|
||||
|
||||
IndexResponse indexResponse = elasticsearchClient.index(indexRequest, RequestOptions.DEFAULT);
|
||||
log.info("保存对话记录到ES成功,文档ID: {}", indexResponse.getId());
|
||||
return true;
|
||||
return indexResponse.getId();
|
||||
} catch (Exception e) {
|
||||
log.error("保存对话记录到ES异常", e);
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,6 +238,7 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
CaseAiMessageVo data = parseMessageFromES(sourceMap);
|
||||
if (data != null) {
|
||||
data.setDocId(hit.getId());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
@@ -253,6 +254,7 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
|
||||
private CaseAiMessageVo parseMessageFromES(Map<String, Object> sourceMap) {
|
||||
try {
|
||||
CaseAiMessageVo messageVo = new CaseAiMessageVo();
|
||||
messageVo.setConversationId((String) sourceMap.get("conversationId"));
|
||||
messageVo.setQuery((String) sourceMap.get("query"));
|
||||
messageVo.setAnswer((String) sourceMap.get("answer"));
|
||||
if (sourceMap.containsKey("startTime")) {
|
||||
@@ -387,6 +389,7 @@ public class ElasticSearchIndexServiceImpl implements IElasticSearchIndexService
|
||||
Map<String, Object> sourceMap = hit.getSourceAsMap();
|
||||
CaseAiMessageVo data = parseMessageFromES(sourceMap);
|
||||
if (data != null) {
|
||||
data.setDocId(hit.getId());
|
||||
list.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,15 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class CaseAiMessageVo {
|
||||
/**
|
||||
* ES docId
|
||||
*/
|
||||
private String docId;
|
||||
|
||||
/**
|
||||
* 会话ID
|
||||
*/
|
||||
private String conversationId;
|
||||
|
||||
/**
|
||||
* 用户提问内容
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.xboe.module.course.entity.*;
|
||||
import com.xboe.module.course.service.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
@@ -137,6 +138,10 @@ public class CourseManageApi extends ApiBaseController{
|
||||
dto.setOrgIds(ids);
|
||||
dto.setReadIds(userOrgIds.getReadIds());
|
||||
PageList<Course> coursePageList = courseService.findPage(pager.getPageIndex(), pager.getPageSize(),dto);
|
||||
//补充审核人,审核时间字段
|
||||
if(CollectionUtils.isEmpty(coursePageList.getList())){
|
||||
fullAuditInfo(coursePageList.getList());
|
||||
}
|
||||
return success(coursePageList);
|
||||
}catch(Exception e) {
|
||||
log.error("管理课程列表查询错误",e);
|
||||
@@ -1226,4 +1231,19 @@ public class CourseManageApi extends ApiBaseController{
|
||||
courseService.saveTip(aid);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
public void fullAuditInfo(List<Course> list){
|
||||
List<String> courseIdList = list.stream().map(Course::getId).collect(Collectors.toList());
|
||||
List<CourseHRBPAudit> auditList = hrbpAuditService.listByCourseIds(courseIdList);
|
||||
Map<String,CourseHRBPAudit> map = auditList.stream().collect(Collectors.toMap(CourseHRBPAudit::getCourseId, i->i));
|
||||
list.forEach(item ->{
|
||||
CourseHRBPAudit audit = map.get(item.getId());
|
||||
if(audit != null){
|
||||
//暂时获取这两个字段,之后看是否需要调整
|
||||
item.setAuditUser(audit.getAuditUser());
|
||||
item.setAuditTime(audit.getAuditTime());
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,6 +406,12 @@ public class Course extends BaseEntity {
|
||||
@Transient
|
||||
private Boolean isTip;
|
||||
|
||||
@Transient
|
||||
private String auditUser;
|
||||
|
||||
@Transient
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
public Course(String id,String name,String summary,String coverImg,String sysCreateAid,String sysCreateBy,Integer type,LocalDateTime publishTime){
|
||||
super.setId(id);
|
||||
this.name=name;
|
||||
|
||||
@@ -57,4 +57,8 @@ public class CourseTeacher extends IdBaseEntity {
|
||||
@Transient
|
||||
private Integer teacherType;
|
||||
|
||||
/**讲师头像*/
|
||||
@Transient
|
||||
private String photo;
|
||||
|
||||
}
|
||||
|
||||
@@ -56,5 +56,7 @@ public interface ICourseHRBPAuditService {
|
||||
*/
|
||||
PageList<CourseHRBPAudit> pageList(Integer pageIndex, Integer pageSize,int userType, CourseHRBPAudit info);
|
||||
|
||||
List<CourseHRBPAudit> listByCourseIds(List<String> courseIdList);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -263,4 +263,8 @@ public class CourseHRBPAuditServiceImpl implements ICourseHRBPAuditService {
|
||||
return courseHRBPAuditDao.get(id);
|
||||
}
|
||||
|
||||
public List<CourseHRBPAudit> getByCourseIds(List<String> courseIdList){
|
||||
return courseHRBPAuditDao.findList(FieldFilters.in("courseId",courseIdList));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -221,6 +221,7 @@ public class StudyCourseApi extends ApiBaseController{
|
||||
ct.setRemark(t.getDescription());
|
||||
ct.setSupplier(t.getSupplier());
|
||||
ct.setTeacherType(t.getTeacherType());
|
||||
ct.setPhoto(t.getPhoto());
|
||||
}
|
||||
if(redisTemplate.opsForValue().get(ct.getTeacherId())==null){
|
||||
List<String>list=new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user