KqglAssoRelationSummaryMapper.xml 8.43 KB
Newer Older
lal committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
<?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.timer.api.dao.kqmk.KqglAssoRelationSummaryMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.kqmk.KqglAssoRelationSummary" >
                <id column="id" property="id" />
                <result column="user_id" property="userId" />
                <result column="app_time" property="appTime" />
                <result column="approval_id" property="approvalId" />
                <result column="approval_type" property="approvalType" />
                <result column="duration" property="duration" />
                <result column="leave_type_id" property="leaveTypeId" />
                <result column="overtime_type_id" property="overtimeTypeId" />
                <result column="compensate_id" property="compensateId" />
lal committed
16 17
                <result column="start_time" property="startTime" />
                <result column="end_time" property="endTime" />
lal committed
18
                <result column="org_code" property="orgCode" />
lal committed
19 20
                <result column="ordernum" property="ordernum" />
                <result column="totals" property="totals" />
lal committed
21 22 23 24 25 26 27 28 29 30 31
    </resultMap>

    <sql id="Base_Column_List">
                id,
                user_id,
                app_time,
                approval_id,
                approval_type,
                duration,
                leave_type_id,
                overtime_type_id,
lal committed
32 33
                compensate_id,
                start_time,
lal committed
34
                end_time,
lal committed
35 36 37
                org_code,
                ordernum,
                totals
lal committed
38
    </sql>
