yxh
7 天以前 68ff33beff11310e830b0615b5a81f83fad0f683
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package cn.lihu.jh.module.ecg.dal.mysql.call;
 
import java.util.*;
 
import cn.lihu.jh.framework.common.pojo.PageResult;
import cn.lihu.jh.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.lihu.jh.framework.mybatis.core.mapper.BaseMapperX;
import cn.lihu.jh.module.ecg.dal.dataobject.call.CallDO;
import org.apache.ibatis.annotations.*;
import cn.lihu.jh.module.ecg.controller.admin.call.vo.*;
 
/**
 * 叫号 Mapper
 *
 * @author 马剑波
 */
@Mapper
public interface CallMapper extends BaseMapperX<CallDO> {
 
    default PageResult<CallDO> selectPage(CallPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CallDO>()
                .eqIfPresent(CallDO::getPatId, reqVO.getPatId())
                .likeIfPresent(CallDO::getPatName, reqVO.getPatName())
                .eqIfPresent(CallDO::getPatGender, reqVO.getPatGender())
                .eqIfPresent(CallDO::getSeqNum, reqVO.getSeqNum())
                .eqIfPresent(CallDO::getPassed, reqVO.getPassed())
                .eqIfPresent(CallDO::getExpired, reqVO.getExpired())
                .eqIfPresent(CallDO::getCalled, reqVO.getCalled())
                .eqIfPresent(CallDO::getJumpFlag, reqVO.getJumpFlag())
                .eqIfPresent(CallDO::getRoomId, reqVO.getRoomId())
                .likeIfPresent(CallDO::getRoomName, reqVO.getRoomName())
                .eqIfPresent(CallDO::getBedNo, reqVO.getBedNo())
                .betweenIfPresent(CallDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CallDO::getId));
    }
 
    @Select("select * from lihu.call_patient where pat_id = #{patId} order by id desc limit 1")
    CallDO getLatestPatientCall(@Param("patId") String patId);
 
    /**
     * 各患者**最近一次叫号记录**的 id(key=pat_id,value=最新 id)。
     *
     * <p>【重叫(本需求)】大屏/诊间屏靠"数据变化"触发播报,重叫本身不会改变队列数据,
     * 因此下发这个 callId:医生每点一次重叫都会**新增一条叫号记录**(见 {@code CallService#callAgain}),
     * callId 随之变大 → 屏幕据此重新播报。
     *
     * <p>用 create_time 限定近 2 天(call_patient 会被每日清理,见 clearCall),
     * 避免全表 group by;不依赖 book_date(可能为空)。
     */
    @Select("select pat_id as patId, max(id) as callId from lihu.call_patient " +
            "where create_time >= date_sub(now(), interval 2 day) group by pat_id")
    List<Map<String, Object>> selectLatestCallIds();
 
    // call_type 0  大屏
    @Select("select * from lihu.call_patient where called = 0 and call_type = 0 order by id limit 1")
    CallDO getNextCall( );
 
    // call_type 1  诊间屏
    @Select("select * from lihu.call_patient where called = 0 and call_type = 1 and room_id = #{roomId} order by id limit 1")
    CallDO getNextInstallCall(@Param("roomId") Long roomId);
 
    //@Update("TRUNCATE TABLE lihu.call_patient")  保持当天数据
    @Delete("delete from lihu.call_patient where TO_DAYS(book_date) != TO_DAYS(NOW())")
    void clearCall();
}