37 lines
882 B
MySQL
37 lines
882 B
MySQL
|
DELIMITER $$
|
||
|
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `cache`.`prod_graphic_refresh`(v_refresh BOOL, wh_id INT)
|
||
|
proc: BEGIN
|
||
|
DECLARE datEQ DATETIME;
|
||
|
DECLARE timDIF TIME;
|
||
|
DECLARE v_calc INT;
|
||
|
|
||
|
CALL cache_calc_start (v_calc, v_refresh, 'prod_graphic', wh_id);
|
||
|
|
||
|
IF !v_refresh
|
||
|
THEN
|
||
|
LEAVE proc;
|
||
|
END IF;
|
||
|
|
||
|
CALL vn2008.production_control_source(wh_id, 0);
|
||
|
|
||
|
DELETE FROM prod_graphic_source;
|
||
|
|
||
|
INSERT INTO prod_graphic_source (warehouse_id, graphCategory, m3, hora, `order`, Agencia)
|
||
|
SELECT
|
||
|
wh_id,
|
||
|
st.graphCategory,
|
||
|
CAST(SUM(m3) AS DECIMAL(10,0)) as m3,
|
||
|
pb.Hora,
|
||
|
pb.state_order,
|
||
|
pb.Agencia
|
||
|
FROM tmp.production_buffer pb
|
||
|
JOIN vn.state st ON st.id = pb.state
|
||
|
WHERE Fecha = util.VN_CURDATE()
|
||
|
GROUP BY wh_id, graphCategory
|
||
|
;
|
||
|
|
||
|
|
||
|
CALL cache_calc_end (v_calc);
|
||
|
END$$
|
||
|
DELIMITER ;
|