From df28814ec16c31f19a4eb1b3ff4f5f4fd3ec05cd Mon Sep 17 00:00:00 2001 From: zhaobing Date: Wed, 10 Jan 2024 17:31:32 +0800 Subject: [PATCH] feat:fix bugs --- api/app/lib/schedule/work_notice.js | 43 +++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 9 deletions(-) diff --git a/api/app/lib/schedule/work_notice.js b/api/app/lib/schedule/work_notice.js index 5fe1918..dd85226 100644 --- a/api/app/lib/schedule/work_notice.js +++ b/api/app/lib/schedule/work_notice.js @@ -66,7 +66,7 @@ module.exports = function (app, opts) { WHERE story.apply_user in ('731') ` ).toPromise() - console.log('查询结果',formRes) + console.log('查询结果', formRes) if (formRes && formRes.length > 0) { for (let f of formRes) { let user = {} @@ -89,8 +89,8 @@ module.exports = function (app, opts) { processingPersonnelId: parseData.processing_personnel.value, 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'), + haveDone: parseData.solution_status.value ? (parseData.solution_status.value === '否' ? false : true) : false, + createTime: moment(f.createTime).format('YYYY-MM-DD HH:mm:ss'), }) } } else { @@ -106,7 +106,7 @@ module.exports = function (app, opts) { //数据全部插入完成之后(筛选数据进行发送企业微信通知) // 获取当前时间 // 计算当前时间之后一天的日期 - const lastDay = moment().subtract(1, 'days') + const lastDay = moment().add(1, 'days') //需要发送提醒的数据 const sendRslt = await models.WorkOrderNotice.findAll({ where: { @@ -114,14 +114,14 @@ module.exports = function (app, opts) { haveDone: false,//未完成 planTime: { - $gte: lastDay + $between: [moment().format('YYYY-MM-DD HH:mm:ss'), moment(lastDay).format('YYYY-MM-DD HH:mm:ss')] } } }) - console.log('sendRslt',sendRslt) + console.log('sendRslt', sendRslt) //发送企业微信通知 if (sendRslt && sendRslt.length) { - console.log('sendRslt发送通知的数据',sendRslt) + console.log('sendRslt发送通知的数据', sendRslt) for (let { dataValues: c } of sendRslt) { await new Promise(resolve => setTimeout(resolve, 5000)); // 这里的5000是等待时间,单位为毫秒,您可以根据需要调整 //根据电话号码查询企业微信对应的userId @@ -133,7 +133,19 @@ module.exports = function (app, opts) { if (userId) { const res = await sendWechat({ opts, msgtype: sendType["mini"], - data: { userId: userId, touser: [userId],content:`你有一个表单《运维中台售后工单问题处理工单 ${c.createTime}》,修复时间即将超期,请尽快处理` } + data: { + userId: userId, touser: [userId], content: [{ + "key": "工单类型", + "value": "运维中台售后工单问题处理工单" + }, { + "key": "发起时间", + "value": c.createTime + }, { + "key": "计划修复时间", + "value": c.planTime + } + ] + } }) if (res.body.errmsg === 'ok') { //将已发送的记录的isSend修改为true(已发送) @@ -147,7 +159,20 @@ module.exports = function (app, opts) { if (manager) { const res = await sendWechat({ opts, msgtype: sendType["mini"], - data: { userId: manager, touser: [manager],content:`你有一个表单《运维中台售后工单问题处理工单 ${c.createTime}》,修复时间即将超期,请尽快处理` } + data: { userId: manager, touser: [manager], + content: [{ + "key": "工单类型", + "value": "运维中台售后工单问题处理工单" + }, { + "key": "发起时间", + "value": c.createTime + }, { + "key": "计划修复时间", + "value": c.planTime + } + ] + + } }) if (res.body.errmsg === 'ok') { //将已发送的记录的isSend修改为true(已发送)