Commit e6365357 by 王勇飞

gyq

parent 5ea39fe6
......@@ -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大组聚合
var params = {
"query": {
......
......@@ -13,6 +13,8 @@ class PatentycService extends ServiceBase {
this.GsbByWorldAggApi = System.getObject("api.wpatentaggregations");
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.tokenUrl = "http://tm.qifu.gongsibao.com/web/auth/accessAuth/getAppTokenByHosts";
this.icUrl = "http://tm.qifu.gongsibao.com/api/action/tmTools/springBoard";
};
async obtainreport(obj) {//专利价值评价报告
......@@ -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) {//国家对应关系
var mapobj = {
"阿拉伯联合酋长国": "United Arab Emirates",
......@@ -8452,7 +8489,7 @@ class PatentycService extends ServiceBase {
useremail: ""
//"product":
};
try{
try {
var client = await this.soapClient(url);
//console.log("client-------------" + JSON.stringify(client));
var rtn = await this.uploadData(client, args);
......@@ -8476,7 +8513,7 @@ class PatentycService extends ServiceBase {
var args = {
guid: obj.uid
};
try{
try {
var client = await this.soapClient(url);
//console.log("client-------------" + JSON.stringify(client));
var rtn = await this.readyReport(client, args);
......@@ -8523,7 +8560,7 @@ class PatentycService extends ServiceBase {
console.log("result-------------" + result);
resolve({
"result": result.UploadDataResult,
"uid":args.guid
"uid": args.guid
})
}
})
......@@ -8549,153 +8586,276 @@ class PatentycService extends ServiceBase {
}
}
async competitionAnalysisInfo(obj){//竞争分析基本信息
try{
return {
"companyname":"华为技术科技有限公司",//公司名称
"patentnum": 12345,//专利总量
"industryname":"通信设备制造,互联网和相关服务",//行业信息
"businessscope" :"123456",//主营业务
"keyword":["终端设备","电信"],//关键词,最多20个
"competeinfo":[//竞争企业信息,最多10个
{
"companyname":"北京小米科技有限公司",//公司名称
"patentnum":9876,//专利总量
"keyword":["终端设备","电信"],//关键词,最多20个
"industryname":"通信设备制造",//行业信息
"competeindex":90//竞争指数
},
async competitionAnalysisInfo(obj) {//竞争分析基本信息
try {
/*
1.调用工商大数据查询企业基本工商信息接口(或者直接查询工商ES),获取公司的行业类别和经营范围
2.查询专利ES,获取相应公司的前20的关键词和专利总量
3.查询行业类别查询专利ES获取前10的专利
4.查询专利ES,获取竞争公司的前20的关键词和专利总量
5.根据关键词计算竞争指数
*/
var redata = {
"companyname": obj.companyname,
"competeinfo": []
};
//1.调用工商大数据查询企业基本工商信息接口(或者直接查询工商ES),获取公司的行业类别和经营范围
var params = {
"actionType": "getAppTokenByHosts",
"actionBody": {}
}
var rc = System.getObject("util.execClient");
var requrl = this.tokenUrl;
var rtn = await rc.execPost3(params, requrl);
var j = JSON.parse(rtn.stdout);
if (j.status == 0) {
params = {
"actionType": "getEntregistryByCompanyName",
"actionBody": {
"companyName": obj.companyname
}
}
requrl = this.icUrl;
rtn = await rc.execPost4(j.data.token, params, requrl);
j = JSON.parse(rtn.stdout); //得到了公司的信息
if (j.status == 0) {
redata.businessscope = j.data.scope;//主营业务
redata.industryname = j.data.companyCate2;//行业信息
//redata.industryname = "计算机、通信和其他电子设备制造业";
//2.查询专利ES,获取相应公司的前20的关键词和专利总量
var searchList = [
{
"companyname":"北京小米科技有限公司",
"patentnum":9876,
"keyword":["终端设备","电信"],
"industryname":"通信设备制造,互联网和相关服务",
"competeindex":90
},
"term": {
"applicant_name.raw": obj.companyname
}
}
];
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 = [
{
"companyname":"北京小米科技有限公司",
"patentnum":9876,
"keyword":["终端设备","电信"],
"industryname":"通信设备制造",
"competeindex":90
"term": {
"broad_name": redata.industryname
}
},
{
"companyname":"北京小米科技有限公司",
"patentnum":9876,
"keyword":["终端设备","电信"],
"industryname":"通信设备制造",
"competeindex":90
"term": {
"appl_type": "企业"
}
},
{
"companyname":"北京小米科技有限公司",
"patentnum":9876,
"keyword":["终端设备","电信"],
"industryname":"通信设备制造",
"competeindex":90
},
]
"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);
});
}
}
catch(error){
return redata;
}
else {
console.log("1111111");
return j;
}
}
else {
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 {};
}
}
async competitionAnalysisContex(obj){//竞争分析详细信息
try{
async competitionAnalysisContex(obj) {//竞争分析详细信息
try {
return [
{
"keyword":"keyword1",//关键词
"company1":{//左边公司的信息
"cpmpanyname":"华为技术科技有限公司",//公司名称
"keyword": "keyword1",//关键词
"company1": {//左边公司的信息
"cpmpanyname": "华为技术科技有限公司",//公司名称
"patentnum": 2000,//专利总量
"patentquality":78,//专利质量得分
"patentrate":"78%",//专利成长率
"totalscore":123,//总评分
"patentquality": 78,//专利质量得分
"patentrate": "78%",//专利成长率
"totalscore": 123,//总评分
"iconscore": 87//icon上的值
},
"company2":{//右边公司的信息
"cpmpanyname":"北京小米科技有限公司",//公司名称
"company2": {//右边公司的信息
"cpmpanyname": "北京小米科技有限公司",//公司名称
"patentnum": 2000,//专利总量
"patentquality":78,//专利质量得分
"patentrate":"78%",//专利成长率
"totalscore":123,//总评分
"patentquality": 78,//专利质量得分
"patentrate": "78%",//专利成长率
"totalscore": 123,//总评分
"iconscore": 87//icon上的值
}
},
{
"keyword":"keyword2",
"company1":{
"cpmpanyname":"华为技术科技有限公司",
"keyword": "keyword2",
"company1": {
"cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
},
"company2":{
"cpmpanyname":"北京小米科技有限公司",
"company2": {
"cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
}
},
{
"keyword":"keyword3",
"company1":{
"cpmpanyname":"华为技术科技有限公司",
"keyword": "keyword3",
"company1": {
"cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
},
"company2":{
"cpmpanyname":"北京小米科技有限公司",
"company2": {
"cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
}
},
{
"keyword":"keyword4",
"company1":{
"cpmpanyname":"华为技术科技有限公司",
"keyword": "keyword4",
"company1": {
"cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
},
"company2":{
"cpmpanyname":"北京小米科技有限公司",
"company2": {
"cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
}
},
{
"keyword":"keyword5",
"company1":{
"cpmpanyname":"华为技术科技有限公司",
"keyword": "keyword5",
"company1": {
"cpmpanyname": "华为技术科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
},
"company2":{
"cpmpanyname":"北京小米科技有限公司",
"company2": {
"cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000,
"patentquality":78,
"patentrate":"78%",
"totalscore":123,
"patentquality": 78,
"patentrate": "78%",
"totalscore": 123,
"iconscore": 87
}
}
......@@ -8703,7 +8863,7 @@ class PatentycService extends ServiceBase {
]
}
catch(error){
catch (error) {
return {};
}
}
......@@ -9573,13 +9733,12 @@ module.exports = PatentycService;
// var d = task.ezGetReport(obj)
// console.log("dddddd---------" + d);
// (async ()=>{
// var task = new PatentycService();
// var obj = {
// "uid": "735f9cd0-c103-11ea-9ecd-1d1c3e85a974",
// "type": "html"
// };
// var d = await task.ezReadyReport(obj)
// console.log("dddddd---------" + JSON.stringify(d));
// })()
(async () => {
var task = new PatentycService();
var obj = {
"companyname": "华为技术有限公司"
};
var d = await task.competitionAnalysisInfo(obj)
console.log("dddddd---------" + JSON.stringify(d));
})()
......@@ -6,6 +6,8 @@ class ExecClient {
constructor() {
this.cmdPostPattern = "curl --user admines:adminGSBes. -k -H 'Content-type: application/json' -d '{data}' {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) {
......@@ -30,12 +32,39 @@ class ExecClient {
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) {
let cmd = this.FetchPostCmd(subData, url);
var result = await this.exec(cmd);
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) {
let cmd = this.FetchPostCmd(subData, url);
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