|
|
|
@ -76,6 +76,7 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
|
try {
|
|
|
|
|
// 目前仅使用讯飞星火大模型
|
|
|
|
|
String appId = chatCommentsDto.getAppId();
|
|
|
|
|
// 获取模板文本
|
|
|
|
|
String text = commentsTemplate(chatCommentsDto);
|
|
|
|
|
if (!StringUtils.isEmpty(text)) {
|
|
|
|
|
chatCommentsDto.setText(text);
|
|
|
|
@ -300,232 +301,256 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private String commentsTemplate(ChatCommentsDto chatCommentsDto) {
|
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
|
String strData = JSON.toJSONString(chatCommentsDto.getData());
|
|
|
|
|
List<ChatModelDto> chatModels = new ArrayList<>();
|
|
|
|
|
ChatModelDto chatModel = null;
|
|
|
|
|
// 获取模型数据
|
|
|
|
|
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) {
|
|
|
|
|
//判断评语类型
|
|
|
|
|
if (chatCommentsDto.getType().equals(chatModelTemp.getType())) {
|
|
|
|
|
chatModel = chatModelTemp;
|
|
|
|
|
break;
|
|
|
|
|
StringBuilder builder = new StringBuilder();
|
|
|
|
|
String strData = JSON.toJSONString(chatCommentsDto.getData());
|
|
|
|
|
//检查是否角色
|
|
|
|
|
int phase = Math.max(chatCommentsDto.getPhase(), 0);
|
|
|
|
|
List<ChatModelDto> chatModels = new ArrayList<>();
|
|
|
|
|
ChatModelDto chatModel = null;
|
|
|
|
|
// 获取模型数据
|
|
|
|
|
chatModels = jsonLoader.myJsonDataBean();
|
|
|
|
|
//循环查找对应的模型数据
|
|
|
|
|
for (ChatModelDto chatModelTemp : chatModels) {
|
|
|
|
|
//判断评语类型
|
|
|
|
|
if (chatCommentsDto.getType().equals(chatModelTemp.getType())) {
|
|
|
|
|
chatModel = chatModelTemp;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String chatName = "";
|
|
|
|
|
switch(phase){
|
|
|
|
|
case 1:
|
|
|
|
|
if (chatCommentsDto.getName().contains("班") || chatCommentsDto.getName().contains("班级")) {
|
|
|
|
|
chatName = chatCommentsDto.getName();
|
|
|
|
|
} else {
|
|
|
|
|
chatName = chatCommentsDto.getName()+"班级";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
if (chatCommentsDto.getName().contains("年级")) {
|
|
|
|
|
chatName = chatCommentsDto.getName();
|
|
|
|
|
} else {
|
|
|
|
|
chatName = chatCommentsDto.getName()+"年级";
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
chatName = chatCommentsDto.getName()+"同学";
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (chatModel != null) {
|
|
|
|
|
//角色条件
|
|
|
|
|
builder.append(String.format(chatModel.getRole(), chatCommentsDto.getPeriod(), chatCommentsDto.getSubject()));
|
|
|
|
|
}
|
|
|
|
|
if (chatModel != null) {
|
|
|
|
|
//角色条件
|
|
|
|
|
builder.append(String.format(chatModel.getRole().get(0), chatCommentsDto.getPeriod(), chatCommentsDto.getSubject(), chatName));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ChatModelDto finalChatModel = chatModel;
|
|
|
|
|
//模版
|
|
|
|
|
switch (chatCommentsDto.getType()) {
|
|
|
|
|
//智育 总体评语模版
|
|
|
|
|
case "wisdom": {
|
|
|
|
|
WisdomCommentsDto wisdomComments;
|
|
|
|
|
//转换问题
|
|
|
|
|
try {
|
|
|
|
|
//转换方式
|
|
|
|
|
wisdomComments = JSON.parseObject(strData, WisdomCommentsDto.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "类型转换失败");
|
|
|
|
|
}
|
|
|
|
|
if (wisdomComments.getName() == null) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
ChatModelDto finalChatModel = chatModel;
|
|
|
|
|
//模版
|
|
|
|
|
switch (chatCommentsDto.getType()) {
|
|
|
|
|
//智育 总体评语模版
|
|
|
|
|
case "wisdom": {
|
|
|
|
|
WisdomCommentsDto wisdomComments;
|
|
|
|
|
//转换问题
|
|
|
|
|
try {
|
|
|
|
|
//转换方式
|
|
|
|
|
wisdomComments = JSON.parseObject(strData, WisdomCommentsDto.class);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "类型转换失败");
|
|
|
|
|
}
|
|
|
|
|
if (wisdomComments.getName() == null) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 使用String.format方法生成最终的字符串
|
|
|
|
|
builder.append(String.format(
|
|
|
|
|
finalChatModel.getChat(),
|
|
|
|
|
wisdomComments.getName(),
|
|
|
|
|
wisdomComments.getYear(),
|
|
|
|
|
wisdomComments.getSemester(),
|
|
|
|
|
wisdomComments.getJoinAll(),
|
|
|
|
|
wisdomComments.getLessonMiddle(),
|
|
|
|
|
wisdomComments.getOnLine(),
|
|
|
|
|
wisdomComments.getMarking(),
|
|
|
|
|
wisdomComments.getLevel(),
|
|
|
|
|
wisdomComments.getProportion(),
|
|
|
|
|
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 -> {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0),
|
|
|
|
|
item.name,
|
|
|
|
|
item.data[0],
|
|
|
|
|
item.data[1],
|
|
|
|
|
item.data[2],
|
|
|
|
|
item.data[3],
|
|
|
|
|
item.data[4]
|
|
|
|
|
String chat = phase > 0 ? finalChatModel.getChat().get(1) : finalChatModel.getChat().get(0);
|
|
|
|
|
String cycleChat = finalChatModel.getCycleChats().get(0);
|
|
|
|
|
|
|
|
|
|
// 使用String.format方法生成最终的字符串
|
|
|
|
|
builder.append(String.format(
|
|
|
|
|
chat,
|
|
|
|
|
chatCommentsDto.getName(),
|
|
|
|
|
wisdomComments.getYear(),
|
|
|
|
|
wisdomComments.getSemester(),
|
|
|
|
|
wisdomComments.getJoinAll(),
|
|
|
|
|
wisdomComments.getLessonMiddle(),
|
|
|
|
|
wisdomComments.getOnLine(),
|
|
|
|
|
wisdomComments.getMarking(),
|
|
|
|
|
wisdomComments.getLevel(),
|
|
|
|
|
wisdomComments.getProportion(),
|
|
|
|
|
wisdomComments.getName()
|
|
|
|
|
));
|
|
|
|
|
});
|
|
|
|
|
builder.append(String.format(finalChatModel.getEnd(), wisdomComments.getName()));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//智育 表现模版
|
|
|
|
|
case "wisdomExam": {
|
|
|
|
|
List<WisdomExamCommentsDto> examComments = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
examComments = JSON.parseObject(strData, new TypeReference<List<WisdomExamCommentsDto>>() {
|
|
|
|
|
wisdomComments.getDims().forEach(item -> {
|
|
|
|
|
if(item.data.length >= 4)
|
|
|
|
|
{
|
|
|
|
|
builder.append(String.format(cycleChat,
|
|
|
|
|
item.name,
|
|
|
|
|
item.data[0],
|
|
|
|
|
item.data[1],
|
|
|
|
|
item.data[2],
|
|
|
|
|
item.data[3],
|
|
|
|
|
item.data[4]
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "类型转换失败");
|
|
|
|
|
//builder.append(String.format(finalChatModel.getEnd().get(0),chatName, wisdomComments.getDims().size()));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (examComments.size() <= 1) {
|
|
|
|
|
if (examComments.isEmpty()) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
//智育 表现模版
|
|
|
|
|
case "wisdomExam": {
|
|
|
|
|
List<WisdomExamCommentsDto> examComments = new ArrayList<>();
|
|
|
|
|
try {
|
|
|
|
|
examComments = JSON.parseObject(strData, new TypeReference<List<WisdomExamCommentsDto>>() {
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "类型转换失败");
|
|
|
|
|
}
|
|
|
|
|
if (examComments.get(0).name == null) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
if (examComments.size() <= 1) {
|
|
|
|
|
if (examComments.isEmpty()) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
if (examComments.get(0).name == null) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
int count = 1;
|
|
|
|
|
for (WisdomExamCommentsDto examComment : examComments) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), count, examComment.getName(),
|
|
|
|
|
examComment.getTime(), examComment.getScore(), examComment.getScoreRate(),
|
|
|
|
|
examComment.getRanking()));
|
|
|
|
|
if (count < examComments.size()) {
|
|
|
|
|
count++;
|
|
|
|
|
int count = 1;
|
|
|
|
|
if(finalChatModel.getChat() != null && !chatCommentsDto.getName().isEmpty()){
|
|
|
|
|
//昵称
|
|
|
|
|
builder.append(String.format(finalChatModel.getChat().get(0), chatCommentsDto.getName()));
|
|
|
|
|
}
|
|
|
|
|
switch(phase){
|
|
|
|
|
case 1:{
|
|
|
|
|
for (WisdomExamCommentsDto examComment : examComments) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(1), count, examComment.getName(),examComment.getTime(), examComment.getClassRate(),examComment.getGradeRate()));
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case 2:{
|
|
|
|
|
for (WisdomExamCommentsDto examComment : examComments) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(2), count, examComment.getName(),examComment.getTime(), examComment.getGradeRate()));
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:{
|
|
|
|
|
for (WisdomExamCommentsDto examComment : examComments) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), count, examComment.getName(),examComment.getTime(), examComment.getScore(), examComment.getScoreRate(),examComment.getRanking()));
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
builder.append(String.format(finalChatModel.getEnd(), count));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
// 智育 学科评语模版
|
|
|
|
|
case "windomSubject": {
|
|
|
|
|
List<WisdomSubjectComments> subjectComments;
|
|
|
|
|
try {
|
|
|
|
|
subjectComments = JSON.parseObject(strData, new TypeReference<List<WisdomSubjectComments>>() {
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
if (subjectComments.size() <= 1) {
|
|
|
|
|
// 智育 学科评语模版
|
|
|
|
|
case "wisdomSubject": {
|
|
|
|
|
List<WisdomSubjectComments> subjectComments;
|
|
|
|
|
try {
|
|
|
|
|
subjectComments = JSON.parseObject(strData, new TypeReference<List<WisdomSubjectComments>>() {});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
if (subjectComments.isEmpty()) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
builder.append(finalChatModel.getChat());
|
|
|
|
|
String name = "";
|
|
|
|
|
//拼接学科数组
|
|
|
|
|
for (WisdomSubjectComments comments : subjectComments) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), comments.subjectName));
|
|
|
|
|
for (WisdomSubjectComments.StuInfo stuInfo : comments.getRankings()) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(1), stuInfo.ranking,stuInfo.name, stuInfo.scoreRate*100));
|
|
|
|
|
if(finalChatModel.getChat() != null && !chatCommentsDto.getName().isEmpty()){
|
|
|
|
|
builder.append(String.format(finalChatModel.getChat().get(1), chatCommentsDto.getName()));
|
|
|
|
|
}
|
|
|
|
|
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.getEnd(), subjectComments.size(),name));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//艺术 考核指标纬度评语
|
|
|
|
|
case "artLatitude":{
|
|
|
|
|
List<ArtLatitudeDto> artLatitudes;
|
|
|
|
|
try {
|
|
|
|
|
artLatitudes = JSON.parseObject(strData, new TypeReference<List<ArtLatitudeDto>>() {
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
else {
|
|
|
|
|
if (finalChatModel.getChat() != null) {
|
|
|
|
|
builder.append(finalChatModel.getChat().get(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String name = "";
|
|
|
|
|
//拼接学科数组
|
|
|
|
|
for (WisdomSubjectComments comments : subjectComments) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), comments.subjectName));
|
|
|
|
|
for (WisdomSubjectComments.StuInfo stuInfo : comments.getRankings()) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(1), stuInfo.ranking,stuInfo.name, stuInfo.scoreRate*100));
|
|
|
|
|
}
|
|
|
|
|
if (phase == 0) {
|
|
|
|
|
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.getEnd().get(0), subjectComments.size(),chatName));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (artLatitudes.size() <= 1) {
|
|
|
|
|
if (artLatitudes.isEmpty()) {
|
|
|
|
|
//艺术 考核指标纬度评语
|
|
|
|
|
case "artLatitude":{
|
|
|
|
|
List<ArtLatitudeDto> artLatitudes;
|
|
|
|
|
try {
|
|
|
|
|
artLatitudes = JSON.parseObject(strData, new TypeReference<List<ArtLatitudeDto>>() {
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
builder.append(finalChatModel.getChat());
|
|
|
|
|
for (ArtLatitudeDto artLatitude : artLatitudes)
|
|
|
|
|
{
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), artLatitude.getQuotaN1(),artLatitude.getQuotaP1(), artLatitude.getQuotaN2(),artLatitude.getQuotaP2(), artLatitude.getQuotaN3(),artLatitude.getQuotaP3(), artLatitude.getPercent(),artLatitude.getLevel()));
|
|
|
|
|
}
|
|
|
|
|
if (artLatitudes.size() <= 1) {
|
|
|
|
|
if (artLatitudes.isEmpty()) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(finalChatModel.getChat() != null && !chatCommentsDto.getName().isEmpty()) {
|
|
|
|
|
builder.append(String.format(finalChatModel.getChat().get(1), chatCommentsDto.getName()));
|
|
|
|
|
}else {
|
|
|
|
|
if (finalChatModel.getChat() != null) {
|
|
|
|
|
builder.append(finalChatModel.getChat().get(0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (ArtLatitudeDto artLatitude : artLatitudes){
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), artLatitude.getQuotaN1(),artLatitude.getQuotaP1(), artLatitude.getQuotaN2(),artLatitude.getQuotaP2(), artLatitude.getQuotaN3(),artLatitude.getQuotaP3(), artLatitude.getPercent(),artLatitude.getLevel()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.append(finalChatModel.getEnd());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//艺术 学科评语模版
|
|
|
|
|
case "artSubject":{
|
|
|
|
|
List<ArtSubjectDto> artSubjects;
|
|
|
|
|
try {
|
|
|
|
|
artSubjects = JSON.parseObject(strData, new TypeReference<List<ArtSubjectDto>>() {
|
|
|
|
|
});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
//builder.append(String.format(finalChatModel.getEnd().get(0),chatName));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (artSubjects.size() <= 1) {
|
|
|
|
|
if (artSubjects.isEmpty()) {
|
|
|
|
|
//艺术 学科评语模版
|
|
|
|
|
case "artSubject":{
|
|
|
|
|
List<ArtSubjectDto> artSubjects;
|
|
|
|
|
try {
|
|
|
|
|
artSubjects = JSON.parseObject(strData, new TypeReference<List<ArtSubjectDto>>() {});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
if (artSubjects.size() <= 1) {
|
|
|
|
|
if (artSubjects.isEmpty()) {
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "请求参数异常");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
builder.append(String.format(finalChatModel.getChat().get(0), chatCommentsDto.getSubject()));
|
|
|
|
|
for (ArtSubjectDto artSubject : artSubjects){
|
|
|
|
|
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().get(0),chatName));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
builder.append(finalChatModel.getChat());
|
|
|
|
|
for (ArtSubjectDto artSubject : artSubjects){
|
|
|
|
|
builder.append(String.format(finalChatModel.getCycleChats().get(0), artSubject.getDimension(),artSubject.getBlock(), artSubject.getPoint(),artSubject.getScore(), artSubject.getTotalScore(),artSubject.getPercent()));
|
|
|
|
|
//体育
|
|
|
|
|
case "sport":{
|
|
|
|
|
builder.append("请按照以下格式回复:\n");
|
|
|
|
|
builder.append("1. 运动作品:\n");
|
|
|
|
|
builder.append("2. 运动作品说明:\n");
|
|
|
|
|
builder.append("3. 运动作品示例:\n");
|
|
|
|
|
builder.append("4. 运动作品示例说明:\n");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
builder.append(String.format(finalChatModel.getEnd(),chatCommentsDto.getSubject()));
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
//体育
|
|
|
|
|
case "sport":{
|
|
|
|
|
builder.append("请按照以下格式回复:\n");
|
|
|
|
|
builder.append("1. 运动作品:\n");
|
|
|
|
|
builder.append("2. 运动作品说明:\n");
|
|
|
|
|
builder.append("3. 运动作品示例:\n");
|
|
|
|
|
builder.append("4. 运动作品示例说明:\n");
|
|
|
|
|
break;
|
|
|
|
|
//德育
|
|
|
|
|
case "moral":{
|
|
|
|
|
builder.append(finalChatModel.getChat());
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "评语类型异常");
|
|
|
|
|
}
|
|
|
|
|
//德育
|
|
|
|
|
case "moral":{
|
|
|
|
|
builder.append(finalChatModel.getChat());
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
throw new ServiceException(ErrorCode.PARAMS_ERROR.getCode(), "评语类型异常");
|
|
|
|
|
}
|
|
|
|
|
String limitChat = "。限制条件如下:1.%s字左右;2.直接返回评价的内容;3.评价开头不要提示语;4.评价开头不允许出现特殊字符。";
|
|
|
|
|
int size = chatCommentsDto.getSize() > 0 ? chatCommentsDto.getSize() : 200;
|
|
|
|
|
builder.append(String.format(limitChat, size));
|
|
|
|
|
|
|
|
|
|
if (chatCommentsDto.getSize() > 0) {
|
|
|
|
|
builder.append("字数限制在:")
|
|
|
|
|
.append(chatCommentsDto.getSize())
|
|
|
|
|
.append("字左右");
|
|
|
|
|
} else {
|
|
|
|
|
builder.append("字数限制在:200字左右");
|
|
|
|
|
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()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return builder.toString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|