linwe
2024-09-03 764d883b5ea3bdc06abbec548b6df0511e567978
src/main/java/org/springblade/modules/backblast/mapper/BackblastPubRecordMapper.xml
@@ -10,9 +10,12 @@
    <select id="selectBackblastPubRecordPage" resultMap="backblastPubRecordResultMap">
        select
        jbpr.*,
        br.town_name as townName,
        br.name as communityName,
        jg.grid_name,
        br.town_name AS townName,
        br.NAME AS communityName,
        jpag.pcs_name pcsName,
        jda.aoi_name,
        CONCAT( IF(jda.building_name,jda.building_name,''), '-', IF(jda.unit_name,jda.unit_name,''), '-', IF(jda.house_name,jda.house_name,'') ) houseName,
        bd.dept_name
        from jczz_backblast_pub_record jbpr
        LEFT JOIN jczz_grid jg on jg.grid_code = jbpr.grid_code and jg.is_deleted = 0
@@ -20,12 +23,13 @@
        LEFT JOIN blade_region br on br.code = jpag.community_code
        LEFT JOIN blade_user bu ON bu.id = jbpr.create_user
        LEFT JOIN blade_dept bd on bd.id = bu.dept_id
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jbpr.house_code
        where jbpr.is_deleted = 0
        <if test="backblastPubRecord.townName != null and backblastPubRecord.townName != ''">
            and br.town_name like concat('%',#{backblastPubRecord.townName},'%')
        </if>
        <if test="backblastPubRecord.communityName != null and backblastPubRecord.communityName != ''">
            and jbr.name like concat('%',#{backblastPubRecord.communityName},'%')
            and br.name like concat('%',#{backblastPubRecord.communityName},'%')
        </if>
        <if test="backblastPubRecord.pcsName != null and backblastPubRecord.pcsName != ''">
            and jpag.pcs_name like concat('%',#{backblastPubRecord.pcsName},'%')
@@ -161,7 +165,7 @@
            and br.town_name like concat('%',#{backblastPubRecord.townName},'%')
        </if>
        <if test="backblastPubRecord.communityName != null and backblastPubRecord.communityName != ''">
            and jbr.name like concat('%',#{backblastPubRecord.communityName},'%')
            and br.name like concat('%',#{backblastPubRecord.communityName},'%')
        </if>
        <if test="backblastPubRecord.pcsName != null and backblastPubRecord.pcsName != ''">
            and jpag.pcs_name like concat('%',#{backblastPubRecord.pcsName},'%')
@@ -185,4 +189,127 @@
    </select>
    <select id="selectBackblastPubRecordExport"
            resultType="org.springblade.modules.backblast.excel.BackblastPubRecordExcel">
        select
        jbpr.*,
        br.town_name AS townName,
        br.NAME AS communityName,
        jpag.pcs_name pcsName,
        jda.aoi_name,
        CONCAT( IF(jda.building_name,jda.building_name,''), '-', IF(jda.unit_name,jda.unit_name,''), '-', IF(jda.house_name,jda.house_name,'') ) houseName,
        bd.dept_name
        from jczz_backblast_pub_record jbpr
        LEFT JOIN jczz_grid jg on jg.grid_code = jbpr.grid_code and jg.is_deleted = 0
        LEFT JOIN jczz_police_affairs_grid jpag on jbpr.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 = jbpr.create_user
        LEFT JOIN blade_dept bd on bd.id = bu.dept_id
        LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jbpr.house_code
        where jbpr.is_deleted = 0
        <if test="backblastPubRecord.townName != null and backblastPubRecord.townName != ''">
            and br.town_name like concat('%',#{backblastPubRecord.townName},'%')
        </if>
        <if test="backblastPubRecord.communityName != null and backblastPubRecord.communityName != ''">
            and br.name like concat('%',#{backblastPubRecord.communityName},'%')
        </if>
        <if test="backblastPubRecord.pcsName != null and backblastPubRecord.pcsName != ''">
            and jpag.pcs_name like concat('%',#{backblastPubRecord.pcsName},'%')
        </if>
        <if test="backblastPubRecord.houseCode != null and backblastPubRecord.houseCode != ''">
            and jbpr.house_code = #{backblastPubRecord.houseCode}
        </if>
        <if test="backblastPubRecord.address != null and backblastPubRecord.address != ''">
            and jbpr.address like concat('%',#{backblastPubRecord.address},'%')
        </if>
        <if test="backblastPubRecord.deptName != null and backblastPubRecord.deptName != ''">
            and  bd.dept_name like concat('%',#{backblastPubRecord.deptName},'%')
        </if>
        <if test="backblastPubRecord.pubContent != null and backblastPubRecord.pubContent != ''">
            and jbpr.pub_content like concat('%',#{backblastPubRecord.pubContent},'%')
        </if>
        <if test="backblastPubRecord.policeman != null and backblastPubRecord.policeman != ''">
            and jbpr.policeman like concat('%',#{backblastPubRecord.policeman},'%')
        </if>
        <if test="backblastPubRecord.createUser != null">
            and jbpr.create_user = #{backblastPubRecord.createUser}
        </if>
        <if test="backblastPubRecord.policemanPhone != null and backblastPubRecord.policemanPhone != ''">
            and jbpr.policeman_phone like concat('%',#{backblastPubRecord.policemanPhone},'%')
        </if>
        <if test="backblastPubRecord.startTime != null and backblastPubRecord.startTime != ''">
            and date_format(jbpr.create_time,'%Y-%m-%d') &gt;= #{backblastPubRecord.startTime}
        </if>
        <if test="backblastPubRecord.endTime != null and backblastPubRecord.endTime != ''">
            and date_format(jbpr.create_time,'%Y-%m-%d') &lt;= #{backblastPubRecord.endTime}
        </if>
        <if test="backblastPubRecord.searchKey!=null and backblastPubRecord.searchKey!=''">
            and CONCAT(
            ifnull(jbpr.policeman_phone,''),
            ifnull(jbpr.address,''),
            ifnull(jbpr.pub_content,''),
            ifnull(jbpr.policeman,'')
            ) like CONCAT ('%', #{backblastPubRecord.searchKey},'%')
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="backblastPubRecord.roleName != null and backblastPubRecord.roleName != ''">
                    <if test="backblastPubRecord.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="backblastPubRecord.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 jbpr.id desc,jbpr.create_time desc
    </select>
</mapper>