Merge branch 'dev' into 7882-quadMinds
gitea/salix/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Guillermo Bonet 2024-08-23 11:26:29 +00:00
commit c9a9a6e074
15 changed files with 110 additions and 60 deletions

View File

@ -412,7 +412,7 @@ INSERT INTO `vn`.`clientManaCache`(`clientFk`, `mana`, `dated`)
(1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)), (1103, 0, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)),
(1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH)); (1104, -30, DATE_ADD(util.VN_CURDATE(), INTERVAL -1 MONTH));
INSERT INTO `vn`.`mandateType`(`id`, `name`) INSERT INTO `vn`.`mandateType`(`id`, `code`)
VALUES VALUES
(1, 'B2B'), (1, 'B2B'),
(2, 'CORE'), (2, 'CORE'),
@ -3945,11 +3945,11 @@ VALUES
(35, 'ES12346B12345679', 3, 241); (35, 'ES12346B12345679', 3, 241);
INSERT INTO vn.accountDetailType INSERT INTO vn.accountDetailType
(id, description) (id, description, code)
VALUES VALUES
(1, 'IBAN'), (1, 'IBAN', 'iban'),
(2, 'SWIFT'), (2, 'SWIFT', 'swift'),
(3, 'Referencia Remesas'), (3, 'Referencia Remesas', 'remRef'),
(4, 'Referencia Transferencias'), (4, 'Referencia Transferencias', 'trnRef'),
(5, 'Referencia Nominas'), (5, 'Referencia Nominas', 'payRef'),
(6, 'ABA'); (6, 'ABA', 'aba');

View File

@ -1,13 +1,9 @@
DELIMITER $$ DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `srt`.`moving_clean` CREATE OR REPLACE DEFINER=`root`@`localhost` EVENT `srt`.`moving_clean`
ON SCHEDULE EVERY 5 MINUTE ON SCHEDULE EVERY 15 MINUTE
STARTS '2022-01-21 00:00:00.000' STARTS '2022-01-21 00:00:00.000'
ON COMPLETION PRESERVE ON COMPLETION PRESERVE
ENABLE ENABLE
COMMENT 'Llama a srt.moving_clean para que elimine y notifique de registr' COMMENT 'Llama a srt.moving_clean para que elimine y notifique de registr'
DO BEGIN DO CALL srt.moving_clean()$$
CALL srt.moving_clean();
END$$
DELIMITER ; DELIMITER ;

View File

@ -3,61 +3,69 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `srt`.`moving_clean`()
BEGIN BEGIN
/** /**
* Elimina movimientos por inactividad * Elimina movimientos por inactividad
*
*/ */
DECLARE vExpeditionFk INT; DECLARE vExpeditionFk INT;
DECLARE vBufferToFk INT;
DECLARE vBufferFromFk INT; DECLARE vBufferFromFk INT;
DECLARE done BOOL DEFAULT FALSE; DECLARE vStateOutFk INT
DEFAULT (SELECT id FROM expeditionState WHERE `description` = 'OUT');
DECLARE cur CURSOR FOR DECLARE vDone BOOL;
SELECT m.expeditionFk, m.bufferToFk, m.bufferFromFk DECLARE vSorter CURSOR FOR
FROM srt.moving m SELECT m.expeditionFk, m.bufferFromFk
JOIN srt.config c FROM moving m
JOIN (SELECT bufferFk, SUM(isActive) hasBox JOIN (
FROM srt.photocell SELECT bufferFk, SUM(isActive) hasBox
GROUP BY bufferFk) sub ON sub.bufferFk = m.bufferFromFk FROM photocell
WHERE m.created < TIMESTAMPADD(MINUTE, - c.movingMaxLife , util.VN_NOW()) GROUP BY bufferFk
) sub ON sub.bufferFk = m.bufferFromFk
WHERE m.created < (util.VN_NOW() - INTERVAL (SELECT movingMaxLife FROM config) MINUTE)
AND NOT sub.hasBox; AND NOT sub.hasBox;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET done = 1; DECLARE CONTINUE HANDLER FOR NOT FOUND SET vDone = TRUE;
OPEN cur; DECLARE EXIT HANDLER FOR SQLEXCEPTION
BEGIN
ROLLBACK;
RESIGNAL;
END;
bucle: LOOP OPEN vSorter;
l: LOOP
SET vDone = FALSE;
FETCH vSorter INTO vExpeditionFk, vBufferFromFk;
FETCH cur INTO vExpeditionFk, vBufferToFk, vBufferFromFk; IF vDone THEN
LEAVE l;
IF done THEN
LEAVE bucle;
END IF; END IF;
DELETE FROM srt.moving START TRANSACTION;
SELECT id
FROM moving
WHERE expeditionFk = vExpeditionFk
FOR UPDATE;
DELETE FROM moving
WHERE expeditionFk = vExpeditionFk; WHERE expeditionFk = vExpeditionFk;
UPDATE srt.expedition e SELECT id
JOIN srt.expeditionState es ON es.description = 'OUT' FROM expedition
SET WHERE id = vExpeditionFk
bufferFk = NULL, OR (bufferFk = vBufferFromFk AND `position` > 0)
FOR UPDATE;
UPDATE expedition
SET bufferFk = NULL,
`position` = NULL, `position` = NULL,
stateFk = es.id stateFk = vStateOutFk
WHERE e.id = vExpeditionFk; WHERE id = vExpeditionFk;
UPDATE srt.expedition e UPDATE expedition
SET e.`position` = e.`position` - 1 SET `position` = `position` - 1
WHERE e.bufferFk = vBufferFromFk WHERE bufferFk = vBufferFromFk
AND e.`position` > 0; AND `position` > 0;
CALL vn.mail_insert(
'pako@verdnatura.es, carles@verdnatura.es',
NULL,
CONCAT('Moving_clean. Expedition: ', vExpeditionFk, ' estaba parada'),
CONCAT('Expedition: ', vExpeditionFk,' vBufferToFk: ', vBufferToFk)
);
END LOOP bucle;
CLOSE cur;
COMMIT;
END LOOP l;
CLOSE vSorter;
END$$ END$$
DELIMITER ; DELIMITER ;

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`roadmap_beforeInsert`
BEFORE INSERT ON `roadmap`
FOR EACH ROW
BEGIN
IF NEW.driver1Fk IS NOT NULL THEN
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
ELSE
SET NEW.driverName = NULL;
END IF;
END$$
DELIMITER ;

