mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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.panzhihua.service_community.dao.ComActAcidDangerMemberDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActAcidDangerMember"
               id="ComActAcidDangerMemberBaseResultMap">
        <result property="id" column="id"/>
        <result property="createTime" column="create_time"/>
        <result property="recordId" column="record_id"/>
        <result property="name" column="name"/>
        <result property="phone" column="phone"/>
        <result property="idCard" column="id_card"/>
        <result property="type" column="type"/>
        <result property="updateTime" column="update_time"/>
        <result property="relationName" column="relation_name"/>
        <result property="riskType" column="risk_type"/>
    </resultMap>
 
    <select id="pageList" resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidDangerMemberVO">
        SELECT t1.id, t1.`name`, t1.`status`, t1.record_id, t1.phone, t1.risk_type, t2.local_city,
        t1.source, t2.create_time AS reportTime, t2.real_address, MAX(t3.create_time) AS checkTime
        FROM com_act_acid_danger_member t1
        LEFT JOIN com_act_acid_record t2 ON t1.record_id = t2.id
        LEFT JOIN com_act_acid_check_record t3 ON t1.id = t3.member_id
        <where>
            t1.is_del=0
            <if test="commonPage.keyword!=null and commonPage.keyword !=''">
                and (t1.`name` like concat('%',#{commonPage.keyword},'%')
                or t1.phone like concat('%',#{commonPage.keyword},'%')
                or t1.id_card like concat('%',#{commonPage.keyword},'%'))
            </if>
            <if test="commonPage.source!=null">
                and t1.source =#{commonPage.source}
            </if>
            <if test="commonPage.status!=null">
                and t1.`status` =#{commonPage.status}
            </if>
            <if test="commonPage.status==null">
                and t1.`status` != 5
            </if>
            <if test="commonPage.type != null">
                AND t1.`type` = #{commonPage.type}
            </if>
            <if test="commonPage.relationName !=null and commonPage.relationName !='' and commonPage.relationName !='panzhihua'">
                and t1.relation_name like concat('%',#{commonPage.relationName},'%')
            </if>
            <if test="commonPage.isAddress !=null">
                <if test="commonPage.isAddress == 0">
                    and (t2.local_city is null OR LENGTH(TRIM(t2.local_city)) = 0)
                </if>
                <if test="commonPage.isAddress == 1">
                    and t2.local_city is not null AND LENGTH(TRIM(t2.local_city)) > 0
                </if>
            </if>
            <if test="commonPage.localCity !=null and commonPage.localCity !='' and commonPage.localCity !='panzhihua'">
                and t2.local_city like concat('%',#{commonPage.localCity},'%')
            </if>
            <if test="commonPage.riskType != null and commonPage.riskType != &quot;&quot;">
                AND t1.risk_type LIKE CONCAT('%', #{commonPage.riskType}, '%')
            </if>
        </where>
        GROUP BY t1.id
        HAVING 1=1
        <if test="commonPage.type == 1">
            <if test="commonPage.startTime!=null">
                AND checkTime >= #{commonPage.startTime}
            </if>
            <if test="commonPage.stopTime!=null">
                AND concat(SUBSTR(#{commonPage.stopTime} FROM 1 FOR 10),' 23:59:59') >= checkTime
            </if>
            order by checkTime asc,reportTime desc
        </if>
        <if test="commonPage.type == 2">
            <if test="commonPage.startTime!=null">
                AND reportTime >= #{commonPage.startTime}
            </if>
            <if test="commonPage.stopTime!=null">
                AND concat(SUBSTR(#{commonPage.stopTime} FROM 1 FOR 10),' 23:59:59') >= reportTime
            </if>
            order by reportTime desc
        </if>
    </select>
    <select id="pageDangerMember"
            resultType="com.panzhihua.common.model.vos.community.acid.ComActAcidDangerMemberVO">
        SELECT t1.id, t1.`name`, t1.`status`, t1.record_id, t1.phone, t2.color_mark, t2.acid_test, MAX(t3.create_time) AS checkTime,t1.create_time
        FROM com_act_acid_danger_member t1
        LEFT JOIN com_act_acid_record t2 ON t1.record_id = t2.id
        LEFT JOIN com_act_acid_check_record t3 ON t1.id = t3.member_id
        <where>
            t1.is_del=0
            <if test="pageDangerMemberDTO.keyword != null and pageDangerMemberDTO.keyword != &quot;&quot;">
                AND t1.`name` LIKE CONCAT('%', #{pageDangerMemberDTO.keyword}, '%')
            </if>
            <if test="pageDangerMemberDTO.isFill != null">
                <if test="pageDangerMemberDTO.isFill == 1">
                    AND t2.local_city IS NOT NULL AND LENGTH(TRIM(t2.local_city)) > 0
                </if>
                <if test="pageDangerMemberDTO.isFill == 2">
                    AND (t2.local_city IS NULL OR LENGTH(TRIM(t2.local_city)) = 0)
                </if>
            </if>
            <if test="pageDangerMemberDTO.type != null">
                AND t1.`type` = #{pageDangerMemberDTO.type}
            </if>
            <if test="pageDangerMemberDTO.relationName !=null and pageDangerMemberDTO.relationName !='' and pageDangerMemberDTO.relationName !='panzhihua'">
                and t1.relation_name like concat('%',#{pageDangerMemberDTO.relationName},'%')
            </if>
        </where>
        GROUP BY t1.id ORDER BY checkTime ASC
    </select>
 
</mapper>