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

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

188 189
        	<if test="param.query != null and param.query != ''">
        		and (
190 191 192
        			a.title like CONCAT('%',#{param.query},'%') or
        			a.initiator like CONCAT('%',#{param.query},'%') or
        			a.id like CONCAT('%',#{param.query},'%') 
193 194 195 196 197 198
        		)
        	</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 != ''">
199
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
200 201
        	</if> 
        ORDER BY a.id DESC
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 236 237 238 239
    </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>
240 241 242
                        <if test ='null != assoType'>
                        asso_type,
                        </if>
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 280 281 282 283
                        <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>
284 285 286
                        <if test ='null != assoType'>
                        #{assoType},
                        </if>
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 313 314 315 316
                        <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>
317
                    <if test ='null != assoType'>asso_type = #{assoType},</if>
318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
                    <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>