|
|
@ -12,11 +12,10 @@ const schedule = require('node-schedule') |
|
|
|
const moment = require('moment') |
|
|
|
const request = require('superagent') |
|
|
|
let isDev = false |
|
|
|
isDev = true |
|
|
|
// isDev = true
|
|
|
|
const sendType = { |
|
|
|
'mini': 'miniprogram_notice', |
|
|
|
} |
|
|
|
|
|
|
|
module.exports = function (app, opts) { |
|
|
|
const workOrderNotice = app.fs.scheduleInit( |
|
|
|
{ |
|
|
@ -63,7 +62,8 @@ module.exports = function (app, opts) { |
|
|
|
ON fgroup.id = fprocess.group_id |
|
|
|
INNER JOIN ${camWorkflow}.act_hi_procinst AS procin |
|
|
|
ON procin.id_ = story.procinst_id |
|
|
|
AND procin.state_ in ('COMPLETED','ACTIVE')` |
|
|
|
AND procin.state_ in ('COMPLETED','ACTIVE') |
|
|
|
WHERE story.apply_user in ('731')` |
|
|
|
).toPromise() |
|
|
|
if (formRes && formRes.length > 0) { |
|
|
|
for (let f of formRes) { |
|
|
@ -88,6 +88,7 @@ module.exports = function (app, opts) { |
|
|
|
processingPersonnelPhone: user && user.length && user[0].phone, |
|
|
|
isSend: false, |
|
|
|
haveDone: parseData.solution_status.value && parseData.solution_status.value === '否' ? false : true || false, |
|
|
|
createTime: moment(f.createTime).format('YYYY-MM-DD'), |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
@ -119,15 +120,17 @@ module.exports = function (app, opts) { |
|
|
|
if (sendRslt && sendRslt.length) { |
|
|
|
console.log('sendRslt发送通知的数据',sendRslt) |
|
|
|
for (let { dataValues: c } of sendRslt) { |
|
|
|
await new Promise(resolve => setTimeout(resolve, 5000)); // 这里的5000是等待时间,单位为毫秒,您可以根据需要调整
|
|
|
|
//根据电话号码查询企业微信对应的userId
|
|
|
|
//phone,兰邦夫的电话号码(2024-1-9)
|
|
|
|
const userId = await getUserId(opts, c.processingPersonnelPhone) |
|
|
|
await new Promise(resolve => setTimeout(resolve, 5000)); // 这里的5000是等待时间,单位为毫秒,您可以根据需要调整
|
|
|
|
const manager = await getUserId(opts, phone) |
|
|
|
//根据查询的userId发送通知
|
|
|
|
if (userId) { |
|
|
|
const res = await sendWechat({ |
|
|
|
opts, msgtype: sendType["mini"], |
|
|
|
data: { userId: userId, touser: [userId] } |
|
|
|
data: { userId: userId, touser: [userId],content:`你有一个表单《运维中台售后工单问题处理工单 ${c.createTime}》,修复时间即将超期,请尽快处理` } |
|
|
|
}) |
|
|
|
if (res.body.errmsg === 'ok') { |
|
|
|
//将已发送的记录的isSend修改为true(已发送)
|
|
|
@ -141,7 +144,7 @@ module.exports = function (app, opts) { |
|
|
|
if (manager) { |
|
|
|
const res = await sendWechat({ |
|
|
|
opts, msgtype: sendType["mini"], |
|
|
|
data: { userId: manager, touser: [manager] } |
|
|
|
data: { userId: manager, touser: [manager],content:`你有一个表单《运维中台售后工单问题处理工单 ${c.createTime}》,修复时间即将超期,请尽快处理` } |
|
|
|
}) |
|
|
|
if (res.body.errmsg === 'ok') { |
|
|
|
//将已发送的记录的isSend修改为true(已发送)
|
|
|
|