ZzglLogDgjlMapper.xml 6.01 KB
Newer Older
yuquan.zhu committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?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.zzgl.ZzglLogDgjlMapper">

	<resultMap id="BaseResultMap"
		type="cn.timer.api.bean.zzgl.ZzglLogDgjl">
		<id column="id" property="id" />
		<result column="org_code" property="orgCode" />
		<result column="emp_num" property="empNum" />
		<result column="obmgw_id" property="obmgwId" />
		<result column="nbmgw_id" property="nbmgwId" />
		<result column="update_id" property="updateId" />
		<result column="create_time" property="createTime" />
翁国栋 committed
15 16 17
		<result column="type" property="type" />
		<result column="comment" property="comment" />

yuquan.zhu committed
18 19 20 21 22 23 24 25 26
	</resultMap>

	<sql id="Base_Column_List">
		a.id,
		a.org_code,
		a.emp_num,
		a.obmgw_id,
		a.nbmgw_id,
		a.update_id,
翁国栋 committed
27 28
		a.create_time,
		a.type
yuquan.zhu committed
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
	</sql>

	<sql id="Base_Column_List_Alias">
		id ZzglLogDgjl_id,
		org_code ZzglLogDgjl_org_code,
		emp_num
		ZzglLogDgjl_emp_num,
		obmgw_id ZzglLogDgjl_obmgw_id,
		nbmgw_id
		ZzglLogDgjl_nbmgw_id,
		update_id ZzglLogDgjl_update_id,
		create_time
		ZzglLogDgjl_create_time
	</sql>

	<select id="selectListdgjl"
		resultType="cn.timer.api.dto.zzgl.ZzglLogDgjlDto"
		parameterType="cn.timer.api.dto.zzgl.ZzglLogDgjlQueryDto">
		SELECT
		<include refid="Base_Column_List" />
		,b.name username
		FROM
		zzgl_log_dgjl a,yggl_main_emp b
		<where>
			a.emp_num = b.emp_num
			<if test="orgCode != null and orgCode != ''">
				and a.org_code = #{orgCode}
			</if>
			<if test="query != null and query != ''">
				and b.name like CONCAT(#{query},'%')
			</if>
			<if test="startTime != null and startTime != ''">
				and a.create_time <![CDATA[ >= ]]>
				#{startTime}
			</if>
			<if test="endTime != null and endTime != ''">
				and a.create_time <![CDATA[ <= ]]>
				#{endTime}
			</if>
		</where>
	</select>

	<select id="selectListdgjls"
		resultType="cn.timer.api.dto.zzgl.LogDgjlsDto"
		parameterType="cn.timer.api.dto.zzgl.LogDgjlsQueryDto">
		SELECT
				c.name `name`,b.name `obmgw`,e.name `nbmgw`,a.emp_num `empNum`,d.name `updateMen`,
				a.create_time `createTime`
			FROM
				zzgl_log_dgjl a
			LEFT JOIN yggl_main_emp c ON a.emp_num = c.emp_num
			LEFT JOIN zzgl_bmgw_m b ON a.obmgw_id = b.id
			LEFT JOIN zzgl_bmgw_m e ON a.nbmgw_id = e.id
翁国栋 committed
82
			LEFT JOIN yggl_main_emp d ON a.update_id = d.emp_num
yuquan.zhu committed
83
		<where>
84 85
			a.org_code = #{param.orgCode} AND c.org_code = #{param.orgCode} AND b.org_code = #{param.orgCode}
			 AND e.org_code = #{param.orgCode} AND d.org_code = #{param.orgCode}
yuquan.zhu committed
86 87
			<if test="null != param.query and param.query != ''">
				and (c.name like CONCAT('%',#{param.query},'%') or
翁国栋 committed
88
				a.emp_num like CONCAT('%',#{param.query},'%') or
yuquan.zhu committed
89 90 91 92 93 94 95 96 97 98
				c.phone like CONCAT('%',#{param.query},'%'))
			</if>
			<if test="param.deptIdList != null">
				and a.nbmgw_id in
				<foreach item="item" index="index"
					collection="param.deptIdList.toArray()" open="(" separator="," close=")">
					#{item}
				</foreach>
			</if>
		</where>
东州 翁 committed
99
		GROUP BY `createTime` order by a.create_time DESC
yuquan.zhu committed
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
	</select>




	<insert id="insertbydeldept">
		insert into zzgl_log_dgjl
		(create_time,emp_num,nbmgw_id,obmgw_id,org_code,update_id,comment)
		select NOW(),emp_num,null,bmgw_id,org_code,#{uid},'删除岗位调岗' from
		yggl_main_emp where bmgw_id in
		<foreach item="item" index="index" collection="ids" open="("
			separator="," close=")">#{item}</foreach>
	</insert>
	<insert id="insertbyaddemp">
		insert into zzgl_log_dgjl
翁国栋 committed
115 116 117 118 119 120 121 122 123
		(create_time,emp_num,nbmgw_id,obmgw_id,org_code,update_id,comment,type)
		select NOW(),emp_num,#{gwid},
		       <if test="ogwid==null">
		       bmgw_id
		       </if>
				<if test="ogwid!=null">
					#{ogwid}
				</if>
		       ,org_code,#{uid},#{comm},#{type} from
yuquan.zhu committed
124 125 126 127
		yggl_main_emp where org_code=#{orgc} and emp_num in
		<foreach item="item" index="index" collection="ids" open="("
			separator="," close=")">#{item}</foreach>
	</insert>
翁国栋 committed
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
	<!-- <insert id="insert" useGeneratedKeys="true" keyColumn="id" parameterType="cn.timer.api.bean.zzgl.ZzglLogDgjl">
		INSERT INTO zzgl_log_dgjl <trim prefix="(" suffix=")" suffixOverrides=",">
		<if test ='null != orgCode'> org_code, </if> <if test ='null != empNum'>
		emp_num, </if> <if test ='null != obmgwId'> obmgw_id, </if> <if test ='null
		!= nbmgwId'> nbmgw_id, </if> <if test ='null != updateId'> update_id, </if>
		<if test ='null != createTime'> create_time </if> </trim> <trim prefix="values
		(" suffix=")" suffixOverrides=","> <if test ='null != orgCode'> #{orgCode},
		</if> <if test ='null != empNum'> #{empNum}, </if> <if test ='null != obmgwId'>
		#{obmgwId}, </if> <if test ='null != nbmgwId'> #{nbmgwId}, </if> <if test
		='null != updateId'> #{updateId}, </if> <if test ='null != createTime'> #{createTime}
		</if> </trim> </insert> <delete id="delete" > DELETE FROM zzgl_log_dgjl WHERE
		id = #{id} </delete> <update id="update" parameterType="cn.timer.api.bean.zzgl.ZzglLogDgjl">
		UPDATE zzgl_log_dgjl <set> <if test ='null != orgCode'>org_code = #{orgCode},</if>
		<if test ='null != empNum'>emp_num = #{empNum},</if> <if test ='null != obmgwId'>obmgw_id
		= #{obmgwId},</if> <if test ='null != nbmgwId'>nbmgw_id = #{nbmgwId},</if>
		<if test ='null != updateId'>update_id = #{updateId},</if> <if test ='null
		!= createTime'>create_time = #{createTime}</if> </set> WHERE id = #{id} </update>
		<select id="load" resultMap="BaseResultMap"> SELECT <include refid="Base_Column_List"
		/> FROM zzgl_log_dgjl WHERE id = #{id} </select> <select id="pageList" resultMap="BaseResultMap">
		SELECT <include refid="Base_Column_List" /> FROM zzgl_log_dgjl LIMIT #{offset},
		#{pageSize} </select> <select id="pageListCount" resultType="java.lang.Integer">
yuquan.zhu committed
149 150
		SELECT count(1) FROM zzgl_log_dgjl </select> -->

翁国栋 committed
151 152 153 154 155 156 157 158
	<select id="selectListByUser"  resultType="cn.timer.api.bean.zzgl.ZzglLogDgjl">
		select z.*,zm.`name` as obmgwName,zmn.`name`as nbmgwName from zzgl_log_dgjl z
			  LEFT JOIN zzgl_bmgw_m zm on zm.id=z.obmgw_id
			  LEFT JOIN zzgl_bmgw_m zmn on zmn.id=z.nbmgw_id
		where z.type in (1,2,3,6,7) and z.emp_num =#{empNum} and z.org_code=#{orgCode}
		order by z.create_time desc
	</select>
</mapper>