|
@ -646,6 +646,7 @@ function getTemplate(opts){ |
|
|
function reportQuest(opts){ |
|
|
function reportQuest(opts){ |
|
|
return async function (ctx, next){ |
|
|
return async function (ctx, next){ |
|
|
try{ |
|
|
try{ |
|
|
|
|
|
const transaction = await ctx.fs.dc.orm.transaction(); |
|
|
const models = ctx.fs.dc.models; |
|
|
const models = ctx.fs.dc.models; |
|
|
const data = ctx.request.body; |
|
|
const data = ctx.request.body; |
|
|
let { patrolPlanId, inspectionTime, points, alarm, pointId, projectId } = data |
|
|
let { patrolPlanId, inspectionTime, points, alarm, pointId, projectId } = data |
|
@ -665,10 +666,18 @@ function reportQuest(opts){ |
|
|
alarm, |
|
|
alarm, |
|
|
pointId: pointId, |
|
|
pointId: pointId, |
|
|
projectId |
|
|
projectId |
|
|
} |
|
|
},{transaction} |
|
|
); |
|
|
); |
|
|
|
|
|
if (alarm) { |
|
|
|
|
|
await models.PatrolRecordIssueHandle.create({ |
|
|
|
|
|
patrolRecordId: recordRes.id, |
|
|
|
|
|
state: 1, |
|
|
|
|
|
}, { transaction }); |
|
|
|
|
|
} |
|
|
|
|
|
await transaction.commit(); |
|
|
ctx.status = 204; |
|
|
ctx.status = 204; |
|
|
}catch(error){ |
|
|
}catch(error){ |
|
|
|
|
|
await transaction.rollback(); |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
|
|
ctx.status = 400; |
|
|
ctx.status = 400; |
|
|
ctx.body = { message: '上报问题失败' } |
|
|
ctx.body = { message: '上报问题失败' } |
|
|