yangys
2025-11-18 8e944cfabb253fc2556588e308e282586043f7b0
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
<?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.qianwen.smartman.modules.mdc.mapper.SuperNewCollectMapper">
 
    <insert id="insertData">
        insert into
        <foreach collection="collects" item="collect" index="index" close=";">
            iot_data.new_process_param_${collect.workstationId}_${collect.item}
            using iot_data.super_new_collect_data
            TAGS(#{collect.workstationId}, #{collect.n})
            values (#{collect.ts}, #{collect.v})
        </foreach>
    </insert>
 
    <update id="createSuperTable">
        CREATE TABLE IF NOT EXISTS super_new_collect_data
        (
            ts timestamp,
            v  NCHAR(256)
        ) TAGS (workstation_id BIGINT, n  NCHAR(64));
    </update>
 
    <select id="queryProcessParameter" resultType="com.qianwen.smartman.modules.mdc.dto.ProcessParameterVO">
        select ts as time,
        ts as realTime,
        n as collectItem,
        v as value_collect
        from iot_data.super_new_collect_data
        where
        n in
        <foreach collection="collectItems" item="ids" index="index" open="(" close=")" separator=",">
            #{ids}
        </foreach>
        and ts &gt;= #{startTime}
        and ts &lt;= #{endTime}
        and workstation_id = #{workstationId}
        order by ts
    </select>
 
    <select id="countProcessParameter" resultType="java.lang.Long">
        select count(*)
        from iot_data.super_new_collect_data
        where n = #{item}
          and ts &gt;= #{startTime}
          and ts &lt;= #{endTime}
          and workstation_id = #{workstationId}
    </select>
 
    <select id="pageProcessParameter" resultType="com.qianwen.smartman.modules.mdc.dto.ProcessParameterVO">
        select ts as time,
               ts as realTime,
               n  as collectItem,
               v  as value_collect
        from iot_data.super_new_collect_data
        where n = #{item}
          and ts &gt;= #{startTime}
          and ts &lt;= #{endTime}
          and workstation_id = #{workstationId}
        order by ts
        limit #{current}, #{size}
    </select>
 
    <select id="queryProcessParameterByTime" resultType="com.qianwen.smartman.modules.mdc.dto.ProcessParameterVO">
        select ts as time,
        ts as realTime,
        n as collectItem,
        v as value_collect
        from iot_data.super_new_collect_data
        where
        n in
        <foreach collection="collectItems" item="ids" index="index" open="(" close=")" separator=",">
            #{ids}
        </foreach>
        and (ts &gt;= #{startTime}
        and ts &lt;= #{endTime})
        and workstation_id = #{workstationId}
        order by ts
    </select>
</mapper>