zhoushihao
2025-05-12 fbd31387721424c65b173cbb23b03202f3e7dce6
hangzhoumesParent/moduleService/CacheGlassModule/src/main/resources/mapper/EdgStorageDeviceTaskHistoryMapper.xml
@@ -18,8 +18,7 @@
        <result column="hollow_total_area_out_two" property="hollowTotalAreaOutTwo"/>
    </resultMap>
    <select id="queryEdgDailyProduction" resultMap="baseMap">
    <select id="queryDailyProduction" resultMap="baseMap">
        SELECT
        count( t.glass_id_out ) AS count_out_one,
        round( sum( t1.width * t1.height )/ 1000000, 2 ) AS total_area_out_one
@@ -36,6 +35,35 @@
            AND device_id = #{deviceId}
        </if>
    </select>
    <select id="queryRunTimes" resultType="com.mes.largenscreen.entity.RunTime">
        with edg_storage_cage_history_task_temp as (
            select distinct create_time from edg_storage_device_task_history  where task_type in (1,3) and
                create_time  BETWEEN CURDATE() AND DATE_ADD(CURDATE(), INTERVAL 1 DAY)
        )
        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 edg_storage_cage_history_task_temp) as start_timestamp
                ,(select max(create_time) from edg_storage_cage_history_task_temp) as end_timestamp
        FROM
            (SELECT
                 create_time,
                 LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp
             FROM
                 edg_storage_cage_history_task_temp ) t1
                JOIN
            (SELECT
                 create_time,
                 LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp
             FROM
                 edg_storage_cage_history_task_temp ) t2 ON t1.next_timestamp = t2.create_time
        WHERE
            TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time) between 6 and 500
        GROUP BY t1.create_time,t2.create_time
        ;
    </select>
</mapper>