Browse Source

feat:fix bugs

dev
zhaobing 1 year ago
parent
commit
df28814ec1
  1. 43
      api/app/lib/schedule/work_notice.js

43
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(已发送)

Loading…
Cancel
Save