linwe
2024-08-09 8b7258c9427882bb1798f1502eaa35184c6e374e
src/main/java/org/springblade/modules/backblast/mapper/BackblastWarnHanRecMapper.xml
@@ -6,9 +6,163 @@
    <resultMap id="backblastWarnHanRecResultMap" type="org.springblade.modules.backblast.vo.BackblastWarnHanRecVO">
    </resultMap>
    <!--自定义分页列表查询-->
    <select id="selectBackblastWarnHanRecPage" resultMap="backblastWarnHanRecResultMap">
        select * from jczz_backblast_warn_han_rec where is_deleted = 0
        select
        jbwhr.*,
        br.town_name as townName,
        br.name as communityName,
        jpag.pcs_name pcsName,
        bd.dept_name
        from jczz_backblast_warn_han_rec jbwhr
        LEFT JOIN jczz_grid jg on jg.grid_code = jbwhr.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jbwhr.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jpag.community_code
        LEFT JOIN blade_user bu ON bu.id = jbwhr.create_user
        LEFT JOIN blade_dept bd on bd.id = bu.dept_id
        where jbwhr.is_deleted = 0
        <if test="backblastWarnHanRec.townName != null and backblastWarnHanRec.townName != ''">
            and br.town_name like concat('%',#{backblastWarnHanRec.townName},'%')
        </if>
        <if test="backblastWarnHanRec.communityName != null and backblastWarnHanRec.communityName != ''">
            and jbr.name like concat('%',#{backblastWarnHanRec.communityName},'%')
        </if>
        <if test="backblastWarnHanRec.pcsName != null and backblastWarnHanRec.pcsName != ''">
            and jpag.pcs_name like concat('%',#{backblastWarnHanRec.pcsName},'%')
        </if>
        <if test="backblastWarnHanRec.houseCode != null and backblastWarnHanRec.houseCode != ''">
            and jbwhr.house_code = #{backblastWarnHanRec.houseCode}
        </if>
        <if test="backblastWarnHanRec.address != null and backblastWarnHanRec.address != ''">
            and jbwhr.address like concat('%',#{backblastWarnHanRec.address},'%')
        </if>
        <if test="backblastWarnHanRec.recContent != null and backblastWarnHanRec.recContent != ''">
            and jbwhr.rec_content like concat('%',#{backblastWarnHanRec.recContent},'%')
        </if>
        <if test="backblastWarnHanRec.policeman != null and backblastWarnHanRec.policeman != ''">
            and jbwhr.policeman like concat('%',#{backblastWarnHanRec.policeman},'%')
        </if>
        <if test="backblastWarnHanRec.policemanPhone != null and backblastWarnHanRec.policemanPhone != ''">
            and jbwhr.policeman_phone like concat('%',#{backblastWarnHanRec.policemanPhone},'%')
        </if>
        <if test="backblastWarnHanRec.startTime != null and backblastWarnHanRec.startTime != ''">
            and date_format(jbwhr.create_time,'%Y-%m-%d') &gt;= #{backblastWarnHanRec.startTime}
        </if>
        <if test="backblastWarnHanRec.endTime != null and backblastWarnHanRec.endTime != ''">
            and date_format(jbwhr.create_time,'%Y-%m-%d') &lt;= #{backblastWarnHanRec.endTime}
        </if>
        <if test="backblastWarnHanRec.createUser != null">
            and jbwhr.create_user = #{backblastWarnHanRec.createUser}
        </if>
        <if test="backblastWarnHanRec.deptName != null and backblastWarnHanRec.deptName != ''">
            and  bd.dept_name like concat('%',#{backblastWarnHanRec.deptName},'%')
        </if>
        <if test="backblastWarnHanRec.searchKey!=null and backblastWarnHanRec.searchKey!=''">
            and CONCAT(
            ifnull(jbwhr.policeman_phone,''),
            ifnull(jbwhr.address,''),
            ifnull(jbwhr.rec_content,''),
            ifnull(jbwhr.policeman,'')
            ) like CONCAT ('%', #{backblastWarnHanRec.searchKey},'%')
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="backblastWarnHanRec.roleName != null and backblastWarnHanRec.roleName != ''">
                    <if test="backblastWarnHanRec.roleName=='wgy'">
                        <choose>
                            <when test="gridCodeList !=null and gridCodeList.size()>0">
                                and jg.grid_code in
                                <foreach collection="gridCodeList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jg.grid_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                    <if test="backblastWarnHanRec.roleName=='mj'">
                        <choose>
                            <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                                and jpag.community_code in
                                <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                    #{code}
                                </foreach>
                            </when>
                            <otherwise>
                                and jpag.community_code in ('')
                            </otherwise>
                        </choose>
                    </if>
                </when>
                <otherwise>
                    <choose>
                        <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                            and
                            (
                            jg.grid_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                            or
                            jpag.community_code in
                            <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                                #{code}
                            </foreach>
                            )
                        </when>
                        <otherwise>
                            and
                            (
                            jg.grid_code in ('') or jpag.community_code in ('')
                            )
                        </otherwise>
                    </choose>
                </otherwise>
            </choose>
        </if>
        order by jbwhr.id desc,jbwhr.create_time desc
    </select>
    <!--自定义分页列表查询-->
    <select id="getDetail" resultType="org.springblade.modules.backblast.vo.BackblastWarnHanRecVO">
        select
        jbwhr.*,
        br.town_name as townName,
        br.name as communityName,
        jpag.pcs_name pcsName
        from jczz_backblast_warn_han_rec jbwhr
        LEFT JOIN jczz_grid jg on jg.grid_code = jbwhr.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jbwhr.jw_grid_code= jpag.jw_grid_code and jpag.is_deleted = 0
        LEFT JOIN blade_region br on br.code = jpag.community_code
        where jbwhr.is_deleted = 0
        <if test="backblastWarnHanRec.townName != null and backblastWarnHanRec.townName != ''">
            and br.town_name like concat('%',#{backblastWarnHanRec.townName},'%')
        </if>
        <if test="backblastWarnHanRec.communityName != null and backblastWarnHanRec.communityName != ''">
            and jbr.name like concat('%',#{backblastWarnHanRec.communityName},'%')
        </if>
        <if test="backblastWarnHanRec.pcsName != null and backblastWarnHanRec.pcsName != ''">
            and jpag.pcs_name like concat('%',#{backblastWarnHanRec.pcsName},'%')
        </if>
        <if test="backblastWarnHanRec.houseCode != null and backblastWarnHanRec.houseCode != ''">
            and jbwhr.house_code = #{backblastWarnHanRec.houseCode}
        </if>
        <if test="backblastWarnHanRec.id != null">
            and jbwhr.id = #{backblastWarnHanRec.id}
        </if>
        <if test="backblastWarnHanRec.address != null and backblastWarnHanRec.address != ''">
            and jbwhr.address like concat('%',#{backblastWarnHanRec.address},'%')
        </if>
        <if test="backblastWarnHanRec.recContent != null and backblastWarnHanRec.recContent != ''">
            and jbwhr.rec_content like concat('%',#{backblastWarnHanRec.recContent},'%')
        </if>
        <if test="backblastWarnHanRec.policeman != null and backblastWarnHanRec.policeman != ''">
            and jbwhr.policeman like concat('%',#{backblastWarnHanRec.policeman},'%')
        </if>
        <if test="backblastWarnHanRec.policemanPhone != null and backblastWarnHanRec.policemanPhone != ''">
            and jbwhr.policeman_phone like concat('%',#{backblastWarnHanRec.policemanPhone},'%')
        </if>
    </select>