<?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.chinaitop.depot.intelligent.grainNumberMonitor.mapper.TNumberWarningMapper">
    <resultMap id="BaseResultMap" type="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarning">
        <id column="id" property="id" jdbcType="VARCHAR"/>
        <result column="vcfcode" property="vcfcode" jdbcType="VARCHAR"/>
        <result column="org_id" property="orgId" jdbcType="VARCHAR"/>
        <result column="vdevcode" property="vdevcode" jdbcType="VARCHAR"/>
        <result column="monitor_number" property="monitorNumber" jdbcType="VARCHAR"/>
        <result column="t_volume" property="tVolume" jdbcType="VARCHAR"/>
        <result column="t_error" property="tError" jdbcType="VARCHAR"/>
        <result column="depot_type" property="depotType" jdbcType="VARCHAR"/>
        <result column="depot_long" property="depotLong" jdbcType="VARCHAR"/>
        <result column="depot_wide" property="depotWide" jdbcType="VARCHAR"/>
        <result column="avg_heightv" property="avgHeightv" jdbcType="VARCHAR"/>
        <result column="abnormal_cargo" property="abnormalCargo" jdbcType="VARCHAR"/>
        <result column="monitor_time" property="monitorTime" jdbcType="TIMESTAMP"/>
        <result column="operator" property="operator" jdbcType="VARCHAR"/>
        <result column="updatetime" property="updatetime" jdbcType="TIMESTAMP"/>
    </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, vcfcode, org_id, vdevcode, monitor_number, t_volume, t_error, depot_type, depot_long, 
    depot_wide, avg_heightv, abnormal_cargo, monitor_time, operator, updatetime
  </sql>
    <select id="selectByExample" resultMap="BaseResultMap"
            parameterType="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarningExample">
        select
        <if test="distinct">
            distinct
        </if>
        <include refid="Base_Column_List"/>
        from t_number_warning
        <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.String">
        select
        <include refid="Base_Column_List"/>
        from t_number_warning
        where id = #{id,jdbcType=VARCHAR}
    </select>
    <delete id="deleteByPrimaryKey" parameterType="java.lang.String">
    delete from t_number_warning
    where id = #{id,jdbcType=VARCHAR}
  </delete>
    <delete id="deleteByExample"
            parameterType="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarningExample">
        delete from t_number_warning
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </delete>
    <insert id="insert" parameterType="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarning">
    insert into t_number_warning (id, vcfcode, org_id, 
      vdevcode, monitor_number, t_volume, 
      t_error, depot_type, depot_long, 
      depot_wide, avg_heightv, abnormal_cargo, 
      monitor_time, operator, updatetime
      )
    values (#{id,jdbcType=VARCHAR}, #{vcfcode,jdbcType=VARCHAR}, #{orgId,jdbcType=VARCHAR}, 
      #{vdevcode,jdbcType=VARCHAR}, #{monitorNumber,jdbcType=VARCHAR}, #{tVolume,jdbcType=VARCHAR}, 
      #{tError,jdbcType=VARCHAR}, #{depotType,jdbcType=VARCHAR}, #{depotLong,jdbcType=VARCHAR}, 
      #{depotWide,jdbcType=VARCHAR}, #{avgHeightv,jdbcType=VARCHAR}, #{abnormalCargo,jdbcType=VARCHAR}, 
      #{monitorTime,jdbcType=TIMESTAMP}, #{operator,jdbcType=VARCHAR}, #{updatetime,jdbcType=TIMESTAMP}
      )
  </insert>
    <insert id="insertSelective"
            parameterType="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarning">
        insert into t_number_warning
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="vcfcode != null">
                vcfcode,
            </if>
            <if test="orgId != null">
                org_id,
            </if>
            <if test="vdevcode != null">
                vdevcode,
            </if>
            <if test="monitorNumber != null">
                monitor_number,
            </if>
            <if test="tVolume != null">
                t_volume,
            </if>
            <if test="tError != null">
                t_error,
            </if>
            <if test="depotType != null">
                depot_type,
            </if>
            <if test="depotLong != null">
                depot_long,
            </if>
            <if test="depotWide != null">
                depot_wide,
            </if>
            <if test="avgHeightv != null">
                avg_heightv,
            </if>
            <if test="abnormalCargo != null">
                abnormal_cargo,
            </if>
            <if test="monitorTime != null">
                monitor_time,
            </if>
            <if test="operator != null">
                operator,
            </if>
            <if test="updatetime != null">
                updatetime,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=VARCHAR},
            </if>
            <if test="vcfcode != null">
                #{vcfcode,jdbcType=VARCHAR},
            </if>
            <if test="orgId != null">
                #{orgId,jdbcType=VARCHAR},
            </if>
            <if test="vdevcode != null">
                #{vdevcode,jdbcType=VARCHAR},
            </if>
            <if test="monitorNumber != null">
                #{monitorNumber,jdbcType=VARCHAR},
            </if>
            <if test="tVolume != null">
                #{tVolume,jdbcType=VARCHAR},
            </if>
            <if test="tError != null">
                #{tError,jdbcType=VARCHAR},
            </if>
            <if test="depotType != null">
                #{depotType,jdbcType=VARCHAR},
            </if>
            <if test="depotLong != null">
                #{depotLong,jdbcType=VARCHAR},
            </if>
            <if test="depotWide != null">
                #{depotWide,jdbcType=VARCHAR},
            </if>
            <if test="avgHeightv != null">
                #{avgHeightv,jdbcType=VARCHAR},
            </if>
            <if test="abnormalCargo != null">
                #{abnormalCargo,jdbcType=VARCHAR},
            </if>
            <if test="monitorTime != null">
                #{monitorTime,jdbcType=TIMESTAMP},
            </if>
            <if test="operator != null">
                #{operator,jdbcType=VARCHAR},
            </if>
            <if test="updatetime != null">
                #{updatetime,jdbcType=TIMESTAMP},
            </if>
        </trim>
    </insert>
    <select id="countByExample"
            parameterType="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarningExample"
            resultType="java.lang.Integer">
        select count(*) from t_number_warning
        <if test="_parameter != null">
            <include refid="Example_Where_Clause"/>
        </if>
    </select>
    <update id="updateByExampleSelective" parameterType="map">
        update t_number_warning
        <set>
            <if test="record.id != null">
                id = #{record.id,jdbcType=VARCHAR},
            </if>
            <if test="record.vcfcode != null">
                vcfcode = #{record.vcfcode,jdbcType=VARCHAR},
            </if>
            <if test="record.orgId != null">
                org_id = #{record.orgId,jdbcType=VARCHAR},
            </if>
            <if test="record.vdevcode != null">
                vdevcode = #{record.vdevcode,jdbcType=VARCHAR},
            </if>
            <if test="record.monitorNumber != null">
                monitor_number = #{record.monitorNumber,jdbcType=VARCHAR},
            </if>
            <if test="record.tVolume != null">
                t_volume = #{record.tVolume,jdbcType=VARCHAR},
            </if>
            <if test="record.tError != null">
                t_error = #{record.tError,jdbcType=VARCHAR},
            </if>
            <if test="record.depotType != null">
                depot_type = #{record.depotType,jdbcType=VARCHAR},
            </if>
            <if test="record.depotLong != null">
                depot_long = #{record.depotLong,jdbcType=VARCHAR},
            </if>
            <if test="record.depotWide != null">
                depot_wide = #{record.depotWide,jdbcType=VARCHAR},
            </if>
            <if test="record.avgHeightv != null">
                avg_heightv = #{record.avgHeightv,jdbcType=VARCHAR},
            </if>
            <if test="record.abnormalCargo != null">
                abnormal_cargo = #{record.abnormalCargo,jdbcType=VARCHAR},
            </if>
            <if test="record.monitorTime != null">
                monitor_time = #{record.monitorTime,jdbcType=TIMESTAMP},
            </if>
            <if test="record.operator != null">
                operator = #{record.operator,jdbcType=VARCHAR},
            </if>
            <if test="record.updatetime != null">
                updatetime = #{record.updatetime,jdbcType=TIMESTAMP},
            </if>
        </set>
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByExample" parameterType="map">
        update t_number_warning
        set id = #{record.id,jdbcType=VARCHAR},
        vcfcode = #{record.vcfcode,jdbcType=VARCHAR},
        org_id = #{record.orgId,jdbcType=VARCHAR},
        vdevcode = #{record.vdevcode,jdbcType=VARCHAR},
        monitor_number = #{record.monitorNumber,jdbcType=VARCHAR},
        t_volume = #{record.tVolume,jdbcType=VARCHAR},
        t_error = #{record.tError,jdbcType=VARCHAR},
        depot_type = #{record.depotType,jdbcType=VARCHAR},
        depot_long = #{record.depotLong,jdbcType=VARCHAR},
        depot_wide = #{record.depotWide,jdbcType=VARCHAR},
        avg_heightv = #{record.avgHeightv,jdbcType=VARCHAR},
        abnormal_cargo = #{record.abnormalCargo,jdbcType=VARCHAR},
        monitor_time = #{record.monitorTime,jdbcType=TIMESTAMP},
        operator = #{record.operator,jdbcType=VARCHAR},
        updatetime = #{record.updatetime,jdbcType=TIMESTAMP}
        <if test="_parameter != null">
            <include refid="Update_By_Example_Where_Clause"/>
        </if>
    </update>
    <update id="updateByPrimaryKeySelective"
            parameterType="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarning">
        update t_number_warning
        <set>
            <if test="vcfcode != null">
                vcfcode = #{vcfcode,jdbcType=VARCHAR},
            </if>
            <if test="orgId != null">
                org_id = #{orgId,jdbcType=VARCHAR},
            </if>
            <if test="vdevcode != null">
                vdevcode = #{vdevcode,jdbcType=VARCHAR},
            </if>
            <if test="monitorNumber != null">
                monitor_number = #{monitorNumber,jdbcType=VARCHAR},
            </if>
            <if test="tVolume != null">
                t_volume = #{tVolume,jdbcType=VARCHAR},
            </if>
            <if test="tError != null">
                t_error = #{tError,jdbcType=VARCHAR},
            </if>
            <if test="depotType != null">
                depot_type = #{depotType,jdbcType=VARCHAR},
            </if>
            <if test="depotLong != null">
                depot_long = #{depotLong,jdbcType=VARCHAR},
            </if>
            <if test="depotWide != null">
                depot_wide = #{depotWide,jdbcType=VARCHAR},
            </if>
            <if test="avgHeightv != null">
                avg_heightv = #{avgHeightv,jdbcType=VARCHAR},
            </if>
            <if test="abnormalCargo != null">
                abnormal_cargo = #{abnormalCargo,jdbcType=VARCHAR},
            </if>
            <if test="monitorTime != null">
                monitor_time = #{monitorTime,jdbcType=TIMESTAMP},
            </if>
            <if test="operator != null">
                operator = #{operator,jdbcType=VARCHAR},
            </if>
            <if test="updatetime != null">
                updatetime = #{updatetime,jdbcType=TIMESTAMP},
            </if>
        </set>
        where id = #{id,jdbcType=VARCHAR}
    </update>
    <update id="updateByPrimaryKey"
            parameterType="com.chinaitop.depot.intelligent.grainNumberMonitor.model.TNumberWarning">
    update t_number_warning
    set vcfcode = #{vcfcode,jdbcType=VARCHAR},
      org_id = #{orgId,jdbcType=VARCHAR},
      vdevcode = #{vdevcode,jdbcType=VARCHAR},
      monitor_number = #{monitorNumber,jdbcType=VARCHAR},
      t_volume = #{tVolume,jdbcType=VARCHAR},
      t_error = #{tError,jdbcType=VARCHAR},
      depot_type = #{depotType,jdbcType=VARCHAR},
      depot_long = #{depotLong,jdbcType=VARCHAR},
      depot_wide = #{depotWide,jdbcType=VARCHAR},
      avg_heightv = #{avgHeightv,jdbcType=VARCHAR},
      abnormal_cargo = #{abnormalCargo,jdbcType=VARCHAR},
      monitor_time = #{monitorTime,jdbcType=TIMESTAMP},
      operator = #{operator,jdbcType=VARCHAR},
      updatetime = #{updatetime,jdbcType=TIMESTAMP}
    where id = #{id,jdbcType=VARCHAR}
  </update>

    <select id="getThisAndSetList" resultType="java.util.Map" parameterType="java.util.Map">
        SELECT
        tj.v_jc_code jccode,
        tj.v_remark vcfcode,
        tj.v_cf_code vcf,
        tj.org_id orgid,
        tj.v_ws_src ws,
        tn.id id,
        tn.monitor_number monitorNumber,
        tn.t_volume tvolume,
        tn.depot_long tlong,
        tn.depot_wide twide,
        tn.depot_type ttype,
        tn.t_error terror,
        tn.avg_heightv avgheightv,
        tn.abnormal_cargo tcargo,
        tn.monitor_time monitorTime,
        tn.operator operator
        FROM
        t_jctable tj
        LEFT JOIN t_number_warning tn ON tj.v_jc_code = tn.vdevcode AND tj.org_id = tn.org_id
        <where>
            tj.v_ws_src IS NOT NULL
            <if test="vcfcode != null">
                AND tj.v_cf_code = #{vcfcode}
            </if>
        </where>
        ORDER BY
        tn.monitor_time DESC
    </select>

    <select id="getVideoInfo" resultType="java.util.Map">
        SELECT
        id id,
        org_id orgId,
        v_cf_code vCfCode,
        v_vedio_ip vVedioIp,
        i_vedio_port iVedioPort,
        v_vedio_user vVedioUser,
        v_vedio_pwd vVedioPwd,
        v_vedio_tdh vVedioTdh,
        v_jcpp vJcpp
        FROM
        t_jctable
        <where>
            v_vedio_ip IS NOT NULL
            AND del_flag = 1
            AND i_vedio_port IS NOT NULL
            AND v_vedio_user IS NOT NULL
            AND v_vedio_pwd IS NOT NULL
            AND v_vedio_tdh IS NOT NULL
        </where>
    </select>


    <select id="getCfName" resultType="java.util.Map" parameterType="java.lang.String">
   SELECT
	storehouse_name cfname,
	storehouse_code cfcode
  FROM
	basic_storehouse
  WHERE
	storehouse_code = (
		SELECT
			v_remark
		FROM
			t_jctable
		WHERE
			v_cf_code = #{cfname}
	)
  </select>
</mapper>