linwei
2024-01-08 ad2ec97fe0c60eee4bb7c8cdacff7c876f280ea7
src/main/java/org/springblade/modules/task/mapper/TaskReportForRepairsMapper.xml
@@ -17,13 +17,147 @@
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
    <!--自定义分页查询-->
    <select id="selectTaskReportForRepairsPage" resultType="org.springblade.modules.task.vo.TaskReportForRepairsVO">
    <resultMap id="taskReportForRepairsResult" type="org.springblade.modules.task.vo.TaskReportForRepairsVO">
        <result property="id" column="id"/>
        <result property="taskId" column="task_id"/>
        <result property="addressCode" column="address_code"/>
        <result property="type" column="type"/>
        <result property="realName" column="real_name"/>
        <result property="phone" column="phone"/>
        <result property="remark" column="remark"/>
        <result property="imageUrls" column="image_urls"/>
        <result property="confirmUserId" column="confirm_user_id"/>
        <result property="confirmTime" column="confirm_time"/>
        <result property="confirmFlag" column="confirm_flag"/>
        <result property="confirmNotion" column="confirm_notion"/>
        <result property="createTime" column="create_time"/>
        <result property="createUser" column="create_user"/>
        <result property="createDept" column="create_dept"/>
        <result property="updateTime" column="update_time"/>
        <result property="updateUser" column="update_user"/>
        <result property="isDeleted" column="is_deleted"/>
        <result property="status" column="status"/>
        <result property="lng" column="lng"/>
        <result property="lat" column="lat"/>
        <result property="address" column="address"/>
        <result property="viewType" column="view_type"/>
        <collection property="taskRepairStepList" column="id" select="selectTaskRepairStepList"
                    javaType="java.util.List" ofType="org.springblade.modules.task.entity.TaskRepairStepEntity"
                    autoMapping="true">
            <id property="repairId" column="id"/>
        </collection>
        <collection property="taskRepairAppraiseList" column="id" select="selectTaskRepairAppraiseList"
                    javaType="java.util.List" ofType="org.springblade.modules.task.entity.TaskRepairAppraiseEntity"
                    autoMapping="true">
            <id property="repairId" column="id"/>
        </collection>
    </resultMap>
    <select id="selectTaskRepairStepList" parameterType="java.lang.Long"
            resultType="org.springblade.modules.task.entity.TaskRepairStepEntity">
        select
        jtrfr.*,
        id,
        repair_id,
        content,
        video_list,
        name,
        mobile,
        user_id,
        people_type,
        create_time,
        update_time,
        image_list
        from
        jczz_task_repair_step
        <where>
            <if test="id != null and id != '' ">repair_id = #{id}</if>
        </where>
    </select>
    <select id="selectTaskRepairAppraiseList" parameterType="java.lang.Long"
            resultType="org.springblade.modules.task.entity.TaskRepairAppraiseEntity">
        select
        id,
        content,
        create_time,
        image_list,
        point,
        repair_id,
        video_list
        from
        jczz_task_repair_appraise
        <where>
            <if test="id != null and id != ''">repair_id = #{id}</if>
        </where>
    </select>
    <sql id="selectTaskReportForRepairs">
        select id,
               task_id,
               address_code,
               type,
               real_name,
               phone,
               remark,
               image_urls,
               confirm_user_id,
               confirm_time,
               confirm_flag,
               confirm_notion,
               create_time,
               create_user,
               create_dept,
               update_time,
               update_user,
               is_deleted,
               status,
               lng,
               lat,
               address,
               view_type
        from jczz_task_report_for_repairs
    </sql>
    <!--自定义分页查询-->
    <select id="selectTaskReportForRepairsPage" resultMap="taskReportForRepairsResult">
        select
        jtrfr.id id,
        jtrfr.task_id,
        jtrfr.address_code,
        jtrfr.type,
        jtrfr.real_name,
        jtrfr.phone,
        jtrfr.remark,
        jtrfr.image_urls,
        jtrfr.confirm_user_id,
        jtrfr.confirm_time,
        jtrfr.confirm_flag,
        jtrfr.confirm_notion,
        jtrfr.create_time,
        jtrfr.create_user,
        jtrfr.create_dept,
        jtrfr.update_time,
        jtrfr.update_user,
        jtrfr.is_deleted,
        jtrfr.status,
        jtrfr.lng,
        jtrfr.lat,
        jtrfr.address,
        jtrfr.view_type,
        jda.address_name as addressName
        from jczz_task_report_for_repairs jtrfr
        left join jczz_doorplate_address jda on jda.address_code = jtrfr.address_code
        left join jczz_grid_range jgr on jgr.house_code = jtrfr.address_code
        left join jczz_grid jg on jg.id = jgr.grid_id and jg.is_deleted = 0
        left join blade_region br on br.code = jg.community_code
        where jtrfr.is_deleted = 0
        <if test="vo.createUser != null and vo.createUser != ''">
            AND jtrfr.create_user = #{vo.createUser}
