Merge branch 'test' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
5ad0f15720
|
@ -1,6 +1,8 @@
|
|||
drop procedure weekWaste;
|
||||
DROP PROCEDURE IF EXISTS `bs`.`weekWaste`;
|
||||
|
||||
create definer = root@`%` procedure weekWaste__()
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE DEFINER = `root`@`%` PROCEDURE `bs`.`weekWaste__`()
|
||||
BEGIN
|
||||
DECLARE vWeek INT;
|
||||
DECLARE vYear INT;
|
||||
|
@ -13,12 +15,14 @@ BEGIN
|
|||
SELECT *, 100 * dwindle / total AS percentage
|
||||
FROM (
|
||||
SELECT buyer,
|
||||
sum(saleTotal) as total,
|
||||
sum(saleWaste) as dwindle
|
||||
SUM(saleTotal) AS total,
|
||||
SUM(saleWaste) AS dwindle
|
||||
FROM bs.waste
|
||||
WHERE year = vYear and week = vWeek
|
||||
WHERE year = vYear
|
||||
AND week = vWeek
|
||||
GROUP BY buyer
|
||||
) sub
|
||||
ORDER BY percentage DESC;
|
||||
END;
|
||||
END;$$
|
||||
DELIMITER ;
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
drop procedure weekWaste_byWorker;
|
||||
DROP PROCEDURE IF EXISTS `bs`.`weekWaste_byWorker`;
|
||||
|
||||
create definer = root@`%` procedure weekWaste_byWorker__(IN vWorkerFk int)
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE
|
||||
DEFINER = root@`%` PROCEDURE `bs`.`weekWaste_byWorker__`(IN vWorkerFk INT)
|
||||
BEGIN
|
||||
|
||||
DECLARE vWeek INT;
|
||||
|
@ -11,18 +14,19 @@ BEGIN
|
|||
FROM vn.time
|
||||
WHERE dated = TIMESTAMPADD(WEEK, -1, CURDATE());
|
||||
|
||||
SELECT *, 100 * mermas / total as porcentaje
|
||||
SELECT *, 100 * mermas / total AS porcentaje
|
||||
FROM (
|
||||
SELECT ws.family,
|
||||
sum(ws.saleTotal) as total,
|
||||
sum(ws.saleWaste) as mermas
|
||||
SUM(ws.saleTotal) AS total,
|
||||
SUM(ws.saleWaste) AS mermas
|
||||
FROM bs.waste ws
|
||||
JOIN vn.worker w ON w.user = ws.buyer
|
||||
WHERE year = vYear AND week = vWeek
|
||||
WHERE year = vYear
|
||||
AND week = vWeek
|
||||
AND w.id = vWorkerFk
|
||||
GROUP BY family
|
||||
|
||||
) sub
|
||||
ORDER BY porcentaje DESC;
|
||||
END;
|
||||
END;;$$
|
||||
DELIMITER ;
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
drop procedure weekWaste_getDetail;
|
||||
DROP PROCEDURE IF EXISTS `bs`.`weekWaste_getDetail`;
|
||||
|
||||
create definer = root@`%` procedure weekWaste_getDetail__()
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE
|
||||
DEFINER = root@`%` PROCEDURE `bs`.`weekWaste_getDetail__`()
|
||||
BEGIN
|
||||
DECLARE vLastWeek DATE;
|
||||
DECLARE vWeek INT;
|
||||
|
@ -14,12 +17,14 @@ BEGIN
|
|||
FROM (
|
||||
SELECT buyer,
|
||||
ws.family,
|
||||
sum(ws.saleTotal) AS total,
|
||||
sum(ws.saleWaste) AS dwindle
|
||||
SUM(ws.saleTotal) AS total,
|
||||
SUM(ws.saleWaste) AS dwindle
|
||||
FROM bs.waste ws
|
||||
WHERE year = vYear AND week = vWeek
|
||||
WHERE year = vYear
|
||||
AND week = vWeek
|
||||
GROUP BY buyer, family
|
||||
) sub
|
||||
ORDER BY percentage DESC;
|
||||
END;
|
||||
END;$$
|
||||
DELIMITER ;
|
||||
|
||||
|
|
|
@ -17,6 +17,5 @@ ALTER TABLE `bs`.`waste`
|
|||
ALTER TABLE `bs`.`waste` DROP PRIMARY KEY;
|
||||
|
||||
ALTER TABLE `bs`.`waste`
|
||||
AD PRIMARY KEY (buyer, year, week, family, itemFk);
|
||||
|
||||
ADD PRIMARY KEY (buyer, `year`, week, family, itemFk);
|
||||
|
||||
|
|
|
@ -2,10 +2,11 @@ UPDATE `bs`.nightTask t SET t.`procedure` = 'waste_addSales' WHERE t.id = 54;
|
|||
|
||||
DROP PROCEDURE IF EXISTS `bs`.`waste_Add`;
|
||||
|
||||
DELIMITER $$
|
||||
$$
|
||||
CREATE
|
||||
DEFINER = root@`%` PROCEDURE `bs`.`waste_addSales`()
|
||||
BEGIN
|
||||
|
||||
DECLARE vWeek INT;
|
||||
DECLARE vYear INT;
|
||||
|
||||
|
@ -32,7 +33,5 @@ BEGIN
|
|||
|
||||
) sub
|
||||
ORDER BY mermas DESC;
|
||||
|
||||
END;
|
||||
|
||||
|
||||
END;$$
|
||||
DELIMITER ;
|
||||
|
|
Loading…
Reference in New Issue