From 6557da5ccc9012c3051b5796278755ac5f6c3d28 Mon Sep 17 00:00:00 2001 From: Archer_cdm Date: Wed, 23 Nov 2022 11:44:43 +0800 Subject: [PATCH] =?UTF-8?q?=EF=BC=88+=EF=BC=89=E6=9F=A5=E8=AF=A2=E5=82=A8?= =?UTF-8?q?=E5=A4=87=E9=A1=B9=E7=9B=AE=E7=BB=9F=E8=AE=A1=E8=A1=A8GET/getRe?= =?UTF-8?q?serveItemReport?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/launch.json | 8 +++--- api/app/lib/controllers/report/index.js | 23 +++++++++++++++++ api/app/lib/models/reserveItemReport.js | 33 +++++++++++++++++++++++++ api/app/lib/routes/report/index.js | 8 ++++++ 4 files changed, 68 insertions(+), 4 deletions(-) create mode 100644 api/app/lib/controllers/report/index.js create mode 100644 api/app/lib/models/reserveItemReport.js create mode 100644 api/app/lib/routes/report/index.js 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