|
|
|
@ -36,27 +36,26 @@ public class UploadMaxKBFile {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//数据集ID
|
|
|
|
|
String dataSetId = list.getFirst().getStr("id");
|
|
|
|
|
String zskId = list.getFirst().getStr("id");
|
|
|
|
|
|
|
|
|
|
//在上传文档前,需要删除掉旧的同名文档
|
|
|
|
|
File fi = new File(uploadFile);
|
|
|
|
|
String fileName = fi.getName();
|
|
|
|
|
|
|
|
|
|
List<Record> listDocuments = mm.getDocumentListByDataSetId(dataSetId);
|
|
|
|
|
//获取身份识别
|
|
|
|
|
String authCode = MaxKbCallUtil.getAuthorization();
|
|
|
|
|
//上传文档
|
|
|
|
|
List<Record> listDocuments = mm.getDocumentListByDataSetId(zskId);
|
|
|
|
|
for (Record record : listDocuments) {
|
|
|
|
|
String documentName = record.getStr("name");
|
|
|
|
|
if (documentName.equals(fileName)) {
|
|
|
|
|
String documentId = record.getStr("id");
|
|
|
|
|
//准备删除掉旧的文档
|
|
|
|
|
|
|
|
|
|
//上传新的文档
|
|
|
|
|
MaxKbCallUtil.delDocument(authCode, zskId, documentId);
|
|
|
|
|
System.out.println("删除旧的文档成功:" + documentName);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//获取身份识别
|
|
|
|
|
// String authCode = MaxKbCallUtil.getAuthorization();
|
|
|
|
|
// //测试上传文件到知识库
|
|
|
|
|
// String id = MaxKbCallUtil.uploadQA(authCode, zskId, uploadFile);
|
|
|
|
|
// System.out.println("生成的文档ID=" + id);
|
|
|
|
|
//上传新的文档
|
|
|
|
|
MaxKbCallUtil.uploadQA(authCode, zskId, uploadFile);
|
|
|
|
|
System.out.println("恭喜,所有操作成功完成!");
|
|
|
|
|
}
|
|
|
|
|
}
|