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

189 190
        	<if test="param.query != null and param.query != ''">
        		and (
191 192 193
        			a.title like CONCAT('%',#{param.query},'%') or
        			a.initiator like CONCAT('%',#{param.query},'%') or
        			a.id like CONCAT('%',#{param.query},'%') 
194 195 196 197 198 199
        		)
        	</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 != ''">
200
        		and a.create_time <![CDATA[ <= ]]> #{param.endTime}
201 202
        	</if> 
        ORDER BY a.id DESC
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 240
    </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>
241 242 243
                        <if test ='null != assoType'>
                        asso_type,
                        </if>
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 284
                        <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>
285 286 287
                        <if test ='null != assoType'>
                        #{assoType},
                        </if>
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 317
                        <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>
318
                    <if test ='null != assoType'>asso_type = #{assoType},</if>
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 346
                    <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>