From d6f7260baf225a0d497ccfb3f7b4967a36dc24d6 Mon Sep 17 00:00:00 2001 From: haungxing <1203316822@qq.com> Date: Wed, 8 May 2024 15:31:47 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E9=89=B4=E6=9D=83=E6=8E=A5=E5=8F=A3?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/InteractiveServiceImpl.java | 21 ++++++++++++++------- pom.xml | 6 ++++-- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java index d9e2efb..f0bf166 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/service/impl/InteractiveServiceImpl.java @@ -22,6 +22,7 @@ import org.springblade.core.tool.api.R; import org.springblade.core.tool.utils.CollectionUtil; import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.StringUtil; +import org.springblade.system.dto.DeptStationDTO; import org.springblade.system.feign.IDeptClient; import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; @@ -36,6 +37,7 @@ import javax.servlet.http.HttpSession; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.stream.Collectors; import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*; /** @@ -76,11 +78,12 @@ public class InteractiveServiceImpl implements IInteractiveService { @Override public R ask(String question,String sessionId,String userId) { - //TODO 保存问题 - Map params = new HashMap<>(); + Map params = new HashMap<>(); params.put("id",sessionId); params.put("userid",userId.toString()); params.put("query",question); + params.put("stationids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId).filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).toArray()); + params.put("projectids",this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getDeptId).filter(Func::isNotEmpty).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) .body(JSON.toJSONString(params)).execute(); if(response.getStatus() != HttpServletResponse.SC_OK) { @@ -107,11 +110,8 @@ public class InteractiveServiceImpl implements IInteractiveService { public Boolean authentication(String stationId, String userId, String funcCode) { // 站点鉴权 if(StringUtil.isNotBlank(stationId)) { - R> stationsR = deptClient.getStationPermissionsById(Long.valueOf(userId)); - Assert.isTrue(stationsR.isSuccess() && CollectionUtil.isNotEmpty(stationsR.getData()),() -> { - throw new ServiceException("获取人员站点权限失败!"); - }); - List stations = stationsR.getData(); + List stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) + .filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).collect(Collectors.toList()); Assert.isTrue(stations.contains(stationId),() -> { throw new ServiceException("人员站点鉴权失败!"); }); @@ -130,4 +130,11 @@ public class InteractiveServiceImpl implements IInteractiveService { return true; } + private List getStationPermissionsById(String userId) { + R> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); + Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { + throw new ServiceException("获取人员站点权限失败!"); + }); + return deptSattionR.getData(); + } } diff --git a/pom.xml b/pom.xml index 182b612..3339d22 100644 --- a/pom.xml +++ b/pom.xml @@ -49,12 +49,14 @@ org.springblade blade-system-api - ${bladex.project.version} + + 5.1.1.RELEASE.fix.4 org.springblade blade-user-api - ${bladex.project.version} + + 5.1.1.RELEASE.fix.4 org.springblade