From b4e3b8ef2b25d8fae72a0e83a25076185f9343b7 Mon Sep 17 00:00:00 2001 From: anxin Date: Thu, 13 Mar 2025 10:56:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8D=E7=BD=AE=E6=A0=BC=E5=BC=8F=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../appservice/ILocationAppService.java | 36 ++++++++- .../impl/LocationAppServiceImpl.java | 74 +++++++++++++++++-- .../impl/OrganizationAppServiceImpl.java | 3 + .../controller/CabinetLocationController.java | 69 ++--------------- .../administration/domain/Location.java | 37 +++++----- 5 files changed, 128 insertions(+), 91 deletions(-) diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/ILocationAppService.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/ILocationAppService.java index d67ce973..01efb47e 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/ILocationAppService.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/ILocationAppService.java @@ -1,13 +1,45 @@ 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.LocationQueryDto; /** * Location 应该服务类 */ public interface ILocationAppService { - // 查询位置树 - Page getLocationTree(Integer formKey, Integer pageNo, Integer pageSize); + /** + * 位置信息 + * + * @param formKey 查询条件 + * @param pageNo 当前页码 + * @param pageSize 查询条数 + * @return 位置信息分页列表 + */ + R getLocationTree(Integer formKey, Integer pageNo, Integer pageSize); + + /** + * 位置信息详情 + * + * @param locationId 位置信息id + * @return 位置信息详情 + */ + R getLocationById(Long locationId); + + /** + * 添加/编辑位置信息 + * + * @param locationQueryDto 位置信息 + * @return 操作结果 + */ + R addOrEditInventoryReceipt(LocationQueryDto locationQueryDto); + + /** + * 删除位置信息 + * + * @param locationId 位置信息id + * @return 操作结果 + */ + R deleteLocation(Long locationId); } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/LocationAppServiceImpl.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/LocationAppServiceImpl.java index 3e2baf0a..09d9c9ed 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/LocationAppServiceImpl.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/LocationAppServiceImpl.java @@ -5,17 +5,20 @@ import java.util.stream.Collectors; import javax.annotation.Resource; -import com.openhis.common.enums.LocationBedStatus; -import com.openhis.common.enums.LocationMode; -import com.openhis.common.enums.LocationStatus; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; 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.openhis.administration.domain.Location; import com.openhis.administration.service.ILocationService; +import com.openhis.common.constant.PromptMsgConstant; +import com.openhis.common.enums.LocationBedStatus; import com.openhis.common.enums.LocationForm; +import com.openhis.common.enums.LocationMode; +import com.openhis.common.enums.LocationStatus; import com.openhis.common.utils.EnumUtils; import com.openhis.web.basedatamanage.appservice.ILocationAppService; import com.openhis.web.basedatamanage.dto.LocationQueryDto; @@ -27,7 +30,7 @@ public class LocationAppServiceImpl implements ILocationAppService { ILocationService locationService; @Override - public Page getLocationTree(Integer formKey, Integer pageNo, Integer pageSize) { + public R getLocationTree(Integer formKey, Integer pageNo, Integer pageSize) { QueryWrapper queryWrapper = new QueryWrapper<>(); if (formKey != null) { @@ -53,7 +56,8 @@ public class LocationAppServiceImpl implements ILocationAppService { e.setModeEnum_enumText(EnumUtils.getInfoByValue(LocationMode.class, e.getModeEnum())); }); - return locationQueryDtoPage; + return R.ok(locationQueryDtoPage, + MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"位置信息查询"})); } /** @@ -98,4 +102,64 @@ public class LocationAppServiceImpl implements ILocationAppService { return tree; } + /** + * 位置信息详情 + * + * @param locationId 位置信息id + * @return 位置信息详情 + */ + @Override + public R getLocationById(Long locationId) { + Location location = locationService.getById(locationId); + return R.ok(location, MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"位置信息查询"})); + } + + /** + * 添加/编辑位置信息 + * + * @param locationQueryDto 位置信息 + * @return 操作结果 + */ + @Override + public R addOrEditInventoryReceipt(LocationQueryDto locationQueryDto) { + + // 初始化位置信息 + Location location = new Location(); + BeanUtils.copyProperties(locationQueryDto, location); + + if (locationQueryDto.getId() != null) { + // 更新位置信息 + locationService.updateById(location); + } else { + // 插入位置信息 + location + // 状态编码:有效 + .setStatusEnum(LocationStatus.ACTIVE.getValue()) + // 操作状态:空闲 + .setOperationalEnum(LocationBedStatus.U.getValue()) + // 模式编码:具体 + .setModeEnum(LocationMode.INSTANCE.getValue()) + // 模式编码:库房 + .setFormEnum(LocationForm.CABINET.getValue()); + locationService.save(location); + } + // 返回位置信息id + return R.ok(location.getId(), + MessageUtils.createMessage(PromptMsgConstant.Common.M00004, new Object[] {"位置信息添加编辑"})); + } + + /** + * 删除位置信息 + * + * @param locationId 位置信息id + * @return 操作结果 + */ + @Override + public R deleteLocation(Long locationId) { + // 删除位置信息 + boolean result = locationService.removeById(locationId); + return result ? R.ok(null, MessageUtils.createMessage(PromptMsgConstant.Common.M00005, new Object[] {"位置信息删除"})) + : R.fail(MessageUtils.createMessage(PromptMsgConstant.Common.M00006, new Object[] {"位置信息删除"})); + } + } diff --git a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java index a46b07a0..b2f9a337 100644 --- a/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java +++ b/openhis-server/openhis-application/src/main/java/com/openhis/web/basedatamanage/appservice/impl/OrganizationAppServiceImpl.java @@ -6,6 +6,7 @@ import java.util.stream.Collectors; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; +import com.openhis.common.enums.AccountStatus; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; @@ -107,6 +108,8 @@ public class OrganizationAppServiceImpl implements IOrganizationAppService { // 更新机构信息 organizationService.updateById(organization); } else { + // 活动标识:有效 + organization.setActiveFlag(AccountStatus.ACTIVE.getValue()); // 生成待发送的机构信息 organizationService.save(organization); } 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 index d9ac2ed0..63cbc628 100644 --- 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 @@ -3,21 +3,10 @@ */ package com.openhis.web.basedatamanage.controller; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.core.common.core.domain.R; -import com.core.common.utils.MessageUtils; -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.LocationBedStatus; -import com.openhis.common.enums.LocationForm; -import com.openhis.common.enums.LocationMode; -import com.openhis.common.enums.LocationStatus; import com.openhis.web.basedatamanage.appservice.ILocationAppService; import com.openhis.web.basedatamanage.dto.LocationQueryDto; @@ -36,12 +25,8 @@ import lombok.extern.slf4j.Slf4j; @AllArgsConstructor public class CabinetLocationController { - private final ILocationService locationService; private final ILocationAppService iLocationAppService; - @Autowired - private LocationMapper locationMapper; - /** * 位置分页列表 * @@ -53,34 +38,7 @@ public class CabinetLocationController { public R getLocationPage(@RequestParam(required = false, value = "formKey", defaultValue = "") Integer formKey, @RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo, @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize) { - - Page locationTree = iLocationAppService.getLocationTree(formKey, pageNo, pageSize); - return R.ok(locationTree, 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); - // locationQueryDto.setFormEnum(LocationForm.CABINET); - // BeanUtils.copyProperties(locationQueryDto, location); - Location location = new Location(locationQueryDto.getId(), locationQueryDto.getBusNo(), - locationQueryDto.getName(), LocationStatus.ACTIVE.getValue(), LocationBedStatus.U.getValue(), - LocationMode.INSTANCE.getValue(), locationQueryDto.getTypeCode(), locationQueryDto.getTypeJson(), - locationQueryDto.getPyStr(), locationQueryDto.getWbStr(), LocationForm.CABINET.getValue(), - locationQueryDto.getOrganizationId(), locationQueryDto.getDisplayOrder()); - - 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[] {"位置信息"})); + return iLocationAppService.getLocationTree(formKey, pageNo, pageSize); } /** @@ -90,9 +48,7 @@ public class CabinetLocationController { */ @GetMapping("/cabinet-location-getById") public R getLocationById(@Validated @RequestParam Long locationId) { - - Location location = locationService.getById(locationId); - return R.ok(location, MessageUtils.createMessage(PromptMsgConstant.Common.M00009, new Object[] {"位置信息"})); + return iLocationAppService.getLocationById(locationId); } /** @@ -101,18 +57,8 @@ public class CabinetLocationController { * @param locationQueryDto 库房位置信息 */ @PutMapping("/cabinet-location") - public R editLocation(@Validated @RequestBody LocationQueryDto locationQueryDto) { - - Location location = new Location(locationQueryDto.getId(), locationQueryDto.getBusNo(), - locationQueryDto.getName(), LocationStatus.ACTIVE.getValue(), LocationBedStatus.U.getValue(), - LocationMode.INSTANCE.getValue(), locationQueryDto.getTypeCode(), locationQueryDto.getTypeJson(), - locationQueryDto.getPyStr(), locationQueryDto.getWbStr(), LocationForm.CABINET.getValue(), - locationQueryDto.getOrganizationId(), locationQueryDto.getDisplayOrder()); - - 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[] {"位置信息"})); + public R addOrEditLocation(@Validated @RequestBody LocationQueryDto locationQueryDto) { + return iLocationAppService.addOrEditInventoryReceipt(locationQueryDto); } /** @@ -122,12 +68,7 @@ public class CabinetLocationController { */ @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[] {"位置信息"})); + return iLocationAppService.deleteLocation(locationId); } } diff --git a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/Location.java b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/Location.java index 7966c482..edc882c7 100644 --- a/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/Location.java +++ b/openhis-server/openhis-domain/src/main/java/com/openhis/administration/domain/Location.java @@ -4,9 +4,6 @@ import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.core.common.core.domain.HisBaseEntity; -import com.openhis.common.enums.LocationBedStatus; -import com.openhis.common.enums.LocationMode; -import com.openhis.common.enums.LocationStatus; import lombok.Data; import lombok.EqualsAndHashCode; @@ -68,22 +65,22 @@ public class Location extends HisBaseEntity { /** 显示顺序 */ private Integer displayOrder; - public Location(Long id, String busNo, String name, Integer statusEnum, Integer operationalEnum, - Integer modeEnum, String typeCode, String typeJson, String pyStr, String wbStr, Integer formEnum, - Long organizationId, Integer displayOrder) { - this.id = id; - this.busNo = busNo; - this.name = name; - this.statusEnum = statusEnum; - this.operationalEnum = operationalEnum; - this.modeEnum = modeEnum; - this.typeCode = typeCode; - this.typeJson = typeJson; - this.pyStr = pyStr; - this.wbStr = wbStr; - this.formEnum = formEnum; - this.organizationId = organizationId; - this.displayOrder = displayOrder; - } + // public Location(Long id, String busNo, String name, Integer statusEnum, Integer operationalEnum, + // Integer modeEnum, String typeCode, String typeJson, String pyStr, String wbStr, Integer formEnum, + // Long organizationId, Integer displayOrder) { + // this.id = id; + // this.busNo = busNo; + // this.name = name; + // this.statusEnum = statusEnum; + // this.operationalEnum = operationalEnum; + // this.modeEnum = modeEnum; + // this.typeCode = typeCode; + // this.typeJson = typeJson; + // this.pyStr = pyStr; + // this.wbStr = wbStr; + // this.formEnum = formEnum; + // this.organizationId = organizationId; + // this.displayOrder = displayOrder; + // } }