周沫沫历险记 2 years ago
parent
commit
92b4a11107
  1. 8
      .vscode/launch.json
  2. 23
      api/app/lib/controllers/report/index.js
  3. 33
      api/app/lib/models/reserveItemReport.js
  4. 8
      api/app/lib/routes/report/index.js

8
.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",
]
},

23
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
}

33
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;
};

8
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);
};
Loading…
Cancel
Save