|
|
|
@ -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<String,String> params = new HashMap<>(); |
|
|
|
|
Map<String,Object> 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<List<String>> stationsR = deptClient.getStationPermissionsById(Long.valueOf(userId)); |
|
|
|
|
Assert.isTrue(stationsR.isSuccess() && CollectionUtil.isNotEmpty(stationsR.getData()),() -> { |
|
|
|
|
throw new ServiceException("获取人员站点权限失败!"); |
|
|
|
|
}); |
|
|
|
|
List<String> stations = stationsR.getData(); |
|
|
|
|
List<String> 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<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(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|