Commit e6365357 by 王勇飞

gyq

parent 5ea39fe6
...@@ -1225,6 +1225,66 @@ class CPatentAggregationsApi extends ApiBase { ...@@ -1225,6 +1225,66 @@ class CPatentAggregationsApi extends ApiBase {
}; };
async ApplKeywordAggs(obj) {//申请人关键词双重聚合
var params = {
"query": {
"bool": {
"must": []
}
},
"from": 0,
"size": 1,
"aggregations": {
"group_by_appl": {
"terms": {
"field": "applicant_name.raw",
"size": 10,
"order": {
"_count": "desc"
}
},
"aggregations": {
"group_by_keyword": {
"terms": {
"field": "key_word",
"size": 20,
"order": {
"_count": "desc"
}
}
}
}
}
}
};
for (var x in obj) {
params.query.bool.must.push(obj[x]);
}
var rc = System.getObject("util.execClient");
var rtn = null;
var requrl = this.patentUrl;
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return rtn = {
status: 0,
msg: "操作成功",
data: j.hits,
buckets: j.aggregations
};
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null,
buckets: null
};
}
};
async AppIpclgAggs(obj) {//Ipc大组聚合 async AppIpclgAggs(obj) {//Ipc大组聚合
var params = { var params = {
"query": { "query": {
......
...@@ -13,6 +13,8 @@ class PatentycService extends ServiceBase { ...@@ -13,6 +13,8 @@ class PatentycService extends ServiceBase {
this.GsbByWorldAggApi = System.getObject("api.wpatentaggregations"); this.GsbByWorldAggApi = System.getObject("api.wpatentaggregations");
this.CreatepdfUrl = "http://202.106.92.152:82/pv4.1/createPdf.php"; this.CreatepdfUrl = "http://202.106.92.152:82/pv4.1/createPdf.php";
this.DownpdfUrl = "http://202.106.92.152:82/pv4.1/downPdf.php"; this.DownpdfUrl = "http://202.106.92.152:82/pv4.1/downPdf.php";
this.tokenUrl = "http://tm.qifu.gongsibao.com/web/auth/accessAuth/getAppTokenByHosts";
this.icUrl = "http://tm.qifu.gongsibao.com/api/action/tmTools/springBoard";
}; };
async obtainreport(obj) {//专利价值评价报告 async obtainreport(obj) {//专利价值评价报告
...@@ -276,6 +278,41 @@ class PatentycService extends ServiceBase { ...@@ -276,6 +278,41 @@ class PatentycService extends ServiceBase {
}; };
RandomNumBoth(Min, Max) {
var Range = Max - Min;
var Rand = Math.random();
var num = Min + Math.round(Rand * Range); //四舍五入
return num;
};
calculatecompete(list1, list2) {//计算竞争指数
var total = 0;
for (var l1 in list1) {
for (var l2 in list2) {
if (l1 == l2) {
total += 1;
break;
}
}
}
var rtndata = 0;
if (total >= 1 && total <= 5) {
rtndata = this.RandomNumBoth(60, 70);
}
else if (total >= 6 && total <= 9) {
rtndata = this.RandomNumBoth(70, 80);
}
else if (total >= 10 && total <= 14) {
rtndata = this.RandomNumBoth(80, 90);
}
else if (total >= 15) {
rtndata = this.RandomNumBoth(90, 98);
}
return rtndata;
};
async getcountryen(cnname) {//国家对应关系 async getcountryen(cnname) {//国家对应关系
var mapobj = { var mapobj = {
"阿拉伯联合酋长国": "United Arab Emirates", "阿拉伯联合酋长国": "United Arab Emirates",
...@@ -8452,7 +8489,7 @@ class PatentycService extends ServiceBase { ...@@ -8452,7 +8489,7 @@ class PatentycService extends ServiceBase {
useremail: "" useremail: ""
//"product": //"product":
}; };
try{ try {
var client = await this.soapClient(url); var client = await this.soapClient(url);
//console.log("client-------------" + JSON.stringify(client)); //console.log("client-------------" + JSON.stringify(client));
var rtn = await this.uploadData(client, args); var rtn = await this.uploadData(client, args);
...@@ -8476,7 +8513,7 @@ class PatentycService extends ServiceBase { ...@@ -8476,7 +8513,7 @@ class PatentycService extends ServiceBase {
var args = { var args = {
guid: obj.uid guid: obj.uid
}; };
try{ try {
var client = await this.soapClient(url); var client = await this.soapClient(url);
//console.log("client-------------" + JSON.stringify(client)); //console.log("client-------------" + JSON.stringify(client));
var rtn = await this.readyReport(client, args); var rtn = await this.readyReport(client, args);
...@@ -8523,13 +8560,13 @@ class PatentycService extends ServiceBase { ...@@ -8523,13 +8560,13 @@ class PatentycService extends ServiceBase {
console.log("result-------------" + result); console.log("result-------------" + result);
resolve({ resolve({
"result": result.UploadDataResult, "result": result.UploadDataResult,
"uid":args.guid "uid": args.guid
}) })
} }
}) })
}) })
} }
async ezGetReport(obj) {//获取报告 async ezGetReport(obj) {//获取报告
var url = ""; var url = "";
if (obj.type == "word") { if (obj.type == "word") {
...@@ -8549,161 +8586,284 @@ class PatentycService extends ServiceBase { ...@@ -8549,161 +8586,284 @@ class PatentycService extends ServiceBase {
} }
} }
async competitionAnalysisInfo(obj){//竞争分析基本信息 async competitionAnalysisInfo(obj) {//竞争分析基本信息
try{ try {
return { /*
"companyname":"华为技术科技有限公司",//公司名称 1.调用工商大数据查询企业基本工商信息接口(或者直接查询工商ES),获取公司的行业类别和经营范围
"patentnum": 12345,//专利总量 2.查询专利ES,获取相应公司的前20的关键词和专利总量
"industryname":"通信设备制造,互联网和相关服务",//行业信息 3.查询行业类别查询专利ES获取前10的专利
"businessscope" :"123456",//主营业务 4.查询专利ES,获取竞争公司的前20的关键词和专利总量
"keyword":["终端设备","电信"],//关键词,最多20个 5.根据关键词计算竞争指数
"competeinfo":[//竞争企业信息,最多10个 */
{ var redata = {
"companyname":"北京小米科技有限公司",//公司名称 "companyname": obj.companyname,
"patentnum":9876,//专利总量 "competeinfo": []
"keyword":["终端设备","电信"],//关键词,最多20个 };
"industryname":"通信设备制造",//行业信息 //1.调用工商大数据查询企业基本工商信息接口(或者直接查询工商ES),获取公司的行业类别和经营范围
"competeindex":90//竞争指数 var params = {
}, "actionType": "getAppTokenByHosts",
{ "actionBody": {}
"companyname":"北京小米科技有限公司", }
"patentnum":9876,
"keyword":["终端设备","电信"], var rc = System.getObject("util.execClient");
"industryname":"通信设备制造,互联网和相关服务", var requrl = this.tokenUrl;
"competeindex":90 var rtn = await rc.execPost3(params, requrl);
}, var j = JSON.parse(rtn.stdout);
{ if (j.status == 0) {
"companyname":"北京小米科技有限公司", params = {
"patentnum":9876, "actionType": "getEntregistryByCompanyName",
"keyword":["终端设备","电信"], "actionBody": {
"industryname":"通信设备制造", "companyName": obj.companyname
"competeindex":90 }
}, }
{ requrl = this.icUrl;
"companyname":"北京小米科技有限公司", rtn = await rc.execPost4(j.data.token, params, requrl);
"patentnum":9876, j = JSON.parse(rtn.stdout); //得到了公司的信息
"keyword":["终端设备","电信"], if (j.status == 0) {
"industryname":"通信设备制造", redata.businessscope = j.data.scope;//主营业务
"competeindex":90 redata.industryname = j.data.companyCate2;//行业信息
}, //redata.industryname = "计算机、通信和其他电子设备制造业";
{ //2.查询专利ES,获取相应公司的前20的关键词和专利总量
"companyname":"北京小米科技有限公司", var searchList = [
"patentnum":9876, {
"keyword":["终端设备","电信"], "term": {
"industryname":"通信设备制造", "applicant_name.raw": obj.companyname
"competeindex":90 }
}, }
] ];
var tms = await this.GsbByChinaAggApi.KeyWordAggs(searchList);//获取查询结果;
redata.total = 0;//公司的专利数量
redata.keyword = "";
var cbuckets = [];
if (tms) {
if (tms.status == 0) {
redata.total = tms.data.total;
if (tms.buckets.types.buckets) {
var max = 20;
if (tms.buckets.types.buckets.length < 20) {
max = tms.buckets.types.buckets.length
}
for (var i = 0; i < max; i++) {
cbuckets.push(tms.buckets.types.buckets[i].key);
redata.keyword = cbuckets.join(',');
}
}
}
};
//3.查询行业类别查询专利ES获取前10的专利
searchList = [
{
"term": {
"broad_name": redata.industryname
}
},
{
"term": {
"appl_type": "企业"
}
},
{
"bool": {
"must_not": {
"term": {
"applicant_name.raw": obj.companyname
}
}
}
}
];
tms = await this.GsbByChinaAggApi.ApplKeywordAggs(searchList);//获取查询结果;
if (tms && tms.status == 0) {
if (tms.buckets.group_by_appl.buckets) {
tms.buckets.group_by_appl.buckets.forEach(element => {
var teminfo = {
"companyname": element.key,
"patentnum": element.doc_count,
"industryname": redata.industryname
}
//keyword
var keybuckets = element.group_by_keyword.buckets;
var keylist = [];
keybuckets.forEach(element1 => {
keylist.push(element1.key);
});
teminfo.keyword = keylist.join(",");
//计算竞争指数
var competeindex = this.calculatecompete(cbuckets, keylist);
teminfo.competeindex = competeindex;
redata.competeinfo.push(teminfo);
});
}
}
return redata;
}
else {
console.log("1111111");
return j;
}
} }
} else {
catch(error){ console.log("SSSSSSS");
return j;
}
// return {
// "companyname": "华为技术科技有限公司",//公司名称
// "patentnum": 12345,//专利总量
// "industryname": "通信设备制造,互联网和相关服务",//行业信息
// "businessscope": "123456",//主营业务
// "keyword": ["终端设备", "电信"],//关键词,最多20个
// "competeinfo": [//竞争企业信息,最多10个
// {
// "companyname": "北京小米科技有限公司",//公司名称
// "patentnum": 9876,//专利总量
// "keyword": ["终端设备", "电信"],//关键词,最多20个
// "industryname": "通信设备制造",//行业信息
// "competeindex": 90//竞争指数
// },
// {
// "companyname": "北京小米科技有限公司",
// "patentnum": 9876,
// "keyword": ["终端设备", "电信"],
// "industryname": "通信设备制造,互联网和相关服务",
// "competeindex": 90
// },
// {
// "companyname": "北京小米科技有限公司",
// "patentnum": 9876,
// "keyword": ["终端设备", "电信"],
// "industryname": "通信设备制造",
// "competeindex": 90
// },
// {
// "companyname": "北京小米科技有限公司",
// "patentnum": 9876,
// "keyword": ["终端设备", "电信"],
// "industryname": "通信设备制造",
// "competeindex": 90
// },
// {
// "companyname": "北京小米科技有限公司",
// "patentnum": 9876,
// "keyword": ["终端设备", "电信"],
// "industryname": "通信设备制造",
// "competeindex": 90
// },
// ]
// }
}
catch (error) {
return {}; return {};
} }
} }
async competitionAnalysisContex(obj){//竞争分析详细信息 async competitionAnalysisContex(obj) {//竞争分析详细信息
try{ try {
return [ return [
{ {
"keyword":"keyword1",//关键词 "keyword": "keyword1",//关键词
"company1":{//左边公司的信息 "company1": {//左边公司的信息
"cpmpanyname":"华为技术科技有限公司",//公司名称 "cpmpanyname": "华为技术科技有限公司",//公司名称
"patentnum": 2000,//专利总量 "patentnum": 2000,//专利总量
"patentquality":78,//专利质量得分 "patentquality": 78,//专利质量得分
"patentrate":"78%",//专利成长率 "patentrate": "78%",//专利成长率
"totalscore":123,//总评分 "totalscore": 123,//总评分
"iconscore": 87//icon上的值 "iconscore": 87//icon上的值
}, },
"company2":{//右边公司的信息 "company2": {//右边公司的信息
"cpmpanyname":"北京小米科技有限公司",//公司名称 "cpmpanyname": "北京小米科技有限公司",//公司名称
"patentnum": 2000,//专利总量 "patentnum": 2000,//专利总量
"patentquality":78,//专利质量得分 "patentquality": 78,//专利质量得分
"patentrate":"78%",//专利成长率 "patentrate": "78%",//专利成长率
"totalscore":123,//总评分 "totalscore": 123,//总评分
"iconscore": 87//icon上的值 "iconscore": 87//icon上的值
} }
}, },
{ {
"keyword":"keyword2", "keyword": "keyword2",
"company1":{ "company1": {
"cpmpanyname":"华为技术科技有限公司", "cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
}, },
"company2":{ "company2": {
"cpmpanyname":"北京小米科技有限公司", "cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
} }
}, },
{ {
"keyword":"keyword3", "keyword": "keyword3",
"company1":{ "company1": {
"cpmpanyname":"华为技术科技有限公司", "cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
}, },
"company2":{ "company2": {
"cpmpanyname":"北京小米科技有限公司", "cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
} }
}, },
{ {
"keyword":"keyword4", "keyword": "keyword4",
"company1":{ "company1": {
"cpmpanyname":"华为技术科技有限公司", "cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
}, },
"company2":{ "company2": {
"cpmpanyname":"北京小米科技有限公司", "cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
} }
}, },
{ {
"keyword":"keyword5", "keyword": "keyword5",
"company1":{ "company1": {
"cpmpanyname":"华为技术科技有限公司", "cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
}, },
"company2":{ "company2": {
"cpmpanyname":"北京小米科技有限公司", "cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000, "patentnum": 2000,
"patentquality":78, "patentquality": 78,
"patentrate":"78%", "patentrate": "78%",
"totalscore":123, "totalscore": 123,
"iconscore": 87 "iconscore": 87
} }
} }
] ]
} }
catch(error){ catch (error) {
return {}; return {};
} }
} }
...@@ -9573,13 +9733,12 @@ module.exports = PatentycService; ...@@ -9573,13 +9733,12 @@ module.exports = PatentycService;
// var d = task.ezGetReport(obj) // var d = task.ezGetReport(obj)
// console.log("dddddd---------" + d); // console.log("dddddd---------" + d);
// (async ()=>{ (async () => {
// var task = new PatentycService(); var task = new PatentycService();
// var obj = { var obj = {
// "uid": "735f9cd0-c103-11ea-9ecd-1d1c3e85a974", "companyname": "华为技术有限公司"
// "type": "html" };
// }; var d = await task.competitionAnalysisInfo(obj)
// var d = await task.ezReadyReport(obj) console.log("dddddd---------" + JSON.stringify(d));
// console.log("dddddd---------" + JSON.stringify(d)); })()
// })()
...@@ -6,6 +6,8 @@ class ExecClient { ...@@ -6,6 +6,8 @@ class ExecClient {
constructor() { constructor() {
this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}"; this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {url}";
this.cmdGetPattern = "curl -G -X GET '{url}'"; this.cmdGetPattern = "curl -G -X GET '{url}'";
this.cmdPostPattern2 = "curl -k -H 'Content-type: application/json' -d '{data}' {url}";
this.cmdPostPattern3 = "curl -k -H 'Content-type: application/json' -H 'token: {token}' -d '{data}' {url}";
} }
async exec(cmd) { async exec(cmd) {
...@@ -30,12 +32,39 @@ class ExecClient { ...@@ -30,12 +32,39 @@ class ExecClient {
return cmd; return cmd;
} }
FetchPostCmd2(subData, url) {
var data = JSON.stringify(subData);
var cmd = this.cmdPostPattern2.replace(/\{data\}/g,
data).replace(/\{url\}/g, url);
console.log(cmd);
return cmd;
}
FetchPostCmd3(token,subData, url) {
var data = JSON.stringify(subData);
var cmd = this.cmdPostPattern3.replace(/\{token\}/g,token).replace(/\{data\}/g,data).replace(/\{url\}/g, url);
console.log(cmd);
return cmd;
}
async execPost(subData, url) { async execPost(subData, url) {
let cmd = this.FetchPostCmd(subData, url); let cmd = this.FetchPostCmd(subData, url);
var result = await this.exec(cmd); var result = await this.exec(cmd);
return result; return result;
} }
async execPost3(subData, url) {
let cmd = this.FetchPostCmd2(subData, url);
var result = await this.exec(cmd);
return result;
}
async execPost4(token,subData, url) {
let cmd = this.FetchPostCmd3(token,subData, url);
var result = await this.exec(cmd);
return result;
}
async execPost2(subData, url) { async execPost2(subData, url) {
let cmd = this.FetchPostCmd(subData, url); let cmd = this.FetchPostCmd(subData, url);
var result = await this.exec2(cmd); var result = await this.exec2(cmd);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment