增加:国家电网停电通知 (#1260)

Closes #1117
This commit is contained in:
凉凉 2018-12-11 11:32:50 +08:00 committed by DIYgod
parent 02ff8826c3
commit 73a01a1ff0
3 changed files with 57 additions and 0 deletions

View File

@ -1853,6 +1853,12 @@ Solidot 提供的 feed:
<route name="东莞市" author="victoriqueko" example="/tingshuitz/dongguan" path="/tingshuitz/dongguan"/>
### 停电通知
<route name="国家电网" author="xyqfer" example="/tingdiantz/95598/36401/36101/2018-12-11/2018-12-18" path="/tingdiantz/95598/:orgNo/:provinceNo/:outageStartTime/:outageEndTime/:scope?" :paramsDesc="['所属省供电公司编码', '所属地市供电公司编码', '开始时间', '结束时间', '停电范围关键字']"/>
> 以上参数可从[查询页面](http://m.95598.cn/95598/woutageNotice/winitOutageNotice)打开控制台抓包获得
### 中央气象台
<route name="全国气象预警" author="ylc395" example="/weatheralarm" path="/weatheralarm">

View File

@ -911,4 +911,7 @@ router.get('/shanbay/checkin/:id', require('./routes/shanbay/checkin'));
// Facebook
router.get('/facebook/page/:id', require('./routes/facebook/page'));
// 停电通知
router.get('/tingdiantz/95598/:orgNo/:provinceNo/:outageStartTime/:outageEndTime/:scope?', require('./routes/tingdiantz/95598'));
module.exports = router;

View File

@ -0,0 +1,48 @@
const axios = require('../../utils/axios');
const qs = require('querystring');
module.exports = async (ctx) => {
const { orgNo, provinceNo, outageStartTime, outageEndTime, scope = '' } = ctx.params;
const anHui = provinceNo === '34101' ? '01' : '02';
const response = await axios({
method: 'post',
url: 'http://m.95598.cn/95598/woutageNotice/wqueryOutageNoticeList?partNo=BM08001',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
data: qs.stringify({
orgNo,
provinceNo,
outageStartTime,
outageEndTime,
scope,
anHui,
}),
});
const items = (response.data.seleList || []).map((item) => {
const title = `${item.subsName} | ${item.typeCode || ''}`;
const description = `
<strong>停电时间</strong>${item.startTime} - ${item.stopTime} <br>
<strong>停电范围</strong>${item.scope} <br>
<strong>停电线路</strong>${item.lineName} <br>
<strong>公变名称</strong>${item.pubTranName} <br>
<strong>停电原因</strong>${item.poweroffReason} <br>
`;
const guid = item.powerOffId;
const pubDate = new Date(item.startTime).toUTCString();
return {
title,
description,
guid,
pubDate,
};
});
ctx.state.data = {
title: '国家电网停电通知',
link: 'http://m.95598.cn/95598/woutageNotice/winitOutageNotice',
item: items,
};
};