提交修改
This commit is contained in:
parent
7823246636
commit
916f9f079e
@ -56,15 +56,8 @@ public abstract class BaiduBaseHandle<P, Result> {
|
|||||||
if (content.startsWith("&")) {
|
if (content.startsWith("&")) {
|
||||||
content = content.substring(1);
|
content = content.substring(1);
|
||||||
}
|
}
|
||||||
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
|
||||||
// image 可以通过 方法获取,如果Content-Type是application/x-www-form-urlencoded时,第二个参数传true
|
Request request = createRequest(content);
|
||||||
RequestBody body = RequestBody.create(mediaType, content);
|
|
||||||
Request request = new Request.Builder()
|
|
||||||
.url("https://aip.baidubce.com/" + getUri() + "?access_token=" + getBaiduAccessToken())
|
|
||||||
.method("POST", body)
|
|
||||||
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
|
||||||
.addHeader("Accept", "application/json")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
Response response = HTTP_CLIENT.newCall(request).execute();
|
Response response = HTTP_CLIENT.newCall(request).execute();
|
||||||
result = response.body().string();
|
result = response.body().string();
|
||||||
@ -73,8 +66,6 @@ public abstract class BaiduBaseHandle<P, Result> {
|
|||||||
return ApiR.setData(resp);
|
return ApiR.setData(resp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Class clazz = this.getClass();
|
Class clazz = this.getClass();
|
||||||
//getGenericSuperclass()获得带有泛型的父类
|
//getGenericSuperclass()获得带有泛型的父类
|
||||||
//Type是 Java 编程语言中所有类型的公共高级接口。它们包括原始类型、参数化类型、数组类型、类型变量和基本类型。
|
//Type是 Java 编程语言中所有类型的公共高级接口。它们包括原始类型、参数化类型、数组类型、类型变量和基本类型。
|
||||||
@ -98,6 +89,24 @@ public abstract class BaiduBaseHandle<P, Result> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* 创建create
|
||||||
|
* @param content
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Request createRequest(String content){
|
||||||
|
MediaType mediaType = MediaType.parse("application/x-www-form-urlencoded");
|
||||||
|
// image 可以通过 方法获取,如果Content-Type是application/x-www-form-urlencoded时,第二个参数传true
|
||||||
|
RequestBody body = RequestBody.create(mediaType, content);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("https://aip.baidubce.com/" + getUri() + "?access_token=" + getBaiduAccessToken())
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Content-Type", "application/x-www-form-urlencoded")
|
||||||
|
.addHeader("Accept", "application/json")
|
||||||
|
.build();
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从用户的AK,SK生成鉴权签名(Access Token)
|
* 从用户的AK,SK生成鉴权签名(Access Token)
|
||||||
*
|
*
|
||||||
|
|||||||
@ -1,12 +1,20 @@
|
|||||||
package com.heyu.api.baidu.handle.convert;
|
package com.heyu.api.baidu.handle.convert;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.heyu.api.data.utils.StringUtils;
|
|
||||||
import com.heyu.api.baidu.BaiduBaseHandle;
|
import com.heyu.api.baidu.BaiduBaseHandle;
|
||||||
import com.heyu.api.baidu.request.convert.BTextreviewRequest;
|
import com.heyu.api.baidu.request.convert.BTextreviewRequest;
|
||||||
import com.heyu.api.baidu.response.convert.BTextreviewResp;
|
import com.heyu.api.baidu.response.convert.BTextreviewResp;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import com.heyu.api.data.utils.SpringContextUtils;
|
||||||
|
import com.heyu.api.data.utils.StringUtils;
|
||||||
|
import com.heyu.api.oss.OssFileUploadService;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.MultipartBody;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@ -19,6 +27,7 @@ import java.util.Map;
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
|
@Slf4j
|
||||||
public class BTextreviewHandle extends BaiduBaseHandle<BTextreviewRequest, BTextreviewResp> {
|
public class BTextreviewHandle extends BaiduBaseHandle<BTextreviewRequest, BTextreviewResp> {
|
||||||
|
|
||||||
public static Map<String, Object> suport = Maps.newHashMap();
|
public static Map<String, Object> suport = Maps.newHashMap();
|
||||||
@ -74,10 +83,33 @@ public class BTextreviewHandle extends BaiduBaseHandle<BTextreviewRequest, BText
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String check(BTextreviewRequest bTextreviewRequest) {
|
public String check(BTextreviewRequest bTextreviewRequest) {
|
||||||
if (CollectionUtils.isEmpty(bTextreviewRequest.getFileURLList())
|
if (StringUtils.isBlank(bTextreviewRequest.getFileURL())
|
||||||
&& bTextreviewRequest.getFile() == null) {
|
&& bTextreviewRequest.getFileBase64() == null) {
|
||||||
return "fileURLList 和file 不能同时为空 ";
|
return "fileURL 和file 不能同时为空 ";
|
||||||
}
|
}
|
||||||
|
if(StringUtils.isNotBlank(bTextreviewRequest.getFileBase64())){
|
||||||
|
OssFileUploadService ossFileUploadService = SpringContextUtils.getBean(OssFileUploadService.class);
|
||||||
|
|
||||||
|
//下面对图片大小,格式做判断是否符合要求,不符合要求直接返回提示
|
||||||
|
String base64;
|
||||||
|
if (bTextreviewRequest.getFileBase64().startsWith("data")) {
|
||||||
|
base64 = bTextreviewRequest.getFileBase64().substring(bTextreviewRequest.getFileBase64().indexOf("base64,") + 7);
|
||||||
|
} else {
|
||||||
|
base64 = bTextreviewRequest.getFileBase64();
|
||||||
|
}
|
||||||
|
if (!base64.startsWith("/9j/")) {
|
||||||
|
log.info("图片格式错误,只支持jpg格式");
|
||||||
|
return "图片格式错误,只支持jpg格式";
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = ossFileUploadService.uploadFileContentByBase64(bTextreviewRequest.getFileBase64(), "jpg");
|
||||||
|
if (StringUtils.isBlank(url)) {
|
||||||
|
log.error(" oss file upload is null");
|
||||||
|
return "你的base64内容有误";
|
||||||
|
}
|
||||||
|
bTextreviewRequest.setFileURL(url);
|
||||||
|
}
|
||||||
|
|
||||||
if (!suport.containsKey(bTextreviewRequest.getTemplateName())) {
|
if (!suport.containsKey(bTextreviewRequest.getTemplateName())) {
|
||||||
return " templateName 必须为 " + StringUtils.printMap(suport);
|
return " templateName 必须为 " + StringUtils.printMap(suport);
|
||||||
}
|
}
|
||||||
@ -87,11 +119,28 @@ public class BTextreviewHandle extends BaiduBaseHandle<BTextreviewRequest, BText
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Request createRequest(String content) {
|
||||||
|
BTextreviewRequest bTextreviewRequest = JSONObject.parseObject(content, BTextreviewRequest.class);
|
||||||
|
MediaType mediaType = MediaType.parse("multipart/form-data");
|
||||||
|
RequestBody body = new MultipartBody.Builder().setType(MultipartBody.FORM)
|
||||||
|
.addFormDataPart("fileURLList", bTextreviewRequest.getFileURL())
|
||||||
|
.addFormDataPart("templateName", bTextreviewRequest.getTemplateName())
|
||||||
|
.addFormDataPart("commentRiskLevel", bTextreviewRequest.getCommentRiskLevel())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url("https://aip.baidubce.com/" + getUri() + "?access_token=" + getBaiduAccessToken())
|
||||||
|
.method("POST", body)
|
||||||
|
.addHeader("Content-Type", "multipart/form-data")
|
||||||
|
.build();
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getContent(BTextreviewRequest bTextreviewRequest) {
|
public String getContent(BTextreviewRequest bTextreviewRequest) {
|
||||||
|
|
||||||
|
return JSON.toJSONString(bTextreviewRequest);
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,9 +3,6 @@ package com.heyu.api.baidu.request.convert;
|
|||||||
import com.heyu.api.baidu.request.BBaseRequest;
|
import com.heyu.api.baidu.request.BBaseRequest;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://console.bce.baidu.com/support/?_=1740667714316×tamp=1740672614231#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=file%2F2.0%2Fbrain%2Fonline%2Fv1%2Ftextreview%2Ftask%2Fquery&method=post
|
* https://console.bce.baidu.com/support/?_=1740667714316×tamp=1740672614231#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=file%2F2.0%2Fbrain%2Fonline%2Fv1%2Ftextreview%2Ftask%2Fquery&method=post
|
||||||
*合同审查-获取结果
|
*合同审查-获取结果
|
||||||
@ -18,7 +15,7 @@ public class BTextreviewRequest extends BBaseRequest {
|
|||||||
* 文件数据,支持Word和PDF格式,文件大小不超过10M
|
* 文件数据,支持Word和PDF格式,文件大小不超过10M
|
||||||
* 优先级: file > fileURLList,当file字段存在时,fileURLList字段失效
|
* 优先级: file > fileURLList,当file字段存在时,fileURLList字段失效
|
||||||
*/
|
*/
|
||||||
private File file;
|
private String fileBase64;
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* 和 file/fileURLList 二选一
|
* 和 file/fileURLList 二选一
|
||||||
@ -29,7 +26,7 @@ public class BTextreviewRequest extends BBaseRequest {
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
private List<String> fileURLList;
|
private String fileURL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 选择需要审查的合同类型。
|
* 选择需要审查的合同类型。
|
||||||
|
|||||||
@ -1,18 +1,151 @@
|
|||||||
package com.heyu.api.baidu.response.convert;
|
package com.heyu.api.baidu.response.convert;
|
||||||
|
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.heyu.api.baidu.response.BBaseResp;
|
import com.heyu.api.baidu.response.BBaseResp;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://console.bce.baidu.com/support/?_=1740703582749×tamp=1740706160699#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv1%2Fextract%2Fquery_task&method=post
|
* https://console.bce.baidu.com/support/?_=1740703582749×tamp=1740706160699#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv1%2Fextract%2Fquery_task&method=post
|
||||||
* <p>
|
* <p>
|
||||||
* 文档抽取-获取结果
|
* 文档抽取-获取结果
|
||||||
*/
|
*/
|
||||||
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public class BQueryTaskResp extends BBaseResp {
|
public class BQueryTaskResp extends BBaseResp {
|
||||||
|
|
||||||
|
|
||||||
|
@JsonProperty("file_name")
|
||||||
|
private String fileName;
|
||||||
|
@JsonProperty("file_id")
|
||||||
|
private String fileId;
|
||||||
|
@JsonProperty("pages")
|
||||||
|
private List<PagesDTO> pages;
|
||||||
|
@JsonProperty("chunks")
|
||||||
|
private List<ChunksDTO> chunks;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class PagesDTO {
|
||||||
|
@JsonProperty("page_id")
|
||||||
|
private String pageId;
|
||||||
|
@JsonProperty("page_num")
|
||||||
|
private Integer pageNum;
|
||||||
|
@JsonProperty("text")
|
||||||
|
private String text;
|
||||||
|
@JsonProperty("layouts")
|
||||||
|
private List<LayoutsDTO> layouts;
|
||||||
|
@JsonProperty("tables")
|
||||||
|
private List<TablesDTO> tables;
|
||||||
|
@JsonProperty("images")
|
||||||
|
private List<?> images;
|
||||||
|
@JsonProperty("meta")
|
||||||
|
private MetaDTO meta;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class MetaDTO {
|
||||||
|
@JsonProperty("page_width")
|
||||||
|
private Integer pageWidth;
|
||||||
|
@JsonProperty("page_height")
|
||||||
|
private Integer pageHeight;
|
||||||
|
@JsonProperty("is_scan")
|
||||||
|
private Boolean isScan;
|
||||||
|
@JsonProperty("page_angle")
|
||||||
|
private Integer pageAngle;
|
||||||
|
@JsonProperty("page_type")
|
||||||
|
private String pageType;
|
||||||
|
@JsonProperty("sheet_name")
|
||||||
|
private String sheetName;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class LayoutsDTO {
|
||||||
|
@JsonProperty("layout_id")
|
||||||
|
private String layoutId;
|
||||||
|
@JsonProperty("text")
|
||||||
|
private String text;
|
||||||
|
@JsonProperty("position")
|
||||||
|
private List<Integer> position;
|
||||||
|
@JsonProperty("type")
|
||||||
|
private String type;
|
||||||
|
@JsonProperty("sub_type")
|
||||||
|
private String subType;
|
||||||
|
@JsonProperty("parent")
|
||||||
|
private String parent;
|
||||||
|
@JsonProperty("children")
|
||||||
|
private List<String> children;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class TablesDTO {
|
||||||
|
@JsonProperty("layout_id")
|
||||||
|
private String layoutId;
|
||||||
|
@JsonProperty("markdown")
|
||||||
|
private String markdown;
|
||||||
|
@JsonProperty("position")
|
||||||
|
private List<Integer> position;
|
||||||
|
@JsonProperty("cells")
|
||||||
|
private List<CellsDTO> cells;
|
||||||
|
@JsonProperty("matrix")
|
||||||
|
private List<List<Integer>> matrix;
|
||||||
|
@JsonProperty("merge_table")
|
||||||
|
private String mergeTable;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class CellsDTO {
|
||||||
|
@JsonProperty("layout_id")
|
||||||
|
private String layoutId;
|
||||||
|
@JsonProperty("text")
|
||||||
|
private String text;
|
||||||
|
@JsonProperty("position")
|
||||||
|
private List<Integer> position;
|
||||||
|
@JsonProperty("type")
|
||||||
|
private String type;
|
||||||
|
@JsonProperty("sub_type")
|
||||||
|
private String subType;
|
||||||
|
@JsonProperty("parent")
|
||||||
|
private String parent;
|
||||||
|
@JsonProperty("children")
|
||||||
|
private Object children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class ChunksDTO {
|
||||||
|
@JsonProperty("chunk_id")
|
||||||
|
private String chunkId;
|
||||||
|
@JsonProperty("content")
|
||||||
|
private String content;
|
||||||
|
@JsonProperty("type")
|
||||||
|
private String type;
|
||||||
|
@JsonProperty("meta")
|
||||||
|
private MetaDTO meta;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class MetaDTO {
|
||||||
|
@JsonProperty("title")
|
||||||
|
private List<String> title;
|
||||||
|
@JsonProperty("position")
|
||||||
|
private List<PositionDTO> position;
|
||||||
|
|
||||||
|
@NoArgsConstructor
|
||||||
|
@Data
|
||||||
|
public static class PositionDTO {
|
||||||
|
@JsonProperty("box")
|
||||||
|
private List<Integer> box;
|
||||||
|
@JsonProperty("page_num")
|
||||||
|
private Integer pageNum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -30,21 +30,21 @@ public class BTextreviewQueryResp {
|
|||||||
@Data
|
@Data
|
||||||
public static class ResultDTO {
|
public static class ResultDTO {
|
||||||
@JsonProperty("taskId")
|
@JsonProperty("taskId")
|
||||||
private String taskId;
|
private String taskId; // 任务ID
|
||||||
@JsonProperty("status")
|
@JsonProperty("status")
|
||||||
private String status;
|
private String status; // 任务状态,pending:排队中;processing:运行中;success:成功;failed:失败
|
||||||
@JsonProperty("apiVersion")
|
@JsonProperty("apiVersion")
|
||||||
private String apiVersion;
|
private String apiVersion;
|
||||||
@JsonProperty("createdAt")
|
@JsonProperty("createdAt")
|
||||||
private String createdAt;
|
private String createdAt; // 任务创建时间
|
||||||
@JsonProperty("startedAt")
|
@JsonProperty("startedAt")
|
||||||
private String startedAt;
|
private String startedAt; // 任务开始时间
|
||||||
@JsonProperty("finishedAt")
|
@JsonProperty("finishedAt")
|
||||||
private String finishedAt;
|
private String finishedAt; // 任务结束时间
|
||||||
@JsonProperty("duration")
|
@JsonProperty("duration")
|
||||||
private String duration;
|
private String duration; //任务执行时长
|
||||||
@JsonProperty("reason")
|
@JsonProperty("reason")
|
||||||
private String reason;
|
private String reason; //任务失败描述信息
|
||||||
@JsonProperty("textreviewResult")
|
@JsonProperty("textreviewResult")
|
||||||
private List<TextreviewResultDTO> textreviewResult;
|
private List<TextreviewResultDTO> textreviewResult;
|
||||||
|
|
||||||
@ -52,55 +52,55 @@ public class BTextreviewQueryResp {
|
|||||||
@Data
|
@Data
|
||||||
public static class TextreviewResultDTO {
|
public static class TextreviewResultDTO {
|
||||||
@JsonProperty("docId")
|
@JsonProperty("docId")
|
||||||
private String docId;
|
private String docId; // 文档ID
|
||||||
@JsonProperty("docName")
|
@JsonProperty("docName")
|
||||||
private String docName;
|
private String docName; // 文档名称
|
||||||
@JsonProperty("status")
|
@JsonProperty("status")
|
||||||
private String status;
|
private String status; // 文件状态,success:成功;failed:失败
|
||||||
@JsonProperty("reason")
|
@JsonProperty("reason")
|
||||||
private String reason;
|
private String reason; // 文件失败描述信息
|
||||||
@JsonProperty("chatContents")
|
@JsonProperty("chatContents")
|
||||||
private List<ChatContentsDTO> chatContents;
|
private List<ChatContentsDTO> chatContents; // 条款审查结果列表
|
||||||
@JsonProperty("fileURL")
|
@JsonProperty("fileURL")
|
||||||
private String fileURL;
|
private String fileURL; // 解析后的含位置信息的PDF文件地址,地址有效期30天
|
||||||
@JsonProperty("reportURL")
|
@JsonProperty("reportURL")
|
||||||
private String reportURL;
|
private String reportURL; // 包含重大风险条款批注的Word文档地址,地址有效期30天。若上传的源文件为PDF格式,则无法支持批注下载
|
||||||
@JsonProperty("reportStatus")
|
@JsonProperty("reportStatus")
|
||||||
private String reportStatus;
|
private String reportStatus; // 包含批注的Word文档状态,success:成功;failed:失败
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public static class ChatContentsDTO {
|
public static class ChatContentsDTO {
|
||||||
@JsonProperty("ruleId")
|
@JsonProperty("ruleId")
|
||||||
private String ruleId;
|
private String ruleId; // 条款ID
|
||||||
@JsonProperty("ruleName")
|
@JsonProperty("ruleName")
|
||||||
private String ruleName;
|
private String ruleName; // 条款名称
|
||||||
@JsonProperty("tags")
|
@JsonProperty("tags")
|
||||||
private List<TagsDTO> tags;
|
private List<TagsDTO> tags; // 条款的原文和位置信息列表
|
||||||
@JsonProperty("riskReviewResults")
|
@JsonProperty("riskReviewResults")
|
||||||
private List<RiskReviewResultsDTO> riskReviewResults;
|
private List<RiskReviewResultsDTO> riskReviewResults;
|
||||||
@JsonProperty("predictResult")
|
@JsonProperty("predictResult")
|
||||||
private String predictResult;
|
private String predictResult; // 条款的原始审查结果
|
||||||
@JsonProperty("isShow")
|
@JsonProperty("isShow")
|
||||||
private Boolean isShow;
|
private Boolean isShow;
|
||||||
@JsonProperty("riskName")
|
@JsonProperty("riskName")
|
||||||
private String riskName;
|
private String riskName; // 条款的风险等级
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public static class TagsDTO {
|
public static class TagsDTO {
|
||||||
@JsonProperty("value")
|
@JsonProperty("value")
|
||||||
private String value;
|
private String value; // 条款的原文
|
||||||
@JsonProperty("positions")
|
@JsonProperty("positions")
|
||||||
private List<PositionsDTO> positions;
|
private List<PositionsDTO> positions; // 条款的位置信息列表
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public static class PositionsDTO {
|
public static class PositionsDTO {
|
||||||
@JsonProperty("pageNum")
|
@JsonProperty("pageNum")
|
||||||
private Integer pageNum;
|
private Integer pageNum; // 条款的原文位置页码
|
||||||
@JsonProperty("box")
|
@JsonProperty("box")
|
||||||
private List<Integer> box;
|
private List<Integer> box; // 条款的原文四角点坐标,每个框选范围包含左上角x坐标、左上角y坐标、矩形框宽度、矩形框高度,共四个数值,如[89,74,61,12]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,23 +108,23 @@ public class BTextreviewQueryResp {
|
|||||||
@Data
|
@Data
|
||||||
public static class RiskReviewResultsDTO {
|
public static class RiskReviewResultsDTO {
|
||||||
@JsonProperty("originalContract")
|
@JsonProperty("originalContract")
|
||||||
private String originalContract;
|
private String originalContract; // 合同原文
|
||||||
@JsonProperty("riskPoint")
|
@JsonProperty("riskPoint")
|
||||||
private String riskPoint;
|
private String riskPoint; // 风险点名称
|
||||||
@JsonProperty("riskAnalysis")
|
@JsonProperty("riskAnalysis")
|
||||||
private String riskAnalysis;
|
private String riskAnalysis; // 风险分析
|
||||||
@JsonProperty("modifyExample")
|
@JsonProperty("modifyExample")
|
||||||
private String modifyExample;
|
private String modifyExample; // 修改示例
|
||||||
@JsonProperty("positions")
|
@JsonProperty("positions")
|
||||||
private List<PositionsDTO> positions;
|
private List<PositionsDTO> positions; // 条款的位置信息列表
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
public static class PositionsDTO {
|
public static class PositionsDTO {
|
||||||
@JsonProperty("pageNum")
|
@JsonProperty("pageNum")
|
||||||
private Integer pageNum;
|
private Integer pageNum; // 条款的原文位置页码
|
||||||
@JsonProperty("box")
|
@JsonProperty("box")
|
||||||
private List<Integer> box;
|
private List<Integer> box; // 条款的原文四角点坐标,每个框选范围包含左上角x坐标、左上角y坐标、矩形框宽度、矩形框高度,共四个数值,如[89,74,61,12]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -0,0 +1,59 @@
|
|||||||
|
package com.heyu.api.controller.convert;
|
||||||
|
|
||||||
|
|
||||||
|
import com.heyu.api.baidu.handle.convert.BExtractHandle;
|
||||||
|
import com.heyu.api.baidu.handle.convert.BQueryTaskHandle;
|
||||||
|
import com.heyu.api.data.annotation.CacheResult;
|
||||||
|
import com.heyu.api.data.annotation.NotIntercept;
|
||||||
|
import com.heyu.api.data.utils.R;
|
||||||
|
import com.heyu.api.request.convert.DocConvertReq;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
*
|
||||||
|
* https://console.bce.baidu.com/support/?_=1740703582749×tamp=1740705642373#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv1%2Fextract%2Ftask&method=post
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* 文档抽取-提交请求
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*https://console.bce.baidu.com/support/?_=1740703582749×tamp=1742713011202#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv1%2Fextract%2Ftask&method=post
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*文档抽取-提交请求
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* 接口描述
|
||||||
|
* 文档抽取支持自定义配置字段,无需训练即可抽取文档字段信息,精准定位字段值,适用于合同、票据、订单等各类文档场景。如希望快速可视化体验效果,可登录智能文档分析平台,一键上传文档,在线测试;在线工具和API服务的额度共享互通。
|
||||||
|
*
|
||||||
|
* 文档抽取API服务为异步接口,需要先调用提交请求接口获取taskId,然后调用获取结果接口进行结果轮询,建议提交请求后30秒开始轮询。提交请求接口QPS为2,获取结果接口QPS为10。
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/doc")
|
||||||
|
@NotIntercept
|
||||||
|
public class DocExtractController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BExtractHandle bExtractHandle ;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BQueryTaskHandle bQueryTaskHandle;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/extract")
|
||||||
|
@CacheResult
|
||||||
|
public R doc(DocConvertReq request) {
|
||||||
|
|
||||||
|
|
||||||
|
return R.error();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,73 @@
|
|||||||
|
package com.heyu.api.controller.convert;
|
||||||
|
|
||||||
|
|
||||||
|
import com.heyu.api.baidu.handle.convert.BParserTextHandle;
|
||||||
|
import com.heyu.api.baidu.handle.convert.BParserTextQueryQueryHandle;
|
||||||
|
import com.heyu.api.baidu.request.convert.BParserTextQueryRequest;
|
||||||
|
import com.heyu.api.baidu.response.convert.BParserTextQueryResp;
|
||||||
|
import com.heyu.api.baidu.response.convert.BParserTextResp;
|
||||||
|
import com.heyu.api.controller.BaseController;
|
||||||
|
import com.heyu.api.data.annotation.CacheResult;
|
||||||
|
import com.heyu.api.data.annotation.NotIntercept;
|
||||||
|
import com.heyu.api.data.utils.ApiR;
|
||||||
|
import com.heyu.api.data.utils.R;
|
||||||
|
import com.heyu.api.data.utils.StringUtils;
|
||||||
|
import com.heyu.api.request.convert.ParserTextReq;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
/***
|
||||||
|
* https://console.bce.baidu.com/support/?_=1740703582749×tamp=1740704125877#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv2%2Fparser%2Ftask&method=post
|
||||||
|
*
|
||||||
|
* 文档解析-提交请求
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*https://console.bce.baidu.com/support/?_=1740703582749×tamp=1742714833134#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E6%99%BA%E8%83%BD%E6%96%87%E6%A1%A3%E5%88%86%E6%9E%90&api=rest%2F2.0%2Fbrain%2Fonline%2Fv2%2Fparser%2Ftask%2Fquery&method=post
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* 文档解析-获取结果
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/text")
|
||||||
|
@NotIntercept
|
||||||
|
public class ParserTextController extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BParserTextHandle bParserTextHandle;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BParserTextQueryQueryHandle bParserTextQueryHandle;
|
||||||
|
|
||||||
|
@RequestMapping("/parse")
|
||||||
|
@CacheResult
|
||||||
|
public R parse(ParserTextReq request) {
|
||||||
|
if (StringUtils.isNotBlank(request.getTaskId())) {
|
||||||
|
ApiR<BParserTextResp> bR = bParserTextHandle.handle(request);
|
||||||
|
|
||||||
|
if (bR.isSuccess()) {
|
||||||
|
BParserTextResp bParserTextResp = bR.getData();
|
||||||
|
return R.ok().setData(bParserTextResp.getResult());
|
||||||
|
}
|
||||||
|
return R.error(bR.getErrorMsg());
|
||||||
|
} else {
|
||||||
|
|
||||||
|
BParserTextQueryRequest bParserTextQueryRequest = new BParserTextQueryRequest();
|
||||||
|
bParserTextQueryRequest.setTaskId(request.getTaskId());
|
||||||
|
|
||||||
|
ApiR<BParserTextQueryResp> bR = bParserTextQueryHandle.handle(bParserTextQueryRequest);
|
||||||
|
if (bR.isSuccess()) {
|
||||||
|
return R.ok().setData(bR.getData());
|
||||||
|
}
|
||||||
|
return R.error(bR.getErrorMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,68 @@
|
|||||||
|
package com.heyu.api.controller.convert;
|
||||||
|
|
||||||
|
import com.heyu.api.baidu.handle.convert.BTextreviewHandle;
|
||||||
|
import com.heyu.api.baidu.handle.convert.BTextreviewQueryHandle;
|
||||||
|
import com.heyu.api.baidu.request.convert.BTextreviewQueryRequest;
|
||||||
|
import com.heyu.api.baidu.response.convert.BTextreviewQueryResp;
|
||||||
|
import com.heyu.api.baidu.response.convert.BTextreviewResp;
|
||||||
|
import com.heyu.api.controller.BaseController;
|
||||||
|
import com.heyu.api.data.annotation.CacheResult;
|
||||||
|
import com.heyu.api.data.annotation.NotIntercept;
|
||||||
|
import com.heyu.api.data.utils.ApiR;
|
||||||
|
import com.heyu.api.data.utils.R;
|
||||||
|
import com.heyu.api.data.utils.StringUtils;
|
||||||
|
import com.heyu.api.request.convert.TextreviewReq;
|
||||||
|
import com.heyu.api.resp.convert.TextreviewRequestResp;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/doc")
|
||||||
|
@NotIntercept
|
||||||
|
public class TextreviewController extends BaseController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BTextreviewHandle bTextreviewHandle;
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BTextreviewQueryHandle bTextreviewQueryHandle;
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping("/textreview")
|
||||||
|
@CacheResult
|
||||||
|
public R parse(TextreviewReq request) {
|
||||||
|
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(request.getTaskId())) {
|
||||||
|
|
||||||
|
ApiR<BTextreviewResp> bR = bTextreviewHandle.handle(request);
|
||||||
|
if (bR.isSuccess()) {
|
||||||
|
TextreviewRequestResp resp = new TextreviewRequestResp();
|
||||||
|
BTextreviewResp bTextreviewResp = bR.getData();
|
||||||
|
|
||||||
|
resp.setTaskId(bTextreviewResp.getResult().getTaskId());
|
||||||
|
|
||||||
|
return R.ok().setData(resp);
|
||||||
|
}
|
||||||
|
return R.error(bR.getErrorMsg());
|
||||||
|
} else {
|
||||||
|
|
||||||
|
BTextreviewQueryRequest bTextreviewQueryRequest = new BTextreviewQueryRequest();
|
||||||
|
bTextreviewQueryRequest.setTaskId(request.getTaskId());
|
||||||
|
|
||||||
|
|
||||||
|
ApiR<BTextreviewQueryResp> bR = bTextreviewQueryHandle.handle(bTextreviewQueryRequest);
|
||||||
|
if(bR.isSuccess() ){
|
||||||
|
BTextreviewQueryResp bTextreviewQueryResp = bR.getData();
|
||||||
|
return R.ok().setData(bTextreviewQueryResp.getResult());
|
||||||
|
}
|
||||||
|
return R.error(bR.getErrorMsg());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.heyu.api.request.convert;
|
||||||
|
|
||||||
|
import com.heyu.api.baidu.request.convert.BParserTextRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ParserTextReq extends BParserTextRequest {
|
||||||
|
/***
|
||||||
|
* 任务id
|
||||||
|
*/
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,13 @@
|
|||||||
|
package com.heyu.api.request.convert;
|
||||||
|
|
||||||
|
import com.heyu.api.baidu.request.convert.BTextreviewRequest;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TextreviewReq extends BTextreviewRequest {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务id
|
||||||
|
*/
|
||||||
|
private String taskId;
|
||||||
|
}
|
||||||
@ -0,0 +1,14 @@
|
|||||||
|
package com.heyu.api.resp.convert;
|
||||||
|
|
||||||
|
import com.heyu.api.data.dto.BaseReq;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class TextreviewRequestResp extends BaseReq {
|
||||||
|
/**
|
||||||
|
* 任务id
|
||||||
|
*/
|
||||||
|
private String taskId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user