diff --git a/.vscode/launch.json b/.vscode/launch.json index ffb06bd..a1edc07 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -16,12 +16,12 @@ "-p 4700", // "-f http://localhost:4700", // 研发 - "-g postgres://postgres:123@10.8.30.166:5432/hr-dev", + "-g postgres://postgres:123456@10.8.16.184:5432/ReportCenter", "--redisHost localhost", - "--redisPort 6379", + "--redisPort 6378", // "--apiEmisUrl http://10.8.30.112:14000", // 测试 - "--apiEmisUrl http://10.8.30.161:1111", + "--apiEmisUrl http://localhost:4000", "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", "--qnbkt dev-hr", @@ -41,7 +41,7 @@ // "--clickHouseHr hr_dev", // 测试 - "--clickHouseUrl http://10.8.30.161", + "--clickHouseUrl http://10.8.16.221", "--clickHousePepEmis pg_pepca", ] }, diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js new file mode 100644 index 0000000..ccf3581 --- /dev/null +++ b/api/app/lib/controllers/report/index.js @@ -0,0 +1,23 @@ +'use strict'; + +// 查询储备项目统计表 +async function getReserveItemReport(ctx, next) { + const { type } = ctx.request.query; + let rslt = null; + try { + rslt = await ctx.fs.dc.models.ReserveItemReport.findAll({ + order: [['year', 'DESC'], ['month', 'DESC']], + where: { type: type } + }) + ctx.status = 200 + ctx.body = rslt + } catch (error) { + ctx.fs.logger.error(`path:${ctx.path},error:${error}`) + ctx.status = 400; + ctx.body = { name: 'FindAllError', message: '获取失败' } + } +} + +module.exports = { + getReserveItemReport +} \ No newline at end of file diff --git a/api/app/lib/models/reserveItemReport.js b/api/app/lib/models/reserveItemReport.js new file mode 100644 index 0000000..ad60d12 --- /dev/null +++ b/api/app/lib/models/reserveItemReport.js @@ -0,0 +1,33 @@ +/* eslint-disable*/ +'use strict'; + +module.exports = dc => { + const DataTypes = dc.ORM; + const sequelize = dc.orm; + const ReserveItemReport = sequelize.define("reserveItemReport", { + year: { + type: DataTypes.INTEGER, + allowNull: true, + field: "year", + }, + month: { + type: DataTypes.INTEGER, + allowNull: true, + field: "month", + }, + path: { + type: DataTypes.STRING, + allowNull: false, + field: "path", + }, + type: { + type: DataTypes.STRING, + allowNull: true, + field: "type", + } + }, { + tableName: "reserve_item_report", + }); + dc.models.ReserveItemReport = ReserveItemReport; + return ReserveItemReport; +}; \ No newline at end of file diff --git a/api/app/lib/routes/report/index.js b/api/app/lib/routes/report/index.js new file mode 100644 index 0000000..62b9527 --- /dev/null +++ b/api/app/lib/routes/report/index.js @@ -0,0 +1,8 @@ +'use strict'; + +const report = require('../../controllers/report'); + +module.exports = function (app, router, opts) { + app.fs.api.logAttr['GET/getReserveItemReport'] = { content: '查询储备项目统计表', visible: false }; + router.get('/getReserveItemReport', report.getReserveItemReport); +}; \ No newline at end of file