<?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.unis.base.server.dao.TyShougouqiyebeianDao" >
  <resultMap id="BaseResultMap" type="com.unis.base.server.entity.TyShougouqiyebeian" >
    <result column="id" property="id" jdbcType="VARCHAR" />
    <result column="szxzqy" property="szxzqy" jdbcType="VARCHAR" />
    <result column="qymc" property="qymc" jdbcType="VARCHAR" />
    <result column="tyshxydm" property="tyshxydm" jdbcType="VARCHAR" />
    <result column="dz" property="dz" jdbcType="VARCHAR" />
    <result column="lxr" property="lxr" jdbcType="VARCHAR" />
    <result column="dh" property="dh" jdbcType="VARCHAR" />
    <result column="bajg" property="bajg" jdbcType="VARCHAR" />
    <result column="barq" property="barq" jdbcType="TIMESTAMP" />
    <result column="sjzt" property="sjzt" jdbcType="INTEGER" />
    <result column="cjsj" property="cjsj" jdbcType="TIMESTAMP" />
    <result column="cjyh" property="cjyh" jdbcType="VARCHAR" />
    <result column="cjdw" property="cjdw" jdbcType="VARCHAR" />
    <result column="xxdz" property="xxdz" jdbcType="VARCHAR" />
  </resultMap>
  
  <resultMap id="ResultMap" type="com.unis.base.server.entity.TyShougouqiyebeianVo" extends="BaseResultMap">
    <result column="dictname" property="dictname" jdbcType="VARCHAR" />
    <result column="sjztname" property="sjztname" jdbcType="VARCHAR" />
  </resultMap>
  
  
  <sql id="Example_Where_Clause" >
    <where >
      <foreach collection="oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause" >
    <where >
      <foreach collection="example.oredCriteria" item="criteria" separator="or" >
        <if test="criteria.valid" >
          <trim prefix="(" suffix=")" prefixOverrides="and" >
            <foreach collection="criteria.criteria" item="criterion" >
              <choose >
                <when test="criterion.noValue" >
                  and ${criterion.condition}
                </when>
                <when test="criterion.singleValue" >
                  and ${criterion.condition} #{criterion.value}
                </when>
                <when test="criterion.betweenValue" >
                  and ${criterion.condition} #{criterion.value} and #{criterion.secondValue}
                </when>
                <when test="criterion.listValue" >
                  and ${criterion.condition}
                  <foreach collection="criterion.value" item="listItem" open="(" close=")" separator="," >
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List" >
    id, szxzqy, qymc, tyshxydm, dz, lxr, dh, bajg, barq, sjzt, cjsj, cjyh, cjdw, xxdz
  </sql>
  <select id="selectByExample" resultMap="ResultMap" parameterType="com.unis.base.server.example.TyShougouqiyebeianExample" >
    
    select qy.id,qy.szxzqy,qy.qymc, qy.tyshxydm, qy.dz, qy.lxr, qy.dh, qy.bajg, qy.barq, qy.sjzt, qy.cjsj, qy.cjyh, qy.cjdw, qy.xxdz,
           case when qy.sjzt = 1 then '待提交' when qy.sjzt = 2 then '已提交' end sjztname,
		   sysd.dict_name as dictname from (
		    	select
			    <if test="distinct" >
			      distinct
			    </if>
			    <include refid="Base_Column_List" />
			    from ty_shougouqiyebeian
			    <if test="_parameter != null" >
			      <include refid="Example_Where_Clause" />
			    </if>
			    <if test="orderByClause != null" >
			      order by ${orderByClause}
			    </if>
		    
		    )as qy left join usercenter.sys_dictionary sysd on qy.szxzqy = sysd.dict_code and sysd.group_id = 'AREA_CODE'
		    
    
  </select>
  <delete id="deleteByExample" parameterType="com.unis.base.server.example.TyShougouqiyebeianExample" >
    delete from ty_shougouqiyebeian
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.unis.base.server.entity.TyShougouqiyebeian" >
    insert into ty_shougouqiyebeian (id, szxzqy, qymc, 
      tyshxydm, dz, lxr, 
      dh, bajg, barq, sjzt, 
      cjsj, cjyh, cjdw, 
      xxdz)
    values (#{id,jdbcType=VARCHAR}, #{szxzqy,jdbcType=VARCHAR}, #{qymc,jdbcType=VARCHAR}, 
      #{tyshxydm,jdbcType=VARCHAR}, #{dz,jdbcType=VARCHAR}, #{lxr,jdbcType=VARCHAR}, 
      #{dh,jdbcType=VARCHAR}, #{bajg,jdbcType=VARCHAR}, #{barq,jdbcType=TIMESTAMP}, #{sjzt,jdbcType=INTEGER}, 
      #{cjsj,jdbcType=TIMESTAMP}, #{cjyh,jdbcType=VARCHAR}, #{cjdw,jdbcType=VARCHAR}, 
      #{xxdz,jdbcType=VARCHAR})
  </insert>
  <insert id="insertSelective" parameterType="com.unis.base.server.entity.TyShougouqiyebeian" >
    insert into ty_shougouqiyebeian
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="szxzqy != null" >
        szxzqy,
      </if>
      <if test="qymc != null" >
        qymc,
      </if>
      <if test="tyshxydm != null" >
        tyshxydm,
      </if>
      <if test="dz != null" >
        dz,
      </if>
      <if test="lxr != null" >
        lxr,
      </if>
      <if test="dh != null" >
        dh,
      </if>
      <if test="bajg != null" >
        bajg,
      </if>
      <if test="barq != null" >
        barq,
      </if>
      <if test="sjzt != null" >
        sjzt,
      </if>
      <if test="cjsj != null" >
        cjsj,
      </if>
      <if test="cjyh != null" >
        cjyh,
      </if>
      <if test="cjdw != null" >
        cjdw,
      </if>
      <if test="xxdz != null" >
        xxdz,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=VARCHAR},
      </if>
      <if test="szxzqy != null" >
        #{szxzqy,jdbcType=VARCHAR},
      </if>
      <if test="qymc != null" >
        #{qymc,jdbcType=VARCHAR},
      </if>
      <if test="tyshxydm != null" >
        #{tyshxydm,jdbcType=VARCHAR},
      </if>
      <if test="dz != null" >
        #{dz,jdbcType=VARCHAR},
      </if>
      <if test="lxr != null" >
        #{lxr,jdbcType=VARCHAR},
      </if>
      <if test="dh != null" >
        #{dh,jdbcType=VARCHAR},
      </if>
      <if test="bajg != null" >
        #{bajg,jdbcType=VARCHAR},
      </if>
      <if test="barq != null" >
        #{barq,jdbcType=TIMESTAMP},
      </if>
      <if test="sjzt != null" >
        #{sjzt,jdbcType=INTEGER},
      </if>
      <if test="cjsj != null" >
        #{cjsj,jdbcType=TIMESTAMP},
      </if>
      <if test="cjyh != null" >
        #{cjyh,jdbcType=VARCHAR},
      </if>
      <if test="cjdw != null" >
        #{cjdw,jdbcType=VARCHAR},
      </if>
      <if test="xxdz != null" >
        #{xxdz,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.unis.base.server.example.TyShougouqiyebeianExample" resultType="java.lang.Integer" >
    select count(1) from ty_shougouqiyebeian
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map" >
    update ty_shougouqiyebeian
    <set >
      <if test="record.id != null" >
        id = #{record.id,jdbcType=VARCHAR},
      </if>
      <if test="record.szxzqy != null" >
        szxzqy = #{record.szxzqy,jdbcType=VARCHAR},
      </if>
      <if test="record.qymc != null" >
        qymc = #{record.qymc,jdbcType=VARCHAR},
      </if>
      <if test="record.tyshxydm != null" >
        tyshxydm = #{record.tyshxydm,jdbcType=VARCHAR},
      </if>
      <if test="record.dz != null" >
        dz = #{record.dz,jdbcType=VARCHAR},
      </if>
      <if test="record.lxr != null" >
        lxr = #{record.lxr,jdbcType=VARCHAR},
      </if>
      <if test="record.dh != null" >
        dh = #{record.dh,jdbcType=VARCHAR},
      </if>
      <if test="record.bajg != null" >
        bajg = #{record.bajg,jdbcType=VARCHAR},
      </if>
      <if test="record.barq != null" >
        barq = #{record.barq,jdbcType=TIMESTAMP},
      </if>
      <if test="record.sjzt != null" >
        sjzt = #{record.sjzt,jdbcType=INTEGER},
      </if>
      <if test="record.cjsj != null" >
        cjsj = #{record.cjsj,jdbcType=TIMESTAMP},
      </if>
      <if test="record.cjyh != null" >
        cjyh = #{record.cjyh,jdbcType=VARCHAR},
      </if>
      <if test="record.cjdw != null" >
        cjdw = #{record.cjdw,jdbcType=VARCHAR},
      </if>
      <if test="record.xxdz != null" >
        xxdz = #{record.xxdz,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map" >
    update ty_shougouqiyebeian
    set id = #{record.id,jdbcType=VARCHAR},
      szxzqy = #{record.szxzqy,jdbcType=VARCHAR},
      qymc = #{record.qymc,jdbcType=VARCHAR},
      tyshxydm = #{record.tyshxydm,jdbcType=VARCHAR},
      dz = #{record.dz,jdbcType=VARCHAR},
      lxr = #{record.lxr,jdbcType=VARCHAR},
      dh = #{record.dh,jdbcType=VARCHAR},
      bajg = #{record.bajg,jdbcType=VARCHAR},
      barq = #{record.barq,jdbcType=TIMESTAMP},
      sjzt = #{record.sjzt,jdbcType=INTEGER},
      cjsj = #{record.cjsj,jdbcType=TIMESTAMP},
      cjyh = #{record.cjyh,jdbcType=VARCHAR},
      cjdw = #{record.cjdw,jdbcType=VARCHAR},
      xxdz = #{record.xxdz,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  
  <update id="updateByPrimaryKeySelective" parameterType="com.unis.base.server.entity.TyShougouqiyebeian" >
    update ty_shougouqiyebeian
    <set >
      <if test="szxzqy != null" >
        szxzqy = #{szxzqy,jdbcType=VARCHAR},
      </if>
      <if test="qymc != null" >
        qymc = #{qymc,jdbcType=VARCHAR},
      </if>
      <if test="tyshxydm != null" >
        tyshxydm = #{tyshxydm,jdbcType=VARCHAR},
      </if>
      <if test="dz != null" >
        dz = #{dz,jdbcType=VARCHAR},
      </if>
      <if test="lxr != null" >
        lxr = #{lxr,jdbcType=VARCHAR},
      </if>
      <if test="dh != null" >
        dh = #{dh,jdbcType=VARCHAR},
      </if>
      <if test="bajg != null" >
        bajg = #{bajg,jdbcType=VARCHAR},
      </if>
      <if test="barq != null" >
        barq = #{barq,jdbcType=TIMESTAMP},
      </if>
      <if test="sjzt != null" >
        sjzt = #{sjzt,jdbcType=INTEGER},
      </if>
      <if test="cjsj != null" >
        cjsj = #{cjsj,jdbcType=TIMESTAMP},
      </if>
      <if test="cjyh != null" >
        cjyh = #{cjyh,jdbcType=VARCHAR},
      </if>
      <if test="cjdw != null" >
        cjdw = #{cjdw,jdbcType=VARCHAR},
      </if>
      <if test="xxdz != null" >
        xxdz = #{xxdz,jdbcType=VARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=VARCHAR}
  </update>
  
   <resultMap id="ExportMap" type="com.unis.base.server.entity.TyShougouqiyebeianEVo" extends="BaseResultMap">
    <result column="dictname" property="dictname" jdbcType="VARCHAR" />
    <result column="sjztname" property="sjztname" jdbcType="VARCHAR" />
    <result column="qymc" property="qymc" jdbcType="VARCHAR" />
    <result column="tyshxydm" property="tyshxydm" jdbcType="VARCHAR" />
    <result column="lxr" property="lxr" jdbcType="VARCHAR" />
    <result column="dh" property="dh" jdbcType="VARCHAR" />
    <result column="bajg" property="bajg" jdbcType="VARCHAR" />
    <result column="barq" property="barq" jdbcType="TIMESTAMP" />
    <result column="xxdz" property="xxdz" jdbcType="VARCHAR" />
  </resultMap>
  
  <select id="selectByExampleIsList" resultType="java.util.HashMap" parameterType="com.unis.base.server.example.TyShougouqiyebeianExample" >
    
    select qy.qymc,qy.tyshxydm,qy.lxr,qy.dh,qy.bajg,date_format(qy.barq, '%Y') as barq,qy.xxdz,
           case when qy.sjzt = 1 then '待提交' when qy.sjzt = 2 then '已提交' end sjztName,
           sysd.dict_name as dictname from (
	    	select
		    <if test="distinct" >
		      distinct
		    </if>
		    <include refid="Base_Column_List" />
		    from ty_shougouqiyebeian
		    <if test="_parameter != null" >
		      <include refid="Example_Where_Clause" />
		    </if>
		    <if test="orderByClause != null" >
		      order by ${orderByClause}
		    </if>
    
    )as qy left join usercenter.sys_dictionary sysd on qy.szxzqy = sysd.dict_code and sysd.group_id = 'AREA_CODE'
  </select>
</mapper>