<?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.PatrolManageRecordMapper"> <!-- 通用映射列 --> <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.PatrolManageRecord"> <result column="id" property="id"/> <result column="patrol_type" property="patrolType"/> <result column="bind_no" property="bindNo"/> <result column="name" property="name"/> <result column="description" property="description"/> <result column="pic_no" property="picNo"/> <result column="create_user_no" property="createUserNo"/> <result column="user_name" property="createUserName"/> <result column="distance" property="distance"/> <result column="coordinate" property="coordinate"/> <result column="start_time" property="startTime"/> <result column="end_time" property="endTime"/> <result column="patrol_time" property="patrolTime"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <!-- 通用数据库列 --> <sql id="Base_Column_List"> id, patrol_type, bind_no, `name`, description, pic_no, create_user_no, create_user_name, distance, coordinate, start_time, end_time, patrol_time, create_time, update_time </sql> <resultMap id="patrolDto" type="com.newfiber.api.pc.model.River.PatrolManageRecordDto"> <result column="id" property="id"/> <result column="patrol_type" property="patrolType"/> <result column="bind_no" property="bindNo"/> <result column="projectName" property="projectName"/> <result column="name" property="name"/> <result column="description" property="description"/> <result column="pic_no" property="picNo"/> <result column="create_user_no" property="createUserNo"/> <result column="distance" property="distance"/> <result column="coordinate" property="coordinate"/> <result column="start_time" property="startTime"/> <result column="end_time" property="endTime"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> <result column="user_name" property="userName"/> <collection property="recordPics" ofType="com.newfiber.api.pc.model.River.PartolManagePic"> <id column="picId" jdbcType="BIGINT" property="id"/> <result column="pNo" jdbcType="VARCHAR" property="picNo"/> <result column="pic_name" jdbcType="VARCHAR" property="picName"/> <result column="pic_address" jdbcType="VARCHAR" property="picAddress"/> <result column="pUser" jdbcType="VARCHAR" property="createUserNo"/> <result column="pTime" jdbcType="TIMESTAMP" property="createTime"/> <result column="pType" jdbcType="TINYINT" property="type"/> </collection> </resultMap> <select id="patrolDetail" resultMap="patrolDto"> SELECT pmr.id,pmr.patrol_type,pmr.bind_no,pmb.project_name projectName,pmr.`name`,pmr.description,pmr.pic_no, pmr.create_user_no,pmr.distance,pmr.coordinate,pmr.start_time,pmr.end_time, pmr.create_time,pmr.update_time,pmr.create_user_name as user_name, pic.id as picId,pic.pic_no as pNo, pic.pic_name,pic.pic_address,pic.create_user_no as pUser,pic.create_time as pTime,pic.type as pType FROM `patrol_manage_record` pmr inner join patrol_manage_user_relation pmur on pmr.bind_no = pmur.bind_no left join patrol_manage_base pmb on pmr.bind_no = pmb.id left join partol_manage_pic pic on pmr.pic_no = pic.pic_no where 1=1 <!-- <if test="userNo != null and userNo != ''"> and (pmur.patrol_user_no = #{userNo} or pmur.duty_user_no=#{userNo} or pmur.handler_no = #{userNo} or pmur.leader_no = #{userNo} or pmr.create_user_no = #{userNo}) </if>--> <if test="patrolType != null and patrolType != ''"> and pmr.patrol_type = #{patrolType} </if> <if test="patrolNo != null and patrolNo != ''"> and pmr.id = #{patrolNo} </if> </select> <select id="patrolList" resultMap="patrolDto"> SELECT pmr.id,pmr.patrol_type,pmr.bind_no,pmb.project_name projectName,pmr.`name`,pmr.description,pmr.pic_no, pmr.create_user_no,pmr.distance,pmr.coordinate,pmr.start_time,pmr.end_time, pmr.create_time,pmr.update_time,pmr.create_user_name as user_name, pic.id as picId,pic.pic_no as pNo, pic.pic_name,pic.pic_address,pic.create_user_no as pUser,pic.create_time as pTime,pic.type as pType FROM `patrol_manage_record` pmr inner join patrol_manage_user_relation pmur on pmr.bind_no = pmur.bind_no left join patrol_manage_base pmb on pmr.bind_no = pmb.id left join partol_manage_pic pic on pmr.pic_no = pic.pic_no where 1=1 <if test="userNo != null and userNo != ''"> and pmr.create_user_no = #{userNo} </if> <if test="patrolType != null and patrolType != ''"> and pmr.patrol_type = #{patrolType} </if> <if test="problemName != null and problemName != ''"> and pmr.`name` like concat('%',#{problemName},'%') </if> group by pmr.id,pmr.patrol_type,pmr.bind_no,pmb.project_name ,pmr.`name`,pmr.description,pmr.pic_no, pmr.create_user_no,pmr.distance,pmr.coordinate,pmr.start_time,pmr.end_time, pmr.create_time,pmr.update_time,pmr.create_user_name , pic.id ,pic.pic_no, pic.pic_name,pic.pic_address,pic.create_user_no ,pic.create_time,pic.type order by pmr.create_time desc </select> <select id="patrolListByUserNos" resultMap="patrolDto"> SELECT pmr.id,pmr.patrol_type,pmr.bind_no,pmb.project_name projectName,pmr.`name`,pmr.description,pmr.pic_no, pmr.create_user_no,pmr.distance,pmr.start_time,pmr.end_time, pmr.create_time,pmr.update_time,pmr.create_user_name as user_name, pic.id as picId,pic.pic_no as pNo, pic.pic_name,pic.pic_address,pic.create_user_no as pUser,pic.create_time as pTime,pic.type as pType FROM `patrol_manage_record` pmr inner join patrol_manage_user_relation pmur on pmr.bind_no = pmur.bind_no inner join patrol_manage_base pmb on pmr.bind_no = pmb.id left join partol_manage_pic pic on pmr.pic_no = pic.pic_no where 1=1 <if test="userNos != null and userNos.size > 0"> and pmr.create_user_no in <foreach collection="userNos" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> <if test="patrolType != null and patrolType != ''"> and pmr.patrol_type = #{patrolType} </if> <if test="problemName != null and problemName != ''"> and pmr.`name` like concat('%',#{problemName},'%') </if> <if test="userName != null and userName != ''"> and pmr.`create_user_name` like concat('%',#{userName},'%') </if> <if test="projectName != null and projectName != ''"> and pmb.`project_name` like concat('%',#{projectName},'%') </if> <if test="startTime != null and startTime != ''"> and pmr.`create_time` > #{startTime} </if> <if test="endTime != null and endTime != ''"> and pmr.`create_time` < #{endTime} </if> group by pmr.id,pmr.patrol_type,pmr.bind_no,pmb.project_name ,pmr.`name`,pmr.description,pmr.pic_no, pmr.create_user_no,pmr.distance,pmr.coordinate,pmr.start_time,pmr.end_time, pmr.create_time,pmr.update_time,pmr.create_user_name , pic.id ,pic.pic_no, pic.pic_name,pic.pic_address,pic.create_user_no ,pic.create_time,pic.type order by pmr.create_time desc </select> <select id="getUserList" resultMap="patrolDto"> SELECT pmr.id,pmr.patrol_type,pmr.bind_no,pmb.project_name projectName,pmr.`name`,pmr.description,pmr.pic_no, pmr.create_user_no,pmr.distance,pmr.coordinate,pmr.start_time,pmr.end_time, pmr.create_time,pmr.update_time,pmr.create_user_name as user_name, pic.id as picId,pic.pic_no as pNo, pic.pic_name,pic.pic_address,pic.create_user_no as pUser,pic.create_time as pTime,pic.type as pType FROM `patrol_manage_record` pmr inner join patrol_manage_user_relation pmur on pmr.bind_no = pmur.bind_no left join patrol_manage_base pmb on pmr.bind_no = pmb.id left join partol_manage_pic pic on pmr.pic_no = pic.pic_no where 1=1 <if test="userNo != null and userNo != ''"> and pmr.create_user_no = #{userNo} </if> <if test="patrolName != null and patrolName != ''"> and pmr.name like concat('%',#{patrolName},'%') </if> <if test="patrolType != null"> and pmr.patrol_type = #{patrolType} </if> <if test="startTime != null"> and pmr.start_time > #{startTime} </if> <if test="endTime != null"> and pmr.start_time < #{endTime} </if> group by pmr.id,pmr.patrol_type,pmr.bind_no,pmb.project_name ,pmr.`name`,pmr.description,pmr.pic_no, pmr.create_user_no,pmr.distance,pmr.coordinate,pmr.start_time,pmr.end_time, pmr.create_time,pmr.update_time,pmr.create_user_name , pic.id ,pic.pic_no, pic.pic_name,pic.pic_address,pic.create_user_no ,pic.create_time,pic.type order by pmr.create_time desc </select> <select id="countByPatrolRealStaff" resultType="com.newfiber.api.pc.model.River.SimplePatrolManageRecord"> select pmr.id as id,pmr.patrol_type as patrolType,pmr.create_user_no as createUserNo from patrol_manage_record pmr where 1=1 <if test="patrolType != null"> and pmr.patrol_type = #{patrolType} </if> <if test="startTime != null"> and pmr.start_time > #{startTime} </if> <if test="endTime != null"> and pmr.start_time < #{endTime} </if> </select> </mapper>