zs 2 years ago
parent
commit
04186da5ac

+ 3 - 3
src/controller/transtion.controller.ts

@@ -16,7 +16,7 @@ import {
   FVO_transtion,
   FVO_transtion,
   QDTO_transtion,
   QDTO_transtion,
   QVO_transtion,
   QVO_transtion,
-  UDTO_transtion,
+  // UDTO_transtion,
   UVAO_transtion,
   UVAO_transtion,
 } from '../interface/transtion.interface';
 } from '../interface/transtion.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
@@ -64,8 +64,8 @@ export class TranstionController extends BaseController {
   @Post('/:id')
   @Post('/:id')
   @Validate()
   @Validate()
   @ApiResponse({ type: UVAO_transtion })
   @ApiResponse({ type: UVAO_transtion })
-  async update(@Param('id') id: string, @Body() body: UDTO_transtion) {
-    const result = await this.service.updateOne(id, body);
+  async update(@Param('id') id: string, @Body() body: any) {
+    const result = await this.service.update(id, body);
     return result;
     return result;
   }
   }
 
 

+ 1 - 1
src/entity/transtion.entity.ts

@@ -24,7 +24,7 @@ export class Transtion extends BaseModel {
   @prop({ required: false, index: true, zh: '专利名称' })
   @prop({ required: false, index: true, zh: '专利名称' })
   patent_name: string;
   patent_name: string;
   @prop({ required: false, index: true, zh: '申请号' })
   @prop({ required: false, index: true, zh: '申请号' })
-  crete_number: string;
+  create_number: string;
   @prop({ required: false, index: true, zh: '当前权利人(变更前专利权人)' })
   @prop({ required: false, index: true, zh: '当前权利人(变更前专利权人)' })
   on_obligee: string;
   on_obligee: string;
   @prop({ required: false, index: true, zh: '联系人' })
   @prop({ required: false, index: true, zh: '联系人' })

+ 4 - 4
src/interface/transtion.interface.ts

@@ -29,7 +29,7 @@ export class FVO_transtion {
   @ApiProperty({ description: '专利名称' })
   @ApiProperty({ description: '专利名称' })
   'patent_name': string = undefined;
   'patent_name': string = undefined;
   @ApiProperty({ description: '申请号' })
   @ApiProperty({ description: '申请号' })
-  'crete_number': string = undefined;
+  'create_number': string = undefined;
   @ApiProperty({ description: '当前权利人(变更前专利权人)' })
   @ApiProperty({ description: '当前权利人(变更前专利权人)' })
   'on_obligee': string = undefined;
   'on_obligee': string = undefined;
   @ApiProperty({ description: '联系人' })
   @ApiProperty({ description: '联系人' })
@@ -81,7 +81,7 @@ export class QDTO_transtion extends SearchBase {
       'user_name',
       'user_name',
       'patent_id',
       'patent_id',
       'patent_name',
       'patent_name',
-      'crete_number',
+      'create_number',
       'on_obligee',
       'on_obligee',
       'contact',
       'contact',
       'phone',
       'phone',
@@ -111,7 +111,7 @@ export class QDTO_transtion extends SearchBase {
   @ApiProperty({ description: '专利名称' })
   @ApiProperty({ description: '专利名称' })
   'patent_name': string = undefined;
   'patent_name': string = undefined;
   @ApiProperty({ description: '申请号' })
   @ApiProperty({ description: '申请号' })
-  'crete_number': string = undefined;
+  'create_number': string = undefined;
   @ApiProperty({ description: '当前权利人(变更前专利权人)' })
   @ApiProperty({ description: '当前权利人(变更前专利权人)' })
   'on_obligee': string = undefined;
   'on_obligee': string = undefined;
   @ApiProperty({ description: '联系人' })
   @ApiProperty({ description: '联系人' })
@@ -165,7 +165,7 @@ export class CDTO_transtion {
   'patent_name': string = undefined;
   'patent_name': string = undefined;
   @ApiProperty({ description: '申请号' })
   @ApiProperty({ description: '申请号' })
   @Rule(RuleType['string']().empty(''))
   @Rule(RuleType['string']().empty(''))
-  'crete_number': string = undefined;
+  'create_number': string = undefined;
   @ApiProperty({ description: '当前权利人(变更前专利权人)' })
   @ApiProperty({ description: '当前权利人(变更前专利权人)' })
   @Rule(RuleType['string']().empty(''))
   @Rule(RuleType['string']().empty(''))
   'on_obligee': string = undefined;
   'on_obligee': string = undefined;

+ 13 - 9
src/service/patent.service.ts

@@ -225,8 +225,8 @@ export class PatentService extends BaseService<modelType> {
           );
           );
           // res = await this.model.findOne({ create_number: obj.create_number });
           // res = await this.model.findOne({ create_number: obj.create_number });
         }
         }
-        // // 处理警告
-        // if (res.term === '1') this.dealData([res]);
+        // 处理警告
+        if (res.term === '1') this.dealData([res]);
       } catch (error) {
       } catch (error) {
         allNotice.push(`申请号 为${create_number} 的 专利信息 创建失败!`);
         allNotice.push(`申请号 为${create_number} 的 专利信息 创建失败!`);
         continue;
         continue;
@@ -262,15 +262,15 @@ export class PatentService extends BaseService<modelType> {
     }
     }
     // 将数据分割,否则容易直接把js堆栈干满了,服务就炸了
     // 将数据分割,否则容易直接把js堆栈干满了,服务就炸了
     const head = meta.map(i => i.label);
     const head = meta.map(i => i.label);
-    for (let i = 0; i < total; i = i + query.end_num) {
+    for (let i = 0; i < total; i = i + parseInt(query.end_num)) {
       try {
       try {
         const workbook = new Excel.Workbook();
         const workbook = new Excel.Workbook();
         const sheet = workbook.addWorksheet('sheet');
         const sheet = workbook.addWorksheet('sheet');
         sheet.addRow(head);
         sheet.addRow(head);
         const list = await this.model
         const list = await this.model
           .find(query.filter)
           .find(query.filter)
-          .skip(query.start_num)
-          .limit(query.end_num);
+          .skip(parseInt(query.start_num))
+          .limit(parseInt(query.end_num));
         for (let k = 0; k < list.length; k++) {
         for (let k = 0; k < list.length; k++) {
           const d = list[k];
           const d = list[k];
           const arr = [];
           const arr = [];
@@ -310,17 +310,21 @@ export class PatentService extends BaseService<modelType> {
               }
               }
             } else if (model === 'type') {
             } else if (model === 'type') {
               const data = typeList.data.find(i => i.value === d[model]);
               const data = typeList.data.find(i => i.value === d[model]);
-              arr.push(data.label);
+              if (data && data.label) arr.push(data.label);
+              else arr.push(d[model]);
             } else if (model === 'term') {
             } else if (model === 'term') {
               const data = termList.data.find(i => i.value === d[model]);
               const data = termList.data.find(i => i.value === d[model]);
-              arr.push(data.label);
+              if (data && data.label) arr.push(data.label);
+              else arr.push(d[model]);
             } else arr.push(d[model]);
             } else arr.push(d[model]);
           }
           }
           sheet.addRow(arr);
           sheet.addRow(arr);
         }
         }
-        skip = skip + query.end_num;
+        skip = skip + parseInt(query.end_num);
         // 生成excel
         // 生成excel
-        const filename = `专利信息导出结果(${i + 1}-${i + query.end_num}).xlsx`;
+        const filename = `专利信息导出结果(${i + 1}-${
+          i + parseInt(query.end_num)
+        }).xlsx`;
         const filePath = `${path}${sep}${filename}`;
         const filePath = `${path}${sep}${filename}`;
         console.log(filePath);
         console.log(filePath);
         await workbook.xlsx.writeFile(filePath);
         await workbook.xlsx.writeFile(filePath);

+ 158 - 0
src/service/transtion.service.ts

@@ -3,9 +3,167 @@ import { InjectEntityModel } from '@midwayjs/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
 import { ReturnModelType } from '@typegoose/typegoose';
 import { BaseService } from 'free-midway-component';
 import { BaseService } from 'free-midway-component';
 import { Transtion } from '../entity/transtion.entity';
 import { Transtion } from '../entity/transtion.entity';
+import { ExamNotice } from '../entity/examNotice.entity';
+const moment = require('moment');
 type modelType = ReturnModelType<typeof Transtion>;
 type modelType = ReturnModelType<typeof Transtion>;
 @Provide()
 @Provide()
 export class TranstionService extends BaseService<modelType> {
 export class TranstionService extends BaseService<modelType> {
   @InjectEntityModel(Transtion)
   @InjectEntityModel(Transtion)
   model: modelType;
   model: modelType;
+
+  @InjectEntityModel(ExamNotice)
+  examModel: ReturnModelType<typeof ExamNotice>;
+
+  //添加处理数据
+  async create(body) {
+    const { status, user_id, mech_id, user_name, patent_name } = body;
+    if (status === '0') {
+      const info = {
+        status: status,
+        create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+        save_id: user_id,
+        save_name: user_name,
+        content: `${user_name}提交了${patent_name}专利的交易信息,请及时查看并处理`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: user_id,
+        send_date: info.create_time,
+        receive_id: mech_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    }
+    const res = await this.model.create(body);
+    return res;
+  }
+
+  // 修改处理数据
+  async update(id, body) {
+    const {
+      status,
+      user_id,
+      user_name,
+      patent_name,
+      mech_id,
+      mech_name,
+      desc,
+    } = body;
+    if (status === '0') {
+      const info = {
+        status: status,
+        create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+        save_id: user_id,
+        save_name: user_name,
+        content: `${user_name}提交了${patent_name}专利的交易信息,请及时查看并处理`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: user_id,
+        send_date: info.create_time,
+        receive_id: mech_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    } else if (status === '1' || status === '2') {
+      const info = {
+        status: status,
+        create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+        save_id: mech_id,
+        save_name: mech_name,
+        content: `${user_name}提交了${patent_name}专利的交易信息已经审核完成,审核意见:${
+          desc || '无'
+        },请及时查看审核通知消息`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: mech_id,
+        send_date: info.create_time,
+        receive_id: user_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    } else if (status === '3') {
+      const info = {
+        status: status,
+        create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+        save_id: user_id,
+        save_name: user_name,
+        content: `${user_name}提交了${patent_name}专利的交易信息的合同,请及时查看并处理`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: user_id,
+        send_date: info.create_time,
+        receive_id: mech_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    } else if (status === '4' || status === '5') {
+      const info: any = {
+        status: status,
+        create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+        save_id: mech_id,
+        save_name: mech_name,
+        content: `${user_name}提交了${patent_name}专利的交易信息已经审核完成,审核意见:${
+          desc || '无'
+        },请及时查看审核通知消息`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: mech_id,
+        send_date: info.create_time,
+        receive_id: user_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    } else if (status === '6') {
+      const info: any = {
+        status: status,
+        create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+        save_id: user_id,
+        save_name: user_name,
+        content: `${user_name}提交了${patent_name}专利的交易信息的合同,用户已确认。请及时查看并处理`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: user_id,
+        send_date: info.create_time,
+        receive_id: mech_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    } else if (status === '7') {
+      const info: any = {
+        status: status,
+        create_time: moment().format('YYYY-MM-DD HH:mm:ss'),
+        save_id: mech_id,
+        save_name: mech_name,
+        content: `${user_name}提交了${patent_name}专利的交易信息已经完成信息归档,交易完成,请及时查看审核通知消息`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: mech_id,
+        send_date: info.create_time,
+        receive_id: user_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    }
+    await this.model.updateOne({ _id: id }, body);
+  }
 }
 }

+ 22 - 0
src/timer/scheduleService.ts

@@ -0,0 +1,22 @@
+import {
+  Provide,
+  Inject,
+  ServerlessTrigger,
+  ServerlessTriggerType,
+} from '@midwayjs/core';
+import { Context, SCF } from '@midwayjs/faas';
+
+@Provide()
+export class HelloTencentService {
+  @Inject()
+  ctx: Context;
+
+  @ServerlessTrigger(ServerlessTriggerType.TIMER, {
+    type: 'cron',
+    value: '*/60 * * * * * *', // 每 60s 触发
+  })
+  async handleTimerEvent(event: SCF.TimerEvent) {
+    this.ctx.logger.info(event);
+    return 'hello world';
+  }
+}

+ 0 - 20
test/controller/api.test.ts

@@ -1,20 +0,0 @@
-import { createApp, close, createHttpRequest } from '@midwayjs/mock';
-import { Framework } from '@midwayjs/koa';
-
-describe('test/controller/home.test.ts', () => {
-
-  it('should POST /api/get_user', async () => {
-    // create app
-    const app = await createApp<Framework>();
-
-    // make request
-    const result = await createHttpRequest(app).get('/api/get_user').query({ uid: 123 });
-
-    // use expect by jest
-    expect(result.status).toBe(200);
-    expect(result.body.message).toBe('OK');
-
-    // close app
-    await close(app);
-  });
-});