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.
64 lines
2.0 KiB
64 lines
2.0 KiB
const moment = require('moment')
|
|
|
|
const TEST = false
|
|
// const TEST = true
|
|
|
|
module.exports = function (app, opts) {
|
|
const mettingGenerate = app.fs.scheduleInit(
|
|
{
|
|
interval: '0 0 0 */1 * *',
|
|
immediate: TEST,
|
|
proRun: !TEST,
|
|
},
|
|
async () => {
|
|
try {
|
|
const { models } = app.fs.dc
|
|
const today = moment()
|
|
const date = today.date()
|
|
const dateFormat = moment().format('YYYY-MM-DD')
|
|
let sites = await models.Site.findAll({
|
|
where: { del: false },
|
|
attributes: ['id', 'name']
|
|
});
|
|
let datasM = [], datasB = [], datasD = [], datas6 = []
|
|
sites.map(s => {
|
|
datasM.push({
|
|
siteId: s.id,
|
|
type: '月度安全例会',
|
|
date: dateFormat
|
|
});
|
|
datasB.push({
|
|
siteId: s.id,
|
|
type: '班前会',
|
|
date: dateFormat
|
|
});
|
|
datasD.push({
|
|
siteId: s.id,
|
|
type: '日调度会',
|
|
date: dateFormat
|
|
});
|
|
datas6.push({
|
|
siteId: s.id,
|
|
type: '逢六教育培训',
|
|
date: dateFormat
|
|
})
|
|
})
|
|
if (date == 1) {
|
|
await models.Metting.bulkCreate(datasM)
|
|
}
|
|
await models.Metting.bulkCreate(datasB)
|
|
await models.Metting.bulkCreate(datasD)
|
|
if (parseInt(date) % 10 == 6) {
|
|
await models.Metting.bulkCreate(datas6)
|
|
}
|
|
|
|
} catch (error) {
|
|
app.fs.logger.error(`sechedule: mettingGenerate, error: ${error}`);
|
|
}
|
|
}
|
|
);
|
|
|
|
return {
|
|
mettingGenerate
|
|
}
|
|
}
|