UserEquiRelationMapper.xml 5.53 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163
<?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.kqgl.UserEquiRelationMapper" >
  <resultMap id="BaseResultMap" type="cn.timer.api.bean.kqgl.UserEquiRelation" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="kqjid" property="kqjid" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="INTEGER" />
    <result column="is_gly" property="isGly" jdbcType="INTEGER" />
  </resultMap>
  <resultMap id="MachinememberMap" type="cn.timer.api.dto.kqgl.MachinememberDto" >
    <result column="dept" property="dept" jdbcType="VARCHAR" />
    <result column="post" property="post" jdbcType="VARCHAR" />
    <result column="name" property="name" jdbcType="VARCHAR" />
    <result column="id" property="id" jdbcType="INTEGER" />
    <result column="user_id" property="userId" jdbcType="INTEGER" />
    <result column="kqjid" property="kqjid" jdbcType="INTEGER" />
    <result column="type" property="type" jdbcType="INTEGER" />
    <result column="isgly" property="isgly" jdbcType="INTEGER" />
  </resultMap>
  <sql id="Base_Column_List" >
    id, user_id, kqjid, type,is_gly
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from kqgl_asso_yhsb
    where id = #{id,jdbcType=INTEGER}
  </select>
  
  <delete id="delAttmacrelpers" parameterType="java.lang.Integer" >
    delete from kqgl_asso_yhsb
    where user_id = #{userId,jdbcType=INTEGER}
    and kqjid = #{kqjid,jdbcType=INTEGER}
  </delete>
  
  <select id="selectByuserIdkqjid" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from kqgl_asso_yhsb
    where user_id = #{userId,jdbcType=INTEGER}
    and kqjid = #{kqjid,jdbcType=INTEGER}
    LIMIT 1
  </select>
  
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from kqgl_asso_yhsb
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="cn.timer.api.bean.kqgl.UserEquiRelation" useGeneratedKeys="true" keyProperty="id">
    insert into kqgl_asso_yhsb ( user_id, kqjid, 
      type,is_gly)
    values ( #{userId,jdbcType=INTEGER}, #{kqjid,jdbcType=INTEGER}, 
      #{type,jdbcType=INTEGER},#{isGly,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="cn.timer.api.bean.kqgl.UserEquiRelation" useGeneratedKeys="true" keyProperty="id">
    insert into kqgl_asso_yhsb
    <trim prefix="(" suffix=")" suffixOverrides="," >
    
      <if test="userId != null" >
        user_id,
      </if>
      <if test="kqjid != null" >
        kqjid,
      </if>
      <if test="type != null" >
        type,
      </if>
      <if test="isGly != null" >
        is_gly,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      
      <if test="userId != null" >
        #{userId,jdbcType=INTEGER},
      </if>
      <if test="kqjid != null" >
        #{kqjid,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        #{type,jdbcType=INTEGER},
      </if>
      <if test="isGly != null" >
        #{isGly,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.timer.api.bean.kqgl.UserEquiRelation" >
    update kqgl_asso_yhsb
    <set >
      <if test="userId != null" >
        user_id = #{userId,jdbcType=INTEGER},
      </if>
      <if test="kqjid != null" >
        kqjid = #{kqjid,jdbcType=INTEGER},
      </if>
      <if test="type != null" >
        type = #{type,jdbcType=INTEGER},
      </if>
      <if test="isGly != null" >
        is_gly = #{isGly,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.timer.api.bean.kqgl.UserEquiRelation" >
    update kqgl_asso_yhsb
    set user_id = #{userId,jdbcType=INTEGER},
      kqjid = #{kqjid,jdbcType=INTEGER},
      type = #{type,jdbcType=INTEGER},
      is_gly = #{isGly,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <select id="selectMmachineMember" resultMap="MachinememberMap">
	     select emp.`name`,
				yhsb.id,
				yhsb.kqjid,
				yhsb.type,
				yhsb.user_id 
		from kqgl_asso_yhsb yhsb
		LEFT JOIN yggl_main_emp as emp on emp.emp_num = yhsb.user_id and emp.org_code = 117
		where yhsb.kqjid = #{kqjid}
	and yhsb.user_id not in (select gly.userid from kqgl_asso_kqjgly gly
	where gly.kqjid = #{kqjid})
  </select>
  
  	<delete id="deleteBykqzid" parameterType="java.lang.Integer" >
		  delete from kqgl_asso_yhsb
		where kqjid in (select kfs.dkfsid from kqgl_asso_kqzdkfs kfs
		where kfs.kqz_id = #{kqzid}
		and kfs.type = 1) 
	</delete>
	
	<select id="selectAircraftMembers" resultMap="MachinememberMap">
			select bmgw.dept,
			 	 bmgw.post,
				emp.`name`,
				yhsb.id,
				yhsb.kqjid,
				yhsb.type,
				yhsb.user_id,
				yhsb.is_gly as isgly
		from kqgl_asso_yhsb yhsb
	LEFT JOIN yggl_main_emp as emp on emp.emp_num = yhsb.user_id and emp.org_code = #{orgcode}
	LEFT JOIN (select m.name as post,um.name as dept,m.id as mid
					 from zzgl_bmgw_m m 
					 left join zzgl_bmgw_m um on um.id = m.up_id  
				) as bmgw on bmgw.mid = emp.bmgw_id
		where yhsb.kqjid = #{kqjid}
	</select>	
	
	
 <select id="selectByuserId" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from kqgl_asso_yhsb
    where user_id = #{userId,jdbcType=INTEGER}
    LIMIT 1
  </select>
  
</mapper>