refs #5843 edit structure
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Satorres 2023-08-22 12:50:27 +02:00
parent b1b6bd13ea
commit 91c6ab9e44
3 changed files with 60 additions and 66 deletions

View File

@ -0,0 +1,5 @@
ALTER TABLE `vn`.`workerDocument` DROP FOREIGN KEY `workerDocument_ibfk_1`;
ALTER TABLE `vn`.`worker` DROP KEY `user_id_UNIQUE`;
ALTER TABLE `vn`.`worker` DROP COLUMN `userFk`;

View File

@ -87,8 +87,8 @@ INSERT INTO `vn`.`educationLevel` (`id`, `name`)
(1, 'ESTUDIOS PRIMARIOS COMPLETOS'),
(2, 'ENSEÑANZAS DE BACHILLERATO');
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `userFk`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, id, 9
INSERT INTO `vn`.`worker`(`id`,`code`, `firstName`, `lastName`, `bossFk`)
SELECT id,UPPER(LPAD(role, 3, '0')), name, name, 9
FROM `account`.`user`;
UPDATE `vn`.`worker` SET bossFk = NULL WHERE id = 20;
@ -188,13 +188,13 @@ INSERT INTO `vn`.`printer` (`id`, `name`, `path`, `isLabeler`, `sectorFk`, `ipAd
UPDATE `vn`.`sector` SET mainPrinterFk = 1 WHERE id = 1;
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`, `userFk`,`bossFk`, `phone`)
INSERT INTO `vn`.`worker`(`id`, `code`, `firstName`, `lastName`,`bossFk`, `phone`)
VALUES
(1106, 'LGN', 'David Charles', 'Haller', 1106, 19, 432978106),
(1107, 'ANT', 'Hank' , 'Pym' , 1107, 19, 432978107),
(1108, 'DCX', 'Charles' , 'Xavier', 1108, 19, 432978108),
(1109, 'HLK', 'Bruce' , 'Banner', 1109, 19, 432978109),
(1110, 'JJJ', 'Jessica' , 'Jones' , 1110, 19, 432978110);
(1106, 'LGN', 'David Charles', 'Haller', 19, 432978106),
(1107, 'ANT', 'Hank' , 'Pym' , 19, 432978107),
(1108, 'DCX', 'Charles' , 'Xavier', 19, 432978108),
(1109, 'HLK', 'Bruce' , 'Banner', 19, 432978109),
(1110, 'JJJ', 'Jessica' , 'Jones' , 19, 432978110);
INSERT INTO `vn`.`parking` (`id`, `column`, `row`, `sectorFk`, `code`, `pickingOrder`)
VALUES

View File

