|
|
@@ -0,0 +1,171 @@
|
|
|
+<?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.zd.laboratory.mapper.XxpDutyMapper">
|
|
|
+
|
|
|
+ <resultMap type="com.zd.laboratory.domain.XxpDuty" id="XxpDutyResult">
|
|
|
+ <result property="id" column="id"/>
|
|
|
+ <result property="userId" column="user_id"/>
|
|
|
+ <result property="userName" column="user_name"/>
|
|
|
+ <result property="userPhone" column="user_phone"/>
|
|
|
+ <result property="userImg" column="user_img"/>
|
|
|
+ <result property="userType" column="user_type"/>
|
|
|
+ <result property="subjectId" column="subject_id"/>
|
|
|
+ <result property="subjectName" column="subject_name"/>
|
|
|
+ <result property="deptId" column="dept_id"/>
|
|
|
+ <result property="deptName" column="dept_name"/>
|
|
|
+ <result property="college" column="college"/>
|
|
|
+ <result property="dutyTime" column="duty_time"/>
|
|
|
+ <result property="createById" column="create_by_id"/>
|
|
|
+ <result property="createBy" column="create_by"/>
|
|
|
+ <result property="createTime" column="create_time"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <sql id="selectXxpDuty">
|
|
|
+ select id,
|
|
|
+ user_id,
|
|
|
+ user_name,
|
|
|
+ user_phone,
|
|
|
+ user_img,
|
|
|
+ user_type,
|
|
|
+ subject_id,
|
|
|
+ subject_name,
|
|
|
+ dept_id,
|
|
|
+ dept_name,
|
|
|
+ college,
|
|
|
+ duty_time,
|
|
|
+ create_by_id,
|
|
|
+ create_by,
|
|
|
+ create_time
|
|
|
+ from xxp_duty t
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <select id="selectXxpDutyList" parameterType="com.zd.laboratory.domain.XxpDuty"
|
|
|
+ resultMap="XxpDutyResult">
|
|
|
+ <include refid="selectXxpDuty"/>
|
|
|
+ <where>
|
|
|
+ <if test="userId != null ">and t.user_id = #{userId}</if>
|
|
|
+ <if test="userName != null and userName != ''">and t.user_name = #{userName}</if>
|
|
|
+ <if test="userPhone != null ">and t.user_phone = #{userPhone}</if>
|
|
|
+ <if test="userImg != null ">and t.user_img = #{userImg}</if>
|
|
|
+ <if test="userType != null ">and t.user_type = #{userType}</if>
|
|
|
+ <if test="subjectId != null ">and t.subject_id = #{subjectId}</if>
|
|
|
+ <if test="subjectName != null and subjectName != '' ">and t.subject_name = #{subjectName}</if>
|
|
|
+ <if test="deptId != null ">and t.dept_id = #{deptId}</if>
|
|
|
+ <if test="deptName != null ">and t.dept_name = #{deptName}</if>
|
|
|
+ <if test="college != null ">and t.college = #{college}</if>
|
|
|
+ <if test="dutyTime != null ">and t.duty_time =#{dutyTime}</if>
|
|
|
+ <if test="createById != null ">and t.create_by_id =#{createById}</if>
|
|
|
+ <if test="createBy != null ">and t.create_by =#{createBy}</if>
|
|
|
+ <if test="beginTime != null ">
|
|
|
+ and t.duty_time >= str_to_date(#{beginTime}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ <if test="endTime != null ">
|
|
|
+ and t.duty_time <= str_to_date(#{endTime}, '%Y-%m-%d')
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectXxpDutyById" resultMap="XxpDutyResult">
|
|
|
+ <include refid="selectXxpDuty"/>
|
|
|
+ where t.id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <insert id="insertXxpDuty" parameterType="com.zd.laboratory.domain.XxpDuty">
|
|
|
+ insert into xxp_duty
|
|
|
+ <trim prefix="(" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="userId != null">user_id,</if>
|
|
|
+ <if test="userName != null">user_name,</if>
|
|
|
+ <if test="userPhone != null">user_phone,</if>
|
|
|
+ <if test="userImg != null">user_img,</if>
|
|
|
+ <if test="userType != null">user_type,</if>
|
|
|
+ <if test="subjectId != null">subject_id,</if>
|
|
|
+ <if test="subjectName != null">subject_name,</if>
|
|
|
+ <if test="deptId != null">dept_id,</if>
|
|
|
+ <if test="deptName != null">dept_name,</if>
|
|
|
+ <if test="college != null">college,</if>
|
|
|
+ <if test="dutyTime != null">duty_time,</if>
|
|
|
+ <if test="createById != null">create_by_id,</if>
|
|
|
+ <if test="createBy != null">create_by,</if>
|
|
|
+ <if test="createTime != null">create_time,</if>
|
|
|
+ </trim>
|
|
|
+ <trim prefix="values (" suffix=")" suffixOverrides=",">
|
|
|
+ <if test="userId != null">#{userId},</if>
|
|
|
+ <if test="userName != null">#{userName},</if>
|
|
|
+ <if test="userPhone != null">#{userPhone},</if>
|
|
|
+ <if test="userImg != null">#{userImg},</if>
|
|
|
+ <if test="userType != null">#{userType},</if>
|
|
|
+ <if test="subjectId != null">#{subjectId},</if>
|
|
|
+ <if test="subjectName != null">#{subjectName},</if>
|
|
|
+ <if test="deptId != null">#{deptId},</if>
|
|
|
+ <if test="deptName != null">#{deptName},</if>
|
|
|
+ <if test="college != null">#{college},</if>
|
|
|
+ <if test="dutyTime != null">#{dutyTime},</if>
|
|
|
+ <if test="createById != null">#{createById},</if>
|
|
|
+ <if test="createBy != null">#{createBy},</if>
|
|
|
+ <if test="createTime != null">#{createTime},</if>
|
|
|
+ </trim>
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <update id="updateXxpDuty" parameterType="com.zd.laboratory.domain.XxpDuty">
|
|
|
+ update xxp_duty
|
|
|
+ <trim prefix="SET" suffixOverrides=",">
|
|
|
+ <if test="userId != null">user_id = #{userId},</if>
|
|
|
+ <if test="userName != null">user_name = #{userName},</if>
|
|
|
+ <if test="userPhone != null">user_phone = #{userPhone},</if>
|
|
|
+ <if test="userImg != null">user_img = #{userImg},</if>
|
|
|
+ <if test="userType != null">user_type = #{userType},</if>
|
|
|
+ <if test="subjectId != null">subject_id = #{subjectId},</if>
|
|
|
+ <if test="subjectName != null">subject_name = #{subjectName},</if>
|
|
|
+ <if test="deptId != null">dept_id = #{deptId},</if>
|
|
|
+ <if test="deptName != null">dept_name = #{deptName},</if>
|
|
|
+ <if test="college != null">college = #{college},</if>
|
|
|
+ <if test="dutyTime != null">duty_time = #{dutyTime},</if>
|
|
|
+ <if test="createById != null">create_by_id = #{createById},</if>
|
|
|
+ <if test="createBy != null">create_by = #{createBy},</if>
|
|
|
+ <if test="createTime != null">create_time = #{createTime},</if>
|
|
|
+ </trim>
|
|
|
+ where id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <delete id="deleteXxpDutyById">
|
|
|
+ delete
|
|
|
+ from xxp_duty
|
|
|
+ where id = #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <delete id="deleteXxpDutyByIds">
|
|
|
+ delete from xxp_duty where id in
|
|
|
+ <foreach item="id" collection="array" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <select id="selectDutyYmdById" parameterType="com.zd.laboratory.domain.XxpDuty" resultType="com.zd.laboratory.domain.vo.XxpDutyVO">
|
|
|
+ select t1.duty_time
|
|
|
+ from (
|
|
|
+ select t.duty_time
|
|
|
+ from xxp_duty t
|
|
|
+ where t.duty_time >= str_to_date(#{beginTime}, '%Y-%m-%d')
|
|
|
+ and t.duty_time <= str_to_date(#{endTime}, '%Y-%m-%d')
|
|
|
+ GROUP BY t.duty_time
|
|
|
+ ) t1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectSubAndUserSum" resultType="com.zd.laboratory.domain.vo.XxpDutyVO" parameterType="java.util.Date">
|
|
|
+ select sum(subSum) subSum, sum(userSum) userSum
|
|
|
+ from (
|
|
|
+ select count(1) subSum, 0 userSum
|
|
|
+ from (
|
|
|
+ select count(1) from xxp_duty d where d.duty_time = #{dutyTime} GROUP BY d.subject_id
|
|
|
+ ) s
|
|
|
+ UNION ALL
|
|
|
+ select 0 subSum, count(1) userSum
|
|
|
+ from (
|
|
|
+ select count(1) from xxp_duty d where d.duty_time = #{dutyTime} GROUP BY d.user_id
|
|
|
+ ) u
|
|
|
+ ) t
|
|
|
+ </select>
|
|
|
+
|
|
|
+</mapper>
|