You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
112 lines
5.2 KiB
XML
112 lines
5.2 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.haiwei.manage.mapper.ApiMapper">
|
|
|
|
|
|
<select id="queryPram" resultType="com.haiwei.manage.domain.ParamVo">
|
|
SELECT order_by,
|
|
ee.point_name as name,
|
|
location_x,
|
|
location_y,
|
|
info.PointName as pointname,
|
|
ed.Data as data
|
|
FROM EPointData ed
|
|
right join (
|
|
SELECT PID, MAX(CreateTime) AS LatestTime
|
|
FROM EPointData
|
|
GROUP BY PID
|
|
) ld on ld.PID = ed.PID and ld.LatestTime = CreateTime
|
|
right join EPointsInfo info on ed.PID = info.ID
|
|
left join base_point_info ee on ee.objid = info.EID
|
|
where ee.device_name = #{deviceName} order by order_by
|
|
</select>
|
|
<select id="queryDeviceState" resultType="com.haiwei.manage.domain.DeviceState">
|
|
SELECT CASE
|
|
when DataType = 1 then
|
|
case when (SELECT DataType FROM EEquipmentState WHERE ID = 1) = 0 then '停机' else '运行' end
|
|
else '故障' end AS state, '一体机' as name
|
|
FROM EEquipmentState
|
|
WHERE ID = #{device}
|
|
union
|
|
SELECT CASE
|
|
when DataType = 1 then
|
|
case when (SELECT DataType FROM EEquipmentState WHERE ID = 3) = 0 then '停机' else '运行' end
|
|
else '故障' end AS state, '切刀' as name
|
|
FROM EEquipmentState
|
|
WHERE ID = #{state}
|
|
</select>
|
|
|
|
<select id="queryPramList" resultType="com.haiwei.manage.domain.RecordRaramData">
|
|
select *
|
|
from (SELECT ee.point_name + info.PointName as pointname, ed.Data as data, CONVERT(varchar, ed.CreateTime, 120) time
|
|
FROM EPointData ed
|
|
right join EPointsInfo info on ed.PID = info.ID
|
|
left join base_point_info ee on ee.objid = info.EID
|
|
where info.Status = 1) a PIVOT (max(data) FOR pointname IN ( 一体机A转速, 一体机A电流, 一体机A切刀转速, 一体机A切刀电流, 一体机A机头温度, 一体机A机头压力 )) t
|
|
<where>
|
|
<if test="beginTime !=null and endTime !=null">
|
|
time between #{beginTime} and #{endTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
<select id="queryPramList_B" resultType="com.haiwei.manage.domain.RecordRaramDataB">
|
|
select *
|
|
from (SELECT ee.point_name + info.PointName as pointname, ed.Data as data, CONVERT(varchar, ed.CreateTime, 120) time
|
|
FROM EPointData ed
|
|
right join EPointsInfo info on ed.PID = info.ID
|
|
left join base_point_info ee on ee.objid = info.EID
|
|
where info.Status = 1) a PIVOT (max(data) FOR pointname IN ( 一体机B转速, 一体机B电流, 一体机B切刀转速, 一体机B切刀电流, 一体机B机头温度, 一体机B机头压力 )) t
|
|
<where>
|
|
<if test="beginTime !=null and endTime !=null">
|
|
time between #{beginTime} and #{endTime}
|
|
</if>
|
|
</where>
|
|
</select>
|
|
|
|
<select id="queryParamData" resultType="com.haiwei.manage.domain.RecordRaramData">
|
|
WITH CTE AS (
|
|
SELECT ROW_NUMBER() OVER (ORDER BY time) AS row_num,*
|
|
from (SELECT ee.point_name + info.PointName as pointname, ed.Data as data, CONVERT(varchar, ed.CreateTime, 120) time
|
|
FROM EPointData ed
|
|
right join EPointsInfo info on ed.PID = info.ID
|
|
left join base_point_info ee on ee.objid = info.EID
|
|
where info.Status = 1) a PIVOT (max(data) FOR pointname IN ( 一体机A转速, 一体机A电流, 一体机A切刀转速, 一体机A切刀电流, 一体机A机头温度, 一体机A机头压力 )) t
|
|
<where>
|
|
<if test="beginTime !=null and endTime !=null">
|
|
time between #{beginTime} and #{endTime}
|
|
</if>
|
|
</where>
|
|
)
|
|
SELECT *
|
|
FROM CTE
|
|
WHERE row_num % #{timeInterval} = 0
|
|
ORDER BY row_num;
|
|
</select>
|
|
|
|
<select id="queryParamData_B" resultType="com.haiwei.manage.domain.RecordRaramDataB">
|
|
WITH CTE AS (
|
|
SELECT ROW_NUMBER() OVER (ORDER BY time) AS row_num,*
|
|
from (SELECT ee.point_name + info.PointName as pointname, ed.Data as data, CONVERT(varchar, ed.CreateTime, 120) time
|
|
FROM EPointData ed
|
|
right join EPointsInfo info on ed.PID = info.ID
|
|
left join base_point_info ee on ee.objid = info.EID
|
|
where info.Status = 1) a PIVOT (max(data) FOR pointname IN ( 一体机B转速, 一体机B电流, 一体机B切刀转速, 一体机B切刀电流, 一体机B机头温度, 一体机B机头压力 )) t
|
|
<where>
|
|
<if test="beginTime !=null and endTime !=null">
|
|
time between #{beginTime} and #{endTime}
|
|
</if>
|
|
</where>
|
|
)
|
|
SELECT *
|
|
FROM CTE
|
|
WHERE row_num % #{timeInterval} = 0
|
|
ORDER BY row_num;
|
|
</select>
|
|
|
|
|
|
|
|
|
|
</mapper>
|