hyingbo
7 天以前 cc0e9036de6e922e8fe254fef01d8de9996024b7
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
<?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.MdcProcessCountMapper">
 
    <select id="getLastData" resultType="org.jeecg.modules.mdc.entity.MdcProcessCount">
        SELECT TOP 1 * FROM mdc_process_count WHERE equipment_id = #{equipmentId} ORDER BY the_date DESC
    </select>
 
    <!--分页查询-->
    <select id="pageList" resultType="org.jeecg.modules.mdc.dto.MdcProcessCountDto">
        SELECT
            t1.equipment_id equipmentId,
            MAX(t1.equipment_name) equipmentName,
            MAX(t2.drive_type) driveType,
            t1.sequence_number sequenceNumber,
            COUNT(*) processCount,
            SUM(t1.duration) duration
        FROM
            mdc_process_count t1
            LEFT JOIN mdc_equipment t2 ON t1.equipment_id = t2.equipment_id
        <where>
            <if test="mdcProcessCountVo.equipmentId != null and mdcProcessCountVo.equipmentId != ''">
                AND t1.equipment_id = #{ mdcProcessCountVo.equipmentId }
            </if>
            <if test="mdcProcessCountVo.equipmentName != null and mdcProcessCountVo.equipmentName != ''">
                AND t1.equipment_name LIKE CONCAT(CONCAT('%',#{mdcProcessCountVo.equipmentName}),'%')
            </if>
            <if test="mdcProcessCountVo.driveType != null and mdcProcessCountVo.driveType != ''">
                AND t2.drive_type = #{ mdcProcessCountVo.driveType }
            </if>
            <if test="mdcProcessCountVo.deviceLevel != null and mdcProcessCountVo.deviceLevel != ''">
                AND t2.device_level = #{ mdcProcessCountVo.deviceLevel }
            </if>
            <if test="mdcProcessCountVo.deviceCategory != null and mdcProcessCountVo.deviceCategory != ''">
                AND t2.device_category = #{ mdcProcessCountVo.deviceCategory }
            </if>
            <if test="mdcProcessCountVo.startTime != null and mdcProcessCountVo.startTime != '' and mdcProcessCountVo.endTime != '' and mdcProcessCountVo.endTime != null">
                AND t1.the_date BETWEEN #{ mdcProcessCountVo.startTime } AND #{ mdcProcessCountVo.endTime }
            </if>
            <if test="mdcProcessCountVo.mdcSectionIds != null and mdcProcessCountVo.mdcSectionIds.size() > 0 ">
                AND t1.equipment_id IN
                <foreach collection="mdcProcessCountVo.mdcSectionIds" item="id" index="index" open="(" close=")" separator=",">
                    #{ id }
                </foreach>
            </if>
        </where>
        GROUP BY
            t1.equipment_id,
            t1.sequence_number
    </select>
 
    <select id="findDuration" resultType="java.math.BigDecimal">
        SELECT
            SUM( duration )
        FROM
            mdc_process_count
        WHERE
            equipment_id = #{ equipmentId } AND the_date LIKE CONCAT(#{ validDate }, '%')
    </select>
 
 
    <select id="findCount" resultType="java.math.BigDecimal">
        SELECT
            count(*)
        FROM
            mdc_process_count
        WHERE
            equipment_id = #{ equipmentId } AND the_date LIKE CONCAT(#{ validDate }, '%')
    </select>
</mapper>