liujie
7 天以前 38731b1ba57e2f0205e428189fb5b776ca9d85c5
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.system.mapper.TSysAppUserMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.ruoyi.system.model.TSysAppUser">
        <id column="id" property="id" />
        <result column="nick_name" property="nickName" />
        <result column="avatar" property="avatar" />
        <result column="phone" property="phone" />
        <result column="birth_time" property="birthTime" />
        <result column="sex" property="sex" />
        <result column="open_id" property="openId" />
        <result column="office_open_id" property="officeOpenId" />
        <result column="chronic_disease_id" property="chronicDiseaseId" />
        <result column="status" property="status" />
        <result column="last_reminder_time" property="lastReminderTime" />
        <result column="clinic_id" property="clinicId" />
        <result column="create_time" property="createTime" />
        <result column="update_time" property="updateTime" />
        <result column="create_by" property="createBy" />
        <result column="update_by" property="updateBy" />
        <result column="disabled" property="disabled" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
        id, nick_name,avatar, phone, birth_time, sex, open_id,chronic_disease_id,status,last_reminder_time,
          office_open_id,clinic_id, create_time, update_time, create_by, update_by, disabled
    </sql>
    <select id="pageList" resultType="com.ruoyi.system.vo.TSysAppUserVO">
        select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id,
               tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time,
               tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled, tsi.lastInspectionTime
        from t_sys_app_user tsau
        left join (select id,app_user_id, max(check_time) as lastInspectionTime from t_sys_inspection limit 1) tsi on tsi.app_user_id = tsau.id
        <where>
            <if test="query.phone != null and query.phone != ''">
                and tsau.phone  like concat('%',#{query.phone},'%')
            </if>
            <if test="query.nickName != null and query.nickName != ''">
                and tsau.nick_name like concat('%',#{query.nickName},'%')
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                and tsau.id in (select app_user_id from t_sys_inspection where check_time between #{query.startTime} and #{query.endTime})
            </if>
            <if test="query.isInspection != null and query.isInspection == 1">
                and tsau.chronic_disease_id IS NOT NULL
            </if>
            <if test="query.isInspection != null and query.isInspection == 0">
                and tsau.chronic_disease_id IS NULL
            </if>
            <if test="query.status != null">
                and tsau.status = #{query.status}
            </if>
            AND tsau.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tsau.create_time DESC
    </select>
    <select id="pageChronicDiseaseUserList" resultType="com.ruoyi.system.vo.TSysAppUserVO">
        select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id,
        tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time,
        tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled
        from t_sys_app_user tsau
        left join (select id,app_user_id, max(check_time) as lastInspectionTime from t_sys_inspection limit 1) tsi on tsi.app_user_id = tsau.id
        <where>
            <if test="query.phone != null and query.phone != ''">
                and tsau.phone like concat('%',#{query.phone},'%')
            </if>
            <if test="query.nickName != null and query.nickName != ''">
                and tsau.nick_name like concat('%',#{query.nickName},'%')
            </if>
            <if test="query.inspectionId != null and query.inspectionId != ''">
                and FIND_IN_SET(#{query.inspectionId},tsau.chronic_disease_id)
            </if>
            AND tsau.chronic_disease_id IS NOT NULL
            AND tsau.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tsau.create_time DESC
    </select>
    <select id="exportList" resultType="com.ruoyi.system.export.TSysAppUserListExport">
        select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id,
        tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time,
        tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled
        from t_sys_app_user tsau
        <where>
            <if test="query.phone != null and query.phone != ''">
                and tsau.phone = #{query.phone}
            </if>
            <if test="query.nickName != null and query.nickName != ''">
                and tsau.nick_name like concat('%',#{query.nickName},'%')
            </if>
            <if test="query.inspectionId != null and query.inspectionId != ''">
                and FIND_IN_SET(#{query.inspectionId},tsau.chronic_disease_id)
            </if>
            AND tsau.chronic_disease_id IS NOT NULL
            AND tsau.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tsau.create_time DESC
    </select>
    <select id="exportListClinic" resultType="com.ruoyi.system.export.TSysAppUserClinicExport">
        select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id,
        tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time,
        tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled
        from t_sys_app_user tsau
        <where>
            <if test="query.phone != null and query.phone != ''">
                and tsau.phone = #{query.phone}
            </if>
            <if test="query.nickName != null and query.nickName != ''">
                and tsau.nick_name like concat('%',#{query.nickName},'%')
            </if>
            <if test="query.inspectionId != null and query.inspectionId != ''">
                and FIND_IN_SET(#{query.inspectionId},tsau.chronic_disease_id)
            </if>
            AND tsau.chronic_disease_id IS NOT NULL
            AND tsau.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tsau.create_time DESC
    </select>
    <select id="exportListAppUser" resultType="com.ruoyi.system.export.TSysAppUserExport">
        select tsau.id, tsau.nick_name,tsau.avatar, tsau.phone, tsau.birth_time, tsau.sex, tsau.open_id,tsau.office_open_id,
        tsau.chronic_disease_id,tsau.status,tsau.last_reminder_time,tsau.clinic_id, tsau.create_time,
        tsau.update_time, tsau.create_by,tsau.update_by, tsau.disabled, tsi.lastInspectionTime
        from t_sys_app_user tsau
        left join (select id,app_user_id, max(check_time) as lastInspectionTime from t_sys_inspection limit 1) tsi on tsi.app_user_id = tsau.id
        <where>
            <if test="query.phone != null and query.phone != ''">
                and tsau.phone = #{query.phone}
            </if>
            <if test="query.nickName != null and query.nickName != ''">
                and tsau.nick_name like concat('%',#{query.nickName},'%')
            </if>
            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
                and tsau.id in (select app_user_id from t_sys_inspection where check_time between #{query.startTime} and #{query.endTime})
            </if>
            <if test="query.isInspection != null and query.isInspection == 1">
                and tsau.chronic_disease_id IS NOT NULL
            </if>
            <if test="query.isInspection != null and query.isInspection == 0">
                and tsau.chronic_disease_id IS NULL
            </if>
            <if test="query.status != null">
                and tsau.status = #{query.status}
            </if>
            AND tsau.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        </where>
        ORDER BY tsau.create_time DESC
    </select>
 
</mapper>