You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

75 lines
2.4 KiB

import {setTimeout as sleep} from 'node:timers/promises';
import _ from "lodash";
import async from "async";
import RollCall from './rollCall.js'
const date = new Date()
const todayDay = (date.toString()).split(' ')[0];
const todayMonth = (date.toString()).split(' ')[1];
const todayDayNum = (date.toString()).split(' ')[2];
const todayYear = (date.toString()).split(' ')[3];
const todayDate = _.join([todayYear, todayMonth, todayDayNum], '-');
export default class Operation {
constructor() {
this.rollCall = new RollCall()
this.usersList = [
{nationalId: '0019717601', password: '10591059'},
{nationalId: '0021028834', password: '13771998'},
{nationalId: '0082506949', password: '688630'},
{nationalId: '0023414162', password: '638369'},
{nationalId: '2980817538', password: '825447'}
]
}
async sanaEnter(req, res) {
if (
['Thu', 'Fri'].includes(todayDay)
||
['2025-Jan-14', '2025-Jan-28', '2025-Feb-10', '2025-Feb-19', '2025-Feb-20'].includes(todayDate)
)
return {}
await async.each(this.usersList, async ({nationalId ,password}, cb) => {
sleep(Math.floor(Math.random() * 100 / 2) * 60 * 1000)
.then(async _ => {
await this.rollCall.login({ nationalId ,password})
await this.rollCall.operation({ enter: true, nationalId})
})
.catch(err => console.error(err))
cb()
})
return {}
}
async sanaExit(req, res) {
if (
['Thu', 'Fri'].includes(todayDay)
||
['2025-Jan-14', '2025-Jan-28', '2025-Feb-10', '2025-Feb-19', '2025-Feb-20'].includes(todayDate)
)
return {}
await async.each(this.usersList, async ({nationalId ,password}, cb) => {
const timer = Math.floor(Math.random() * 100 / 2) * 60 * 1000
console.log('$$$$$$$$$$$', timer)
sleep(timer)
.then(async _ => {
await this.rollCall.login({ nationalId ,password})
await this.rollCall.operation({ enter: false, nationalId})
})
.catch(err => console.error(err))
cb()
})
return {}
}
async test() {
console.log(123123132)
}
}