yangys
2024-04-02 1a77b1a7c072b136925d6d73c4d8f017ca016e3a
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
<?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.dmpLog.mapper.DmpLogSignalMapper">
    <!--新增-->
    <insert id="save" parameterType="com.qianwen.smartman.modules.dmpLog.entity.SignalLog">
        insert into iot_data.dmp_log_signal_${MachineCode}_${collectMonth}
            USING iot_data.super_dmp_log_signal TAGS (${MachineCode},${collectMonth})
        (ts, trace_id, type, machine_name, affected_variable, variable_value,
         status)
        values (#{TimeStamp}, #{TraceId}, #{type}, #{MachineName}, #{AffectedVariable},
            #{VariableValue}, #{status})
    </insert>
    <!--创建子表-->
    <update id="createTable">
        create table if not exists iot_data.dmp_log_signal_${machineCode}_${collectMonth} using iot_data.super_dmp_log_signal TAGS
        (
            ${machineCode},${collectMonth}
        )
 
    </update>
 
    <select id="pageDmpLog" resultType="com.qianwen.smartman.modules.dmpLog.vo.DmpLogVo">
        select * from iot_data.super_dmp_log_signal
        <where>
            <if test="param.machineCode != null and param.machineCode != ''">
                AND machine_code = #{param.machineCode}
            </if>
            <if test="param.affectedVariable != null and param.affectedVariable != ''">
                AND affected_variable = #{param.affectedVariable}
            </if>
            <if test="param.variableValue != null and param.variableValue != ''">
                AND variable_value = #{param.variableValue}
            </if>
            <if test="param.startTime != null and param.endTime != ''">
                AND ts BETWEEN #{param.startTime} AND #{param.endTime}
            </if>
        </where>
        order by ts desc
        limit #{start}, #{end}
    </select>
 
    <select id="countDmpLog" resultType="java.lang.Integer">
        select count(*)
        from iot_data.super_dmp_log_signal
        <where>
            <if test="param.machineCode != null and param.machineCode != ''">
                AND machine_code = #{param.machineCode}
            </if>
            <if test="param.affectedVariable != null and param.affectedVariable != ''">
                AND affected_variable = #{param.affectedVariable}
            </if>
            <if test="param.variableValue != null and param.variableValue != ''">
                AND variable_value = #{param.variableValue}
            </if>
            <if test="param.startTime != null and param.endTime != ''">
                AND ts BETWEEN #{param.startTime} AND #{param.endTime}
            </if>
        </where>
    </select>
 
    <select id="getTableNamesByMonth" parameterType="int" resultType="string">
        select tbname
        from super_dmp_log_signal
        where collect_month &lt;= #{rangeParam}
        union all
        select tbname
        from super_dmp_log_signal_flow
        where collect_month &lt;= #{rangeParam}
        union all
        select tbname
        from super_dmp_log_method_time
        where collect_month &lt;= #{rangeParam}
    </select>
</mapper>