| | |
| | | import org.apache.ibatis.annotations.Update; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | public interface AppointmentMapper extends BaseMapperX<AppointmentDO> { |
| | | |
| | | default PageResult<AppointmentDO> selectPage(AppointmentPageReqVO reqVO) { |
| | | return selectPage(reqVO, new LambdaQueryWrapperX<AppointmentDO>() |
| | | LambdaQueryWrapperX<AppointmentDO> wrapper = (LambdaQueryWrapperX<AppointmentDO>) new LambdaQueryWrapperX<AppointmentDO>() |
| | | .eqIfPresent(AppointmentDO::getPatId, reqVO.getPatId()) |
| | | .eqIfPresent(AppointmentDO::getPatName, reqVO.getPatName()) |
| | | .likeIfPresent(AppointmentDO::getPatName, reqVO.getPatName()) |
| | | .eqIfPresent(AppointmentDO::getPatGender, reqVO.getPatGender()) |
| | | .eqIfPresent(AppointmentDO::getPatBirthday, reqVO.getPatBirthday()) |
| | | .eqIfPresent(AppointmentDO::getPatMobile, reqVO.getPatMobile()) |
| | |
| | | .eqIfPresent(AppointmentDO::getBookCheckType, reqVO.getBookCheckType()) |
| | | .eqIfPresent(AppointmentDO::getBookSrc, reqVO.getBookSrc()) |
| | | .eqIfPresent(AppointmentDO::getPaid, reqVO.getPaid()) |
| | | .eqIfPresent(AppointmentDO::getStatus, reqVO.getStatus()) |
| | | .orderByDesc(AppointmentDO::getId)); |
| | | .eqIfPresent(AppointmentDO::getApplyNo, reqVO.getApplyNo()) |
| | | .eqIfPresent(AppointmentDO::getEpisodeId, reqVO.getEpisodeId()) |
| | | .inIfPresent(AppointmentDO::getStatus, reqVO.getStatus()) |
| | | // 时间范围查询,注意这里强制指定类型为 LambdaQueryWrapperX |
| | | .and(reqVO.getRegisterTime() != null, w -> { |
| | | LocalDate today = LocalDate.now(); |
| | | if ("上午".equals(reqVO.getRegisterTime())) { |
| | | w.between(AppointmentDO::getRegisterDate, today.atTime(5, 0, 0), today.atTime(13, 0, 0)); |
| | | } else if ("下午".equals(reqVO.getRegisterTime())) { |
| | | w.between(AppointmentDO::getRegisterDate, today.atTime(13, 0, 1), today.atTime(22, 0, 0)); |
| | | } |
| | | }); |
| | | |
| | | // 动态排序 |
| | | if (reqVO.getOrderCreateTime() != null) { |
| | | wrapper.orderByDesc(AppointmentDO::getCreateTime); |
| | | } else { |
| | | wrapper.orderByAsc(AppointmentDO::getRegisterDate) |
| | | .orderByAsc(AppointmentDO::getPatWardDesc); |
| | | } |
| | | return selectPage(reqVO, wrapper); |
| | | } |
| | | |
| | | |
| | | @Select("select * from lihu.appointment where pat_id = #{patId} and to_days(book_date) = to_days(Now())") |
| | | List<AppointmentDO> getCurrentPatId(String patId); |
| | | |
| | | @Select("select * from lihu.appointment where (apply_no = #{code} or episode_id= #{code} or hospital_no =#{code} or pat_identity_id=#{code}) and to_days(book_date) = to_days(Now())") |
| | | List<AppointmentDO> getCurrentCode(String code); |
| | | |
| | | @Select("select * from lihu.appointment where pat_id = #{patId} and book_check_type = #{checkType} and to_days(book_date) = to_days(Now()) limit 1") |
| | | AppointmentDO getByPatAndCheckTypeAndBookDate(@Param("patId") String patId, @Param("checkType") Integer checkType); |
| | | |
| | | @Update("update lihu.appointment set status = #{status} where apply_no = #{applyNo};") |
| | | Integer updateStatusByApplyNo(@Param("applyNo") String applyNo, @Param("status") String status); |
| | | @Update("update lihu.appointment set status = #{status} " + "<if test='registerDate != null'>" + ", register_date = #{registerDate} " + "</if>" + "where apply_no = #{applyNo};") |
| | | Integer updateStatusByApplyNo(@Param("applyNo") String applyNo, @Param("status") String status, @Param("registerDate") Date registerDate); |
| | | |
| | | @Select("select * from lihu.appointment where episode_id = #{episodeId} and apply_no = #{applyNo} limit 1") |
| | | AppointmentDO getByEpisodeIdAndApplyNo(@Param("episodeId") String episodeId, @Param("applyNo") String applyNo); |