feat: refs #5167 update
gitea/salix/pipeline/head There was a failure building this commit Details
gitea/salix/pipeline/pr-dev There was a failure building this commit Details

This commit is contained in:
Juanjo Breso 2024-01-31 09:38:57 +01:00
parent aba0d97106
commit 18772c04f6
12 changed files with 36 additions and 218 deletions

View File

@ -73,9 +73,10 @@ INSERT INTO vn.cmr (id, truckPlate, observations, senderInstruccions, paymentIns
UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101'); UPDATE `vn`.`claimRatio` SET `claimAmount` = '10' WHERE (`clientFk` = '1101');
INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `warehouseAliasFk`, `isOwn`, `isAnyVolumeAllowed`) VALUES INSERT INTO `vn`.`agency` (`name`, `warehouseFk`, `isOwn`, `isAnyVolumeAllowed`)
('Agencia', '1', '1', '1', '1'), VALUES
('Otra agencia ', '1', '2', '0', '0'); ('Agencia', '1', '1', '1'),
('Otra agencia ', '1', '0', '0');
INSERT INTO `vn`.`expedition` (`agencyModeFk`, `ticketFk`, `isBox`, `counter`, `workerFk`, `externalId`, `packagingFk`, `hostFk`, `itemPackingTypeFk`, `hasNewRoute`) VALUES INSERT INTO `vn`.`expedition` (`agencyModeFk`, `ticketFk`, `isBox`, `counter`, `workerFk`, `externalId`, `packagingFk`, `hostFk`, `itemPackingTypeFk`, `hasNewRoute`) VALUES
('1', '1', 1, '1', '1', '1', '1', 'pc00', 'F', 0), ('1', '1', 1, '1', '1', '1', '1', 'pc00', 'F', 0),

View File

