liujiangyong
2 years ago
7 changed files with 146 additions and 19 deletions
@ -0,0 +1,36 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
async function getPatrolReport(ctx, next) { |
||||
|
try { |
||||
|
const models = ctx.fs.dc.models; |
||||
|
const { limit, page, projectId, startTime, endTime } = ctx.query; |
||||
|
let options = { |
||||
|
where: {} |
||||
|
}; |
||||
|
if (limit) { |
||||
|
options.limit = Number(limit); |
||||
|
} |
||||
|
if (page && limit) { |
||||
|
options.offset = Number(page) * Number(limit); |
||||
|
} |
||||
|
if (projectId) { |
||||
|
options.where.projectId = projectId; |
||||
|
} |
||||
|
if (startTime && endTime) { |
||||
|
options.where.inspectTm = { $between: [startTime, endTime] }; |
||||
|
} |
||||
|
const res = await models.ReportInfo.findAndCountAll(options); |
||||
|
ctx.status = 200; |
||||
|
ctx.body = res; |
||||
|
} catch (error) { |
||||
|
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`); |
||||
|
ctx.status = 400; |
||||
|
ctx.body = { |
||||
|
"message": "获取巡检报告失败" |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
module.exports = { |
||||
|
getPatrolReport, |
||||
|
} |
@ -0,0 +1,60 @@ |
|||||
|
/* eslint-disable*/ |
||||
|
'use strict'; |
||||
|
|
||||
|
module.exports = dc => { |
||||
|
const DataTypes = dc.ORM; |
||||
|
const sequelize = dc.orm; |
||||
|
const ReportInfo = sequelize.define("reportInfo", { |
||||
|
id: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: true, |
||||
|
field: "id", |
||||
|
autoIncrement: true, |
||||
|
}, |
||||
|
projectId: { |
||||
|
type: DataTypes.INTEGER, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "project_id", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
excelPath: { |
||||
|
type: DataTypes.STRING, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "excel_path", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
inspectTm: { |
||||
|
type: DataTypes.DATE, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "inspect_tm", |
||||
|
autoIncrement: false |
||||
|
}, |
||||
|
reportTm: { |
||||
|
type: DataTypes.DATE, |
||||
|
allowNull: false, |
||||
|
defaultValue: null, |
||||
|
comment: null, |
||||
|
primaryKey: false, |
||||
|
field: "report_tm", |
||||
|
autoIncrement: false |
||||
|
} |
||||
|
}, { |
||||
|
tableName: "report_info", |
||||
|
comment: "", |
||||
|
indexes: [] |
||||
|
}); |
||||
|
dc.models.ReportInfo = ReportInfo; |
||||
|
return ReportInfo; |
||||
|
}; |
@ -0,0 +1,8 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
const patrolReport = require('../../controllers/patrolManage/patrolReport'); |
||||
|
|
||||
|
module.exports = function (app, router, opts) { |
||||
|
app.fs.api.logAttr['GET/patrolReport'] = { content: '获取巡检报告', visible: false }; |
||||
|
router.get('/patrolReport', patrolReport.getPatrolReport); |
||||
|
}; |
Loading…
Reference in new issue