SpmkApproveSummaryMapper.xml 13.8 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
                <result column="digest" property="digest" />
20 21 22 23
                <result column="update_time" property="updateTime" />
                <result column="end_time" property="endTime" />
                <result column="digest" property="digest" />
    </resultMap>
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
    
    <resultMap id="BaseResultMap_As" 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" />
                <result column="asso_type" property="assoType" />
                <result column="update_time" property="updateTime" />
                <result column="end_time" property="endTime" />
                <result column="digest" property="digest" />
                <result column="gw_name" property="gwName" />
                <result column="bm_id" property="bmId" />
                <result column="bm_name" property="bmName" />
    </resultMap>
45 46 47 48 49 50 51 52 53 54 55 56 57

    <sql id="Base_Column_List">
                id,
                org_code,
                emp_num,
                title,
                department_name,
                initiator,
                create_time,
                approve_name,
                sts,
                current_approver,
                history_approver,
58
                asso_type,
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
                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,
76
                a.asso_type,
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
                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,
94
                asso_type SpmkApproveSummary_asso_type,
95 96 97 98 99
                update_time SpmkApproveSummary_update_time,
                end_time SpmkApproveSummary_end_time,
                digest SpmkApproveSummary_digest
    </sql>
    
100
    <select id="selectPageByQuery" resultMap="BaseResultMap_As" >
101 102
        SELECT 
        	<include refid="Base_Column_List_a" />,
103 104 105
        	(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
106
        FROM spmk_approve_summary a
107
        WHERE a.org_code = #{param.orgCode} 
108 109
        	<if test="param.query != null and param.query != ''">
        		and (
110 111 112
        			a.title like CONCAT('%',#{param.query},'%') or
        			a.initiator like CONCAT('%',#{param.query},'%') or
        			a.id like CONCAT('%',#{param.query},'%') 
113 114
        		)
        	</if>
115 116
        	<if test="param.sts != null">
        		and a.sts = #{param.sts}
117
			</if>
118 119 120 121
        	<if test="param.startTime != null and param.startTime != ''">
        		and a.create_time <![CDATA[ >= ]]> #{param.startTime}
        	</if>
        	<if test="param.endTime != null and param.endTime != ''">
122
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
123
        	</if>
124 125 126 127 128 129 130 131 132 133 134
        	<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>
    
135
    <select id="selectPageByQueryForEmpNum" resultMap="BaseResultMap_As" >
136 137 138 139 140 141 142
        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} 
143
        
144 145 146
        	<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 
147 148 149 150 151
				(SELECT 
					approve_execute_record_id 
				 FROM 
				 	spmk_executor 
				 WHERE 
lal committed
152 153 154 155 156
				 	emp_num = #{param.empNum}
				 	<if test="param.sts == 0">
					 	and sts not in (2,3,4)
					</if>
				 	) 
lal committed
157 158 159 160 161 162
				 <if test="param.type == 3">
				 	and type in (0,1,2)
				 </if>
				 <if test="param.type != 3">
				 	and type = #{param.type}
				 </if>
163
			) 
164
			
165 166 167 168 169 170
			</if>
			
			<if test="param.type != null and param.type == 0">
        	and a.emp_num = #{param.empNum}
			</if>
			
171
			<if test="param.sts != null">
lal committed
172 173 174 175 176 177 178 179 180
				<if test="param.sts == 5">
	        		and a.sts in (0,1,2,3)
				</if>
				<if test="param.sts == 4">
	        		and a.sts in (2,3)
				</if>
				<if test="param.sts != 4 and param.sts != 5">
					and a.sts = #{param.sts}
				</if>
181
			</if>
lal committed
182
			
183

184 185
        	<if test="param.query != null and param.query != ''">
        		and (
186 187 188
        			a.title like CONCAT('%',#{param.query},'%') or
        			a.initiator like CONCAT('%',#{param.query},'%') or
        			a.id like CONCAT('%',#{param.query},'%') 
189 190 191 192 193 194
        		)
        	</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 != ''">
195
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
196 197
        	</if> 
        ORDER BY a.id DESC
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 235
    </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>
236 237 238
                        <if test ='null != assoType'>
                        asso_type,
                        </if>
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 268 269 270 271 272 273 274 275 276 277 278 279
                        <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>
280 281 282
                        <if test ='null != assoType'>
                        #{assoType},
                        </if>
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312
                        <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>
313
                    <if test ='null != assoType'>asso_type = #{assoType},</if>
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341
                    <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>