|
|
@ -22,6 +22,7 @@ import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.CollectionUtil; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.Func; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
|
|
|
import org.springblade.system.dto.DeptStationDTO; |
|
|
|
import org.springblade.system.feign.IDeptClient; |
|
|
|
import org.springblade.system.feign.IDeptClient; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springblade.system.user.feign.IUserClient; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
@ -36,6 +37,7 @@ import javax.servlet.http.HttpSession; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*; |
|
|
|
import static com.hnac.hzims.bigmodel.interactive.constants.FunctionConstants.*; |
|
|
|
/** |
|
|
|
/** |
|
|
@ -76,11 +78,12 @@ public class InteractiveServiceImpl implements IInteractiveService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public R ask(String question,String sessionId,String userId) { |
|
|
|
public R ask(String question,String sessionId,String userId) { |
|
|
|
//TODO 保存问题
|
|
|
|
Map<String,Object> params = new HashMap<>(); |
|
|
|
Map<String,String> params = new HashMap<>(); |
|
|
|
|
|
|
|
params.put("id",sessionId); |
|
|
|
params.put("id",sessionId); |
|
|
|
params.put("userid",userId.toString()); |
|
|
|
params.put("userid",userId.toString()); |
|
|
|
params.put("query",question); |
|
|
|
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()) |
|
|
|
HttpResponse response = HttpRequest.post(fdpHost + bigModelInvokeUrl.getAssistantAsk()) |
|
|
|
.body(JSON.toJSONString(params)).execute(); |
|
|
|
.body(JSON.toJSONString(params)).execute(); |
|
|
|
if(response.getStatus() != HttpServletResponse.SC_OK) { |
|
|
|
if(response.getStatus() != HttpServletResponse.SC_OK) { |
|
|
@ -107,11 +110,8 @@ public class InteractiveServiceImpl implements IInteractiveService { |
|
|
|
public Boolean authentication(String stationId, String userId, String funcCode) { |
|
|
|
public Boolean authentication(String stationId, String userId, String funcCode) { |
|
|
|
// 站点鉴权
|
|
|
|
// 站点鉴权
|
|
|
|
if(StringUtil.isNotBlank(stationId)) { |
|
|
|
if(StringUtil.isNotBlank(stationId)) { |
|
|
|
R<List<String>> stationsR = deptClient.getStationPermissionsById(Long.valueOf(userId)); |
|
|
|
List<String> stations = this.getStationPermissionsById(userId).stream().map(DeptStationDTO::getStationId) |
|
|
|
Assert.isTrue(stationsR.isSuccess() && CollectionUtil.isNotEmpty(stationsR.getData()),() -> { |
|
|
|
.filter(StringUtil::isNotBlank).filter(Func::isNotEmpty).collect(Collectors.toList()); |
|
|
|
throw new ServiceException("获取人员站点权限失败!"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
List<String> stations = stationsR.getData(); |
|
|
|
|
|
|
|
Assert.isTrue(stations.contains(stationId),() -> { |
|
|
|
Assert.isTrue(stations.contains(stationId),() -> { |
|
|
|
throw new ServiceException("人员站点鉴权失败!"); |
|
|
|
throw new ServiceException("人员站点鉴权失败!"); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -130,4 +130,11 @@ public class InteractiveServiceImpl implements IInteractiveService { |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<DeptStationDTO> getStationPermissionsById(String userId) { |
|
|
|
|
|
|
|
R<List<DeptStationDTO>> deptSattionR = deptClient.getStationPermissionsById(Long.valueOf(userId)); |
|
|
|
|
|
|
|
Assert.isTrue(deptSattionR.isSuccess() && CollectionUtil.isNotEmpty(deptSattionR.getData()),() -> { |
|
|
|
|
|
|
|
throw new ServiceException("获取人员站点权限失败!"); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return deptSattionR.getData(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|