1711Eliminar_referencias_vn2008
gitea/salix/1711Eliminar_referencias_vn2008 This commit looks good
Details
gitea/salix/1711Eliminar_referencias_vn2008 This commit looks good
Details
This commit is contained in:
parent
a67f6ec1ae
commit
1ce0c63bf2
|
@ -0,0 +1,26 @@
|
||||||
|
DROP procedure IF EXISTS `vn`.`rangeDateInfo`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE PROCEDURE `vn`.`rangeDateInfo` (vStarted DATE, vEnded DATE)
|
||||||
|
BEGIN
|
||||||
|
/*
|
||||||
|
* Crea una tabla temporal con las fechas
|
||||||
|
* desde una fecha inicial a una final
|
||||||
|
* @vStarted: fecha inicial
|
||||||
|
* @vEnded: fecha final
|
||||||
|
*/
|
||||||
|
DECLARE vDated DATE DEFAULT vStarted;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.rangeDate;
|
||||||
|
CREATE TEMPORARY TABLE tmp.rangeDate(
|
||||||
|
dated DATE
|
||||||
|
)
|
||||||
|
ENGINE = MEMORY;
|
||||||
|
|
||||||
|
WHILE vDated <= vEnded DO
|
||||||
|
INSERT INTO tmp.rangeDate(dated) VALUES(vDated);
|
||||||
|
SET vDated = DATE_ADD(vDated, INTERVAL 1 DAY);
|
||||||
|
END WHILE;
|
||||||
|
END$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
|
|
|
@ -0,0 +1,95 @@
|
||||||
|
|
||||||
|
DROP procedure IF EXISTS `vn`.`timeBusiness_calculate`;
|
||||||
|
|
||||||
|
DELIMITER $$
|
||||||
|
CREATE DEFINER=`root`@`%` PROCEDURE `vn`.`timeBusiness_calculate`(vDatedFrom DATETIME, vDatedTo DATETIME)
|
||||||
|
BEGIN
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Horas que debe trabajar un empleado según contrato y día.
|
||||||
|
* @param vDatedFrom workerTimeControl
|
||||||
|
* @param vDatedTo workerTimeControl
|
||||||
|
* @table tmp.user(userFk)
|
||||||
|
* @return tmp.timeBusinessCalculate
|
||||||
|
*/
|
||||||
|
DECLARE vHoursFullTime INT DEFAULT 40;
|
||||||
|
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate;
|
||||||
|
DROP TEMPORARY TABLE IF EXISTS tmp.businessFullTime;
|
||||||
|
|
||||||
|
CALL rangeDateInfo(vDatedFrom, vDatedTo);
|
||||||
|
|
||||||
|
CREATE TEMPORARY TABLE tmp.timeBusinessCalculate
|
||||||
|
SELECT dated,
|
||||||
|
businessFk,
|
||||||
|
userFk,
|
||||||
|
departmentFk,
|
||||||
|
hourStart,
|
||||||
|
hourEnd,
|
||||||
|
timeWorkSeconds,
|
||||||
|
SEC_TO_TIME(timeWorkSeconds) timeWorkSexagesimal,
|
||||||
|
timeWorkSeconds / 3600 timeWorkDecimal,
|
||||||
|
timeWorkSeconds timeBusinessSeconds,
|
||||||
|
SEC_TO_TIME(timeWorkSeconds) timeBusinessSexagesimal,
|
||||||
|
timeWorkSeconds / 3600 timeBusinessDecimal,
|
||||||
|
type,
|
||||||
|
permissionrate,
|
||||||
|
hoursWeek
|
||||||
|
FROM(SELECT rd.dated,
|
||||||
|
b.business_id businessFk,
|
||||||
|
w.userFk,
|
||||||
|
bl.department_id departmentFk,
|
||||||
|
IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.start,2) ORDER BY j.start ASC SEPARATOR '-')) hourStart ,
|
||||||
|
IF(cl.hours_week = vHoursFullTime, NULL, GROUP_CONCAT(DISTINCT LEFT(j.end,2) ORDER BY j.end ASC SEPARATOR '-')) hourEnd,
|
||||||
|
IF(cl.hours_week = vHoursFullTime, 0, IFNULL(SUM(TIME_TO_SEC(j.end)) - SUM(TIME_TO_SEC(j.start)),0)) timeWorkSeconds,
|
||||||
|
cs.type,
|
||||||
|
cs.permissionRate,
|
||||||
|
cl.hours_week hoursWeek
|
||||||
|
FROM tmp.rangeDate rd
|
||||||
|
LEFT JOIN postgresql.business b ON rd.dated BETWEEN b.date_start AND ifnull(b.date_end, vDatedTo )
|
||||||
|
LEFT JOIN postgresql.profile AS pr ON b.client_id = pr.profile_id
|
||||||
|
LEFT JOIN postgresql.person AS p ON pr.person_id = p.person_id
|
||||||
|
LEFT JOIN vn.worker AS w ON p.id_trabajador = w.id
|
||||||
|
JOIN tmp.`user` u ON u.userFK = w.userFK
|
||||||
|
JOIN postgresql.business_labour AS bl ON b.business_id = bl.business_id
|
||||||
|
LEFT JOIN postgresql.business_labour_payroll AS bp ON bl.business_id = bp.business_id
|
||||||
|
LEFT JOIN postgresql.professional_category AS pc ON bl.professional_category_id = pc.professional_category_id
|
||||||
|
LEFT JOIN postgresql.workcenter AS wc ON bl.workcenter_id = wc.workcenter_id
|
||||||
|
LEFT JOIN postgresql.calendar_labour_type AS cl ON bl.calendar_labour_type_id = cl.calendar_labour_type_id
|
||||||
|
LEFT JOIN postgresql.journey AS j ON j.business_id = b.business_id and j.day_id=WEEKDAY(rd.dated)+1
|
||||||
|
LEFT JOIN postgresql.calendar_employee ce ON ce.business_id=b.business_id and ce.date = rd.dated
|
||||||
|
LEFT JOIN postgresql.calendar_state cs ON cs.calendar_state_id = ce.calendar_state_id
|
||||||
|
WHERE rd.dated BETWEEN vDatedFrom AND vDatedTo
|
||||||
|
GROUP BY w.userFk,dated
|
||||||
|
)sub;
|
||||||
|
|
||||||
|
|
||||||
|
UPDATE tmp.timeBusinessCalculate t
|
||||||
|
SET t.timeWorkSeconds = vHoursFullTime / 5 * 3600,
|
||||||
|
t.timeWorkSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600),
|
||||||
|
t.timeWorkDecimal = vHoursFullTime / 5,
|
||||||
|
t.timeBusinessSeconds = vHoursFullTime / 5 * 3600,
|
||||||
|
t.timeBusinessSexagesimal = SEC_TO_TIME( vHoursFullTime / 5 * 3600),
|
||||||
|
t.timeBusinessDecimal = vHoursFullTime / 5
|
||||||
|
WHERE DAYOFWEEK(t.dated) IN(2,3,4,5,6) AND hoursWeek = vHoursFullTime ;
|
||||||
|
|
||||||
|
UPDATE tmp.timeBusinessCalculate t
|
||||||
|
SET t.timeWorkSeconds = t.timeWorkSeconds - (t.timeWorkSeconds * permissionrate) ,
|
||||||
|
t.timeWorkSexagesimal = SEC_TO_TIME(t.timeWorkSeconds - (t.timeWorkSeconds * permissionrate)),
|
||||||
|
t.timeWorkDecimal = t.timeWorkDecimal - (t.timeWorkDecimal * permissionrate)
|
||||||
|
WHERE permissionrate <> 0;
|
||||||
|
|
||||||
|
UPDATE tmp.timeBusinessCalculate t
|
||||||
|
JOIN postgresql.calendar_labour cl ON cl.day = t.dated
|
||||||
|
JOIN postgresql.business_labour bl ON bl.business_id = t.businessFk AND bl.workcenter_id = cl.workcenter_id
|
||||||
|
SET t.timeWorkSeconds = 0,
|
||||||
|
t.timeWorkSexagesimal = 0,
|
||||||
|
t.timeWorkDecimal = 0,
|
||||||
|
t.permissionrate = 1,
|
||||||
|
t.type = 'Festivo'
|
||||||
|
WHERE t.type IS NULL;
|
||||||
|
|
||||||
|
END$$
|
||||||
|
|
||||||
|
DELIMITER ;
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -53,7 +53,6 @@ dump_tables ${TABLES[@]}
|
||||||
|
|
||||||
TABLES=(
|
TABLES=(
|
||||||
vn2008
|
vn2008
|
||||||
time
|
|
||||||
accion_dits
|
accion_dits
|
||||||
businessReasonEnd
|
businessReasonEnd
|
||||||
container
|
container
|
||||||
|
|
Loading…
Reference in New Issue