This commit is contained in:
parent
f9e9181637
commit
849989afa8
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
module.exports = Self => {
|
module.exports = Self => {
|
||||||
Self.remoteMethodCtx('add', {
|
Self.remoteMethodCtx('add', {
|
||||||
description: 'Add activity if the activity is different or is the same but have exceed time for break',
|
description: 'Add activity if the activity is different or is the same but have exceed time for break',
|
||||||
|
@ -31,23 +30,21 @@ module.exports = Self => {
|
||||||
|
|
||||||
return await Self.rawSql(`
|
return await Self.rawSql(`
|
||||||
INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
|
INSERT INTO workerActivity (workerFk, workerActivityTypeFk, model)
|
||||||
SELECT ?,
|
SELECT ?, ?, ?
|
||||||
?,
|
FROM workerTimeControlParams wtcp
|
||||||
?
|
LEFT JOIN (
|
||||||
FROM workerTimeControlParams wtcp
|
SELECT wa.workerFk,
|
||||||
LEFT JOIN (
|
wa.created,
|
||||||
SELECT wa.workerFk,
|
wat.code
|
||||||
wa.created,
|
FROM workerActivity wa
|
||||||
wat.code
|
LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk
|
||||||
FROM workerActivity wa
|
WHERE wa.workerFk = ?
|
||||||
LEFT JOIN workerActivityType wat ON wat.code = wa.workerActivityTypeFk
|
ORDER BY wa.created DESC
|
||||||
WHERE wa.workerFk = ?
|
LIMIT 1
|
||||||
ORDER BY wa.created DESC
|
) sub ON TRUE
|
||||||
LIMIT 1
|
WHERE sub.workerFk IS NULL
|
||||||
) sub ON TRUE
|
OR sub.code <> ?
|
||||||
WHERE sub.workerFk IS NULL
|
OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;`
|
||||||
OR sub.code <> ?
|
|
||||||
OR TIMESTAMPDIFF(SECOND, sub.created, util.VN_NOW()) > wtcp.dayBreak;`
|
|
||||||
, [userId, code, model, userId, code], myOptions);
|
, [userId, code, model, userId, code], myOptions);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue