From 347bde69a521797568a7e22f55853935dbd05a99 Mon Sep 17 00:00:00 2001 From: zhoushihao <zsh19950802@163.com> Date: 星期一, 12 五月 2025 18:18:03 +0800 Subject: [PATCH] 1、大屏数据导出 --- hangzhoumesParent/common/servicebase/src/main/resources/mapper/LargenScreenMapper.xml | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 161 insertions(+), 0 deletions(-) diff --git a/hangzhoumesParent/common/servicebase/src/main/resources/mapper/LargenScreenMapper.xml b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/LargenScreenMapper.xml index 14a179a..f505063 100644 --- a/hangzhoumesParent/common/servicebase/src/main/resources/mapper/LargenScreenMapper.xml +++ b/hangzhoumesParent/common/servicebase/src/main/resources/mapper/LargenScreenMapper.xml @@ -136,6 +136,167 @@ t6.product_date order by t.date </select> + <select id="exportDailyProduction" resultType="com.mes.largenscreen.entity.DailyProductionData"> + with edg_storage_history_temp as ( + select t.glass_id_in as glass_id, t.create_time, STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date + from edg_storage_device_task_history t + where t.task_type in + (1, 3) + and STR_TO_DATE(t.create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate} + ) + , big_storage_cage_history_temp as ( + select t.glass_id, t.create_time, STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date + from big_storage_cage_history_task t + where t.task_type = 2 + and STR_TO_DATE(t.create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate} + ) + , hollow_big_storage_cage_history_temp as ( + select t.glass_id, t.create_time, STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date + from hollow_big_storage_cage_history_task t + where t.task_type = 5 + and STR_TO_DATE(t.create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate} + ) + , engineer_temp as ( + select STR_TO_DATE(create_time, '%Y-%m-%d') as product_date, engineer_id, glass_total, glass_total_area + from engineering + where STR_TO_DATE(create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate} + ) + , edg_temp as ( + select t.product_date, + count(t.glass_id) as + count_out, + round(sum(t1.width * t1.height) / 1000000, 1) as total_area_out + from edg_storage_history_temp t + inner join glass_info t1 on t.glass_id = t1.glass_id + group by product_date + ) + , edg_time_one as ( + select product_date, + min(create_time) as edg_begin_time, + max(create_time) as edg_end_time, + TIMESTAMPDIFF(MINUTE, min(create_time), max(create_time)) AS edg_time_total + from edg_storage_history_temp + group by product_date + ) + , edg_time_two as ( + SELECT t1.product_date, + sum(TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time)) AS edg_time_free + FROM (SELECT product_date, + create_time, + LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp + FROM edg_storage_history_temp + ) t1 + JOIN + (SELECT create_time, + LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp + FROM edg_storage_history_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.product_date + ) + , big_storage_temp as ( + select t.product_date, + count(distinct t1.engineer_id, t1.tempering_layout_id) as tempering_layout_count, + count(distinct t1.glass_id) as tempering_glass_count, + round(sum(t1.width * t1.height) / 1000000, 1) as tempering_area + from big_storage_cage_history_temp t + inner join glass_info t1 + on t.glass_id = t1.glass_id + group by t.product_date + ) + , big_storage_time_base as ( + select distinct product_date, create_time from big_storage_cage_history_temp + ) + , big_storage_time_one as (select product_date, + min(create_time) as big_begin_time, + max(create_time) as big_end_time, + TIMESTAMPDIFF(MINUTE, min(create_time), max(create_time)) AS big_time_total + from big_storage_time_base + group by product_date) + , big_storage_time_two as ( + SELECT t1.product_date, + IFNULL(sum(TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time)), 0) AS big_time_free + FROM (SELECT product_date, + create_time, + LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp + FROM big_storage_time_base) t1 + JOIN + (SELECT create_time, + LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp + FROM big_storage_time_base) t2 ON t1.next_timestamp = t2.create_time + WHERE TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time) between 11 and 500 + group by t1.product_date + ) + , hollow_big_storage_temp as ( + select t.product_date, + count(distinct t1.glass_id) as hollow_glass_count, + round(sum(t1.width * t1.height) / 1000000, 1) as hollow_area + from hollow_big_storage_cage_history_temp t + inner join glass_info t1 + on t.glass_id = t1.glass_id + group by t.product_date + ) + , hollow_big_storage_time_base as ( + select distinct product_date, create_time from hollow_big_storage_cage_history_temp + ) + , hollow_big_storage_time_one as (select product_date, + min(create_time) as hollow_begin_time, + max(create_time) as hollow_end_time, + TIMESTAMPDIFF(MINUTE, min(create_time), max(create_time)) AS hollow_time_total + from hollow_big_storage_time_base + group by product_date) + , hollow_big_storage_time_two as ( + SELECT t1.product_date, + IFNULL(sum(TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time)), 0) AS hollow_time_free + FROM (SELECT product_date, + create_time, + LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp + FROM hollow_big_storage_time_base) t1 + JOIN + (SELECT create_time, + LEAD(create_time) OVER (ORDER BY create_time) AS next_timestamp + FROM hollow_big_storage_time_base) t2 ON t1.next_timestamp = t2.create_time + WHERE TIMESTAMPDIFF(MINUTE, t1.create_time, t2.create_time) between 11 and 500 + group by t1.product_date + ) + , result as ( + select t.count_out, + t.total_area_out, + t1.*, + t2.edg_time_free, + t1.edg_time_total - t2.edg_time_free as edg_time_diff, + t3.tempering_layout_count, + t3.tempering_glass_count, + t3.tempering_area, + t4.big_begin_time, + t4.big_end_time, + t4.big_time_total, + t5.big_time_free, + t4.big_time_total - t5.big_time_free as big_time_diff, + t6.hollow_glass_count, + t6.hollow_area, + t7.hollow_begin_time, + t7.hollow_end_time, + t7.hollow_time_total, + t8.hollow_time_free, + t7.hollow_time_total - t8.hollow_time_free as hollow_time_diff, + t9.engineer_id, + t9.glass_total, + t9.glass_total_area + from edg_temp t + LEFT JOIN edg_time_one t1 on t.product_date = t1.product_date + LEFT JOIN edg_time_two t2 on t.product_date = t2.product_date + LEFT JOIN big_storage_temp t3 on t.product_date = t3.product_date + LEFT JOIN big_storage_time_one t4 on t.product_date = t4.product_date + LEFT JOIN big_storage_time_two t5 on t.product_date = t5.product_date + LEFT JOIN hollow_big_storage_temp t6 on t.product_date = t6.product_date + LEFT JOIN hollow_big_storage_time_one t7 on t.product_date = t7.product_date + LEFT JOIN hollow_big_storage_time_two t8 on t.product_date = t8.product_date + LEFT JOIN engineer_temp t9 on t.product_date = t9.product_date + ) + select * + from result + order by product_date + </select> </mapper> \ No newline at end of file -- Gitblit v1.8.0