View File

@ -0,0 +1,12 @@
DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate`
BEFORE UPDATE ON `roadmap`
FOR EACH ROW
BEGIN
IF NEW.driver1Fk IS NOT NULL THEN
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
ELSE
SET NEW.driverName = NULL;
END IF;
END$$
DELIMITER ;

View File

@ -2,5 +2,5 @@ CREATE OR REPLACE DEFINER=`root`@`localhost`
SQL SECURITY DEFINER SQL SECURITY DEFINER
VIEW `vn2008`.`mandato_tipo` VIEW `vn2008`.`mandato_tipo`
AS SELECT `m`.`id` AS `idmandato_tipo`, AS SELECT `m`.`id` AS `idmandato_tipo`,
`m`.`name` AS `Nombre` `m`.`code` AS `Nombre`
FROM `vn`.`mandateType` `m` FROM `vn`.`mandateType` `m`

View File

@ -0,0 +1 @@
ALTER TABLE srt.moving DROP INDEX moving_fk1_idx;

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.mandateType
CHANGE name code VARCHAR(45) NOT NULL,
ADD UNIQUE (code);

View File

@ -0,0 +1,3 @@
ALTER TABLE vn.accountDetailType
ADD COLUMN code VARCHAR(45) NOT NULL,
ADD UNIQUE (code);

View File

@ -0,0 +1,9 @@
UPDATE vn.accountDetailType
SET code = CASE description
WHEN 'IBAN' THEN 'iban'
WHEN 'SWIFT' THEN 'swift'
WHEN 'Referencia Remesas' THEN 'remRef'
WHEN 'Referencia Transferencias' THEN 'trnRef'
WHEN 'Referencia Nominas' THEN 'payRef'
WHEN 'ABA' THEN 'aba'
END;

View File

@ -0,0 +1,6 @@
ALTER TABLE vn.roadmap
ADD COLUMN m3 INT UNSIGNED NULL,
ADD COLUMN driver2Fk INT UNSIGNED NULL,
ADD COLUMN driver1Fk INT UNSIGNED NULL,
ADD CONSTRAINT roadmap_worker_FK FOREIGN KEY (driver1Fk) REFERENCES vn.worker(id) ON DELETE RESTRICT ON UPDATE CASCADE,
ADD CONSTRAINT roadmap_worker_FK_2 FOREIGN KEY (driver2Fk) REFERENCES vn.worker(id) ON DELETE RESTRICT ON UPDATE CASCADE;

View File

@ -27,7 +27,7 @@ module.exports = Self => {
// Renew mandate // Renew mandate
if (mandate) { if (mandate) {
const mandateType = await models.MandateType.findOne({ const mandateType = await models.MandateType.findOne({
where: {name: mandate.type} where: {code: mandate.type}
}); });
const oldMandate = await models.Mandate.findOne({ const oldMandate = await models.Mandate.findOne({

View File

@ -12,7 +12,7 @@
"type": "number", "type": "number",
"description": "Identifier" "description": "Identifier"
}, },
"name": { "code": {
"type": "string" "type": "string"
} }
} }

View File

@ -26,7 +26,7 @@
<vn-tr ng-repeat="mandate in mandates"> <vn-tr ng-repeat="mandate in mandates">
<vn-td number>{{::mandate.id}}</vn-td> <vn-td number>{{::mandate.id}}</vn-td>
<vn-td>{{::mandate.company.code}}</vn-td> <vn-td>{{::mandate.company.code}}</vn-td>
<vn-td>{{::mandate.mandateType.name}}</vn-td> <vn-td>{{::mandate.mandateType.code}}</vn-td>
<vn-td shrink-datetime>{{::mandate.created | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}}</vn-td> <vn-td shrink-datetime>{{::mandate.created | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}}</vn-td>
<vn-td shrink-datetime>{{::mandate.finished | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}}</vn-td> <vn-td shrink-datetime>{{::mandate.finished | date:'dd/MM/yyyy HH:mm' | dashIfEmpty}}</vn-td>
</vn-tr> </vn-tr>

View File

@ -9,7 +9,7 @@ class Controller extends Section {
{ {
relation: 'mandateType', relation: 'mandateType',
scope: { scope: {
fields: ['id', 'name'] fields: ['id', 'code']
} }
}, { }, {
relation: 'company', relation: 'company',