<?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.xinwei.order.dao.OrderAlarmTblMapper" >
  <resultMap id="BaseResultMap" type="com.xinwei.order.entity.OrderAlarmTbl" >
    <id column="id" property="id" jdbcType="BIGINT" />
    <result column="alarm_id" property="alarmId" jdbcType="VARCHAR" />
    <result column="data_id" property="dataId" jdbcType="VARCHAR" />
    <result column="device_name" property="deviceName" jdbcType="VARCHAR" />
    <result column="device_id" property="deviceId" jdbcType="VARCHAR" />
    <result column="alarm_topic" property="alarmTopic" jdbcType="VARCHAR" />
    <result column="level" property="level" jdbcType="VARCHAR" />
    <result column="order_status" property="orderStatus" jdbcType="VARCHAR" />
    <result column="cost_time" property="costTime" jdbcType="VARCHAR" />
    <result column="proc_inst_id" property="procInstId" jdbcType="VARCHAR" />
    <result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
     <result column="alarm_type" property="alarmType" jdbcType="VARCHAR" />
    <result column="alarm_location" property="alarmLocation" jdbcType="VARCHAR" />
    <result column="ext" property="ext" jdbcType="VARCHAR" />
    <result column="suspend_reason" property="suspendReason" jdbcType="VARCHAR" />
  </resultMap>
 
      <delete id="deleteById" parameterType="java.lang.Long" >
        delete from order_alarm_tbl
        where id = #{id,jdbcType=BIGINT}
      </delete>
      
        <delete id="deleteAll">
        delete from order_alarm_tbl
      </delete>
      
        <delete id="deleteByAlarmId" parameterType="java.lang.String" >
        delete from order_alarm_tbl
        where alarm_id = #{alarmId,jdbcType=VARCHAR}
      </delete>
 
      <insert id="insert" parameterType="com.xinwei.order.entity.OrderAlarmTbl" >
        insert into order_alarm_tbl (id, alarm_id, data_id,
          device_name, device_id, alarm_topic, alarm_type, alarm_location,
          level, order_status, cost_time,
          proc_inst_id, create_time, ext,suspend_reason
          )
        values (#{id,jdbcType=BIGINT}, #{alarmId,jdbcType=VARCHAR}, #{dataId,jdbcType=VARCHAR},
          #{deviceName,jdbcType=VARCHAR}, #{deviceId,jdbcType=VARCHAR}, #{alarmTopic,jdbcType=VARCHAR},
          #{alarmType,jdbcType=VARCHAR}, #{alarmLocation,jdbcType=VARCHAR},  
          #{level,jdbcType=VARCHAR}, #{orderStatus,jdbcType=VARCHAR}, #{costTime,jdbcType=VARCHAR},
          #{procInstId,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{ext,jdbcType=VARCHAR}, #{suspendReason,jdbcType=VARCHAR}
          )
      </insert>
 
     <insert id="insertByBatch" parameterType="java.util.List">
        insert into order_alarm_tbl (id,alarm_id, data_id,
      device_name, device_id, alarm_topic, alarm_type, alarm_location,
      level, order_status, cost_time,
      proc_inst_id, create_time, ext,suspend_reason
      )
        values
        <foreach collection="list" item="item" index="index" separator=",">
         ( #{item.id,jdbcType=BIGINT},#{item.alarmId,jdbcType=VARCHAR}, #{item.dataId,jdbcType=VARCHAR},
      #{item.deviceName,jdbcType=VARCHAR}, #{item.deviceId,jdbcType=VARCHAR}, #{item.alarmTopic,jdbcType=VARCHAR},
      #{item.alarmType,jdbcType=VARCHAR}, #{item.alarmLocation,jdbcType=VARCHAR},  
      #{item.level,jdbcType=VARCHAR}, #{item.orderStatus,jdbcType=VARCHAR}, #{item.costTime,jdbcType=VARCHAR},
      #{item.procInstId,jdbcType=VARCHAR}, #{item.createTime,jdbcType=TIMESTAMP}, #{item.ext,jdbcType=VARCHAR}, #{item.suspendReason,jdbcType=VARCHAR}
      )
        </foreach>
    </insert>
 
  <update id="updateByPrimaryKey" parameterType="com.xinwei.order.entity.OrderAlarmTbl" >
    update order_alarm_tbl
    set alarm_id = #{alarmId,jdbcType=VARCHAR},
    data_id = #{dataId,jdbcType=VARCHAR},
    device_name = #{deviceName,jdbcType=VARCHAR},
    device_id = #{deviceId,jdbcType=VARCHAR},
    alarm_topic = #{alarmTopic,jdbcType=VARCHAR},
    alarm_type = #{alarmType,jdbcType=VARCHAR},
    alarm_location = #{alarmLocation,jdbcType=VARCHAR},
    level = #{level,jdbcType=VARCHAR},
    order_status = #{orderStatus,jdbcType=VARCHAR},
    cost_time = #{costTime,jdbcType=VARCHAR},
    proc_inst_id = #{procInstId,jdbcType=VARCHAR},
    create_time = #{createTime,jdbcType=TIMESTAMP},
    ext = #{ext,jdbcType=VARCHAR},
    suspend_reason = #{suspendReason,jdbcType=VARCHAR}
    where id = #{id,jdbcType=VARCHAR}
  </update>
 
    <update id="updateOrderStatusByDataId" parameterType="com.xinwei.order.entity.OrderAlarmTbl" >
    update order_alarm_tbl
    set order_status = #{orderStatus,jdbcType=VARCHAR}
    where data_id = #{dataId,jdbcType=VARCHAR}
  </update>
 
   <update id="updateSuspendReasonByDataId" parameterType="com.xinwei.order.entity.OrderAlarmTbl" >
    update order_alarm_tbl
    set suspend_reason = #{suspendReason,jdbcType=VARCHAR}
    where data_id = #{dataId,jdbcType=VARCHAR}
  </update>
 
   <update id="updateSuspendReasonByProcessInstId" parameterType="com.xinwei.order.entity.OrderAlarmTbl" >
    update order_alarm_tbl
    set suspend_reason = #{suspendReason,jdbcType=VARCHAR}
    where proc_inst_id = #{procInstId,jdbcType=VARCHAR}
  </update>
 
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic,alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    where id = #{id,jdbcType=BIGINT}
  </select>
 
    <select id="getByDataId" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic,alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    where data_id = #{dataId,jdbcType=VARCHAR}
  </select>
 
    <select id="getByAlarmId" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic,alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    where alarm_id = #{alarmId,jdbcType=VARCHAR}
  </select>
 
   <select id="getById" resultMap="BaseResultMap" parameterType="java.lang.Long" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic,alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    where id = #{id,jdbcType=BIGINT}
  </select>
 
  <select id="countMyApplyByCondition" resultType="java.lang.Long" >
    select count(1)
   from order_alarm_tbl
    where 1=1 <include refid="queryString" />
  </select>
 
   <select id="selectMyApplyByCondition" resultMap="BaseResultMap" >
 select id, alarm_id, data_id, device_name, device_id, alarm_topic,alarm_type, alarm_location,  level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    WHERE 1=1
    <include refid="queryString" />
    limit #{startRow},#{pageSize}
  </select>

