<?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.goafanti.common.dao.TTaskMidMapper">
  <resultMap id="BaseResultMap" type="com.goafanti.common.model.TTaskMid">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="tid" jdbcType="INTEGER" property="tid" />
    <result column="cost_amount" jdbcType="DECIMAL" property="costAmount" />
    <result column="party_amount" jdbcType="DECIMAL" property="partyAmount" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="certificates_count" jdbcType="INTEGER" property="certificatesCount" />
    <result column="urgent_day" jdbcType="INTEGER" property="urgentDay" />
    <result column="if_material" jdbcType="INTEGER" property="ifMaterial" />
    <result column="reject_count" jdbcType="INTEGER" property="rejectCount" />
    <result column="accept_count" jdbcType="INTEGER" property="acceptCount" />
    <result column="end_count" jdbcType="INTEGER" property="endCount" />
    <result column="authorize_count" jdbcType="INTEGER" property="authorizeCount" />
    <result column="apply_count" jdbcType="INTEGER" property="applyCount" />
    <result column="high_new_retrial" jdbcType="INTEGER" property="highNewRetrial" />
    <result column="dispatch_count" jdbcType="INTEGER" property="dispatchCount" />
    <result column="stock_count" jdbcType="INTEGER" property="stockCount" />
    <result column="complete_count" jdbcType="INTEGER" property="completeCount" />
    <result column="promulgate_count" jdbcType="INTEGER" property="promulgateCount" />
    <result column="dispatch_province" jdbcType="INTEGER" property="dispatchProvince" />
    <result column="duty_dep" jdbcType="VARCHAR" property="dutyDep" />
    <result column="set_up_count" jdbcType="INTEGER" property="setUpCount" />
    <result column="spot_check_count" jdbcType="INTEGER" property="spotCheckCount" />
    <result column="fail_count" jdbcType="INTEGER" property="failCount" />
    <result column="last_year" jdbcType="VARCHAR" property="lastYear" />
    <result column="last_year_capital" jdbcType="DECIMAL" property="lastYearCapital" />
    <result column="last_year_income" jdbcType="DECIMAL" property="lastYearIncome" />
    <result column="cost_actual" jdbcType="DECIMAL" property="costActual" />
    <result column="patent_cost" jdbcType="DECIMAL" property="patentCost" />
    <result column="patent_cost_actual" jdbcType="DECIMAL" property="patentCostActual" />
    <result column="soft_cost" jdbcType="DECIMAL" property="softCost" />
    <result column="soft_cost_actual" jdbcType="DECIMAL" property="softCostActual" />
    <result column="audit_cost" jdbcType="DECIMAL" property="auditCost" />
    <result column="audit_cost_actual" jdbcType="DECIMAL" property="auditCostActual" />
    <result column="other_cost" jdbcType="DECIMAL" property="otherCost" />
    <result column="other_cost_actual" jdbcType="DECIMAL" property="otherCostActual" />
    <result column="expect_profit" jdbcType="DECIMAL" property="expectProfit" />
    <result column="actual_profit" jdbcType="DECIMAL" property="actualProfit" />
    <result column="stop_type" jdbcType="INTEGER" property="stopType" />
    <result column="stop_status" jdbcType="INTEGER" property="stopStatus" />
    <result column="change" jdbcType="INTEGER" property="change" />
  </resultMap>
  <sql id="Base_Column_List">
    id, tid, cost_amount, party_amount, create_time, certificates_count, urgent_day,
    if_material, reject_count, accept_count, end_count, authorize_count, apply_count,
    high_new_retrial, dispatch_count, stock_count, complete_count, promulgate_count,
    dispatch_province, duty_dep, set_up_count, spot_check_count, fail_count, last_year,
    last_year_capital, last_year_income, cost_actual, patent_cost, patent_cost_actual,
    soft_cost, soft_cost_actual, audit_cost, audit_cost_actual, other_cost, other_cost_actual,
    expect_profit, actual_profit, stop_type, stop_status, `change`
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select
    <include refid="Base_Column_List" />
    from t_task_mid
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_task_mid
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TTaskMid" useGeneratedKeys="true">
    insert into t_task_mid (tid, cost_amount, party_amount,
      create_time, certificates_count, urgent_day,
      if_material, reject_count, accept_count,
      end_count, authorize_count, apply_count,
      high_new_retrial, dispatch_count, stock_count,
      complete_count, promulgate_count, dispatch_province,
      duty_dep, set_up_count, spot_check_count,
      fail_count, last_year, last_year_capital,
      last_year_income, cost_actual, patent_cost,
      patent_cost_actual, soft_cost, soft_cost_actual,
      audit_cost, audit_cost_actual, other_cost,
      other_cost_actual, expect_profit, actual_profit,
      stop_type, stop_status, `change`
      )
    values (#{tid,jdbcType=INTEGER}, #{costAmount,jdbcType=DECIMAL}, #{partyAmount,jdbcType=DECIMAL},
      #{createTime,jdbcType=TIMESTAMP}, #{certificatesCount,jdbcType=INTEGER}, #{urgentDay,jdbcType=INTEGER},
      #{ifMaterial,jdbcType=INTEGER}, #{rejectCount,jdbcType=INTEGER}, #{acceptCount,jdbcType=INTEGER},
      #{endCount,jdbcType=INTEGER}, #{authorizeCount,jdbcType=INTEGER}, #{applyCount,jdbcType=INTEGER},
      #{highNewRetrial,jdbcType=INTEGER}, #{dispatchCount,jdbcType=INTEGER}, #{stockCount,jdbcType=INTEGER},
      #{completeCount,jdbcType=INTEGER}, #{promulgateCount,jdbcType=INTEGER}, #{dispatchProvince,jdbcType=INTEGER},
      #{dutyDep,jdbcType=VARCHAR}, #{setUpCount,jdbcType=INTEGER}, #{spotCheckCount,jdbcType=INTEGER},
      #{failCount,jdbcType=INTEGER}, #{lastYear,jdbcType=VARCHAR}, #{lastYearCapital,jdbcType=DECIMAL},
      #{lastYearIncome,jdbcType=DECIMAL}, #{costActual,jdbcType=DECIMAL}, #{patentCost,jdbcType=DECIMAL},
      #{patentCostActual,jdbcType=DECIMAL}, #{softCost,jdbcType=DECIMAL}, #{softCostActual,jdbcType=DECIMAL},
      #{auditCost,jdbcType=DECIMAL}, #{auditCostActual,jdbcType=DECIMAL}, #{otherCost,jdbcType=DECIMAL},
      #{otherCostActual,jdbcType=DECIMAL}, #{expectProfit,jdbcType=DECIMAL}, #{actualProfit,jdbcType=DECIMAL},
      #{stopType,jdbcType=INTEGER}, #{stopStatus,jdbcType=INTEGER}, #{change,jdbcType=INTEGER}
      )
  </insert>
  <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.TTaskMid" useGeneratedKeys="true">
    insert into t_task_mid
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="tid != null">
        tid,
      </if>
      <if test="costAmount != null">
        cost_amount,
      </if>
      <if test="partyAmount != null">
        party_amount,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="certificatesCount != null">
        certificates_count,
      </if>
      <if test="urgentDay != null">
        urgent_day,
      </if>
      <if test="ifMaterial != null">
        if_material,
      </if>
      <if test="rejectCount != null">
        reject_count,
      </if>
      <if test="acceptCount != null">
        accept_count,
      </if>
      <if test="endCount != null">
        end_count,
      </if>
      <if test="authorizeCount != null">
        authorize_count,
      </if>
      <if test="applyCount != null">
        apply_count,
      </if>
      <if test="highNewRetrial != null">
        high_new_retrial,
      </if>
      <if test="dispatchCount != null">
        dispatch_count,
      </if>
      <if test="stockCount != null">
        stock_count,
      </if>
      <if test="completeCount != null">
        complete_count,
      </if>
      <if test="promulgateCount != null">
        promulgate_count,
      </if>
      <if test="dispatchProvince != null">
        dispatch_province,
      </if>
      <if test="dutyDep != null">
        duty_dep,
      </if>
      <if test="setUpCount != null">
        set_up_count,
      </if>
      <if test="spotCheckCount != null">
        spot_check_count,
      </if>
      <if test="failCount != null">
        fail_count,
      </if>
      <if test="lastYear != null">
        last_year,
      </if>
      <if test="lastYearCapital != null">
        last_year_capital,
      </if>
      <if test="lastYearIncome != null">
        last_year_income,
      </if>
      <if test="costActual != null">
        cost_actual,
      </if>
      <if test="patentCost != null">
        patent_cost,
      </if>
      <if test="patentCostActual != null">
        patent_cost_actual,
      </if>
      <if test="softCost != null">
        soft_cost,
      </if>
      <if test="softCostActual != null">
        soft_cost_actual,
      </if>
      <if test="auditCost != null">
        audit_cost,
      </if>
      <if test="auditCostActual != null">
        audit_cost_actual,
      </if>
      <if test="otherCost != null">
        other_cost,
      </if>
      <if test="otherCostActual != null">
        other_cost_actual,
      </if>
      <if test="expectProfit != null">
        expect_profit,
      </if>
      <if test="actualProfit != null">
        actual_profit,
      </if>
      <if test="stopType != null">
        stop_type,
      </if>
      <if test="stopStatus != null">
        stop_status,
      </if>
      <if test="change != null">
        `change`,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="tid != null">
        #{tid,jdbcType=INTEGER},
      </if>
      <if test="costAmount != null">
        #{costAmount,jdbcType=DECIMAL},
      </if>
      <if test="partyAmount != null">
        #{partyAmount,jdbcType=DECIMAL},
      </if>
      <if test="createTime != null">
        #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="certificatesCount != null">
        #{certificatesCount,jdbcType=INTEGER},
      </if>
      <if test="urgentDay != null">
        #{urgentDay,jdbcType=INTEGER},
      </if>
      <if test="ifMaterial != null">
        #{ifMaterial,jdbcType=INTEGER},
      </if>
      <if test="rejectCount != null">
        #{rejectCount,jdbcType=INTEGER},
      </if>
      <if test="acceptCount != null">
        #{acceptCount,jdbcType=INTEGER},
      </if>
      <if test="endCount != null">
        #{endCount,jdbcType=INTEGER},
      </if>
      <if test="authorizeCount != null">
        #{authorizeCount,jdbcType=INTEGER},
      </if>
      <if test="applyCount != null">
        #{applyCount,jdbcType=INTEGER},
      </if>
      <if test="highNewRetrial != null">
        #{highNewRetrial,jdbcType=INTEGER},
      </if>
      <if test="dispatchCount != null">
        #{dispatchCount,jdbcType=INTEGER},
      </if>
      <if test="stockCount != null">
        #{stockCount,jdbcType=INTEGER},
      </if>
      <if test="completeCount != null">
        #{completeCount,jdbcType=INTEGER},
      </if>
      <if test="promulgateCount != null">
        #{promulgateCount,jdbcType=INTEGER},
      </if>
      <if test="dispatchProvince != null">
        #{dispatchProvince,jdbcType=INTEGER},
      </if>
      <if test="dutyDep != null">
        #{dutyDep,jdbcType=VARCHAR},
      </if>
      <if test="setUpCount != null">
        #{setUpCount,jdbcType=INTEGER},
      </if>
      <if test="spotCheckCount != null">
        #{spotCheckCount,jdbcType=INTEGER},
      </if>
      <if test="failCount != null">
        #{failCount,jdbcType=INTEGER},
      </if>
      <if test="lastYear != null">
        #{lastYear,jdbcType=VARCHAR},
      </if>
      <if test="lastYearCapital != null">
        #{lastYearCapital,jdbcType=DECIMAL},
      </if>
      <if test="lastYearIncome != null">
        #{lastYearIncome,jdbcType=DECIMAL},
      </if>
      <if test="costActual != null">
        #{costActual,jdbcType=DECIMAL},
      </if>
      <if test="patentCost != null">
        #{patentCost,jdbcType=DECIMAL},
      </if>
      <if test="patentCostActual != null">
        #{patentCostActual,jdbcType=DECIMAL},
      </if>
      <if test="softCost != null">
        #{softCost,jdbcType=DECIMAL},
      </if>
      <if test="softCostActual != null">
        #{softCostActual,jdbcType=DECIMAL},
      </if>
      <if test="auditCost != null">
        #{auditCost,jdbcType=DECIMAL},
      </if>
      <if test="auditCostActual != null">
        #{auditCostActual,jdbcType=DECIMAL},
      </if>
      <if test="otherCost != null">
        #{otherCost,jdbcType=DECIMAL},
      </if>
      <if test="otherCostActual != null">
        #{otherCostActual,jdbcType=DECIMAL},
      </if>
      <if test="expectProfit != null">
        #{expectProfit,jdbcType=DECIMAL},
      </if>
      <if test="actualProfit != null">
        #{actualProfit,jdbcType=DECIMAL},
      </if>
      <if test="stopType != null">
        #{stopType,jdbcType=INTEGER},
      </if>
      <if test="stopStatus != null">
        #{stopStatus,jdbcType=INTEGER},
      </if>
      <if test="change != null">
        #{change,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.TTaskMid">
    update t_task_mid
    <set>
      <if test="tid != null">
        tid = #{tid,jdbcType=INTEGER},
      </if>
      <if test="costAmount != null">
        cost_amount = #{costAmount,jdbcType=DECIMAL},
      </if>
      <if test="partyAmount != null">
        party_amount = #{partyAmount,jdbcType=DECIMAL},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="certificatesCount != null">
        certificates_count = #{certificatesCount,jdbcType=INTEGER},
      </if>
      <if test="urgentDay != null">
        urgent_day = #{urgentDay,jdbcType=INTEGER},
      </if>
      <if test="ifMaterial != null">
        if_material = #{ifMaterial,jdbcType=INTEGER},
      </if>
      <if test="rejectCount != null">
        reject_count = #{rejectCount,jdbcType=INTEGER},
      </if>
      <if test="acceptCount != null">
        accept_count = #{acceptCount,jdbcType=INTEGER},
      </if>
      <if test="endCount != null">
        end_count = #{endCount,jdbcType=INTEGER},
      </if>
      <if test="authorizeCount != null">
        authorize_count = #{authorizeCount,jdbcType=INTEGER},
      </if>
      <if test="applyCount != null">
        apply_count = #{applyCount,jdbcType=INTEGER},
      </if>
      <if test="highNewRetrial != null">
        high_new_retrial = #{highNewRetrial,jdbcType=INTEGER},
      </if>
      <if test="dispatchCount != null">
        dispatch_count = #{dispatchCount,jdbcType=INTEGER},
      </if>
      <if test="stockCount != null">
        stock_count = #{stockCount,jdbcType=INTEGER},
      </if>
      <if test="completeCount != null">
        complete_count = #{completeCount,jdbcType=INTEGER},
      </if>
      <if test="promulgateCount != null">
        promulgate_count = #{promulgateCount,jdbcType=INTEGER},
      </if>
      <if test="dispatchProvince != null">
        dispatch_province = #{dispatchProvince,jdbcType=INTEGER},
      </if>
      <if test="dutyDep != null">
        duty_dep = #{dutyDep,jdbcType=VARCHAR},
      </if>
      <if test="setUpCount != null">
        set_up_count = #{setUpCount,jdbcType=INTEGER},
      </if>
      <if test="spotCheckCount != null">
        spot_check_count = #{spotCheckCount,jdbcType=INTEGER},
      </if>
      <if test="failCount != null">
        fail_count = #{failCount,jdbcType=INTEGER},
      </if>
      <if test="lastYear != null">
        last_year = #{lastYear,jdbcType=VARCHAR},
      </if>
      <if test="lastYearCapital != null">
        last_year_capital = #{lastYearCapital,jdbcType=DECIMAL},
      </if>
      <if test="lastYearIncome != null">
        last_year_income = #{lastYearIncome,jdbcType=DECIMAL},
      </if>
      <if test="costActual != null">
        cost_actual = #{costActual,jdbcType=DECIMAL},
      </if>
      <if test="patentCost != null">
        patent_cost = #{patentCost,jdbcType=DECIMAL},
      </if>
      <if test="patentCostActual != null">
        patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
      </if>
      <if test="softCost != null">
        soft_cost = #{softCost,jdbcType=DECIMAL},
      </if>
      <if test="softCostActual != null">
        soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
      </if>
      <if test="auditCost != null">
        audit_cost = #{auditCost,jdbcType=DECIMAL},
      </if>
      <if test="auditCostActual != null">
        audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
      </if>
      <if test="otherCost != null">
        other_cost = #{otherCost,jdbcType=DECIMAL},
      </if>
      <if test="otherCostActual != null">
        other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
      </if>
      <if test="expectProfit != null">
        expect_profit = #{expectProfit,jdbcType=DECIMAL},
      </if>
      <if test="actualProfit != null">
        actual_profit = #{actualProfit,jdbcType=DECIMAL},
      </if>
      <if test="stopType != null">
        stop_type = #{stopType,jdbcType=INTEGER},
      </if>
      <if test="stopStatus != null">
        stop_status = #{stopStatus,jdbcType=INTEGER},
      </if>
      <if test="change != null">
        `change` = #{change,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.goafanti.common.model.TTaskMid">
    update t_task_mid
    set tid = #{tid,jdbcType=INTEGER},
      cost_amount = #{costAmount,jdbcType=DECIMAL},
      party_amount = #{partyAmount,jdbcType=DECIMAL},
      create_time = #{createTime,jdbcType=TIMESTAMP},
      certificates_count = #{certificatesCount,jdbcType=INTEGER},
      urgent_day = #{urgentDay,jdbcType=INTEGER},
      if_material = #{ifMaterial,jdbcType=INTEGER},
      reject_count = #{rejectCount,jdbcType=INTEGER},
      accept_count = #{acceptCount,jdbcType=INTEGER},
      end_count = #{endCount,jdbcType=INTEGER},
      authorize_count = #{authorizeCount,jdbcType=INTEGER},
      apply_count = #{applyCount,jdbcType=INTEGER},
      high_new_retrial = #{highNewRetrial,jdbcType=INTEGER},
      dispatch_count = #{dispatchCount,jdbcType=INTEGER},
      stock_count = #{stockCount,jdbcType=INTEGER},
      complete_count = #{completeCount,jdbcType=INTEGER},
      promulgate_count = #{promulgateCount,jdbcType=INTEGER},
      dispatch_province = #{dispatchProvince,jdbcType=INTEGER},
      duty_dep = #{dutyDep,jdbcType=VARCHAR},
      set_up_count = #{setUpCount,jdbcType=INTEGER},
      spot_check_count = #{spotCheckCount,jdbcType=INTEGER},
      fail_count = #{failCount,jdbcType=INTEGER},
      last_year = #{lastYear,jdbcType=VARCHAR},
      last_year_capital = #{lastYearCapital,jdbcType=DECIMAL},
      last_year_income = #{lastYearIncome,jdbcType=DECIMAL},
      cost_actual = #{costActual,jdbcType=DECIMAL},
      patent_cost = #{patentCost,jdbcType=DECIMAL},
      patent_cost_actual = #{patentCostActual,jdbcType=DECIMAL},
      soft_cost = #{softCost,jdbcType=DECIMAL},
      soft_cost_actual = #{softCostActual,jdbcType=DECIMAL},
      audit_cost = #{auditCost,jdbcType=DECIMAL},
      audit_cost_actual = #{auditCostActual,jdbcType=DECIMAL},
      other_cost = #{otherCost,jdbcType=DECIMAL},
      other_cost_actual = #{otherCostActual,jdbcType=DECIMAL},
      expect_profit = #{expectProfit,jdbcType=DECIMAL},
      actual_profit = #{actualProfit,jdbcType=DECIMAL},
      stop_type = #{stopType,jdbcType=INTEGER},
      stop_status = #{stopStatus,jdbcType=INTEGER},
      `change` = #{change,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>



  <update id="updatePaymentAmount">
    update t_task_mid
    set party_amount = party_amount
    <if test="type == 0">
      + #{paymentAmount,jdbcType=DECIMAL}
    </if>
    <if test="type == 1">
      - #{paymentAmount,jdbcType=DECIMAL}
    </if>
    where tid = #{tid,jdbcType=INTEGER}
  </update>


  <update id="updateCostAmount">
    update t_order_task a ,t_task_mid c
    set c.cost_amount=#{count},c.party_amount=#{party}
    where  a.id=c.tid and a.id= #{tid}
  </update>

  <update id="updateCertificatesCountByTid">
    update t_task_mid
    set certificates_count= #{count}
    where tid= #{tid}
  </update>

  <update id="updateByTid" parameterType="com.goafanti.common.model.TTaskMid">
    update t_task_mid
    <set>
      <if test="costAmount != null">
        cost_amount = #{costAmount,jdbcType=DECIMAL},
      </if>
      <if test="partyAmount != null">
        party_amount = #{partyAmount,jdbcType=DECIMAL},
      </if>
      <if test="createTime != null">
        create_time = #{createTime,jdbcType=TIMESTAMP},
      </if>
      <if test="certificatesCount != null">
        certificates_count = #{certificatesCount,jdbcType=INTEGER},
      </if>
      <if test="urgentDay != null">
        urgent_day = #{urgentDay,jdbcType=INTEGER},
      </if>
      <if test="ifMaterial != null">
        if_material = #{ifMaterial,jdbcType=INTEGER},
      </if>
      <if test="rejectCount != null">
        reject_count = #{rejectCount,jdbcType=INTEGER},
      </if>
      <if test="acceptCount != null">
        accept_count = #{acceptCount,jdbcType=INTEGER},
      </if>
      <if test="endCount != null">
        end_count = #{endCount,jdbcType=INTEGER},
      </if>
      <if test="authorizeCount != null">
        authorize_count = #{authorizeCount,jdbcType=INTEGER},
      </if>
      <if test="applyCount != null">
        apply_count = #{applyCount,jdbcType=INTEGER},
      </if>
      <if test="highNewRetrial != null">
        high_new_retrial = #{highNewRetrial,jdbcType=INTEGER},
      </if>
      <if test="dispatchCount != null">
        dispatch_count = #{dispatchCount,jdbcType=INTEGER},
      </if>
      <if test="stockCount != null">
        stock_count = #{stockCount,jdbcType=INTEGER},
      </if>
      <if test="completeCount != null">
        complete_count = #{completeCount,jdbcType=INTEGER},
      </if>
      <if test="promulgateCount != null">
        promulgate_count = #{promulgateCount,jdbcType=INTEGER},
      </if>
      <if test="dispatchProvince != null">
        dispatch_province = #{dispatchProvince,jdbcType=INTEGER},
      </if>
      <if test="dutyDep != null">
        duty_dep = #{dutyDep,jdbcType=VARCHAR},
      </if>
      <if test="setUpCount != null">
        set_up_count = #{setUpCount,jdbcType=INTEGER},
      </if>
      <if test="spotCheckCount != null">
        spot_check_count = #{spotCheckCount,jdbcType=INTEGER},
      </if>
      <if test="failCount != null">
        fail_count = #{failCount,jdbcType=INTEGER},
      </if>
      <if test="lastYear != null">
        last_year = #{lastYear,jdbcType=VARCHAR},
      </if>
      <if test="lastYearCapital != null">
        last_year_capital = #{lastYearCapital,jdbcType=DECIMAL},
      </if>
      <if test="lastYearIncome != null">
        last_year_income = #{lastYearIncome,jdbcType=DECIMAL},
      </if>
      <if test="stopType != null">
        stop_type = #{stopType,jdbcType=INTEGER},
      </if>
      <if test="stopStatus != null">
        stop_status = #{stopStatus,jdbcType=INTEGER},
      </if>
    </set>
    where tid = #{tid,jdbcType=INTEGER}
  </update>
  <select id="selectCountBytid" resultType="com.goafanti.common.model.TTaskMid">
    select a.id,
    <if test="type ==0">
      ifnull(b.lic,0) certificatesCount
    </if>
    <if test="type ==1">
      ifnull(b.acc ,0)acceptCount, ifnull(b.lic ,0)authorizeCount,ifnull(b.lic ,0)certificatesCount,
      ifnull(b.tgc ,0)endCount,ifnull(b.bhc ,0)rejectCount
    </if>
    <if test="type ==2">
      ifnull(b.acc ,0)acceptCount,ifnull(b.lic ,0)certificatesCount,ifnull(b.sqc,0) applyCount,
      ifnull(b.bhc,0) rejectCount
    </if>
    from t_task_mid a left join (select task_id tid,
    <if test="type ==0">
      sum(if(licence_time is null,0,1))lic from task_progress where task_id= #{tid} GROUP by task_id)b
    </if>
    <if test="type ==1">
      <!-- 下证数与授权数一样，下证统计大于则用下证，小于或者等于用授权统计 -->
      sum(if(if(licence_time is null,0,1) &gt; if(authorize_time is null,0,1),
      if(licence_time is null,0,1),if(authorize_time is null,0,1)))lic ,ifnull(count(accept_time),0)acc,
      sum(if(status=1,1,0))tgc,sum(if(status=2 ,1,0))bhc from task_progress where task_id= #{tid} GROUP by task_id )b
    </if>
    <if test="type ==2">
      count(*)sqc,  sum(if(licence_time is null,0,1))lic , sum(if(accept_time is null,0,1))acc,
      sum(if(status=2 ,1,0))bhc  from task_progress where task_id= #{tid} GROUP by task_id )b
    </if>
    on a.tid =b.tid
    where a.tid= #{tid}
  </select>
  <select id="getDtails" resultType="com.goafanti.common.model.TTaskMid">
    select a.id tid,dg.id dispatchProvince,tr.department_id dutyDep
    from t_order_task a left join t_order_new b on a.order_no =b.order_no
                        left join department c on b.order_dep =c.id  left join admin tr on a.task_receiver =tr.id
                        left join district_glossory dg on c.province =dg.id
    where a.id= #{id};
  </select>

</mapper>
