90 lines
3.4 KiB
XML
90 lines
3.4 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.ruoyi.project.oil.mapper.ThDeviceReportMapper">
|
||
|
|
||
|
<resultMap id="BaseResultMap" type="com.ruoyi.project.oil.domain.monitor.ThDeviceReport">
|
||
|
<id property="id" column="id" jdbcType="BIGINT"/>
|
||
|
<result property="sn" column="sn" jdbcType="VARCHAR"/>
|
||
|
<result property="reportTime" column="report_time" jdbcType="TIMESTAMP"/>
|
||
|
<result property="reportContent" column="report_content" jdbcType="OTHER"/>
|
||
|
<result property="power" column="power" jdbcType="VARCHAR"/>
|
||
|
<result property="sos" column="sos" jdbcType="VARCHAR"/>
|
||
|
<result property="qb" column="qb" jdbcType="VARCHAR"/>
|
||
|
<result property="wd" column="wd" jdbcType="VARCHAR"/>
|
||
|
<result property="sd" column="sd" jdbcType="VARCHAR"/>
|
||
|
<result property="yl" column="yl" jdbcType="VARCHAR"/>
|
||
|
<result property="latitude" column="latitude" jdbcType="VARCHAR"/>
|
||
|
<result property="longitude" column="longitude" jdbcType="VARCHAR"/>
|
||
|
<result property="cgq" column="cgq" jdbcType="INTEGER"/>
|
||
|
<result property="source" column="source" jdbcType="VARCHAR"/>
|
||
|
<result property="ds" column="ds" jdbcType="VARCHAR"/>
|
||
|
<result property="dbz" column="dbz" jdbcType="VARCHAR"/>
|
||
|
<result property="gbz" column="gbz" jdbcType="VARCHAR"/>
|
||
|
</resultMap>
|
||
|
|
||
|
<sql id="Base_Column_List">
|
||
|
SELECT d.id,
|
||
|
d.sn,
|
||
|
d.report_time,
|
||
|
d.report_content,
|
||
|
d.power,
|
||
|
d.sos,
|
||
|
d.qb,
|
||
|
d.wd,
|
||
|
d.sd,
|
||
|
d.yl,
|
||
|
d.latitude,
|
||
|
d.longitude,
|
||
|
d.cgq,
|
||
|
d.source,
|
||
|
d.ds,
|
||
|
d.dbz,
|
||
|
d.gbz
|
||
|
FROM th_device_report d
|
||
|
</sql>
|
||
|
<select id="selectDeviceReport" parameterType="com.ruoyi.project.oil.domain.monitor.ThDeviceReport" resultMap="BaseResultMap">
|
||
|
<include refid="Base_Column_List"/>
|
||
|
WHERE 1=1
|
||
|
<if test="sn != null and sn != ''">
|
||
|
AND d.sn = #{sn}
|
||
|
</if>
|
||
|
<if test="params.beginTime != null and params.beginTime != ''">
|
||
|
AND d.report_time >= TO_DATE(#{params.beginTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||
|
</if>
|
||
|
<if test="params.endTime != null and params.endTime != ''">
|
||
|
AND d.report_time <= TO_DATE(#{params.endTime}, 'YYYY-MM-DD HH24:MI:SS')
|
||
|
</if>
|
||
|
ORDER BY d.report_time ASC
|
||
|
</select>
|
||
|
<select id="selectAvgDsByMonth" parameterType="map" resultType="map">
|
||
|
SELECT
|
||
|
TO_CHAR(d.report_time, 'YYYY-MM') AS month,
|
||
|
AVG(TO_NUMBER(d.ds)) AS avg_ds
|
||
|
FROM
|
||
|
th_device_report d
|
||
|
WHERE
|
||
|
d.sn IN (
|
||
|
SELECT
|
||
|
d.sn
|
||
|
FROM
|
||
|
th_device d
|
||
|
LEFT JOIN sys_dept p ON d.dept_id = p.dept_id
|
||
|
WHERE
|
||
|
d.dept_id IN (
|
||
|
SELECT dept_id
|
||
|
FROM sys_dept
|
||
|
START WITH dept_id = #{deptId}
|
||
|
CONNECT BY PRIOR dept_id = parent_id
|
||
|
)
|
||
|
)
|
||
|
AND d.report_time >= TO_DATE(#{startMonth}, 'YYYY-MM')
|
||
|
AND d.report_time <= ADD_MONTHS(TO_DATE(#{endMonth}, 'YYYY-MM'), 1)
|
||
|
GROUP BY
|
||
|
TO_CHAR(d.report_time, 'YYYY-MM')
|
||
|
ORDER BY
|
||
|
month
|
||
|
</select>
|
||
|
</mapper>
|