<select id="countAll" resultType="java.lang.Long" >
    SELECT COUNT(*)
    from order_alarm_tbl
   </select>

<select id="getAll" resultMap="BaseResultMap" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic, alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    limit #{startRow},#{pageSize}
  </select>
 
    <select id="selectAll" resultMap="BaseResultMap" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic, alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    order by create_time desc
  </select>
 
   <select id="selectAllAlarmType" resultType="java.lang.String" >
  SELECT DISTINCT alarm_type
    FROM order_alarm_tbl
  </select>
 
  <select id="getSuspendTask" resultMap="BaseResultMap" >
   SELECT * FROM order_alarm_tbl WHERE suspend_reason IS NOT null
    order by create_time desc
  </select>
 
  <select id="countByCondition" resultType="java.lang.Long" >
    SELECT COUNT(*)
      from order_alarm_tbl
      where 1=1
    <include refid="queryString" />
   </select>
   
    <select id="getByCondition" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic,alarm_type, alarm_location,  level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    WHERE 1=1
    <include refid="queryString" />
    limit #{startRow},#{pageSize}
  </select>
 
     <select id="countExportByCondition" resultType="java.lang.Long" >
    SELECT COUNT(*)
      from order_alarm_tbl
      where 1=1
    <include refid="queryString" />
   </select>
 
    <select id="exportByCondition" resultMap="BaseResultMap" parameterType="java.lang.String" >
     select id, alarm_id, data_id, device_name, device_id, alarm_topic,alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    WHERE 1=1
    <include refid="queryString" />
  </select>
 
    <select id="selectProcInstIdByCondition" resultType="java.lang.String" >
    select proc_inst_id
    from order_alarm_tbl
    where 1=1 <include refid="queryString" />
  </select>
 
    <select id="countTAToDoListByCondition" resultType="java.lang.Long" >
    SELECT COUNT(*)
      from order_alarm_tbl
      where 1=1
    <include refid="queryTAToDoListByCondition" />
   </select>
   
    <select id="getTAToDoListByCondition" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic, alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    WHERE 1=1
    <include refid="queryTAToDoListByCondition" />
    limit #{startRow},#{pageSize}
  </select>
 
 
    <select id="getTAToDoListByConditionNoPage" resultMap="BaseResultMap" parameterType="java.lang.String" >
    select id, alarm_id, data_id, device_name, device_id, alarm_topic, alarm_type, alarm_location, level, order_status,
    cost_time, proc_inst_id, create_time, ext,suspend_reason
    from order_alarm_tbl
    WHERE 1=1
    <include refid="queryTAToDoListByCondition" />
  </select>

