Ver Fonte

更新产生警告方法

guhongwei há 3 anos atrás
pai
commit
6a6b94bdc0
1 ficheiros alterados com 25 adições e 9 exclusões
  1. 25 9
      app/service/patent/patentearly.js

+ 25 - 9
app/service/patent/patentearly.js

@@ -61,7 +61,7 @@ class PatentearlyService extends CrudService {
    * 产生警告
    */
   async needWarning() {
-    const limit = 3;
+    const limit = 5000;
     let skip = 0;
     // 一段一段查数据
     // skip += limit;
@@ -75,28 +75,44 @@ class PatentearlyService extends CrudService {
 
   async searchAndDeal(skip, limit) {
     let total = 0;
-    let data = await this.patentinfo.find({ term: '有效' }, { name: 1, inventor: 1, create_date: 1, user_id: 1 }).skip(skip).limit(limit);
+    let data = await this.patentinfo.find({ term: '有效' }, { name: 1, inventor: 1, create_date: 1 }).skip(skip).limit(limit);
     if (data.length > 0) data = JSON.parse(JSON.stringify(data));
     // 取出今天是不是在失效时间的前1个月范围内
     for (const i of data) {
       const { create_date } = i;
-      const start = moment(create_date).subtract(1, 'M');
-      const end = moment(create_date).add(3, 'M');
+      // 取专利日期
+      const month = moment(create_date).format('MM-DD');
+      // // 取得当前年份
+      const nowYear = moment('2020').format('YYYY');
+      // // 当前年份+一年
+      const afterYear = moment('2020').add(1, 'year').format('YYYY');
+      // // 开始时间(先组合日期,减去三个月)
+      const nowDate = afterYear + '-' + month;
+      const start = moment(nowDate).subtract(3, 'months').format('YYYY-MM-DD');
+      // 结束时间
+      const end = afterYear + '-' + month;
       const r = moment().isBetween(start, end, null, '[]');
       if (r) {
         total++;
         const { inventor, name } = i;
         // 2021-11-04 修改,因为inventor修改为发明人[Object],所以发明人需要处理成字符串
-        const user_id = inventor.map((i) => ObjectId(i.user_id));
-        const inventorNameString = inventor.map((i) => i.name).join(';');
-        const content = `发明人 【${inventorNameString}】 的已授权专利 【${name}】 即将失效,避免专利失效过期,请用户及时查看消息并处理! `;
-        const nobj = { ..._.omit(i, ['_id', 'id', 'user_id', 'inventor']), content, parent_id: i._id, user_id };
+        const user_id = inventor.map(i => ObjectId(i.user_id));
+        // const inventorNameString = inventor.map(i => i.name).join(';');
+        // const content = `发明人 【${inventorNameString}】 的已授权专利 【${name}】 即将失效,避免专利失效过期,请用户及时查看消息并处理! `;
+        const content = '您可能需缴年费了,具体以缴费通知书为准 ';
+        const nobj = {
+          ..._.omit(i, [ '_id', 'id', 'user_id', 'inventor' ]),
+          content,
+          parent_id: i._id,
+          user_id,
+        };
         this.model.create(nobj);
         // 2021-11-04添加 向 patentexamine 表中添加数据
         const patentexamineArray = [];
         for (const i of inventor) {
           const { user_id } = i;
-          const peContent = `【${name}】 专利即将过期,请用户及时到相应功能模块中处理专利信息!`;
+          // const peContent = `【${name}】 专利即将过期,请用户及时到相应功能模块中处理专利信息!`;
+          const peContent = '您可能需缴年费了,具体以缴费通知书为准';
           const patentexamineObject = {
             to: user_id,
             content: peContent,