<?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.newfiber.api.pc.dao.RiverManage.PatrolManageConfigMapper"> <!-- 通用映射列 --> <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.PatrolManageConfig"> <result column="id" property="id"/> <result column="patrol_type" property="patrolType"/> <result column="bind_no" property="bindNo"/> <result column="project_name" property="projectName"/> <result column="day_count" property="dayCount"/> <result column="day_time" property="dayTime"/> <result column="week_count" property="weekCount"/> <result column="month_count" property="monthCount"/> <result column="year_count" property="yearCount"/> <result column="creare_user" property="creareUser"/> <result column="update_user" property="updateUser"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <!-- 通用数据库列 --> <sql id="Base_Column_List"> id, patrol_type, bind_no, project_name, day_count, day_time, week_count, month_count, year_count, creare_user, update_user, create_time, update_time </sql> <select id="selectCountNum" resultType="com.newfiber.api.pc.model.River.PatrolManageConfigDto"> SELECT pmr.bind_no, SUM(CASE WHEN pmr.create_time > #{dayStart} and pmr.create_time < #{dayEnd} THEN 1 ELSE 0 END) AS dayNum, SUM(CASE WHEN pmr.create_time > #{weekStart} and pmr.create_time < #{weekEnd} THEN 1 ELSE 0 END) AS weekNum, SUM(CASE WHEN pmr.create_time > #{monthStart} and pmr.create_time < #{monthEnd} THEN 1 ELSE 0 END) AS monthNum, SUM(CASE WHEN pmr.create_time > #{yearStart} and pmr.create_time < #{yearEnd} THEN 1 ELSE 0 END) AS yearNum FROM `patrol_manage_record` pmr where bind_no is not null and pmr.patrol_type = #{patrolType} group by pmr.bind_no; </select> <select id="listPatrolAll" resultType="com.newfiber.api.pc.model.River.PatrolCountDto"> SELECT pmr.bind_no, SUM(CASE WHEN pmr.create_time > #{startTime} and pmr.create_time < #{endTime} THEN 1 ELSE 0 END) AS countNum FROM `patrol_manage_record` pmr where pmr.patrol_type = #{patrolType} and bind_no is not null group by pmr.bind_no; </select> <select id="selectByType" resultType="com.newfiber.api.pc.model.River.PatrolManageConfig"> SELECT pmb.id, pmb.patrol_type, pmb.id as bind_no, pmb.project_name, pmc.day_count, pmc.week_count, pmc.month_count, pmc.year_count, pmc.creare_user, pmc.update_user, pmc.create_time, pmc.update_time, pmr.handler_name as userName FROM `patrol_manage_base` pmb left join patrol_manage_config pmc on pmb.id=pmc.bind_no left join patrol_manage_user_relation pmr on pmb.id = pmr.bind_no where pmb.patrol_type = #{patrolType} </select> </mapper>