|
@@ -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
|
|
|
),
|
|
@@ -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,
|
|
|
{
|
|
@@ -388,24 +388,24 @@ class IndexService extends CrudService {
|
|
|
// 专利申请
|
|
|
const papply = this.ctx.model.Patent.Patentapply;
|
|
|
const apply = await papply.count({
|
|
|
- status: [ '0', '1', '-1', '2', '3', '4', '-4', '5', '-5', '6', '-6', '7' ],
|
|
|
+ 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({ user_id: { $elemMatch: { user_id: 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 });
|
|
@@ -420,6 +420,27 @@ class IndexService extends CrudService {
|
|
|
transaction: { trans1, trans2, trans3, trans4, trans5 },
|
|
|
};
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据申请人统计,申请人所在的专利信息数量
|
|
|
+ */
|
|
|
+ async patentInfoByApplyPerson() {
|
|
|
+ const pImodel = this.ctx.model.Patent.Patentinfo;
|
|
|
+ const data = await pImodel.find({}, { apply_personal: 1 });
|
|
|
+ if (data.length <= 0) {
|
|
|
+ return '未找到专利信息相关数据';
|
|
|
+ }
|
|
|
+ let nameList = data.map((i) => i.apply_personal).map((i) => i.split(';'));
|
|
|
+ nameList = _.uniq(_.flattenDeep(nameList).map((i) => _.trim(i)));
|
|
|
+ const arr = [];
|
|
|
+ for (const i of nameList) {
|
|
|
+ const reg = new RegExp(i);
|
|
|
+ const query = { apply_personal: reg };
|
|
|
+ const num = await pImodel.count(query);
|
|
|
+ arr.push({ name: i, num });
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
module.exports = IndexService;
|