Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-api
Commits
4a6205ff
Commit
4a6205ff
authored
Jun 27, 2025
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 法务对话 + 合同审核用户划分
parent
88ca063e
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
329 additions
and
3 deletions
+329
-3
AiDialoguesTypeEnum.java
...cn/com/poc/ai_dialogues/constant/AiDialoguesTypeEnum.java
+2
-0
LegalAffairsDialoguesService.java
.../poc/covenant/aggregate/LegalAffairsDialoguesService.java
+11
-0
LegalAffairsDialoguesServiceImpl.java
...nant/aggregate/impl/LegalAffairsDialoguesServiceImpl.java
+166
-0
LegalAffairsDialoguesDto.java
...ava/cn/com/poc/covenant/dto/LegalAffairsDialoguesDto.java
+75
-0
ExtractionRest.java
src/main/java/cn/com/poc/covenant/rest/ExtractionRest.java
+2
-1
LegalAffairsRest.java
src/main/java/cn/com/poc/covenant/rest/LegalAffairsRest.java
+19
-0
ExtractionRestImpl.java
...ava/cn/com/poc/covenant/rest/impl/ExtractionRestImpl.java
+14
-2
LegalAffairsRestImpl.java
...a/cn/com/poc/covenant/rest/impl/LegalAffairsRestImpl.java
+40
-0
No files found.
src/main/java/cn/com/poc/ai_dialogues/constant/AiDialoguesTypeEnum.java
View file @
4a6205ff
...
...
@@ -16,6 +16,8 @@ public enum AiDialoguesTypeEnum {
AI_FINANCE
(
"ai_finance"
,
"AI财务"
),
LEGAL_AFFAIRS
(
"legal_affairs"
,
"法务问答"
),
;
private
final
String
type
;
...
...
src/main/java/cn/com/poc/covenant/aggregate/LegalAffairsDialoguesService.java
0 → 100644
View file @
4a6205ff
package
cn
.
com
.
poc
.
covenant
.
aggregate
;
/**
* @author alex.yao
* @date 2025/6/27
*/
public
interface
LegalAffairsDialoguesService
{
void
call
(
String
dialoguesId
,
String
input
,
String
fileUrl
,
Integer
[]
knowledgeIds
,
Integer
[]
databaseIds
,
Long
userId
)
throws
Exception
;
}
src/main/java/cn/com/poc/covenant/aggregate/impl/LegalAffairsDialoguesServiceImpl.java
0 → 100644
View file @
4a6205ff
package
cn
.
com
.
poc
.
covenant
.
aggregate
.
impl
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationService
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.entity.*
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
import
cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity
;
import
cn.com.poc.ai_dialogues.service.BizAiDialoguesService
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.common.utils.StringUtils
;
import
cn.com.poc.covenant.aggregate.LegalAffairsDialoguesService
;
import
cn.com.poc.knowledge.aggregate.KnowledgeService
;
import
cn.com.poc.thirdparty.resource.demand.ai.constants.KnowledgeSearchTypeEnum
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Message
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.dialogue.Tool
;
import
cn.com.poc.thirdparty.resource.demand.ai.entity.function.FunctionCallResult
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
cn.com.yict.framemax.frame.service.FmxParamConfigService
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.stereotype.Service
;
import
org.springframework.web.context.request.RequestContextHolder
;
import
org.springframework.web.context.request.ServletRequestAttributes
;
import
javax.annotation.Resource
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* @author alex.yao
* @date 2025/6/27
*/
@Service
public
class
LegalAffairsDialoguesServiceImpl
implements
LegalAffairsDialoguesService
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
LegalAffairsDialoguesService
.
class
);
private
final
String
FMX_PARAM_AGENT_ID_CODE
=
"legal_affairs.agent_id"
;
@Resource
private
FmxParamConfigService
fmxParamConfigService
;
@Resource
private
BizAiDialoguesService
bizAiDialoguesService
;
@Resource
private
AgentApplicationService
agentApplicationService
;
@Resource
private
KnowledgeService
knowledgeService
;
@Resource
private
BizAgentApplicationPublishService
bizAgentApplicationPublishService
;
@Resource
private
BizAgentApplicationDialoguesRecordService
bizAgentApplicationDialoguesRecordService
;
@Override
public
void
call
(
String
dialoguesId
,
String
input
,
String
fileUrl
,
Integer
[]
knowledgeIds
,
Integer
[]
databaseIds
,
Long
userId
)
throws
Exception
{
String
agentId
=
fmxParamConfigService
.
getParam
(
FMX_PARAM_AGENT_ID_CODE
);
if
(
StringUtils
.
isBlank
(
agentId
))
{
logger
.
error
(
"获取AI财务对话agentId失败"
);
throw
new
BusinessException
(
"对话异常"
);
}
// 获取Agent基本信息
BizAgentApplicationPublishEntity
infoEntity
=
bizAgentApplicationPublishService
.
getByAgentId
(
agentId
);
if
(
infoEntity
==
null
)
{
logger
.
error
(
"获取AI财务对话agent信息失败"
);
throw
new
BusinessException
(
"对话异常"
);
}
// 保存对话基础信息
BizAiDialoguesEntity
bizAiDialoguesEntity
=
new
BizAiDialoguesEntity
();
bizAiDialoguesEntity
.
setMemberId
(
userId
);
bizAiDialoguesEntity
.
setDialoguesId
(
dialoguesId
);
bizAiDialoguesEntity
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizAiDialoguesEntity
>
bizAiDialoguesEntities
=
bizAiDialoguesService
.
findByExample
(
bizAiDialoguesEntity
,
null
);
if
(
CollectionUtils
.
isEmpty
(
bizAiDialoguesEntities
))
{
logger
.
error
(
"dialogues id 不存在,请重新创建"
);
throw
new
BusinessException
(
"对话异常"
);
}
// 保存标题信息
if
(
StringUtils
.
isBlank
(
bizAiDialoguesEntities
.
get
(
0
).
getTitle
()))
{
BizAiDialoguesEntity
portalDialoguesEntity
=
bizAiDialoguesEntities
.
get
(
0
);
portalDialoguesEntity
.
setTitle
(
input
);
bizAiDialoguesService
.
update
(
portalDialoguesEntity
);
}
// 获取对话配置
String
largeModel
=
infoEntity
.
getLargeModel
();
//获取模型
String
agentSystem
=
infoEntity
.
getAgentSystem
();
//获取Agent角色词
List
<
Integer
>
kdIds
=
knowledgeService
.
getKdIdsByKnowledgeInfoIds
(
knowledgeIds
);
//获取知识库ids
List
<
Message
>
messages
=
AgentApplicationTools
.
buildMessage
(
dialoguesId
,
agentId
,
userId
,
input
);
//构建消息
List
<
Tool
>
tools
=
AgentApplicationTools
.
buildFunctionConfig
(
infoEntity
.
getVariableStructure
(),
infoEntity
.
getIsLongMemory
(),
dialoguesId
,
agentId
,
infoEntity
.
getUnitIds
(),
infoEntity
.
getIsDocumentParsing
());
//构建函数配置
List
<
String
>
fileUrls
=
new
ArrayList
<>();
//构建文件链接
if
(
StringUtils
.
isNotBlank
(
fileUrl
))
{
fileUrls
.
add
(
fileUrl
);
}
CheckPluginUseEntity
checkPluginUseEntity
=
AgentApplicationTools
.
checkPluginUse
(
messages
,
tools
,
fileUrls
);
//检查插件使用
FunctionCallResult
functionCallResult
=
checkPluginUseEntity
.
getFunctionCallResult
();
//函数调用结果
boolean
stream
=
true
;
//是否流式输出
KnowledgeSearchTypeEnum
knowledgeSearchTypeEnum
=
KnowledgeSearchTypeEnum
.
valueOf
(
infoEntity
.
getKnowledgeSearchType
());
//知识库检索方式
KnowledgeSuperclassProblemConfig
knowledgeSuperclassProblemConfig
=
new
KnowledgeSuperclassProblemConfig
();
//知识库超纲配置
knowledgeSuperclassProblemConfig
.
setKnowledgeResponseType
(
infoEntity
.
getKnowledgeResponseType
());
//知识库回复类型
knowledgeSuperclassProblemConfig
.
setKnowledgeCustomResponse
(
infoEntity
.
getKnowledgeCustomResponse
());
//知识库自定义回复
// 记录用户输入时间戳
Long
inputTimestamp
=
System
.
currentTimeMillis
();
// 调用对话Agent
ServletRequestAttributes
servletRequestAttributes
=
(
ServletRequestAttributes
)
RequestContextHolder
.
getRequestAttributes
();
HttpServletResponse
response
=
servletRequestAttributes
.
getResponse
();
AgentResultEntity
agentResultEntity
=
agentApplicationService
.
callAgentApplication
(
agentId
,
dialoguesId
,
largeModel
,
agentSystem
,
kdIds
.
toArray
(
new
Integer
[
0
]),
databaseIds
,
infoEntity
.
getCommunicationTurn
(),
infoEntity
.
getTopP
(),
infoEntity
.
getTemperature
(),
messages
,
tools
,
functionCallResult
,
stream
,
infoEntity
.
getKnowledgeSimilarity
(),
infoEntity
.
getKnowledgeNResult
(),
knowledgeSearchTypeEnum
,
knowledgeSuperclassProblemConfig
,
response
);
//保存对话记录
//用户输入记录
BizAgentApplicationDialoguesRecordEntity
inputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
inputRecord
.
setAgentId
(
agentId
);
inputRecord
.
setMemberId
(
userId
);
inputRecord
.
setContent
(
input
);
inputRecord
.
setDialogsId
(
dialoguesId
);
inputRecord
.
setRole
(
AgentApplicationDialoguesRecordConstants
.
ROLE
.
USER
);
inputRecord
.
setTimestamp
(
inputTimestamp
);
bizAgentApplicationDialoguesRecordService
.
save
(
inputRecord
);
//AI输出记录
BizAgentApplicationDialoguesRecordEntity
outputRecord
=
new
BizAgentApplicationDialoguesRecordEntity
();
outputRecord
.
setRole
(
AgentApplicationDialoguesRecordConstants
.
ROLE
.
ASSISTANT
);
outputRecord
.
setAgentId
(
infoEntity
.
getAgentId
());
outputRecord
.
setDialogsId
(
dialoguesId
);
outputRecord
.
setMemberId
(
userId
);
if
(
agentResultEntity
.
getFunction
()
!=
null
)
{
outputRecord
.
setFunction
(
JsonUtils
.
serialize
(
agentResultEntity
.
getFunction
()));
}
outputRecord
.
setTimestamp
(
System
.
currentTimeMillis
());
outputRecord
.
setContent
(
agentResultEntity
.
getMessage
());
outputRecord
.
setReasoningContent
(
agentResultEntity
.
getReasoningContent
());
bizAgentApplicationDialoguesRecordService
.
save
(
outputRecord
);
}
}
src/main/java/cn/com/poc/covenant/dto/LegalAffairsDialoguesDto.java
0 → 100644
View file @
4a6205ff
package
cn
.
com
.
poc
.
covenant
.
dto
;
/**
* @author alex.yao
* @date 2025/6/20
*/
public
class
LegalAffairsDialoguesDto
{
/**
* 对话id
*/
private
String
dialoguesId
;
/**
* 问题
*/
private
String
input
;
/**
* 文件地址
*/
private
String
fileUrl
;
/**
* 知识库ids
*/
private
Integer
[]
knowledgeIds
;
/**
* 数据库ids
*/
private
Integer
[]
databaseIds
;
public
String
getDialoguesId
()
{
return
dialoguesId
;
}
public
void
setDialoguesId
(
String
dialoguesId
)
{
this
.
dialoguesId
=
dialoguesId
;
}
public
String
getInput
()
{
return
input
;
}
public
void
setInput
(
String
input
)
{
this
.
input
=
input
;
}
public
String
getFileUrl
()
{
return
fileUrl
;
}
public
void
setFileUrl
(
String
fileUrl
)
{
this
.
fileUrl
=
fileUrl
;
}
public
Integer
[]
getKnowledgeIds
()
{
return
knowledgeIds
;
}
public
void
setKnowledgeIds
(
Integer
[]
knowledgeIds
)
{
this
.
knowledgeIds
=
knowledgeIds
;
}
public
Integer
[]
getDatabaseIds
()
{
return
databaseIds
;
}
public
void
setDatabaseIds
(
Integer
[]
databaseIds
)
{
this
.
databaseIds
=
databaseIds
;
}
}
src/main/java/cn/com/poc/covenant/rest/ExtractionRest.java
View file @
4a6205ff
...
...
@@ -18,7 +18,7 @@ import java.util.List;
* @author alex.yao
* @date 2025/5/19
*/
@Permission
(
Access
.
Anonymous
)
@Permission
(
Access
.
Safety
)
public
interface
ExtractionRest
extends
BaseRest
{
/**
...
...
@@ -34,6 +34,7 @@ public interface ExtractionRest extends BaseRest {
/**
* 获取合同类型列表
*/
@Permission
(
Access
.
Anonymous
)
List
<
BizExtreactionContractTypeModel
>
getContractTypeList
(
@RequestParam
String
contractType
)
throws
Exception
;
/**
...
...
src/main/java/cn/com/poc/covenant/rest/LegalAffairsRest.java
0 → 100644
View file @
4a6205ff
package
cn
.
com
.
poc
.
covenant
.
rest
;
import
cn.com.poc.covenant.dto.LegalAffairsDialoguesDto
;
import
cn.com.yict.framemax.core.rest.BaseRest
;
import
cn.com.yict.framemax.web.permission.Access
;
import
cn.com.yict.framemax.web.permission.Permission
;
import
org.springframework.web.bind.annotation.RequestBody
;
/**
* @author alex.yao
* @date 2025/6/27
*/
@Permission
(
Access
.
Safety
)
public
interface
LegalAffairsRest
extends
BaseRest
{
void
call
(
@RequestBody
LegalAffairsDialoguesDto
legalAffairsDialoguesDto
)
throws
Exception
;
}
src/main/java/cn/com/poc/covenant/rest/impl/ExtractionRestImpl.java
View file @
4a6205ff
...
...
@@ -4,6 +4,7 @@ package cn.com.poc.covenant.rest.impl;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.common.model.BizFileUploadRecordModel
;
import
cn.com.poc.common.service.BizFileUploadRecordService
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.common.utils.DocumentLoad
;
import
cn.com.poc.common.utils.UUIDTool
;
...
...
@@ -20,6 +21,7 @@ import cn.com.poc.covenant.rest.ExtractionRest;
import
cn.com.poc.covenant.service.BizExtractionKeyInfoConfigService
;
import
cn.com.poc.covenant.service.BizExtractionReviewTaskService
;
import
cn.com.poc.covenant.service.BizExtreactionContractTypeService
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.poc.thirdparty.resource.baidu.api.BaiduTokenAPI
;
import
cn.com.poc.thirdparty.resource.baidu.api.TextReviewApi
;
import
cn.com.poc.thirdparty.resource.baidu.entity.response.TextReviewSubmitResponse
;
...
...
@@ -76,6 +78,11 @@ public class ExtractionRestImpl implements ExtractionRest {
public
String
startExtract
(
StartReviewDto
startReviewDto
)
throws
Exception
{
Assert
.
notNull
(
startReviewDto
.
getContractType
());
Assert
.
notEmpty
(
startReviewDto
.
getFileUrls
());
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
BusinessException
(
"用户未登录"
);
}
String
taskId
=
UUIDTool
.
getUUID
();
// 保存任务信息
...
...
@@ -94,6 +101,7 @@ public class ExtractionRestImpl implements ExtractionRest {
bizExtractionReviewTaskModel
.
setFileName
(
getFileName
(
fileUrl
));
}
bizExtractionReviewTaskModel
.
setTaskId
(
taskId
);
bizExtractionReviewTaskModel
.
setUserId
(
userBaseEntity
.
getUserId
());
bizExtractionReviewTaskModel
.
setFileUrl
(
fileUrl
);
bizExtractionReviewTaskModel
.
setActionType
(
ContractConstants
.
ActionType
.
extract
);
bizExtractionReviewTaskModel
.
setReviewStatus
(
"RUN"
);
...
...
@@ -111,6 +119,11 @@ public class ExtractionRestImpl implements ExtractionRest {
Assert
.
notNull
(
startReviewDto
.
getContractType
());
String
taskId
=
UUIDTool
.
getUUID
();
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
BusinessException
(
"用户未登录"
);
}
// 保存任务信息
if
(
CollectionUtils
.
isEmpty
(
startReviewDto
.
getFileUrls
()))
{
throw
new
BusinessException
(
"请上传文件"
);
...
...
@@ -118,11 +131,9 @@ public class ExtractionRestImpl implements ExtractionRest {
String
fileUrl
=
startReviewDto
.
getFileUrls
().
get
(
0
);
// File c = File.createTempFile(UUIDTool.getUUID(), "." + getFileSuffix(fileUrl));
//下载bos
URL
url
=
new
URL
(
fileUrl
);
File
tempAudioFile
=
DocumentLoad
.
downloadURLDocument
(
url
.
getPath
());
// inputstreamtofile(download, tempAudioFile);
List
<
BizExtractionReviewTaskModel
>
bizExtractionReviewTaskModels
=
new
ArrayList
<>();
...
...
@@ -144,6 +155,7 @@ public class ExtractionRestImpl implements ExtractionRest {
bizExtractionReviewTaskModel
.
setFileUrl
(
fileUrl
);
bizExtractionReviewTaskModel
.
setActionType
(
ContractConstants
.
ActionType
.
textreview
);
bizExtractionReviewTaskModel
.
setReviewStatus
(
"RUN"
);
bizExtractionReviewTaskModel
.
setUserId
(
userBaseEntity
.
getUserId
());
bizExtractionReviewTaskModel
.
setReviewErrorMsg
(
null
);
bizExtractionReviewTaskModel
.
setTextInTaskId
(
textReviewSubmitResponse
.
getResult
().
getTaskId
());
bizExtractionReviewTaskModel
.
setContractType
(
startReviewDto
.
getContractType
());
...
...
src/main/java/cn/com/poc/covenant/rest/impl/LegalAffairsRestImpl.java
0 → 100644
View file @
4a6205ff
package
cn
.
com
.
poc
.
covenant
.
rest
.
impl
;
import
cn.com.poc.common.utils.Assert
;
import
cn.com.poc.common.utils.BlContext
;
import
cn.com.poc.covenant.aggregate.LegalAffairsDialoguesService
;
import
cn.com.poc.covenant.dto.LegalAffairsDialoguesDto
;
import
cn.com.poc.covenant.rest.LegalAffairsRest
;
import
cn.com.poc.support.security.oauth.entity.UserBaseEntity
;
import
cn.com.yict.framemax.core.exception.BusinessException
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
/**
* @author alex.yao
* @date 2025/6/27
*/
@Component
public
class
LegalAffairsRestImpl
implements
LegalAffairsRest
{
@Resource
private
LegalAffairsDialoguesService
legalAffairsDialoguesService
;
@Override
public
void
call
(
LegalAffairsDialoguesDto
legalAffairsDialoguesDto
)
throws
Exception
{
Assert
.
notNull
(
legalAffairsDialoguesDto
);
Assert
.
notBlank
(
legalAffairsDialoguesDto
.
getInput
());
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUserNotException
();
if
(
userBaseEntity
==
null
)
{
throw
new
BusinessException
(
"用户未登录"
);
}
legalAffairsDialoguesService
.
call
(
legalAffairsDialoguesDto
.
getDialoguesId
(),
legalAffairsDialoguesDto
.
getInput
(),
legalAffairsDialoguesDto
.
getFileUrl
(),
legalAffairsDialoguesDto
.
getKnowledgeIds
(),
legalAffairsDialoguesDto
.
getDatabaseIds
(),
userBaseEntity
.
getUserId
());
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment