ZengTao
2025-05-26 fcb8b8cc392b146aa11bbaab9e497f7f13f29d44
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
<?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.mes.hollowtask.mapper.HollowBigStorageCageHistoryTaskMapper">
 
    <resultMap id="baseMap" type="com.mes.largenscreen.entity.DailyProductionVO">
        <result column="date" property="date"/>
        <result column="count_out_one" property="countOutOne"/>
        <result column="total_area_out_one" property="totalAreaOutOne"/>
        <result column="count_out_two" property="countOutTwo"/>
        <result column="total_area_out_two" property="totalAreaOutTwo"/>
        <result column="count_in" property="countIn"/>
        <result column="total_area_in" property="totalAreaIn"/>
        <result column="count_out" property="countOut"/>
        <result column="total_area_out" property="totalAreaOut"/>
        <result column="hollow_count_out_one" property="hollowCountOutOne"/>
        <result column="hollow_total_area_out_one" property="hollowTotalAreaOutOne"/>
        <result column="hollow_count_out_two" property="hollowCountOutTwo"/>
        <result column="hollow_total_area_out_two" property="hollowTotalAreaOutTwo"/>
    </resultMap>
 
    <select id="queryHollowDailyProduction" resultMap="baseMap">
        with hollow_out_one_temp as (
        select count(t.glass_id) as hollow_count_out_one,
        round(sum(t1.width * t1.height) / 1000000, 2) as hollow_total_area_out_one
        from hollow_big_storage_cage_history_task t
        INNER JOIN glass_info t1 on t.glass_id = t1.glass_id
        where t.task_type = 5
        and t.target_slot = 930
        <if test="beginDate != null and beginDate != ''">
            AND STR_TO_DATE( t.create_time, '%Y-%m-%d' ) BETWEEN #{beginDate}
            AND #{endDate}
        </if>
        ),
        hollow_out_two_temp as (
        select count(t.glass_id) as hollow_count_out_two,
        round(sum(t1.width * t1.height) / 1000000, 2) as hollow_total_area_out_two
        from hollow_big_storage_cage_history_task t
        INNER JOIN glass_info t1 on t.glass_id = t1.glass_id
        where t.task_type = 5
        and t.target_slot = 931
        <if test="beginDate != null and beginDate != ''">
            AND STR_TO_DATE( t.create_time, '%Y-%m-%d' ) BETWEEN #{beginDate}
            AND #{endDate}
        </if>
        )
        select *
        from hollow_out_one_temp
        inner join hollow_out_two_temp on 1 = 1
    </select>
    <select id="queryRunTimes" resultType="com.mes.largenscreen.entity.RunTime">
        with big_storage_cage_history_task_temp as (
            select distinct create_time from hollow_big_storage_cage_history_task  where task_type = 5 and
                create_time  LIKE '%${days}%'
        )
        SELECT
            t1.create_time AS first_timestamp,
            t2.create_time AS second_timestamp,
            TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time) as diff_minutes,
               (select min(create_time) from big_storage_cage_history_task_temp) as start_timestamp
                ,(select max(create_time) from big_storage_cage_history_task_temp) as end_timestamp
        FROM
            (SELECT
                 create_time,
                 LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp
             FROM
                 big_storage_cage_history_task_temp ) t1
                JOIN
            (SELECT
                 create_time,
                 LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp
             FROM
                 big_storage_cage_history_task_temp ) t2 ON t1.next_timestamp = t2.create_time
        WHERE
            TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time) between 11 and 500;
    </select>
</mapper>