|
|
@ -76,6 +76,7 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// 目前仅使用讯飞星火大模型
|
|
|
|
// 目前仅使用讯飞星火大模型
|
|
|
|
String appId = chatCommentsDto.getAppId();
|
|
|
|
String appId = chatCommentsDto.getAppId();
|
|
|
|
|
|
|
|
// 获取模板文本
|
|
|
|
String text = commentsTemplate(chatCommentsDto);
|
|
|
|
String text = commentsTemplate(chatCommentsDto);
|
|
|
|
if (!StringUtils.isEmpty(text)) {
|
|
|
|
if (!StringUtils.isEmpty(text)) {
|
|
|
|
chatCommentsDto.setText(text);
|
|
|
|
chatCommentsDto.setText(text);
|
|
|
@ -300,29 +301,15 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private String commentsTemplate(ChatCommentsDto chatCommentsDto) {
|
|
|
|
private String commentsTemplate(ChatCommentsDto chatCommentsDto) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
String strData = JSON.toJSONString(chatCommentsDto.getData());
|
|
|
|
String strData = JSON.toJSONString(chatCommentsDto.getData());
|
|
|
|
|
|
|
|
//检查是否角色
|
|
|
|
|
|
|
|
int phase = Math.max(chatCommentsDto.getPhase(), 0);
|
|
|
|
List<ChatModelDto> chatModels = new ArrayList<>();
|
|
|
|
List<ChatModelDto> chatModels = new ArrayList<>();
|
|
|
|
ChatModelDto chatModel = null;
|
|
|
|
ChatModelDto chatModel = null;
|
|
|
|
// 获取模型数据
|
|
|
|
// 获取模型数据
|
|
|
|
chatModels = jsonLoader.myJsonDataBean();
|
|
|
|
chatModels = jsonLoader.myJsonDataBean();
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
//验证获取模型数据 异常问题
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
String fileText = FileUtil.getFileText("Json/ChatModel.json");
|
|
|
|
|
|
|
|
String jsonData = JSON.toJSONString(fileText);
|
|
|
|
|
|
|
|
//获取聊天字段中的数据
|
|
|
|
|
|
|
|
Object obj = JSON.parseObject(jsonData).get("chatModel");
|
|
|
|
|
|
|
|
String jsonData01 = JSON.toJSONString(obj);
|
|
|
|
|
|
|
|
//转换方式
|
|
|
|
|
|
|
|
chatModels = JSON.parseObject(jsonData01, new TypeReference<List<ChatModelDto>>() {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("获取地址fileText:"+fileText+"----文件内容Data:"+ jsonData +"----获取模型集合Object:" + obj +"----获取模型集合String:"+ jsonData01 +"----获取模型集合机构:"+chatModels);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件" + Arrays.toString(e.getStackTrace()) + e.getMessage());
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//循环查找对应的模型数据
|
|
|
|
//循环查找对应的模型数据
|
|
|
|
for (ChatModelDto chatModelTemp : chatModels) {
|
|
|
|
for (ChatModelDto chatModelTemp : chatModels) {
|
|
|
|
//判断评语类型
|
|
|
|
//判断评语类型
|
|
|
@ -333,8 +320,16 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (chatModel != null) {
|
|
|
|
if (chatModel != null) {
|
|
|
|
|
|
|
|
String role = "";
|
|
|
|
|
|
|
|
if (phase > 2){
|
|
|
|
|
|
|
|
role = chatModel.getRole().get(0);
|
|
|
|
|
|
|
|
}else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
role = chatModel.getRole().get(1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//角色条件
|
|
|
|
//角色条件
|
|
|
|
builder.append(String.format(chatModel.getRole(), chatCommentsDto.getPeriod(), chatCommentsDto.getSubject()));
|
|
|
|
builder.append(String.format(chatModel.getRole().get(phase), chatCommentsDto.getPeriod(), chatCommentsDto.getSubject()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChatModelDto finalChatModel = chatModel;
|
|
|
|
ChatModelDto finalChatModel = chatModel;
|
|
|
@ -354,9 +349,12 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String chat = phase > 0 ? finalChatModel.getChat().get(1) : finalChatModel.getChat().get(0);
|
|
|
|
|
|
|
|
String cycleChat = finalChatModel.getCycleChats().get(0);
|
|
|
|
|
|
|
|
|
|
|
|
// 使用String.format方法生成最终的字符串
|
|
|
|
// 使用String.format方法生成最终的字符串
|
|
|
|
builder.append(String.format(
|
|
|
|
builder.append(String.format(
|
|
|
|
finalChatModel.getChat(),
|
|
|
|
chat,
|
|
|
|
wisdomComments.getName(),
|
|
|
|
wisdomComments.getName(),
|
|
|
|
wisdomComments.getYear(),
|
|
|
|
wisdomComments.getYear(),
|
|
|
|
wisdomComments.getSemester(),
|
|
|
|
wisdomComments.getSemester(),
|
|
|
@ -368,24 +366,10 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
wisdomComments.getProportion(),
|
|
|
|
wisdomComments.getProportion(),
|
|
|
|
wisdomComments.getName()
|
|
|
|
wisdomComments.getName()
|
|
|
|
));
|
|
|
|
));
|
|
|
|
/*
|
|
|
|
|
|
|
|
//有平均分
|
|
|
|
|
|
|
|
builder.append(String.format(
|
|
|
|
|
|
|
|
finalChatModel.getChat(),
|
|
|
|
|
|
|
|
wisdomComments.getName(),
|
|
|
|
|
|
|
|
wisdomComments.getYear(),
|
|
|
|
|
|
|
|
wisdomComments.getSemester(),
|
|
|
|
|
|
|
|
wisdomComments.getJoinAll(),
|
|
|
|
|
|
|
|
wisdomComments.getLessonMiddle(),
|
|
|
|
|
|
|
|
wisdomComments.getOnLine(),
|
|
|
|
|
|
|
|
wisdomComments.getMarking(),
|
|
|
|
|
|
|
|
wisdomComments.getAverage(),
|
|
|
|
|
|
|
|
wisdomComments.getLevel(),
|
|
|
|
|
|
|
|
wisdomComments.getProportion(),
|
|
|
|
|
|
|
|
wisdomComments.getName()
|
|
|
|
|
|
|
|
));*/
|
|
|
|
|
|
|
|
wisdomComments.getDims().forEach(item -> {
|
|
|
|
wisdomComments.getDims().forEach(item -> {
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0),
|
|
|
|
if(item.data.length >= 4)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
builder.append(String.format(cycleChat,
|
|
|
|
item.name,
|
|
|
|
item.name,
|
|
|
|
item.data[0],
|
|
|
|
item.data[0],
|
|
|
|
item.data[1],
|
|
|
|
item.data[1],
|
|
|
@ -393,8 +377,9 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
item.data[3],
|
|
|
|
item.data[3],
|
|
|
|
item.data[4]
|
|
|
|
item.data[4]
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
builder.append(String.format(finalChatModel.getEnd(), wisdomComments.getName()));
|
|
|
|
builder.append(String.format(finalChatModel.getEnd().get(0), wisdomComments.getDims().size()));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//智育 表现模版
|
|
|
|
//智育 表现模版
|
|
|
@ -423,11 +408,11 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
builder.append(String.format(finalChatModel.getEnd(), count));
|
|
|
|
builder.append(String.format(finalChatModel.getEnd().get(0), count));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// 智育 学科评语模版
|
|
|
|
// 智育 学科评语模版
|
|
|
|
case "windomSubject": {
|
|
|
|
case "wisdomSubject": {
|
|
|
|
List<WisdomSubjectComments> subjectComments;
|
|
|
|
List<WisdomSubjectComments> subjectComments;
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
subjectComments = JSON.parseObject(strData, new TypeReference<List<WisdomSubjectComments>>() {
|
|
|
|
subjectComments = JSON.parseObject(strData, new TypeReference<List<WisdomSubjectComments>>() {
|
|
|
@ -435,11 +420,9 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (subjectComments.size() <= 1) {
|
|
|
|
|
|
|
|
if (subjectComments.isEmpty()) {
|
|
|
|
if (subjectComments.isEmpty()) {
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
builder.append(finalChatModel.getChat());
|
|
|
|
builder.append(finalChatModel.getChat());
|
|
|
|
String name = "";
|
|
|
|
String name = "";
|
|
|
|
//拼接学科数组
|
|
|
|
//拼接学科数组
|
|
|
@ -448,10 +431,12 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
for (WisdomSubjectComments.StuInfo stuInfo : comments.getRankings()) {
|
|
|
|
for (WisdomSubjectComments.StuInfo stuInfo : comments.getRankings()) {
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(1), stuInfo.ranking,stuInfo.name, stuInfo.scoreRate*100));
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(1), stuInfo.ranking,stuInfo.name, stuInfo.scoreRate*100));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (phase == 0) {
|
|
|
|
name = comments.getClaasRanking().name;
|
|
|
|
name = comments.getClaasRanking().name;
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(2),name,comments.getClaasRanking().ranking, comments.getClaasRanking().scoreRate * 100,comments.getClaasRanking().average * 100));
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(2), name, comments.getClaasRanking().ranking, comments.getClaasRanking().scoreRate * 100, comments.getClaasRanking().average * 100));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
builder.append(String.format(finalChatModel.getEnd(), subjectComments.size(),name));
|
|
|
|
builder.append(String.format(finalChatModel.getEnd().get(0), subjectComments.size(),name));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//艺术 考核指标纬度评语
|
|
|
|
//艺术 考核指标纬度评语
|
|
|
@ -496,7 +481,7 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), artSubject.getDimension(),artSubject.getBlock(), artSubject.getPoint(),artSubject.getScore(), artSubject.getTotalScore(),artSubject.getPercent()));
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), artSubject.getDimension(),artSubject.getBlock(), artSubject.getPoint(),artSubject.getScore(), artSubject.getTotalScore(),artSubject.getPercent()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
builder.append(String.format(finalChatModel.getEnd(),chatCommentsDto.getSubject()));
|
|
|
|
builder.append(String.format(finalChatModel.getEnd().get(0),chatCommentsDto.getSubject()));
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//体育
|
|
|
|
//体育
|
|
|
@ -519,13 +504,17 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (chatCommentsDto.getSize() > 0) {
|
|
|
|
if (chatCommentsDto.getSize() > 0) {
|
|
|
|
builder.append("字数限制在:")
|
|
|
|
builder.append("限制条件:")
|
|
|
|
.append(chatCommentsDto.getSize())
|
|
|
|
.append(chatCommentsDto.getSize())
|
|
|
|
.append("字左右");
|
|
|
|
.append("字左右;【返回评语内容#不要开头提示语#】。");
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
builder.append("字数限制在:200字左右");
|
|
|
|
builder.append("字数限制在:200字左右;【#返回评语内容#,#不要内容提示语#】。");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return builder.toString();
|
|
|
|
return builder.toString();
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
log.info(Arrays.toString(e.getStackTrace()));
|
|
|
|
|
|
|
|
log.error("{}-{}", e.getMessage(), Arrays.toString(e.getStackTrace()));
|
|
|
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), Arrays.toString(e.getStackTrace()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|