From c3e27cb2e84782e99a30cc5a6e8caa67ca0cb72f Mon Sep 17 00:00:00 2001 From: eight <641137800@qq.com> Date: 星期三, 25 九月 2024 17:33:32 +0800 Subject: [PATCH] 医生登出,自动离座,自动从暂停恢复 --- jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApi.java | 8 ++++ jh-module-system/jh-module-system-biz/pom.xml | 6 +++ jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java | 5 ++ jh-module-system/jh-module-system-biz/src/main/java/cn/lihu/jh/module/system/controller/admin/auth/AuthController.java | 11 +++++ jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java | 3 + jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java | 3 + jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApiImpl.java | 29 ++++++++++++++ 7 files changed, 64 insertions(+), 1 deletions(-) diff --git a/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApi.java b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApi.java new file mode 100644 index 0000000..bbdf7db --- /dev/null +++ b/jh-module-ecg/jh-module-ecg-api/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApi.java @@ -0,0 +1,8 @@ +package cn.lihu.jh.module.ecg.api.doctor; + +import cn.lihu.jh.framework.common.exception.ErrorCode; +import cn.lihu.jh.framework.common.pojo.CommonResult; + +public interface DoctorApi { + ErrorCode bedDoctorOff(Long userId, String userName); +} diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApiImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApiImpl.java new file mode 100644 index 0000000..e7ed3fd --- /dev/null +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/api/doctor/DoctorApiImpl.java @@ -0,0 +1,29 @@ +package cn.lihu.jh.module.ecg.api.doctor; + +import cn.lihu.jh.framework.common.exception.ErrorCode; +import cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants; +import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; +import cn.lihu.jh.module.ecg.service.queue.QueueService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; + +@Service +public class DoctorApiImpl implements DoctorApi { + + @Resource + private QueueService queueService; + + @Override + public ErrorCode bedDoctorOff(Long userId, String userName) { + RoomDO roomDO = queueService.getDocRoomInfo(userId); + // 鏈叆搴�, 璺宠繃 + if (null == roomDO) { + return GlobalErrorCodeConstants.SUCCESS; + } + + return queueService.bedDoctorOff(roomDO.getRoomId(), roomDO.getBedNo(), userId, userName); + } + +} + diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java index a99128c..efedc7a 100644 --- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/dal/mysql/room/RoomMapper.java @@ -56,6 +56,9 @@ @Select("SELECT * FROM lihu.clinic_room where room_id=#{roomId} and bed_no=#{bedNo} and doc_id=#{docId}") RoomDO getRoom(@Param("roomId")Long roomId, @Param("bedNo")String bedNo, @Param("docId")Long docId); + @Select("SELECT * FROM lihu.clinic_room where doc_id=#{docId} limit 1") + RoomDO getRoomByDocId(@Param("docId")Long docId); + @Update("<script> " + "update lihu.clinic_room set status=#{newStatus.status} " + " where room_id=#{roomId} and bed_no=#{bedNo} and isNull(doc_id) " + diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java index 4d3db85..2f9de52 100644 --- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueService.java @@ -10,6 +10,7 @@ import cn.lihu.jh.module.ecg.controller.admin.room.vo.RoomRespVO; import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; import cn.lihu.jh.framework.common.pojo.PageResult; +import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; /** * 鎺掗槦 Service 鎺ュ彛 @@ -118,4 +119,6 @@ Integer patientJump(String patId, Byte jumped ); void monitorInfo(); + + RoomDO getDocRoomInfo(Long docId); } diff --git a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java index 7153832..a2b2484 100644 --- a/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java +++ b/jh-module-ecg/jh-module-ecg-biz/src/main/java/cn/lihu/jh/module/ecg/service/queue/QueueServiceImpl.java @@ -703,4 +703,9 @@ + " opening " + openingFlag.get()); } + @Override + public RoomDO getDocRoomInfo(Long docId) { + return roomMapper.getRoomByDocId(docId); + } + } diff --git a/jh-module-system/jh-module-system-biz/pom.xml b/jh-module-system/jh-module-system-biz/pom.xml index 0117bc4..d5cb1d5 100644 --- a/jh-module-system/jh-module-system-biz/pom.xml +++ b/jh-module-system/jh-module-system-biz/pom.xml @@ -28,6 +28,12 @@ <artifactId>jh-module-infra-api</artifactId> <version>${revision}</version> </dependency> + <dependency> + <groupId>cn.lihu</groupId> + <artifactId>jh-module-ecg-api</artifactId> + <version>${revision}</version> + <scope>compile</scope> + </dependency> <!-- 涓氬姟缁勪欢 --> <dependency> diff --git a/jh-module-system/jh-module-system-biz/src/main/java/cn/lihu/jh/module/system/controller/admin/auth/AuthController.java b/jh-module-system/jh-module-system-biz/src/main/java/cn/lihu/jh/module/system/controller/admin/auth/AuthController.java index 862492a..36bddbe 100644 --- a/jh-module-system/jh-module-system-biz/src/main/java/cn/lihu/jh/module/system/controller/admin/auth/AuthController.java +++ b/jh-module-system/jh-module-system-biz/src/main/java/cn/lihu/jh/module/system/controller/admin/auth/AuthController.java @@ -6,7 +6,9 @@ import cn.lihu.jh.framework.common.enums.UserTypeEnum; import cn.lihu.jh.framework.common.pojo.CommonResult; import cn.lihu.jh.framework.security.config.SecurityProperties; +import cn.lihu.jh.framework.security.core.LoginUser; import cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils; +import cn.lihu.jh.module.ecg.api.doctor.DoctorApi; import cn.lihu.jh.module.system.controller.admin.auth.vo.*; import cn.lihu.jh.module.system.convert.auth.AuthConvert; import cn.lihu.jh.module.system.dal.dataobject.permission.MenuDO; @@ -37,7 +39,7 @@ import static cn.lihu.jh.framework.common.pojo.CommonResult.success; import static cn.lihu.jh.framework.common.util.collection.CollectionUtils.convertSet; -import static cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; +import static cn.lihu.jh.framework.security.core.util.SecurityFrameworkUtils.*; @Tag(name = "绠$悊鍚庡彴 - 璁よ瘉") @RestController @@ -62,6 +64,9 @@ @Resource private SecurityProperties securityProperties; + @Resource + private DoctorApi doctorApi; + @PostMapping("/login") @PermitAll @Operation(summary = "浣跨敤璐﹀彿瀵嗙爜鐧诲綍") @@ -73,8 +78,12 @@ @PermitAll @Operation(summary = "鐧诲嚭绯荤粺") public CommonResult<Boolean> logout(HttpServletRequest request) { + // 鐧诲嚭鍓嶏紝鍏堢搴� + doctorApi.bedDoctorOff(getLoginUserId(), getLoginUserNickname()); + String token = SecurityFrameworkUtils.obtainAuthorization(request, securityProperties.getTokenHeader(), securityProperties.getTokenParameter()); + if (StrUtil.isNotBlank(token)) { authService.logout(token, LoginLogTypeEnum.LOGOUT_SELF.getType()); } -- Gitblit v1.9.3