SpmkApproveSummaryMapper.xml 12.1 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
<?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.spmk.SpmkApproveSummaryMapper">

    <resultMap id="BaseResultMap" type="cn.timer.api.bean.spmk.SpmkApproveSummary" >
                <id column="id" property="id" />
                <result column="org_code" property="orgCode" />
                <result column="emp_num" property="empNum" />
                <result column="title" property="title" />
                <result column="department_name" property="departmentName" />
                <result column="initiator" property="initiator" />
                <result column="create_time" property="createTime" />
                <result column="approve_name" property="approveName" />
                <result column="sts" property="sts" />
                <result column="current_approver" property="currentApprover" />
                <result column="history_approver" property="historyApprover" />
18
                <result column="asso_type" property="assoType" />
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
                <result column="update_time" property="updateTime" />
                <result column="end_time" property="endTime" />
                <result column="digest" property="digest" />
    </resultMap>

    <sql id="Base_Column_List">
                id,
                org_code,
                emp_num,
                title,
                department_name,
                initiator,
                create_time,
                approve_name,
                sts,
                current_approver,
                history_approver,
36
                asso_type,
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
                update_time,
                end_time,
                digest
    </sql>
    
    <sql id="Base_Column_List_a">
                a.id,
                a.org_code,
                a.emp_num,
                a.title,
                a.department_name,
                a.initiator,
                a.create_time,
                a.approve_name,
                a.sts,
                a.current_approver,
                a.history_approver,
54
                a.asso_type,
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
                a.update_time,
                a.end_time,
                a.digest
    </sql>
    
    <sql id="Base_Column_List_Alias">
                id SpmkApproveSummary_id,
                org_code SpmkApproveSummary_org_code,
                emp_num SpmkApproveSummary_emp_num,
                title SpmkApproveSummary_title,
                department_name SpmkApproveSummary_department_name,
                initiator SpmkApproveSummary_initiator,
                create_time SpmkApproveSummary_create_time,
                approve_name SpmkApproveSummary_approve_name,
                sts SpmkApproveSummary_sts,
                current_approver SpmkApproveSummary_current_approver,
                history_approver SpmkApproveSummary_history_approver,
72
                asso_type SpmkApproveSummary_asso_type,
73 74 75 76 77 78 79 80
                update_time SpmkApproveSummary_update_time,
                end_time SpmkApproveSummary_end_time,
                digest SpmkApproveSummary_digest
    </sql>
    
    <select id="selectPageByQuery" resultMap="BaseResultMap" >
        SELECT 
        	<include refid="Base_Column_List_a" />,
81 82 83
        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT bmgw_id FROM yggl_main_emp WHERE a.emp_num = emp_num limit 1) limit 1) as gw_name,
			(SELECT id FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = (SELECT bmgw_id FROM yggl_main_emp WHERE a.emp_num = emp_num limit 1) limit 1) limit 1) as bm_id,
			(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = (SELECT bmgw_id FROM yggl_main_emp WHERE a.emp_num = emp_num limit 1) limit 1) limit 1) as bm_name
84
        FROM spmk_approve_summary a
85
        WHERE a.org_code = #{param.orgCode} 
