WorkCollectMapper.xml 2.91 KB
Newer Older
cq990612's avatar
cq990612 committed
1 2 3 4 5 6
<?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="cn.wisenergy.mapper.WorkCollectMapper">

    <!-- 通用查询映射结果 -->
    <resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkCollect">
nie'hong's avatar
nie'hong committed
7 8 9 10 11 12 13
        <id column="id" property="id" />
        <result column="user_id" property="userId" />
        <result column="work_day" property="workDay" />
        <result column="total_time" property="totalTime" />
        <result column="status" property="status" />
        <result column="create_time" property="createTime" />
        <result column="modify_time" property="modifyTime" />
cq990612's avatar
cq990612 committed
14
        <result column="reject_time" property="rejectTime" />
cq990612's avatar
cq990612 committed
15 16
    </resultMap>

cq990612's avatar
cq990612 committed
17
    <sql id="vals">
cq990612's avatar
cq990612 committed
18
    #{userId},#{workDay},#{totalTime},#{status},#{rejectTime},now(),now()
cq990612's avatar
cq990612 committed
19 20
    </sql>

cq990612's avatar
cq990612 committed
21 22
    <!-- 通用查询结果列 -->
    <sql id="Base_Column_List">
cq990612's avatar
cq990612 committed
23
        id, user_id, work_day, total_time, status,reject_time,create_time,modify_time
cq990612's avatar
cq990612 committed
24 25
    </sql>
    <sql id="cols_exclude_id">
cq990612's avatar
cq990612 committed
26
        user_id, work_day, total_time, status,reject_time,create_time,modify_time
cq990612's avatar
cq990612 committed
27 28 29 30 31 32 33 34 35
    </sql>

    <sql id="table">
        work_collect
    </sql>

    <sql id="CalendarDto_List" >
       user_id, work_day,status
    </sql>
cq990612's avatar
cq990612 committed
36
    <insert id="insertWorkCollect">
cq990612's avatar
cq990612 committed
37 38 39 40 41 42 43
        INSERT INTO
        <include refid="table"/>
        (<include refid="cols_exclude_id"/>)
        VALUES (
        <include refid="vals"/>
        )
    </insert>
cq990612's avatar
cq990612 committed
44
    <update id="updateStatusOrTotalTime">
cq990612's avatar
cq990612 committed
45 46 47 48 49
        UPDATE
        <include refid="table"/>
        <set>

            <if test="null != status">
cq990612's avatar
cq990612 committed
50
                   status=#{status},
cq990612's avatar
cq990612 committed
51 52
            </if>
            <if test="null !=totalTime">
cq990612's avatar
cq990612 committed
53 54 55 56
                  total_time =  #{totalTime},
            </if>
            <if test="3 ==status ">
               reject_time = now(),
cq990612's avatar
cq990612 committed
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
            </if>
            modify_time = now()
        </set>
        WHERE id = #{id}

    </update>


    <select id="getWorkMonth" resultType="cn.wisenergy.model.dto.CalendarDto">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        <include refid="table"/>
        <where>
            <if test="null != userId">
            AND    user_id = #{userId}
            </if>
            <if test="null != workMonth">
                AND DATE_FORMAT(work_day, '%Y%m') = DATE_FORMAT(#{workMonth} ,'%Y%m')
            </if>
        </where>
    </select>
cq990612's avatar
cq990612 committed
79 80 81 82 83 84
    <select id="getCompletedByUserIdAndMonth" resultType="cn.wisenergy.model.app.WorkCollect">
        SELECT
        <include refid="Base_Column_List"/>
        FROM
        <include refid="table"/>
        <where>
cq990612's avatar
cq990612 committed
85
        total_time = 8 AND status !=3
cq990612's avatar
cq990612 committed
86 87 88 89 90 91 92 93 94 95
        <if test="userId !=null">
        AND    user_id = #{userId}
        </if>
        <if test="month !=null">
        AND    DATE_FORMAT(work_day, '%Y%m') = DATE_FORMAT(#{month} ,'%Y%m')
        </if>

        </where>

    </select>
cq990612's avatar
cq990612 committed
96 97

</mapper>