| | |
| | | */ |
| | | public interface ErrorCodeConstants { |
| | | |
| | | ErrorCode APPOINTMENT_NOT_EXISTS = new ErrorCode(1_010_000_000, "预约不存在"); |
| | | ErrorCode ROOM_NOT_EXISTS = new ErrorCode(1_010_001_000, "诊室和诊疗床不存在"); |
| | | ErrorCode QUEUE_NOT_EXISTS = new ErrorCode(1_010_002_000, "排队不存在"); |
| | | ErrorCode ECG_INNER_ERROR = new ErrorCode(1_010_000_000, "ECG内部错误"); |
| | | |
| | | ErrorCode APPOINTMENT_NOT_EXISTS = new ErrorCode(1_010_001_000, "预约不存在"); |
| | | ErrorCode ROOM_NOT_EXISTS = new ErrorCode(1_010_002_000, "诊室和诊疗床不存在"); |
| | | ErrorCode ROOM_INVALID_STATUS = new ErrorCode(1_010_002_001, "诊室和诊疗床状态异常"); |
| | | ErrorCode QUEUE_NOT_EXISTS = new ErrorCode(1_010_003_000, "排队不存在"); |
| | | ErrorCode QUEUE_BED_ABNORMAL = new ErrorCode(1_010_003_001, "工位队列不存在"); |
| | | } |
| | |
| | | import cn.lihu.jh.framework.common.pojo.CommonResult; |
| | | import cn.lihu.jh.framework.common.util.object.BeanUtils; |
| | | |
| | | import static cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS; |
| | | import static cn.lihu.jh.framework.common.pojo.CommonResult.error; |
| | | import static cn.lihu.jh.framework.common.pojo.CommonResult.success; |
| | | |
| | |
| | | @RequestParam("roomId") Long roomId, |
| | | @RequestParam("bedNo") String bedNo) |
| | | { |
| | | Integer result = queueService.startBedOpen(roomId, bedNo); |
| | | if (null == result || 0 == result) |
| | | ErrorCode result = queueService.startBedOpen(roomId, bedNo); |
| | | if (result.equals(SUCCESS)) |
| | | return success(0); |
| | | |
| | | return error(new ErrorCode(result, "出错了")); |
| | | return error(result); |
| | | } |
| | | |
| | | @GetMapping("/bed-close") |
| | |
| | | @RequestParam("roomId") Long roomId, |
| | | @RequestParam("bedNo") String bedNo) |
| | | { |
| | | Integer result = queueService.startBedClose(roomId, bedNo); |
| | | if (null == result || 0 == result) |
| | | ErrorCode result = queueService.startBedClose(roomId, bedNo); |
| | | if (result.equals(SUCCESS)) |
| | | return success(0); |
| | | |
| | | return error(new ErrorCode(result, "出错了")); |
| | | return error(result); |
| | | } |
| | | |
| | | @GetMapping("/bed-doctor-pause") |
| | |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | | |
| | | Integer result = queueService.startBedDoctorPause(roomId, bedNo, userId, userNickname); |
| | | if (null == result || 0 == result) |
| | | ErrorCode result = queueService.startBedDoctorPause(roomId, bedNo, userId, userNickname); |
| | | if (result.equals(SUCCESS)) |
| | | return success(0); |
| | | |
| | | return error(new ErrorCode(result, "出错了")); |
| | | return error(result); |
| | | } |
| | | |
| | | @GetMapping("/bed-doctor-on") |
| | |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | | |
| | | Integer result = queueService.startBedDoctorOn(roomId, bedNo, userId, userNickname); |
| | | if (null == result || 0 == result) |
| | | ErrorCode result = queueService.startBedDoctorOn(roomId, bedNo, userId, userNickname); |
| | | if (result.equals(SUCCESS)) |
| | | return success(0); |
| | | |
| | | return error(new ErrorCode(result, "出错了")); |
| | | return error(result); |
| | | } |
| | | |
| | | @GetMapping("/bed-doctor-off") |
| | |
| | | Long userId = SecurityFrameworkUtils.getLoginUserId(); |
| | | String userNickname = SecurityFrameworkUtils.getLoginUserNickname(); |
| | | |
| | | Integer result = queueService.startBedDoctorOff(roomId, bedNo, userId, userNickname); |
| | | if (null == result || 0 == result) |
| | | ErrorCode result = queueService.startBedDoctorOff(roomId, bedNo, userId, userNickname); |
| | | if (result.equals(SUCCESS)) |
| | | return success(0); |
| | | |
| | | return error(new ErrorCode(result, "出错了")); |
| | | return error(result); |
| | | } |
| | | |
| | | @GetMapping("/startbiz") |
| | |
| | | package cn.lihu.jh.module.ecg.service.queue; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | |
| | | import java.util.concurrent.Callable; |
| | | |
| | | public class BedCloseCallable implements Callable<Integer> { |
| | | public class BedCloseCallable implements Callable<ErrorCode> { |
| | | |
| | | QueueService queueService; |
| | | private Long roomId; |
| | |
| | | this.queueService = queueService; |
| | | } |
| | | |
| | | public Integer call() throws Exception { |
| | | public ErrorCode call() throws Exception { |
| | | return queueService.bedClose(roomId, bedNo); |
| | | } |
| | | |
| | |
| | | package cn.lihu.jh.module.ecg.service.queue; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | |
| | | import java.util.concurrent.Callable; |
| | | |
| | | public class BedDoctorOffCallable implements Callable<Integer> { |
| | | public class BedDoctorOffCallable implements Callable<ErrorCode> { |
| | | |
| | | QueueService queueService; |
| | | private Long roomId; |
| | |
| | | this.docName = docName; |
| | | } |
| | | |
| | | public Integer call() throws Exception { |
| | | public ErrorCode call() throws Exception { |
| | | return queueService.bedDoctorOff(roomId, bedNo, docId, docName); |
| | | } |
| | | |
| | |
| | | package cn.lihu.jh.module.ecg.service.queue; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | |
| | | import java.util.concurrent.Callable; |
| | | |
| | | public class BedDoctorOnCallable implements Callable<Integer> { |
| | | public class BedDoctorOnCallable implements Callable<ErrorCode> { |
| | | |
| | | QueueService queueService; |
| | | private Long roomId; |
| | |
| | | this.docName = docName; |
| | | } |
| | | |
| | | public Integer call() throws Exception { |
| | | public ErrorCode call() throws Exception { |
| | | return queueService.bedDoctorOn(roomId, bedNo, docId, docName); |
| | | } |
| | | |
| | |
| | | package cn.lihu.jh.module.ecg.service.queue; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | |
| | | import java.util.concurrent.Callable; |
| | | |
| | | public class BedDoctorPauseCallable implements Callable<Integer> { |
| | | public class BedDoctorPauseCallable implements Callable<ErrorCode> { |
| | | |
| | | QueueService queueService; |
| | | private Long roomId; |
| | |
| | | this.docName = docName; |
| | | } |
| | | |
| | | public Integer call() throws Exception { |
| | | public ErrorCode call() throws Exception { |
| | | return queueService.bedDoctorPause(roomId, bedNo, docId, docName); |
| | | } |
| | | |
| | |
| | | package cn.lihu.jh.module.ecg.service.queue; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.queue.queueMapper; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.room.RoomMapper; |
| | |
| | | |
| | | import static cn.lihu.jh.module.ecg.service.queue.QueueService.MAX_QUEUE_NUM; |
| | | |
| | | public class BedOpenCallable implements Callable<Integer> { |
| | | public class BedOpenCallable implements Callable<ErrorCode> { |
| | | |
| | | QueueService queueService; |
| | | private Long roomId; |
| | |
| | | this.queueService = queueService; |
| | | } |
| | | |
| | | public Integer call() throws Exception { |
| | | public ErrorCode call() throws Exception { |
| | | return queueService.bedOpen(roomId, bedNo); |
| | | } |
| | | |
| | |
| | | package cn.lihu.jh.module.ecg.service.queue; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | import cn.lihu.jh.module.ecg.controller.admin.queue.vo.*; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueDO; |
| | | import cn.lihu.jh.framework.common.pojo.PageResult; |
| | |
| | | /** |
| | | * |
| | | */ |
| | | Integer startBedOpen(Long roomId, String bedNo); |
| | | Integer startBedClose(Long roomId, String bedNo); |
| | | Integer startBedDoctorPause(Long roomId, String bedNo, Long docId, String docName); |
| | | Integer startBedDoctorOn(Long roomId, String bedNo, Long docId, String docName); |
| | | Integer startBedDoctorOff(Long roomId, String bedNo, Long docId, String docName); |
| | | ErrorCode startBedOpen(Long roomId, String bedNo); |
| | | ErrorCode startBedClose(Long roomId, String bedNo); |
| | | ErrorCode startBedDoctorPause(Long roomId, String bedNo, Long docId, String docName); |
| | | ErrorCode startBedDoctorOn(Long roomId, String bedNo, Long docId, String docName); |
| | | ErrorCode startBedDoctorOff(Long roomId, String bedNo, Long docId, String docName); |
| | | |
| | | Integer bedOpen(Long roomId, String bedNo); |
| | | Integer bedClose(Long roomId, String bedNo); |
| | | Integer bedDoctorPause(Long roomId, String bedNo, Long docId, String docName); |
| | | Integer bedDoctorOn(Long roomId, String bedNo, Long docId, String docName); |
| | | Integer bedDoctorOff(Long roomId, String bedNo, Long docId, String docName); |
| | | ErrorCode bedOpen(Long roomId, String bedNo); |
| | | ErrorCode bedClose(Long roomId, String bedNo); |
| | | ErrorCode bedDoctorPause(Long roomId, String bedNo, Long docId, String docName); |
| | | ErrorCode bedDoctorOn(Long roomId, String bedNo, Long docId, String docName); |
| | | ErrorCode bedDoctorOff(Long roomId, String bedNo, Long docId, String docName); |
| | | |
| | | /** |
| | | * 获得排队 |
| | |
| | | package cn.lihu.jh.module.ecg.service.queue; |
| | | |
| | | import cn.lihu.jh.framework.common.exception.ErrorCode; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.queue.BedQueueStatisticDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.queue.QueueStatisticDO; |
| | | import cn.lihu.jh.module.ecg.dal.dataobject.room.RoomDO; |
| | | import cn.lihu.jh.module.ecg.dal.mysql.room.RoomMapper; |
| | | import cn.lihu.jh.module.ecg.enums.BedStatusEnum; |
| | | import cn.lihu.jh.module.ecg.enums.ErrorCodeConstants; |
| | | import cn.lihu.jh.module.ecg.enums.QueueStatusEnum; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.validation.annotation.Validated; |
| | |
| | | import java.util.concurrent.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | |
| | | import static cn.lihu.jh.framework.common.exception.enums.GlobalErrorCodeConstants.SUCCESS; |
| | | import static cn.lihu.jh.framework.common.exception.util.ServiceExceptionUtil.exception; |
| | | import static cn.lihu.jh.module.ecg.enums.ErrorCodeConstants.*; |
| | | |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer startBedOpen(Long roomId, String bedNo) { |
| | | Future<Integer> future = singleThreadExecutor.submit( new BedOpenCallable(this, roomId, bedNo)); |
| | | public ErrorCode startBedOpen(Long roomId, String bedNo) { |
| | | Future<ErrorCode> future = singleThreadExecutor.submit( new BedOpenCallable(this, roomId, bedNo)); |
| | | |
| | | try { |
| | | Integer ret = future.get(); |
| | | ErrorCode ret = future.get(); |
| | | return ret; |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return 100; |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | @Override |
| | | public Integer startBedClose(Long roomId, String bedNo) { |
| | | Future<Integer> future = singleThreadExecutor.submit( new BedCloseCallable(this, roomId, bedNo)); |
| | | public ErrorCode startBedClose(Long roomId, String bedNo) { |
| | | Future<ErrorCode> future = singleThreadExecutor.submit( new BedCloseCallable(this, roomId, bedNo)); |
| | | |
| | | try { |
| | | Integer ret = future.get(); |
| | | ErrorCode ret = future.get(); |
| | | return ret; |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return 100; |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | @Override |
| | | public Integer startBedDoctorPause(Long roomId, String bedNo, Long docId, String docName) { |
| | | Future<Integer> future = singleThreadExecutor.submit( |
| | | public ErrorCode startBedDoctorPause(Long roomId, String bedNo, Long docId, String docName) { |
| | | Future<ErrorCode> future = singleThreadExecutor.submit( |
| | | new BedDoctorPauseCallable(this, roomId, bedNo, docId, docName) |
| | | ); |
| | | |
| | | try { |
| | | Integer ret = future.get(); |
| | | ErrorCode ret = future.get(); |
| | | return ret; |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return 100; |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | @Override |
| | | public Integer startBedDoctorOn(Long roomId, String bedNo, Long docId, String docName) { |
| | | Future<Integer> future = singleThreadExecutor.submit( |
| | | public ErrorCode startBedDoctorOn(Long roomId, String bedNo, Long docId, String docName) { |
| | | Future<ErrorCode> future = singleThreadExecutor.submit( |
| | | new BedDoctorOnCallable(this, roomId, bedNo, docId, docName) |
| | | ); |
| | | |
| | | try { |
| | | Integer ret = future.get(); |
| | | ErrorCode ret = future.get(); |
| | | return ret; |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return 100; |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | @Override |
| | | public Integer startBedDoctorOff(Long roomId, String bedNo, Long docId, String docName) { |
| | | Future<Integer> future = singleThreadExecutor.submit( |
| | | public ErrorCode startBedDoctorOff(Long roomId, String bedNo, Long docId, String docName) { |
| | | Future<ErrorCode> future = singleThreadExecutor.submit( |
| | | new BedDoctorOffCallable(this, roomId, bedNo, docId, docName) |
| | | ); |
| | | |
| | | try { |
| | | Integer ret = future.get(); |
| | | ErrorCode ret = future.get(); |
| | | return ret; |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | return 100; |
| | | return ECG_INNER_ERROR; |
| | | } |
| | | |
| | | |
| | |
| | | * @return |
| | | */ |
| | | @Override |
| | | public Integer bedOpen(Long roomId, String bedNo) { |
| | | public ErrorCode bedOpen(Long roomId, String bedNo) { |
| | | // DB update |
| | | List statusList = new ArrayList<BedStatusEnum>(); |
| | | statusList.add(BedStatusEnum.CLOSED); |
| | |
| | | Integer updateNum = roomMapper.setBedStatus(roomId, bedNo, |
| | | BedStatusEnum.OPENING, statusList); |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return 310; |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | List<Byte> queueStatusList = new ArrayList<>(); |
| | | queueStatusList.add(QueueStatusEnum.READY.getStatus()); |
| | |
| | | bedQueueBO.setQueueNum(new AtomicInteger(queueDOList.size())); |
| | | priorityQueue.offer(bedQueueBO); |
| | | mapBedVsQueue.put(String.format("%09d%s", roomId, bedNo), bedQueueBO); |
| | | return 0; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | | public Integer bedClose(Long roomId, String bedNo) { |
| | | public ErrorCode bedClose(Long roomId, String bedNo) { |
| | | BedQueueBO bedQueueBO = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo)); |
| | | if (null == bedQueueBO) |
| | | return 320; |
| | | return QUEUE_BED_ABNORMAL; |
| | | |
| | | // DB update |
| | | List statusList = new ArrayList<BedStatusEnum>(); |
| | |
| | | Integer updateNum = roomMapper.setBedStatus(roomId, bedNo, |
| | | BedStatusEnum.CLOSING, statusList); |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return 321; |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | return 0; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | | public Integer bedDoctorPause(Long roomId, String bedNo, Long docId, String docName) { |
| | | public ErrorCode bedDoctorPause(Long roomId, String bedNo, Long docId, String docName) { |
| | | BedQueueBO bedQueueBO = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo)); |
| | | if (null == bedQueueBO) |
| | | return 320; |
| | | return QUEUE_BED_ABNORMAL; |
| | | |
| | | // DB update |
| | | List statusList = new ArrayList<BedStatusEnum>(); |
| | |
| | | Integer updateNum = roomMapper.setBedDoctorPause(roomId, bedNo, docId, docName, |
| | | BedStatusEnum.PAUSE, statusList); |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return 331; |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | return 0; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | | public Integer bedDoctorOn(Long roomId, String bedNo, Long docId, String docName) { |
| | | public ErrorCode bedDoctorOn(Long roomId, String bedNo, Long docId, String docName) { |
| | | BedQueueBO bedQueueBO = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo)); |
| | | if (null == bedQueueBO) |
| | | return 320; |
| | | return QUEUE_BED_ABNORMAL; |
| | | |
| | | // DB update |
| | | List statusList = new ArrayList<BedStatusEnum>(); |
| | |
| | | Integer updateNum = roomMapper.setBedDoctorOn(roomId, bedNo, docId, docName, |
| | | BedStatusEnum.DOCTOR_ON, statusList); |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return 341; |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | return 0; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | @Override |
| | | public Integer bedDoctorOff(Long roomId, String bedNo, Long docId, String docName) { |
| | | public ErrorCode bedDoctorOff(Long roomId, String bedNo, Long docId, String docName) { |
| | | BedQueueBO bedQueueBO = mapBedVsQueue.get(String.format("%09d%s", roomId, bedNo)); |
| | | if (null == bedQueueBO) |
| | | return 320; |
| | | return QUEUE_BED_ABNORMAL; |
| | | |
| | | // DB update |
| | | List statusList = new ArrayList<BedStatusEnum>(); |
| | |
| | | Integer updateNum = roomMapper.setBedDoctorOff(roomId, bedNo, docId, docName, |
| | | BedStatusEnum.OPENING, statusList); |
| | | if ( null==updateNum || 0 == updateNum ) |
| | | return 351; |
| | | return ROOM_INVALID_STATUS; |
| | | |
| | | return 0; |
| | | return SUCCESS; |
| | | } |
| | | |
| | | private void validatequeueExists(Integer id) { |