fix(emergency): myParticipatedOrders接口补充返回当前用户自己发起/被救助的应急工单
This commit is contained in:
+1
-1
@@ -88,7 +88,7 @@ public interface EmergencyOrderApiService {
|
||||
IPage<EmployeeVO> searchEmployee(String realname, String orgCode, String workNo, String phone, String excludeSessionId, Integer pageNo, Integer pageSize);
|
||||
|
||||
/**
|
||||
* 查询当前登录人参与的应急工单列表(sessionNow=1)
|
||||
* 查询当前登录人参与的应急工单列表 + 自己发起/被救助的应急工单
|
||||
*/
|
||||
IPage<MyParticipatedOrderVO> myParticipatedOrders(Integer pageNo, Integer pageSize);
|
||||
|
||||
|
||||
+120
-58
@@ -923,15 +923,8 @@ public class EmergencyOrderApiServiceImpl implements EmergencyOrderApiService {
|
||||
|
||||
@Override
|
||||
public IPage<EmergencyProfessionUser> searchExpert(String realname, String centerId, String excludeSessionId, Integer pageNo, Integer pageSize) {
|
||||
LambdaQueryWrapper<EmergencyProfessionUser> query = new LambdaQueryWrapper<>();
|
||||
query.eq(EmergencyProfessionUser::getType, "6");
|
||||
if (StrUtil.isNotBlank(realname)) {
|
||||
query.like(EmergencyProfessionUser::getRealname, realname);
|
||||
}
|
||||
if (StrUtil.isNotBlank(centerId)) {
|
||||
query.eq(EmergencyProfessionUser::getCenterId, centerId);
|
||||
}
|
||||
// 排除已在群中的人员
|
||||
// ---- 1. 收集需要排除的userId(已在群中的人) ----
|
||||
Set<String> excludeUserIds = new HashSet<>();
|
||||
if (StrUtil.isNotBlank(excludeSessionId)) {
|
||||
Order order = orderMapper.selectOne(new LambdaQueryWrapper<Order>()
|
||||
.eq(Order::getSessionId, excludeSessionId));
|
||||
@@ -939,67 +932,117 @@ public class EmergencyOrderApiServiceImpl implements EmergencyOrderApiService {
|
||||
List<OrderOperator> ops = orderOperatorMapper.selectList(
|
||||
new LambdaQueryWrapper<OrderOperator>()
|
||||
.eq(OrderOperator::getOrderId, order.getId()));
|
||||
List<String> existUserIds = ops.stream().map(OrderOperator::getUserId).collect(Collectors.toList());
|
||||
if (!existUserIds.isEmpty()) {
|
||||
query.notIn(EmergencyProfessionUser::getUserId, existUserIds);
|
||||
}
|
||||
excludeUserIds.addAll(ops.stream().map(OrderOperator::getUserId).collect(Collectors.toList()));
|
||||
}
|
||||
}
|
||||
Page<EmergencyProfessionUser> page = new Page<>(pageNo != null ? pageNo : 1, pageSize != null ? pageSize : 10);
|
||||
IPage<EmergencyProfessionUser> result = emergencyProfessionUserMapper.selectPage(page, query);
|
||||
// 批量查询系统用户信息,填充科室(部门)名称
|
||||
List<String> userIds = result.getRecords().stream()
|
||||
|
||||
// ---- 2. 查询 QH_EME_PROFESS_USER(急救专业人员) ----
|
||||
LambdaQueryWrapper<EmergencyProfessionUser> profQuery = new LambdaQueryWrapper<>();
|
||||
profQuery.eq(EmergencyProfessionUser::getType, "6");
|
||||
if (StrUtil.isNotBlank(realname)) {
|
||||
profQuery.like(EmergencyProfessionUser::getRealname, realname);
|
||||
}
|
||||
if (StrUtil.isNotBlank(centerId)) {
|
||||
profQuery.eq(EmergencyProfessionUser::getCenterId, centerId);
|
||||
}
|
||||
if (!excludeUserIds.isEmpty()) {
|
||||
profQuery.notIn(EmergencyProfessionUser::getUserId, excludeUserIds);
|
||||
}
|
||||
List<EmergencyProfessionUser> profUsers = emergencyProfessionUserMapper.selectList(profQuery);
|
||||
|
||||
// ---- 3. 查询 qh_con_doctor(咨询专家),排除已在 profUsers 或已在群中的 ----
|
||||
List<String> skipIds = new ArrayList<>(excludeUserIds);
|
||||
profUsers.forEach(u -> skipIds.add(u.getUserId()));
|
||||
List<EmergencyProfessionUser> doctorUsers = conDoctorMapper.searchDoctorByName(realname, skipIds);
|
||||
|
||||
// ---- 4. 合并两条结果(profUsers 优先,doctorUsers 追加) ----
|
||||
Map<String, EmergencyProfessionUser> mergedMap = new LinkedHashMap<>();
|
||||
for (EmergencyProfessionUser u : profUsers) {
|
||||
mergedMap.put(u.getUserId(), u);
|
||||
}
|
||||
// 从 qh_con_doctor 来的记录,不入 mergedMap 时用 doctorName 兜底 realname/avatar
|
||||
for (EmergencyProfessionUser u : doctorUsers) {
|
||||
mergedMap.putIfAbsent(u.getUserId(), u);
|
||||
}
|
||||
List<EmergencyProfessionUser> allRecords = new ArrayList<>(mergedMap.values());
|
||||
|
||||
// ---- 5. 批量查询 sys_user,统一填充 realname/avatar/phone/deptName ----
|
||||
List<String> allUserIds = allRecords.stream()
|
||||
.map(EmergencyProfessionUser::getUserId).collect(Collectors.toList());
|
||||
if (!userIds.isEmpty()) {
|
||||
Map<String, LoginUserNew> userMap = emergencyCloudManager.listUser(userIds);
|
||||
result.getRecords().forEach(prof -> {
|
||||
if (!allUserIds.isEmpty()) {
|
||||
Map<String, LoginUserNew> userMap = emergencyCloudManager.listUser(allUserIds);
|
||||
allRecords.forEach(prof -> {
|
||||
LoginUserNew sysUser = userMap.get(prof.getUserId());
|
||||
if (sysUser != null && StrUtil.isNotBlank(sysUser.getOrgCode())) {
|
||||
prof.setDeptName(emergencyCacheManager.getUserDepart(sysUser.getOrgCode()).getDepartName());
|
||||
}
|
||||
if (sysUser != null) {
|
||||
prof.setPhone(sysUser.getPhone());
|
||||
// 兜底:从 qh_con_doctor 来的记录没有 realname/avatar,用 sys_user 填充
|
||||
if (StrUtil.isBlank(prof.getRealname())) {
|
||||
prof.setRealname(sysUser.getRealname());
|
||||
}
|
||||
if (StrUtil.isBlank(prof.getAvatar())) {
|
||||
prof.setAvatar(sysUser.getAvatar());
|
||||
}
|
||||
if (StrUtil.isNotBlank(sysUser.getOrgCode())) {
|
||||
prof.setDeptName(emergencyCacheManager.getUserDepart(sysUser.getOrgCode()).getDepartName());
|
||||
}
|
||||
if (StrUtil.isBlank(prof.getPhone())) {
|
||||
prof.setPhone(sysUser.getPhone());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
// 批量查询 con_doctor 专家资料,补充专家字段
|
||||
if (!userIds.isEmpty()) {
|
||||
List<EmergencyProfessionUser> doctorList = conDoctorMapper.selectDoctorByIds(userIds);
|
||||
|
||||
// ---- 6. 对 profUsers 补充 qh_con_doctor 专家字段 ----
|
||||
List<String> profUserIds = profUsers.stream()
|
||||
.map(EmergencyProfessionUser::getUserId).collect(Collectors.toList());
|
||||
if (!profUserIds.isEmpty()) {
|
||||
List<EmergencyProfessionUser> doctorList = conDoctorMapper.selectDoctorByIds(profUserIds);
|
||||
if (CollectionUtils.isNotEmpty(doctorList)) {
|
||||
Map<String, EmergencyProfessionUser> doctorMap = doctorList.stream()
|
||||
.collect(Collectors.toMap(EmergencyProfessionUser::getUserId, e -> e, (a, b) -> a));
|
||||
result.getRecords().forEach(prof -> {
|
||||
profUsers.forEach(prof -> {
|
||||
EmergencyProfessionUser doc = doctorMap.get(prof.getUserId());
|
||||
if (doc == null) {
|
||||
return;
|
||||
}
|
||||
prof.setDoctorName(doc.getDoctorName());
|
||||
prof.setDoctorNo(doc.getDoctorNo());
|
||||
prof.setPhoto(doc.getPhoto());
|
||||
prof.setResourceName(doc.getResourceName());
|
||||
prof.setDepartmentId(doc.getDepartmentId());
|
||||
prof.setDepartmentName(doc.getDepartmentName());
|
||||
prof.setDoctorTitle(doc.getDoctorTitle());
|
||||
prof.setDoctorJob(doc.getDoctorJob());
|
||||
prof.setDoctorStatus(doc.getDoctorStatus());
|
||||
prof.setIsAccept(doc.getIsAccept());
|
||||
prof.setDoctorType(doc.getDoctorType());
|
||||
prof.setAudioStatus(doc.getAudioStatus());
|
||||
prof.setTfJumpHoliday(doc.getTfJumpHoliday());
|
||||
prof.setExperience(doc.getExperience());
|
||||
prof.setSort(doc.getSort());
|
||||
prof.setTfRecommend(doc.getTfRecommend());
|
||||
prof.setIntroduction(doc.getIntroduction());
|
||||
// 已有字段,con_doctor 有值时覆盖为更权威的专家资料
|
||||
if (StrUtil.isNotBlank(doc.getGoodAt())) prof.setGoodAt(doc.getGoodAt());
|
||||
if (StrUtil.isNotBlank(doc.getSchool())) prof.setSchool(doc.getSchool());
|
||||
if (StrUtil.isNotBlank(doc.getEdu())) prof.setEdu(doc.getEdu());
|
||||
if (doc == null) return;
|
||||
copyDoctorFields(doc, prof);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// ---- 7. 内存分页 ----
|
||||
int total = allRecords.size();
|
||||
int pn = pageNo != null ? pageNo : 1;
|
||||
int ps = pageSize != null ? pageSize : 10;
|
||||
int fromIndex = Math.min((pn - 1) * ps, total);
|
||||
int toIndex = Math.min(fromIndex + ps, total);
|
||||
List<EmergencyProfessionUser> pageRecords = allRecords.subList(fromIndex, toIndex);
|
||||
|
||||
IPage<EmergencyProfessionUser> result = new Page<>(pn, ps, total);
|
||||
result.setRecords(pageRecords);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void copyDoctorFields(EmergencyProfessionUser doc, EmergencyProfessionUser prof) {
|
||||
prof.setDoctorName(doc.getDoctorName());
|
||||
prof.setDoctorNo(doc.getDoctorNo());
|
||||
prof.setPhoto(doc.getPhoto());
|
||||
prof.setResourceName(doc.getResourceName());
|
||||
prof.setDepartmentId(doc.getDepartmentId());
|
||||
prof.setDepartmentName(doc.getDepartmentName());
|
||||
prof.setDoctorTitle(doc.getDoctorTitle());
|
||||
prof.setDoctorJob(doc.getDoctorJob());
|
||||
prof.setDoctorStatus(doc.getDoctorStatus());
|
||||
prof.setIsAccept(doc.getIsAccept());
|
||||
prof.setDoctorType(doc.getDoctorType());
|
||||
prof.setAudioStatus(doc.getAudioStatus());
|
||||
prof.setTfJumpHoliday(doc.getTfJumpHoliday());
|
||||
prof.setExperience(doc.getExperience());
|
||||
prof.setSort(doc.getSort());
|
||||
prof.setTfRecommend(doc.getTfRecommend());
|
||||
prof.setIntroduction(doc.getIntroduction());
|
||||
if (StrUtil.isNotBlank(doc.getGoodAt())) prof.setGoodAt(doc.getGoodAt());
|
||||
if (StrUtil.isNotBlank(doc.getSchool())) prof.setSchool(doc.getSchool());
|
||||
if (StrUtil.isNotBlank(doc.getEdu())) prof.setEdu(doc.getEdu());
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<EmployeeVO> searchEmployee(String realname, String orgCode, String workNo, String phone, String excludeSessionId, Integer pageNo, Integer pageSize) {
|
||||
// 收集需要在结果中排除的用户ID
|
||||
@@ -1045,25 +1088,44 @@ public class EmergencyOrderApiServiceImpl implements EmergencyOrderApiService {
|
||||
@Override
|
||||
public IPage<MyParticipatedOrderVO> myParticipatedOrders(Integer pageNo, Integer pageSize) {
|
||||
String userId = GlobalUtils.getLoginUser().getId();
|
||||
// 1. 查当前登录人参与的所有工单ID(去重)
|
||||
List<String> orderIds = orderOperatorMapper.selectList(
|
||||
// 1. 查当前登录人参与的工单ID(从order_operator表)
|
||||
List<String> participatedOrderIds = orderOperatorMapper.selectList(
|
||||
new LambdaQueryWrapper<OrderOperator>()
|
||||
.select(OrderOperator::getOrderId)
|
||||
.eq(OrderOperator::getUserId, userId)
|
||||
).stream().map(OrderOperator::getOrderId).distinct().collect(Collectors.toList());
|
||||
if (CollectionUtils.isEmpty(orderIds)) {
|
||||
|
||||
// 2. 查当前用户自己发起的或被救助的应急工单ID(从order表)
|
||||
List<String> ownOrderIds = orderMapper.selectList(
|
||||
new LambdaQueryWrapper<Order>()
|
||||
.select(Order::getId)
|
||||
.and(w -> w.eq(Order::getInitiatorUserId, userId).or().eq(Order::getSalvageUserId, userId))
|
||||
.eq(Order::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||
.eq(Order::getStatus, 1)
|
||||
).stream().map(Order::getId).distinct().collect(Collectors.toList());
|
||||
|
||||
// 3. 合并去重
|
||||
Set<String> allOrderIds = new LinkedHashSet<>();
|
||||
if (CollectionUtils.isNotEmpty(participatedOrderIds)) {
|
||||
allOrderIds.addAll(participatedOrderIds);
|
||||
}
|
||||
if (CollectionUtils.isNotEmpty(ownOrderIds)) {
|
||||
allOrderIds.addAll(ownOrderIds);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(allOrderIds)) {
|
||||
return new Page<>(pageNo != null ? pageNo : 1, pageSize != null ? pageSize : 10);
|
||||
}
|
||||
// 2. 查正在应急的工单
|
||||
|
||||
// 4. 分页查询正在应急的工单
|
||||
Page<Order> page = new Page<>(pageNo != null ? pageNo : 1, pageSize != null ? pageSize : 10);
|
||||
LambdaQueryWrapper<Order> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(Order::getId, orderIds);
|
||||
wrapper.in(Order::getId, new ArrayList<>(allOrderIds));
|
||||
wrapper.eq(Order::getSessionNow, true);
|
||||
wrapper.eq(Order::getDelFlag, CommonConstant.DEL_FLAG_0);
|
||||
wrapper.eq(Order::getStatus, 1);
|
||||
wrapper.orderByDesc(Order::getCreateTime);
|
||||
IPage<Order> srcPage = orderMapper.selectPage(page, wrapper);
|
||||
// 3. 映射VO
|
||||
// 5. 映射VO
|
||||
Page<MyParticipatedOrderVO> targetPage = new Page<>(srcPage.getCurrent(), srcPage.getSize(), srcPage.getTotal());
|
||||
if (CollectionUtils.isEmpty(srcPage.getRecords())) {
|
||||
return targetPage;
|
||||
|
||||
Reference in New Issue
Block a user