Browse Source

feat:修改提示内容

dev
zhaobing 1 year ago
parent
commit
d0c5eb96b9
  1. 8
      api/app/lib/models/work_order_notice.js
  2. 13
      api/app/lib/schedule/work_notice.js
  3. 7
      api/app/lib/utils/qy.js
  4. 9
      script/4.3/schema/1.create_work_order_notice.sql

8
api/app/lib/models/work_order_notice.js

@ -23,6 +23,14 @@ module.exports = dc => {
primaryKey: false,
autoIncrement: false,
},
createTime: {
field: 'create_time',
type: DataTypes.DATE,
allowNull: true,
comment: '',
primaryKey: false,
autoIncrement: false,
},
processingPersonnelId: {
field: 'processing_personnel_id',
type: DataTypes.INTEGER,

13
api/app/lib/schedule/work_notice.js

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

7
api/app/lib/utils/qy.js

@ -15,6 +15,9 @@ const WechatApi = {
const sendType = {
'mini': 'miniprogram_notice',
}
const userIds={
}
module.exports = function (app, opts) {
const getGetToken = async (opts) => {
@ -42,11 +45,15 @@ module.exports = function (app, opts) {
//获取用户id
const getUserId = async (opts, phoneNum) => {
if (userIds[phoneNum]) {
return userIds[phoneNum];
}
console.log(`info: getGetToken--start-- `)
await getGetToken(opts)
console.log(`info: getGetToken--end-- `)
const res = await request.post(`${opts.weChat.reqUrl}${WechatApi.getUserId}?access_token=${wechatExpires.accessToken}`, { mobile: phoneNum })
if(res.body.errmsg==='ok'){
userIds[phoneNum] = res.body.userid
return res.body.userid
}else{

9
script/4.3/schema/1.create_work_order_notice.sql

@ -23,4 +23,11 @@ comment on column work_order_notice.is_send is '是否已发送';
comment on column work_order_notice.procinst_id is '表单实例id';
comment on column work_order_notice.have_done is '是否解决';
comment on column work_order_notice.have_done is '是否解决';
alter table work_order_notice
add create_time timestamp without time zone;
comment on column public.work_order_notice.create_time is '表单发起时间';
Loading…
Cancel
Save