<?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.TaskUserMapper"> <!-- 通用映射列 --> <resultMap id="BaseResultMap" type="com.newfiber.api.pc.model.entity.TaskUser"> <result column="id" property="id"/> <result column="task_id" property="taskId"/> <result column="unit_id" property="unitId"/> <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"/> <result column="description" property="description"/> <result column="check_state" property="checkState"/> <result column="check_state_desc" property="checkStateDesc"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <!-- 通用数据库列 --> <sql id="Base_Column_List"> id, task_id, unit_id, unit, job, user_no, user_name, phone, user_type, state, description, org_type, org_name, check_state, check_state_desc, state_desc, create_time, update_time </sql> <select id="selectTaskUserList" resultMap="BaseResultMap"> select <include refid="Base_Column_List"/> from task_user tu where tu.task_id in <foreach collection="collect" item="item" open="(" close=")" separator=","> #{item} </foreach> order by tu.id asc </select> <update id="updateByTaskId"> update task_state set task_state = 2 where task_id = #{taskId}; </update> <update id="updateByTaskId2"> update task set task_state = 2,task_state_name = "关闭" where id = #{taskId}; </update> <update id="updateByTaskId3"> update task_user set state = 7,state_desc = "关闭" where id = #{taskId}; </update> <select id="selectListById" resultType="com.newfiber.api.pc.model.entity.TaskUser"> SELECT tu.id, tu.task_id, tu.unit_id, tu.unit, tu.job, tu.user_no, tu.user_name, tu.phone, tu.user_type, tu.state, tu.description, tu.check_state, tu.check_state_desc, tu.state_desc, tu.create_time, tu.update_time, t.expected_end_time, t.task_sign FROM `task_user` tu left join task t on tu.task_id = t.id where 1=1 and tu.task_id = #{taskId} and tu.user_type!=3 <if test="orgType!= null and orgType != ''"> and org_type = #{orgType} </if> <if test="type!=null"> <choose> <when test="type == 1"> and tu.state = 1 </when> <when test="type == 2"> and tu.state >= 2 </when> <when test="type == 3"> and tu.state = 3 </when> <when test="type == 4"> and tu.state = 4 </when> <when test="type == 5"> and tu.state = 1 and tu.create_time < date_sub(now(),interval 20 minute) </when> <when test="type == 6"> and tu.state < 3 and t.expected_end_time < now() and t.task_sign !=1 </when> <otherwise> </otherwise> </choose> </if> order by tu.update_time desc </select> <select id="selectOrgCount" resultType="com.newfiber.api.pc.model.entity.TaskOrgCount"> select org_type,org_name,count(tu.id) as count from task_user tu left join task t on tu.task_id = t.id where tu.task_id = #{taskId} and tu.user_type!=3 <if test="type!=null"> <choose> <when test="type == 1"> and tu.state = 1 </when> <when test="type == 2"> and tu.state >= 2 </when> <when test="type == 3"> and tu.state = 3 </when> <when test="type == 4"> and tu.state = 4 </when> <when test="type == 5"> and tu.state = 1 and tu.create_time < date_sub(now(),interval 20 minute) </when> <when test="type == 6"> and tu.state < 3 and t.expected_end_time < now() and t.task_sign !=1 </when> <otherwise> </otherwise> </choose> </if> group by org_type </select> </mapper>