InspectionPlanMapper.xml 2.6 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.inspectionplan.InspectionPlanMapper">

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

    <delete id="deleteByBatchNo">
        delete from garden_inspection_plan where batch_no =#{batchNo}
    </delete>

    <select id="getInspectionPlanAppPage" resultType="com.zteits.urbanops.module.garden.controller.app.inspectionplan.vo.AppInspectionPlanRespVO">
        SELECT
           a.batch_no,
            a.road_id,
            a.road_name,
            a.plan_type_id,
            a.level_id,
            a.finish_state,
            a.begin_time,
            a.end_time
        FROM
            garden_inspection_plan a,
            garden_inspection_plan_role b
        WHERE
            a.batch_no = b.batch_no
          AND a.dept_id =b.dept_id
          AND a.deleted=0
           AND a.company_id = #{req.companyId}
          <if test="req.roadName != null and req.roadName !=''">
            AND a.road_name LIKE CONCAT('%',#{req.roadName},'%')
          </if>
        <if test="req.roleIds != null and req.roleIds.size() > 0">
            AND b.role_id IN
            <foreach collection="req.roleIds" item="roleId" open="(" separator="," close=")">
                #{roleId}
            </foreach>
        </if>
        <if test="req.busiLineList != null and req.busiLineList.size() > 0">
            AND a.busi_line IN
            <foreach collection="req.busiLineList" item="busiLine" open="(" separator="," close=")">
                #{busiLine}
            </foreach>
        </if>
        <!--状态 1:未完成;2:已完成;3:已失效-->
        <if test="req.finishState == 3">
            <![CDATA[and a.end_time < #{req.localDate}]]>
        </if>
        <if test="req.finishState == 2">
            and a.finish_state = #{req.finishState}
        </if>
        <if test="req.finishState == 1">
            and a.finish_state = #{req.finishState}
            <![CDATA[and a.end_time >= #{req.localDate}]]>
        </if>
        GROUP BY
        a.batch_no,
        a.road_id,
        a.road_name,
        a.plan_type_id,
        a.level_id,
        a.begin_time,
        a.end_time
    </select>
</mapper>