index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. 'use strict';
  2. const Controller = require('egg').Controller;
  3. const { CrudController } = require('naf-framework-mongoose/lib/controller');
  4. const meta = require('./.index.js');
  5. // 首页-数据动态统计
  6. class IndexController extends Controller {
  7. constructor(ctx) {
  8. super(ctx);
  9. this.service = this.ctx.service.statistics.index;
  10. }
  11. async index() {
  12. const patent = await this.service.patent(this.ctx.query);
  13. const product = await this.service.product(this.ctx.query);
  14. const expert = await this.service.expert(this.ctx.query);
  15. const circle = await this.service.circle(this.ctx.query);
  16. this.ctx.ok({ data: { patent, product, expert, circle } });
  17. }
  18. /**
  19. * 首页专利统计
  20. */
  21. async patent() {
  22. const data = await this.service.patent(this.ctx.query);
  23. this.ctx.ok({ data });
  24. }
  25. /**
  26. * 首页成果统计
  27. */
  28. async product() {
  29. const data = await this.service.product(this.ctx.query);
  30. this.ctx.ok({ data });
  31. }
  32. /**
  33. * 首页成果统计
  34. */
  35. async expert() {
  36. const data = await this.service.expert(this.ctx.query);
  37. this.ctx.ok({ data });
  38. }
  39. /**
  40. * 首页数据统计
  41. */
  42. async circle() {
  43. const data = await this.service.circle(this.ctx.query);
  44. this.ctx.ok({ data });
  45. }
  46. async dockIndex() {
  47. const res = await this.service.dockIndex(this.ctx.query);
  48. this.ctx.ok({ data: res });
  49. }
  50. /**
  51. * 企业数量统计
  52. */
  53. async orgCount() {
  54. const res = await this.ctx.service.users.organization.count(this.ctx.query);
  55. this.ctx.ok({ data: res });
  56. }
  57. /**
  58. * 创新券申请统计
  59. */
  60. async policyApplyCount() {
  61. const data = await this.service.pac();
  62. this.ctx.ok({ data });
  63. }
  64. /**
  65. * 高企申报个步骤统计
  66. */
  67. async declare() {
  68. const data = await this.service.declare();
  69. this.ctx.ok({ data });
  70. }
  71. async dockProduct() {
  72. const query = this.ctx.query;
  73. const arr = ['skip', 'limit', 'dock_id'];
  74. for (const key in query) {
  75. const r = arr.find((f) => f === key);
  76. if (!r) {
  77. query[`productList.${key}`] = query[key];
  78. delete query[key];
  79. }
  80. }
  81. const data = await this.service.dockProduct(query);
  82. this.ctx.ok(data);
  83. }
  84. // 专利运营用户首页统计
  85. async patentUserIndex() {
  86. const data = await this.service.patentUserIndex(this.ctx.query);
  87. this.ctx.ok({ data });
  88. }
  89. /**
  90. * 根据申请人统计,申请人所在的专利信息数量
  91. */
  92. async patentInfoByApplyPerson() {
  93. const data = await this.service.patentInfoByApplyPerson();
  94. this.ctx.ok({ data });
  95. }
  96. }
  97. module.exports = CrudController(IndexController, meta);