hotFix: workerTimeControl
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ce64d5f0c4
commit
9e39e96cf4
|
@ -66,46 +66,36 @@ module.exports = Self => {
|
|||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.timeControlCalculate');
|
||||
stmts.push('DROP TEMPORARY TABLE IF EXISTS tmp.timeBusinessCalculate');
|
||||
|
||||
const destroyAllWhere = {
|
||||
timed: {between: [started, ended]},
|
||||
isSendMail: true
|
||||
};
|
||||
const updateAllWhere = {
|
||||
year: args.year,
|
||||
week: args.week
|
||||
};
|
||||
|
||||
const tmpUserSQL = `
|
||||
CREATE OR REPLACE TEMPORARY TABLE tmp.user
|
||||
SELECT id as userFk
|
||||
FROM vn.worker`;
|
||||
let tmpUser = new ParameterizedSQL(tmpUserSQL);
|
||||
|
||||
if (args.workerId) {
|
||||
await models.WorkerTimeControl.destroyAll({
|
||||
userFk: args.workerId,
|
||||
timed: {between: [started, ended]},
|
||||
isSendMail: true
|
||||
}, myOptions);
|
||||
|
||||
const where = {
|
||||
workerFk: args.workerId,
|
||||
year: args.year,
|
||||
week: args.week
|
||||
};
|
||||
await models.WorkerTimeControlMail.updateAll(where, {
|
||||
updated: Date.vnNew(), state: 'SENDED'
|
||||
}, myOptions);
|
||||
|
||||
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||
stmts.push(stmt);
|
||||
stmt = new ParameterizedSQL('CREATE TEMPORARY TABLE tmp.`user` SELECT id userFk FROM account.user WHERE id = ?', [args.workerId]);
|
||||
stmts.push(stmt);
|
||||
} else {
|
||||
await models.WorkerTimeControl.destroyAll({
|
||||
timed: {between: [started, ended]},
|
||||
isSendMail: true
|
||||
}, myOptions);
|
||||
|
||||
const where = {
|
||||
year: args.year,
|
||||
week: args.week
|
||||
};
|
||||
await models.WorkerTimeControlMail.updateAll(where, {
|
||||
updated: Date.vnNew(), state: 'SENDED'
|
||||
}, myOptions);
|
||||
|
||||
stmt = new ParameterizedSQL('DROP TEMPORARY TABLE IF EXISTS tmp.`user`');
|
||||
stmts.push(stmt);
|
||||
stmt = new ParameterizedSQL('CREATE TEMPORARY TABLE IF NOT EXISTS tmp.`user` SELECT id as userFk FROM vn.worker w JOIN account.`user` u ON u.id = w.id WHERE id IS NOT NULL');
|
||||
stmts.push(stmt);
|
||||
destroyAllWhere.userFk = args.workerId;
|
||||
updateAllWhere.workerFk = args.workerId;
|
||||
tmpUser = new ParameterizedSQL(tmpUserSQL + ' WHERE id = ?', [args.workerId]);
|
||||
}
|
||||
|
||||
await models.WorkerTimeControl.destroyAll(destroyAllWhere, myOptions);
|
||||
|
||||
await models.WorkerTimeControlMail.updateAll(updateAllWhere, {
|
||||
updated: Date.vnNew(),
|
||||
state: 'SENDED'
|
||||
}, myOptions);
|
||||
|
||||
stmts.push(tmpUser);
|
||||
|
||||
stmt = new ParameterizedSQL(
|
||||
`CALL vn.timeControl_calculate(?, ?)
|
||||
`, [started, ended]);
|
||||
|
|
Loading…
Reference in New Issue