houzhongjian
2024-07-23 a6de490948278991e47952e90671ddba4555e9a2
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?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.iailab.module.data.point.dao.DaPointDao">
 
    <select id="getPageList" resultType="com.iailab.module.data.point.dto.DaPointDTO">
      select
      t1.id,
      t1.point_no,
      t1.point_name,
      t1.point_type ,
      t1.data_type,
      t1.value_type,
      t1.unit,
      t1.unittransfactor,
      t1.default_value,
      t1.max_value,
      t1.min_value,
      t1.minfreqid,
      t1.remark,
      t1.is_enable,
      t1.creator,
      t1.create_time,
      t1.updater,
      t1.update_time,
      t2.source_type,
      t3.source_name,
      t2.tag_no
      from t_da_point t1
      left join t_da_measure_point t2 on t2.point_id = t1.id
      left join (
        select id source_id,server_name source_name
        from t_channel_opcua_device
        union
        select id source_id, name source_name
        from t_channel_modbus_device
        union
        select id source_id, code source_name
        from t_http_api
        union
        select id source_id, instance_name source_name
        from t_channel_kio_device
      ) t3 on t3.source_id = t2.source_id
        <where>
            <if test="params.pointNo != null and params.pointNo != ''">
                and t1.point_no like concat('%', #{params.pointNo}, '%')
            </if>
            <if test="params.pointName != null and params.pointName != ''">
                and t1.point_name like concat('%', #{params.pointName}, '%')
            </if>
            <if test="params.pointType != null and params.pointType != ''">
                and t1.point_type = #{params.pointType}
            </if>
            <if test="params.dataType != null and params.dataType != ''">
                and t1.data_type = #{params.dataType}
            </if>
            <if test="params.sourceName != null and params.sourceName != ''">
                and t3.source_name like concat('%', #{params.sourceName}, '%')
            </if>
            <if test="params.tagNo != null and params.tagNo != ''">
                and t2.tag_no like concat('%', #{params.tagNo}, '%')
            </if>
            <if test="params.isEnable != null ">
                and t1.is_enable = #{params.isEnable}
            </if>
        </where>
        order by t1.point_no desc
    </select>
 
    <select id="getConstantPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO">
        SELECT
        t1.point_no,
        t1.point_name,
        t1.default_value,
        t1.point_type,
        t1.store_type,
        t1.data_type
        FROM t_da_point t1
        <where>
            t1.point_type =  #{pointType}
            <if test="isEnable != null">
                AND t1.is_enable = #{isEnable}
            </if>
            <if test="minfreqid != null and minfreqid != ''">
                AND t1.minfreqid = #{minfreqid}
            </if>
            <if test="pointNos != null">
                AND t1.point_no in
                <foreach collection="pointNos" item="item" index="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
 
    <select id="getMeasurePoint" resultType="com.iailab.module.data.point.dto.DaPointDTO">
        SELECT
        t1.point_no,
        t1.point_name,
        t1.point_type,
        t1.data_type,
        t1.store_type,
        t1.default_value,
        t1.unittransfactor,
        t1.max_value,
        t1.min_value,
        t2.source_type,
        t2.source_id,
        t3.source_name,
        t2.tag_no
        FROM t_da_point t1
        LEFT JOIN t_da_measure_point t2 ON t2.point_id = t1.id
        left join (
            select id source_id,server_name source_name
            from t_channel_opcua_device
            union
            select id source_id, name source_name
            from t_channel_modbus_device
            union
            select id source_id, instance_name source_name
            from t_channel_kio_device
            union
            select id source_id, code source_name
            from t_http_api
        ) t3 on t3.source_id = t2.source_id
        <where>
            t1.point_type =  #{pointType}
            <if test="isEnable != null">
                AND t1.is_enable = #{isEnable}
            </if>
            <if test="minfreqid != null and minfreqid != ''">
                AND t1.minfreqid = #{minfreqid}
            </if>
            <if test="pointNo != null and pointNo != ''">
                AND t1.point_no = #{pointNo}
            </if>
            <if test="pointNos != null">
                AND t1.point_no in
                <foreach collection="pointNos" item="item" index="item" open="(" close=")" separator=",">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
    <select id="getMathPoint" resultType="com.iailab.module.data.point.dto.DaPointDTO">
        SELECT
        t1.point_no,
        t1.point_name,
        t1.default_value,
        t1.point_type,
        t1.data_type,
        t1.store_type,
        t2.expression
        FROM t_da_point t1
        LEFT JOIN t_da_math_point t2 ON t2.point_id = t1.id
        <where>
            t1.point_type =  #{pointType}
            <if test="isEnable != null">
                AND t1.is_enable = #{isEnable}
            </if>
            <if test="minfreqid != null and minfreqid != ''">
                AND t1.minfreqid = #{minfreqid}
            </if>
        </where>
    </select>
 
</mapper>