Browse Source

异常上报之短信推送

dev
CODE 2 years ago
parent
commit
44674c2fa4
  1. 3
      api/app/lib/index.js
  2. 1
      api/app/lib/schedule/index.js
  3. 55
      api/app/lib/schedule/noticeAbnormal.js
  4. 2
      api/app/lib/schedule/zhidiao.js
  5. 1
      api/config.js

3
api/app/lib/index.js

@ -94,6 +94,9 @@ module.exports.models = function (dc) { // dc = { orm: Sequelize对象, ORM: Seq
VillageDistance.belongsTo(Village, { foreignKey: 'calcVillage', targetKey: 'id' });
Village.hasMany(VillageDistance, { foreignKey: 'calcVillage', sourceKey: 'id' });
Report.belongsTo(Road, { foreignKey: 'roadId', targetKey: 'id', as: 'road_' });
Road.hasMany(Report, { foreignKey: 'roadId', sourceKey: 'id', as: 'road_' });
};

1
api/app/lib/schedule/index.js

@ -17,6 +17,7 @@ module.exports = async function (app, opts) {
}
const j = nodeSchedule.scheduleJob(interval, callback);
if (immediate && (!proRun || (proRun && !opts.dev))) {
console.log(22222);
setTimeout(callback, 0)
}
return j;

55
api/app/lib/schedule/noticeAbnormal.js

@ -0,0 +1,55 @@
const moment = require('moment')
let isDev = false
isDev = true
module.exports = function (app, opts) {
const notice = app.fs.scheduleInit(
{
interval: '0 9 */1 * * *',
immediate: isDev && opts.dev,
proRun: !isDev,
disabled: false
},
async () => {
try {
const { models, ORM: sequelize } = app.fs.dc
console.log(123123);
const anomalyList = await models.Report.findAll({
where: {
handleState: null,
reportType: 'anomaly',
time: {
[sequelize.Op.lt]: moment().subtract(3, 'days').format('YYYY-MM-DD HH:mm:ss')
}
},
include: [{
model: models.User,
}, {
model: models.Road,
as: 'road_'
}]
})
for (let i = 0; i < anomalyList.length; i++) {
const anomaly = anomalyList[i]
/**
* 通过XX反馈类型反馈XX所道路的XX所属路段路段具体位置于XXXXXX反馈内容XXX上报人上报时间XX您已超过3天未处理请至平台尽快处理
*/
}
console.log(anomalyList);
} catch (error) {
console.error(error);
}
}
)
return {
notice,
}
}

2
api/app/lib/schedule/zhidiao.js

@ -9,7 +9,7 @@ module.exports = function (app, opts) {
{
interval: '24 0 */1 * * *',
immediate: true,
proRun: false,
proRun: true,
disabled: false
},

1
api/config.js

@ -57,6 +57,7 @@ if (
const product = {
port: flags.port || 8080,
staticDirs: ['static'],
dev: dev,
mws: [
{
entry: require('@fs/attachment').entry,

Loading…
Cancel
Save