refs #4856 manejo errores
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
6a0bca1a94
commit
a44a640d15
|
@ -82,14 +82,9 @@ module.exports = Self => {
|
||||||
updated: Date.vnNew(), state: 'SENDED'
|
updated: Date.vnNew(), state: 'SENDED'
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(
|
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||||
`CALL vn.timeControl_calculateByUser(?, ?, ?)
|
|
||||||
`, [args.workerId, started, ended]);
|
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
stmt = new ParameterizedSQL('CREATE TEMPORARY TABLE tmp.`user` SELECT id userFk FROM account.user WHERE id = vUserFk', [args.workerId]);
|
||||||
stmt = new ParameterizedSQL(
|
|
||||||
`CALL vn.timeBusiness_calculateByUser(?, ?, ?)
|
|
||||||
`, [args.workerId, started, ended]);
|
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
} else {
|
} else {
|
||||||
await models.WorkerTimeControl.destroyAll({
|
await models.WorkerTimeControl.destroyAll({
|
||||||
|
@ -105,13 +100,27 @@ module.exports = Self => {
|
||||||
updated: Date.vnNew(), state: 'SENDED'
|
updated: Date.vnNew(), state: 'SENDED'
|
||||||
}, myOptions);
|
}, myOptions);
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`CALL vn.timeControl_calculateAll(?, ?)`, [started, ended]);
|
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
|
stmt = new ParameterizedSQL('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');
|
||||||
stmt = new ParameterizedSQL(`CALL vn.timeBusiness_calculateAll(?, ?)`, [started, ended]);
|
|
||||||
stmts.push(stmt);
|
stmts.push(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`CALL vn.timeControl_calculate(?, ?)
|
||||||
|
`, [started, ended]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`CALL vn.timeControl_getError(?, ?)
|
||||||
|
`, [started, ended]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
|
stmt = new ParameterizedSQL(
|
||||||
|
`CALL vn.timeBusiness_calculate(?, ?)
|
||||||
|
`, [started, ended]);
|
||||||
|
stmts.push(stmt);
|
||||||
|
|
||||||
stmt = new ParameterizedSQL(`
|
stmt = new ParameterizedSQL(`
|
||||||
SELECT CONCAT(u.name, '@verdnatura.es') receiver,
|
SELECT CONCAT(u.name, '@verdnatura.es') receiver,
|
||||||
u.id workerFk,
|
u.id workerFk,
|
||||||
|
@ -131,7 +140,13 @@ module.exports = Self => {
|
||||||
JOIN business b ON b.id = tb.businessFk
|
JOIN business b ON b.id = tb.businessFk
|
||||||
LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated
|
LEFT JOIN tmp.timeControlCalculate tc ON tc.userFk = tb.userFk AND tc.dated = tb.dated
|
||||||
LEFT JOIN worker w ON w.id = u.id
|
LEFT JOIN worker w ON w.id = u.id
|
||||||
WHERE IFNULL(?, u.id) = u.id
|
LEFT JOIN (
|
||||||
|
SELECT DISTINCT wtc.userFk
|
||||||
|
FROM tmp.timeControlError tce
|
||||||
|
JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
|
||||||
|
)sub ON sub.userFk = tb.userFk
|
||||||
|
WHERE sub.userFK IS NULL
|
||||||
|
AND IFNULL(?, u.id) = u.id
|
||||||
AND b.companyCodeFk = 'VNL'
|
AND b.companyCodeFk = 'VNL'
|
||||||
AND w.businessFk
|
AND w.businessFk
|
||||||
AND d.isTeleworking
|
AND d.isTeleworking
|
||||||
|
@ -322,11 +337,9 @@ module.exports = Self => {
|
||||||
|
|
||||||
const lastDay = days[index][days[index].length - 1];
|
const lastDay = days[index][days[index].length - 1];
|
||||||
if (day.workerFk != previousWorkerFk || day == lastDay) {
|
if (day.workerFk != previousWorkerFk || day == lastDay) {
|
||||||
await models.WorkerTimeControlMail.create({
|
const query = `INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week)
|
||||||
workerFk: previousWorkerFk,
|
VALUES(?, ?, ?);`;
|
||||||
year: args.year,
|
await Self.rawSql(query, [previousWorkerFk, args.year, args.week]);
|
||||||
week: args.week
|
|
||||||
}, myOptions);
|
|
||||||
|
|
||||||
ctx.args = {
|
ctx.args = {
|
||||||
recipient: previousReceiver,
|
recipient: previousReceiver,
|
||||||
|
@ -351,6 +364,21 @@ module.exports = Self => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// await Self.rawSql('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||||
|
await Self.rawSql('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');
|
||||||
|
|
||||||
|
await Self.rawSql(`CALL vn.timeControl_getError(?, ?);`, [started, ended]);
|
||||||
|
const query = `INSERT INTO mail (receiver, replyTo, subject, body)
|
||||||
|
SELECT CONCAT(u.name, '@verdnatura.es'),
|
||||||
|
CONCAT('Error registro de horas semana ', vWeek, ' año ', vYear) ,
|
||||||
|
CONCAT('No se ha podido enviar el registro de horas al empleado/s: ', GROUP_CONCAT(DISTINCT CONCAT('<br>', w.id, ' ', w.firstName, ' ', w.lastName)))
|
||||||
|
FROM tmp.timeControlError tce
|
||||||
|
JOIN vn.workerTimeControl wtc ON wtc.id = tce.id
|
||||||
|
JOIN worker w ON w.id = wtc.userFK
|
||||||
|
JOIN account.user u ON u.id = w.bossFk
|
||||||
|
GROUP BY w.bossFk;`;
|
||||||
|
await Self.rawSql(query, [previousWorkerFk, args.year, args.week]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue