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'
|
||||
}, myOptions);
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`CALL vn.timeControl_calculateByUser(?, ?, ?)
|
||||
`, [args.workerId, started, ended]);
|
||||
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`CALL vn.timeBusiness_calculateByUser(?, ?, ?)
|
||||
`, [args.workerId, started, ended]);
|
||||
stmt = new ParameterizedSQL('CREATE TEMPORARY TABLE tmp.`user` SELECT id userFk FROM account.user WHERE id = vUserFk', [args.workerId]);
|
||||
stmts.push(stmt);
|
||||
} else {
|
||||
await models.WorkerTimeControl.destroyAll({
|
||||
|
@ -105,13 +100,27 @@ module.exports = Self => {
|
|||
updated: Date.vnNew(), state: 'SENDED'
|
||||
}, myOptions);
|
||||
|
||||
stmt = new ParameterizedSQL(`CALL vn.timeControl_calculateAll(?, ?)`, [started, ended]);
|
||||
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||
stmts.push(stmt);
|
||||
|
||||
stmt = new ParameterizedSQL(`CALL vn.timeBusiness_calculateAll(?, ?)`, [started, ended]);
|
||||
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');
|
||||
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(`
|
||||
SELECT CONCAT(u.name, '@verdnatura.es') receiver,
|
||||
u.id workerFk,
|
||||
|
@ -131,7 +140,13 @@ module.exports = Self => {
|
|||
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 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 w.businessFk
|
||||
AND d.isTeleworking
|
||||
|
@ -322,11 +337,9 @@ module.exports = Self => {
|
|||
|
||||
const lastDay = days[index][days[index].length - 1];
|
||||
if (day.workerFk != previousWorkerFk || day == lastDay) {
|
||||
await models.WorkerTimeControlMail.create({
|
||||
workerFk: previousWorkerFk,
|
||||
year: args.year,
|
||||
week: args.week
|
||||
}, myOptions);
|
||||
const query = `INSERT IGNORE INTO workerTimeControlMail (workerFk, year, week)
|
||||
VALUES(?, ?, ?);`;
|
||||
await Self.rawSql(query, [previousWorkerFk, args.year, args.week]);
|
||||
|
||||
ctx.args = {
|
||||
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;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue