<?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.TzQylxDao" >
  <resultMap id="BaseResultMap" type="com.unis.base.server.entity.TzQylxDO" >
    <id column="ID" property="id" jdbcType="DECIMAL" />
    <result column="QYID" property="qyid" jdbcType="DECIMAL" />
    <result column="QYLXMC" property="qylxmc" jdbcType="VARCHAR" />
    <result column="QYLXBH" property="qylxbh" jdbcType="VARCHAR" />
    <result column="STATUS" property="status" jdbcType="DECIMAL" />
    <result column="CREATOR" property="creator" jdbcType="VARCHAR" />
    <result column="CREATOR_CODE" property="creatorCode" jdbcType="VARCHAR" />
    <result column="CREATE_DATE" property="createDate" jdbcType="TIMESTAMP" />
    <result column="REFRESHER" property="refresher" jdbcType="VARCHAR" />
    <result column="REFRESHER_CODE" property="refresherCode" jdbcType="VARCHAR" />
    <result column="REFRESH_TIME" property="refreshTime" jdbcType="TIMESTAMP" />
    <result column="REMARK" property="remark" 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, QYID, QYLXMC, QYLXBH, STATUS, CREATOR, CREATOR_CODE, CREATE_DATE, REFRESHER, 
    REFRESHER_CODE, REFRESH_TIME, REMARK
  </sql>
  <!-- <select id="selectByExample" resultMap="BaseResultMap" parameterType="com.unis.base.server.entity.TzQylxExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from TZ_QYLX
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select> -->
  <!-- <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select 
    <include refid="Base_Column_List" />
    from TZ_QYLX
    where ID = #{id,jdbcType=DECIMAL}
  </select> -->
  <!-- <delete id="deleteByPrimaryKey" parameterType="java.lang.Long" >
    delete from TZ_QYLX
    where ID = #{id,jdbcType=DECIMAL}
  </delete> -->
  <!-- <delete id="deleteByExample" parameterType="com.unis.base.server.entity.TzQylxExample" >
    delete from TZ_QYLX
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
  </delete> -->
  <insert id="insert" parameterType="com.unis.base.server.entity.TzQylxDO" >
    insert into TZ_QYLX (ID, QYID, QYLXMC, 
      QYLXBH, STATUS, CREATOR, 
      CREATOR_CODE, CREATE_DATE, REFRESHER, 
      REFRESHER_CODE, REFRESH_TIME, REMARK
      )
    values (#{id,jdbcType=DECIMAL}, #{qyid,jdbcType=DECIMAL}, #{qylxmc,jdbcType=VARCHAR}, 
      #{qylxbh,jdbcType=VARCHAR}, #{status,jdbcType=DECIMAL}, #{creator,jdbcType=VARCHAR}, 
      #{creatorCode,jdbcType=VARCHAR}, #{createDate,jdbcType=TIMESTAMP}, #{refresher,jdbcType=VARCHAR}, 
      #{refresherCode,jdbcType=VARCHAR}, #{refreshTime,jdbcType=TIMESTAMP}, #{remark,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.unis.base.server.entity.TzQylxDO" >
    insert into TZ_QYLX
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        ID,
      </if>
      <if test="qyid != null" >
        QYID,
      </if>
      <if test="qylxmc != null" >
        QYLXMC,
      </if>
      <if test="qylxbh != null" >
        QYLXBH,
      </if>
      <if test="status != null" >
        STATUS,
      </if>
      <if test="creator != null" >
        CREATOR,
      </if>
      <if test="creatorCode != null" >
        CREATOR_CODE,
      </if>
      <if test="createDate != null" >
        CREATE_DATE,
      </if>
      <if test="refresher != null" >
        REFRESHER,
      </if>
      <if test="refresherCode != null" >
        REFRESHER_CODE,
      </if>
      <if test="refreshTime != null" >
        REFRESH_TIME,
      </if>
      <if test="remark != null" >
        REMARK,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=DECIMAL},
      </if>
      <if test="qyid != null" >
        #{qyid,jdbcType=DECIMAL},
      </if>
      <if test="qylxmc != null" >
        #{qylxmc,jdbcType=VARCHAR},
      </if>
      <if test="qylxbh != null" >
        #{qylxbh,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        #{status,jdbcType=DECIMAL},
      </if>
      <if test="creator != null" >
        #{creator,jdbcType=VARCHAR},
      </if>
      <if test="creatorCode != null" >
        #{creatorCode,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="refresher != null" >
        #{refresher,jdbcType=VARCHAR},
      </if>
      <if test="refresherCode != null" >
        #{refresherCode,jdbcType=VARCHAR},
      </if>
      <if test="refreshTime != null" >
        #{refreshTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null" >
        #{remark,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>

  <!-- <update id="updateByExampleSelective" parameterType="map" >
    update TZ_QYLX
    <set >
      <if test="record.id != null" >
        ID = #{record.id,jdbcType=DECIMAL},
      </if>
      <if test="record.qyid != null" >
        QYID = #{record.qyid,jdbcType=DECIMAL},
      </if>
      <if test="record.qylxmc != null" >
        QYLXMC = #{record.qylxmc,jdbcType=VARCHAR},
      </if>
      <if test="record.qylxbh != null" >
        QYLXBH = #{record.qylxbh,jdbcType=VARCHAR},
      </if>
      <if test="record.status != null" >
        STATUS = #{record.status,jdbcType=DECIMAL},
      </if>
      <if test="record.creator != null" >
        CREATOR = #{record.creator,jdbcType=VARCHAR},
      </if>
      <if test="record.creatorCode != null" >
        CREATOR_CODE = #{record.creatorCode,jdbcType=VARCHAR},
      </if>
      <if test="record.createDate != null" >
        CREATE_DATE = #{record.createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.refresher != null" >
        REFRESHER = #{record.refresher,jdbcType=VARCHAR},
      </if>
      <if test="record.refresherCode != null" >
        REFRESHER_CODE = #{record.refresherCode,jdbcType=VARCHAR},
      </if>
      <if test="record.refreshTime != null" >
        REFRESH_TIME = #{record.refreshTime,jdbcType=TIMESTAMP},
      </if>
      <if test="record.remark != null" >
        REMARK = #{record.remark,jdbcType=VARCHAR},
      </if>
    </set>
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update> -->
  <!-- <update id="updateByExample" parameterType="map" >
    update TZ_QYLX
    set ID = #{record.id,jdbcType=DECIMAL},
      QYID = #{record.qyid,jdbcType=DECIMAL},
      QYLXMC = #{record.qylxmc,jdbcType=VARCHAR},
      QYLXBH = #{record.qylxbh,jdbcType=VARCHAR},
      STATUS = #{record.status,jdbcType=DECIMAL},
      CREATOR = #{record.creator,jdbcType=VARCHAR},
      CREATOR_CODE = #{record.creatorCode,jdbcType=VARCHAR},
      CREATE_DATE = #{record.createDate,jdbcType=TIMESTAMP},
      REFRESHER = #{record.refresher,jdbcType=VARCHAR},
      REFRESHER_CODE = #{record.refresherCode,jdbcType=VARCHAR},
      REFRESH_TIME = #{record.refreshTime,jdbcType=TIMESTAMP},
      REMARK = #{record.remark,jdbcType=VARCHAR}
    <if test="_parameter != null" >
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update> -->
  <!-- <update id="updateByPrimaryKeySelective" parameterType="com.unis.base.server.entity.TzQylx" >
    update TZ_QYLX
    <set >
      <if test="qyid != null" >
        QYID = #{qyid,jdbcType=DECIMAL},
      </if>
      <if test="qylxmc != null" >
        QYLXMC = #{qylxmc,jdbcType=VARCHAR},
      </if>
      <if test="qylxbh != null" >
        QYLXBH = #{qylxbh,jdbcType=VARCHAR},
      </if>
      <if test="status != null" >
        STATUS = #{status,jdbcType=DECIMAL},
      </if>
      <if test="creator != null" >
        CREATOR = #{creator,jdbcType=VARCHAR},
      </if>
      <if test="creatorCode != null" >
        CREATOR_CODE = #{creatorCode,jdbcType=VARCHAR},
      </if>
      <if test="createDate != null" >
        CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
      </if>
      <if test="refresher != null" >
        REFRESHER = #{refresher,jdbcType=VARCHAR},
      </if>
      <if test="refresherCode != null" >
        REFRESHER_CODE = #{refresherCode,jdbcType=VARCHAR},
      </if>
      <if test="refreshTime != null" >
        REFRESH_TIME = #{refreshTime,jdbcType=TIMESTAMP},
      </if>
      <if test="remark != null" >
        REMARK = #{remark,jdbcType=VARCHAR},
      </if>
    </set>
    where ID = #{id,jdbcType=DECIMAL}
  </update> -->
  <update id="updateByPrimaryKey" parameterType="com.unis.base.server.entity.TzQylxDO" >
    update TZ_QYLX
    set QYID = #{qyid,jdbcType=DECIMAL},
      QYLXMC = #{qylxmc,jdbcType=VARCHAR},
      QYLXBH = #{qylxbh,jdbcType=VARCHAR},
      STATUS = #{status,jdbcType=DECIMAL},
      CREATOR = #{creator,jdbcType=VARCHAR},
      CREATOR_CODE = #{creatorCode,jdbcType=VARCHAR},
      CREATE_DATE = #{createDate,jdbcType=TIMESTAMP},
      REFRESHER = #{refresher,jdbcType=VARCHAR},
      REFRESHER_CODE = #{refresherCode,jdbcType=VARCHAR},
      REFRESH_TIME = #{refreshTime,jdbcType=TIMESTAMP},
      REMARK = #{remark,jdbcType=VARCHAR}
    where ID = #{id,jdbcType=DECIMAL}
  </update>
  
  
  
  <update id="delete" parameterType="com.unis.base.server.entity.TzQylxDO" >
    update TZ_QYLX
    set 
      STATUS = #{status,jdbcType=DECIMAL}
    where qyid = #{qyid,jdbcType=DECIMAL}
  </update>
  
  
  <select id="selectMaxId" resultType="java.lang.Integer">
  	select max(id) 
    from TZ_QYLX
  </select>
    <select id="qyxxList" resultType="com.unis.base.common.vo.QyxxVO">
      select * from (SELECT
      s.qymc as sskdmc,s.tyshxydm,s.qybm,s.qytxdz qydz,(select count(0) from d_cfxxsjy d where d.qybm = s.qybm) cfnum,
      (select sum(fcsl) from db_utf8.ty_kccxgssw kc where kc.ssyddm = s.tyshxydm) lssl
      from base.tz_slqy s
      WHERE s.status = 1 and s.qyzyyw like '%8%' and s.sfba = '5'
      <if test="sskdmc != null and sskdmc != ''">
        and s.qymc LIKE '%'||#{sskdmc}||'%'
      </if>
      ) re
      <where>
        <if test="slstr != null and slstr != ''">
          and re.lssl ${slstr} #{lssl}
        </if>
      </where>
    </select>
</mapper>