|
|
@ -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 str = JSON.parseObject(fileText).get("chatModel");
|
|
|
|
Object obj = JSON.parseObject(jsonData).get("chatModel");
|
|
|
|
String strData1 = JSON.toJSONString(str);
|
|
|
|
String jsonData01 = JSON.toJSONString(obj);
|
|
|
|
//转换方式
|
|
|
|
//转换方式
|
|
|
|
chatModels = JSON.parseObject(strData1, new TypeReference<List<ChatModelDto>>() { });
|
|
|
|
chatModels = JSON.parseObject(jsonData01, new TypeReference<List<ChatModelDto>>() {});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log.info("获取地址fileText:"+fileText+"----文件内容Data:"+ jsonData +"----获取模型集合Object:" + obj +"----获取模型集合String:"+ jsonData01 +"----获取模型集合机构:"+chatModels);
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "类型转换失败");
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件" + Arrays.toString(e.getStackTrace()) + e.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*try {
|
|
|
|
|
|
|
|
//File file = null;
|
|
|
|
//chatModels = readResourceFile("Json/ChatModel.json");
|
|
|
|
//chatModels = readResourceFile("Json/ChatModel.json");
|
|
|
|
//String str = readResourceFile("Json/ChatModel.json");
|
|
|
|
|
|
|
|
//file = new File(ClassLoader.getSystemResource("Json/ChatModel.json").getPath()); //相对路径获取文件信息
|
|
|
|
//file = new File(ClassLoader.getSystemResource("Json/ChatModel.json").getPath()); //相对路径获取文件信息
|
|
|
|
//File file = new File("src/main/resources/Json/ChatModel.json"); //绝对路径获取文件信息
|
|
|
|
//File file = new File("src/main/resources/Json/ChatModel.json"); //绝对路径获取文件信息
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
throw new ServiceException(ErrorCode.OPERATION_ERROR.getCode(), "读取文件" + Arrays.toString(e.getStackTrace()) + e.getMessage());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/*try {
|
|
|
|
|
|
|
|
//chatModel = readerMethod(file);
|
|
|
|
|
|
|
|
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;
|
|
|
|