zhangherong
2025-05-09 f9a9fb9090c2e9e1a4e00374d48181efe2463a56
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
<?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.MdcEquipmentStatisticalInfoMapper">
 
 
    <!--获取设备最新日期的运行数据-->
    <select id="getMaxStaticsData" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
        SELECT TOP 1 * FROM mdc_equipment_statistical_info WHERE equipment_id = #{equipmentId} ORDER BY the_date DESC
    </select>
 
    <!--查询设备运行时间-->
    <select id="selectProcessLong" resultType="java.lang.Integer">
        SELECT TOP 1 process_long FROM mdc_equipment_statistical_info WHERE equipment_id = #{equipmentId} AND the_date = #{validDate}
    </select>
 
    <select id="findByEquipmentAndMonth" resultType="org.jeecg.modules.mdc.dto.MdcEquipmentStatisticalDto">
        SELECT
            SUM(open_long) openLong,
            SUM(close_long) closeLong,
            SUM(wait_long) waitLong,
            SUM(process_long) processLong,
            SUM(error_long) errorLong,
            COUNT(*) dayNum
        FROM
            mdc_equipment_statistical_info
        WHERE
            equipment_id = #{equipmentId} AND the_date LIKE CONCAT(#{date}, '%')
    </select>
 
    <select id="findByEquipmentAndDate" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
        SELECT
            the_date,
            AVG ( open_long ) openLong,
            AVG ( wait_long ) waitLong,
            AVG ( process_long ) processLong,
            AVG ( close_long ) closeLong,
            AVG ( error_long ) errorLong
        FROM
            mdc_equipment_statistical_info
        <where>
            the_date BETWEEN #{start} AND #{end}
            AND equipment_id IN
            <foreach collection="equipmentList" index="index" item="id" open="(" separator="," close=")">
                #{id}
            </foreach>
        </where>
        GROUP BY
            the_date
    </select>
 
    <select id="findByEquIdAndDate" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
        SELECT * FROM mdc_equipment_statistical_info WHERE equipment_id = #{equipmentId} AND the_date BETWEEN #{start} AND #{end} ORDER BY the_date
    </select>
 
    <select id="findByEquIdAndMonth" resultType="org.jeecg.modules.mdc.entity.MdcEquipmentStatisticalInfo">
        SELECT
            AVG(open_long) openLong,
            AVG(close_long) closeLong,
            AVG(wait_long) waitLong,
            AVG(process_long) processLong,
            AVG(error_long) errorLong
        FROM
            mdc_equipment_statistical_info
        WHERE
            equipment_id = #{equipmentId} AND the_date LIKE CONCAT(#{month}, '%')
    </select>
</mapper>