@ -24465,7 +24465,7 @@ BEGIN
CONCAT('Cliente ', NEW.id),
CONCAT('Recibida la documentación: ', vText)
FROM worker w
LEFT JOIN account.user u ON w.userFk = u.id AND u.active
LEFT JOIN account.user u ON w.id = u.id AND u.active
LEFT JOIN account.account ac ON ac.id = u.id
WHERE w.id = NEW.salesPersonFk;
END IF;
@ -45621,7 +45621,7 @@ BEGIN
SELECT code INTO vUserCode
FROM worker
WHERE userFk = account.myUser_getId();
WHERE id = account.myUser_getId();
RETURN vUserCode;
END ;;
@ -48037,22 +48037,22 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` FUNCTION `workerIsBoss`(vUserId INT) RETURNS int(11)
CREATE DEFINER=`root`@`localhost` FUNCTION `workerIsBoss`(vSelf INT) RETURNS int(11)
DETERMINISTIC
BEGIN
/**
* Comprueba por jerarquía si el trabajador actual es jefe
* de un trabajador en concreto.
*
* @param vUserId Id del trabajador que se desea comprobar.
* @param vSelf Id del trabajador que se desea comprobar.
* @return Revuelve verdadero si es jefe del empleado por escala jerárquica.
*/
DECLARE vWorkerId INT;
DECLARE vBossId INT;
SELECT id INTO vWorkerId
FROM vn.worker
WHERE userFk = vUserId;
FROM worker
WHERE id = vSelf;
IF vWorkerId IS NULL THEN
CALL util.throw('USER_NOT_FOUND');
END IF;
@ -48064,7 +48064,7 @@ BEGIN
SELECT id workerFk FROM worker LIMIT 0;
LOOP
SELECT bossFk INTO vBossId
FROM vn.worker
FROM worker
WHERE id = vWorkerId;
IF (SELECT COUNT(*) FROM tCheckedWorker WHERE workerFk = vBossId) THEN
CALL util.throw('INFINITE_LOOP');
@ -64369,7 +64369,7 @@ proc: BEGIN
SELECT isTodayRelative INTO vIsTodayRelative
FROM worker
WHERE userFk = getUser();
WHERE id = getUser();
CALL prepareTicketList( util.VN_CURDATE() - INTERVAL 1 DAY, vEndingDate);
@ -70656,7 +70656,7 @@ DELIMITER ;
/*!50003 SET @saved_sql_mode = @@sql_mode */ ;
/*!50003 SET sql_mode = 'IGNORE_SPACE,NO_ENGINE_SUBSTITUTION' */ ;
DELIMITER ;;
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneWeekly`(IN vWeek INT)
CREATE DEFINER=`root`@`localhost` PROCEDURE `ticket_cloneWeekly`(vWeek INT)
BEGIN
DECLARE vIsDone BOOL;
DECLARE vLanding DATE;
@ -70742,8 +70742,7 @@ BEGIN
SELECT e.email INTO vSalesPersonEmail
FROM vn.client c
JOIN vn.worker sp ON sp.id = c.salesPersonFk
JOIN account.emailUser e ON e.userFk = sp.userFk
JOIN account.emailUser e ON e.userFk = c.salesPersonFk
WHERE c.id = vClientFk;
SET vSubject = CONCAT('Turnos - No se ha podido clonar correctamente el ticket ', vTicketFk,
@ -72839,7 +72838,7 @@ BEGIN
isAllowedToWork
FROM(SELECT t.dated,
b.id businessFk,
w.userFk,
w.id,
b.departmentFk,
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.started,5) ORDER BY bs.started ASC SEPARATOR ' - ')) hourStart ,
IF(bs.started = NULL, NULL, GROUP_CONCAT(DISTINCT LEFT(bs.ended,5) ORDER BY bs.ended ASC SEPARATOR ' - ')) hourEnd,
@ -72849,18 +72848,19 @@ BEGIN
at2.permissionRate,
at2.discountRate,
ct.hoursWeek hoursWeek,
at2.isAllowedToWork
at2.isAllowedToWork,
u.userFk
FROM time t
LEFT JOIN business b ON t.dated BETWEEN b.started AND IFNULL(b.ended, vDatedTo)
LEFT JOIN worker w ON w.id = b.workerFk
JOIN tmp.`user` u ON u.userFK = w.userFK
JOIN tmp.`user` u ON u.userFK = w.id
LEFT JOIN workCenter wc ON wc.id = b.workcenterFK
LEFT JOIN calendarType ct ON ct.id = b.calendarTypeFk
LEFT JOIN businessSchedule bs ON bs.businessFk = b.id AND bs.weekday = WEEKDAY(t.dated) + 1
LEFT JOIN calendar c ON c.businessFk = b.id AND c.dated = t.dated
LEFT JOIN absenceType at2 ON at2.id = c.dayOffTypeFk
WHERE t.dated BETWEEN vDatedFrom AND vDatedTo
GROUP BY w.userFk, t.dated
GROUP BY w.id, t.dated
)sub;
UPDATE tmp.timeBusinessCalculate t
@ -72913,13 +72913,9 @@ BEGIN
* @param vDatedTo workerTimeControl
*/
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
SELECT userFk
FROM vn.worker w
JOIN account.`user` u ON u.id = w.userFk
WHERE userFk IS NOT NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.`user`
SELECT w.id userFk
FROM vn.worker w;
CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo);
@ -73023,15 +73019,12 @@ BEGIN
* @param vDatedTo workerTimeControl
*/
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
CREATE OR REPLACE TEMPORARY TABLE tmp.`user`
SELECT w.id userFk
FROM worker w
WHERE w.id = vWorkerFk;
CREATE TEMPORARY TABLE tmp.`user`
SELECT u.id userFk
FROM account.user u
JOIN vn.worker w ON w.userFk = u.id
WHERE w.id = vWorkerFk;
CALL vn.timeBusiness_calculate(vDatedFrom, vDatedTo);
CALL timeBusiness_calculate(vDatedFrom, vDatedTo);
DROP TEMPORARY TABLE tmp.`user`;
@ -73273,13 +73266,9 @@ BEGIN
* @param vDatedTo workerTimeControl
*/
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user`
SELECT userFk
FROM vn.worker w
JOIN account.`user` u ON u.id = w.userFk
WHERE userFk IS NOT NULL;
CREATE OR REPLACE TEMPORARY TABLE tmp.`user`
SELECT w.id userFk
FROM vn.worker w;
CALL vn.timeControl_calculate(vDatedFrom, vDatedTo);
@ -74723,8 +74712,8 @@ BEGIN
* Create new worker
*
*/
INSERT INTO worker(id, code, firstName, lastName, userFk, bossFk, fi, birth)
VALUES (vUserFk, vCode, vFirstname, vLastName, vUserFk, vBossFk, vFi, vBirth);
INSERT INTO worker(id, code, firstName, lastName, bossFk, fi, birth)
VALUES (vUserFk, vCode, vFirstname, vLastName, vBossFk, vFi, vBirth);
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -74765,8 +74754,8 @@ BEGIN
SET vSurnames = CONCAT(vSurname1, ' ', vSurname2);
END IF;
INSERT INTO worker(id, firstName, lastName, code, userFk, isFreelance)
SELECT vUserId, vFirstName, vSurnames, vWorkerCode, vUserId, true;
INSERT INTO worker(id, firstName, lastName, code, isFreelance)
SELECT vUserId, vFirstName, vSurnames, vWorkerCode, true;
END ;;
DELIMITER ;
/*!50003 SET sql_mode = @saved_sql_mode */ ;
@ -74789,7 +74778,7 @@ BEGIN
DROP TEMPORARY TABLE IF EXISTS tmp.workerDepartmentByDate;
CREATE TEMPORARY TABLE tmp.workerDepartmentByDate
ENGINE = MEMORY
SELECT w.userFk,
SELECT w.id,
w.lastName name,
w.firstName firstname,
d.name department,
@ -75490,7 +75479,7 @@ BEGIN
LIMIT 10000000000000000000)sub
GROUP BY cont
HAVING cont2 MOD 2 = 1
)sub2
)sub2;
JOIN worker w ON w.userFk = sub2.userFk;
END ;;
DELIMITER ;
@ -76550,10 +76539,10 @@ BEGIN
w.lastName,
w.firstname,
c.fi,
w.id,
w.id userFk,
MONTHNAME(t.dated) mes,
YEAR(t.dated) año,
w.userFk,
w.id,
tm.hoursWeek,
tm.type,
b.started,
@ -78136,7 +78125,7 @@ CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`zone_getLeaves`(
vSearch VARCHAR(255),
vHasInsert BOOL
)
BEGIN
BEGIN
/**
* Devuelve las ubicaciones incluidas en la ruta y que sean hijos de parentFk.
* @param vSelf Id de la zona
@ -78151,23 +78140,23 @@ BEGIN
CREATE OR REPLACE TEMPORARY TABLE tNodes
(UNIQUE (id))
ENGINE = MEMORY
SELECT id
FROM zoneGeo
SELECT id
FROM zoneGeo
LIMIT 0;
IF vIsSearch THEN
SET vIsNumber = vSearch REGEXP '^[0-9]+$';
INSERT INTO tNodes
SELECT id
SELECT id
FROM zoneGeo
WHERE (vIsNumber AND `name` = vSearch)
OR (!vIsNumber AND `name` LIKE CONCAT('%', vSearch, '%'))
LIMIT 1000;
ELSEIF vParentFk IS NULL THEN
INSERT INTO tNodes
SELECT geoFk
SELECT geoFk
FROM zoneIncluded
WHERE zoneFk = vSelf;
END IF;
@ -78190,25 +78179,25 @@ BEGIN
FROM zoneGeo g
JOIN tChilds c ON c.id = g.id
WHERE g.parentFk IS NOT NULL;
INSERT IGNORE INTO tNodes
SELECT id FROM tParents;
IF NOT ROW_COUNT() THEN
LEAVE myLoop;
END IF;
DELETE FROM tChilds;
INSERT INTO tChilds
SELECT id FROM tParents;
END LOOP;
DROP TEMPORARY TABLE tChilds, tParents;
END IF;
IF NOT vIsSearch THEN
INSERT IGNORE INTO tNodes
SELECT id
SELECT id
FROM zoneGeo
WHERE parentFk <=> vParentFk;
END IF;
@ -81824,7 +81813,7 @@ USE `vn`;
/*!50001 SET collation_connection = utf8mb3_general_ci */;
/*!50001 CREATE ALGORITHM=UNDEFINED */
/*!50013 DEFINER=`root`@`localhost` SQL SECURITY DEFINER */
/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on(`w`.`userFk` = `u`.`id`)) join `vn`.`client` `c` on(`c`.`id` = `u`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) */;
/*!50001 VIEW `workerTimeControlUserInfo` AS select `u`.`id` AS `userFk`,`w`.`firstName` AS `name`,`w`.`lastName` AS `surname`,`u`.`name` AS `user`,`u`.`password` AS `password`,`wd`.`departmentFk` AS `departmentFk`,left(`c`.`fi`,8) AS `dni` from (((`account`.`user` `u` join `vn`.`worker` `w` on(`w`.`id` = `u`.`id`)) join `vn`.`client` `c` on(`c`.`id` = `u`.`id`)) left join `vn`.`workerDepartment` `wd` on(`wd`.`workerFk` = `w`.`id`)) */;
/*!50001 SET character_set_client = @saved_cs_client */;
/*!50001 SET character_set_results = @saved_cs_results */;
/*!50001 SET collation_connection = @saved_col_connection */;