Merge branch 'dev' into 2893-show-expedition.externalId
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
commit
e952e995cb
|
@ -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
|
BEGIN
|
||||||
DECLARE vWeek INT;
|
DECLARE vWeek INT;
|
||||||
DECLARE vYear INT;
|
DECLARE vYear INT;
|
||||||
|
@ -13,12 +15,14 @@ BEGIN
|
||||||
SELECT *, 100 * dwindle / total AS percentage
|
SELECT *, 100 * dwindle / total AS percentage
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT buyer,
|
||||||
sum(saleTotal) as total,
|
SUM(saleTotal) AS total,
|
||||||
sum(saleWaste) as dwindle
|
SUM(saleWaste) AS dwindle
|
||||||
FROM bs.waste
|
FROM bs.waste
|
||||||
WHERE year = vYear and week = vWeek
|
WHERE year = vYear
|
||||||
|
AND week = vWeek
|
||||||
GROUP BY buyer
|
GROUP BY buyer
|
||||||
) sub
|
) sub
|
||||||
ORDER BY percentage DESC;
|
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
|
BEGIN
|
||||||
|
|
||||||
DECLARE vWeek INT;
|
DECLARE vWeek INT;
|
||||||
|
@ -9,20 +12,21 @@ BEGIN
|
||||||
SELECT week, year
|
SELECT week, year
|
||||||
INTO vWeek, vYear
|
INTO vWeek, vYear
|
||||||
FROM vn.time
|
FROM vn.time
|
||||||
WHERE dated = TIMESTAMPADD(WEEK,-1,CURDATE());
|
WHERE dated = TIMESTAMPADD(WEEK, -1, CURDATE());
|
||||||
|
|
||||||
SELECT *, 100 * mermas / total as porcentaje
|
SELECT *, 100 * mermas / total AS porcentaje
|
||||||
FROM (
|
FROM (
|
||||||
SELECT ws.family,
|
SELECT ws.family,
|
||||||
sum(ws.saleTotal) as total,
|
SUM(ws.saleTotal) AS total,
|
||||||
sum(ws.saleWaste) as mermas
|
SUM(ws.saleWaste) AS mermas
|
||||||
FROM bs.waste ws
|
FROM bs.waste ws
|
||||||
JOIN vn.worker w ON w.user = ws.buyer
|
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
|
AND w.id = vWorkerFk
|
||||||
GROUP BY family
|
GROUP BY family
|
||||||
|
|
||||||
) sub
|
) sub
|
||||||
ORDER BY porcentaje DESC;
|
ORDER BY porcentaje DESC;
|
||||||
END;
|
END;;$$
|
||||||
|
DELIMITER ;
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
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
|
BEGIN
|
||||||
DECLARE vLastWeek DATE;
|
DECLARE vLastWeek DATE;
|
||||||
DECLARE vWeek INT;
|
DECLARE vWeek INT;
|
||||||
DECLARE vYear INT;
|
DECLARE vYear INT;
|
||||||
|
|
||||||
SET vLastWeek = TIMESTAMPADD(WEEK,-1,CURDATE());
|
SET vLastWeek = TIMESTAMPADD(WEEK, -1, CURDATE());
|
||||||
SET vYear = YEAR(vLastWeek);
|
SET vYear = YEAR(vLastWeek);
|
||||||
SET vWeek = WEEK(vLastWeek, 1);
|
SET vWeek = WEEK(vLastWeek, 1);
|
||||||
|
|
||||||
|
@ -14,12 +17,14 @@ BEGIN
|
||||||
FROM (
|
FROM (
|
||||||
SELECT buyer,
|
SELECT buyer,
|
||||||
ws.family,
|
ws.family,
|
||||||
sum(ws.saleTotal) AS total,
|
SUM(ws.saleTotal) AS total,
|
||||||
sum(ws.saleWaste) AS dwindle
|
SUM(ws.saleWaste) AS dwindle
|
||||||
FROM bs.waste ws
|
FROM bs.waste ws
|
||||||
WHERE year = vYear AND week = vWeek
|
WHERE year = vYear
|
||||||
|
AND week = vWeek
|
||||||
GROUP BY buyer, family
|
GROUP BY buyer, family
|
||||||
) sub
|
) sub
|
||||||
ORDER BY percentage DESC;
|
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` DROP PRIMARY KEY;
|
||||||
|
|
||||||
ALTER TABLE `bs`.`waste`
|
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`;
|
DROP PROCEDURE IF EXISTS `bs`.`waste_Add`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
$$
|
||||||
CREATE
|
CREATE
|
||||||
DEFINER = root@`%` PROCEDURE `bs`.`waste_addSales`()
|
DEFINER = root@`%` PROCEDURE `bs`.`waste_addSales`()
|
||||||
BEGIN
|
BEGIN
|
||||||
|
|
||||||
DECLARE vWeek INT;
|
DECLARE vWeek INT;
|
||||||
DECLARE vYear INT;
|
DECLARE vYear INT;
|
||||||
|
|
||||||
|
@ -32,7 +33,5 @@ BEGIN
|
||||||
|
|
||||||
) sub
|
) sub
|
||||||
ORDER BY mermas DESC;
|
ORDER BY mermas DESC;
|
||||||
|
END;$$
|
||||||
END;
|
DELIMITER ;
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue