qa-prevention-gwj/src/main/resources/mybatis/datasource/anemometer/AnemometerLocalMapper.xml

116 lines
2.3 KiB
XML

<?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.zcloud.mapper.datasource.anemometer.AnemometerLocalMapper">
<!--模型表名 -->
<sql id="tableName">
bus_anemometer_local
</sql>
<!-- 字段 -->
<sql id="Field">
FLID,
FNAME,
FVALUE,
FTIME
</sql>
<!-- 字段值 -->
<sql id="FieldValue">
#{FLID},
#{FNAME},
#{FVALUE},
#{FTIME}
</sql>
<!-- 批量插入字段值 -->
<sql id="FieldValueBatch">
#{item.FLID},
#{item.FNAME},
#{item.FVALUE},
#{item.FTIME}
</sql>
<!--新增 -->
<insert id="add" parameterType="pd">
insert into
<include refid="tableName"></include>
(
<include refid="Field"></include>
) values (
<include refid="FieldValue"></include>
)
</insert>
<!-- 批量插入 -->
<insert id="BatchinsertInfo" parameterType="pd">
insert into <include refid="tableName"></include>
(
<include refid="Field"></include>
)
values
<foreach item="item" index="index" collection="list" separator=",">
(
<include refid="FieldValueBatch"></include>
)
</foreach>
</insert>
<!--编辑 -->
<update id="edit" parameterType="pd">
update
<include refid="tableName"></include>
set
FNAME =#{FNAME},
FVALUE =#{FVALUE} ,
FTIME=#{FTIME}
where
FLID=#{FLID}
</update>
<!--查询所有 -->
<select id="listAll" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include>
</select>
<select id="detailListAll" parameterType="pd" resultType="pd">
SELECT
f.FID,
f.FNAME,
CONCAT_WS( '--', f.LATITUDE, f.LONGITUDE ) LONGTITUDEANDLATITUDE,
f.LATITUDE,
f.LONGITUDE,
f.FNAME AS EQUIPMENTNAME,
al.FVALUE,
al.FTIME,
al.FVALUE AS WINDSPEED,
al.FTIME AS OPERATTIME
FROM
bus_anemometer_machine f
LEFT JOIN ( SELECT MAX( FTIME ) AS FTIME,FNAME FROM bus_anemometer_local GROUP BY FNAME ) ba ON f.FNAME = ba.FNAME
LEFT JOIN bus_anemometer_local al ON f.FNAME = al.FNAME and al.FTIME = ba.FTIME
ORDER BY f.FID DESC
</select>
<!--查询所有 -->
<select id="findByName" parameterType="pd" resultType="pd">
select
<include refid="Field"></include>
from
<include refid="tableName"></include> f
where
f.FNAME = #{FNAME}
</select>
</mapper>