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
<?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.ComSwPatrolRecordDAO">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="com.panzhihua.service_community.model.dos.ComSwPatrolRecordDO">
                <id column="id" property="id" />
                <result column="community_id" property="communityId" />
                <result column="patrol_time" property="patrolTime" />
                <result column="patrol_type" property="patrolType" />
                <result column="patrol_leader" property="patrolLeader" />
                <result column="patrol_person" property="patrolPerson" />
                <result column="address" property="address" />
                <result column="record_content" property="recordContent" />
                <result column="find_record" property="findRecord" />
                <result column="record_photo" property="recordPhoto" />
                <result column="remark" property="remark" />
                <result column="succession_leader" property="successionLeader" />
                <result column="succession_person" property="successionPerson" />
                <result column="succession_time" property="successionTime" />
                <result column="is_hidden_danger" property="isHiddenDanger" />
                <result column="create_at" property="createAt" />
                <result column="create_by" property="createBy" />
                <result column="update_at" property="updateAt" />
                <result column="update_by" property="updateBy" />
    </resultMap>
 
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
    id, community_id, patrol_time, patrol_type, patrol_leader, patrol_person, address, record_content, find_record, record_photo, remark, succession_leader, succession_person, succession_time, is_hidden_danger, create_at, create_by, update_at, update_by
    </sql>
 
    <select id="pagePatrolRecord" resultType="com.panzhihua.common.model.vos.community.ComSwPatrolRecordVO">
        SELECT
            cspr.id,
            cspr.community_id AS communityId,
            cspr.patrol_time AS patrolTime,
            cspr.patrol_type AS patrolType,
            cspr.patrol_person AS patrolPerson,
            cspr.person_name AS personName,
            cspr.person_phone AS personPhone,
            cspr.address,
            cspr.record_content AS recordContent,
            cspr.find_record AS findRecord,
            cspr.record_photo AS recordPhoto,
            cspr.remark,
            cspr.succession_person AS successionPerson,
            cspr.succession_time AS successionTime,
            cspr.create_at AS createAt,
            cspr.create_by AS createBy,
            csprr.report_id AS reportId,
            t.name as communityName
        FROM
            com_sw_patrol_record as cspr
        left join com_sw_patrol_record_report as csprr on csprr.patrol_record_id = cspr.id
        left join com_act t on cspr.community_id = t.community_id
        <where>
            <if test='comSwPatrolRecordDTO.communityId != null and comSwPatrolRecordDTO.communityId != 0'>
                AND cspr.community_id = ${comSwPatrolRecordDTO.communityId}
            </if>
            <if test='comSwPatrolRecordDTO.areaCode !=null'>
                AND t.area_code = #{comSwPatrolRecordDTO.areaCode}
            </if>
            <if test='comSwPatrolRecordDTO.patrolPerson != null and comSwPatrolRecordDTO.patrolPerson != ""'>
                AND cspr.person_name LIKE concat('%',#{comSwPatrolRecordDTO.patrolPerson},'%')
            </if>
            <if test='comSwPatrolRecordDTO.patrolType != null and comSwPatrolRecordDTO.patrolType != ""'>
                AND cspr.patrol_type LIKE concat('%',#{comSwPatrolRecordDTO.patrolType},'%')
            </if>
            <if test='comSwPatrolRecordDTO.patrolAtBegin != null and comSwPatrolRecordDTO.patrolAtBegin != ""'>
                AND cspr.patrol_time <![CDATA[ >= ]]> #{comSwPatrolRecordDTO.patrolAtBegin}
            </if>
            <if test='comSwPatrolRecordDTO.patrolAtEnd != null and comSwPatrolRecordDTO.patrolAtEnd != ""'>
                AND cspr.patrol_time <![CDATA[ <= ]]> #{comSwPatrolRecordDTO.patrolAtEnd}
            </if>
        </where>
        order by cspr.create_at desc
    </select>
 
    <select id="getPbServiceTeamById" resultType="Map">
        select `name`,phone from com_pb_service_team where id = #{teamId}
    </select>
 
    <select id="getPbServiceTeamCardNo" resultType="Map">
        select cpst.id,cpst.`name`,cpst.phone from com_pb_service_team as cpst
        left join sys_user as su on su.phone = cpst.card_no and su.type = 1
        where su.user_id = #{userId}
    </select>
 
    <select id="getCreateName" resultType="String">
        select `name` from sys_user where user_id = #{userId}
    </select>
 
    <select id="getPatrolPersonName" resultType="Map">
        select cspr.person_name from com_sw_patrol_record_report as csprr
        left join com_sw_patrol_record as cspr on cspr.id = csprr.patrol_record_id
        where csprr.report_id = #{dangerId}
    </select>
 
</mapper>