MaintainPlanCommitMapper.xml 3.98 KB
<?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.zteits.urbanops.module.garden.dal.mysql.maintainplan.MaintainPlanCommitMapper">

    <!--
        一般情况下,尽可能使用 Mapper 进行 CRUD 增删改查即可。
        无法满足的场景,例如说多表关联查询,才使用 XML 编写 SQL。
        代码生成器暂时只生成 Mapper XML 文件本身,更多推荐 MybatisX 快速开发插件来生成查询。
        文档可见:https://www.iocoder.cn/MyBatis/x-plugins/
     -->

    <select id="selectForPage" resultType="com.zteits.urbanops.module.garden.controller.admin.maintainplan.vo.MaintainPlanCommitRespVO">
        SELECT
            a.batch_no,
            a.plan_no,
            b.plan_name,
            b.road_id,
            b.road_name,
            b.level_id,
            b.plan_attr,
            b.plan_type_id,
            b.cycle_id,
            b.plan_num,
            b.busi_line,
            b.plan_finish_num,
            a.begin_time,
            a.end_time,
            a.company_id,
            a.dept_id,
            a.finish_percent as finishPercent,
            c.finish_time,
            c.user_name
        FROM
            garden_maintain_plan_detail a,
            garden_maintain_plan b,
            (SELECT plan_no,finish_time,user_id,user_name  FROM garden_maintain_plan_commit ORDER BY id ASC LIMIT 1) c
        WHERE
            a.batch_no = b.batch_no
          AND a.plan_no = c.plan_no
        <if test="req.planNo != null and req.planNo !=''">
            and a.plan_no = #{req.planNo}
        </if>
        <if test="req.planName != null and req.planName !=''">
            and b.plan_name = #{req.planName}
        </if>
        <if test="req.roadName != null and req.roadName !=''">
            AND b.road_name  LIKE CONCAT(#{req.roadName},'%')
        </if>
        <if test="req.levelId != null">
            and b.level_id = #{req.levelId}
        </if>
        <if test="busiLineList != null and busiLineList.size() > 0">
            AND b.busi_line IN
            <foreach collection="busiLineList" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        <if test="req.planTypeId != null">
            and b.plan_type_id = #{req.planTypeId}
        </if>
        <if test="req.planAttr != null">
            and b.plan_attr = #{req.planAttr}
        </if>
        <if test="req.companyId != null">
            and a.company_id = #{req.companyId}
        </if>
        <if test="req.deptId != null">
            and a.dept_id = #{req.deptId}
        </if>
<!--        <if test="req.roleName != null and req.roleName !=''">-->
<!--            AND c.role_name  LIKE CONCAT(#{req.roleName},'%')-->
<!--        </if>-->
        <if test="req.userName != null and req.userName !=''">
            AND c.user_name  LIKE CONCAT(#{req.userName},'%')
        </if>
        <if test="req.finishTime != null">
            AND DATE_FORMAT(c.finish_time, '%Y-%m-%d') = #{req.finishTime}
        </if>
    </select>

   <select id="appMaintainPlanCommitDetailPage" resultType="com.zteits.urbanops.module.garden.controller.app.maintainplan.vo.AppMaintainPlanCommitDetailPageRespVO">
       SELECT
       a.batch_no,
       a.plan_no,
       b.plan_name,
       b.road_id,
       b.road_name,
       b.level_id,
       b.plan_attr,
       b.plan_type_id,
       b.cycle_id,
       b.plan_num,
       b.busi_line,
       b.plan_finish_num,
       a.begin_time,
       a.end_time,
       a.company_id,
       a.finish_state,
       a.dept_id,
       a.finish_percent,
       c.begin_img,
       c.img_host,
       c.finish_time,
       c.user_name
       FROM
       garden_maintain_plan_detail a,
       garden_maintain_plan b,
       garden_maintain_plan_commit c
       WHERE
       a.batch_no = b.batch_no
       AND a.batch_no = c.batch_no
       AND a.plan_no = c.plan_no
       AND c.plan_no = #{req.planNo}
   </select>
</mapper>