<?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.largenscreen.mapper.LargenScreenMapper">
|
|
<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="queryDailyProduction" resultMap="baseMap">
|
WITH RECURSIVE
|
date_series AS (
|
SELECT #{beginDate} AS date
|
UNION ALL
|
SELECT DATE_ADD(date, INTERVAL 1 DAY)
|
FROM date_series
|
WHERE date <= DATE_SUB(#{endDate}, INTERVAL 1 DAY)
|
),
|
one_edg_temp as (
|
select STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date,
|
count(t.glass_id_out) as
|
count_out_one,
|
round(sum(t1.width * t1.height) / 1000000, 2) as total_area_out_one
|
from edg_storage_device_task_history t
|
inner join glass_info t1 on t.glass_id_out = t1.glass_id
|
where t.task_type in
|
(2, 3)
|
and STR_TO_DATE(t.create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate}
|
and device_id = 1
|
group by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
order by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
),
|
two_edg_temp as (
|
select STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date,
|
count(t.glass_id_out) as
|
count_out_two,
|
round(sum(t1.width * t1.height) / 1000000, 2) as total_area_out_two
|
from edg_storage_device_task_history t
|
inner join glass_info t1 on t.glass_id_out = t1.glass_id
|
where t.task_type in
|
(2, 3)
|
and STR_TO_DATE(t.create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate}
|
and device_id = 2
|
group by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
order by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
),
|
big_storage_in_temp as (
|
select STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date,
|
count(t.glass_id) as
|
count_in,
|
round(sum(t1.width * t1.height) / 1000000, 2) as total_area_in
|
from big_storage_cage_history_task t
|
INNER JOIN glass_info t1 on t.glass_id = t1.glass_id
|
where t.task_type = 1
|
and STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
BETWEEN #{beginDate} and #{endDate}
|
group by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
order by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
),
|
big_storage_out_temp as (
|
select STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date,
|
count(t.glass_id) as
|
count_out,
|
round(sum(t1.width * t1.height) / 1000000, 2) as total_area_out
|
from big_storage_cage_history_task t
|
INNER JOIN glass_info t1 on t.glass_id = t1.glass_id
|
where t.task_type = 2
|
and STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
BETWEEN #{beginDate} and #{endDate}
|
group by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
order by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
),
|
hollow_out_one_temp as (
|
select STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date,
|
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
|
and STR_TO_DATE(t.create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate}
|
group by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
order by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
),
|
hollow_out_two_temp as (
|
select STR_TO_DATE(t.create_time, '%Y-%m-%d') as product_date,
|
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
|
and STR_TO_DATE(t.create_time, '%Y-%m-%d') BETWEEN #{beginDate} and #{endDate}
|
group by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
order by STR_TO_DATE(t.create_time, '%Y-%m-%d')
|
)
|
select t.date,
|
ifnull(t1.count_out_one, 0) count_out_one,
|
ifnull(t1.total_area_out_one, 0) total_area_out_one,
|
ifnull(t2.count_out_two, 0) count_out_two,
|
ifnull(t2.total_area_out_two, 0) total_area_out_two,
|
ifnull(t3.count_in, 0) count_in,
|
ifnull(t3.total_area_in, 0) total_area_in,
|
ifnull(t4.count_out, 0) count_out,
|
ifnull(t4.total_area_out, 0) total_area_out,
|
ifnull(t5.hollow_count_out_one, 0) hollow_count_out_one,
|
ifnull(t5.hollow_total_area_out_one, 0)
|
hollow_total_area_out_one,
|
ifnull(t6.hollow_count_out_two, 0) hollow_count_out_two,
|
ifnull(t6.hollow_total_area_out_two, 0)
|
hollow_total_area_out_two
|
from date_series t
|
left join one_edg_temp t1 on t.date = t1.product_date
|
left join two_edg_temp t2 on t.date =
|
t2.product_date
|
left join big_storage_in_temp t3 on t.date = t3.product_date
|
left join big_storage_out_temp t4 on t.date =
|
t4.product_date
|
left join hollow_out_one_temp t5 on t.date = t5.product_date
|
left join hollow_out_two_temp t6 on t.date =
|
t6.product_date
|
order by t.date
|
</select>
|
|
|
</mapper>
|