yangys
2024-04-04 2cf2921440e7473ae50796c2cb688f609b3a7995
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
<?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.tdengine.mapper.WorkstationAggregatePulseMapper">
 
 
    <delete id="deleteSuperTable">
        drop table if exists iot_data.pulse_data_${workstationId}_${usageCode}
    </delete>
 
    <delete id="deleteTable">
        drop table if exists iot_data.aggregate_pulse_data_${workstationId}_${usageCode}
    </delete>
 
 
 
    <select id="getShiftOutput"
            resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput">
        select ts,
        pre_ts as preTs,
        output,
        cur_output as curOutput,
        pre_output as preOutput,
        calendar_code as calendarCode,
        factory_year as factoryYear,
        factory_month as factoryMonth,
        factory_week as factoryWeek,
        factory_date as factoryDate,
        shift_index as shiftIndex,
        shift_time_type as shiftTimeType,
        program,
        product_code as productCode,
        product_name as productName,
        workstation_id as workstationId
        from iot_data.super_aggregate_pulse_data
        where output <![CDATA[>=]]> 0
        and factory_date = #{factoryDate}
        and shift_index = #{shiftIndex}
        and usage_code = #{usageCode}
        <if test="workstationIds != null and workstationIds.size() > 0">
            AND workstation_id IN
            <foreach collection="workstationIds" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY ts asc
    </select>
 
 
    <select id="getOutputDataByWorkstationAndFactoryDate" resultType="com.qianwen.smartman.modules.mdc.entity.SuperAggregateOutput">
        select ts,
        pre_ts as preTs,
        output,
        cur_output as curOutput,
        pre_output as preOutput,
        calendar_code as calendarCode,
        factory_year as factoryYear,
        factory_month as factoryMonth,
        factory_week as factoryWeek,
        factory_date as factoryDate,
        shift_index as shiftIndex,
        shift_time_type as shiftTimeType,
        program,
        product_code as productCode,
        product_name as productName,
        workstation_id as workstationId
        from iot_data.super_aggregate_pulse_data
        where output <![CDATA[>=]]> 0
        and ts <![CDATA[>=]]> #{startDate} and ts <![CDATA[<]]> #{endDate}
        and usage_code = #{usageCode}
        <if test="workstationId != null and workstationId !=''">
            AND workstation_id =#{workstationId}
        </if>
        ORDER BY ts asc
    </select>
 
</mapper>