diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/CabinetLocationController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/CabinetLocationController.java new file mode 100644 index 00000000..aa5d0cc1 --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/CabinetLocationController.java @@ -0,0 +1,141 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.basedatamanage.controller; + +import java.util.Arrays; +import java.util.HashSet; + +import javax.servlet.http.HttpServletRequest; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.core.common.core.domain.R; +import com.core.common.utils.MessageUtils; +import com.core.common.utils.bean.BeanUtils; +import com.openhis.administration.domain.Location; +import com.openhis.administration.mapper.LocationMapper; +import com.openhis.administration.service.ILocationService; +import com.openhis.common.constant.PromptMsgConstant; +import com.openhis.common.enums.LocationForm; +import com.openhis.common.utils.HisPageUtils; +import com.openhis.common.utils.HisQueryUtils; +import com.openhis.web.basedatamanage.dto.LocationQueryDto; +import com.openhis.web.basedatamanage.dto.LocationQueryParam; + +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; + +/** + * 位置管理Controller业务层处理 + * + * @author + * @date 2025-02-21 + */ +@RestController +@RequestMapping("/basedatamanage/cabinet-location") +@Slf4j +@AllArgsConstructor +public class CabinetLocationController { + + private final ILocationService locationService; + + @Autowired + private LocationMapper locationMapper; + + /** + * 位置分页列表 + * + * @param locationQueryParam 查询字段 + * @param searchKey 模糊查询关键字 + * @param pageNo 当前页码 + * @param pageSize 查询条数 + * @param request 请求数据 + * @return 位置分页列表 + */ + @GetMapping(value = "/cabinet-location") + public R getLocationPage(LocationQueryParam locationQueryParam, + @RequestParam(value = "searchKey", defaultValue = "") String searchKey, + @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) { + + // 构建查询条件 + QueryWrapper queryWrapper = HisQueryUtils.buildQueryWrapper(locationQueryParam, searchKey, + new HashSet<>(Arrays.asList("name", "py_str", "wb_str")), request); + + // 设置排序 + queryWrapper.orderByDesc("create_time"); + // 执行分页查询并转换为 locationQueryDtoPage + Page locationQueryDtoPage = + HisPageUtils.selectPage(locationMapper, queryWrapper, pageNo, pageSize, LocationQueryDto.class); + + return R.ok(locationQueryDtoPage, + MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] {"位置信息"})); + } + + /** + * 添加库房位置信息 + * + * @param locationQueryDto 位置信息 + */ + @PostMapping("/cabinet-location") + public R addLocation(@Validated @RequestBody LocationQueryDto locationQueryDto) { + + LocationQueryDto locationQuery = new LocationQueryDto(LocationForm.CABINET); + Location location = new Location(); + BeanUtils.copyProperties(locationQuery, location); + + boolean saveLocationSuccess = locationService.save(location); + + return saveLocationSuccess + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00001, new Object[] {"位置信息"})) + : R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00003, new Object[] {"位置信息"})); + } + + /** + * 获取位置需要编辑的信息 + * + * @param locationId 位置信息 + */ + @GetMapping("/cabinet-location-editById") + public R getLocationById(@Validated @RequestParam Long locationId) { + + Location location = locationService.getById(locationId); + return R.ok(location, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"位置信息"})); + } + + /** + * 编辑位置信息 + * + * @param location 位置信息 + */ + @PutMapping("/cabinet-location") + public R editLocation(@Validated @RequestBody Location location) { + + boolean updateLocationSuccess = locationService.updateById(location); + + return updateLocationSuccess + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00002, new Object[] {"位置信息"})) + : R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00007, new Object[] {"位置信息"})); + } + + /** + * 删除位置信息 + * + * @param locationId 主表id + */ + @DeleteMapping("/cabinet-location") + public R deleteLocation(@RequestParam Long locationId) { + + boolean deleteLocationSuccess = locationService.removeById(locationId); + + return deleteLocationSuccess + ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] {"位置信息"})) + : R.fail(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00006, new Object[] {"位置信息"})); + } + +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java index 33a7ba03..f551b232 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/controller/OrganizationController.java @@ -77,7 +77,7 @@ public class OrganizationController { * @return 机构分页列表 */ @GetMapping(value = "/organization") - public R getOrganizationPage(@RequestBody OrgQueryParam orgQueryParam, + public R getOrganizationPage(OrgQueryParam orgQueryParam, @RequestParam(value = "searchKey", defaultValue = "") String searchKey, @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) { diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/LocationQueryDto.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/LocationQueryDto.java new file mode 100644 index 00000000..3fd2b5a0 --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/LocationQueryDto.java @@ -0,0 +1,67 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.basedatamanage.dto; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableId; +import com.openhis.common.enums.*; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * @author + * @date 2025-02-21 + */ +@Data +@Accessors(chain = true) +public class LocationQueryDto { + + /** ID */ + @TableId(type = IdType.ASSIGN_ID) + private Long id; + + /** 编码 */ + private String busNo; + + /** 名称 */ + private String name; + + /** 状态编码 */ + private LocationStatus statusEnum; + + /** 操作状态 */ + private LocationBedStatus operationalEnum; + + /** 模式编码 */ + private LocationMode modeEnum; + + /** 模式编码 */ + private String typeCode; + + /** 功能编码 */ + private String typeJson; + + /** 拼音码 */ + private String pyStr; + + /** 五笔码 */ + private String wbStr; + + /** 物理形式枚举 */ + private LocationForm formEnum; + + /** 机构编码 */ + private Long organizationId; + + /** 显示顺序 */ + private Integer displayOrder; + +// public LocationQueryDto(LocationForm form, String busNo, LocationMode mode) { + public LocationQueryDto(LocationForm form) { + this.statusEnum = LocationStatus.ACTIVE; + this.formEnum = form; +// this.modeEnum = mode; + } +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/LocationQueryParam.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/LocationQueryParam.java new file mode 100644 index 00000000..97f71502 --- /dev/null +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/LocationQueryParam.java @@ -0,0 +1,25 @@ +/* + * Copyright ©2023 CJB-CNIT Team. All rights reserved + */ +package com.openhis.web.basedatamanage.dto; + +import java.io.Serializable; + +import com.openhis.common.enums.LocationMode; + +import lombok.Data; +import lombok.experimental.Accessors; + +/** + * 科室分页查询条件 + * + * @author + * @date 2025-02-21 + */ +@Data +@Accessors(chain = true) +public class LocationQueryParam implements Serializable { + /** 模式编码 */ + private LocationMode modeEnum; + +} diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/OrganizationQueryDto.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/OrganizationQueryDto.java index 9f092423..1525cd94 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/OrganizationQueryDto.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/dto/OrganizationQueryDto.java @@ -3,6 +3,9 @@ */ package com.openhis.web.basedatamanage.dto; +import java.util.ArrayList; +import java.util.List; + import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.openhis.common.enums.OrganizationClass; @@ -52,4 +55,7 @@ public class OrganizationQueryDto { /** 显示顺序 */ private Integer displayOrder; + + List children = new ArrayList<>(); + }