|
|
@ -10,9 +10,7 @@ import com.fkzy.warn.common.util.MD5Util; |
|
|
import com.fkzy.warn.common.util.RedisUtil; |
|
|
import com.fkzy.warn.common.util.RedisUtil; |
|
|
import com.fkzy.warn.mapper.LawCaseMapper; |
|
|
import com.fkzy.warn.mapper.LawCaseMapper; |
|
|
import com.fkzy.warn.model.*; |
|
|
import com.fkzy.warn.model.*; |
|
|
import com.fkzy.warn.model.params.AILawParams; |
|
|
|
|
|
import com.fkzy.warn.model.params.LawGroupParam; |
|
|
|
|
|
import com.fkzy.warn.model.params.PageParam; |
|
|
|
|
|
|
|
|
import com.fkzy.warn.model.params.*; |
|
|
import com.fkzy.warn.service.FyApiService; |
|
|
import com.fkzy.warn.service.FyApiService; |
|
|
import com.fkzy.warn.service.InvocationRecordService; |
|
|
import com.fkzy.warn.service.InvocationRecordService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
@ -36,7 +34,7 @@ import javax.annotation.Resource; |
|
|
import java.io.IOException; |
|
|
import java.io.IOException; |
|
|
import java.net.URLEncoder; |
|
|
import java.net.URLEncoder; |
|
|
import java.nio.charset.StandardCharsets; |
|
|
import java.nio.charset.StandardCharsets; |
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
|
import java.util.*; |
|
|
import java.util.concurrent.TimeUnit; |
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
@ -67,6 +65,16 @@ public class FyApiServiceImpl extends ServiceImpl implem |
|
|
|
|
|
|
|
|
@Value(value = "${api.apiId}") |
|
|
@Value(value = "${api.apiId}") |
|
|
private String apiId; |
|
|
private String apiId; |
|
|
|
|
|
|
|
|
|
|
|
@Value(value = "${api.recommendedCasesUrl}") |
|
|
|
|
|
private String recommendedCasesUrl; |
|
|
|
|
|
|
|
|
|
|
|
@Value(value = "${api.caseByIdUrl}") |
|
|
|
|
|
private String caseByIdUrl; |
|
|
|
|
|
|
|
|
|
|
|
@Value(value = "${api.caseAdvancedUrl}") |
|
|
|
|
|
private String caseAdvancedUrl; |
|
|
|
|
|
|
|
|
@Resource |
|
|
@Resource |
|
|
RedisUtil redisUtil; |
|
|
RedisUtil redisUtil; |
|
|
@Resource |
|
|
@Resource |
|
|
@ -94,11 +102,18 @@ public class FyApiServiceImpl extends ServiceImpl implem |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void getLawGroup(LawGroupParam lawGroupParam) { |
|
|
public void getLawGroup(LawGroupParam lawGroupParam) { |
|
|
// getAccessToken(); |
|
|
|
|
|
// if (true){ |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// LawGroupParam lawGroupParam = new LawGroupParam(); |
|
|
|
|
|
// lawGroupParam.setOrgan("全国人民代表大会"); |
|
|
|
|
|
// lawGroupParam.setExprityDateList(Collections.singletonList("[全国人民代表大会]")); |
|
|
|
|
|
// lawGroupParam.setSourceList(Collections.singletonList("[地方政府规章]")); |
|
|
|
|
|
// lawGroupParam.setTimeliness("现行有效"); |
|
|
|
|
|
// lawGroupParam.setPageSize(20); |
|
|
|
|
|
// lawGroupParam.setPubDate("2014"); |
|
|
|
|
|
// lawGroupParam.setPubDateList(Collections.singletonList("[地方政府规章]")); |
|
|
|
|
|
// lawGroupParam.setTimelinessList(Collections.singletonList("[现行有效]")); |
|
|
|
|
|
// lawGroupParam.setTitle("中国"); |
|
|
|
|
|
// lawGroupParam.setPageNum(1); |
|
|
PageParam pageParam = new PageParam(); |
|
|
PageParam pageParam = new PageParam(); |
|
|
pageParam.setPageNum(1); |
|
|
pageParam.setPageNum(1); |
|
|
pageParam.setPageSize(20); |
|
|
pageParam.setPageSize(20); |
|
|
@ -128,14 +143,73 @@ public class FyApiServiceImpl extends ServiceImpl implem |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void sendAILaw(AILawParams aiLawParams) { |
|
|
public void sendAILaw(AILawParams aiLawParams) { |
|
|
// getAccessToken(); |
|
|
|
|
|
// if (true) { |
|
|
|
|
|
// return; |
|
|
|
|
|
// } |
|
|
|
|
|
|
|
|
// AILawParams aiLawParams = new AILawParams(); |
|
|
|
|
|
// aiLawParams.setStream(true); |
|
|
|
|
|
// aiLawParams.setModel("中国法研LLM"); |
|
|
|
|
|
// AImessage aImessage = new AImessage(); |
|
|
|
|
|
// aImessage.setContent("借条和欠条的区别"); |
|
|
|
|
|
// aImessage.setRole("user"); |
|
|
|
|
|
// List<AImessage> aImessageList = new ArrayList<>(); |
|
|
|
|
|
// aImessageList.add(aImessage); |
|
|
|
|
|
// aiLawParams.setMessages(aImessageList); |
|
|
|
|
|
|
|
|
String jsonParams = JSON.toJSONString(aiLawParams); |
|
|
String jsonParams = JSON.toJSONString(aiLawParams); |
|
|
HttpHeaders headers = getRequestHeader(jsonParams); |
|
|
HttpHeaders headers = getRequestHeader(jsonParams); |
|
|
postStream(aiLawUrl, headers, jsonParams, "法研平台-AI检索法规"); |
|
|
postStream(aiLawUrl, headers, jsonParams, "法研平台-AI检索法规"); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void recommendedCases(RecommendedCasesParams recommendedCasesParams) { |
|
|
|
|
|
if (recommendedCasesParams==null){ |
|
|
|
|
|
recommendedCasesParams = new RecommendedCasesParams(); |
|
|
|
|
|
} |
|
|
|
|
|
// recommendedCasesParams.setCity(Arrays.asList("[\"山东省\"]")); |
|
|
|
|
|
// recommendedCasesParams.setProvince(Arrays.asList("[\"济南市\"]")); |
|
|
|
|
|
// recommendedCasesParams.setDoctype(Arrays.asList("[\"判决书\"]")); |
|
|
|
|
|
recommendedCasesParams.setQuestion("酒后驾驶"); |
|
|
|
|
|
recommendedCasesParams.setTop_k("10"); |
|
|
|
|
|
|
|
|
|
|
|
String jsonParams = JSON.toJSONString(recommendedCasesParams); |
|
|
|
|
|
HttpHeaders headers = getRequestHeader(jsonParams); |
|
|
|
|
|
String result = postAip(recommendedCasesUrl, headers, jsonParams, "相似案例推荐"); |
|
|
|
|
|
ApiResult<List<JudgmentDocument>> resultData = JSON.parseObject( |
|
|
|
|
|
result, |
|
|
|
|
|
new TypeReference<ApiResult<List<JudgmentDocument>>>() { |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void caseById(String docId) { |
|
|
|
|
|
|
|
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
|
object.put("id", docId); |
|
|
|
|
|
String json = object.toJSONString(); |
|
|
|
|
|
HttpHeaders headers = getRequestHeader(json); |
|
|
|
|
|
String result = postAip(caseByIdUrl, headers, json, "法研平台-按文书标识查询公开案例详情"); |
|
|
|
|
|
ApiResult<JudgmentDocumentFull> resultData = JSON.parseObject( |
|
|
|
|
|
result, |
|
|
|
|
|
new TypeReference<ApiResult<JudgmentDocumentFull>>() { |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public void caseAdvanced(JudgmentSearchParams judgmentSearchParams) { |
|
|
|
|
|
if (judgmentSearchParams ==null){ |
|
|
|
|
|
judgmentSearchParams = new JudgmentSearchParams(); |
|
|
|
|
|
} |
|
|
|
|
|
String jsonParams = JSON.toJSONString(judgmentSearchParams); |
|
|
|
|
|
HttpHeaders headers = getRequestHeader(jsonParams); |
|
|
|
|
|
String result = postAip(caseAdvancedUrl, headers, jsonParams, "公开案例高级检索"); |
|
|
|
|
|
ApiResult<List<JudgmentDocumentFull>> resultData = JSON.parseObject( |
|
|
|
|
|
result, |
|
|
|
|
|
new TypeReference<ApiResult<List<JudgmentDocumentFull>>>() { |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 发送流式请求到指定URL,并处理SSE响应 |
|
|
* 发送流式请求到指定URL,并处理SSE响应 |
|
|
* |
|
|
* |
|
|
|