fix: refs #6276 machineWorker_add
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
ab1dc7af55
commit
9afc3840c7
|
@ -37,27 +37,16 @@ module.exports = Self => {
|
|||
|
||||
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(
|
||||
{or: [{workerFk: userId}, {machineFk: machine.id}]},
|
||||
{
|
||||
or: [{workerFk: userId}, {machineFk: machine.id}],
|
||||
and: [{outTime: null }]
|
||||
},
|
||||
{outTime: Date.vnNew()},
|
||||
myOptions
|
||||
);
|
||||
}
|
||||
|
||||
await models.MachineWorker.create({machineFk: machine.id, workerFk: userId}, myOptions);
|
||||
|
||||
if (tx) await tx.commit();
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in New Issue