|
@@ -3,9 +3,120 @@ import { InjectEntityModel } from '@midwayjs/typegoose';
|
|
|
import { ReturnModelType } from '@typegoose/typegoose';
|
|
|
import { BaseService } from 'free-midway-component';
|
|
|
import { Analysis } from '../entity/analysis.entity';
|
|
|
+import { ExamNotice } from '../entity/examNotice.entity';
|
|
|
+const moment = require('moment');
|
|
|
type modelType = ReturnModelType<typeof Analysis>;
|
|
|
@Provide()
|
|
|
export class AnalysisService extends BaseService<modelType> {
|
|
|
@InjectEntityModel(Analysis)
|
|
|
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);
|
|
|
+ }
|
|
|
}
|