<sql id="queryTAToDoListByCondition">
    
      <if test="alarmType != null and alarmType !=''">
     and alarm_type = #{alarmType,jdbcType=VARCHAR}
    </if>
    
      <if test="alarmLocation != null and alarmLocation !=''">
     and alarm_location = #{alarmLocation,jdbcType=VARCHAR}
    </if>
    
     <if test="level != null and level !=''">
     and level = #{level,jdbcType=VARCHAR}
    </if>
    
     <if test="alarmId != null and alarmId !=''">
     and alarm_id = #{alarmId,jdbcType=VARCHAR}
    </if>
    
    <if test="deviceId != null and deviceId !=''">
     and device_id = #{deviceId,jdbcType=VARCHAR}
    </if>
    
    <if test="alarmTopic != null and alarmTopic !=''">
     and alarm_topic LIKE '%${alarmTopic}%'
    </if>

</sql>
 
  <sql id="queryString">
     <if test="alarmId != null and alarmId !=''">
     and alarm_id = #{alarmId,jdbcType=VARCHAR}
    </if>
    
    <if test="deviceId != null and deviceId !=''">
     and device_id = #{deviceId,jdbcType=VARCHAR}
    </if>
    
    <if test="alarmTopic != null and alarmTopic !=''">
     and alarm_topic LIKE '%${alarmTopic}%'
    </if>
    
     <if test="startTime != null and endTime != null">
        and DATE_FORMAT(create_time,'%m-%d-%Y')
           between DATE_FORMAT(#{startTime,jdbcType=VARCHAR},'%m-%d-%Y')
           and DATE_FORMAT(#{endTime,jdbcType=VARCHAR},'%m-%d-%Y')
    </if>
 </sql>
</mapper>

mybatis batchinsert的更多相关文章

  1. MyBatis6:MyBatis集成Spring事物管理(下篇)

    前言 前一篇文章<MyBatis5:MyBatis集成Spring事物管理(上篇)>复习了MyBatis的基本使用以及使用Spring管理MyBatis的事物的做法,本文的目的是在这个的基 ...

  2. MyBatis_ibatis和mybatis的区别【转】

    1. ibatis3.*版本以后正式改名为mybaits,它也从apache转到了google code下:也就是说ibatis2.*,mybatis3.*. 2. 映射文件的不同 ibatis的配置 ...

  3. 基于Oracle的Mybatis 批量插入

    项目中会遇到这样的情况,一次性要插入多条数据到数据库中,有两种插入方法: 方法一: Mybatis本身只支持逐条插入,比较笨的方法,就是遍历一个List,循环中逐条插入,比如下面这段代码 for(Da ...

  4. MyBatis6:MyBatis集成Spring事务管理(下篇)

    前言 前一篇文章<MyBatis5:MyBatis集成Spring事务管理(上篇)>复习了MyBatis的基本使用以及使用Spring管理MyBatis的事务的做法,本文的目的是在这个的基 ...

  5. MyBatis(6):MyBatis集成Spring事务管理(下)

    前一篇文章复习了MyBatis的基本使用以及使用Spring管理MyBatis的事务的做法,本文的目的是在这个的基础上稍微做一点点的进阶:多数据的事务处理.文章内容主要包含两方面: 1.单表多数据的事 ...

  6. mybatis批量update(mysql)

    Mapper文件中的写法 <insert id="batchUpdateTjData"> <foreach collection="list" ...

  7. MyBatis浅尝笔记

    MyBatis应属于一种轻量级的java持久层技术,它通过简单的SQL xml或注解,将数据库数据映射到接口与POJO.最近项目要用到mybatis,所以学习之后在这里做个总结,文中的示例以xml配置 ...

  8. mybatis 自动生成代码(mybatis generator)

    pom.xml 文件配置 引入 mybatis generator <properties> <mysql.connector.version>5.1.44</mysql ...

  9. mybatis mysql 批量插入

    场景描述: 使用mybatis操作mysql数据库,进行批量插入数据,提高代码质量和执行效率. 环境: mybatis spring mysql java xml配置文件 <insert id ...

随机推荐

  1. gateone安装使用

    下载地址 https://github.com/liftoff/GateOne unzip GateOne-master.zip cd GateOne-master/ python setup.py ...

  2. winform excel导入--自带office.interop.excel方式

    用npoi方式,遇到一个问题,有的excel用加密软件(盖章,只读等)生成的解析不了,所以换成自带的方式,可以解决. 需要引用系统自带Microsoft.office.interop.excel pu ...

  3. 关于数据库DML、DDL、DCL区别

    总体解释:DML(data manipulation language):       它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据库里的数据 ...

  4. U3d 入门

    环境搭建: 1.安装exe; 2.破解 ,百度

  5. 洛谷P4358密钥破解 [CQOI2016] 数论

    正解:数论 解题报告: 先,放个传送门QwQ 这题难点可能在理解题意,,, 所以我先放个题意QAQ 大概就是说,给定一个整数N,可以被拆成两个质数的成绩p*q,然后给出了一个数e,求d满足e*d=1( ...

  6. 计算机网络 0.初识Internet与TCP/IP协议

    互联网,即因特网,Internet.互联网是一个世界范围的计算机网络.连接了世界上无数的计算设备,这些计算设备为PC.基于Linux的工作站,serverservers等等. 这些设备依据其作用不同可 ...

  7. Python3学习之路~3.2 递归、函数式编程、高阶函数、匿名函数、嵌套函数

    1 递归 在函数内部,可以调用其他函数.如果一个函数在内部调用自身本身,这个函数就是递归函数. def calc(n): print(n) if int(n / 2) == 0: return n r ...

  8. HTML5-CSS3-JavaScript(1)

    之前大致总结过HTML5的发展. 这里贴出之前的随笔:http://www.cnblogs.com/jiangxiaobo/p/5199924.html 我们就从HTML5的基础总结起.希望可以提高自 ...

  9. sqlalchemy的fliter使用总结

    1.sqlalchemy查询操作的filter函数内,日期比较用datetime试了半天行不通(因为数据库表中那个字段是datetime类型,最后是用字符串"%Y-%m-%d %H:%M:% ...

  10. 循环匹配出图片地址(即src属性)

    <script type="text/javascript"> //思路分两步:作者(yanue). //1,匹配出图片img标签(即匹配出所有图片),过滤其他不需要的 ...