Browse Source

短信指派责任人提醒 90%

dev
liujiangyong 1 year ago
parent
commit
0a573538ef
  1. 4
      api/.vscode/launch.json
  2. 28
      api/app/lib/controllers/data/anspectionNotificationPhone.js
  3. 3
      api/app/lib/routes/data/index.js
  4. 16
      api/config.js
  5. 3
      api/package.json
  6. 35
      api/utils/push.js
  7. 11
      web/client/src/sections/fillion/actions/appointTask.js
  8. 5
      web/client/src/sections/fillion/components/feedback/nominateModalcopy.js
  9. 5
      web/client/src/utils/webapi.js

4
api/.vscode/launch.json

@ -27,9 +27,11 @@
// "--yingshiKey d0704fb9d5d14a6682c1c1d592c12512",
// "--yingshiSecret 93d023269495b86be62cdfdcf34a6cd1",
"--yingshiKey 5d16a667e1c2423d9d0d634f781810b4",
"--yingshiSecret 0cc4e1ec4e6a53ea3dabeb09cd5f468b",
"--smsKey LTAI5tAFdjz7j38aNF2C9Qe8",
"--smsSecret 1trYkmiqfBtvZL6BxkNH2uQcQQPs0S",
]
},
{

28
api/app/lib/controllers/data/anspectionNotificationPhone.js

@ -1,5 +1,6 @@
'use strict';
const moment = require('moment')
const { pushBySms } = require('../../../../utils/push.js');
async function getAnspectionNotificationPhone(ctx) {
try {
@ -47,7 +48,32 @@ async function addAnspectionNotificationPhone(ctx) {
}
}
function pushAppointSMS(opts) {
return async function (ctx) {
try {
const { phone = [] } = ctx.request.body
if (phone.length) {
await pushBySms({
accessKey: opts.sms.accessKey,
accessSecret: opts.sms.accessSecret,
phone: phone,
templateCode: 'SMS_273640525',
})
} else {
throw '缺少请求参数';
}
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : '短信推送失败'
}
}
}
}
module.exports = {
getAnspectionNotificationPhone, addAnspectionNotificationPhone
getAnspectionNotificationPhone, addAnspectionNotificationPhone, pushAppointSMS
};

3
api/app/lib/routes/data/index.js

@ -214,4 +214,7 @@ module.exports = function (app, router, opts) {
//添加
app.fs.api.logAttr['POST/anspection/notification/phone'] = { content: '导入道路数据', visible: true };
router.post('/anspection/notification/phone', anspectionNotificationPhone.addAnspectionNotificationPhone);
app.fs.api.logAttr['POST/pushAppointSMS'] = { content: '推送指派短信', visible: true };
router.post('/pushAppointSMS', anspectionNotificationPhone.pushAppointSMS(opts));
};

16
api/config.js

@ -19,6 +19,9 @@ args.option('qndmn', 'qiniuDomain');
//
args.option('yingshiKey', '萤石 KEY')
args.option('yingshiSecret', '萤石 SECRET')
// 短信-阿里云
args.option('smsKey', 'smsAccessKey');
args.option('smsSecret', 'smsSecretKey');
const flags = args.parse(process.argv);
@ -32,6 +35,10 @@ const QINIU_SK = process.env.ANXINCLOUD_QINIU_SECRETKEY || flags.qnsk;
//
const YINGSHI_KEY = process.env.YINGSHI_KEY || flags.yingshiKey;
const YINGSHI_SECRET = process.env.YINGSHI_SECRET || flags.yingshiSecret;
const SMS_KEY = process.env.SMS_KEY || flags.smsKey;
const SMS_SECRET = process.env.SMS_SECRET || flags.smsSecret;
// 萤石服务的地址
const YINGSHI_URL = process.env.YINGSHI_URL || flags.yingshiUrl || 'https://open.ys7.com/api';
// 智调系统基础数据接口
@ -39,7 +46,8 @@ const ZHIDIAO_URL = process.env.ZHIDIAO_URL || flags.zhidiaoUrl || 'http://61.13
if (
!FS_UNIAPP_DB ||
!YINGSHI_KEY || !YINGSHI_SECRET) {
!YINGSHI_KEY || !YINGSHI_SECRET ||
!SMS_KEY || !SMS_SECRET) {
console.log('缺少启动参数,异常退出');
args.showHelp();
process.exit(-1);
@ -82,7 +90,11 @@ const product = {
root: ZHIDIAO_URL,
params: {}
}
]
],
sms: {
accessKey: SMS_KEY,
accessSecret: SMS_SECRET
},
}
}
],

