<?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.TaskMapper"> <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.entity.Task"> <result column="id" property="id"/> <result column="task_no" property="taskNo"/> <result column="expected_end_time" property="expectedEndTime"/> <result column="task_name" property="taskName"/> <result column="task_level" property="taskLevel"/> <result column="task_state" property="taskState"/> <result column="task_state_name" property="taskStateName"/> <result column="duty_user" property="dutyUser"/> <result column="duty_user_name" property="dutyUserName"/> <result column="create_user" property="createUser"/> <result column="create_user_name" property="createUserName"/> <result column="address" property="address"/> <result column="longitude" property="longitude"/> <result column="latitude" property="latitude"/> <result column="task_sign" property="taskSign"/> <result column="description" property="description"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <!-- 閫氱敤鏁版嵁搴撳垪 --> <sql id="Base_Column_List"> id, task_no, expected_end_time, task_name, task_level, task_state, task_state_name, duty_user, duty_user_name, create_user, create_user_name, address, longitude, latitude, task_sign, description, create_time, update_time </sql> <resultMap id="taskVos" type="com.newfiber.api.pc.model.vo.TaskVo"> <result column="id" property="id"/> <result column="task_no" property="taskNo"/> <result column="expected_end_time" property="expectedEndTime"/> <result column="task_name" property="taskName"/> <result column="task_level" property="taskLevel"/> <result column="task_state" property="taskState"/> <result column="task_state_name" property="taskStateName"/> <result column="duty_user" property="dutyUser"/> <result column="duty_user_name" property="dutyUserName"/> <result column="create_user" property="createUser"/> <result column="create_user_name" property="createUserName"/> <result column="address" property="address"/> <result column="longitude" property="longitude"/> <result column="latitude" property="latitude"/> <result column="task_sign" property="taskSign"/> <result column="description" property="description"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> <collection property="taskUsers" ofType="com.newfiber.api.pc.model.entity.TaskUser"> <result column="tid" property="id"/> <result column="task_id" property="taskId"/> <result column="unit" property="unit"/> <result column="job" property="job"/> <result column="user_no" property="userNo"/> <result column="user_name" property="userName"/> <result column="phone" property="phone"/> <result column="user_type" property="userType"/> <result column="state" property="state"/> <result column="state_desc" property="stateDesc"/> </collection> </resultMap> <select id="selectAppTaskList" resultType="com.newfiber.api.pc.model.entity.Task"> SELECT t.id,t.task_no,t.expected_end_time,t.task_name,t.task_level,t.task_state,t.task_state_name, t.duty_user,t.duty_user_name,t.create_user,t.create_user_name,t.address,t.longitude,t.latitude,tu.user_no,tu.user_name,tu.unit, t.description,t.create_time,t.update_time,tu.user_type,tu.state,tu.state_desc,tu.id as taskUserId,tu.unit_id,ts.task_state userState FROM `task_user` tu left join task_state ts on tu.task_id = ts.task_id left join task t on t.id =tu.task_id where ts.operation_user = #{userNo} and tu.user_no = #{userNo} GROUP BY tu.task_id order by tu.id desc </select> <select id="selectDutyTaskList" resultType="com.newfiber.api.pc.model.entity.Task"> SELECT t.id,t.task_no,t.expected_end_time,t.task_name,t.task_level,t.task_state,t.task_state_name, t.duty_user,t.duty_user_name,t.create_user,t.create_user_name,t.address,t.longitude,t.latitude, t.description,t.create_time,t.update_time,tu.user_no,tu.user_name,tu.unit,tu.user_type,tu.state,tu.state_desc,tu.id as taskUserId,tu.unit_id,ts.task_state userState FROM `task_user` tu left join task_state ts on tu.task_id = ts.task_id left join task t on t.id =tu.task_id where 1=1 and tu.user_type != 3 <if test="list != null and list.size > 0"> AND tu.task_id in <foreach collection="list" index="index" item="item" open="(" separator="," close=")"> #{item} </foreach> </if> group by tu.id order by tu.id desc </select> <select id="selectPcTaskList" resultType="com.newfiber.api.pc.model.entity.Task"> SELECT t.id,t.task_no,t.expected_end_time,t.task_name,t.task_level,t.task_state,t.task_state_name, t.duty_user,t.duty_user_name,t.create_user,t.create_user_name,t.address,t.longitude,t.latitude, t.description,t.create_time,t.update_time,t.task_sign FROM `task` t left join task_user tu on t.id = tu.task_id where 1=1 <if test="userNo!=null and userNo !=''"> and (t.duty_user = #{userNo} or t.create_user = #{userNo}) </if> <if test="type!=null and type !=''"> and t.task_state = #{type} </if> <if test="taskName!=null and taskName !=''"> and t.task_name like concat('%',#{taskName},'%') </if> group by t.id order by t.id desc </select> <select id="selectTaskById" resultType="com.newfiber.api.pc.model.entity.Task"> SELECT t.id,t.task_no,t.expected_end_time,t.task_name,t.task_level,t.task_state,t.task_state_name, t.duty_user,t.duty_user_name,t.create_user,t.create_user_name,t.address,t.longitude,t.latitude,t.task_sign,tu.user_no,tu.user_name, t.description,t.create_time,t.update_time,tu.user_type,tu.state,tu.state_desc,tu.id as taskUserId,ts.task_state as userState FROM `task` t inner join task_user tu on t.id = tu.task_id left join task_state ts on t.id = ts.task_id where tu.id = #{id} <if test="userNo!=null and userNo !=''"> and ts.operation_user = #{userNo} </if> limit 1 </select> <select id="selectTaskCount" resultType="com.newfiber.api.pc.model.entity.TaskUserCount"> SELECT tu.task_id, SUM(CASE WHEN tu.state=1 THEN 1 ELSE 0 END) AS unRead, SUM(CASE WHEN tu.state >= 2 THEN 1 ELSE 0 END) AS `isRead`, SUM(CASE WHEN tu.state = 3 THEN 1 ELSE 0 END) AS `unComplete`, SUM(CASE WHEN tu.state=4 THEN 1 ELSE 0 END) AS `complete`, SUM(CASE WHEN tu.state < 3 and t.expected_end_time < now() and t.task_sign !=1 THEN 1 ELSE 0 END) AS `completeOverTime`, count(tu.id) as total FROM `task_user` tu left join task t on tu.task_id = t.id where task_id = #{taskId} and tu.user_type!=3 <if test="orgType!= null"> and org_type = #{orgType} </if> </select> <select id="selectAllTaskList" resultType="com.newfiber.api.pc.model.entity.Task"> SELECT t.id,t.task_no,t.expected_end_time,t.task_name,t.task_level,t.task_state,t.task_state_name, t.duty_user,t.duty_user_name,t.create_user,t.create_user_name,t.address,t.longitude,t.latitude, t.description,t.create_time,t.update_time FROM `task` t </select> <select id="selectByDutyUser" resultType="com.newfiber.api.pc.model.entity.Task"> SELECT <include refid="Base_Column_List"/> FROM `task` t where t.duty_user = #{userNo} </select> </mapper>