|
|
|
@ -3,96 +3,110 @@
|
|
|
|
|
<sqlMap namespace="com.backoffice.m.memory">
|
|
|
|
|
<select id="select_week" resultClass="dataMap" parameterClass="dataMap">
|
|
|
|
|
SELECT
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%Y-%m-%d') as day,
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%d') as dd,
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%H') * 4.15 as hour,
|
|
|
|
|
LPAD(c.val_1, 2, '0') as val_1,
|
|
|
|
|
(select color_cd from tbl_code_item ts where ts.val_1 = c.cd_no) as color_cd,
|
|
|
|
|
c.title as title,
|
|
|
|
|
ifnull(
|
|
|
|
|
CASE
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_1' THEN
|
|
|
|
|
(select (blm + brm) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_1 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_2' THEN
|
|
|
|
|
(select (bm + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_2 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_3' THEN
|
|
|
|
|
(select (bm + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_3 tn1
|
|
|
|
|
left outer join tbl_db_nutrient tn on tn1.db_dn_no = tn.dn_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_5' THEN
|
|
|
|
|
(select (sleep_h * 60 + sleep_m) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_5 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_6' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_6 tn1
|
|
|
|
|
inner join tbl_code_item_str tn2 on tn2.cg_cd = 'BF_FECES_QTY' and tn1.rest_qty = tn2.val_1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_7' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_7 tn1
|
|
|
|
|
inner join tbl_db_vac tv on tn1.db_dvs_no = tv.dv_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_9' THEN
|
|
|
|
|
(select (bm + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_9 tn1
|
|
|
|
|
left outer join tbl_db_home_bf tb on tn1.db_dhb_no = tb.dhb_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_10' THEN
|
|
|
|
|
(select (bm * 60 + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_10 tn1
|
|
|
|
|
left outer join tbl_db_bf_commerce tc on tc.dbc_no = tn1.db_dbc_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_11' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_11 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_12' THEN
|
|
|
|
|
(select disturb_min + disturb_sec
|
|
|
|
|
from tbl_bf_daily_nutrition_12 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_13' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_13 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_14' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_14 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_15' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_15 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
END
|
|
|
|
|
, 1) AS add_degree,
|
|
|
|
|
count(*) as cnt
|
|
|
|
|
FROM tbl_bf_family_match a
|
|
|
|
|
INNER JOIN tbl_bf_daily_nutrition b on a.smc_no = b.smc_no
|
|
|
|
|
INNER JOIN tbl_code_item_str c on b.nutirition_cd_no = c.cd_no
|
|
|
|
|
WHERE
|
|
|
|
|
a.smc_no = #smc_no#
|
|
|
|
|
and b.nutirition_cd_no != ''
|
|
|
|
|
and b.reg_dt between STR_TO_DATE(#startDate#,'%Y-%m-%d %H:%i:%s') and ADDDATE( STR_TO_DATE(#endDate#,'%Y-%m-%d %H:%i:%s'), INTERVAL 7 DAY)
|
|
|
|
|
group by DATE_FORMAT(b.reg_dt, '%Y-%m-%d %H'), DATE_FORMAT(b.reg_dt, '%H'), DATE_FORMAT(b.reg_dt, '%d'), LPAD(c.val_1, 2, '0')
|
|
|
|
|
order by DATE_FORMAT(b.reg_dt, '%Y-%m-%d') asc, DATE_FORMAT(b.reg_dt, '%H') asc, DATE_FORMAT(b.reg_dt, '%d') asc, LPAD(c.val_1, 2, '0') asc
|
|
|
|
|
XA.day,
|
|
|
|
|
XA.dd,
|
|
|
|
|
XA.hour,
|
|
|
|
|
XA.val_1,
|
|
|
|
|
XA.color_cd,
|
|
|
|
|
XA.title,
|
|
|
|
|
CASE WHEN XA.add_degree > 42.5 then 42.5
|
|
|
|
|
ELSE XA.add_degree
|
|
|
|
|
END as add_degree,
|
|
|
|
|
XA.cnt
|
|
|
|
|
FROM
|
|
|
|
|
(
|
|
|
|
|
SELECT
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%Y-%m-%d') as day,
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%d') as dd,
|
|
|
|
|
DATE_FORMAT(b.reg_dt, '%H') * 4.15 as hour,
|
|
|
|
|
LPAD(c.val_1, 2, '0') as val_1,
|
|
|
|
|
(select color_cd from tbl_code_item ts where ts.val_1 = c.cd_no) as color_cd,
|
|
|
|
|
c.title as title,
|
|
|
|
|
ifnull(
|
|
|
|
|
CASE
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_1' THEN
|
|
|
|
|
(select (blm + brm) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_1 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_2' THEN
|
|
|
|
|
(select (bm + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_2 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_3' THEN
|
|
|
|
|
(select (bm + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_3 tn1
|
|
|
|
|
left outer join tbl_db_nutrient tn on tn1.db_dn_no = tn.dn_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_5' THEN
|
|
|
|
|
(select (sleep_h * 60 + sleep_m) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_5 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_6' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_6 tn1
|
|
|
|
|
inner join tbl_code_item_str tn2 on tn2.cg_cd = 'BF_FECES_QTY' and tn1.rest_qty = tn2.val_1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_7' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_7 tn1
|
|
|
|
|
inner join tbl_db_vac tv on tn1.db_dvs_no = tv.dv_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_9' THEN
|
|
|
|
|
(select (bm + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_9 tn1
|
|
|
|
|
left outer join tbl_db_home_bf tb on tn1.db_dhb_no = tb.dhb_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_10' THEN
|
|
|
|
|
(select (bm * 60 + bs) * 0.233
|
|
|
|
|
from tbl_bf_daily_nutrition_10 tn1
|
|
|
|
|
left outer join tbl_db_bf_commerce tc on tc.dbc_no = tn1.db_dbc_no
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_11' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_11 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_12' THEN
|
|
|
|
|
(select disturb_min + disturb_sec
|
|
|
|
|
from tbl_bf_daily_nutrition_12 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_13' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_13 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_14' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_14 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
when c.cd_no = 'BF_NU_TP_15' THEN
|
|
|
|
|
(select 2
|
|
|
|
|
from tbl_bf_daily_nutrition_15 tn1
|
|
|
|
|
where tn1.dn_no = b.dn_no
|
|
|
|
|
)
|
|
|
|
|
END
|
|
|
|
|
, 1) AS add_degree,
|
|
|
|
|
count(*) as cnt
|
|
|
|
|
FROM tbl_bf_family_match a
|
|
|
|
|
INNER JOIN tbl_bf_daily_nutrition b on a.smc_no = b.smc_no
|
|
|
|
|
INNER JOIN tbl_code_item_str c on b.nutirition_cd_no = c.cd_no
|
|
|
|
|
WHERE
|
|
|
|
|
a.smc_no = #smc_no#
|
|
|
|
|
and b.nutirition_cd_no != ''
|
|
|
|
|
and b.reg_dt between STR_TO_DATE(#startDate#,'%Y-%m-%d %H:%i:%s') and ADDDATE( STR_TO_DATE(#endDate#,'%Y-%m-%d %H:%i:%s'), INTERVAL 7 DAY)
|
|
|
|
|
group by DATE_FORMAT(b.reg_dt, '%Y-%m-%d %H'), DATE_FORMAT(b.reg_dt, '%H'), DATE_FORMAT(b.reg_dt, '%d'), LPAD(c.val_1, 2, '0')
|
|
|
|
|
order by DATE_FORMAT(b.reg_dt, '%Y-%m-%d') asc, DATE_FORMAT(b.reg_dt, '%H') asc, DATE_FORMAT(b.reg_dt, '%d') asc, LPAD(c.val_1, 2, '0') asc
|
|
|
|
|
) XA
|
|
|
|
|
</select>
|
|
|
|
|
|
|
|
|
|
<select id="select_day" resultClass="dataMap" parameterClass="dataMap">
|
|
|
|
|