|
|
@ -312,30 +312,25 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
ChatModelDto chatModel = null;
|
|
|
|
ChatModelDto chatModel = null;
|
|
|
|
|
|
|
|
|
|
|
|
//验证获取模型数据 异常问题
|
|
|
|
//验证获取模型数据 异常问题
|
|
|
|
File file = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
String fileText = FileUtil.getFileText("Json/ChatModel.json");
|
|
|
|
String fileText = FileUtil.getFileText("Json/ChatModel.json");
|
|
|
|
//转换问题
|
|
|
|
String jsonData = JSON.toJSONString(fileText);
|
|
|
|
try {
|
|
|
|
//获取聊天字段中的数据
|
|
|
|
//String strData01 = JSON.toJSONString(fileText);
|
|
|
|
Object obj = JSON.parseObject(jsonData).get("chatModel");
|
|
|
|
//获取聊天字段中的数据
|
|
|
|
String jsonData01 = JSON.toJSONString(obj);
|
|
|
|
Object str = JSON.parseObject(fileText).get("chatModel");
|
|
|
|
//转换方式
|
|
|
|
String strData1 = JSON.toJSONString(str);
|
|
|
|
chatModels = JSON.parseObject(jsonData01, new TypeReference<List<ChatModelDto>>() {});
|
|
|
|
//转换方式
|
|
|
|
|
|
|
|
chatModels = JSON.parseObject(strData1, new TypeReference<List<ChatModelDto>>() { });
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "类型转换失败");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//chatModels = readResourceFile("Json/ChatModel.json");
|
|
|
|
log.info("获取地址fileText:"+fileText+"----文件内容Data:"+ jsonData +"----获取模型集合Object:" + obj +"----获取模型集合String:"+ jsonData01 +"----获取模型集合机构:"+chatModels);
|
|
|
|
//String str = readResourceFile("Json/ChatModel.json");
|
|
|
|
|
|
|
|
//file = new File(ClassLoader.getSystemResource("Json/ChatModel.json").getPath()); //相对路径获取文件信息
|
|
|
|
|
|
|
|
//File file = new File("src/main/resources/Json/ChatModel.json"); //绝对路径获取文件信息
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件" + Arrays.toString(e.getStackTrace()) + e.getMessage());
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件" + Arrays.toString(e.getStackTrace()) + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*try {
|
|
|
|
/*try {
|
|
|
|
//chatModel = readerMethod(file);
|
|
|
|
//File file = null;
|
|
|
|
|
|
|
|
//chatModels = readResourceFile("Json/ChatModel.json");
|
|
|
|
|
|
|
|
//file = new File(ClassLoader.getSystemResource("Json/ChatModel.json").getPath()); //相对路径获取文件信息
|
|
|
|
|
|
|
|
//File file = new File("src/main/resources/Json/ChatModel.json"); //绝对路径获取文件信息
|
|
|
|
chatModels = readerMethod(file);
|
|
|
|
chatModels = readerMethod(file);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件并转换实体类" + Arrays.toString(e.getStackTrace()));
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件并转换实体类" + Arrays.toString(e.getStackTrace()));
|
|
|
@ -352,8 +347,7 @@ public class ChatMessageServiceImpl implements ChatMessageService {
|
|
|
|
|
|
|
|
|
|
|
|
if (chatModel != null) {
|
|
|
|
if (chatModel != null) {
|
|
|
|
//角色条件
|
|
|
|
//角色条件
|
|
|
|
builder.append(String.format(chatModel.getRole(), chatCommentsDto.getPeriod(),
|
|
|
|
builder.append(String.format(chatModel.getRole(), chatCommentsDto.getPeriod(), chatCommentsDto.getSubject()));
|
|
|
|
chatCommentsDto.getSubject()));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ChatModelDto finalChatModel = chatModel;
|
|
|
|
ChatModelDto finalChatModel = chatModel;
|
|
|
|