Merge branch 'develop' of https://gitea.gentronhealth.com/wangyizhe/his into develop
This commit is contained in:
@@ -464,17 +464,86 @@ public class CommonServiceImpl implements ICommonService {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<LocationDto> getPractitionerWard() {
|
public List<LocationDto> getPractitionerWard() {
|
||||||
// 查询当前登录者管理的病区
|
// 获取当前登录用户信息
|
||||||
Long practitionerId = SecurityUtils.getLoginUser().getPractitionerId();
|
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<Long> locationIds = practitionerRoleService.getLocationIdsByPractitionerId(practitionerId);
|
||||||
List<Location> locationList
|
// 获取用户配置的科室 ID 列表
|
||||||
= locationService.getLocationList(locationIds, Collections.singletonList(LocationStatus.ACTIVE.getValue()));
|
List<Long> orgIds = practitionerRoleService.getOrgIdsByPractitionerId(practitionerId);
|
||||||
|
|
||||||
|
log.info("getPractitionerWard - locationIds: {}, orgIds: {}", locationIds, orgIds);
|
||||||
|
|
||||||
List<Location> wardList = new ArrayList<>();
|
List<Location> wardList = new ArrayList<>();
|
||||||
for (Location ward : locationList) {
|
|
||||||
if (LocationForm.WARD.getValue().equals(ward.getFormEnum())) {
|
// 方式 1:从 locationIds 中过滤出病区
|
||||||
wardList.add(ward);
|
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<>();
|
List<LocationDto> locationDtoList = new ArrayList<>();
|
||||||
LocationDto locationDto;
|
LocationDto locationDto;
|
||||||
for (Location ward : wardList) {
|
for (Location ward : wardList) {
|
||||||
@@ -482,6 +551,31 @@ public class CommonServiceImpl implements ICommonService {
|
|||||||
BeanUtils.copyProperties(ward, locationDto);
|
BeanUtils.copyProperties(ward, locationDto);
|
||||||
locationDtoList.add(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;
|
return locationDtoList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -202,8 +202,8 @@ public class CommonAppController {
|
|||||||
* @return 病区列表
|
* @return 病区列表
|
||||||
*/
|
*/
|
||||||
@GetMapping(value = "/practitioner-ward")
|
@GetMapping(value = "/practitioner-ward")
|
||||||
public List<LocationDto> getPractitionerWard() {
|
public R<?> getPractitionerWard() {
|
||||||
return commonService.getPractitionerWard();
|
return R.ok(commonService.getPractitionerWard());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -206,3 +206,14 @@ export function getAllWards(params = {}) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前登录用户有权限管理的病区
|
||||||
|
*/
|
||||||
|
export function getPractitionerWard(queryParams) {
|
||||||
|
return request({
|
||||||
|
url: '/app-common/practitioner-ward',
|
||||||
|
method: 'get',
|
||||||
|
params: queryParams,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -202,7 +202,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {
|
import {
|
||||||
diagnosisInit,
|
diagnosisInit,
|
||||||
getAllWards,
|
getPractitionerWard,
|
||||||
getBedInfo,
|
getBedInfo,
|
||||||
getContractList,
|
getContractList,
|
||||||
getDiagnosisDefinitionList,
|
getDiagnosisDefinitionList,
|
||||||
@@ -427,13 +427,13 @@ function getInitOptions() {
|
|||||||
// 获取所有科室
|
// 获取所有科室
|
||||||
const orgPromise = getOrgList();
|
const orgPromise = getOrgList();
|
||||||
// 获取所有病区
|
// 获取所有病区
|
||||||
const wardPromise = getAllWards();
|
const wardPromise = getPractitionerWard();
|
||||||
|
|
||||||
Promise.all([orgPromise, wardPromise]).then(([orgRes, wardRes]) => {
|
Promise.all([orgPromise, wardPromise]).then(([orgRes, wardRes]) => {
|
||||||
const allOrgs = orgRes.data.records.filter(
|
const allOrgs = orgRes.data.records.filter(
|
||||||
(record) => record.typeEnum === 2 && checkClassEnumValue(record.classEnum, 2)
|
(record) => record.typeEnum === 2 && checkClassEnumValue(record.classEnum, 2)
|
||||||
);
|
);
|
||||||
const allWards = wardRes.data.records || [];
|
const allWards = wardRes.data || [];
|
||||||
|
|
||||||
// 提取所有病区关联的科室ID
|
// 提取所有病区关联的科室ID
|
||||||
const linkedOrgIds = new Set();
|
const linkedOrgIds = new Set();
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ import Filter from '@/components/TableLayout/Filter.vue';
|
|||||||
import {computed, onBeforeMount, onMounted, reactive, ref} from 'vue';
|
import {computed, onBeforeMount, onMounted, reactive, ref} from 'vue';
|
||||||
import TransferInDialog from './transferInDialog.vue';
|
import TransferInDialog from './transferInDialog.vue';
|
||||||
import SignEntryDialog from './signEntryDialog.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 {ElLoading, ElMessage, ElMessageBox} from 'element-plus';
|
||||||
import PendingPatientList from '@/components/PendingPatientList/index.vue';
|
import PendingPatientList from '@/components/PendingPatientList/index.vue';
|
||||||
|
|
||||||
@@ -233,8 +233,8 @@ const ininData = async () => {
|
|||||||
priorityOptions.value = initRes.data.priorityOptions || [];
|
priorityOptions.value = initRes.data.priorityOptions || [];
|
||||||
|
|
||||||
// 然后获取病区数据(使用与病区管理页面相同的接口)
|
// 然后获取病区数据(使用与病区管理页面相同的接口)
|
||||||
const wardRes = await getWardList({ pageNum: 1, pageSize: 50, formEnum: 4 });
|
const wardRes = await getPractitionerWard();
|
||||||
const wardList = wardRes.data?.records || [];
|
const wardList = wardRes.data || [];
|
||||||
selectHosLoding.value = false;
|
selectHosLoding.value = false;
|
||||||
queryParams.value.wardId = wardList[0]?.id || '';
|
queryParams.value.wardId = wardList[0]?.id || '';
|
||||||
initInfoOptions.value.wardListOptions = wardList;
|
initInfoOptions.value.wardListOptions = wardList;
|
||||||
|
|||||||
Reference in New Issue
Block a user