3
api/package.json

@ -5,7 +5,7 @@
"main": "server.js",
"scripts": {
"test": "set DEBUG=true&&\"node_modules/.bin/mocha\" --harmony --reporter spec app/test/*.test.js",
"start": "set NODE_ENV=development&&node server -p 4001 -g postgres://postgres://postgres:123@10.8.30.32:5432/highways4good -f http://localhost:14000 --qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5 --qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa --qnbkt dev-highways4good --qndmn http://rfkimpwbb.hn-bkt.clouddn.com",
"start": "set NODE_ENV=development&&node server -p 4001 -g postgres://postgres://postgres:123@10.8.30.32:5432/highways4good -f http://localhost:14000 --qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5 --qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa --qnbkt dev-highways4good --qndmn http://rfkimpwbb.hn-bkt.clouddn.com --smsKey LTAI5tAFdjz7j38aNF2C9Qe8 --smsSecret 1trYkmiqfBtvZL6BxkNH2uQcQQPs0S",
"start:linux": "export NODE_ENV=development&&node server -p 4001 -g postgres://FashionAdmin:123456@10.8.30.39:5432/pm1",
"automate": "sequelize-automate -c sequelize-automate.config.js"
},
@ -13,6 +13,7 @@
"license": "MIT",
"repository": {},
"dependencies": {
"@alicloud/pop-core": "^1.7.12",
"@fs/attachment": "^1.0.0",
"archiver": "3.0.0",
"args": "^3.0.7",

35
api/utils/push.js

@ -0,0 +1,35 @@
'use strict';
const Core = require('@alicloud/pop-core');
const pushBySms = async ({ phone = [], templateCode, accessKey, accessSecret } = {}) => {
try {
if (phone.length) {
const client = new Core({
accessKeyId: accessKey,
accessKeySecret: accessSecret,
endpoint: 'http://dysmsapi.aliyuncs.com', // 固定
apiVersion: '2017-05-25' // 固定
});
const SendSmsRes = await client.request('SendSms', {
"PhoneNumbers": phone.join(','), // 接收短信的手机号码。
"SignName": "隧道智慧运维助手", // 短信签名名称。必须是已添加、并通过审核的短信签名。
"TemplateCode": templateCode, // 短信模板ID。必须是已添加、并通过审核的短信签名;且发送国际/港澳台消息时,请使用国际/港澳台短信模版。
"TemplateParam": JSON.stringify({
struction: 'test',
point: 'test',
number: 1
}) // 短信模板变量对应的实际值,JSON格式。
}, {
method: 'POST'
});
return SendSmsRes
}
} catch (error) {
throw error
}
}
module.exports = {
pushBySms,
}

11
web/client/src/sections/fillion/actions/appointTask.js

@ -11,3 +11,14 @@ export function appointTask(query) {
msg: { option: '指派任务' },
});
}
export function pushAppointSMS(data) {
return dispatch => basicAction({
type: 'post',
data,
dispatch: dispatch,
actionType: 'PUSH_APPOINT_SMS',
url: ApiTable.pushAppointSMS,
msg: { option: '发送指派信息' },
});
}

5
web/client/src/sections/fillion/components/feedback/nominateModalcopy.js

@ -4,7 +4,7 @@ import { connect } from 'react-redux';
import { Spin, TreeSelect, Modal, Form, Select, Input } from 'antd';
import ProForm, { ProFormText, ModalForm, ProFormSwitch, ProFormTreeSelect, ProFormSelect } from '@ant-design/pro-form';
import { getDepUser } from '../../../organization/actions/user'
import { appointTask } from '../../actions/appointTask'
import { appointTask, pushAppointSMS } from '../../actions/appointTask'
import moment from 'moment'
import { v4 as uuidv4 } from 'uuid';
@ -45,8 +45,7 @@ const NominateModal = (props) => {
setDepUsers([])
form.resetFields()
// const phone = depUsers.find(u => u.value == values.nameId)?.phone;
// console.log(phone, 'phone')
// dispatch(pushAppointSMS({ phone, info: 'info...' }))
// dispatch(pushAppointSMS({ phone: [phone] }))
}
})
})

5
web/client/src/utils/webapi.js

@ -310,8 +310,9 @@ export const ApiTable = {
modifyRoadadministration:'editRoadadministration/:id',
delRoadadministration:'delRoadadministration/:id',
addRoadadministration:'/addRoadadministration',
getRoadadministration:'/getRoadadministration'
getRoadadministration:'/getRoadadministration',
// 发送短信
pushAppointSMS: 'pushAppointSMS',
};

Loading…
Cancel
Save