ScheduleMapper.xml 8.41 KB
Newer Older
yuquan.zhu committed
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
<?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.ScheduleMapper" >
  <resultMap id="BaseResultMap" type="cn.timer.api.bean.kqgl.Schedule" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="userid" property="userid" jdbcType="INTEGER" />
    <result column="data" property="data" jdbcType="DATE" />
    <result column="bcid" property="bcid" jdbcType="INTEGER" />
    <result column="kqzid" property="kqzid" jdbcType="INTEGER" />
    
    
    <result column="bcname" property="bcname" jdbcType="VARCHAR" />
    <result column="sbdk1" property="sbdk1" jdbcType="VARCHAR" />
    <result column="sbqjks1" property="sbqjks1" jdbcType="VARCHAR" />
    <result column="sbqjjs1" property="sbqjjs1" jdbcType="VARCHAR" />
    
    <result column="xbdk1" property="xbdk1" jdbcType="VARCHAR" />
    <result column="xbqjks1" property="xbqjks1" jdbcType="VARCHAR" />
    <result column="xbqjjs1" property="xbqjjs1" jdbcType="VARCHAR" />
    
    <result column="sbdk2" property="sbdk2" jdbcType="VARCHAR" />
    <result column="sbqjks2" property="sbqjks2" jdbcType="VARCHAR" />
    <result column="sbqjjs2" property="sbqjjs2" jdbcType="VARCHAR" />
    
    <result column="xbdk2" property="xbdk2" jdbcType="VARCHAR" />
    <result column="xbqjks2" property="xbqjks2" jdbcType="VARCHAR" />
    <result column="xbqjjs2" property="xbqjjs2" jdbcType="VARCHAR" />
    
    <result column="sbdk3" property="sbdk3" jdbcType="VARCHAR" />
    <result column="sbqjks3" property="sbqjks3" jdbcType="VARCHAR" />
    <result column="sbqjjs3" property="sbqjjs3" jdbcType="VARCHAR" />
    
    <result column="xbdk3" property="xbdk3" jdbcType="VARCHAR" />
    <result column="xbqjks3" property="xbqjks3" jdbcType="VARCHAR" />
    <result column="xbqjjs3" property="xbqjjs3" jdbcType="VARCHAR" />
    
    <result column="isxbdk" property="isxbdk" jdbcType="INTEGER" />
    
    <result column="sxbcs" property="sxbcs" jdbcType="INTEGER" />
  </resultMap>
  
  <resultMap id="ScheduleAuxMap" type="cn.timer.api.bean.kqgl.ScheduleAux" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="userid" property="userid" jdbcType="INTEGER" />
    <result column="data" property="data" jdbcType="DATE" />
    <result column="bcid" property="bcid" jdbcType="INTEGER" />
    <result column="kqzid" property="kqzid" jdbcType="INTEGER" />
    
  </resultMap>
  
  <sql id="Base_Column_List" >
    id, userid, data, bcid, kqzid
  </sql>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    from kqgl_asso_pbmx
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from kqgl_asso_pbmx
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="cn.timer.api.bean.kqgl.Schedule" useGeneratedKeys="true" keyProperty="id">
    insert into kqgl_asso_pbmx (userid, data, 
      bcid, kqzid)
    values (#{userid,jdbcType=INTEGER}, #{data,jdbcType=DATE}, 
      #{bcid,jdbcType=INTEGER}, #{kqzid,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="cn.timer.api.bean.kqgl.Schedule" useGeneratedKeys="true" keyProperty="id">
    insert into kqgl_asso_pbmx
    <trim prefix="(" suffix=")" suffixOverrides="," >
      
      <if test="userid != null" >
        userid,
      </if>
      <if test="data != null" >
        data,
      </if>
      <if test="bcid != null" >
        bcid,
      </if>
      <if test="kqzid != null" >
        kqzid,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      
      <if test="userid != null" >
        #{userid,jdbcType=INTEGER},
      </if>
      <if test="data != null" >
        #{data,jdbcType=DATE},
      </if>
      <if test="bcid != null" >
        #{bcid,jdbcType=INTEGER},
      </if>
      <if test="kqzid != null" >
        #{kqzid,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="cn.timer.api.bean.kqgl.Schedule" >
    update kqgl_asso_pbmx
    <set >
      <if test="userid != null" >
        userid = #{userid,jdbcType=INTEGER},
      </if>
      <if test="data != null" >
        data = #{data,jdbcType=DATE},
      </if>
      <if test="bcid != null" >
        bcid = #{bcid,jdbcType=INTEGER},
      </if>
      <if test="kqzid != null" >
        kqzid = #{kqzid,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="cn.timer.api.bean.kqgl.Schedule" >
    update kqgl_asso_pbmx
    set userid = #{userid,jdbcType=INTEGER},
      data = #{data,jdbcType=DATE},
      bcid = #{bcid,jdbcType=INTEGER},
      kqzid = #{kqzid,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
  
  <insert id="insertKqglAssoPbmxList" parameterType="java.util.List" >
	    insert into kqgl_asso_pbmx (userid, data, bcid, kqzid)
	    <foreach collection="list" item="item" index="index" open="values " close="" separator=",">
	   	(
	      <if test="item.userid != null" >
	        #{item.userid,jdbcType=INTEGER},
	      </if>
	      <if test="item.data != null" >
	        #{item.data,jdbcType=DATE},
	      </if>
	      <if test="item.bcid != null" >
	        #{item.bcid,jdbcType=INTEGER},
	      </if>
	      <if test="item.kqzid != null" >
	        #{item.kqzid,jdbcType=INTEGER}
	      </if>
	      )
	    </foreach>
   </insert>
   
ilal committed
150
   <delete id="deleteByPrimaryBykqzid" >
yuquan.zhu committed
151 152
    delete from kqgl_asso_pbmx
    where kqzid = #{kqzid,jdbcType=INTEGER}
ilal committed
153
    and SUBSTR(data,1,7) = #{date,jdbcType=VARCHAR}
yuquan.zhu committed
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171
  </delete>
  
  <select id="selectAttGroupScheduling" resultMap="BaseResultMap">
  		select pbmx.*,
			info.`name` as username,
			bcsz.`name` bcname,
			SUBSTR(pbmx.`data`,1,7) as yemo,
      		SUBSTR(pbmx.`data`,9,10) as xsrq
		from kqgl_asso_pbmx pbmx
		LEFT JOIN yggl_main_emp as info on info.emp_num = pbmx.userid
		LEFT JOIN kqgl_asso_bcsz as bcsz on bcsz.id = pbmx.bcid
		where info.org_code = #{qyid,jdbcType=INTEGER}
		<if test="date != null" >
			and SUBSTR(pbmx.`data`,1,7) = #{date,jdbcType=VARCHAR}
		</if>
		and pbmx.kqzid = #{kqzid,jdbcType=INTEGER}
  </select>
  
ilal committed
172
  <delete id="deleteByPrimaryByUserid">
yuquan.zhu committed
173 174
    delete from kqgl_asso_pbmx
    where userid = #{userid,jdbcType=INTEGER}
ilal committed
175 176
    and SUBSTR(data,1,7) = #{date,jdbcType=VARCHAR}
    and kqzid = #{kqzid,jdbcType=INTEGER}
yuquan.zhu committed
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 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 240
  </delete>
  
  <select id="getAttendanceShouldList" resultMap="BaseResultMap">
  	select * from kqgl_asso_pbmx pbmx
		where pbmx.userid = #{userid,jdbcType=INTEGER}
		<!-- and pbmx.bcid != 0 -->
		and UNIX_TIMESTAMP(pbmx.`data`)* 1000 &gt;= #{start,jdbcType=BIGINT}
		and UNIX_TIMESTAMP(pbmx.`data`)* 1000 &lt;= #{end,jdbcType=BIGINT}
  </select>
  
  <select id="getScheduleSpecificAttendance" resultMap="BaseResultMap">
  		select pbmx.*,
			bcsz.`name` bcname,
			bcsz.sbdk1,
			bcsz.sbqjks1,
			bcsz.sbqjjs1,
			bcsz.xbdk1,
			bcsz.xbqjks1,
			bcsz.xbqjjs1,
			bcsz.sbdk2,
			bcsz.sbqjks2,
			bcsz.sbqjjs2,
			bcsz.xbdk2,
			bcsz.xbqjks2,
			bcsz.xbqjjs2,
			bcsz.sbdk3,
			bcsz.sbqjks3,
			bcsz.sbqjjs3,
			bcsz.xbdk3,
			bcsz.xbqjks3,
			bcsz.xbqjjs3,
			bcsz.sxbcs,
			bcsz.is_xbdk as isxbdk
		 from kqgl_asso_pbmx pbmx
		LEFT JOIN kqgl_asso_bcsz as bcsz on bcsz.id = pbmx.bcid
		where pbmx.kqzid = #{kqzid,jdbcType=INTEGER}
		and pbmx.userid = #{userid,jdbcType=INTEGER}
		and pbmx.`data` = #{date,jdbcType=VARCHAR}
  </select>
  
  <select id="getCalendarAttendance" resultMap="ScheduleAuxMap">
  			select pbmx.*
		from kqgl_asso_pbmx pbmx
		where  pbmx.userid = #{userid,jdbcType=INTEGER}
		and pbmx.kqzid = (select yhkqz.kqzid from kqgl_asso_yhkqz yhkqz
				where yhkqz.userid = #{userid,jdbcType=INTEGER})
  </select>
  
  <select id="getCustomRoster" resultMap="BaseResultMap">
		select * from kqgl_asso_pbmx pbmx
		where pbmx.kqzid = (select yhkqz.kqzid from kqgl_asso_yhkqz yhkqz
				where yhkqz.userid = #{userid,jdbcType=INTEGER})
		and pbmx.userid = #{userid,jdbcType=INTEGER}
		and pbmx.`data` = #{date,jdbcType=VARCHAR}
  </select>
  
  <insert id="insertCustomRoster" parameterType="cn.timer.api.bean.kqgl.CustomRosterSchedule" useGeneratedKeys="true" keyProperty="id">
    insert into kqgl_asso_pbmx (userid, data, 
      bcid, kqzid)
    values (#{userid,jdbcType=INTEGER}, #{data,jdbcType=DATE}, 
      #{bcid,jdbcType=INTEGER}, #{kqzid,jdbcType=INTEGER})
  </insert>
  
</mapper>