2024-01-15 11:31:03 +00:00
|
|
|
DELIMITER $$
|
2024-08-20 08:06:10 +00:00
|
|
|
CREATE OR REPLACE DEFINER=`vn`@`localhost` PROCEDURE `vn`.`timeBusiness_calculateByDepartment`(vDepartmentFk INT, vDatedFrom DATETIME, vDatedTo DATETIME)
|
2024-01-15 11:31:03 +00:00
|
|
|
BEGIN
|
|
|
|
/**
|
|
|
|
* @param vDepartmentFk
|
|
|
|
* @param vDatedFrom workerTimeControl
|
|
|
|
* @param vDatedTo workerTimeControl
|
|
|
|
*/
|
|
|
|
DROP TEMPORARY TABLE IF EXISTS tmp.`user`;
|
|
|
|
|
|
|
|
CREATE TEMPORARY TABLE tmp.`user`
|
|
|
|
SELECT DISTINCT b.workerFk userFk
|
|
|
|
FROM business AS b
|
|
|
|
WHERE (b.started BETWEEN vDatedFrom AND vDatedTo
|
|
|
|
OR IFNULL(b.ended, vDatedTo) BETWEEN vDatedFrom AND vDatedTo
|
|
|
|
OR (b.started <= vDatedFrom AND b.ended >= vDatedTo)
|
|
|
|
) AND b.departmentFk = vDepartmentFk
|
|
|
|
ORDER BY b.ended DESC;
|
|
|
|
|
|
|
|
CALL timeBusiness_calculate(vDatedFrom, vDatedTo);
|
|
|
|
|
|
|
|
DROP TEMPORARY TABLE tmp.`user`;
|
|
|
|
|
|
|
|
END$$
|
|
|
|
DELIMITER ;
|