<?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="com.gaowj.business.system.SystemBackDAO">

	<select id="getUserAllModule" parameterType="String" resultType="upperCaseKeyMap">
	 <![CDATA[
	    select m_id from c_t_sys_group_m where g_id in (select g_id from c_t_sys_group_u where u_id=#{uid}) 
	  ]]>
	</select>
	
	<select id="getTopMenu" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	select * from  c_t_sys_module_type where mt_id in(select distinct mt_id from c_t_sys_module where m_id in(${MIDS}) and m_state=0) order by mt_sort
     ]]>
	</select>
	
	<select id="getLeftMenu1" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	select distinct m_menu from c_t_sys_module where m_id in(${MIDS}) and mt_id=#{MTID} and m_state=0
     ]]>
	</select>
	
	<select id="getLeftMenu2" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select * from c_t_sys_module 
	   where 1=1 and m_state=0 
     ]]>
     <if test="MIDS != null and MIDS != ''">
      and m_id in (${MIDS})
     </if>
     <if test="MTID != null and MTID != ''">
      and mt_id = #{MTID}
     </if>
     <if test="MENU1 != null and MENU1 != ''">
      and m_menu = #{MENU1}
     </if>
     order by m_sort 
	</select>
	
	<insert id="insert_user" parameterType="map">
	      insert into c_t_sys_loginuser(
		<trim prefix="" suffixOverrides=",">
			<foreach collection="infoListKey" item="key">
				${key},
			</foreach>
		</trim>
	      <![CDATA[ ) values( ]]>
		<trim prefix="" suffixOverrides=",">
			<foreach collection="infoList" item="value">
				#{value},
			</foreach>
		</trim>
	      <![CDATA[ ) ]]>
 	</insert>
 
 	<update id="update_user" parameterType="map">
 	   <![CDATA[
            update c_t_sys_loginuser set 
         ]]>
		<trim prefix="" suffixOverrides=",">
			<foreach collection="info" item="info">
				${info.key} = #{info.value} ,
			</foreach>
		</trim>
		<where>
			<if test="CODE != null and CODE != ''">
				and CODE = #{CODE}
           </if>
		</where>
 	</update>
 	
 	<update id="delete_user" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_loginuser 
	  ]]>
	  <where>
	    <if test="CODE != null and CODE != ''">
	      and code = #{CODE} 
	    </if>
	    <if test="EMID != null and EMID != ''">
	      and emid = #{EMID}
	    </if>
	  </where> 
 	</update>
 	
 	<delete id="delete_batch_user" parameterType="list">
        <![CDATA[
            delete from c_t_sys_loginuser where code in
         ]]>
         <foreach collection="list" item="code"  open="("  separator=","  close=")">  
            #{code} 
         </foreach>
    </delete>
	
	<select id="listLoginUserInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select u.*,d.dpt_name emdepartname,(select max(opetime) from c_t_sys_loginlog where code=u.emid) beforetime,
	   (select count(1) from c_t_sys_group_u gu where gu.u_id=u.emid) ysy 
	   from c_t_sys_loginuser u left 
	   join c_t_sys_department d on d.dpt_no = u.emdepart 
	   where 1=1  
     ]]>
     <if test="EMID != null and EMID != ''">
      and u.emid like CONCAT('%',#{EMID},'%')
     </if>
     <if test="NAME != null and NAME != ''">
      and u.emid in (select lu.emid from c_t_sys_loginuser lu where lu.emname like CONCAT('%',#{NAME},'%') or lu.emid like CONCAT('%',#{NAME},'%'))
     </if>
     <if test="EMPASS != null and EMPASS != ''">
      and u.empass = #{EMPASS}
     </if>
     <if test="CODE != null and CODE != ''">
      and u.code = #{CODE}
     </if>
     <if test="STATE != null and STATE != '' ">
      and u.state = #{STATE}
     </if>
     <if test="EMDEPART != null and EMDEPART != ''">
      and u.emdepart = #{EMDEPART}
     </if>
     <if test="START_DATE != null and START_DATE != '' ">
      and u.regdate &gt;= #{START_DATE}
     </if>
	 <if test="END_DATE != null  and END_DATE != '' ">
	  and u.regdate &lt;= #{END_DATE}
	 </if>
	 <if test="O_ENABLE != null and O_ENABLE != '' ">
      and u.o_enable = #{O_ENABLE}
     </if>
	</select>
	
	<select id="listLoginUserInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_loginuser u left 
	   join c_t_sys_department d on d.dpt_no = u.emdepart 
	   where 1=1  
     ]]>
     <if test="EMID != null and EMID != ''">
      and u.emid like CONCAT('%',#{EMID},'%')
     </if>
     <if test="NAME != null and NAME != ''">
      and u.emid in (select lu.emid from c_t_sys_loginuser lu where lu.emname like CONCAT('%',#{NAME},'%') or lu.emid like CONCAT('%',#{NAME},'%'))
     </if>
     <if test="EMPASS != null and EMPASS != ''">
      and u.empass = #{EMPASS}
     </if>
     <if test="CODE != null and CODE != ''">
      and u.code = #{CODE}
     </if>
     <if test="STATE != null and STATE != '' ">
      and u.state = #{STATE}
     </if>
     <if test="EMDEPART != null and EMDEPART != ''">
      and u.emdepart = #{EMDEPART}
     </if>
     <if test="START_DATE != null and START_DATE != '' ">
      and u.regdate &gt;= #{START_DATE}
     </if>
	 <if test="END_DATE != null  and END_DATE != '' ">
	  and u.regdate &lt;= #{END_DATE}
	 </if>
	 <if test="O_ENABLE != null and O_ENABLE != '' ">
      and u.o_enable = #{O_ENABLE}
     </if>
	</select>
	
	<select id="getMaxLoginUserCode" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select max(code) maxcode from c_t_sys_loginuser where 1=1 and code like CONCAT('',#{EMDEPART},'%')
	  ]]>
	</select>
	
	<select id="getMaxLoginUserEmid" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select max(emid) maxemid from c_t_sys_loginuser where 1=1 and emid like CONCAT('',#{EMDEPART},'%')
	  ]]>
	</select>
	
	<select id="listDepartmentInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select d.*,(select emname from c_t_sys_loginuser u where u.code = d.manager) managername,(select count(*) from c_t_sys_loginuser u where u.emdepart = d.dpt_no) ysy  
	   from c_t_sys_department d 
	   where 1=1 
     ]]>
     <if test="DPT_NO != null and DPT_NO != ''">
      and d.dpt_no = #{DPT_NO}
     </if>
	 <if test="DPT_NAME != null and DPT_NAME != ''">
      and d.dpt_no in (select u.dpt_no from c_t_sys_department u where u.dpt_name like CONCAT('%',#{DPT_NAME},'%') or u.dpt_no like CONCAT('%',#{DPT_NAME},'%'))
     </if>
     <if test="DELETE_FLAG != null and DELETE_FLAG != ''">
      and d.DELETE_FLAG = #{DELETE_FLAG}
     </if>
      order by d.sort 
	</select>
	
	<select id="listDepartmentInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_department d 
	   where 1=1 
     ]]>
     <if test="DPT_NO != null and DPT_NO != ''">
      and d.dpt_no = #{DPT_NO}
     </if>
	  <if test="DPT_NAME != null and DPT_NAME != ''">
      and d.dpt_no in (select u.dpt_no from c_t_sys_department u where u.dpt_name like CONCAT('%',#{DPT_NAME},'%') or u.dpt_no like CONCAT('%',#{DPT_NAME},'%'))
     </if>
     <if test="DELETE_FLAG != null and DELETE_FLAG != ''">
      and d.DELETE_FLAG = #{DELETE_FLAG}
     </if>
	</select>
	
	<insert id="insert_depart" parameterType="map">
	    insert into c_t_sys_department(
		<trim prefix="" suffixOverrides=",">
			<foreach collection="infoListKey" item="key">
				${key},
			</foreach>
		</trim>
	    <![CDATA[ ) values( ]]>
			<trim prefix="" suffixOverrides=",">
				<foreach collection="infoList" item="value">
					#{value},
				</foreach>
			</trim>
	    <![CDATA[ ) ]]>
 	</insert>
 
 	<update id="update_depart" parameterType="map">
 	   <![CDATA[
            update c_t_sys_department set 
         ]]>
		<trim prefix="" suffixOverrides=",">
			<foreach collection="info" item="info">
				${info.key} = #{info.value} ,
			</foreach>
		</trim>
		<where>
			<if test="DPT_NO != null and DPT_NO != ''">
				and DPT_NO = #{DPT_NO}
            </if>
		</where>
 	</update>
 	
 	<update id="delete_depart" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_department 
	  ]]>
	  <where>
	    <if test="DPT_NO != null and DPT_NO != ''">
	      and dpt_no = #{DPT_NO} 
	    </if>
	  </where> 
 	</update>
	
	<update id="modifyPass" parameterType="map">
	 <![CDATA[
	     update c_t_sys_loginuser set empass=#{EMPASS} where code=#{CODE}
	  ]]> 
 	</update>
	
	
	
	<select id="listGroupAll" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	    select t.*,(select count(*) from c_t_sys_group_m t1 where t1.g_id=t.g_id) msy,
	    (select count(*) from c_t_sys_group_u t2 where t2.g_id=t.g_id) usy  from c_t_sys_group t  
		where 1=1
	  ]]> 
		<if test="G_ID != null and G_ID != ''">
	    and  t.g_id = #{G_ID}
		</if>
		<if test="G_NAME != null and G_NAME != ''">
	    and t.g_id in (select u.g_id from c_t_sys_group u where u.g_name like CONCAT('%',#{G_NAME},'%') or u.g_id like CONCAT('%',#{G_NAME},'%'))
		</if>
		<if test="G_STATE != null and G_STATE != ''">
	    and  t.g_state = #{G_STATE}
		</if>
		order by t.g_sort
	</select>
 
	<select id="listGroupAllCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(1) c from c_t_sys_group t 
		where 1=1
	  ]]> 
		<if test="G_ID != null and G_ID != ''">
	    and  t.g_id = #{G_ID}
		</if>
		<if test="G_NAME != null and G_NAME != ''">
	    and t.g_id in (select u.g_id from c_t_sys_group u where u.g_name like CONCAT('%',#{G_NAME},'%') or u.g_id like CONCAT('%',#{G_NAME},'%'))
		</if>
		<if test="G_STATE != null and G_STATE != ''">
	    and  t.g_state = #{G_STATE}
		</if>
	</select>
	
	<insert id="insert_group" parameterType="map">
	      insert into c_t_sys_group(
		<trim prefix="" suffixOverrides=",">
			<foreach collection="infoListKey" item="key">
				${key},
			</foreach>
		</trim>
	    <![CDATA[ ) values( ]]>
			<trim prefix="" suffixOverrides=",">
				<foreach collection="infoList" item="value">
					#{value},
				</foreach>
			</trim>
	    <![CDATA[ ) ]]>
 	</insert>
 
 	<update id="update_group" parameterType="map">
 	   <![CDATA[
            update c_t_sys_group set 
         ]]>
		<trim prefix="" suffixOverrides=",">
			<foreach collection="info" item="info">
				${info.key} = #{info.value} ,
			</foreach>
		</trim>
		<where>
			<if test="G_ID != null and G_ID != ''">
				and G_ID = #{G_ID}
            </if>
		</where>
 	</update>
 	
 	<update id="delete_group" parameterType="String">
	 <![CDATA[
	delete from c_t_sys_group 
		where G_ID = #{G_ID} 
	  ]]> 
 	</update>
 	
 	<select id="listGroupM_from_G" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
 	     select m.m_id,m.m_name from c_t_sys_group_m gm,c_t_sys_module m 
 	     where 1=1 and gm.m_id=m.m_id
	  ]]>
	  <if test="G_ID != null and G_ID != ''">
	    and  gm.g_id = #{G_ID}
	  </if>
	  <if test="M_ID != null and M_ID != ''">
	    and  gm.m_id = #{M_ID}
	  </if>
	</select>
	
	<select id="listModuleType" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	  select mt.*,(select count(1) c from c_t_sys_module m  where m.mt_id=mt.mt_id) ysy from  c_t_sys_module_type mt where 1=1 
     ]]>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt.mt_id = #{MT_ID} 
	    </if>
	    <if test="MT_NAME != null and MT_NAME != ''">
	      and  mt.mt_id in (select m1.mt_id from c_t_sys_module_type m1 where m1.mt_name like CONCAT('%',#{MT_NAME},'%') or m1.mt_id like CONCAT('%',#{MT_NAME},'%'))
	    </if>
	  order by mt.mt_sort
	</select>
	<select id="listModuleTypeCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(1) c from c_t_sys_module_type mt where 1=1 
	  ]]>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt.mt_id = #{MT_ID} 
	    </if> 
	    <if test="MT_NAME != null and MT_NAME != ''">
	      and  mt.mt_id in (select m1.mt_id from c_t_sys_module_type m1 where m1.mt_name like CONCAT('%',#{MT_NAME},'%') or m1.mt_id like CONCAT('%',#{MT_NAME},'%'))
	    </if>
	</select>
	<insert id="insert_moduleType" parameterType="map">
	     insert into c_t_sys_module_type(
		<trim prefix="" suffixOverrides=",">
			<foreach collection="infoListKey" item="key">
				${key},
			</foreach>
		</trim>
	    <![CDATA[ ) values( ]]>
			<trim prefix="" suffixOverrides=",">
				<foreach collection="infoList" item="value">
					#{value},
				</foreach>
			</trim>
	    <![CDATA[ ) ]]>
 	</insert>
 
 	<update id="update_moduleType" parameterType="map">
 	   <![CDATA[
            update c_t_sys_module_type set 
         ]]>
		<trim prefix="" suffixOverrides=",">
			<foreach collection="info" item="info">
				${info.key} = #{info.value} ,
			</foreach>
		</trim>
		<where>
			<if test="MT_ID != null and MT_ID != ''">
				and MT_ID = #{MT_ID}
            </if>
		</where>
 	</update>
 	
 	<update id="delete_moduleType" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_module_type 
	  ]]>
	  <where>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt_id = #{MT_ID} 
	    </if>
	  </where> 
 	</update>
	
	<select id="listModule" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select m.*,(select mt.mt_name from c_t_sys_module_type mt where mt.mt_id=m.mt_id) mt_name,(select count(1) c from c_t_sys_group_m gm  where m.m_id=gm.m_id) ysy from c_t_sys_module m where 1=1  
     ]]>
      <if test="MT_ID != null and MT_ID != ''">
	    and  m.mt_id = #{MT_ID}
	  </if>
	  <if test="M_ID != null and M_ID != ''">
	      and m.m_id = #{M_ID} 
	  </if>
	  <if test="M_STATE != null and M_STATE != ''">
	      and m.m_state = #{M_STATE} 
	  </if>
	  <if test="M_NAME != null and M_NAME != ''">
	      and  m.m_id in (select m1.m_id from c_t_sys_module m1 where m1.m_name like CONCAT('%',#{M_NAME},'%') or m1.m_id like CONCAT('%',#{M_NAME},'%'))
	  </if>
     order by m.mt_id,m.m_menu,m.m_sort 
	</select>
	<select id="listModuleCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(1) c from c_t_sys_module m where 1=1 and m.m_state=0 
	  ]]>
	  <if test="MT_ID != null and MT_ID != ''">
	    and  mt_id = #{MT_ID}
	  </if> 
	  <if test="M_ID != null and M_ID != ''">
	      and m_id = #{M_ID} 
	  </if>
	  <if test="M_STATE != null and M_STATE != ''">
	      and m.m_state = #{M_STATE} 
	  </if>
	  <if test="M_NAME != null and M_NAME != ''">
	      and  m.m_id in (select m1.m_id from c_t_sys_module m1 where m1.m_name like CONCAT('%',#{M_NAME},'%') or m1.m_id like CONCAT('%',#{M_NAME},'%'))
	  </if>
	</select>
	
	<insert id="insert_module" parameterType="map">
	      insert into c_t_sys_module(
		<trim prefix="" suffixOverrides=",">
			<foreach collection="infoListKey" item="key">
				${key},
			</foreach>
		</trim>
	    <![CDATA[ ) values( ]]>
			<trim prefix="" suffixOverrides=",">
				<foreach collection="infoList" item="value">
					#{value},
				</foreach>
			</trim>
	    <![CDATA[ ) ]]>
 	</insert>
 
 	<update id="update_module" parameterType="map">
 	   <![CDATA[
            update c_t_sys_module set 
         ]]>
		<trim prefix="" suffixOverrides=",">
			<foreach collection="info" item="info">
				${info.key} = #{info.value} ,
			</foreach>
		</trim>
		<where>
			<if test="M_ID != null and M_ID != ''">
				and M_ID = #{M_ID}
            </if>
		</where>
 	</update>
 	
 	<update id="delete_module" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_module 
	  ]]>
	  <where>
	    <if test="MT_ID != null and MT_ID != ''">
	      and mt_id = #{MT_ID} 
	    </if>
	    <if test="M_ID != null and M_ID != ''">
	      and m_id = #{M_ID} 
	    </if>
	  </where> 
 	</update>
	
	<insert id="insert_group_c_m" parameterType="map">
	      insert into c_t_sys_group_m(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="GM != null ">GM, </if>
	         <if test="G_ID != null ">G_ID, </if>
             <if test="M_ID != null ">M_ID, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="GM != null ">#{GM}, </if>
	         <if test="G_ID != null ">#{G_ID}, </if>
             <if test="M_ID != null ">#{M_ID}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="delete_group_c_m" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_group_m  
	  ]]> 
	  <where>
	    <if test="GM != null and GM != ''">
	    and  gm = #{GM}
	    </if>
	    <if test="G_ID != null and G_ID != ''">
	    and  g_id = #{G_ID}
	  </if>
	  <if test="M_ID != null and M_ID != ''">
	    and  m_id = #{M_ID}
	    </if>
	  </where>
 	</update>
 	
 	<select id="getMaxGm" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(gm) maxgm from c_t_sys_group_m where 1=1 
	  ]]>
	</select>
	
	
	<!-- 角色组/功能组选人 -->
	<select id="listGroupU_from_G" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
 	     select e.code,e.emname,e.emdepart,e.emid from c_t_sys_group_u gu,c_t_sys_loginuser e 
 	     where 1=1 and gu.u_id=e.code
	  ]]>
	  <if test="G_ID != null and G_ID != ''">
	    and  gu.g_id = #{G_ID}
	  </if>
	  <if test="U_ID != null and U_ID != ''">
	    and  gu.u_id = #{U_ID}
	  </if>
	</select>

	<insert id="insert_group_c_u" parameterType="map">
	      insert into c_t_sys_group_u(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="GU != null ">GU, </if>
	         <if test="G_ID != null ">G_ID, </if>
             <if test="U_ID != null ">U_ID, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="GU != null ">#{GU}, </if>
	         <if test="G_ID != null ">#{G_ID}, </if>
             <if test="U_ID != null ">#{U_ID}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="delete_group_c_u" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_group_u  
	  ]]> 
	  <where>
	    <if test="GU != null and GU != ''">
	    and  gu = #{GU}
	    </if>
	    <if test="G_ID != null and G_ID != ''">
	    and  g_id = #{G_ID}
	    </if>
	    <if test="U_ID != null and U_ID != ''">
	    and  u_id = #{U_ID}
	    </if>
	  </where>
 	</update>
 	
 	<select id="getMaxGu" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(gu) maxgu from c_t_sys_group_u where 1=1 
	  ]]>
	</select>
	
	<!-- 人管人查询 -->
	<select id="listPerson_from_P" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
 	     select * from c_t_sys_person 
 	     where 1=1 
	  ]]>
	  <if test="QXLX != null and QXLX != ''">
	    and  qxlx = #{QXLX}
	  </if>
	  <if test="GUANLI != null and GUANLI != ''">
	    and  guanli = #{GUANLI}
	  </if>
	  <if test="BEIGUANLI != null and BEIGUANLI != ''">
	    and  beiguanli = #{BEIGUANLI}
	  </if>
	</select>
	
	<insert id="insert_person_p" parameterType="map">
	      insert into c_t_sys_person(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="QXLX != null ">QXLX, </if>
	         <if test="GUANLI != null ">GUANLI, </if>
             <if test="BEIGUANLI != null ">BEIGUANLI, </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="QXLX != null ">#{QXLX}, </if>
	         <if test="GUANLI != null ">#{GUANLI}, </if>
             <if test="BEIGUANLI != null ">#{BEIGUANLI}, </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="delete_person_p" parameterType="map">
	 <![CDATA[
	delete from c_t_sys_person  
	  ]]> 
	  <where>
	    <if test="QXLX != null and QXLX != ''">
	      and  qxlx = #{QXLX}
	    </if>
	    <if test="GUANLI != null and GUANLI != ''">
	      and  guanli = #{GUANLI}
	    </if>
	    <if test="BEIGUANLI != null and BEIGUANLI != ''">
	      and  beiguanli = #{BEIGUANLI}
	    </if>
	  </where>
 	</update>
 	<!-- 日志信息 -->
 	<select id="listLogInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select log.*,(select l.emname from c_t_sys_loginuser l where l.code = log.code) username,
	   (select l.emid from c_t_sys_loginuser l where l.code = log.code) useremid 
	   from c_t_sys_loginlog log 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log.opetime &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log.opetime &lt;= #{END_DATE} 
	 </if>
	 <if test="NAME != null and NAME != ''">
	    and log.code in (select l.code from c_t_sys_loginlog l where l.code like CONCAT('%',#{NAME},'%') or l.emname like CONCAT('%',#{NAME},'%'))
	 </if>
	 <if test="EMIP != null and EMIP != ''">
	    and log.emIP like '${EMIP}%'
	 </if>
      order by log.opetime desc 
	</select>
	
	<select id="listLogInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_loginlog log 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log.opetime &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log.opetime &lt;= #{END_DATE} 
	 </if>
	 <if test="NAME != null and NAME != ''">
	    and log.code in (select l.code from c_t_sys_loginlog l where l.code like CONCAT('%',#{NAME},'%') or l.emname like CONCAT('%',#{NAME},'%'))
	 </if>
	 <if test="EMIP != null and EMIP != ''">
	    and log.emIP like '${EMIP}%'
	 </if>
	</select>
	
	<insert id="insert_log" parameterType="map">
	      insert into c_t_sys_loginlog(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">ID, </if>
	         <if test="CODE != null ">CODE, </if>
             <if test="EMNAME != null ">EMNAME, </if>
             <if test="EMIP != null ">EMIP, </if>
             <if test="OPENAME != null ">OPENAME , </if>
             <if test="OPETIME != null ">OPETIME , </if>
             <if test="TYPE != null ">TYPE , </if>
             <if test="OPETYPE != null ">OPETYPE , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">#{ID}, </if>
	         <if test="CODE != null ">#{CODE}, </if>
             <if test="EMNAME != null ">#{EMNAME}, </if>
             <if test="EMIP != null ">#{EMIP}, </if>
             <if test="OPENAME != null ">#{OPENAME} , </if>
             <if test="OPETIME != null ">#{OPETIME} , </if>
             <if test="TYPE != null ">#{TYPE} , </if>
             <if test="OPETYPE != null ">#{OPETYPE} , </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
	<select id="getMaxLog" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(id) maxid from c_t_sys_loginlog where 1=1 
	  ]]>
	</select>
	<!--log4j 日志信息 -->
	<select id="listLog4jInfo" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select * 
	   from c_t_sys_log4jinfo log4j 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log4j.logdate &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log4j.logdate &lt;= #{END_DATE} 
	 </if>
	 <if test="USERINFO != null and USERINFO != ''">
	    and log4j.userinfo in like CONCAT('',#{USERINFO},'%') 
	 </if>
	 <if test="LOGLEVEL != null and LOGLEVEL != ''">
	    and log4j.loglevel = #{LOGLEVEL} 
	 </if>
	 <if test="ID != null and ID != ''">
	    and log4j.ID = #{ID} 
	 </if>
      order by log4j.logdate desc 
	</select>
	
	<select id="listLog4jInfoCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from c_t_sys_log4jinfo log4j 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log4j.logdate &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log4j.logdate &lt;= #{END_DATE} 
	 </if>
	 <if test="USERINFO != null and USERINFO != ''">
	    and log4j.userinfo in like CONCAT('',#{USERINFO},'%') 
	 </if>
	 <if test="LOGLEVEL != null and LOGLEVEL != ''">
	    and log4j.loglevel = #{LOGLEVEL} 
	 </if>
	 <if test="ID != null and ID != ''">
	    and log4j.ID = #{ID} 
	 </if>
	</select>
	
	<insert id="insert_log4j" parameterType="map">
	      insert into c_t_sys_log4jinfo(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">ID, </if>
	         <if test="LOGDATE != null ">LOGDATE, </if>
             <if test="LOGTHREAD != null ">LOGTHREAD, </if>
             <if test="LOGLEVEL != null ">LOGLEVEL, </if>
             <if test="LOGCATEGORY != null ">LOGCATEGORY , </if>
             <if test="LOGLOCATION != null ">LOGLOCATION , </if>
             <if test="LOGMESSAGE != null ">LOGMESSAGE , </if>
             <if test="USERINFO != null ">USERINFO , </if>
             <if test="CLIENTINFO != null ">CLIENTINFO , </if>
             <if test="SERVERINFO != null ">SERVERINFO , </if>
             <if test="LOGTHROWABLE != null ">LOGTHROWABLE , </if>
             <if test="LOGNDC != null ">LOGNDC , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="ID != null ">#{ID}, </if>
	         <if test="LOGDATE != null ">#{LOGDATE}, </if>
             <if test="LOGTHREAD != null ">#{LOGTHREAD}, </if>
             <if test="LOGLEVEL != null ">#{LOGLEVEL}, </if>
             <if test="LOGCATEGORY != null ">#{LOGCATEGORY} , </if>
             <if test="LOGLOCATION != null ">#{LOGLOCATION} , </if>
             <if test="LOGMESSAGE != null ">#{LOGMESSAGE} , </if>
             <if test="USERINFO != null ">#{USERINFO} , </if>
             <if test="CLIENTINFO != null ">#{CLIENTINFO} , </if>
             <if test="SERVERINFO != null ">#{SERVERINFO} , </if>
             <if test="LOGTHROWABLE != null ">#{LOGTHROWABLE} , </if>
             <if test="LOGNDC != null ">#{LOGNDC} , </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
 	
 	<update id="update_log4j" parameterType="map">
	   update c_t_sys_log4jinfo  
	    <set> 
             <if test="LOGTHROWABLE != null ">LOGTHROWABLE = #{LOGTHROWABLE}, </if>
             <if test="LOGNDC != null ">LOGNDC = #{LOGNDC}, </if>
	    </set>
         where ID = #{ID}
 	</update>
 	
	<select id="getMaxLog4j" parameterType="map" resultType="int">
	 <![CDATA[
	   select max(id) maxid from c_t_sys_log4jinfo where 1=1 
	  ]]>
	</select>
	
	<!-- 业务操作日志信息 -->
 	<select id="listLogBusiness" parameterType="map" resultType="upperCaseKeyMap">
	 <![CDATA[
	   select log.*,(select l.emname from c_t_sys_loginuser l where l.code = log.userid) username,
	   (select l.emid from c_t_sys_loginuser l where l.code = log.userid) useremid  
	   from C_T_SYS_LOG_BUSINESS log 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log.opetime &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log.opetime &lt;= #{END_DATE} 
	 </if>
	 <if test="NAME != null and NAME != ''">
	    and log.userid in (select l.code from c_t_sys_loginuser l where l.emid like CONCAT('',#{NAME},'%') or l.emname like CONCAT('',#{NAME},'%'))
	 </if>
	 <if test="UUID != null and UUID != ''">
	    and log.UUID = #{UUID} 
	 </if>
	 <if test="DESCRIPTION != null and DESCRIPTION != ''">
	    and log.DESCRIPTION like CONCAT('%',#{DESCRIPTION},'%')
	 </if>
	 <if test="RECORDID != null and RECORDID != ''">
	    and log.RECORDID like CONCAT('%',#{RECORDID},'%') 
	 </if>
	 <if test="TYPE != null and TYPE != ''">
	    and log.TYPE = #{TYPE} 
	 </if>
      order by log.opetime desc 
	</select>
	
	<select id="listLogBusinessCount" parameterType="map" resultType="int">
	 <![CDATA[
	   select count(*) c 
	   from C_T_SYS_LOG_BUSINESS log 
	   where 1=1 
     ]]>
     <if test="BEGIN_DATE != null and BEGIN_DATE != ''">
	    and  log.opetime &gt;= #{BEGIN_DATE} 
	 </if>
	 <if test="END_DATE != null and END_DATE != ''">
	    and  log.opetime &lt;= #{END_DATE} 
	 </if>
	 <if test="NAME != null and NAME != ''">
	    and log.userid in (select l.code from c_t_sys_loginuser l where l.emid like CONCAT('',#{NAME},'%') or l.emname like CONCAT('',#{NAME},'%'))
	 </if>
	 <if test="UUID != null and UUID != ''">
	    and log.UUID = #{UUID} 
	 </if>
	 <if test="DESCRIPTION != null and DESCRIPTION != ''">
	    and log.DESCRIPTION like CONCAT('%',#{DESCRIPTION},'%')
	 </if>
	 <if test="RECORDID != null and RECORDID != ''">
	    and log.RECORDID like CONCAT('%',#{RECORDID},'%') 
	 </if>
	 <if test="TYPE != null and TYPE != ''">
	    and log.TYPE = #{TYPE} 
	 </if>
	</select>
	
	<insert id="insert_logBusiness" parameterType="map">
	      insert into C_T_SYS_LOG_BUSINESS(
	      <trim prefix=""  suffixOverrides=",">
	         <if test="UUID != null ">UUID, </if>
	         <if test="USERID != null ">USERID, </if>
             <if test="IP != null ">IP, </if>
             <if test="MODULES != null ">MODULES, </if>
             <if test="OPE != null ">OPE , </if>
             <if test="OPETIME != null ">OPETIME , </if>
             <if test="DESCRIPTION != null ">DESCRIPTION , </if>
             <if test="RECORDID != null ">RECORDID , </if>
             <if test="TYPE != null ">TYPE , </if>
             <if test="RECORDNAME != null ">RECORDNAME , </if>
           </trim>
	    <![CDATA[ ) values( ]]> 
	       <trim prefix=""  suffixOverrides=",">
	         <if test="UUID != null ">#{UUID}, </if>
	         <if test="USERID != null ">#{USERID}, </if>
             <if test="IP != null ">#{IP}, </if>
             <if test="MODULES != null ">#{MODULES}, </if>
             <if test="OPE != null ">#{OPE} , </if>
             <if test="OPETIME != null ">#{OPETIME} , </if>
             <if test="DESCRIPTION != null ">#{DESCRIPTION} , </if>
             <if test="RECORDID != null ">#{RECORDID} , </if>
             <if test="TYPE != null ">#{TYPE} , </if>
             <if test="RECORDNAME != null ">#{RECORDNAME} , </if>
            </trim>
	    <![CDATA[ ) ]]> 
 	</insert>
</mapper>