@@ -40,11 +174,23 @@
        <if test="vo.confirmFlag != null">
            AND jtrfr.confirm_flag = #{vo.confirmFlag}
        </if>
        <if test="vo.confirmUserId != null">
            AND jtrfr.confirm_user_id = #{vo.confirmUserId}
        </if>
        <if test="vo.status != null">
            AND jtrfr.status = #{vo.status}
        </if>
        <if test="vo.addressCode != null">
            AND jtrfr.address_code = #{vo.addressCode}
        </if>
        <if test="vo.viewType != null">
            AND jtrfr.view_type = #{vo.viewType}
        </if>
        <if test="vo.startTime != null and vo.startTime != '' and vo.endTime != null and vo.endTime != '' ">
            AND jtrfr.create_time BETWEEN #{vo.startTime} and #{vo.endTime}
        </if>
        <if test="vo.regionCode != null and vo.regionCode !='' ">
            and jg.community_code like concat('%',#{vo.regionCode},'%')
        </if>
        <if test="vo.roleName!=null and vo.roleName!=''">
            <if test="vo.roleName=='网格员'">
@@ -74,7 +220,6 @@
        LEFT JOIN jczz_doorplate_address jda ON jtrfr.address_code = jda.address_code
        WHERE
        jda.nei_code = #{code}
        AND jda.unit_code IS NOT NULL
        AND jtrfr.is_deleted = 0
        <if test="status != null">
            and jtrfr.confirm_flag = #{status}
@@ -83,18 +228,27 @@
            and jtrfr.type = #{type}
        </if>
        <if test="userId != null">
            AND EXISTS (
            SELECT
            *
        <if test="userId != null and roleType == '1'">
            AND jda.address_code IN (
            SELECT DISTINCT
            jgr.house_code
            FROM
            jczz_grid jg
            LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
            LEFT JOIN jczz_grid_range jgr ON jgr.grid_id = jg.id
            WHERE
            jgm.user_id = #{userId}
            AND jtrfr.address_code = jgr.house_code
            AND jg.is_deleted = 0
            )
        </if>
        <if test="userId != null and roleType == '3'">
            AND jda.address_code IN (SELECT
            jda.address_code
            FROM
            jczz_doorplate_address jda
            LEFT JOIN jczz_community jc ON jc.CODE = jda.nei_code
            WHERE
            jc.res_police_user_id = #{userId})
            )
        </if>
    </select>
@@ -113,19 +267,32 @@
    <select id="getStatistics" resultType="java.lang.Integer">
        SELECT
            count(1)
        count( 1 )
        FROM
            jczz_gridman jgm
                LEFT JOIN jczz_grid jg ON jgm.grid_id = jg.id
                LEFT JOIN jczz_grid_range jgr ON jg.id = jgr.grid_id
                LEFT JOIN jczz_task_report_for_repairs jtr ON jgr.house_code = jtr.address_code
                LEFT JOIN jczz_doorplate_address jda ON jda.address_code = jtr.address_code
        WHERE
            jg.is_deleted = 0
          and jtr.confirm_flag = 1
          AND jgm.user_id = #{userId}
        jczz_task_report_for_repairs jtr
        LEFT JOIN jczz_doorplate_address jda ON jtr.address_code = jda.address_code
        <where>
            <if test="neiCode != null and neiCode != ''">
                and jda.nei_code = #{neiCode}
            </if>
            <if test="userId != null">
                AND jtr.address_code IN (
                SELECT
                jgr.house_code
                FROM
                jczz_grid_range jgr
                LEFT JOIN jczz_grid jg ON jg.id = jgr.grid_id
                LEFT JOIN jczz_gridman jgm ON jg.id = jgm.grid_id
                WHERE
                jg.is_deleted = 0
                AND jgm.user_id = #{userId} )
            </if>
            and jtr.is_deleted = 0
            and jtr.confirm_flag = 1
        </where>
    </select>