|
@@ -1,4 +1,4 @@
|
|
-import { Provide, Inject } from '@midwayjs/decorator';
|
|
|
|
|
|
+import { Provide, Inject, TaskLocal } from '@midwayjs/decorator';
|
|
import { InjectEntityModel } from '@midwayjs/typegoose';
|
|
import { InjectEntityModel } from '@midwayjs/typegoose';
|
|
import { ReturnModelType } from '@typegoose/typegoose';
|
|
import { ReturnModelType } from '@typegoose/typegoose';
|
|
import {
|
|
import {
|
|
@@ -49,8 +49,9 @@ export class PatentService extends BaseService<modelType> {
|
|
rabbitmqService: RabbitmqService;
|
|
rabbitmqService: RabbitmqService;
|
|
|
|
|
|
async beforeQuery(query) {
|
|
async beforeQuery(query) {
|
|
- const { _id, type, code } = this.ctx.user;
|
|
|
|
- assert(_id, '未获取到用户信息');
|
|
|
|
|
|
+ const _id = _.get(this.ctx.user, '_id');
|
|
|
|
+ const type = _.get(this.ctx.user, 'type');
|
|
|
|
+ const code = _.get(this.ctx.user, 'code');
|
|
const { skip = 0, limit = 0, ...info } = query;
|
|
const { skip = 0, limit = 0, ...info } = query;
|
|
if (type === '2') {
|
|
if (type === '2') {
|
|
const person: any = await this.adminAxios.get(`/personal?code=${code}`);
|
|
const person: any = await this.adminAxios.get(`/personal?code=${code}`);
|
|
@@ -556,6 +557,15 @@ export class PatentService extends BaseService<modelType> {
|
|
return { result, notice };
|
|
return { result, notice };
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ // 每天晚上11点执行一次检查并创建预警信息
|
|
|
|
+ @TaskLocal('0 0 23 * *')
|
|
|
|
+ async test() {
|
|
|
|
+ console.log('定时任务');
|
|
|
|
+ let data = await this.model.find({ term: '1' });
|
|
|
|
+ if (data.length > 0) data = JSON.parse(JSON.stringify(data));
|
|
|
|
+ await this.dealData(data);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
* @param {Array} data 处理数据
|
|
* @param {Array} data 处理数据
|
|
@@ -565,7 +575,7 @@ export class PatentService extends BaseService<modelType> {
|
|
const limitMonth = 3;
|
|
const limitMonth = 3;
|
|
for (const i of data) {
|
|
for (const i of data) {
|
|
try {
|
|
try {
|
|
- const { create_date, create_number, name } = i;
|
|
|
|
|
|
+ const { create_date, create_number, name, users } = i;
|
|
// 专利到期时间
|
|
// 专利到期时间
|
|
const expire_date =
|
|
const expire_date =
|
|
moment(new Date()).format('YYYY') +
|
|
moment(new Date()).format('YYYY') +
|
|
@@ -598,46 +608,17 @@ export class PatentService extends BaseService<modelType> {
|
|
}
|
|
}
|
|
// 不发就继续
|
|
// 不发就继续
|
|
if (!dr) continue;
|
|
if (!dr) continue;
|
|
- const { users } = i;
|
|
|
|
- const user_id = users.map(i => i.user_id);
|
|
|
|
- // 判断预警次数
|
|
|
|
- const early_num =
|
|
|
|
- toDay === start
|
|
|
|
- ? 1
|
|
|
|
- : toDay === start_two
|
|
|
|
- ? 2
|
|
|
|
- : toDay === start_thr
|
|
|
|
- ? 3
|
|
|
|
- : '';
|
|
|
|
- // 截止日期
|
|
|
|
- const lose_date = end;
|
|
|
|
- const content = '您可能需缴年费了,具体以缴费通知书为准 ';
|
|
|
|
- const nobj = {
|
|
|
|
- ..._.omit(i, ['_id', 'id', 'users']),
|
|
|
|
- content,
|
|
|
|
|
|
+ // 2021-11-04添加 向 patentWarnning 表中添加数据
|
|
|
|
+ const patentexamineObject = {
|
|
|
|
+ create_number,
|
|
|
|
+ patnet_name: name,
|
|
parent_id: i._id,
|
|
parent_id: i._id,
|
|
- users: user_id,
|
|
|
|
- early_num,
|
|
|
|
- lose_date,
|
|
|
|
|
|
+ send_date: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
+ lose_date: end,
|
|
|
|
+ receive: users,
|
|
|
|
+ content: '您可能需缴年费了,具体以缴费通知书为准',
|
|
};
|
|
};
|
|
- this.model.create(nobj);
|
|
|
|
- // 2021-11-04添加 向 patentexamine 表中添加数据
|
|
|
|
- const patentexamineArray = [];
|
|
|
|
- for (const i of users) {
|
|
|
|
- const { user_id } = i;
|
|
|
|
- // const peContent = `【${name}】 专利即将过期,请用户及时到相应功能模块中处理专利信息!`;
|
|
|
|
- const peContent = '您可能需缴年费了,具体以缴费通知书为准';
|
|
|
|
- const patentexamineObject = {
|
|
|
|
- create_number,
|
|
|
|
- patnet_name: name,
|
|
|
|
- send_date: moment().format('YYYY-MM-DD HH:mm:ss'),
|
|
|
|
- lose_date,
|
|
|
|
- receive: user_id,
|
|
|
|
- content: peContent,
|
|
|
|
- };
|
|
|
|
- patentexamineArray.push(patentexamineObject);
|
|
|
|
- }
|
|
|
|
- this.PatentModel.insertMany(patentexamineArray);
|
|
|
|
|
|
+ this.PatentModel.create(patentexamineObject);
|
|
}
|
|
}
|
|
} catch (error) {
|
|
} catch (error) {
|
|
continue;
|
|
continue;
|