<?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.PatrolManageBaseMapper"> <!-- 通用映射列 --> <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.River.PatrolManageBase"> <result column="id" property="id"/> <result column="patrol_type" property="patrolType"/> <result column="project_name" property="projectName"/> <result column="project_parent_id" property="projectParentId"/> <result column="area_code" property="areaCode"/> <result column="area_name" property="areaName"/> <result column="start_name" property="startName"/> <result column="end_name" property="endName"/> <result column="length" property="length"/> <result column="unit" property="unit"/> <result column="description" property="description"/> <result column="cretae_time" property="cretaeTime"/> <result column="update_time" property="updateTime"/> </resultMap> <resultMap id="patrolDto" type="com.newfiber.api.pc.model.River.PatrolProblemCountDto"> <result column="id" property="id"/> <result column="project_name" property="projectName"/> <collection column="cid" property="childs" ofType="long"> <result column="cid" /> </collection> </resultMap> <!-- 通用数据库列 --> <sql id="Base_Column_List"> id, patrol_type, project_name, project_parent_id, area_code, area_name, start_name, end_name, user_no, `name`, phone, `length`, `unit`, description, cretae_time, update_time </sql> <select id="selectListByTypeAndName" resultType="com.newfiber.api.pc.model.River.PatrolManageBaseDto"> SELECT pmb.id,pmb.patrol_type,pmb.project_name,pmb.`length`,pmb.`unit`,pmb.description,pmb.cretae_time, pmb.update_time,pmur.id as relationId,pmur.bind_no, pmur.handler_no,pmur.handler_name,pmut.user_no as dutyUserNo,pmut.user_name as dutyUserName from patrol_manage_base pmb left join patrol_manage_user_relation pmur on pmb.id=pmur.bind_no left join patrol_manage_user_type pmut on pmut.user_type = 3 where 1=1 <if test="patrolType != null and patrolType != ''"> and pmut.patrol_type = #{patrolType} </if> <if test="patrolType != null and patrolType != ''"> and pmb.patrol_type = #{patrolType} </if> <if test="projectName != null and projectName != ''"> and pmb.project_name like concat('%',#{projectName},'%') </if> group by pmb.id order by pmb.update_time </select> <select id="selectListByIds" resultType="com.newfiber.api.pc.model.River.PatrolManageBase"> SELECT <include refid="Base_Column_List"/> from patrol_manage_base pmb where 1=1 and patrol_type = #{patrolType} <if test="collect != null and collect.size > 0"> and pmb.id in <foreach collection="collect" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> order by pmb.id desc </select> <select id="selectProjectList" resultType="com.newfiber.api.pc.model.River.PatrolManageProjectDto"> SELECT pmb.id,pmb.patrol_type,pmb.project_name,pmur.handler_no,pmur.handler_name FROM `patrol_manage_base` pmb inner join patrol_manage_user_relation pmur on pmb.id=pmur.bind_no where 1=1 <if test="projectParentId != null"> and pmb.project_parent_id = #{projectParentId} </if> <if test="patrolType != null"> and pmb.patrol_type = #{patrolType} </if> <if test="projectName != null and projectName != ''"> and pmb.project_name like concat('%',#{projectName},'%') </if> <if test="handlerNo != null and handlerNo != ''"> and pmur.handler_no =#{handlerNo} </if> </select> <select id="selectCountList" resultMap="patrolDto"> select pmb.id,pmb.project_name,pmb2.id as cid from patrol_manage_base pmb inner join patrol_manage_base pmb2 on pmb.id = pmb2.project_parent_id <if test="patrolType != null"> and pmb.patrol_type = #{patrolType} </if> </select> <select id="getProjectId" resultMap="BaseResultMap"> SELECT <include refid="Base_Column_List"/> FROM `patrol_manage_base` where 1=1 <if test="patrolType != null"> and patrol_type = #{patrolType} </if> and (id = #{projectId} or project_parent_id = #{projectId}) limit 1 </select> <select id="selectProblemCount" resultType="com.newfiber.api.pc.model.River.PatrolProblemTypeCountDto"> select problem_type as problemType,pdc.`name` as problemName,count(pmp.id) as `count` from patrol_manage_problem pmp left join patrol_manage_dic pdc on pmp.problem_type = pdc.patrol_type_id and pdc.source ="problem" where 1=1 and state!=0 and project_main_id is not null <if test="patrolType != null"> and pmp.patrol_type = #{patrolType} </if> <if test="startTime != null"> and pmp.create_time > #{startTime} </if> <if test="endTime != null"> and pmp.create_time < #{endTime} </if> group by problem_type having `count`>0 </select> <select id="selectBase" resultType="com.newfiber.api.pc.model.River.PatrolManageBase"> SELECT <include refid="Base_Column_List"/> FROM `patrol_manage_base` where 1=1 <if test="patrolType != null and patrolType != ''"> and patrol_type = #{patrolType} </if> <if test="areaCode != null and areaCode != ''"> and area_code = #{areaCode} </if> <if test="projectName != null and projectName != ''"> and project_name like concat('%',#{projectName},'%') </if> <if test="projectParentId != null and projectParentId != ''"> and project_parent_id = #{projectParentId} </if> order by update_time desc </select> </mapper>