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 92ce693..d9e2efb 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 @@ -19,8 +19,11 @@ import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.secure.utils.AuthUtil; 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.feign.IDeptClient; +import org.springblade.system.user.feign.IUserClient; import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; @@ -48,13 +51,14 @@ public class InteractiveServiceImpl implements IInteractiveService { private final IFunctionService functionService; private final BigModelInvokeUrl bigModelInvokeUrl; private final BladeLogger logger; + private final IDeptClient deptClient; + private final IUserClient userClient; @Value("${fdp.host}") private String fdpHost; @Override public R resolve(ModelFunctionReq req) { logger.info("interactive:resolve","开始解析大模型函数,函数内容为:" + JSON.toJSONString(req)); - //TODO 数据鉴权 FunctionEntity function = functionService.getFunctionByCode(req.getFunctionName()); TypeEnum typeEnum = TypeEnum.getTypeEnumByType(function.getType()); switch (typeEnum) { @@ -88,8 +92,8 @@ public class InteractiveServiceImpl implements IInteractiveService { @Override public List getAnswerBySessionIds(String sessionIds) { - Map params = new HashMap<>(); - params.put("ids",sessionIds); + Map params = new HashMap<>(); + params.put("ids",Func.toStrList(",",sessionIds).toArray()); HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantStatus()) .body(JSON.toJSONString(params)).execute(); logger.info("interactive:getAnswerBySessionIds","获取答案:" + response.body()); @@ -101,7 +105,28 @@ public class InteractiveServiceImpl implements IInteractiveService { @Override public Boolean authentication(String stationId, String userId, String funcCode) { - //TODO 鉴权逻辑完善 + // 站点鉴权 + 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(); + Assert.isTrue(stations.contains(stationId),() -> { + throw new ServiceException("人员站点鉴权失败!"); + }); + } + // 菜单鉴权 + if(StringUtil.isNotBlank(funcCode)) { + FunctionEntity function = functionService.getFunctionByCode(funcCode); + Assert.isTrue(Func.isNotEmpty(function) && StringUtil.isNotBlank(function.getRoute()),() -> { + throw new ServiceException("传入函数未获取到菜单,鉴权失败!"); + }); + R authenticationR = userClient.permissionMenuById(Long.valueOf(userId), function.getRoute()); + Assert.isTrue(authenticationR.isSuccess() && authenticationR.getData(), () -> { + throw new ServiceException("人员菜单鉴权失败!"); + }); + } return true; } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java index ae34551..3b1ac38 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/interactive/vo/AnswerVO.java @@ -44,4 +44,7 @@ public class AnswerVO implements Serializable { @ApiModelProperty("query对应的答案") private String answer; + @ApiModelProperty("其它调用的参数") + private String[] extra; + } diff --git a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java index 25ea4a8..56af36e 100644 --- a/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java +++ b/hzims-service/hzims-big-model/src/main/java/com/hnac/hzims/bigmodel/schedule/InteractiveSchedule.java @@ -68,7 +68,7 @@ public class InteractiveSchedule { @XxlJob(GET_INTERACTIVE_RESULT) public ReturnT execute(String params) { List sessionIds = InteractiveSessionManager.getSessionIds(); - XxlJobLogger.log("开始获取到sessionId:"+sessionIds); + XxlJobLogger.log("开始获取到sessionId:"+sessionIds.stream().collect(Collectors.joining(","))); List AnswerList = interactiveService.getAnswerBySessionIds(sessionIds.stream().collect(Collectors.joining(","))); XxlJobLogger.log("获取到答案:"+JSON.toJSONString(AnswerList)); AnswerList.parallelStream().forEach(answerVO -> {