wlzboy
1 天以前 08f95b2f159b56fa3bd4f4b348855989de8aa456
ruoyi-system/src/main/resources/mapper/system/SysTaskMapper.xml
@@ -35,6 +35,7 @@
        <result property="assigneeName"     column="assignee_name"     />
        <result property="deptName"         column="dept_name"         />
        <result property="vehicleNo"        column="vehicle_no"        />
        <result property="isHeadPush"       column="is_head_push"      />
        <collection property="assignedVehicles" ofType="SysTaskVehicle">
            <result property="id"            column="tv_id"             />
            <result property="taskId"        column="tv_task_id"        />
@@ -57,6 +58,7 @@
               t.planned_start_time, t.planned_end_time,
               t.actual_start_time, t.actual_end_time, t.creator_id, t.assignee_id, t.dept_id,
               t.create_time, t.update_time, t.create_by, t.update_by, t.remark, t.del_flag, t.legacy_synced,
               t.is_head_push,
               u1.nick_name as creator_name, u2.nick_name as assignee_name, d.dept_name,
               (
                   select v2.vehicle_no 
@@ -88,16 +90,36 @@
            <if test="taskStatus != null  and taskStatus != ''"> and t.task_status = #{taskStatus}</if>
            <if test="vehicleNo != null  and vehicleNo != ''"> and v.vehicle_no like concat('%', #{vehicleNo}, '%')</if>
            <!-- 综合查询:当前用户所在机构 OR 当前用户创建 OR 分配给当前用户 -->
            <if test="(creatorId != null and creatorId != 0) or (assigneeId != null and assigneeId != 0) or (deptId != null and deptId != 0)">
            <if test="(creatorId != null and creatorId != 0) or (assigneeId != null and assigneeId != 0) or (deptId != null and deptId != 0) or (deptIds != null and deptIds.size() > 0)">
                and (
                    <if test="deptId != null and deptId != 0">t.dept_id = #{deptId}</if>
                    <if test="creatorId != null and creatorId != 0">
                    <!-- 查询指定分公司及其所有子部门的任务 -->
                    <if test="deptId != null and deptId != 0">
                        (t.dept_id = #{deptId} OR t.dept_id IN (
                            SELECT dept_id FROM sys_dept
                            WHERE del_flag = '0' AND find_in_set(#{deptId}, ancestors)
                        ))
                    </if>
                    <!-- 查询多个分公司及其所有子部门的任务 -->
                    <if test="deptIds != null and deptIds.size() > 0">
                        <if test="deptId != null and deptId != 0"> or </if>
                        (
                            <foreach collection="deptIds" item="branchDeptId" separator=" OR ">
                                (t.dept_id = #{branchDeptId} OR t.dept_id IN (
                                    SELECT dept_id FROM sys_dept
                                    WHERE del_flag = '0' AND find_in_set(#{branchDeptId}, ancestors)
                                ))
                            </foreach>
                        )
                    </if>
                    <if test="creatorId != null and creatorId != 0">
                        <if test="(deptId != null and deptId != 0) or (deptIds != null and deptIds.size() > 0)"> or </if>
                        t.creator_id = #{creatorId}
                    </if>
                    <if test="assigneeId != null and assigneeId != 0">
                        <if test="(deptId != null and deptId != 0) or (creatorId != null and creatorId != 0)"> or </if>
                        t.assignee_id = #{assigneeId}
                        <if test="(deptId != null and deptId != 0) or (deptIds != null and deptIds.size() > 0) or (creatorId != null and creatorId != 0)"> or </if>
                        t.task_id IN (
                            SELECT task_id FROM sys_task_assignee WHERE user_id = #{assigneeId}
                        )
                    </if>
                )
            </if>
@@ -145,7 +167,12 @@
    <select id="selectMyTasks" parameterType="Long" resultMap="SysTaskResult">
        <include refid="selectSysTaskVo"/>
        where t.del_flag = '0' and (t.creator_id = #{userId} or t.assignee_id = #{userId})
        where t.del_flag = '0' and (
            t.creator_id = #{userId}
            OR t.task_id IN (
                SELECT task_id FROM sys_task_assignee WHERE user_id = #{userId}
            )
        )
        order by 
            CASE t.task_status
                WHEN 'PENDING' THEN 1
@@ -159,6 +186,19 @@
            END,
            t.update_time desc,
            t.create_time desc
    </select>
    <select id="selectTaskByVehicleIdAndDate" resultMap="SysTaskResult">
        select tv.task_id, t.actual_start_time,
        IFNULL(t.actual_end_time, NOW()) as actual_end_time
        from sys_task_vehicle tv
        inner join sys_task t on tv.task_id = t.task_id
        where tv.vehicle_id = #{vehicleId}
        and t.del_flag = '0'
        and (
        (t.actual_start_time &lt;= #{endTime} and (t.actual_end_time is null or t.actual_end_time &gt;= #{startTime}))
        )
        order by t.actual_start_time
    </select>
    <select id="selectTaskStatistics" resultType="TaskStatisticsVO">
@@ -196,6 +236,7 @@
            <if test="creatorId != null">creator_id,</if>
            <if test="assigneeId != null">assignee_id,</if>
            <if test="deptId != null">dept_id,</if>
            <if test="isHeadPush != null">is_head_push,</if>
            <if test="createTime != null">create_time,</if>
            update_time,
            <if test="createBy != null">create_by,</if>
@@ -222,6 +263,7 @@
            <if test="creatorId != null">#{creatorId},</if>
            <if test="assigneeId != null">#{assigneeId},</if>
            <if test="deptId != null">#{deptId},</if>
            <if test="isHeadPush != null">#{isHeadPush},</if>
            <if test="createTime != null">#{createTime},</if>
            now(),
            <if test="createBy != null">#{createBy},</if>
@@ -252,6 +294,7 @@
            <if test="creatorId != null">creator_id = #{creatorId},</if>
            <if test="assigneeId != null">assignee_id = #{assigneeId},</if>
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="isHeadPush != null">is_head_push = #{isHeadPush},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null">update_by = #{updateBy},</if>
            <if test="remark != null">remark = #{remark},</if>