|
@ -5,8 +5,8 @@ module.exports = function (app, opts) { |
|
|
const updateAttendance = app.fs.scheduleInit( |
|
|
const updateAttendance = app.fs.scheduleInit( |
|
|
// 妥妥流水账 (*^▽^*)
|
|
|
// 妥妥流水账 (*^▽^*)
|
|
|
{ |
|
|
{ |
|
|
interval: '34 21 4 * * *', |
|
|
// interval: '34 21 4 * * *',
|
|
|
// interval: '*/3 * * * *',
|
|
|
interval: '34 21 */1 * * *', |
|
|
// immediate: true,
|
|
|
// immediate: true,
|
|
|
// proRun: true,
|
|
|
// proRun: true,
|
|
|
}, |
|
|
}, |
|
@ -22,6 +22,9 @@ module.exports = function (app, opts) { |
|
|
const { } = app.fs.utils |
|
|
const { } = app.fs.utils |
|
|
|
|
|
|
|
|
let overtimeNeedData = { |
|
|
let overtimeNeedData = { |
|
|
|
|
|
reason: { |
|
|
|
|
|
keyWord: ['加班事由'] |
|
|
|
|
|
}, |
|
|
begainTime: { |
|
|
begainTime: { |
|
|
keyWord: ['加班开始时间'], |
|
|
keyWord: ['加班开始时间'], |
|
|
require: true, |
|
|
require: true, |
|
@ -44,6 +47,9 @@ module.exports = function (app, opts) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
let vacateNeedData = { |
|
|
let vacateNeedData = { |
|
|
|
|
|
reason: { |
|
|
|
|
|
keyWord: ['请假事由'] |
|
|
|
|
|
}, |
|
|
begainTime: { |
|
|
begainTime: { |
|
|
keyWord: ['请假开始时间', '请假起始时间'], |
|
|
keyWord: ['请假开始时间', '请假起始时间'], |
|
|
keys: ['leaveStartTime'], |
|
|
keys: ['leaveStartTime'], |
|
@ -160,7 +166,7 @@ module.exports = function (app, opts) { |
|
|
) |
|
|
) |
|
|
} else { |
|
|
} else { |
|
|
console.warn( |
|
|
console.warn( |
|
|
`表单数据缺失:`, |
|
|
`表单数据缺失:[${nd}]`, |
|
|
applyDetail |
|
|
applyDetail |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
@ -177,6 +183,8 @@ module.exports = function (app, opts) { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const existOvertimeCount = await models.Overtime.count() |
|
|
|
|
|
const existVacateCount = await models.Vacate.count() |
|
|
|
|
|
|
|
|
const attendanceRes = await clickHouse.pepEmis.query( |
|
|
const attendanceRes = await clickHouse.pepEmis.query( |
|
|
` |
|
|
` |
|
@ -207,6 +215,11 @@ module.exports = function (app, opts) { |
|
|
AND fgroup.name = '假勤管理' |
|
|
AND fgroup.name = '假勤管理' |
|
|
INNER JOIN ${camWorkflow}.act_hi_procinst AS procin |
|
|
INNER JOIN ${camWorkflow}.act_hi_procinst AS procin |
|
|
ON procin.id_ = story.procinst_id |
|
|
ON procin.id_ = story.procinst_id |
|
|
|
|
|
` +
|
|
|
|
|
|
` |
|
|
|
|
|
${existOvertimeCount || existVacateCount ? |
|
|
|
|
|
`WHERE story.create_at > '${moment().subtract(1, 'month').format('YYYY-MM-DD HH:mm:ss')}'` |
|
|
|
|
|
: ''} |
|
|
` |
|
|
` |
|
|
).toPromise() |
|
|
).toPromise() |
|
|
|
|
|
|
|
@ -218,7 +231,7 @@ module.exports = function (app, opts) { |
|
|
if (a.processName.indexOf('请假') > -1) { |
|
|
if (a.processName.indexOf('请假') > -1) { |
|
|
let needData = JSON.parse(JSON.stringify(vacateNeedData)) |
|
|
let needData = JSON.parse(JSON.stringify(vacateNeedData)) |
|
|
getData(a, needData) |
|
|
getData(a, needData) |
|
|
const { begainTime, endTime, type, hrAffirmType, duration, hrAffirmDuration } = needData |
|
|
const { begainTime, endTime, type, hrAffirmType, duration, hrAffirmDuration, reason } = needData |
|
|
if (begainTime.value && endTime.value && type.value) { |
|
|
if (begainTime.value && endTime.value && type.value) { |
|
|
let durationSec = 0 |
|
|
let durationSec = 0 |
|
|
if (hrAffirmDuration.value) { |
|
|
if (hrAffirmDuration.value) { |
|
@ -253,6 +266,7 @@ module.exports = function (app, opts) { |
|
|
duration: durationSec, |
|
|
duration: durationSec, |
|
|
type: typeStorage, |
|
|
type: typeStorage, |
|
|
wfProcessState: a.state, |
|
|
wfProcessState: a.state, |
|
|
|
|
|
reason: reason.value |
|
|
} |
|
|
} |
|
|
if (existRes) { |
|
|
if (existRes) { |
|
|
await models.Vacate.update(storageD, { |
|
|
await models.Vacate.update(storageD, { |
|
@ -277,7 +291,7 @@ module.exports = function (app, opts) { |
|
|
// 获取表单里的数据并插入 needData
|
|
|
// 获取表单里的数据并插入 needData
|
|
|
getData(a, needData) |
|
|
getData(a, needData) |
|
|
|
|
|
|
|
|
const { begainTime, endTime, duration, compensate, hrAffirmDuration } = needData |
|
|
const { begainTime, endTime, duration, compensate, hrAffirmDuration, reason } = needData |
|
|
|
|
|
|
|
|
if (begainTime.value && endTime.value && hrAffirmDuration.value && compensate.value) { |
|
|
if (begainTime.value && endTime.value && hrAffirmDuration.value && compensate.value) { |
|
|
let durationSec = parseFloat(hrAffirmDuration.value) * 3600 |
|
|
let durationSec = parseFloat(hrAffirmDuration.value) * 3600 |
|
@ -372,7 +386,8 @@ module.exports = function (app, opts) { |
|
|
payWorkday, |
|
|
payWorkday, |
|
|
payDayoff, |
|
|
payDayoff, |
|
|
payFestivals, |
|
|
payFestivals, |
|
|
compensate: compensate.value |
|
|
compensate: compensate.value, |
|
|
|
|
|
reason: reason.value |
|
|
} |
|
|
} |
|
|
if (existRes) { |
|
|
if (existRes) { |
|
|
await models.Overtime.update(storageD, { |
|
|
await models.Overtime.update(storageD, { |
|
@ -410,17 +425,17 @@ module.exports = function (app, opts) { |
|
|
|
|
|
|
|
|
console.info(` |
|
|
console.info(` |
|
|
假勤数据更新 用时 ${moment().diff(startTime, 'seconds')} s |
|
|
假勤数据更新 用时 ${moment().diff(startTime, 'seconds')} s |
|
|
`)
|
|
|
`)
|
|
|
console.info(` |
|
|
console.info(` |
|
|
共:${attendanceRes.length}; |
|
|
共:${attendanceRes.length}; |
|
|
新增:${insertCount}; |
|
|
新增:${insertCount}; |
|
|
更新数据:${updateCount}; |
|
|
更新数据:${updateCount}; |
|
|
非完成状态流程:${unCompletedCount}; |
|
|
非完成状态流程:${unCompletedCount}; |
|
|
不明流程:${unknowCount}; |
|
|
不明流程:${unknowCount}; |
|
|
无效(warning):${invalidCount}; |
|
|
无效(warning):${invalidCount}; |
|
|
`);
|
|
|
`);
|
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
app.fs.logger.error(`sechedule: updateAttendance, error: ${error}`); |
|
|
app.fs.logger.error(`sechedule: updateAttendance, error: ${error} `); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
return { |
|
|
return { |
|
|