瀏覽代碼

价值评估

zs 2 年之前
父節點
當前提交
72ed19539b
共有 2 個文件被更改,包括 114 次插入3 次删除
  1. 3 3
      src/controller/assessment.controller.ts
  2. 111 0
      src/service/assessment.service.ts

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

@@ -16,7 +16,7 @@ import {
   FVO_assessment,
   FVO_assessment,
   QDTO_assessment,
   QDTO_assessment,
   QVO_assessment,
   QVO_assessment,
-  UDTO_assessment,
+  // UDTO_assessment,
   UVAO_assessment,
   UVAO_assessment,
 } from '../interface/assessment.interface';
 } from '../interface/assessment.interface';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
 import { ApiResponse, ApiTags, ApiQuery } from '@midwayjs/swagger';
@@ -64,8 +64,8 @@ export class AssessmentController extends BaseController {
   @Post('/:id')
   @Post('/:id')
   @Validate()
   @Validate()
   @ApiResponse({ type: UVAO_assessment })
   @ApiResponse({ type: UVAO_assessment })
-  async update(@Param('id') id: string, @Body() body: UDTO_assessment) {
-    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;
   }
   }
 
 

+ 111 - 0
src/service/assessment.service.ts

@@ -3,9 +3,120 @@ 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 { Assessment } from '../entity/assessment.entity';
 import { Assessment } from '../entity/assessment.entity';
+import { ExamNotice } from '../entity/examNotice.entity';
+const moment = require('moment');
 type modelType = ReturnModelType<typeof Assessment>;
 type modelType = ReturnModelType<typeof Assessment>;
 @Provide()
 @Provide()
 export class AssessmentService extends BaseService<modelType> {
 export class AssessmentService extends BaseService<modelType> {
   @InjectEntityModel(Assessment)
   @InjectEntityModel(Assessment)
   model: modelType;
   model: modelType;
+
+  @InjectEntityModel(ExamNotice)
+  examModel: ReturnModelType<typeof ExamNotice>;
+
+  //添加处理数据
+  async create(body) {
+    const { status, user_id, admin_id, user_name, 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}提交了${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: admin_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, name, admin_id, admin_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}提交了${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: admin_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: admin_id,
+        save_name: admin_name,
+        content: `${user_name}提交了${name}专利的价值评估单已经审核完成,审核意见:${desc},请及时查看审核通知消息`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: admin_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: admin_id,
+        save_name: admin_name,
+        content: `${user_name}提交了${name}专利的价值评估单已发报告,请及时查看审核通知消息`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: admin_id,
+        send_date: info.create_time,
+        receive_id: user_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    } else if (status === '4') {
+      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}提交了${name}专利的价值评估单,审核意见:${desc},报告已接收`,
+      };
+      if (body.record) body.record.push(info);
+      else body.record = [info];
+      const exam = {
+        send_id: user_id,
+        send_date: info.create_time,
+        receive_id: admin_id,
+        content: info.content,
+        is_read: '0',
+      };
+      await this.examModel.create(exam);
+    }
+    await this.model.updateOne({ _id: id }, body);
+  }
 }
 }