四好公路
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

60 lines
1.8 KiB

'use strict';
const moment = require('moment')
const reportTypeText = (text) => {
switch (text) {
case 'road': return '道路';
//
case 'countyRoad': return '县道';
case 'villageRoad': return '乡道';
case 'rusticRoad': return '村道';
//
case 'bridge': return '桥梁';
case 'culvert': return '涵洞';
case 'other': return '其他';
//
case 'conserve': return '养护';
case 'patrol': return '巡查';
case 'construction': return '在建';
default: return text;
}
}
async function appoint(ctx) {
try {
const models = ctx.fs.dc.models
const { recordId, performerId, handleAdvice, handleState } = ctx.request.body
await models.Report.update({
performerId, handleAdvice, handleState
}, { where: { id: recordId } })
const { pushBySms } = ctx.app.fs.utils
const report = await models.Report.findOne({ where: { id: recordId } })
const data = await models.User.findOne({ where: { id: performerId } })
if (data.phone && data.name && report.projectType) {
await pushBySms({
phone: [data.phone],
templateCode: 'SMS_464820121',
templateParam: {
report_name: data.name,
type: reportTypeText(report.projectType),
road_name: report.road,
section_name: report.roadSectionStart + report.roadSectionEnd
}
})
}
ctx.status = 204;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
module.exports = {
appoint
};