<?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.gyee.frame.mapper.auto.WarningInfoDayMapper">
  <resultMap id="BaseResultMap" type="com.gyee.frame.model.auto.WarningInfoDay">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="recordDate" jdbcType="TIMESTAMP" property="recorddate" />
    <result column="manufacturerId" jdbcType="VARCHAR" property="manufacturerid" />
    <result column="modelId" jdbcType="VARCHAR" property="modelid" />
    <result column="warningId" jdbcType="VARCHAR" property="warningid" />
    <result column="frequencyDay" jdbcType="INTEGER" property="frequencyday" />
    <result column="totalhoursDay" jdbcType="DECIMAL" property="totalhoursday" />
    <result column="frequencyMonth" jdbcType="INTEGER" property="frequencymonth" />
    <result column="totalhoursMonth" jdbcType="DECIMAL" property="totalhoursmonth" />
    <result column="frequencyYear" jdbcType="INTEGER" property="frequencyyear" />
    <result column="totalhoursYear" jdbcType="DECIMAL" property="totalhoursyear" />
    <result column="frequency" jdbcType="INTEGER" property="frequency" />
    <result column="totalHours" jdbcType="DECIMAL" property="totalhours" />
  </resultMap>
  <sql id="Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <where>
      <foreach collection="oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Update_By_Example_Where_Clause">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    <where>
      <foreach collection="example.oredCriteria" item="criteria" separator="or">
        <if test="criteria.valid">
          <trim prefix="(" prefixOverrides="and" suffix=")">
            <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 close=")" collection="criterion.value" item="listItem" open="(" separator=",">
                    #{listItem}
                  </foreach>
                </when>
              </choose>
            </foreach>
          </trim>
        </if>
      </foreach>
    </where>
  </sql>
  <sql id="Base_Column_List">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    id, recordDate, manufacturerId, modelId, warningId, frequencyDay, totalhoursDay, 
    frequencyMonth, totalhoursMonth, frequencyYear, totalhoursYear, frequency, totalHours
  </sql>
  <select id="selectByExample" parameterType="com.gyee.frame.model.auto.WarningInfoDayExample" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select
    <if test="distinct">
      distinct
    </if>
    <include refid="Base_Column_List" />
    from warninginfoday
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null">
      order by ${orderByClause}
    </if>
  </select>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select 
    <include refid="Base_Column_List" />
    from warninginfoday
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from warninginfoday
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <delete id="deleteByExample" parameterType="com.gyee.frame.model.auto.WarningInfoDayExample">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    delete from warninginfoday
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </delete>
  <insert id="insert" parameterType="com.gyee.frame.model.auto.WarningInfoDay">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into warninginfoday (id, recordDate, manufacturerId, 
      modelId, warningId, frequencyDay, 
      totalhoursDay, frequencyMonth, totalhoursMonth, 
      frequencyYear, totalhoursYear, frequency, 
      totalHours)
    values (#{id,jdbcType=INTEGER}, #{recorddate,jdbcType=TIMESTAMP}, #{manufacturerid,jdbcType=VARCHAR}, 
      #{modelid,jdbcType=VARCHAR}, #{warningid,jdbcType=VARCHAR}, #{frequencyday,jdbcType=INTEGER}, 
      #{totalhoursday,jdbcType=DECIMAL}, #{frequencymonth,jdbcType=INTEGER}, #{totalhoursmonth,jdbcType=DECIMAL}, 
      #{frequencyyear,jdbcType=INTEGER}, #{totalhoursyear,jdbcType=DECIMAL}, #{frequency,jdbcType=INTEGER}, 
      #{totalhours,jdbcType=DECIMAL})
  </insert>
  <insert id="insertSelective" parameterType="com.gyee.frame.model.auto.WarningInfoDay">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    insert into warninginfoday
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="recorddate != null">
        recordDate,
      </if>
      <if test="manufacturerid != null">
        manufacturerId,
      </if>
      <if test="modelid != null">
        modelId,
      </if>
      <if test="warningid != null">
        warningId,
      </if>
      <if test="frequencyday != null">
        frequencyDay,
      </if>
      <if test="totalhoursday != null">
        totalhoursDay,
      </if>
      <if test="frequencymonth != null">
        frequencyMonth,
      </if>
      <if test="totalhoursmonth != null">
        totalhoursMonth,
      </if>
      <if test="frequencyyear != null">
        frequencyYear,
      </if>
      <if test="totalhoursyear != null">
        totalhoursYear,
      </if>
      <if test="frequency != null">
        frequency,
      </if>
      <if test="totalhours != null">
        totalHours,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="recorddate != null">
        #{recorddate,jdbcType=TIMESTAMP},
      </if>
      <if test="manufacturerid != null">
        #{manufacturerid,jdbcType=VARCHAR},
      </if>
      <if test="modelid != null">
        #{modelid,jdbcType=VARCHAR},
      </if>
      <if test="warningid != null">
        #{warningid,jdbcType=VARCHAR},
      </if>
      <if test="frequencyday != null">
        #{frequencyday,jdbcType=INTEGER},
      </if>
      <if test="totalhoursday != null">
        #{totalhoursday,jdbcType=DECIMAL},
      </if>
      <if test="frequencymonth != null">
        #{frequencymonth,jdbcType=INTEGER},
      </if>
      <if test="totalhoursmonth != null">
        #{totalhoursmonth,jdbcType=DECIMAL},
      </if>
      <if test="frequencyyear != null">
        #{frequencyyear,jdbcType=INTEGER},
      </if>
      <if test="totalhoursyear != null">
        #{totalhoursyear,jdbcType=DECIMAL},
      </if>
      <if test="frequency != null">
        #{frequency,jdbcType=INTEGER},
      </if>
      <if test="totalhours != null">
        #{totalhours,jdbcType=DECIMAL},
      </if>
    </trim>
  </insert>
  <select id="countByExample" parameterType="com.gyee.frame.model.auto.WarningInfoDayExample" resultType="java.lang.Long">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    select count(*) from warninginfoday
    <if test="_parameter != null">
      <include refid="Example_Where_Clause" />
    </if>
  </select>
  <update id="updateByExampleSelective" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warninginfoday
    <set>
      <if test="record.id != null">
        id = #{record.id,jdbcType=INTEGER},
      </if>
      <if test="record.recorddate != null">
        recordDate = #{record.recorddate,jdbcType=TIMESTAMP},
      </if>
      <if test="record.manufacturerid != null">
        manufacturerId = #{record.manufacturerid,jdbcType=VARCHAR},
      </if>
      <if test="record.modelid != null">
        modelId = #{record.modelid,jdbcType=VARCHAR},
      </if>
      <if test="record.warningid != null">
        warningId = #{record.warningid,jdbcType=VARCHAR},
      </if>
      <if test="record.frequencyday != null">
        frequencyDay = #{record.frequencyday,jdbcType=INTEGER},
      </if>
      <if test="record.totalhoursday != null">
        totalhoursDay = #{record.totalhoursday,jdbcType=DECIMAL},
      </if>
      <if test="record.frequencymonth != null">
        frequencyMonth = #{record.frequencymonth,jdbcType=INTEGER},
      </if>
      <if test="record.totalhoursmonth != null">
        totalhoursMonth = #{record.totalhoursmonth,jdbcType=DECIMAL},
      </if>
      <if test="record.frequencyyear != null">
        frequencyYear = #{record.frequencyyear,jdbcType=INTEGER},
      </if>
      <if test="record.totalhoursyear != null">
        totalhoursYear = #{record.totalhoursyear,jdbcType=DECIMAL},
      </if>
      <if test="record.frequency != null">
        frequency = #{record.frequency,jdbcType=INTEGER},
      </if>
      <if test="record.totalhours != null">
        totalHours = #{record.totalhours,jdbcType=DECIMAL},
      </if>
    </set>
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByExample" parameterType="map">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warninginfoday
    set id = #{record.id,jdbcType=INTEGER},
      recordDate = #{record.recorddate,jdbcType=TIMESTAMP},
      manufacturerId = #{record.manufacturerid,jdbcType=VARCHAR},
      modelId = #{record.modelid,jdbcType=VARCHAR},
      warningId = #{record.warningid,jdbcType=VARCHAR},
      frequencyDay = #{record.frequencyday,jdbcType=INTEGER},
      totalhoursDay = #{record.totalhoursday,jdbcType=DECIMAL},
      frequencyMonth = #{record.frequencymonth,jdbcType=INTEGER},
      totalhoursMonth = #{record.totalhoursmonth,jdbcType=DECIMAL},
      frequencyYear = #{record.frequencyyear,jdbcType=INTEGER},
      totalhoursYear = #{record.totalhoursyear,jdbcType=DECIMAL},
      frequency = #{record.frequency,jdbcType=INTEGER},
      totalHours = #{record.totalhours,jdbcType=DECIMAL}
    <if test="_parameter != null">
      <include refid="Update_By_Example_Where_Clause" />
    </if>
  </update>
  <update id="updateByPrimaryKeySelective" parameterType="com.gyee.frame.model.auto.WarningInfoDay">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warninginfoday
    <set>
      <if test="recorddate != null">
        recordDate = #{recorddate,jdbcType=TIMESTAMP},
      </if>
      <if test="manufacturerid != null">
        manufacturerId = #{manufacturerid,jdbcType=VARCHAR},
      </if>
      <if test="modelid != null">
        modelId = #{modelid,jdbcType=VARCHAR},
      </if>
      <if test="warningid != null">
        warningId = #{warningid,jdbcType=VARCHAR},
      </if>
      <if test="frequencyday != null">
        frequencyDay = #{frequencyday,jdbcType=INTEGER},
      </if>
      <if test="totalhoursday != null">
        totalhoursDay = #{totalhoursday,jdbcType=DECIMAL},
      </if>
      <if test="frequencymonth != null">
        frequencyMonth = #{frequencymonth,jdbcType=INTEGER},
      </if>
      <if test="totalhoursmonth != null">
        totalhoursMonth = #{totalhoursmonth,jdbcType=DECIMAL},
      </if>
      <if test="frequencyyear != null">
        frequencyYear = #{frequencyyear,jdbcType=INTEGER},
      </if>
      <if test="totalhoursyear != null">
        totalhoursYear = #{totalhoursyear,jdbcType=DECIMAL},
      </if>
      <if test="frequency != null">
        frequency = #{frequency,jdbcType=INTEGER},
      </if>
      <if test="totalhours != null">
        totalHours = #{totalhours,jdbcType=DECIMAL},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.gyee.frame.model.auto.WarningInfoDay">
    <!--
      WARNING - @mbg.generated
      This element is automatically generated by MyBatis Generator, do not modify.
    -->
    update warninginfoday
    set recordDate = #{recorddate,jdbcType=TIMESTAMP},
      manufacturerId = #{manufacturerid,jdbcType=VARCHAR},
      modelId = #{modelid,jdbcType=VARCHAR},
      warningId = #{warningid,jdbcType=VARCHAR},
      frequencyDay = #{frequencyday,jdbcType=INTEGER},
      totalhoursDay = #{totalhoursday,jdbcType=DECIMAL},
      frequencyMonth = #{frequencymonth,jdbcType=INTEGER},
      totalhoursMonth = #{totalhoursmonth,jdbcType=DECIMAL},
      frequencyYear = #{frequencyyear,jdbcType=INTEGER},
      totalhoursYear = #{totalhoursyear,jdbcType=DECIMAL},
      frequency = #{frequency,jdbcType=INTEGER},
      totalHours = #{totalhours,jdbcType=DECIMAL}
    where id = #{id,jdbcType=INTEGER}
  </update>

  <select id="getWarningInfoDayByWarningid"  resultType="com.gyee.frame.model.custom.SawVo">


    SELECT    Warning2.chineseText   name,SUM(WarningInfoDay.frequencyDay)   frequencyday, SUM(WarningInfoDay.totalhoursDay)  totalhoursday,
    WarningInfoDay.warningId,equipmentmodel.name  model
    FROM WarningInfoDay LEFT JOIN Warning2 ON WarningInfoDay.warningId = Warning2.id INNER JOIN equipmentmodel ON
    WarningInfoDay.modelid = equipmentmodel.id
    AND WarningInfoDay.modelId = equipmentmodel.id  WHERE (

    WarningInfoDay.recordDate>= to_date('${beginDate}','YYYY-MM-DD HH24:MI:SS') and WarningInfoDay.recordDate &lt; to_date('${endDate}','YYYY-MM-DD HH24:MI:SS')
    )
    GROUP BY Warning2.chineseText, WarningInfoDay.warningId, equipmentmodel.name  order by  ${order}
  </select>

  <select id="getWarningInfoDayByWarningClassify"  resultType="com.gyee.frame.model.custom.SawVo">

    SELECT    SUM(WarningInfoDay.frequencyDay) AS frequencyday, SUM(WarningInfoDay.totalhoursDay) AS totalhoursday, WarningClassify.name
    FROM (SELECT  * FROM WarningInfoDay WHERE
       WarningInfoDay.recordDate>= to_date('${beginDate}','YYYY-MM-DD HH24:MI:SS') and WarningInfoDay.recordDate &lt; to_date('${endDate}','YYYY-MM-DD HH24:MI:SS'))
    WarningInfoDay LEFT JOIN Warning2 ON WarningInfoDay.warningId = Warning2.id LEFT JOIN WarningClassify ON Warning2.warningClassifyId = WarningClassify.id
    GROUP BY WarningClassify.name  order by  ${order}

  </select>

  <select id="getWarningInfoDayByManufacturer"  resultType="com.gyee.frame.model.custom.SawVo">
    SELECT    WarningInfoDay.manufacturerId, SUM(WarningInfoDay.frequencyDay) AS frequencyday, SUM(WarningInfoDay.totalhoursDay) AS totalhoursday, Manufacturer.name
     FROM  WarningInfoDay INNER JOIN Manufacturer ON WarningInfoDay.manufacturerId = Manufacturer.id WHERE
    WarningInfoDay.recordDate>= to_date('${beginDate}','YYYY-MM-DD HH24:MI:SS') and WarningInfoDay.recordDate &lt; to_date('${endDate}','YYYY-MM-DD HH24:MI:SS')
    GROUP BY WarningInfoDay.manufacturerId, Manufacturer.name  order by  ${order}


  </select>
</mapper>