From 788489c7e95352a11cf5ec40a7a9c7277e5cc0f3 Mon Sep 17 00:00:00 2001
From: fengxiang <110431245@qq.com>
Date: Fri, 02 Feb 2018 09:19:53 +0800
Subject: [PATCH] 安全跨域设置
---
src/main/resources/mapper/HistoryMapper.xml | 405 ++++-----------------------------------------------------
1 files changed, 33 insertions(+), 372 deletions(-)
diff --git a/src/main/resources/mapper/HistoryMapper.xml b/src/main/resources/mapper/HistoryMapper.xml
index 5f805da..2ca98f3 100644
--- a/src/main/resources/mapper/HistoryMapper.xml
+++ b/src/main/resources/mapper/HistoryMapper.xml
@@ -1,376 +1,37 @@
<?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.moral.mapper.HistoryMapper">
- <resultMap id="BaseResultMap" type="com.moral.entity.History">
- <result column="mac" jdbcType="VARCHAR" property="mac" />
- <result column="value" jdbcType="OTHER" property="value" />
- <result column="time" jdbcType="TIMESTAMP" property="time" />
- <result column="version" jdbcType="INTEGER" property="version" />
- </resultMap>
- <sql id="Example_Where_Clause">
- <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">
- <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">
- mac, value, time, version
- </sql>
- <select id="selectByExample" parameterType="com.moral.entity.HistoryExample" resultMap="BaseResultMap">
- select
- <if test="distinct">
- distinct
- </if>
- <include refid="Base_Column_List" />
- from history
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- <if test="orderByClause != null">
- order by ${orderByClause}
- </if>
- </select>
- <delete id="deleteByExample" parameterType="com.moral.entity.HistoryExample">
- delete from history
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </delete>
- <insert id="insert" parameterType="com.moral.entity.History">
- insert into history (mac, value, time,
- version)
- values (#{mac,jdbcType=VARCHAR}, #{value,jdbcType=OTHER}, #{time,jdbcType=TIMESTAMP},
- #{version,jdbcType=INTEGER})
- </insert>
- <insert id="insertSelective" parameterType="com.moral.entity.History">
- insert into history
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="mac != null">
- mac,
- </if>
- <if test="value != null">
- value,
- </if>
- <if test="time != null">
- time,
- </if>
- <if test="version != null">
- version,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="mac != null">
- #{mac,jdbcType=VARCHAR},
- </if>
- <if test="value != null">
- #{value,jdbcType=OTHER},
- </if>
- <if test="time != null">
- #{time,jdbcType=TIMESTAMP},
- </if>
- <if test="version != null">
- #{version,jdbcType=INTEGER},
- </if>
- </trim>
- </insert>
- <select id="countByExample" parameterType="com.moral.entity.HistoryExample" resultType="java.lang.Integer">
- select count(*) from history
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </select>
- <update id="updateByExampleSelective" parameterType="map">
- update history
- <set>
- <if test="record.mac != null">
- mac = #{record.mac,jdbcType=VARCHAR},
- </if>
- <if test="record.value != null">
- value = #{record.value,jdbcType=OTHER},
- </if>
- <if test="record.time != null">
- time = #{record.time,jdbcType=TIMESTAMP},
- </if>
- <if test="record.version != null">
- version = #{record.version,jdbcType=INTEGER},
- </if>
- </set>
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByExample" parameterType="map">
- update history
- set mac = #{record.mac,jdbcType=VARCHAR},
- value = #{record.value,jdbcType=OTHER},
- time = #{record.time,jdbcType=TIMESTAMP},
- version = #{record.version,jdbcType=INTEGER}
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <resultMap id="BaseResultMap" type="com.moral.entity.History">
- <result column="device_mac" jdbcType="VARCHAR" property="deviceMac" />
- <result column="value" jdbcType="OTHER" property="value" />
- <result column="time" jdbcType="TIMESTAMP" property="time" />
- <result column="version" jdbcType="VARCHAR" property="version" />
- </resultMap>
- <sql id="Example_Where_Clause">
- <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">
- <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">
- device_mac, value, time, version
- </sql>
- <select id="selectByExample" parameterType="com.moral.entity.HistoryExample" resultMap="BaseResultMap">
- select
- <if test="distinct">
- distinct
- </if>
- <include refid="Base_Column_List" />
- from history
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- <if test="orderByClause != null">
- order by ${orderByClause}
- </if>
- </select>
- <delete id="deleteByExample" parameterType="com.moral.entity.HistoryExample">
- delete from history
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </delete>
- <insert id="insert" parameterType="com.moral.entity.History">
- insert into history (device_mac, value, time,
- version)
- values (#{deviceMac,jdbcType=VARCHAR}, #{value,jdbcType=OTHER}, #{time,jdbcType=TIMESTAMP},
- #{version,jdbcType=VARCHAR})
- </insert>
- <insert id="insertSelective" parameterType="com.moral.entity.History">
- insert into history
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="deviceMac != null">
- device_mac,
- </if>
- <if test="value != null">
- value,
- </if>
- <if test="time != null">
- time,
- </if>
- <if test="version != null">
- version,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="deviceMac != null">
- #{deviceMac,jdbcType=VARCHAR},
- </if>
- <if test="value != null">
- #{value,jdbcType=OTHER},
- </if>
- <if test="time != null">
- #{time,jdbcType=TIMESTAMP},
- </if>
- <if test="version != null">
- #{version,jdbcType=VARCHAR},
- </if>
- </trim>
- </insert>
- <select id="countByExample" parameterType="com.moral.entity.HistoryExample" resultType="java.lang.Integer">
- select count(*) from history
- <if test="_parameter != null">
- <include refid="Example_Where_Clause" />
- </if>
- </select>
- <update id="updateByExampleSelective" parameterType="map">
- update history
- <set>
- <if test="record.deviceMac != null">
- device_mac = #{record.deviceMac,jdbcType=VARCHAR},
- </if>
- <if test="record.value != null">
- value = #{record.value,jdbcType=OTHER},
- </if>
- <if test="record.time != null">
- time = #{record.time,jdbcType=TIMESTAMP},
- </if>
- <if test="record.version != null">
- version = #{record.version,jdbcType=VARCHAR},
- </if>
- </set>
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
- <update id="updateByExample" parameterType="map">
- update history
- set device_mac = #{record.deviceMac,jdbcType=VARCHAR},
- value = #{record.value,jdbcType=OTHER},
- time = #{record.time,jdbcType=TIMESTAMP},
- version = #{record.version,jdbcType=VARCHAR}
- <if test="_parameter != null">
- <include refid="Update_By_Example_Where_Clause" />
- </if>
- </update>
-
- <select id="getDayAQIBySensor" resultType="map">
- SELECT
- AVG(value -> '$.e1') e1,
- AVG(value -> '$.e2') e2,
- AVG(value -> '$.e10') e10,
- AVG(value -> '$.e11') e11,
- AVG(value -> '$.e15') e15,
- AVG(value -> '$.e16') e16
- FROM
- history
- WHERE
- device_mac = #{mac}
- AND time > #{start}
- AND time < #{end}
- </select>
-
- <select id="getAverageByAll" resultType="map">
- SELECT
- <if test="macKey != null and macKey != 'all'">
- e.name,
- </if>
- <if test="macKey == 'all'">
- h.mac_key,
- </if>
- AVG(h.mac_value) avg
- FROM
- history h,
- monitorpoint m,
- equipment e
- WHERE
- m.areacode = #{areaCode}
- AND m.id = epoint
- AND e.mac = h.mac
- AND h.time > #{start}
- AND h.time < #{end}
- <if test="orgIds != null and orgIds.size > 0">
- <!-- JOIN org_equ oe ON e.id = oe.equid -->
- AND e.owner_id IN
- <foreach close=")" collection="orgIds" item="listItem" open="(" separator=",">
- #{listItem}
- </foreach>
- </if>
- <if test="macKey != null and macKey != 'all'">
- AND h.mac_key = #{macKey}
- GROUP BY e.id
- ORDER BY avg
- </if>
- <if test="macKey == 'all'">
- GROUP BY h.mac_key
- </if>
- </select>
+ <select id="getAreaAllDataByAccount" resultType="java.util.LinkedHashMap">
+ SELECT
+ <if test="macKey == 'all'">
+ ${queryColumns}
+ </if>
+ <if test="macKey != 'all'">
+ d.`name`,
+ AVG( h.`value` -> ${macKey}) avg
+ </if>
+ FROM
+ history h,
+ device d,
+ monitor_point mp
+ WHERE
+ mp.area_code = #{areaCode}
+ AND h.time >= #{start}
+ AND h.time < #{end}
+ <if test="orgIds != null and orgIds.size > 0">
+ AND mp.organization_id IN
+ <foreach collection="orgIds" open="(" separator="," close=")" item="listItem">
+ #{listItem}
+ </foreach>
+ </if>
+ AND h.mac = d.mac
+ AND d.monitor_point_id = mp.id
+ <if test="macKey != 'all'">
+ GROUP BY d.id
+ ORDER BY avg desc
+ </if>
+ </select>
+
+
+
</mapper>
\ No newline at end of file
--
Gitblit v1.8.0