feat: refs #8227 Roadmap changes #3372
|
@ -2749,13 +2749,13 @@ INSERT INTO `vn`.`roadmapAddress` (`addressFk`)
|
||||||
(3),
|
(3),
|
||||||
(4);
|
(4);
|
||||||
|
|
||||||
INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `userFk`, `price`, `driverName`)
|
INSERT INTO `vn`.`roadmap` (`id`, `name`, `tractorPlate`, `trailerPlate`, `phone`, `supplierFk`, `etd`, `observations`, `editorFk`, `price`, `driverName`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 'val-algemesi', '1234-BCD', '9876-BCD', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'),
|
(1, 'val-algemesi', '1234-BCD', '9876-BCD', '111111111', 1, util.VN_NOW(), 'this is test observation', 1, 15, 'Batman'),
|
||||||
(2, 'alg-valencia', '2345-CDF', '8765-BCD', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'),
|
(2, 'alg-valencia', '2345-CDF', '8765-BCD', '111111111', 1, util.VN_NOW(), 'test observation', 1, 20, 'Robin'),
|
||||||
(3, 'alz-algemesi', '3456-DFG', '7654-BCD', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman');
|
(3, 'alz-algemesi', '3456-DFG', '7654-BCD', '222222222', 2, DATE_ADD(util.VN_NOW(), INTERVAL 2 DAY), 'observations...', 2, 25, 'Driverman');
|
||||||
|
|
||||||
INSERT INTO `vn`.`roadmapStop` (`id`, `roadmapFk`, `addressFk`, `eta`, `description`, `userFk`)
|
INSERT INTO `vn`.`roadmapStop` (`id`, `roadmapFk`, `addressFk`, `eta`, `description`, `editorFk`)
|
||||||
VALUES
|
VALUES
|
||||||
(1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1),
|
(1, 1, 1, DATE_ADD(util.VN_NOW(), INTERVAL 1 DAY), 'Best truck in fleet', 1),
|
||||||
(2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1),
|
(2, 1, 2, DATE_ADD(util.VN_NOW(), INTERVAL '1 2' DAY_HOUR), 'Second truck in fleet', 1),
|
||||||
|
|
|
@ -1,17 +1,30 @@
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(vNumberPlate VARCHAR(10), vCountryCodeFk VARCHAR(2))
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`vehicle_checkNumberPlate`(
|
||||||
|
vNumberPlate VARCHAR(10),
|
||||||
|
vCountryCodeFk VARCHAR(2)
|
||||||
|
)
|
||||||
BEGIN
|
BEGIN
|
||||||
/**
|
/**
|
||||||
* Comprueba si la matricula pasada tiene el formato correcto dependiendo del pais del vehiculo
|
* Comprueba si la matricula pasada tiene el formato
|
||||||
|
* correcto dependiendo del pais del vehiculo.
|
||||||
|
*
|
||||||
|
* @param vNumberPlate Número de matricula
|
||||||
|
* @param vCountryCodeFk Código de pais
|
||||||
*/
|
*/
|
||||||
DECLARE vRegex VARCHAR(45);
|
DECLARE vRegex VARCHAR(45);
|
||||||
|
|
||||||
SELECT vp.regex INTO vRegex
|
IF vCountryCodeFk IS NULL THEN
|
||||||
FROM vehiclePlateRegex vp
|
SET vRegex = '^[A-Z0-9 -]{6,12}$';
|
||||||
WHERE vp.countryCodeFk = vCountryCodeFk;
|
ELSE
|
||||||
|
SELECT regex INTO vRegex
|
||||||
|
FROM vehiclePlateRegex
|
||||||
|
WHERE countryCodeFk = vCountryCodeFk;
|
||||||
|
END IF;
|
||||||
|
|
||||||
IF NOT vNumberPlate REGEXP BINARY (vRegex)THEN
|
IF NOT vNumberPlate REGEXP BINARY (vRegex)THEN
|
||||||
CALL util.throw(CONCAT('Error: la matricula ', vNumberPlate, ' no es valida para ',vCountryCodeFk));
|
CALL util.throw(CONCAT('La matricula ', vNumberPlate,
|
||||||
|
' no es valida', IF(vCountryCodeFk IS NOT NULL,
|
||||||
|
CONCAT(' para ', vCountryCodeFk), '')));
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,8 +3,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmapStop_beforeInser
|
||||||
BEFORE INSERT ON `roadmapStop`
|
BEFORE INSERT ON `roadmapStop`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
SET NEW.description = UCASE(NEW.description);
|
SET NEW.description = UCASE(NEW.description);
|
||||||
|
IF NEW.roadmapFk IS NOT NULL THEN
|
||||||
|
IF NEW.eta < (SELECT etd FROM roadmap WHERE id = NEW.roadmapFk) THEN
|
||||||
|
CALL util.throw('Departure time can not be after arrival time');
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,8 +3,14 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmapStop_beforeUpdat
|
||||||
BEFORE UPDATE ON `roadmapStop`
|
BEFORE UPDATE ON `roadmapStop`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
SET NEW.description = UCASE(NEW.description);
|
SET NEW.description = UCASE(NEW.description);
|
||||||
|
IF (NOT (NEW.roadmapFk <=> OLD.roadmapFk) AND NEW.roadmapFk IS NOT NULL)
|
||||||
|
OR (NOT (NEW.eta <=> OLD.eta) AND NEW.eta IS NOT NULL) THEN
|
||||||
|
|
||||||
|
IF NEW.eta < (SELECT etd FROM roadmap WHERE id = NEW.roadmapFk) THEN
|
||||||
|
CALL util.throw('Departure time can not be after arrival time');
|
||||||
|
END IF;
|
||||||
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
|
@ -3,10 +3,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeInsert`
|
||||||
BEFORE INSERT ON `roadmap`
|
BEFORE INSERT ON `roadmap`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
IF NEW.driver1Fk IS NOT NULL THEN
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
|
IF NEW.tractorPlate IS NOT NULL THEN
|
||||||
ELSE
|
CALL vehicle_checkNumberPlate(NEW.tractorPlate, NULL);
|
||||||
SET NEW.driverName = NULL;
|
END IF;
|
||||||
|
IF NEW.trailerPlate IS NOT NULL THEN
|
||||||
|
CALL vehicle_checkNumberPlate(NEW.trailerPlate, NULL);
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -3,10 +3,12 @@ CREATE OR REPLACE DEFINER=`vn`@`localhost` TRIGGER `vn`.`roadmap_beforeUpdate`
|
||||||
BEFORE UPDATE ON `roadmap`
|
BEFORE UPDATE ON `roadmap`
|
||||||
FOR EACH ROW
|
FOR EACH ROW
|
||||||
BEGIN
|
BEGIN
|
||||||
IF NEW.driver1Fk IS NOT NULL THEN
|
SET NEW.editorFk = account.myUser_getId();
|
||||||
SET NEW.driverName = (SELECT firstName FROM worker WHERE id = NEW.driver1Fk);
|
IF NEW.tractorPlate IS NOT NULL THEN
|
||||||
ELSE
|
CALL vehicle_checkNumberPlate(NEW.tractorPlate, NULL);
|
||||||
SET NEW.driverName = NULL;
|
END IF;
|
||||||
|
IF NEW.trailerPlate IS NOT NULL THEN
|
||||||
|
CALL vehicle_checkNumberPlate(NEW.trailerPlate, NULL);
|
||||||
END IF;
|
END IF;
|
||||||
END$$
|
END$$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
|
@ -0,0 +1,5 @@
|
||||||
|
ALTER TABLE vn.roadmap
|
||||||
|
MODIFY COLUMN m3 int(10) unsigned DEFAULT NULL NULL COMMENT 'Capacidad máxima del remolque',
|
||||||
|
CHANGE driver1Fk driverFk int(10) unsigned DEFAULT NULL NULL COMMENT 'Conductor principal' AFTER driverName,
|
||||||
|
CHANGE driver2Fk codriverFk int(10) unsigned DEFAULT NULL NULL COMMENT 'Copiloto' AFTER driverFk,
|
||||||
|
CHANGE userFk editorFk int(10) unsigned DEFAULT NULL NULL AFTER m3;
|
|
@ -0,0 +1 @@
|
||||||
|
ALTER TABLE vn.roadmapStop CHANGE userFk editorFk int(10) unsigned DEFAULT NULL NULL;
|
|
@ -0,0 +1,4 @@
|
||||||
|
ALTER TABLE vn.route
|
||||||
|
ADD roadmapStopFk int(11) NULL,
|
||||||
|
ADD CONSTRAINT route_roadmapStop_FK FOREIGN KEY (roadmapStopFk) REFERENCES vn.roadmapStop(id) ON DELETE RESTRICT ON UPDATE CASCADE,
|
||||||
|
CHANGE editorFk editorFk int(10) unsigned DEFAULT NULL NULL AFTER roadmapStopFk;
|
Loading…
Reference in New Issue