<?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.yssh.mapper.SuYuanMapper">
|
<resultMap id="SuYuan2dResult" type="com.yssh.entity.SuYuan2d">
|
<result property="id" column="id" />
|
<result property="x" column="x" />
|
<result property="y" column="y" />
|
<result property="value" column="c" />
|
</resultMap>
|
|
<resultMap id="SuYuan3dResult" type="com.yssh.entity.SuYuan3d">
|
<result property="id" column="id" />
|
<result property="x" column="x" />
|
<result property="y" column="y" />
|
<result property="height0" column="height0" />
|
<result property="height10" column="height10" />
|
<result property="height20" column="height20" />
|
<result property="height30" column="height30" />
|
<result property="height40" column="height40" />
|
<result property="height50" column="height50" />
|
<result property="height60" column="height60" />
|
<result property="height70" column="height70" />
|
<result property="height80" column="height80" />
|
<result property="height90" column="height90" />
|
</resultMap>
|
|
<resultMap id="DistanceSuYuanResult" type="com.yssh.entity.DistanceSuYuan">
|
<result property="id" column="id" />
|
<result property="x" column="x" />
|
<result property="y" column="y" />
|
<result property="u" column="u" />
|
<result property="v" column="v" />
|
<result property="vocsValue" column="c" />
|
</resultMap>
|
|
<resultMap id="TemporaryResult" type="com.yssh.entity.Temporary">
|
<result property="id" column="id" />
|
<result property="x" column="x" />
|
<result property="y" column="y" />
|
<result property="z" column="z" />
|
<result property="u" column="u" />
|
<result property="v" column="v" />
|
<result property="w" column="w" />
|
<result property="c" column="c" />
|
</resultMap>
|
|
<resultMap id="SuYuanMonitorDataResult" type="com.yssh.entity.SuYuanMonitorData">
|
<result property="id" column="id" />
|
<result property="value" column="c" />
|
<result property="time" column="time" />
|
</resultMap>
|
|
<select id="get2d" resultMap="SuYuan2dResult">
|
SELECT id, x, y, format(c, 2) "c"
|
FROM ${tableName}
|
WHERE id IN
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
ORDER BY z ASC, x ASC, y DESC
|
</select>
|
|
<select id="get3d" resultMap="SuYuan3dResult">
|
SELECT sy.id, sy.x, sy.y, sy.id, sy.x, sy.y, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 0)
|
) AS height0, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 1)
|
) AS height10, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 2)
|
) AS height20, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 3)
|
) AS height30, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 4)
|
) AS height40, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 5)
|
) AS height50, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 6)
|
) AS height60, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 7)
|
) AS height70, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 8)
|
) AS height80, (
|
SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2), 9)
|
) AS height90
|
FROM ${tableName} AS sy
|
WHERE id IN
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
ORDER BY sy.z ASC, sy.x ASC, sy.y DESC
|
</select>
|
|
<select id="getDistanceSuYuan" resultMap="DistanceSuYuanResult">
|
SELECT id, x, y, format(c, 2) "c", u, v
|
FROM ${tableName}
|
WHERE id IN
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
ORDER BY z ASC, x ASC, y DESC
|
</select>
|
|
<select id="getSuYuan500Max" resultMap="DistanceSuYuanResult">
|
select id, x, y, format(c, 2) "c", u, v
|
from ${tableName}
|
where id in
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
order by c desc
|
limit 1;
|
</select>
|
|
<select id="getSuYuan500MaxByFilter" resultMap="DistanceSuYuanResult">
|
select id, x, y, format(c, 2) "c", u, v
|
from ${tableName}
|
where ${filter}
|
order by c desc
|
limit 1;
|
</select>
|
|
<select id="getSuYuanById" resultMap="DistanceSuYuanResult">
|
select id, x, y, format(c, 2) "c", u, v
|
from ${tableName}
|
where id = #{id}
|
</select>
|
|
<select id="getAlarmsAnalyse" resultMap="SuYuan2dResult">
|
SELECT id, x, y, format(c, 2) "c"
|
FROM ${tableName}
|
WHERE id IN
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
AND c >= (SELECT jcbj FROM alert_config LIMIT 1)
|
</select>
|
|
<select id="getWarningAnalyse" resultMap="SuYuan2dResult">
|
SELECT id, x, y, format(c, 2) "c"
|
FROM ${tableName}
|
WHERE id IN
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
and c >= (select jcyj from alert_config limit 1) and c < (select jcbj from alert_config limit 1)
|
</select>
|
|
<select id="getMonitorData" resultMap="SuYuanMonitorDataResult">
|
<foreach collection="tableNames" item="tableName" separator=" UNION ">
|
SELECT id, format(c, 2) "c", SUBSTRING_INDEX(#{tableName}, '_', -1) AS time
|
FROM ${tableName}
|
WHERE id = #{id}
|
</foreach>
|
</select>
|
|
<select id="getMonthValueDataMax" resultType="java.util.Map">
|
<foreach collection="tableNames" item="tableName" separator=" UNION ">
|
SELECT format(c, 2) AS value, SUBSTRING_INDEX(#{tableName}, '_', -1) AS time
|
FROM ${tableName}
|
WHERE id = #{id}
|
</foreach>
|
ORDER BY value DESC
|
LIMIT 1
|
</select>
|
|
<select id="selectSuYuan700ById" resultType="com.yssh.entity.SuYuan700">
|
select * from suyuan_70_70
|
where su_yuan_id = #{id} and create_time = #{time}
|
limit 1;
|
</select>
|
|
<select id="selectSuYuan46ById" resultType="com.yssh.entity.SuYuan700">
|
select * from suyuan_46
|
where su_yuan_id = #{id} and create_time = #{time}
|
limit 1;
|
</select>
|
|
<select id="getTemporary" resultMap="TemporaryResult">
|
SELECT x, y, z, u, v, w, format(c, 2) "c"
|
FROM ${tableName}
|
WHERE id IN
|
<foreach collection="ids" item="item" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
ORDER BY z ASC, x ASC, y DESC
|
</select>
|
|
<insert id="batchInsert">
|
INSERT INTO ${tableName} (
|
id,x,y,z,u,v,w,c
|
)VALUES
|
<foreach collection="datas" item="item" separator=",">
|
(
|
#{item.id},
|
#{item.x},
|
#{item.y},
|
#{item.z},
|
#{item.u},
|
#{item.v},
|
#{item.w},
|
#{item.c}
|
)
|
</foreach>
|
</insert>
|
|
<select id="isTableExists" resultType="java.lang.Integer">
|
select count(*) from information_schema.tables where table_name = #{tableName};
|
</select>
|
|
<select id="selectFastById" resultType="com.yssh.entity.SuYuanFast">
|
select * from yssh.suyuan_fast
|
where su_yuan_id = #{id} and create_time = #{time}
|
order by id;
|
</select>
|
|
<update id="createTable" parameterType="java.lang.String">
|
create table ${tableName} (
|
`id` varchar(10) not null comment '主键',
|
`x` int(3) null default null,
|
`y` int(3) null default null,
|
`z` int(2) null default null,
|
`u` double null default null,
|
`v` double null default null,
|
`w` double null default null,
|
`c` double null default null,
|
primary key (`id`) using btree
|
) engine = innodb character set = utf8 collate = utf8_general_ci row_format = dynamic;
|
</update>
|
|
<update id="update" >
|
UPDATE ${tableName} SET c = #{value} WHERE id = #{id}
|
</update>
|
|
<update id="updateVocsName">
|
update ${table} set vocsName = #{vocsName} where id = #{id};
|
</update>
|
</mapper>
|