Commit 6aab2c93 authored by 赵灿灿's avatar 赵灿灿

增加查询专家信息

parent f1f8a6eb
Pipeline #21459 passed with stages
in 4 minutes and 24 seconds
...@@ -767,4 +767,114 @@ public class LangChainController { ...@@ -767,4 +767,114 @@ public class LangChainController {
chatService.deleteChat(sessionId); chatService.deleteChat(sessionId);
return Result.successData("删除成功"); return Result.successData("删除成功");
} }
//调用智能体
@GetMapping("/sseTest")
public ResponseEntity<SseEmitter> sseTest(@RequestParam String chatMessage,@RequestParam String dialogId,
@RequestParam String selectedExpert ,@RequestParam String selectedOrg) {
String condition="";
// String regionName= chatService.getAuthRegionName();
// if("内部专家".equals(selectedExpert)) {
// if ("组织内".equals(selectedOrg) && StringUtils.isNotEmpty(regionName)) {
// condition = ",只能查找" + regionName;
// } else if ("组织外".equals(selectedOrg) && StringUtils.isNotEmpty(regionName)) {
// condition = ",排除" + regionName;
// }
// }
// String urlAddr = "http://10.32.41.35:40517/scene_gateway/agent/6809d0895428476bb6789ad70c525c97";
String urlAddr ="http://10.32.41.35:40517/scene_gateway/agent/468fd1bfa3e543fc8526a82a9093097a"; //chatService.getUrl(selectedExpert);
//String urlAddr = "http://10.32.41.35:40517/scene_gateway/agent/83f77143b09c461993dd9a7db403eb94";
SseEmitter emitter = new SseEmitter(0L);
QuestionRequest questionRequest=new QuestionRequest();
questionRequest.setKeyword(chatMessage+condition);
questionRequest.setRequestId(getRequestId());
questionRequest.setDialogId(dialogId);
// Conversations conversations=chatService.saveConversations(dialogId,chatMessage,selectedExpert);
// Messages messagesQusetion=new Messages();
// messagesQusetion.setRequestId(dialogId);
// messagesQusetion.setContent(chatMessage);
// messagesQusetion.setRole("user");
// messagesQusetion.setModelName("qwen2.5-72b");
// messagesQusetion=chatService.insertQuestionMessage(conversations,messagesQusetion);
// Messages messagesContent=new Messages();
// messagesContent.setRole("assistant");
// messagesContent.setModelName("qwen2.5-72b");
// messagesContent.setParentMsgId(messagesQusetion.getId());
// messagesContent.setSort(messagesQusetion.getSort()+1);
// chatService.insertMessage(conversations,messagesContent);
String params = JsonUtils.objectToJson(questionRequest);
StringBuffer content =new StringBuffer();
StringBuffer lineCotent =new StringBuffer();
new Thread(() -> {
HttpURLConnection connection = null;
try {
URL url = new URL(urlAddr);
// 建立链接
connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
connection.setRequestProperty("AuthToken", "4009fe23e6b648539792330c14f5ed8e");
// connection.setRequestProperty("AuthToken", "fc40db5b7abe47dabfe1899e61fde2d7");
// 允许输入和输出
connection.setDoInput(true);
connection.setDoOutput(true);
// 设置超时为0,表示无限制
connection.setConnectTimeout(0);
connection.setReadTimeout(0);
try (OutputStream os = connection.getOutputStream()) {
os.write(params.getBytes(StandardCharsets.UTF_8));
os.flush();
}
// 检查响应码
int responseCode = connection.getResponseCode();
if (responseCode != HttpURLConnection.HTTP_OK) {
emitter.completeWithError(new RuntimeException("SSE 连接失败: " + responseCode));
return;
}
// 持续读取 SSE 数据流
try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
String line;
while ((line = reader.readLine()) != null) {
logger.info(line);
if (!line.startsWith("data:CALLBACK#")) {
if (line.startsWith("data:")) {
String data = line.substring(5).trim();
if("stop".equals(data))
{
emitter.send(SseEmitter.event().data("stop"),MediaType.parseMediaType("application/json; charset=UTF-8"));
}else
{
lineCotent.append(data);
String sendData=data.replace("attachment#[]#attachment","").replace("source#[]#source","")
.replace("#","").replace("*","");
emitter.send(SseEmitter.event().data(sendData), MediaType.parseMediaType("application/json; charset=UTF-8"));
if(!sendData.startsWith("SUGGEST["))
content.append(sendData);
}
}
}
}
}
emitter.complete(); // 流结束
} catch (Exception e) {
emitter.completeWithError(e);
logger.info(e.getMessage());
} finally {
// messagesContent.setContent(content.toString());
// chatService.updateMessage(messagesContent);
if (connection != null) {
connection.disconnect();
}
logger.info(lineCotent.toString());
}
}).start();
return ResponseEntity.ok()
.header(HttpHeaders.CONTENT_TYPE, MediaType.TEXT_EVENT_STREAM_VALUE)
.body(emitter);
}
} }
package com.infoepoch.pms.dispatchassistant.domain.expertInformation;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.math.BigDecimal;
import java.util.Date;
/**
* generated by code-generator
* 专家信息表
*/
public class ExpertInformation {
/**
* 专家ID
*/
private Integer id;
/**
* 专家姓名
*/
private String name;
/**
* 专家性别
*/
private String gender;
/**
* 专家邮箱
*/
private String mailbox;
/**
* 专家电话
*/
private String telephone;
/**
* 专家OA用户名
*/
private String userName;
/**
* 入职时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date employmentDate;
/**
* 专家部门
*/
private String department;
/**
* 专家科室
*/
private String group;
/**
* 职位
*/
private String position;
/**
* 业务范围
*/
private String scopeBusiness;
/**
* 调用状态
*/
private String state;
/**
* 擅长领域
*/
private String specializesFields;
/**
* 专家简介
*/
private String expertIntroduction;
/**
* 所属OA组织编码
*/
private String organizationalCode;
/**
* 记录时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date recordTime;
/**
* 更新时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updateTime;
/**
* 专家照片
*/
private String photo;
/**
* 专家科室ID
*/
private Integer groupId;
/**
* 专家部门ID
*/
private Integer departmentId;
/**
* 专家用户ID
*/
private Integer userId;
/**
* 专家满意度均分
*/
private BigDecimal satisfactionScore;
/**
* 专家职称
*/
private String level;
/**
* 专家是否启用(1是启用,0是禁用,2是冻结)
*/
private String disabled;
/**
* 所属地市
*/
private String regionCode;
/**
* 排序
*/
private Integer sort;
/**
* 私有无参构造
*/
private ExpertInformation() {
}
/**
* 仓储还原
*/
public ExpertInformation(Integer id, String name, String gender, String mailbox, String telephone, String userName, Date employmentDate, String department, String group, String position, String scopeBusiness, String state, String specializesFields, String expertIntroduction, String organizationalCode, Date recordTime, Date updateTime, String photo, Integer groupId, Integer departmentId, Integer userId, BigDecimal satisfactionScore, String level, String disabled, String regionCode, Integer sort) {
this.id = id;
this.name = name;
this.gender = gender;
this.mailbox = mailbox;
this.telephone = telephone;
this.userName = userName;
this.employmentDate = employmentDate;
this.department = department;
this.group = group;
this.position = position;
this.scopeBusiness = scopeBusiness;
this.state = state;
this.specializesFields = specializesFields;
this.expertIntroduction = expertIntroduction;
this.organizationalCode = organizationalCode;
this.recordTime = recordTime;
this.updateTime = updateTime;
this.photo = photo;
this.groupId = groupId;
this.departmentId = departmentId;
this.userId = userId;
this.satisfactionScore = satisfactionScore;
this.level = level;
this.disabled = disabled;
this.regionCode = regionCode;
this.sort = sort;
}
/**
* 校验
*/
public void verify() {
}
public Integer getId() {
return id;
}
public String getName() {
return name;
}
public String getGender() {
return gender;
}
public String getMailbox() {
return mailbox;
}
public String getTelephone() {
return telephone;
}
public String getUserName() {
return userName;
}
public Date getEmploymentDate() {
return employmentDate;
}
public String getDepartment() {
return department;
}
public String getGroup() {
return group;
}
public String getPosition() {
return position;
}
public String getScopeBusiness() {
return scopeBusiness;
}
public String getState() {
return state;
}
public String getSpecializesFields() {
return specializesFields;
}
public String getExpertIntroduction() {
return expertIntroduction;
}
public String getOrganizationalCode() {
return organizationalCode;
}
public Date getRecordTime() {
return recordTime;
}
public Date getUpdateTime() {
return updateTime;
}
public String getPhoto() {
return photo;
}
public Integer getGroupId() {
return groupId;
}
public Integer getDepartmentId() {
return departmentId;
}
public Integer getUserId() {
return userId;
}
public BigDecimal getSatisfactionScore() {
return satisfactionScore;
}
public String getLevel() {
return level;
}
public String getDisabled() {
return disabled;
}
public String getRegionCode() {
return regionCode;
}
public Integer getSort() {
return sort;
}
}
package com.infoepoch.pms.dispatchassistant.domain.expertInformation;
import com.infoepoch.pms.dispatchassistant.common.exception.ValidationException;
import com.infoepoch.pms.dispatchassistant.common.utils.StringUtils;
import com.infoepoch.pms.dispatchassistant.infractructure.langchain.ConversationsRepository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* generated by code-generator
* 专家信息表Service
**/
@Service
public class ExpertInformationService {
@Autowired
private IExpertInformationRepository repository;
private static final Logger LogHelper = LoggerFactory.getLogger(ConversationsRepository.class);
/**
* 根据条件查询单个对象
**/
public ExpertInformation querySingle( ExpertInformationCriteria criteria) {
criteria.removeMapNullOrEmpty();
ExpertInformation entity;
try {
entity = repository.selectOneByCriteria(criteria);
return entity;
} catch (Exception e) {
LogHelper.info(e.getMessage());
throw new ValidationException("根据条件查询专家信息表 数据 失败。");
}
}
/**
* 根据id查询
**/
public ExpertInformation queryById(String id) {
if (StringUtils.isBlank(id)){
throw new ValidationException("唯一标识不能为空");
};
ExpertInformation entity;
try {
entity = repository.selectById(id);
return entity;
} catch (Exception e) {
LogHelper.info(e.getMessage());
throw new ValidationException("根据id查询 专家信息表 数据 失败。");
}
}
/**
* 根据条件查询列表(可分页)
**/
public Map<String, Object> queryList( ExpertInformationCriteria criteria) {
try {
criteria.removeMapNullOrEmpty();
if (criteria.byPage()) {
List<ExpertInformation> entityList = repository.selectCriteriaByPage(criteria, criteria.getPageSize(), criteria.getPageSize());
int totalCount = repository.selectCountByCriteria(criteria);
Map<String, Object> map = new HashMap<>();
map.put("totalCount", totalCount);
map.put("entityList", entityList);
return map;
} else {
if (!criteria.hasCriteria())
throw new ValidationException("请输入查询条件。");
return null;
}
} catch (Exception e) {
LogHelper.info(e.getMessage());
throw new ValidationException("根据条件查询 专家信息表 列表 数据 失败。");
}
}
/**
* 保存
**/
public boolean save( ExpertInformation entity) {
try {
entity.verify();
boolean insert = repository.insert(entity);
return insert;
} catch (Exception e) {
LogHelper.info(e.getMessage());
throw new ValidationException("保存 专家信息表 数据 失败。");
}
}
/**
* 修改
**/
public boolean modify( ExpertInformation entity) {
try {
entity.verify();
boolean update = repository.update(entity);
return update;
} catch (Exception e) {
LogHelper.info(e.getMessage());
throw new ValidationException("修改 专家信息表 数据 失败。");
}
}
}
package com.infoepoch.pms.dispatchassistant.domain.expertInformation;
import java.util.List;
/**
* generated by code-generator
* 专家信息表仓储接口
*/
public interface IExpertInformationRepository {
/**
* 表序列id
*/
Long sequenceId();
/**
* 新增
* @param: [entity]
*/
boolean insert(ExpertInformation entity);
/**
* 更新
* @param: [entity]
*/
boolean update(ExpertInformation entity);
/**
* 批量新增
* @param: [entitys]
*/
int[] batchInsert(List<ExpertInformation> entitys);
/**
* 批量更新
* @param: [entitys]
*/
int[] batchUpdate(List<ExpertInformation> entitys);
/**
* 删除
* @param: [id]
*/
boolean delete(String id);
// region select
/**
* 根据Id查询
* @param: [id]
*/
ExpertInformation selectById(String id);
/**
* 根据查询条件查询单个对象
* @param: [criteria]
*/
ExpertInformation selectOneByCriteria(ExpertInformationCriteria criteria);
/**
* 根据查询条件查询对象集合
* @param: [criteria]
*/
List<ExpertInformation> selectByCriteria(ExpertInformationCriteria criteria);
/**
* 根据查询条件分页查询对象结合
* @param: [criteria, pageNum, pageSize]
*/
List<ExpertInformation> selectCriteriaByPage(ExpertInformationCriteria criteria, int pageNum, int pageSize);
/**
* 根据条件查询对象总记录数
* @param: [criteria]
*/
Integer selectCountByCriteria(ExpertInformationCriteria criteria);
// endregion
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment