<?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.cku.dao.CkuTabGradeDdzMapper" >
  <resultMap id="BaseResultMap" type="com.cku.model.CkuTabGradeDdz" >
    <id column="id" property="id" jdbcType="INTEGER" />
    <result column="showsCode" property="showscode" jdbcType="CHAR" />
    <result column="showsId" property="showsid" jdbcType="VARCHAR" />
    <result column="serialNumber" property="serialnumber" jdbcType="CHAR" />
    <result column="CC" property="cc" jdbcType="CHAR" />
    <result column="BOB" property="bob" jdbcType="CHAR" />
    <result column="BOW" property="bow" jdbcType="CHAR" />
    <result column="WB" property="wb" jdbcType="VARCHAR" />
    <result column="BISS" property="biss" jdbcType="CHAR" />
    <result column="rankings" property="rankings" jdbcType="VARCHAR" />
    <result column="integrals" property="integrals" jdbcType="INTEGER" />
    <result column="userId" property="userid" jdbcType="CHAR" />
    <result column="UserName_C" property="usernameC" jdbcType="VARCHAR" />
    <result column="UserName_E" property="usernameE" jdbcType="VARCHAR" />
    <result column="fciCode" property="fcicode" jdbcType="CHAR" />
    <result column="dogSex" property="dogsex" jdbcType="CHAR" />
    <result column="ageClass" property="ageclass" jdbcType="INTEGER" />
    <result column="breedId" property="breedid" jdbcType="VARCHAR" />
    <result column="breedIdOther" property="breedidother" jdbcType="VARCHAR" />
    <result column="judges" property="judges" jdbcType="VARCHAR" />
    <result column="showsPlace" property="showsplace" jdbcType="CHAR" />
    <result column="editTime" property="edittime" jdbcType="TIMESTAMP" />
    <result column="del_tag" property="delTag" jdbcType="CHAR" />
    <result column="dogGroup" property="doggroup" jdbcType="CHAR" />
    <result column="print_cc" property="printCc" jdbcType="CHAR" />
    <result column="formatCode" property="formatcode" jdbcType="CHAR" />
    <result column="starting_data" property="starting_data" jdbcType="TIMESTAMP" />
    <result column="ending_data" property="ending_data" jdbcType="TIMESTAMP" />
    <result column="show_name" property="show_name" jdbcType="VARCHAR" />
    <result column="gradeMonth" property="gradeMonth" jdbcType="VARCHAR" />
  </resultMap>
  <resultMap id="ResultMapWithBLOBs" type="com.cku.model.CkuTabGradeDdzWithBLOBs" extends="BaseResultMap" >
    <result column="CC_Remarks" property="ccRemarks" jdbcType="LONGVARCHAR" />
    <result column="operater" property="operater" jdbcType="LONGVARCHAR" />
    <result column="Remarks" property="remarks" jdbcType="LONGVARCHAR" />
  </resultMap>
  <!-- 根据cku证书号查询犬只（单独展）比赛结果 zhuoHeng -->
  <select id="getDogGradeDdzList" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  	SELECT
		tab.*,
		game.开始日期 starting_data ,
		game.结束日期 ending_data,
		game.赛事名称 show_name,
		left(CONVERT(varchar(100), game.结束日期, 23),7) gradeMonth
	FROM
		tab_grade_ddz tab
	LEFT JOIN tab_games game ON tab.showsId = game.赛事编号
	WHERE
		breedId =  #{pedigreeNum}
		and left(CONVERT(varchar(100), game.结束日期, 23),7) = #{charTime}
  </select>
  <select id="getDogGradeDdzMonth" resultMap="BaseResultMap" parameterType="java.lang.Long" >
  SELECT
		left(CONVERT(varchar(100), game.结束日期, 23),7) gradeMonth
	FROM
		tab_grade_ddz tab
	LEFT JOIN tab_games game ON tab.showsId = game.赛事编号
	WHERE
		breedId =  #{pedigreeNum}
	order by tab.id desc
  </select>
  <sql id="Base_Column_List" >
    id, showsCode, showsId, serialNumber, CC, BOB, BOW, WB, BISS, rankings, integrals, 
    userId, UserName_C, UserName_E, fciCode, dogSex, ageClass, breedId, breedIdOther, 
    judges, showsPlace, editTime, del_tag, dogGroup, print_cc, formatCode
  </sql>
  <sql id="Blob_Column_List" >
    CC_Remarks, operater, Remarks
  </sql>
  <select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.Integer" >
    select 
    <include refid="Base_Column_List" />
    ,
    <include refid="Blob_Column_List" />
    from tab_grade_ddz
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    delete from tab_grade_ddz
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.cku.model.CkuTabGradeDdzWithBLOBs" >
    insert into tab_grade_ddz (id, showsCode, showsId, 
      serialNumber, CC, BOB, BOW, 
      WB, BISS, rankings, integrals, 
      userId, UserName_C, UserName_E, 
      fciCode, dogSex, ageClass, 
      breedId, breedIdOther, judges, 
      showsPlace, editTime, del_tag, 
      dogGroup, print_cc, formatCode, 
      CC_Remarks, operater, Remarks
      )
    values (#{id,jdbcType=INTEGER}, #{showscode,jdbcType=CHAR}, #{showsid,jdbcType=VARCHAR}, 
      #{serialnumber,jdbcType=CHAR}, #{cc,jdbcType=CHAR}, #{bob,jdbcType=CHAR}, #{bow,jdbcType=CHAR}, 
      #{wb,jdbcType=VARCHAR}, #{biss,jdbcType=CHAR}, #{rankings,jdbcType=VARCHAR}, #{integrals,jdbcType=INTEGER}, 
      #{userid,jdbcType=CHAR}, #{usernameC,jdbcType=VARCHAR}, #{usernameE,jdbcType=VARCHAR}, 
      #{fcicode,jdbcType=CHAR}, #{dogsex,jdbcType=CHAR}, #{ageclass,jdbcType=INTEGER}, 
      #{breedid,jdbcType=VARCHAR}, #{breedidother,jdbcType=VARCHAR}, #{judges,jdbcType=VARCHAR}, 
      #{showsplace,jdbcType=CHAR}, #{edittime,jdbcType=TIMESTAMP}, #{delTag,jdbcType=CHAR}, 
      #{doggroup,jdbcType=CHAR}, #{printCc,jdbcType=CHAR}, #{formatcode,jdbcType=CHAR}, 
      #{ccRemarks,jdbcType=LONGVARCHAR}, #{operater,jdbcType=LONGVARCHAR}, #{remarks,jdbcType=LONGVARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.cku.model.CkuTabGradeDdzWithBLOBs" >
    insert into tab_grade_ddz
    <trim prefix="(" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        id,
      </if>
      <if test="showscode != null" >
        showsCode,
      </if>
      <if test="showsid != null" >
        showsId,
      </if>
      <if test="serialnumber != null" >
        serialNumber,
      </if>
      <if test="cc != null" >
        CC,
      </if>
      <if test="bob != null" >
        BOB,
      </if>
      <if test="bow != null" >
        BOW,
      </if>
      <if test="wb != null" >
        WB,
      </if>
      <if test="biss != null" >
        BISS,
      </if>
      <if test="rankings != null" >
        rankings,
      </if>
      <if test="integrals != null" >
        integrals,
      </if>
      <if test="userid != null" >
        userId,
      </if>
      <if test="usernameC != null" >
        UserName_C,
      </if>
      <if test="usernameE != null" >
        UserName_E,
      </if>
      <if test="fcicode != null" >
        fciCode,
      </if>
      <if test="dogsex != null" >
        dogSex,
      </if>
      <if test="ageclass != null" >
        ageClass,
      </if>
      <if test="breedid != null" >
        breedId,
      </if>
      <if test="breedidother != null" >
        breedIdOther,
      </if>
      <if test="judges != null" >
        judges,
      </if>
      <if test="showsplace != null" >
        showsPlace,
      </if>
      <if test="edittime != null" >
        editTime,
      </if>
      <if test="delTag != null" >
        del_tag,
      </if>
      <if test="doggroup != null" >
        dogGroup,
      </if>
      <if test="printCc != null" >
        print_cc,
      </if>
      <if test="formatcode != null" >
        formatCode,
      </if>
      <if test="ccRemarks != null" >
        CC_Remarks,
      </if>
      <if test="operater != null" >
        operater,
      </if>
      <if test="remarks != null" >
        Remarks,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides="," >
      <if test="id != null" >
        #{id,jdbcType=INTEGER},
      </if>
      <if test="showscode != null" >
        #{showscode,jdbcType=CHAR},
      </if>
      <if test="showsid != null" >
        #{showsid,jdbcType=VARCHAR},
      </if>
      <if test="serialnumber != null" >
        #{serialnumber,jdbcType=CHAR},
      </if>
      <if test="cc != null" >
        #{cc,jdbcType=CHAR},
      </if>
      <if test="bob != null" >
        #{bob,jdbcType=CHAR},
      </if>
      <if test="bow != null" >
        #{bow,jdbcType=CHAR},
      </if>
      <if test="wb != null" >
        #{wb,jdbcType=VARCHAR},
      </if>
      <if test="biss != null" >
        #{biss,jdbcType=CHAR},
      </if>
      <if test="rankings != null" >
        #{rankings,jdbcType=VARCHAR},
      </if>
      <if test="integrals != null" >
        #{integrals,jdbcType=INTEGER},
      </if>
      <if test="userid != null" >
        #{userid,jdbcType=CHAR},
      </if>
      <if test="usernameC != null" >
        #{usernameC,jdbcType=VARCHAR},
      </if>
      <if test="usernameE != null" >
        #{usernameE,jdbcType=VARCHAR},
      </if>
      <if test="fcicode != null" >
        #{fcicode,jdbcType=CHAR},
      </if>
      <if test="dogsex != null" >
        #{dogsex,jdbcType=CHAR},
      </if>
      <if test="ageclass != null" >
        #{ageclass,jdbcType=INTEGER},
      </if>
      <if test="breedid != null" >
        #{breedid,jdbcType=VARCHAR},
      </if>
      <if test="breedidother != null" >
        #{breedidother,jdbcType=VARCHAR},
      </if>
      <if test="judges != null" >
        #{judges,jdbcType=VARCHAR},
      </if>
      <if test="showsplace != null" >
        #{showsplace,jdbcType=CHAR},
      </if>
      <if test="edittime != null" >
        #{edittime,jdbcType=TIMESTAMP},
      </if>
      <if test="delTag != null" >
        #{delTag,jdbcType=CHAR},
      </if>
      <if test="doggroup != null" >
        #{doggroup,jdbcType=CHAR},
      </if>
      <if test="printCc != null" >
        #{printCc,jdbcType=CHAR},
      </if>
      <if test="formatcode != null" >
        #{formatcode,jdbcType=CHAR},
      </if>
      <if test="ccRemarks != null" >
        #{ccRemarks,jdbcType=LONGVARCHAR},
      </if>
      <if test="operater != null" >
        #{operater,jdbcType=LONGVARCHAR},
      </if>
      <if test="remarks != null" >
        #{remarks,jdbcType=LONGVARCHAR},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.cku.model.CkuTabGradeDdzWithBLOBs" >
    update tab_grade_ddz
    <set >
      <if test="showscode != null" >
        showsCode = #{showscode,jdbcType=CHAR},
      </if>
      <if test="showsid != null" >
        showsId = #{showsid,jdbcType=VARCHAR},
      </if>
      <if test="serialnumber != null" >
        serialNumber = #{serialnumber,jdbcType=CHAR},
      </if>
      <if test="cc != null" >
        CC = #{cc,jdbcType=CHAR},
      </if>
      <if test="bob != null" >
        BOB = #{bob,jdbcType=CHAR},
      </if>
      <if test="bow != null" >
        BOW = #{bow,jdbcType=CHAR},
      </if>
      <if test="wb != null" >
        WB = #{wb,jdbcType=VARCHAR},
      </if>
      <if test="biss != null" >
        BISS = #{biss,jdbcType=CHAR},
      </if>
      <if test="rankings != null" >
        rankings = #{rankings,jdbcType=VARCHAR},
      </if>
      <if test="integrals != null" >
        integrals = #{integrals,jdbcType=INTEGER},
      </if>
      <if test="userid != null" >
        userId = #{userid,jdbcType=CHAR},
      </if>
      <if test="usernameC != null" >
        UserName_C = #{usernameC,jdbcType=VARCHAR},
      </if>
      <if test="usernameE != null" >
        UserName_E = #{usernameE,jdbcType=VARCHAR},
      </if>
      <if test="fcicode != null" >
        fciCode = #{fcicode,jdbcType=CHAR},
      </if>
      <if test="dogsex != null" >
        dogSex = #{dogsex,jdbcType=CHAR},
      </if>
      <if test="ageclass != null" >
        ageClass = #{ageclass,jdbcType=INTEGER},
      </if>
      <if test="breedid != null" >
        breedId = #{breedid,jdbcType=VARCHAR},
      </if>
      <if test="breedidother != null" >
        breedIdOther = #{breedidother,jdbcType=VARCHAR},
      </if>
      <if test="judges != null" >
        judges = #{judges,jdbcType=VARCHAR},
      </if>
      <if test="showsplace != null" >
        showsPlace = #{showsplace,jdbcType=CHAR},
      </if>
      <if test="edittime != null" >
        editTime = #{edittime,jdbcType=TIMESTAMP},
      </if>
      <if test="delTag != null" >
        del_tag = #{delTag,jdbcType=CHAR},
      </if>
      <if test="doggroup != null" >
        dogGroup = #{doggroup,jdbcType=CHAR},
      </if>
      <if test="printCc != null" >
        print_cc = #{printCc,jdbcType=CHAR},
      </if>
      <if test="formatcode != null" >
        formatCode = #{formatcode,jdbcType=CHAR},
      </if>
      <if test="ccRemarks != null" >
        CC_Remarks = #{ccRemarks,jdbcType=LONGVARCHAR},
      </if>
      <if test="operater != null" >
        operater = #{operater,jdbcType=LONGVARCHAR},
      </if>
      <if test="remarks != null" >
        Remarks = #{remarks,jdbcType=LONGVARCHAR},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKeyWithBLOBs" parameterType="com.cku.model.CkuTabGradeDdzWithBLOBs" >
    update tab_grade_ddz
    set showsCode = #{showscode,jdbcType=CHAR},
      showsId = #{showsid,jdbcType=VARCHAR},
      serialNumber = #{serialnumber,jdbcType=CHAR},
      CC = #{cc,jdbcType=CHAR},
      BOB = #{bob,jdbcType=CHAR},
      BOW = #{bow,jdbcType=CHAR},
      WB = #{wb,jdbcType=VARCHAR},
      BISS = #{biss,jdbcType=CHAR},
      rankings = #{rankings,jdbcType=VARCHAR},
      integrals = #{integrals,jdbcType=INTEGER},
      userId = #{userid,jdbcType=CHAR},
      UserName_C = #{usernameC,jdbcType=VARCHAR},
      UserName_E = #{usernameE,jdbcType=VARCHAR},
      fciCode = #{fcicode,jdbcType=CHAR},
      dogSex = #{dogsex,jdbcType=CHAR},
      ageClass = #{ageclass,jdbcType=INTEGER},
      breedId = #{breedid,jdbcType=VARCHAR},
      breedIdOther = #{breedidother,jdbcType=VARCHAR},
      judges = #{judges,jdbcType=VARCHAR},
      showsPlace = #{showsplace,jdbcType=CHAR},
      editTime = #{edittime,jdbcType=TIMESTAMP},
      del_tag = #{delTag,jdbcType=CHAR},
      dogGroup = #{doggroup,jdbcType=CHAR},
      print_cc = #{printCc,jdbcType=CHAR},
      formatCode = #{formatcode,jdbcType=CHAR},
      CC_Remarks = #{ccRemarks,jdbcType=LONGVARCHAR},
      operater = #{operater,jdbcType=LONGVARCHAR},
      Remarks = #{remarks,jdbcType=LONGVARCHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.cku.model.CkuTabGradeDdz" >
    update tab_grade_ddz
    set showsCode = #{showscode,jdbcType=CHAR},
      showsId = #{showsid,jdbcType=VARCHAR},
      serialNumber = #{serialnumber,jdbcType=CHAR},
      CC = #{cc,jdbcType=CHAR},
      BOB = #{bob,jdbcType=CHAR},
      BOW = #{bow,jdbcType=CHAR},
      WB = #{wb,jdbcType=VARCHAR},
      BISS = #{biss,jdbcType=CHAR},
      rankings = #{rankings,jdbcType=VARCHAR},
      integrals = #{integrals,jdbcType=INTEGER},
      userId = #{userid,jdbcType=CHAR},
      UserName_C = #{usernameC,jdbcType=VARCHAR},
      UserName_E = #{usernameE,jdbcType=VARCHAR},
      fciCode = #{fcicode,jdbcType=CHAR},
      dogSex = #{dogsex,jdbcType=CHAR},
      ageClass = #{ageclass,jdbcType=INTEGER},
      breedId = #{breedid,jdbcType=VARCHAR},
      breedIdOther = #{breedidother,jdbcType=VARCHAR},
      judges = #{judges,jdbcType=VARCHAR},
      showsPlace = #{showsplace,jdbcType=CHAR},
      editTime = #{edittime,jdbcType=TIMESTAMP},
      del_tag = #{delTag,jdbcType=CHAR},
      dogGroup = #{doggroup,jdbcType=CHAR},
      print_cc = #{printCc,jdbcType=CHAR},
      formatCode = #{formatcode,jdbcType=CHAR}
    where id = #{id,jdbcType=INTEGER}
  </update>
</mapper>