86 87 88 89 90 91 92
        	<if test="param.query != null and param.query != ''">
        		and (
        			a.title like CONCAT(#{param.query},'%') or
        			a.initiator like CONCAT(#{param.query},'%') or
        			a.id like CONCAT(#{param.query},'%') 
        		)
        	</if>
93 94 95 96
        	
        	<if test="param.sts != null and param.sts != ''">
        	and a.sts = #{param.sts}
			</if>
97 98 99 100
        	<if test="param.startTime != null and param.startTime != ''">
        		and a.create_time <![CDATA[ >= ]]> #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
101
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
102
        	</if>
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
        	<if test="param.empNums != null and param.empNums.size() > 0">
				and a.emp_num IN 
				(
				<foreach item="it" index="index" collection="param.empNums" separator="," close="" >
		        	#{it}
				</foreach>
				)
        	</if> 
        ORDER BY a.id DESC
        	
    </select>
    
    <select id="selectPageByQueryForEmpNum" resultMap="BaseResultMap" >
        SELECT 
        	<include refid="Base_Column_List_a" />,
        	(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT bmgw_id FROM yggl_main_emp WHERE a.emp_num = emp_num limit 1) limit 1) as gw_name,
			(SELECT id FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = (SELECT bmgw_id FROM yggl_main_emp WHERE a.emp_num = emp_num limit 1) limit 1) limit 1) as bm_id,
			(SELECT name FROM zzgl_bmgw_m WHERE id = (SELECT up_id FROM zzgl_bmgw_m WHERE id = (SELECT bmgw_id FROM yggl_main_emp WHERE a.emp_num = emp_num limit 1) limit 1) limit 1) as bm_name
        FROM spmk_approve_summary a
        WHERE a.org_code = #{param.orgCode} 
        	<if test="param.type != null and param.type >= 1">
        	and a.id in 
        	(SELECT approve_summary_id FROM spmk_approve_execute_record WHERE id IN 
			(SELECT approve_execute_record_id FROM spmk_executor WHERE emp_num = #{param.empNum})
	        and type = #{param.type}
128 129
			) 
			and a.sts <![CDATA[ <> ]]> 1
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
			</if>
			
			<if test="param.type != null and param.type == 0">
        	and a.emp_num = #{param.empNum}
			</if>
			
			<if test="param.sts != null and param.sts != ''">
        	and a.sts = #{param.sts}
			</if>
        	<if test="param.query != null and param.query != ''">
        		and (
        			a.title like CONCAT(#{param.query},'%') or
        			a.initiator like CONCAT(#{param.query},'%') or
        			a.id like CONCAT(#{param.query},'%') 
        		)
        	</if>
        	<if test="param.startTime != null and param.startTime != ''">
        		and a.create_time <![CDATA[ >= ]]> #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
150
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
151 152
        	</if> 
        ORDER BY a.id DESC
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
    </select>
    

	<!-- 

    <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.spmk.SpmkApproveSummary">
        INSERT INTO spmk_approve_summary
        <trim prefix="(" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        org_code,
                        </if>
                        <if test ='null != empNum'>
                        emp_num,
                        </if>
                        <if test ='null != title'>
                        title,
                        </if>
                        <if test ='null != departmentName'>
                        department_name,
                        </if>
                        <if test ='null != initiator'>
                        initiator,
                        </if>
                        <if test ='null != createTime'>
                        create_time,
                        </if>
                        <if test ='null != approveName'>
                        approve_name,
                        </if>
                        <if test ='null != sts'>
                        sts,
                        </if>
                        <if test ='null != currentApprover'>
                        current_approver,
                        </if>
                        <if test ='null != historyApprover'>
                        history_approver,
                        </if>
191 192 193
                        <if test ='null != assoType'>
                        asso_type,
                        </if>
194 195 196 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 222 223 224 225 226 227 228 229 230 231 232 233 234
                        <if test ='null != updateTime'>
                        update_time,
                        </if>
                        <if test ='null != endTime'>
                        end_time,
                        </if>
                        <if test ='null != digest'>
                        digest
                        </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
                        <if test ='null != orgCode'>
                        #{orgCode},
                        </if>
                        <if test ='null != empNum'>
                        #{empNum},
                        </if>
                        <if test ='null != title'>
                        #{title},
                        </if>
                        <if test ='null != departmentName'>
                        #{departmentName},
                        </if>
                        <if test ='null != initiator'>
                        #{initiator},
                        </if>
                        <if test ='null != createTime'>
                        #{createTime},
                        </if>
                        <if test ='null != approveName'>
                        #{approveName},
                        </if>
                        <if test ='null != sts'>
                        #{sts},
                        </if>
                        <if test ='null != currentApprover'>
                        #{currentApprover},
                        </if>
                        <if test ='null != historyApprover'>
                        #{historyApprover},
                        </if>
235 236 237
                        <if test ='null != assoType'>
                        #{assoType},
                        </if>
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
                        <if test ='null != updateTime'>
                        #{updateTime},
                        </if>
                        <if test ='null != endTime'>
                        #{endTime},
                        </if>
                        <if test ='null != digest'>
                        #{digest}
                        </if>
        </trim>
    </insert>

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

    <update id="update" parameterType="cn.timer.api.bean.spmk.SpmkApproveSummary">
        UPDATE spmk_approve_summary
        <set>
                    <if test ='null != orgCode'>org_code = #{orgCode},</if>
                    <if test ='null != empNum'>emp_num = #{empNum},</if>
                    <if test ='null != title'>title = #{title},</if>
                    <if test ='null != departmentName'>department_name = #{departmentName},</if>
                    <if test ='null != initiator'>initiator = #{initiator},</if>
                    <if test ='null != createTime'>create_time = #{createTime},</if>
                    <if test ='null != approveName'>approve_name = #{approveName},</if>
                    <if test ='null != sts'>sts = #{sts},</if>
                    <if test ='null != currentApprover'>current_approver = #{currentApprover},</if>
                    <if test ='null != historyApprover'>history_approver = #{historyApprover},</if>
268
                    <if test ='null != assoType'>asso_type = #{assoType},</if>
269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296
                    <if test ='null != updateTime'>update_time = #{updateTime},</if>
                    <if test ='null != endTime'>end_time = #{endTime},</if>
                    <if test ='null != digest'>digest = #{digest}</if>
        </set>
        WHERE id = #{id}
    </update>


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

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

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

	 -->

</mapper>