@ -174,20 +174,15 @@ INSERT INTO `vn`.`country`(`id`, `country`, `isUeeMember`, `code`, `currencyFk`,
(19,'Francia', 1, 'FR', 1, 27, 4, 0, 1), (19,'Francia', 1, 'FR', 1, 27, 4, 0, 1),
(30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2); (30,'Canarias', 1, 'IC', 1, 24, 4, 1, 2);
INSERT INTO `vn`.`warehouseAlias`(`id`, `name`) INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `countryFk`, `hasProduction`, `isOrigin`, `isDestiny`)
VALUES VALUES
(1, 'Main Warehouse'), (1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 1, 1, 1, 1),
(2, 'Gotham'); (2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 13, 1, 1, 0),
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 1, 0),
INSERT INTO `vn`.`warehouse`(`id`, `name`, `code`, `isComparative`, `isInventory`, `hasAvailable`, `isManaged`, `hasDms`, `hasComission`, `aliasFk`, `countryFk`, `hasProduction`) (4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 1),
VALUES (5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 1, 1, 0, 0),
(1, 'Warehouse One', 'ALG', 1, 1, 1, 1, 1, 1, 2, 1, 1), (13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 1, 0, 0, 0),
(2, 'Warehouse Two', NULL, 1, 1, 1, 1, 0, 1, 2, 13, 1), (60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 1, 0, 0, 0);
(3, 'Warehouse Three', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(4, 'Warehouse Four', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(5, 'Warehouse Five', NULL, 1, 1, 1, 1, 0, 0, 2, 1, 1),
(13, 'Inventory', 'inv', 1, 1, 1, 0, 0, 0, 2, 1, 0),
(60, 'Algemesi', NULL, 1, 1, 1, 0, 0, 0, 2, 1, 0);
INSERT INTO `vn`.`sectorType` (id,description) INSERT INTO `vn`.`sectorType` (id,description)
VALUES (1,'First type'); VALUES (1,'First type');
@ -271,18 +266,18 @@ INSERT INTO `vn`.`deliveryMethod`(`id`, `code`, `description`)
(3, 'PICKUP', 'Recogida'), (3, 'PICKUP', 'Recogida'),
(4, 'OTHER', 'Otros'); (4, 'OTHER', 'Otros');
INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`, `warehouseAliasFk`) INSERT INTO `vn`.`agency`(`id`, `name`, `warehouseFk`)
VALUES VALUES
(1, 'inhouse pickup' , 1, 1), (1, 'inhouse pickup' , 1),
(2, 'Super-Man delivery' , 1, 1), (2, 'Super-Man delivery' , 1),
(3, 'Teleportation device' , 1, 1), (3, 'Teleportation device' , 1),
(4, 'Entanglement' , 1, 1), (4, 'Entanglement' , 1),
(5, 'Quantum break device' , 1, 1), (5, 'Quantum break device' , 1),
(6, 'Walking' , 1, 1), (6, 'Walking' , 1),
(7, 'Gotham247' , 1, 1), (7, 'Gotham247' , 1),
(8, 'Gotham247Expensive' , 1, 1), (8, 'Gotham247Expensive' , 1),
(9, 'Refund' , 1, 1), (9, 'Refund' , 1),
(10, 'Other agency' , 1, 1); (10, 'Other agency' , 1);
UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup'; UPDATE `vn`.`agencyMode` SET `id` = 1 WHERE `name` = 'inhouse pickup';
UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery'; UPDATE `vn`.`agencyMode` SET `id` = 2 WHERE `name` = 'Super-Man delivery';

View File

@ -8,16 +8,9 @@ BEGIN
* @param vItemFk Identificador de vn.item * @param vItemFk Identificador de vn.item
* @param vSectorFk Identificador de vn.sector * @param vSectorFk Identificador de vn.sector
*/ */
DECLARE vWarehouseAliasFk INT;
SELECT w.aliasFk INTO vWarehouseAliasFk
FROM vn.sector s
JOIN vn.warehouse w ON w.id = s.warehouseFk
WHERE s.id = vSectorFk;
SELECT ish.shelvingFk shelving, SELECT ish.shelvingFk shelving,
p.code parking, p.code parking,
sum(ish.visible) as stockTotal, SUM(ish.visible) as stockTotal,
ish.created, ish.created,
p.pickingOrder p.pickingOrder
FROM vn.itemShelving ish FROM vn.itemShelving ish
@ -25,10 +18,10 @@ BEGIN
JOIN vn.parking p ON p.id = sh.parkingFk JOIN vn.parking p ON p.id = sh.parkingFk
JOIN vn.sector sc ON sc.id = p.sectorFk JOIN vn.sector sc ON sc.id = p.sectorFk
JOIN vn.warehouse w ON w.id = sc.warehouseFk JOIN vn.warehouse w ON w.id = sc.warehouseFk
WHERE w.aliasFk = vWarehouseAliasFk WHERE sc.id = vSectorFk
AND ish.visible > 0 AND ish.visible > 0
AND ish.itemFk = vItemFk AND ish.itemFk = vItemFk
GROUP BY ish.id GROUP BY ish.id
ORDER BY (sc.id = vSectorFk) DESC, sh.priority DESC, ish.created, p.pickingOrder; ORDER BY sh.priority DESC, ish.created, p.pickingOrder;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -1,12 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`warehouse_afterUpdate`
AFTER UPDATE ON `warehouse`
FOR EACH ROW
BEGIN
IF NEW.isFeedStock IS TRUE AND OLD.isFeedStock IS FALSE THEN
INSERT IGNORE INTO warehouseAlias(`name`) VALUES(NEW.`name`);
INSERT IGNORE INTO warehouseJoined(warehouseFk, warehouseAliasFk)
VALUES(NEW.id,LAST_INSERT_ID());
END IF;
END$$
DELIMITER ;

View File

@ -1,6 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`warehouseJoined`
AS SELECT `wj`.`warehouse_id` AS `warehouseFk`,
`wj`.`warehouse_alias_id` AS `warehouseAliasFk`
FROM `vn2008`.`warehouse_joined` `wj`

View File

@ -1,25 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn`.`zoneEstimatedDelivery`
AS SELECT t.zoneFk,
zc.`hour` zoneClosureHour,
z.`hour` zoneHour,
sv.volume volume,
al.hasToRecalcPrice,
lhp.m3,
dl.minSpeed
FROM ticket t
JOIN ticketStateToday tst ON tst.ticket = t.id
JOIN state s ON s.id = tst.state
JOIN saleVolume sv ON sv.ticketFk = t.id
LEFT JOIN lastHourProduction lhp ON lhp.warehouseFk = t.warehouseFk
JOIN warehouse w ON w.id = t.warehouseFk
JOIN warehouseAlias wa ON wa.id = w.aliasFk
STRAIGHT_JOIN `zone` z ON z.id = t.zoneFk
LEFT JOIN zoneClosure zc ON zc.zoneFk = t.zoneFk
AND zc.dated = util.VN_CURDATE()
LEFT JOIN cache.departure_limit dl ON dl.warehouse_id = t.warehouseFk
AND dl.fecha = util.VN_CURDATE()
JOIN alertLevel al ON al.id = s.alertLevel
WHERE w.hasProduction
AND DATE(t.shipped) = util.VN_CURDATE()

View File

@ -1,82 +0,0 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn2008`.`desglose_volume`(IN vAgencyFk INT)
BEGIN
DECLARE vStarted DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE());
DECLARE vEnded DATETIME DEFAULT TIMESTAMP(util.VN_CURDATE(), '23:59:59');
DECLARE vIsHolland BOOL;
SELECT (wa.name = 'Holanda') INTO vIsHolland
FROM vn.agency a
JOIN vn.warehouseAlias wa ON wa.id = a.warehouseAliasFk
WHERE a.id = vAgencyFk;
IF vIsHolland THEN
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated;
CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated
(
ticketFk INT PRIMARY KEY
,carros DECIMAL(5,1) DEFAULT 0
);
INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, carros)
SELECT sv.ticketFk, ROUND(vc.dutchCompressionRate * sum(sv.volume) / vc.trolleyM3,0)
FROM vn.ticket t
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.volumeConfig vc
WHERE t.shipped BETWEEN vStarted AND vEnded
AND am.agencyFk = vAgencyFk
GROUP BY t.id;
SELECT a.nickname Provincia,
count(*) expediciones,
0 Bultos,
sum(tpe.carros) Prevision
FROM vn.ticket t
JOIN vn.address a ON a.id = t.addressFk
JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id
GROUP BY a.nickname;
ELSE
DROP TEMPORARY TABLE IF EXISTS tmp.ticket_PackagingEstimated;
CREATE TEMPORARY TABLE tmp.ticket_PackagingEstimated
(
ticketFk INT PRIMARY KEY
,boxes INT DEFAULT 0
);
INSERT INTO tmp.ticket_PackagingEstimated(ticketFk, boxes)
SELECT sv.ticketFk, CEIL(1000 * sum(sv.volume) / vc.standardFlowerBox)
FROM vn.ticket t
JOIN vn.saleVolume sv ON sv.ticketFk = t.id
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN vn.volumeConfig vc
WHERE t.shipped BETWEEN vStarted AND vEnded
AND IFNULL(t.packages,0) = 0
AND am.agencyFk = vAgencyFk
GROUP BY t.id;
SELECT p.name Provincia,
count(*) expediciones,
sum(t.packages) Bultos,
sum(tpe.boxes) Prevision
FROM vn.ticket t
JOIN vn.address a ON a.id = t.addressFk
JOIN vn.province p ON a.provinceFk = p.id
JOIN vn.agencyMode am ON am.id = t.agencyModeFk
JOIN tmp.ticket_PackagingEstimated tpe ON tpe.ticketFk = t.id
WHERE t.warehouseFk = 60
AND t.shipped BETWEEN vStarted AND vEnded
AND am.agencyFk = vAgencyFk
GROUP BY p.name;
END IF;
SELECT * FROM tmp.ticket_PackagingEstimated;
DROP TEMPORARY TABLE tmp.ticket_PackagingEstimated;
END$$
DELIMITER ;

View File

@ -4,7 +4,6 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
AS SELECT `a`.`id` AS `agency_id`, AS SELECT `a`.`id` AS `agency_id`,
`a`.`name` AS `name`, `a`.`name` AS `name`,
`a`.`warehouseFk` AS `warehouse_id`, `a`.`warehouseFk` AS `warehouse_id`,
`a`.`warehouseAliasFk` AS `warehouse_alias_id`,
`a`.`isOwn` AS `propios`, `a`.`isOwn` AS `propios`,
`a`.`workCenterFk` AS `workCenterFk` `a`.`workCenterFk` AS `workCenterFk`
FROM `vn`.`agency` `a` FROM `vn`.`agency` `a`

View File

@ -1,35 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_price_fixed`
AS SELECT `pf`.`warehouse_id` AS `warehouse_id`,
`pf`.`item_id` AS `item_id`,
`pf`.`rate_0` AS `rate_0`,
`pf`.`rate_1` AS `rate_1`,
`pf`.`rate_2` AS `rate_2`,
`pf`.`rate_3` AS `rate_3`,
`pf`.`date_start` AS `date_start`,
`pf`.`date_end` AS `date_end`,
`pf`.`bonus` AS `bonus`,
`pf`.`grouping` AS `grouping`,
`pf`.`Packing` AS `Packing`,
`pf`.`caja` AS `caja`
FROM `vn2008`.`price_fixed` `pf`
WHERE `pf`.`warehouse_id` < 1000
UNION ALL
SELECT `wg`.`warehouse_id` AS `warehouse_id`,
`pf`.`item_id` AS `item_id`,
`pf`.`rate_0` AS `rate_0`,
`pf`.`rate_1` AS `rate_1`,
`pf`.`rate_2` AS `rate_2`,
`pf`.`rate_3` AS `rate_3`,
`pf`.`date_start` AS `date_start`,
`pf`.`date_end` AS `date_end`,
`pf`.`bonus` AS `bonus`,
`pf`.`grouping` AS `grouping`,
`pf`.`Packing` AS `Packing`,
`pf`.`caja` AS `caja`
FROM (
`vn2008`.`price_fixed` `pf`
JOIN `vn2008`.`warehouse_group` `wg`
)
WHERE `wg`.`warehouse_alias_id` + 1000 = `pf`.`warehouse_id`

View File

@ -1,10 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`v_warehouse`
AS SELECT `warehouse`.`id` AS `id`,
`warehouse`.`name` AS `almacen`
FROM `vn2008`.`warehouse`
UNION ALL
SELECT 1000 + `warehouse_alias`.`warehouse_alias_id` AS `warehouse_alias_id`,
concat(`warehouse_alias`.`alias`, '(G)') AS `concat(alias, '(G)')`
FROM `vn2008`.`warehouse_alias`

View File

@ -1,6 +0,0 @@
CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER
VIEW `vn2008`.`warehouse_alias`
AS SELECT `wa`.`id` AS `warehouse_alias_id`,
`wa`.`name` AS `alias`
FROM `vn`.`warehouseAlias` `wa`

View File

@ -0,0 +1,6 @@
ALTER TABLE vn.agency CHANGE warehouseAliasFk warehouseAliasFk__ smallint(5) unsigned DEFAULT NULL NULL COMMENT 'Refs #5167 Deprecated 2024-01-23';
ALTER TABLE vn.warehouse CHANGE aliasFk aliasFk__ smallint(5) unsigned DEFAULT NULL NULL COMMENT 'Refs #5167 Deprecated 2024-01-23';
RENAME TABLE vn.warehouseAlias TO vn.warehouseAlias__;
ALTER TABLE vn.warehouseAlias__ COMMENT='Refs #5167 Deprecated 2024-01-23';