7152-devToTest_2414 #2228

Merged
alexm merged 636 commits from 7152-devToTest_2414 into test 2024-03-28 08:26:34 +00:00
1 changed files with 6 additions and 17 deletions
Showing only changes of commit 9afc3840c7 - Show all commits

View File

@ -37,27 +37,16 @@ module.exports = Self => {
if (!machine) throw new Error(`plate ${plate} does not exist`); if (!machine) throw new Error(`plate ${plate} does not exist`);
const twelveHoursAgo = Date.vnNew();
twelveHoursAgo.setHours(twelveHoursAgo.getHours() - 12);
const isRegistered = await models.MachineWorker.findOne({
where: {
and: [
{machineFk: machine.id},
{workerFk: userId},
{outTime: {gte: twelveHoursAgo}}
]
}
}, myOptions);
if (!isRegistered) await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
else {
await models.MachineWorker.updateAll( await models.MachineWorker.updateAll(
{or: [{workerFk: userId}, {machineFk: machine.id}]}, {
or: [{workerFk: userId}, {machineFk: machine.id}],
and: [{outTime: null }]
},
{outTime: Date.vnNew()}, {outTime: Date.vnNew()},
myOptions myOptions
); );
}
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
if (tx) await tx.commit(); if (tx) await tx.commit();
} catch (e) { } catch (e) {