|
@@ -1,9 +1,9 @@
|
|
|
/*
|
|
/*
|
|
|
* @Author: YKH
|
|
* @Author: YKH
|
|
|
* @Date: 2021-12-11 21:36:52
|
|
* @Date: 2021-12-11 21:36:52
|
|
|
- * @LastEditTime: 2022-06-28 14:01:44
|
|
|
|
|
- * @Description:
|
|
|
|
|
- * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\service\utils.ts
|
|
|
|
|
|
|
+ * @LastEditTime: 2022-10-04 19:57:52
|
|
|
|
|
+ * @Description:
|
|
|
|
|
+ * @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\utils.ts
|
|
|
*/
|
|
*/
|
|
|
import { Inject, Provide } from '@midwayjs/decorator';
|
|
import { Inject, Provide } from '@midwayjs/decorator';
|
|
|
import { BaseService } from 'midwayjs-cool-core';
|
|
import { BaseService } from 'midwayjs-cool-core';
|
|
@@ -12,7 +12,6 @@ import { Utils } from '../../../comm/utils';
|
|
|
|
|
|
|
|
@Provide()
|
|
@Provide()
|
|
|
export class ShuyouUtilsService extends BaseService {
|
|
export class ShuyouUtilsService extends BaseService {
|
|
|
-
|
|
|
|
|
@Inject()
|
|
@Inject()
|
|
|
utils: Utils;
|
|
utils: Utils;
|
|
|
|
|
|
|
@@ -20,9 +19,9 @@ export class ShuyouUtilsService extends BaseService {
|
|
|
* 获取天气信息
|
|
* 获取天气信息
|
|
|
*/
|
|
*/
|
|
|
async getWeatherCD() {
|
|
async getWeatherCD() {
|
|
|
- let cityIds = '101270101' //成都
|
|
|
|
|
- let resWe
|
|
|
|
|
- const data = await getWeather(cityIds)
|
|
|
|
|
|
|
+ let cityIds = '101270101'; //成都
|
|
|
|
|
+ let resWe;
|
|
|
|
|
+ const data = await getWeather(cityIds);
|
|
|
let data6 = JSON.parse(data + '');
|
|
let data6 = JSON.parse(data + '');
|
|
|
if (data6.code == 200) {
|
|
if (data6.code == 200) {
|
|
|
resWe = data6;
|
|
resWe = data6;
|
|
@@ -33,129 +32,139 @@ export class ShuyouUtilsService extends BaseService {
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
*调用钉钉机器人发送消息GET
|
|
*调用钉钉机器人发送消息GET
|
|
|
- * @return {*}
|
|
|
|
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouUtilsService
|
|
* @memberof ShuyouUtilsService
|
|
|
*/
|
|
*/
|
|
|
async dingRobot(text: string, atMobiles: string) {
|
|
async dingRobot(text: string, atMobiles: string) {
|
|
|
- const data = await dingRobot(text, atMobiles)
|
|
|
|
|
|
|
+ const data = await dingRobot(text, atMobiles);
|
|
|
return data;
|
|
return data;
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
*调用钉钉机器人发送消息Post
|
|
*调用钉钉机器人发送消息Post
|
|
|
- * @return {*}
|
|
|
|
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouUtilsService
|
|
* @memberof ShuyouUtilsService
|
|
|
*/
|
|
*/
|
|
|
async postRobot(text: string, atMobiles) {
|
|
async postRobot(text: string, atMobiles) {
|
|
|
- const data = await postRobot(text, atMobiles)
|
|
|
|
|
|
|
+ const data = await postRobot(text, atMobiles);
|
|
|
return data;
|
|
return data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
*调用企业微信机器人发送消息Post:数优-加币/未完成播报群
|
|
*调用企业微信机器人发送消息Post:数优-加币/未完成播报群
|
|
|
- * @return {*}
|
|
|
|
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouUtilsService
|
|
* @memberof ShuyouUtilsService
|
|
|
*/
|
|
*/
|
|
|
async postRobotEnterpriseWeChat(text: string) {
|
|
async postRobotEnterpriseWeChat(text: string) {
|
|
|
- const time = this.utils.formatDateTime(new Date())
|
|
|
|
|
- const data = await postRobotEnterpriseWeChat(text, time)
|
|
|
|
|
|
|
+ const time = this.utils.formatDateTime(new Date());
|
|
|
|
|
+ const data = await postRobotEnterpriseWeChat(text, time);
|
|
|
return data;
|
|
return data;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
*调用企业微信机器人发送消息Post到:数据优化-深圳项目对接群
|
|
*调用企业微信机器人发送消息Post到:数据优化-深圳项目对接群
|
|
|
- * @return {*}
|
|
|
|
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouUtilsService
|
|
* @memberof ShuyouUtilsService
|
|
|
*/
|
|
*/
|
|
|
async postRobotEnterpriseWeChat2(text: string) {
|
|
async postRobotEnterpriseWeChat2(text: string) {
|
|
|
- const time = this.utils.formatDateTime(new Date())
|
|
|
|
|
- const data = await postRobotEnterpriseWeChat2(text, time)
|
|
|
|
|
|
|
+ const time = this.utils.formatDateTime(new Date());
|
|
|
|
|
+ const data = await postRobotEnterpriseWeChat2(text, time);
|
|
|
return data;
|
|
return data;
|
|
|
}
|
|
}
|
|
|
/**
|
|
/**
|
|
|
- *调用企业微信机器人发送消息Post到:数优资源报警群
|
|
|
|
|
- * @return {*}
|
|
|
|
|
- * @memberof ShuyouUtilsService
|
|
|
|
|
- */
|
|
|
|
|
|
|
+ *调用企业微信机器人发送消息Post到:数优资源报警群
|
|
|
|
|
+ * @return {*}
|
|
|
|
|
+ * @memberof ShuyouUtilsService
|
|
|
|
|
+ */
|
|
|
async postRobotEnterpriseWeChat3(text: string) {
|
|
async postRobotEnterpriseWeChat3(text: string) {
|
|
|
- const time = this.utils.formatDateTime(new Date())
|
|
|
|
|
- const data = await postRobotEnterpriseWeChat3(text, time)
|
|
|
|
|
|
|
+ const time = this.utils.formatDateTime(new Date());
|
|
|
|
|
+ const data = await postRobotEnterpriseWeChat3(text, time);
|
|
|
return data;
|
|
return data;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//=====================
|
|
//=====================
|
|
|
// 获取天气信息
|
|
// 获取天气信息
|
|
|
let getWeather = function (cityIds) {
|
|
let getWeather = function (cityIds) {
|
|
|
- var apiUrl = "http://aider.meizu.com/app/weather/listWeather?cityIds=" + cityIds;
|
|
|
|
|
|
|
+ var apiUrl =
|
|
|
|
|
+ 'http://aider.meizu.com/app/weather/listWeather?cityIds=' + cityIds;
|
|
|
var http = require('http');
|
|
var http = require('http');
|
|
|
var pm = new Promise(function (resolve, reject) {
|
|
var pm = new Promise(function (resolve, reject) {
|
|
|
- http.get(apiUrl, function (res) {
|
|
|
|
|
- var html = '';
|
|
|
|
|
- res.on('data', function (d) {
|
|
|
|
|
- html += d.toString()
|
|
|
|
|
- });
|
|
|
|
|
- res.on('end', function () {
|
|
|
|
|
- resolve(html);
|
|
|
|
|
|
|
+ http
|
|
|
|
|
+ .get(apiUrl, function (res) {
|
|
|
|
|
+ var html = '';
|
|
|
|
|
+ res.on('data', function (d) {
|
|
|
|
|
+ html += d.toString();
|
|
|
|
|
+ });
|
|
|
|
|
+ res.on('end', function () {
|
|
|
|
|
+ resolve(html);
|
|
|
|
|
+ });
|
|
|
|
|
+ })
|
|
|
|
|
+ .on('error', function (e) {
|
|
|
|
|
+ reject(e);
|
|
|
});
|
|
});
|
|
|
- }).on('error', function (e) {
|
|
|
|
|
- reject(e)
|
|
|
|
|
- });
|
|
|
|
|
});
|
|
});
|
|
|
return pm;
|
|
return pm;
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
// 钉钉机器人发送消息get
|
|
// 钉钉机器人发送消息get
|
|
|
let dingRobot = function (text: string, atMobiles: string) {
|
|
let dingRobot = function (text: string, atMobiles: string) {
|
|
|
- var access_token = '9513466adf38271afe11d02406497db43e4a8db7dbbe3d0bed2a5919efc3ac2f';
|
|
|
|
|
- var apiUrl = "https://oapi.dingtalk.com/robot/send?access_token=" + access_token;
|
|
|
|
|
|
|
+ var access_token =
|
|
|
|
|
+ '9513466adf38271afe11d02406497db43e4a8db7dbbe3d0bed2a5919efc3ac2f';
|
|
|
|
|
+ var apiUrl =
|
|
|
|
|
+ 'https://oapi.dingtalk.com/robot/send?access_token=' + access_token;
|
|
|
let content = ``;
|
|
let content = ``;
|
|
|
- let atArr
|
|
|
|
|
|
|
+ let atArr;
|
|
|
let atString = '';
|
|
let atString = '';
|
|
|
// console.log(atMobiles)
|
|
// console.log(atMobiles)
|
|
|
if (atMobiles != '') {
|
|
if (atMobiles != '') {
|
|
|
- atArr = atMobiles.split(',')
|
|
|
|
|
|
|
+ atArr = atMobiles.split(',');
|
|
|
atArr.forEach(e => {
|
|
atArr.forEach(e => {
|
|
|
atString = atString + '@' + e;
|
|
atString = atString + '@' + e;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
// console.log(atArr);
|
|
// console.log(atArr);
|
|
|
- content = atString + "**监控报警** \n" + text + "\n > ##### [点击查看详细数据](http://ykhvip.fun) \n"
|
|
|
|
|
|
|
+ content =
|
|
|
|
|
+ atString +
|
|
|
|
|
+ '**监控报警** \n' +
|
|
|
|
|
+ text +
|
|
|
|
|
+ '\n > ##### [点击查看详细数据](http://ykhvip.fun) \n';
|
|
|
// console.log(content)
|
|
// console.log(content)
|
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
|
- const axios = require('axios')
|
|
|
|
|
|
|
+ const axios = require('axios');
|
|
|
var pm = new Promise(function (resolve, reject) {
|
|
var pm = new Promise(function (resolve, reject) {
|
|
|
- axios.post(apiUrl, {
|
|
|
|
|
- "msgtype": "markdown",
|
|
|
|
|
- "markdown": {
|
|
|
|
|
- "title": "数据监控报警",
|
|
|
|
|
- "text": content
|
|
|
|
|
- },
|
|
|
|
|
- "at": {
|
|
|
|
|
- "atMobiles": atArr,
|
|
|
|
|
- // "atUserIds": [
|
|
|
|
|
- // "ykh001"
|
|
|
|
|
- // ],
|
|
|
|
|
- "isAtAll": false
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ axios
|
|
|
|
|
+ .post(apiUrl, {
|
|
|
|
|
+ msgtype: 'markdown',
|
|
|
|
|
+ markdown: {
|
|
|
|
|
+ title: '数据监控报警',
|
|
|
|
|
+ text: content,
|
|
|
|
|
+ },
|
|
|
|
|
+ at: {
|
|
|
|
|
+ atMobiles: atArr,
|
|
|
|
|
+ // "atUserIds": [
|
|
|
|
|
+ // "ykh001"
|
|
|
|
|
+ // ],
|
|
|
|
|
+ isAtAll: false,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(res => {
|
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
|
// console.log(res.data)
|
|
// console.log(res.data)
|
|
|
resolve(res.data);
|
|
resolve(res.data);
|
|
|
})
|
|
})
|
|
|
- .catch((error) => {
|
|
|
|
|
|
|
+ .catch(error => {
|
|
|
// console.error(error)
|
|
// console.error(error)
|
|
|
- reject(error)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ reject(error);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
return pm;
|
|
return pm;
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
// 钉钉机器人发送消息post
|
|
// 钉钉机器人发送消息post
|
|
|
let postRobot = function (text: string, atMobiles: []) {
|
|
let postRobot = function (text: string, atMobiles: []) {
|
|
|
- var access_token = '9513466adf38271afe11d02406497db43e4a8db7dbbe3d0bed2a5919efc3ac2f';
|
|
|
|
|
- var apiUrl = "https://oapi.dingtalk.com/robot/send?access_token=" + access_token;
|
|
|
|
|
|
|
+ var access_token =
|
|
|
|
|
+ '9513466adf38271afe11d02406497db43e4a8db7dbbe3d0bed2a5919efc3ac2f';
|
|
|
|
|
+ var apiUrl =
|
|
|
|
|
+ 'https://oapi.dingtalk.com/robot/send?access_token=' + access_token;
|
|
|
let content = ``;
|
|
let content = ``;
|
|
|
let atString = '';
|
|
let atString = '';
|
|
|
// console.log(atArr);
|
|
// console.log(atArr);
|
|
@@ -164,119 +173,140 @@ let postRobot = function (text: string, atMobiles: []) {
|
|
|
atString = atString + '@' + e;
|
|
atString = atString + '@' + e;
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
- content = atString + "**监控报警** \n" + text + "\n > ##### [点击查看详细数据](http://ykhvip.fun) \n"
|
|
|
|
|
|
|
+ content =
|
|
|
|
|
+ atString +
|
|
|
|
|
+ '**监控报警** \n' +
|
|
|
|
|
+ text +
|
|
|
|
|
+ '\n > ##### [点击查看详细数据](http://ykhvip.fun) \n';
|
|
|
// console.log(content)
|
|
// console.log(content)
|
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
|
- const axios = require('axios')
|
|
|
|
|
|
|
+ const axios = require('axios');
|
|
|
var pm = new Promise(function (resolve, reject) {
|
|
var pm = new Promise(function (resolve, reject) {
|
|
|
- axios.post(apiUrl, {
|
|
|
|
|
- "msgtype": "markdown",
|
|
|
|
|
- "markdown": {
|
|
|
|
|
- "title": "数据监控报警",
|
|
|
|
|
- "text": content
|
|
|
|
|
- },
|
|
|
|
|
- "at": {
|
|
|
|
|
- "atMobiles": atMobiles,
|
|
|
|
|
- // "atUserIds": [
|
|
|
|
|
- // "ykh001"
|
|
|
|
|
- // ],
|
|
|
|
|
- "isAtAll": false
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ axios
|
|
|
|
|
+ .post(apiUrl, {
|
|
|
|
|
+ msgtype: 'markdown',
|
|
|
|
|
+ markdown: {
|
|
|
|
|
+ title: '数据监控报警',
|
|
|
|
|
+ text: content,
|
|
|
|
|
+ },
|
|
|
|
|
+ at: {
|
|
|
|
|
+ atMobiles: atMobiles,
|
|
|
|
|
+ // "atUserIds": [
|
|
|
|
|
+ // "ykh001"
|
|
|
|
|
+ // ],
|
|
|
|
|
+ isAtAll: false,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(res => {
|
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
|
// console.log(res.data)
|
|
// console.log(res.data)
|
|
|
resolve(res.data);
|
|
resolve(res.data);
|
|
|
})
|
|
})
|
|
|
- .catch((error) => {
|
|
|
|
|
|
|
+ .catch(error => {
|
|
|
// console.error(error)
|
|
// console.error(error)
|
|
|
- reject(error)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ reject(error);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
return pm;
|
|
return pm;
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
// 企业微信机器人发送消息post(数优-加币/未完成播报群)
|
|
// 企业微信机器人发送消息post(数优-加币/未完成播报群)
|
|
|
let postRobotEnterpriseWeChat = function (text: string, time: string) {
|
|
let postRobotEnterpriseWeChat = function (text: string, time: string) {
|
|
|
var access_token = '7d095d5b-8240-45fd-a68c-baff3628d83b';
|
|
var access_token = '7d095d5b-8240-45fd-a68c-baff3628d83b';
|
|
|
- var apiUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=" + access_token;
|
|
|
|
|
|
|
+ var apiUrl =
|
|
|
|
|
+ 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=' + access_token;
|
|
|
let content = ``;
|
|
let content = ``;
|
|
|
- content = "**监控报警" + time + "** \n" + text + "\n > ##### [点击进入查看详细数据](http://ykhvip.fun) \n"
|
|
|
|
|
|
|
+ content =
|
|
|
|
|
+ '**监控报警' +
|
|
|
|
|
+ time +
|
|
|
|
|
+ '** \n' +
|
|
|
|
|
+ text +
|
|
|
|
|
+ '\n > ##### [点击进入查看详细数据](http://ykhvip.fun) \n';
|
|
|
// console.log(content)
|
|
// console.log(content)
|
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
|
- const axios = require('axios')
|
|
|
|
|
|
|
+ const axios = require('axios');
|
|
|
var pm = new Promise(function (resolve, reject) {
|
|
var pm = new Promise(function (resolve, reject) {
|
|
|
- axios.post(apiUrl, {
|
|
|
|
|
- "msgtype": "markdown",
|
|
|
|
|
- "markdown": {
|
|
|
|
|
- "content": content
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ axios
|
|
|
|
|
+ .post(apiUrl, {
|
|
|
|
|
+ msgtype: 'markdown',
|
|
|
|
|
+ markdown: {
|
|
|
|
|
+ content: content,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(res => {
|
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
|
// console.log(res.data)
|
|
// console.log(res.data)
|
|
|
resolve(res.data);
|
|
resolve(res.data);
|
|
|
})
|
|
})
|
|
|
- .catch((error) => {
|
|
|
|
|
|
|
+ .catch(error => {
|
|
|
// console.error(error)
|
|
// console.error(error)
|
|
|
- resolve(error)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ resolve(error);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
return pm;
|
|
return pm;
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
// 企业微信机器人发送消息post(数据优化-深圳项目对接群)
|
|
// 企业微信机器人发送消息post(数据优化-深圳项目对接群)
|
|
|
let postRobotEnterpriseWeChat2 = function (text: string, time: string) {
|
|
let postRobotEnterpriseWeChat2 = function (text: string, time: string) {
|
|
|
var access_token = '5ccfb180-c062-48b5-ae18-0c96f7c19f0b';
|
|
var access_token = '5ccfb180-c062-48b5-ae18-0c96f7c19f0b';
|
|
|
- var apiUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=" + access_token;
|
|
|
|
|
|
|
+ var apiUrl =
|
|
|
|
|
+ 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=' + access_token;
|
|
|
let content = ``;
|
|
let content = ``;
|
|
|
- content = "**监控报警" + time + "** \n" + text + "\n > ##### [点击进入查看详细数据](http://ykhvip.fun) \n"
|
|
|
|
|
|
|
+ content =
|
|
|
|
|
+ '**监控报警' +
|
|
|
|
|
+ time +
|
|
|
|
|
+ '** \n' +
|
|
|
|
|
+ text +
|
|
|
|
|
+ '\n > ##### [点击进入查看详细数据](http://ykhvip.fun) \n';
|
|
|
// console.log(content)
|
|
// console.log(content)
|
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
|
- const axios = require('axios')
|
|
|
|
|
|
|
+ const axios = require('axios');
|
|
|
var pm = new Promise(function (resolve, reject) {
|
|
var pm = new Promise(function (resolve, reject) {
|
|
|
- axios.post(apiUrl, {
|
|
|
|
|
- "msgtype": "markdown",
|
|
|
|
|
- "markdown": {
|
|
|
|
|
- "content": content
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ axios
|
|
|
|
|
+ .post(apiUrl, {
|
|
|
|
|
+ msgtype: 'markdown',
|
|
|
|
|
+ markdown: {
|
|
|
|
|
+ content: content,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(res => {
|
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
|
// console.log(res.data)
|
|
// console.log(res.data)
|
|
|
resolve(res.data);
|
|
resolve(res.data);
|
|
|
})
|
|
})
|
|
|
- .catch((error) => {
|
|
|
|
|
|
|
+ .catch(error => {
|
|
|
// console.error(error)
|
|
// console.error(error)
|
|
|
- resolve(error)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ resolve(error);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
return pm;
|
|
return pm;
|
|
|
-}
|
|
|
|
|
|
|
+};
|
|
|
// 企业微信机器人发送消息post(数优资源报警群)
|
|
// 企业微信机器人发送消息post(数优资源报警群)
|
|
|
let postRobotEnterpriseWeChat3 = function (text: string, time: string) {
|
|
let postRobotEnterpriseWeChat3 = function (text: string, time: string) {
|
|
|
var access_token = '34cbfa5a-c31d-464f-baf8-8363d6f4ac6a';
|
|
var access_token = '34cbfa5a-c31d-464f-baf8-8363d6f4ac6a';
|
|
|
- var apiUrl = "https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=" + access_token;
|
|
|
|
|
|
|
+ var apiUrl =
|
|
|
|
|
+ 'https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=' + access_token;
|
|
|
let content = ``;
|
|
let content = ``;
|
|
|
- content = "**资源不足报警" + time + "** \n" + text + "\n"
|
|
|
|
|
|
|
+ content = '**资源不足报警' + time + '** \n' + text + '\n';
|
|
|
// console.log(content)
|
|
// console.log(content)
|
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
// "#### @18408246387监控报警 \n > 9度,西北风1级,空气良89,相对温度73%\n > \n > ###### 10点20分发布 [天气](https://www.dingtalk.com) \n"
|
|
|
- const axios = require('axios')
|
|
|
|
|
|
|
+ const axios = require('axios');
|
|
|
var pm = new Promise(function (resolve, reject) {
|
|
var pm = new Promise(function (resolve, reject) {
|
|
|
- axios.post(apiUrl, {
|
|
|
|
|
- "msgtype": "markdown",
|
|
|
|
|
- "markdown": {
|
|
|
|
|
- "content": content
|
|
|
|
|
- }
|
|
|
|
|
- })
|
|
|
|
|
- .then((res) => {
|
|
|
|
|
|
|
+ axios
|
|
|
|
|
+ .post(apiUrl, {
|
|
|
|
|
+ msgtype: 'markdown',
|
|
|
|
|
+ markdown: {
|
|
|
|
|
+ content: content,
|
|
|
|
|
+ },
|
|
|
|
|
+ })
|
|
|
|
|
+ .then(res => {
|
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
// console.log(`statusCode: ${res.statusCode}`)
|
|
|
// console.log(res.data)
|
|
// console.log(res.data)
|
|
|
resolve(res.data);
|
|
resolve(res.data);
|
|
|
})
|
|
})
|
|
|
- .catch((error) => {
|
|
|
|
|
|
|
+ .catch(error => {
|
|
|
// console.error(error)
|
|
// console.error(error)
|
|
|
- resolve(error)
|
|
|
|
|
- })
|
|
|
|
|
|
|
+ resolve(error);
|
|
|
|
|
+ });
|
|
|
});
|
|
});
|
|
|
return pm;
|
|
return pm;
|
|
|
-}
|
|
|
|
|
|
|
+};
|