ilal committed
39 40 41 42 43 44 45 46 47 48 49
	
	<select id="HolidayDetails" resultMap="BaseResultMap">
		select su.*
	    	from kqgl_asso_relation_summary su 
			where su.approval_type = 2
			and su.org_code = #{orgcode}
			and su.ordernum = 1
			and SUBSTR(su.app_time,1,7) = #{apptime}
			and su.leave_type_id = (select ru.id from kqgl_asso_leave_rules ru where ru.org_code = #{orgcode} and ru.rules_type = #{rules_type})
			and su.user_id = #{userid}
	</select>
lal committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
	
	<select id="SecondaryValue" resultMap="BaseResultMap">
    		select a.user_id,
				SUM(a.duration) as duration
				from (select res.user_id,res.duration
					from kqgl_asso_relation_summary res 
				where res.user_id = #{userid} 
				and res.approval_type = #{approvaltype}
				and SUBSTR(res.app_time,1,7) = #{time}
				GROUP BY res.approval_id) as a
			GROUP BY a.user_id
    </select>
    
    <select id="SpecificLeave" resultMap="BaseResultMap">
    	select <include refid="Base_Column_List" />
			from kqgl_asso_relation_summary res 
			where res.user_id = #{userid} 
			and res.approval_type = #{approvaltype}
			and SUBSTR(res.app_time,1,7) = #{apptime}
ilal committed
69
			and res.org_code = #{orgcode}
lal committed
70 71
    </select>
    
lal committed
72 73 74 75 76
    <select id="LeaveInvestigation" resultMap="BaseResultMap">
    	select res.start_time,
				res.end_time
			from kqgl_asso_relation_summary res 
		where res.user_id = #{userid} 
lal committed
77
		and res.org_code = #{orgcode}
lal committed
78 79 80 81
		and res.approval_type = #{approvaltype}
		and SUBSTR(res.app_time,1,7) = #{apptime}
		GROUP BY res.start_time,res.end_time;
    </select>
lal committed
82 83 84 85 86 87 88 89
    <select id="leaveinvesti" resultMap="BaseResultMap">
    	select res.start_time,
				res.end_time
			from kqgl_asso_relation_summary res 
		where res.user_id = #{userid} 
		and res.org_code = #{orgcode}
		and res.approval_type = #{approvaltype}
		and res.app_time = #{apptime}
ilal committed
90
		GROUP BY res.start_time,res.end_time DESC LIMIT 1
lal committed
91
    </select>
lal committed
92
    
lal committed
93 94 95 96 97 98 99
    <select id="selectTabledata" resultMap="BaseResultMap">
    select SUM(res.duration) as duration
			from kqgl_asso_relation_summary res 
			where res.user_id = #{userid}
			and res.approval_type = #{approvaltype}
			and SUBSTR(res.app_time,1,7) = #{apptime}
    </select>
ilal committed
100 101 102 103 104 105 106 107 108
    
    <select id="Businessdayclockin" resultMap="BaseResultMap">
    	select IFNULL(SUM(res.duration),0) as duration
			from kqgl_asso_relation_summary res 
			where res.user_id = #{userid}
			and res.approval_type = #{approvaltype}
			and res.app_time = #{apptime}
			and res.org_code = #{orgcode}
    </select>
lal committed
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.kqmk.KqglAssoRelationSummary">
        INSERT INTO kqgl_asso_relation_summary
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != userId'>
                        user_id,
                        </if>
                        <if test ='null != appTime'>
                        app_time,
                        </if>
                        <if test ='null != approvalId'>
                        approval_id,
                        </if>
                        <if test ='null != approvalType'>
                        approval_type,
                        </if>
                        <if test ='null != duration'>
                        duration,
                        </if>
                        <if test ='null != leaveTypeId'>
                        leave_type_id,
                        </if>
                        <if test ='null != overtimeTypeId'>
                        overtime_type_id,
                        </if>
                        <if test ='null != compensateId'>
lal committed
136 137 138 139 140 141 142
                        compensate_id,
                        </if>
                        <if test ='null != startTime'>
                        start_time,
                        </if>
                        <if test ='null != endTime'>
                        end_time
lal committed
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != userId'>
                        #{userId},
                        </if>
                        <if test ='null != appTime'>
                        #{appTime},
                        </if>
                        <if test ='null != approvalId'>
                        #{approvalId},
                        </if>
                        <if test ='null != approvalType'>
                        #{approvalType},
                        </if>
                        <if test ='null != duration'>
                        #{duration},
                        </if>
                        <if test ='null != leaveTypeId'>
                        #{leaveTypeId},
                        </if>
                        <if test ='null != overtimeTypeId'>
                        #{overtimeTypeId},
                        </if>
                        <if test ='null != compensateId'>
lal committed
168 169 170 171 172 173 174
                        #{compensateId},
                        </if>
                        <if test ='null != startTime'>
                        #{startTime},
                        </if>
                        <if test ='null != endTime'>
                        #{endTime}
lal committed
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
                        </if>
        </trim>
    </insert>

    <delete id="delete" >
        DELETE FROM kqgl_asso_relation_summary
        WHERE id = #{id}
    </delete>

    <update id="update" parameterType="cn.timer.api.bean.kqmk.KqglAssoRelationSummary">
        UPDATE kqgl_asso_relation_summary
        <set>
                    <if test ='null != userId'>user_id = #{userId},</if>
                    <if test ='null != appTime'>app_time = #{appTime},</if>
                    <if test ='null != approvalId'>approval_id = #{approvalId},</if>
                    <if test ='null != approvalType'>approval_type = #{approvalType},</if>
                    <if test ='null != duration'>duration = #{duration},</if>
                    <if test ='null != leaveTypeId'>leave_type_id = #{leaveTypeId},</if>
                    <if test ='null != overtimeTypeId'>overtime_type_id = #{overtimeTypeId},</if>
lal committed
194 195 196
                    <if test ='null != compensateId'>compensate_id = #{compensateId},</if>
                    <if test ='null != startTime'>start_time = #{startTime},</if>
                    <if test ='null != endTime'>end_time = #{endTime}</if>
lal committed
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
        </set>
        WHERE id = #{id}
    </update>


    <select id="load" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM kqgl_asso_relation_summary
        WHERE id = #{id}
    </select>

    <select id="pageList" resultMap="BaseResultMap">
        SELECT <include refid="Base_Column_List" />
        FROM kqgl_asso_relation_summary
        LIMIT #{offset}, #{pageSize}
    </select>

    <select id="pageListCount" resultType="java.lang.Integer">
        SELECT count(1)
        FROM kqgl_asso_relation_summary
    </select>

	 -->

</mapper>