Explorar o código

专利申请统计

guhongwei %!s(int64=3) %!d(string=hai) anos
pai
achega
00d2bad30e
Modificáronse 1 ficheiros con 29 adicións e 26 borrados
  1. 29 26
      app/service/statistics/index.js

+ 29 - 26
app/service/statistics/index.js

@@ -38,13 +38,13 @@ class IndexService extends CrudService {
     for (const i of res) {
       const { _id, value } = i;
       const unitList = this.patentUnitList();
-      const unit = unitList.find((f) => (_id && _id.includes(f.name)) || f.name.includes(_id));
+      const unit = unitList.find(f => (_id && _id.includes(f.name)) || f.name.includes(_id));
       if (unit) {
         // 说明是需要单拎出来的数据,现查arr中是否有该单位:有=>数字合并;没有=>创建条目
         const { name } = unit;
-        const arrItem = arr.find((f) => f.name === name);
+        const arrItem = arr.find(f => f.name === name);
         if (arrItem) {
-          const index = arr.findIndex((f) => f.name === name);
+          const index = arr.findIndex(f => f.name === name);
           arr[index] = { name, value: (arrItem.value || 0) + value };
         } else {
           arr.push({ name, value });
@@ -53,7 +53,7 @@ class IndexService extends CrudService {
         other.value += value;
       }
     }
-    arr = _.orderBy(arr, ['value'], ['desc']);
+    arr = _.orderBy(arr, [ 'value' ], [ 'desc' ]);
     arr.push(other);
     return arr;
   }
@@ -93,13 +93,13 @@ class IndexService extends CrudService {
     for (const i of res) {
       const { _id, value } = i;
       const unitList = this.expertList();
-      const unit = unitList.find((f) => (_id && _id.includes(f.name)) || f.name.includes(_id));
+      const unit = unitList.find(f => (_id && _id.includes(f.name)) || f.name.includes(_id));
       if (unit) {
         // 说明是需要单拎出来的数据,现查arr中是否有该单位:有=>数字合并;没有=>创建条目
         const { name, sort } = unit;
-        const arrItem = arr.find((f) => f.name === name);
+        const arrItem = arr.find(f => f.name === name);
         if (arrItem) {
-          const index = arr.findIndex((f) => f.name === name);
+          const index = arr.findIndex(f => f.name === name);
           arr[index] = { ...arr[index], value: (arrItem.value || 0) + value };
         } else {
           arr.push({ name, value, sort });
@@ -108,11 +108,11 @@ class IndexService extends CrudService {
         other.value += value;
       }
     }
-    arr = _.orderBy(arr, ['sort'], ['asc']);
+    arr = _.orderBy(arr, [ 'sort' ], [ 'asc' ]);
     arr.push(other);
     // 换名
-    arr.map((i) => {
-      const r = this.expertList().find((f) => f.name === i.name);
+    arr.map(i => {
+      const r = this.expertList().find(f => f.name === i.name);
       if (r && r.alias) i.name = r.alias;
       return i;
     });
@@ -154,7 +154,7 @@ class IndexService extends CrudService {
       value: surveys,
     });
     const trans = await this.tranModel.aggregate([
-      { $match: { status: { $in: ['0', '1', '3'] } } },
+      { $match: { status: { $in: [ '0', '1', '3' ] } } },
       {
         $group: {
           _id: '$status',
@@ -165,7 +165,7 @@ class IndexService extends CrudService {
     arr.push({
       name: '正在洽谈',
       value: _.get(
-        trans.find((f) => f._id === '0'),
+        trans.find(f => f._id === '0'),
         'value',
         0
       ),
@@ -173,7 +173,7 @@ class IndexService extends CrudService {
     arr.push({
       name: '达成意向',
       value: _.get(
-        trans.find((f) => f._id === '1'),
+        trans.find(f => f._id === '1'),
         'value',
         0
       ),
@@ -181,7 +181,7 @@ class IndexService extends CrudService {
     arr.push({
       name: '对接完成',
       value: _.get(
-        trans.find((f) => f._id === '3'),
+        trans.find(f => f._id === '3'),
         'value',
         0
       ),
@@ -228,7 +228,7 @@ class IndexService extends CrudService {
   async dockIndex({ dock_id }) {
     // 同时在线人数(伪)
     let tszx = _.random(100, 1000);
-    if(this.redis) {
+    if (this.redis) {
       tszx = (await this.redis.get('login_number')) || tszx;
     }
     // 特邀嘉宾
@@ -237,7 +237,7 @@ class IndexService extends CrudService {
     console.log(tyjb);
     // 洽谈合作 达成意向 交易完成
     const trans = await this.tranModel.aggregate([
-      { $match: { status: { $in: ['0', '1', '3'] } } },
+      { $match: { status: { $in: [ '0', '1', '3' ] } } },
       {
         $group: {
           _id: '$status',
@@ -246,17 +246,17 @@ class IndexService extends CrudService {
       },
     ]);
     const qthz = _.get(
-      trans.find((f) => f._id === '0'),
+      trans.find(f => f._id === '0'),
       'value',
       0
     );
     const dcyx = _.get(
-      trans.find((f) => f._id === '1'),
+      trans.find(f => f._id === '1'),
       'value',
       0
     );
     const jywc = _.get(
-      trans.find((f) => f._id === '3'),
+      trans.find(f => f._id === '3'),
       'value',
       0
     );
@@ -340,7 +340,7 @@ class IndexService extends CrudService {
     const obj = [];
     for (const i of meta) {
       const { key, name } = i;
-      const r = list.find((f) => f._id === key);
+      const r = list.find(f => f._id === key);
       if (r) {
         obj.push({ name, value: r.count });
       } else {
@@ -361,7 +361,7 @@ class IndexService extends CrudService {
       else userQuery[key] = query[key];
     }
     const publics = [{ $match: userQuery }, { $project: { productList: 1, _id: 0 } }, { $unwind: '$productList' }, { $match: productQuery }];
-    const data = await this.ctx.model.Dock.DockUser.aggregate([...publics, { $skip: parseInt(skip) }, { $limit: parseInt(limit) }]).replaceRoot('productList');
+    const data = await this.ctx.model.Dock.DockUser.aggregate([ ...publics, { $skip: parseInt(skip) }, { $limit: parseInt(limit) }]).replaceRoot('productList');
     let total = await this.ctx.model.Dock.DockUser.aggregate([
       ...publics,
       {
@@ -384,22 +384,25 @@ class IndexService extends CrudService {
     const unread = await patentExamine.count({ to: id, is_read: false });
     // 专利申请
     const papply = this.ctx.model.Patent.Patentapply;
-    const apply = await papply.count({ status: ['0', '1', '-1', '2', '-2', '3', '-3', '4', '5'], user_id: id });
+    const apply = await papply.count({
+      status: [ '0', '1', '-1', '2', '3', '4', '-4', '5', '-5', '6', '-6', '7' ],
+      user_id: id,
+    });
     // 查询检索
     const palysis = this.ctx.model.Patent.Patentanalysis;
-    const analysis = await palysis.count({ status: ['0', '1', '-1', '2'], user_id: id });
+    const analysis = await palysis.count({ status: [ '0', '1', '-1', '2' ], user_id: id });
     // 价值评估
     const paccess = this.ctx.model.Patent.Patentassess;
-    const access = await paccess.count({ status: ['0', '1', '-1', '2'], user_id: id });
+    const access = await paccess.count({ status: [ '0', '1', '-1', '2' ], user_id: id });
     // 专利信息
     const patentInfo = this.ctx.model.Patent.Patentinfo;
     const information = await patentInfo.count({ inventor: { $elemMatch: { user_id: ObjectId(id) } } });
     // 专利维权
     const patentsafeg = this.ctx.model.Patent.Patentsafeg;
-    const safeg = await patentsafeg.count({ status: ['0', '1', '2'], user_id: id });
+    const safeg = await patentsafeg.count({ status: [ '0', '1', '2' ], user_id: id });
     // 专利预警
     const patentEarly = this.ctx.model.Patent.Patentearly;
-    const early = await patentEarly.count({ user_id: { $elemMatch: { $in: [ObjectId(id)] } } });
+    const early = await patentEarly.count({ user_id: { $elemMatch: { $in: [ ObjectId(id) ] } } });
     // 专利交易
     const patentTrans = this.ctx.model.Patent.Patenttrans;
     const trans1 = await patentTrans.count({ type: '转让', user_id: id });