Lius
2024-11-07 81eae83295642387de38a97fdc5a35f485307587
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
<?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 &gt;= #{startDate}
            AND CollectTime &lt; #{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 &gt;= #{startDate}
            AND CollectTime &lt; #{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>