diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/IOrganizationAppService.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/IOrganizationAppService.java index bb0fc11e..4027d38e 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/IOrganizationAppService.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/IOrganizationAppService.java @@ -3,7 +3,6 @@ package com.openhis.web.basedatamanage.appservice; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.core.domain.R; import com.openhis.web.basedatamanage.dto.OrganizationDto; -import org.springframework.web.bind.annotation.RequestParam; import javax.servlet.http.HttpServletRequest; import java.util.List; @@ -15,18 +14,19 @@ public interface IOrganizationAppService { /** * 查询机构树 * - * @param pageNo 当前页码 - * @param pageSize 查询条数 - * @param name 科室名称 - * @param typeEnum 科室类型 + * @param pageNo 当前页码 + * @param pageSize 查询条数 + * @param name 科室名称 + * @param typeEnum 科室类型 * @param classEnumList 科室分类列表(逗号分隔的值) - * @param sortField 排序字段 - * @param sortOrder 排序方向 - * @param request 请求数据 + * @param sortField 排序字段 + * @param sortOrder 排序方向 + * @param request 请求数据 * @return 机构树分页列表 */ - Page getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, List classEnumList, - String sortField, String sortOrder, HttpServletRequest request); + Page getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, + List classEnumList, + String sortField, String sortOrder, HttpServletRequest request); /** * 机构信息详情 @@ -71,9 +71,12 @@ public interface IOrganizationAppService { /** * 获取挂号科室列表 * + * @param pageNum 当前页码 + * @param pageSize 查询条数 + * @param name 机构/科室名称 + * @param orgName 机构名称 * @return 挂号科室列表 */ - R getRegisterOrganizations(@RequestParam(required = false) String name, - @RequestParam(required = false) String orgName); + R getRegisterOrganizations(Integer pageNum, Integer pageSize, String name, String orgName); } diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java index dd4f7a62..5c50cccf 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java @@ -1,7 +1,6 @@ package com.openhis.web.basedatamanage.appservice.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.OrderItem; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.core.domain.R; import com.core.common.utils.AssignSeqUtil; @@ -20,7 +19,6 @@ import com.openhis.web.basedatamanage.appservice.IOrganizationAppService; import com.openhis.web.basedatamanage.dto.OrganizationDto; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; -import org.springframework.web.bind.annotation.RequestParam; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -28,8 +26,6 @@ import java.lang.reflect.Field; import java.util.*; import java.util.stream.Collectors; -import static com.baomidou.mybatisplus.core.toolkit.StringUtils.camelToUnderline; - @Service public class OrganizationAppServiceImpl implements IOrganizationAppService { @@ -40,8 +36,9 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { private AssignSeqUtil assignSeqUtil; @Override - public Page getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, List classEnumList, - String sortField, String sortOrder, HttpServletRequest request) { + public Page getOrganizationTree(Integer pageNo, Integer pageSize, String name, Integer typeEnum, + List classEnumList, + String sortField, String sortOrder, HttpServletRequest request) { // 使用Page对象进行分页查询 Page page = new Page<>(pageNo, pageSize); @@ -64,24 +61,24 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { if (i == 0) { // 第一个条件 wrapper.and(subWrapper -> { - subWrapper.eq(Organization::getClassEnum, classEnum) // 精确匹配 - .or() // 或者 - .likeRight(Organization::getClassEnum, classEnum + ",") // 以"值,"开头 - .or() // 或者 - .likeLeft(Organization::getClassEnum, "," + classEnum) // 以",值"结尾 - .or() // 或者 - .like(Organization::getClassEnum, "," + classEnum + ","); // 在中间,被逗号包围 + subWrapper.eq(Organization::getClassEnum, classEnum) // 精确匹配 + .or() // 或者 + .likeRight(Organization::getClassEnum, classEnum + ",") // 以"值,"开头 + .or() // 或者 + .likeLeft(Organization::getClassEnum, "," + classEnum) // 以",值"结尾 + .or() // 或者 + .like(Organization::getClassEnum, "," + classEnum + ","); // 在中间,被逗号包围 }); } else { // 后续条件使用OR连接 wrapper.or(subWrapper -> { - subWrapper.eq(Organization::getClassEnum, classEnum) // 精确匹配 - .or() // 或者 - .likeRight(Organization::getClassEnum, classEnum + ",") // 以"值,"开头 - .or() // 或者 - .likeLeft(Organization::getClassEnum, "," + classEnum) // 以",值"结尾 - .or() // 或者 - .like(Organization::getClassEnum, "," + classEnum + ","); // 在中间,被逗号包围 + subWrapper.eq(Organization::getClassEnum, classEnum) // 精确匹配 + .or() // 或者 + .likeRight(Organization::getClassEnum, classEnum + ",") // 以"值,"开头 + .or() // 或者 + .likeLeft(Organization::getClassEnum, "," + classEnum) // 以",值"结尾 + .or() // 或者 + .like(Organization::getClassEnum, "," + classEnum + ","); // 在中间,被逗号包围 }); } } @@ -114,7 +111,7 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { private List buildTree(List records) { // 按b_no的层级排序,确保父节点先处理 List sortedRecords = records.stream() - .sorted(Comparator.comparingInt(r -> r.getBusNo().split("\\.").length)).collect(Collectors.toList()); + .sorted(Comparator.comparingInt(r -> r.getBusNo().split("\\.").length)).collect(Collectors.toList()); Map nodeMap = new HashMap<>(); List tree = new ArrayList<>(); @@ -159,17 +156,20 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { public R getOrgInfo(Long orgId) { Organization organization = organizationService.getById(orgId); if (organization == null) { - return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00006, new Object[] {"机构信息"})); + return R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00006, new Object[] { "机构信息" })); } - + // 转换为DTO对象,确保数据格式一致 OrganizationDto organizationDto = new OrganizationDto(); BeanUtils.copyProperties(organization, organizationDto); - organizationDto.setTypeEnum_dictText(EnumUtils.getInfoByValue(OrganizationType.class, organizationDto.getTypeEnum())); + organizationDto + .setTypeEnum_dictText(EnumUtils.getInfoByValue(OrganizationType.class, organizationDto.getTypeEnum())); organizationDto.setClassEnum_dictText(formatClassEnumDictText(organizationDto.getClassEnum())); - organizationDto.setActiveFlag_dictText(EnumUtils.getInfoByValue(AccountStatus.class, organizationDto.getActiveFlag())); - - return R.ok(organizationDto, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息查询"})); + organizationDto + .setActiveFlag_dictText(EnumUtils.getInfoByValue(AccountStatus.class, organizationDto.getActiveFlag())); + + return R.ok(organizationDto, + MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] { "机构信息查询" })); } /** @@ -196,7 +196,7 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { // 如果传了上级科室 把当前的code拼到后边 if (StringUtils.isNotEmpty(organization.getBusNo())) { organization.setBusNo(String.format(CommonConstants.Common.MONTAGE_FORMAT, organization.getBusNo(), - CommonConstants.Common.POINT, code)); + CommonConstants.Common.POINT, code)); } else { organization.setBusNo(code); } @@ -205,7 +205,7 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { } // 返回机构id return R.ok(organization.getId(), - MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息更新添加"})); + MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] { "机构信息更新添加" })); } /** @@ -225,8 +225,8 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { // 删除机构信息 boolean deleteOrgSuccess = organizationService.removeByIds(orgIdList); return deleteOrgSuccess - ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] {"机构信息"})) - : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息"})); + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] { "机构信息" })) + : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] { "机构信息" })); } /** @@ -239,8 +239,9 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { public R activeOrg(Long orgId) { // 机构启用 boolean result = organizationService.activeOrg(orgId); - return result ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息启用"})) - : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息启用"})); + return result + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] { "机构信息启用" })) + : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] { "机构信息启用" })); } /** @@ -253,8 +254,9 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { public R inactiveOrg(Long orgId) { // 机构停用 boolean result = organizationService.inactiveOrg(orgId); - return result ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"机构信息停用"})) - : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"机构信息停用"})); + return result + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] { "机构信息停用" })) + : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] { "机构信息停用" })); } /** @@ -289,27 +291,41 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { /** * 获取挂号科室列表 * - * @param name 机构/科室名称 - * @param orgName 机构名称 + * @param pageNo 当前页码 + * @param pageSize 查询条数 + * @param name 机构/科室名称 + * @param orgName 机构名称 * @return 挂号科室列表 */ @Override - public R getRegisterOrganizations(@RequestParam(required = false) String name, - @RequestParam(required = false) String orgName) { + public R getRegisterOrganizations(Integer pageNo, Integer pageSize, String name, String orgName) { + // 使用Page对象进行分页查询 + Page page = new Page<>(pageNo != null ? pageNo : 1, pageSize != null ? pageSize : 10); + // 创建查询条件,只查询register_flag为1的组织机构 LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(Organization::getRegisterFlag, 1); // 只获取挂号科室 + queryWrapper.eq(Organization::getDeleteFlag, "0"); // 确保未删除 // 添加名称过滤条件 if (StringUtils.isNotEmpty(name)) { queryWrapper.like(Organization::getName, name); } - // 执行查询 - List organizationList = organizationService.list(queryWrapper); + // 如果有机构名称筛选 + if (StringUtils.isNotEmpty(orgName)) { + // 这里假设 orgName 是父机构名称,如果需要更复杂的关联查询可在此扩展 + // 当前逻辑暂保持与原逻辑一致的过滤方式或根据需求调整 + } + + // 按编码排序 + queryWrapper.orderByAsc(Organization::getBusNo); + + // 执行分页查询 + Page resultPage = organizationService.page(page, queryWrapper); // 转换为DTO对象并设置字典文本 - List organizationDtoList = organizationList.stream().map(org -> { + List organizationDtoList = resultPage.getRecords().stream().map(org -> { OrganizationDto dto = new OrganizationDto(); BeanUtils.copyProperties(org, dto); dto.setTypeEnum_dictText(EnumUtils.getInfoByValue(OrganizationType.class, dto.getTypeEnum())); @@ -318,7 +334,14 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { return dto; }).collect(Collectors.toList()); - return R.ok(organizationDtoList); + // 创建返回分页对象 + Page finalResult = new Page<>(); + finalResult.setRecords(organizationDtoList); + finalResult.setTotal(resultPage.getTotal()); + finalResult.setSize(resultPage.getSize()); + finalResult.setCurrent(resultPage.getCurrent()); + + return R.ok(finalResult); } /** diff --git a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java index 9d9b38f0..3fc8f573 100644 --- a/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java +++ b/openhis-server-new/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java @@ -42,24 +42,24 @@ public class OrganizationController { /** * 机构分页列表 * - * @param pageNo 当前页码 - * @param pageSize 查询条数 - * @param name 科室名称 - * @param typeEnum 科室类型 + * @param pageNo 当前页码 + * @param pageSize 查询条数 + * @param name 科室名称 + * @param typeEnum 科室类型 * @param classEnum 科室分类(支持多选,逗号分隔) * @param sortField 排序字段 * @param sortOrder 排序方向 - * @param request 请求对象 + * @param request 请求对象 * @return 机构分页列表 */ @GetMapping(value = "/organization") public R getOrganizationPage(@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(value = "pageSize", defaultValue = "100") Integer pageSize, - @RequestParam(value = "name", required = false) String name, - @RequestParam(value = "typeEnum", required = false) Integer typeEnum, - @RequestParam(value = "classEnum", required = false) String classEnum, - @RequestParam(value = "sortField", required = false) String sortField, - @RequestParam(value = "sortOrder", required = false) String sortOrder, HttpServletRequest request) { + @RequestParam(value = "pageSize", defaultValue = "100") Integer pageSize, + @RequestParam(value = "name", required = false) String name, + @RequestParam(value = "typeEnum", required = false) Integer typeEnum, + @RequestParam(value = "classEnum", required = false) String classEnum, + @RequestParam(value = "sortField", required = false) String sortField, + @RequestParam(value = "sortOrder", required = false) String sortOrder, HttpServletRequest request) { // 解析classEnum参数,支持逗号分隔的多个值 List classEnumList = null; @@ -67,10 +67,10 @@ public class OrganizationController { classEnumList = Arrays.asList(classEnum.split(",")); } - Page organizationTree = - iOrganizationAppService.getOrganizationTree(pageNo, pageSize, name, typeEnum, classEnumList, sortField, sortOrder, request); + Page organizationTree = iOrganizationAppService.getOrganizationTree(pageNo, pageSize, name, + typeEnum, classEnumList, sortField, sortOrder, request); return R.ok(organizationTree, - MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] {"机构信息"})); + MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] { "机构信息" })); } /** @@ -133,14 +133,18 @@ public class OrganizationController { /** * 获取挂号科室列表 * - * @param name 机构/科室名称 - * @param orgName 机构名称 + * @param pageNum 当前页码 + * @param pageSize 查询条数 + * @param name 机构/科室名称 + * @param orgName 机构名称 * @return 挂号科室列表 */ @GetMapping("/register-organizations") - public R getRegisterOrganizations(@RequestParam(required = false) String name, - @RequestParam(required = false) String orgName) { - return iOrganizationAppService.getRegisterOrganizations(name, orgName); + public R getRegisterOrganizations(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, + @RequestParam(required = false) String name, + @RequestParam(required = false) String orgName) { + return iOrganizationAppService.getRegisterOrganizations(pageNum, pageSize, name, orgName); } } diff --git a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue index 5a374a4a..df3ae4ad 100644 --- a/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue +++ b/openhis-ui-vue3/src/views/appoinmentmanage/deptManage/index.vue @@ -1,375 +1,376 @@ -