|
|
@ -27,6 +27,7 @@ module.exports = function (app, opts) { |
|
|
|
async () => { |
|
|
|
try { |
|
|
|
//前一次执行时间
|
|
|
|
const phone = opts.phone//运维部门审批工单的负责人的电话号码
|
|
|
|
console.log('运维中台售后问题处理工单数据抽取开始', moment().format('YYYY-MM-DD HH:mm:ss')) |
|
|
|
const { parseProcessData, getUserId, sendWechat } = app.fs.utils |
|
|
|
const startTime = moment().format('YYYY-MM-DD HH:mm:ss') |
|
|
@ -76,8 +77,8 @@ module.exports = function (app, opts) { |
|
|
|
procinstId: f.procinstId, |
|
|
|
} |
|
|
|
}) |
|
|
|
//没有计划完成时间,没有处理人,没有是否解决,都不推送通知
|
|
|
|
if (parseData.processing_personnel.value && parseData.planTime.value && parseData.solution_status.value) { |
|
|
|
//没有计划完成时间,没有处理人,都不推送通知
|
|
|
|
if (parseData.processing_personnel.value && parseData.planTime.value) { |
|
|
|
user = await clickHouse.pepEmis.query(`select * from user where id=${Number(parseData.processing_personnel.value)}`).toPromise() |
|
|
|
if (!rlst) { |
|
|
|
await models.WorkOrderNotice.create({ |
|
|
@ -86,11 +87,11 @@ module.exports = function (app, opts) { |
|
|
|
processingPersonnelId: parseData.processing_personnel.value, |
|
|
|
processingPersonnelPhone: user && user.length && user[0].phone, |
|
|
|
isSend: false, |
|
|
|
haveDone: parseData.solution_status.value === '否' ? false : true, |
|
|
|
haveDone: parseData.solution_status.value && parseData.solution_status.value === '否' ? false : true || false, |
|
|
|
}) |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log('没有对应的处理人', f.procinstId) |
|
|
|
console.log('没有对应的处理人,没有计划完成时间', f.procinstId) |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
@ -118,26 +119,9 @@ module.exports = function (app, opts) { |
|
|
|
if (sendRslt && sendRslt.length) { |
|
|
|
for (let { dataValues: c } of sendRslt) { |
|
|
|
//根据电话号码查询企业微信对应的userId
|
|
|
|
//15083558812,兰邦夫的电话号码
|
|
|
|
if(c.processingPersonnelPhone==='15083558812'){ |
|
|
|
//phone,兰邦夫的电话号码(2024-1-9)
|
|
|
|
const userId = await getUserId(opts, c.processingPersonnelPhone) |
|
|
|
if(userId){ |
|
|
|
const res= await sendWechat({ |
|
|
|
opts, msgtype: sendType["mini"], |
|
|
|
data: { userId:userId, touser: [userId] } |
|
|
|
}) |
|
|
|
if(res.body.errmsg==='ok'){ |
|
|
|
//将已发送的记录的isSend修改为true(已发送)
|
|
|
|
await models.WorkOrderNotice.update({ isSend: true }, { where: { id: c.id } }) |
|
|
|
}else{ |
|
|
|
console.log('发送消息失败',res.body.errmsg) |
|
|
|
} |
|
|
|
}else{ |
|
|
|
console.log('查询不到对应的userId',c.processingPersonnelPhone) |
|
|
|
} |
|
|
|
} |
|
|
|
const userId=await getUserId(opts,c.processingPersonnelPhone) |
|
|
|
const userLan=await getUserId(opts,'15083558812') |
|
|
|
const manager = await getUserId(opts, phone) |
|
|
|
//根据查询的userId发送通知
|
|
|
|
if (userId) { |
|
|
|
const res = await sendWechat({ |
|
|
@ -153,20 +137,20 @@ module.exports = function (app, opts) { |
|
|
|
} else { |
|
|
|
console.log('查询不到对应的userId', c.processingPersonnelPhone) |
|
|
|
} |
|
|
|
if(userLan){ |
|
|
|
if (manager) { |
|
|
|
const res = await sendWechat({ |
|
|
|
opts, msgtype: sendType["mini"], |
|
|
|
data: { userId:userLan, touser: [userLan] } |
|
|
|
data: { userId: manager, touser: [manager] } |
|
|
|
}) |
|
|
|
if (res.body.errmsg === 'ok') { |
|
|
|
//将已发送的记录的isSend修改为true(已发送)
|
|
|
|
console.log('已发送给兰邦夫') |
|
|
|
console.log('已发送给运维部门主管') |
|
|
|
// await models.WorkOrderNotice.update({ isSend: true }, { where: { id: c.id } })
|
|
|
|
} else { |
|
|
|
console.log('发送消息失败', res.body.errmsg) |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log('查询不到对应的userId','15083558812') |
|
|
|
console.log('查询不到对应的userId', phone) |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|