<?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="org.jeecg.modules.mdc.mapper.CurrentXYZHistoryMapper">
|
|
<!--获取数据的最小时间-->
|
<select id="getMinDate" resultType="java.util.Date">
|
select MIN(CollectTime) CollectTime from CurrentXYZ_History where equipmentID = #{ equipmentId }
|
</select>
|
|
<!--获取某台设备某个坐标的最大电流-->
|
<select id="getMaxElectric" resultType="org.jeecg.modules.mdc.dto.CurrentElectricHistoryDto">
|
<if test="axisType != null and axisType != '' and axisType == 1">
|
SELECT
|
n.XCurrent currentValue,
|
m.EquipmentID,
|
n.CollectTime
|
FROM
|
(
|
SELECT
|
MAX( ABS( CONVERT ( DECIMAL ( 18, 3 ), XCurrent ) ) ) currentValue,
|
MIN ( EquipmentID ) EquipmentID
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 2">
|
SELECT
|
n.YCurrent currentValue,
|
m.EquipmentID,
|
n.CollectTime
|
FROM
|
(
|
SELECT
|
MAX( ABS( CONVERT ( DECIMAL ( 18, 3 ), YCurrent ) ) ) currentValue,
|
MIN ( EquipmentID ) EquipmentID
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 3">
|
SELECT
|
n.ZCurrent currentValue,
|
m.EquipmentID,
|
n.C
|
ollectTime
|
FROM
|
(
|
SELECT
|
MAX( ABS( CONVERT ( DECIMAL ( 18, 3 ), ZCurrent ) ) ) currentValue,
|
MIN ( EquipmentID ) EquipmentID
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 4">
|
SELECT
|
n.ACurrent currentValue,
|
m.EquipmentID,
|
n.CollectTime
|
FROM
|
(
|
SELECT
|
MAX( ABS( CONVERT ( DECIMAL ( 18, 3 ), ACurrent ) ) ) currentValue,
|
MIN ( EquipmentID ) EquipmentID
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 5">
|
SELECT
|
n.BCurrent currentValue,
|
m.EquipmentID,
|
n.CollectTime
|
FROM
|
(
|
SELECT
|
MAX( ABS( CONVERT ( DECIMAL ( 18, 3 ), BCurrent ) ) ) currentValue,
|
MIN ( EquipmentID ) EquipmentID
|
</if>
|
FROM
|
CurrentXYZ_History
|
WHERE
|
CollectTime >= #{startDate}
|
AND CollectTime < #{endDate}
|
AND EquipmentID = #{equipmentId}
|
) m
|
LEFT JOIN (
|
SELECT
|
EquipmentID,
|
CollectTime,
|
ABS( CONVERT ( DECIMAL ( 18, 3 ), XCurrent ) ) xValue,
|
XCurrent,
|
ABS( CONVERT ( DECIMAL ( 18, 3 ), YCurrent ) ) yValue,
|
YCurrent,
|
ABS( CONVERT ( DECIMAL ( 18, 3 ), ZCurrent ) ) zValue,
|
ZCurrent,
|
ABS( CONVERT ( DECIMAL ( 18, 3 ), ACurrent ) ) aValue,
|
ACurrent,
|
ABS( CONVERT ( DECIMAL ( 18, 3 ), BCurrent ) ) bValue,
|
BCurrent
|
FROM
|
CurrentXYZ_History
|
WHERE
|
CollectTime >= #{startDate}
|
AND CollectTime < #{endDate}
|
AND EquipmentID = #{equipmentId}
|
) n ON m.EquipmentID= n.EquipmentID
|
<if test="axisType != null and axisType != '' and axisType == 1">
|
AND m.currentValue= n.xValue
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 2">
|
AND m.currentValue= n.yValue
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 3">
|
AND m.currentValue= n.zValue
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 4">
|
AND m.currentValue= n.aValue
|
</if>
|
<if test="axisType != null and axisType != '' and axisType == 5">
|
AND m.currentValue= n.bValue
|
</if>
|
</select>
|
</mapper>
|