zs 1 year ago
parent
commit
ab1db7be2d

+ 8 - 8
src/config/config.local.ts

@@ -25,14 +25,14 @@ export default {
       },
     },
   },
-  // redis: {
-  //   client: {
-  //     port: 6379, // Redis port
-  //     host: '120.48.146.1', // Redis host
-  //     password: '123456',
-  //     db: 4,
-  //   },
-  // },
+  redis: {
+    client: {
+      port: 6379, // Redis port
+      host: '120.48.146.1', // Redis host
+      password: '123456',
+      db: 4,
+    },
+  },
   axios: {
     clients: {
       zkzx_admin: {

+ 8 - 8
src/config/config.prod.ts

@@ -25,14 +25,14 @@ export default {
       },
     },
   },
-  // redis: {
-  //   client: {
-  //     port: 6379, // Redis port
-  //     host: '120.48.146.1', // Redis host
-  //     password: '123456',
-  //     db: 4,
-  //   },
-  // },
+  redis: {
+    client: {
+      port: 6379, // Redis port
+      host: '120.48.146.1', // Redis host
+      password: '123456',
+      db: 4,
+    },
+  },
   axios: {
     clients: {
       zkzx_admin: {

+ 10 - 0
src/controller/patent.controller.ts

@@ -24,12 +24,16 @@ import {
 } from '../interface/patent.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { Validate } from '@midwayjs/validate';
+import { RedisService } from '@midwayjs/redis';
 @ApiTags(['e专利'])
 @Controller('/patent')
 export class PatentController extends BaseController {
   @Inject()
   service: PatentService;
 
+  @Inject()
+  redisService: RedisService;
+
   @Post('/')
   @Validate()
   @ApiResponse({ type: CVO_patent })
@@ -60,6 +64,12 @@ export class PatentController extends BaseController {
     return result;
   }
 
+  @Get('/findFromQueue')
+  async findFromQueue() {
+    const result = await this.redisService.get('file');
+    return result || {};
+  }
+
   @Post('/:id')
   @Validate()
   @ApiResponse({ type: UVAO_patent })

+ 5 - 0
src/service/patent.service.ts

@@ -11,6 +11,7 @@ import { PatentWarning } from '../entity/patentWarning.entity';
 import { HttpServiceFactory, HttpService } from '@midwayjs/axios';
 import { Config, InjectClient } from '@midwayjs/core';
 import { RabbitmqService } from './util/rabbitmq';
+import { RedisService } from '@midwayjs/redis';
 const assert = require('assert');
 const Excel = require('exceljs');
 import _ = require('lodash');
@@ -46,6 +47,9 @@ export class PatentService extends BaseService<modelType> {
   @Inject()
   rabbitmqService: RabbitmqService;
 
+  @Inject()
+  redisService: RedisService;
+
   async beforeQuery(query) {
     const _id = _.get(this.ctx.user, '_id');
     const type = _.get(this.ctx.user, 'type');
@@ -387,6 +391,7 @@ export class PatentService extends BaseService<modelType> {
         uri: downloadPath,
         remark: '打包成功',
       };
+      this.redisService.set('file', data.uri);
       this.sendToMQ(data);
     } catch (error) {
       const data = {