Merge branch 'develop' of https://gitea.gentronhealth.com/wangyizhe/his into develop

This commit is contained in:
2026-03-12 14:56:13 +08:00
5 changed files with 119 additions and 14 deletions

View File

@@ -464,17 +464,86 @@ public class CommonServiceImpl implements ICommonService {
*/
@Override
public List<LocationDto> getPractitionerWard() {
// 查询当前登录者管理的病区
// 获取当前登录用户信息
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
Long currentOrgId = SecurityUtils.getLoginUser().getOrgId();
log.info("getPractitionerWard - practitionerId: {}, currentOrgId: {}", practitionerId, currentOrgId);
// 获取用户配置的位置 ID 列表(可能包含科室、病区等)
List<Long> locationIds = practitionerRoleService.getLocationIdsByPractitionerId(practitionerId);
List<Location> locationList
= locationService.getLocationList(locationIds, Collections.singletonList(LocationStatus.ACTIVE.getValue()));
// 获取用户配置的科室 ID 列表
List<Long> orgIds = practitionerRoleService.getOrgIdsByPractitionerId(practitionerId);
log.info("getPractitionerWard - locationIds: {}, orgIds: {}", locationIds, orgIds);
List<Location> wardList = new ArrayList<>();
for (Location ward : locationList) {
if (LocationForm.WARD.getValue().equals(ward.getFormEnum())) {
wardList.add(ward);
// 方式 1从 locationIds 中过滤出病区
if (locationIds != null && !locationIds.isEmpty()) {
// 过滤掉 null 值
locationIds = locationIds.stream().filter(id -> id != null).collect(java.util.stream.Collectors.toList());
if (!locationIds.isEmpty()) {
List<Location> locationList
= locationService.getLocationList(locationIds, Collections.singletonList(LocationStatus.ACTIVE.getValue()));
log.info("getPractitionerWard - 从 locationIds 查询到的位置总数:{}", locationList != null ? locationList.size() : 0);
for (Location location : locationList) {
log.info("getPractitionerWard - 位置id={}, name={}, formEnum={}, organizationId={}",
location.getId(), location.getName(), location.getFormEnum(), location.getOrganizationId());
if (LocationForm.WARD.getValue().equals(location.getFormEnum())) {
// 如果当前有选择科室,只添加当前科室的病区
if (currentOrgId == null || currentOrgId.equals(location.getOrganizationId())) {
wardList.add(location);
}
}
}
}
}
// 方式 2从 orgIds 查询病区(补充查询,确保能获取到病区)
if (orgIds != null && !orgIds.isEmpty()) {
// 过滤掉 null 值并去重
orgIds = orgIds.stream().filter(id -> id != null).distinct().collect(java.util.stream.Collectors.toList());
if (!orgIds.isEmpty()) {
log.info("getPractitionerWard - 从 orgIds 查询病区orgIds: {}", orgIds);
for (Long orgId : orgIds) {
// 如果当前有选择科室,只查询当前科室的病区
if (currentOrgId != null && !currentOrgId.equals(orgId)) {
continue;
}
List<Location> orgWards = locationService.getWardList(orgId);
log.info("getPractitionerWard - orgId: {} 查询到病区数:{}", orgId, orgWards != null ? orgWards.size() : 0);
if (orgWards != null && !orgWards.isEmpty()) {
wardList.addAll(orgWards);
}
}
}
}
// 方式 3如果仍然没有病区且 currentOrgId 为空,尝试获取所有病区
if (wardList.isEmpty() && currentOrgId == null) {
log.info("getPractitionerWard - 尝试获取所有病区");
List<Location> allWards = locationService.getWardList(null);
log.info("getPractitionerWard - 所有病区数:{}", allWards != null ? allWards.size() : 0);
if (allWards != null && !allWards.isEmpty()) {
wardList.addAll(allWards);
}
}
// 去重:根据病区 ID 去重(因为方式 1 和方式 2 可能会查询到相同的病区)
if (!wardList.isEmpty()) {
wardList = wardList.stream()
.collect(java.util.stream.Collectors.collectingAndThen(
java.util.stream.Collectors.toCollection(() ->
new java.util.TreeSet<>(java.util.Comparator.comparing(Location::getId))),
ArrayList::new
));
}
log.info("getPractitionerWard - 最终病区数:{}", wardList.size());
// 转换为 DTO
List<LocationDto> locationDtoList = new ArrayList<>();
LocationDto locationDto;
for (Location ward : wardList) {
@@ -482,6 +551,31 @@ public class CommonServiceImpl implements ICommonService {
BeanUtils.copyProperties(ward, locationDto);
locationDtoList.add(locationDto);
}
return locationDtoList;
}
/**
* 将Location列表转换为LocationDto列表
*
* @param locationList Location列表
* @return LocationDto列表
*/
private List<LocationDto> convertToLocationDtoList(List<Location> locationList) {
List<LocationDto> locationDtoList = new ArrayList<>();
if (locationList == null || locationList.isEmpty()) {
return locationDtoList;
}
LocationDto locationDto;
for (Location location : locationList) {
// 只返回病区类型的位置
if (LocationForm.WARD.getValue().equals(location.getFormEnum())) {
locationDto = new LocationDto();
BeanUtils.copyProperties(location, locationDto);
locationDtoList.add(locationDto);
}
}
return locationDtoList;
}

View File

@@ -202,8 +202,8 @@ public class CommonAppController {
* @return 病区列表
*/
@GetMapping(value = "/practitioner-ward")
public List<LocationDto> getPractitionerWard() {
return commonService.getPractitionerWard();
public R<?> getPractitionerWard() {
return R.ok(commonService.getPractitionerWard());
}
/**

View File

@@ -206,3 +206,14 @@ export function getAllWards(params = {}) {
},
});
}
/**
* 获取当前登录用户有权限管理的病区
*/
export function getPractitionerWard(queryParams) {
return request({
url: '/app-common/practitioner-ward',
method: 'get',
params: queryParams,
});
}

View File

@@ -202,7 +202,7 @@
<script setup>
import {
diagnosisInit,
getAllWards,
getPractitionerWard,
getBedInfo,
getContractList,
getDiagnosisDefinitionList,
@@ -427,13 +427,13 @@ function getInitOptions() {
// 获取所有科室
const orgPromise = getOrgList();
// 获取所有病区
const wardPromise = getAllWards();
const wardPromise = getPractitionerWard();
Promise.all([orgPromise, wardPromise]).then(([orgRes, wardRes]) => {
const allOrgs = orgRes.data.records.filter(
(record) => record.typeEnum === 2 && checkClassEnumValue(record.classEnum, 2)
);
const allWards = wardRes.data.records || [];
const allWards = wardRes.data || [];
// 提取所有病区关联的科室ID
const linkedOrgIds = new Set();

View File

@@ -89,7 +89,7 @@ import Filter from '@/components/TableLayout/Filter.vue';
import {computed, onBeforeMount, onMounted, reactive, ref} from 'vue';
import TransferInDialog from './transferInDialog.vue';
import SignEntryDialog from './signEntryDialog.vue';
import {childLocationList, getBedInfo, getInit, getPendingInfo, getWardList} from './api';
import {childLocationList, getBedInfo, getInit, getPendingInfo, getPractitionerWard} from './api';
import {ElLoading, ElMessage, ElMessageBox} from 'element-plus';
import PendingPatientList from '@/components/PendingPatientList/index.vue';
@@ -233,8 +233,8 @@ const ininData = async () => {
priorityOptions.value = initRes.data.priorityOptions || [];
// 然后获取病区数据(使用与病区管理页面相同的接口)
const wardRes = await getWardList({ pageNum: 1, pageSize: 50, formEnum: 4 });
const wardList = wardRes.data?.records || [];
const wardRes = await getPractitionerWard();
const wardList = wardRes.data || [];
selectHosLoding.value = false;
queryParams.value.wardId = wardList[0]?.id || '';
initInfoOptions.value.wardListOptions = wardList;