Commit b94edf0b by 王勇飞

gyq

parent f93f43af
...@@ -76,7 +76,7 @@ class PatentycCtl extends CtlBase { ...@@ -76,7 +76,7 @@ class PatentycCtl extends CtlBase {
if (obj.companyname && obj.companyname != 'undefined'){ if (obj.companyname && obj.companyname != 'undefined'){
try{ try{
var result = await this.service.competitionAnalysisInfo(obj); var result = await this.service.competitionAnalysisInfo(obj);
if (result){ if (JSON.stringify(result) != '{}'){
return System.getResult2(result); return System.getResult2(result);
} }
else{ else{
...@@ -94,10 +94,10 @@ class PatentycCtl extends CtlBase { ...@@ -94,10 +94,10 @@ class PatentycCtl extends CtlBase {
} }
async competitionAnalysisContex(pobj,obj,req){//竞争分析详细信息 async competitionAnalysisContex(pobj,obj,req){//竞争分析详细信息
if (obj.company1 && obj.company1 != 'undefined' && obj.company2 && obj.company2 != 'undefined'){ if (obj.company1 && obj.company1 != 'undefined' && obj.company2 && obj.company2 != 'undefined' && obj.keyword1 && obj.keyword1 != 'undefined' && obj.keyword2 && obj.keyword2 ){
try{ try{
var result = await this.service.competitionAnalysisContex(obj); var result = await this.service.competitionAnalysisContex(obj);
if (result){ if (JSON.stringify(result) != '{}'){
return System.getResult2(result); return System.getResult2(result);
} }
else{ else{
...@@ -1430,15 +1430,17 @@ class PatentycCtl extends CtlBase { ...@@ -1430,15 +1430,17 @@ class PatentycCtl extends CtlBase {
} }
module.exports = PatentycCtl; module.exports = PatentycCtl;
// var task = new PatentycCtl(); var task = new PatentycCtl();
// var obj = { var obj = {
// "companyname": "667b8300-c101-11ea-98dd-3142bd90eec4", "company1": "华为技术有限公司",
// "company2": "html" "company2": "中兴通讯股份有限公司",
// }; "keyword1":"用户设备,通信领域,通信技术,设备发送,指示信息,通信系统,通信方法,设备接收,对应关系,基站发送,终端发送,用户体验,配置信息,请求消息,数据传输方法,用户终端,网络侧,移动终端,通信设备,传输方法",
// task.competitionAnalysisInfo({},obj,{}).then(d=>{ "keyword2":"用户体验,移动终端,用户设备,相关技术,网络侧,终端发送,用户终端,配置信息,指示信息,请求消息,对应关系,传输方法,基站发送,通信系统,数据传输方法,通信领域,通信技术,设备发送,响应消息,发送方法"
// console.log(JSON.stringify(d)); };
// //console.log(d[0].analyse); task.competitionAnalysisContex({},obj,{}).then(d=>{
// }) console.log(JSON.stringify(d));
//console.log(d[0].analyse);
})
// (async ()=>{ // (async ()=>{
// var task = new PatentycCtl(); // var task = new PatentycCtl();
......
...@@ -11,6 +11,7 @@ class PatentycService extends ServiceBase { ...@@ -11,6 +11,7 @@ class PatentycService extends ServiceBase {
this.GsbByChinaAffairSearchApi = System.getObject("api.chinaaffairsearch"); this.GsbByChinaAffairSearchApi = System.getObject("api.chinaaffairsearch");
this.GsbByChinaAggApi = System.getObject("api.cpatentaggregations"); this.GsbByChinaAggApi = System.getObject("api.cpatentaggregations");
this.GsbByWorldAggApi = System.getObject("api.wpatentaggregations"); this.GsbByWorldAggApi = System.getObject("api.wpatentaggregations");
this.redisClient = System.getObject("util.redisClient");
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.tokenUrl = "http://tm.qifu.gongsibao.com/web/auth/accessAuth/getAppTokenByHosts";
...@@ -289,13 +290,14 @@ class PatentycService extends ServiceBase { ...@@ -289,13 +290,14 @@ class PatentycService extends ServiceBase {
var total = 0; var total = 0;
for (var l1 in list1) { for (var l1 in list1) {
for (var l2 in list2) { for (var l2 in list2) {
if (l1 == l2) { if (list1[l1] == list2[l2]) {
total += 1; total += 1;
break; break;
} }
} }
} }
var rtndata = 0; var rtndata = 0;
console.log("total----------------" + total);
if (total >= 1 && total <= 5) { if (total >= 1 && total <= 5) {
rtndata = this.RandomNumBoth(60, 70); rtndata = this.RandomNumBoth(60, 70);
} }
...@@ -313,6 +315,18 @@ class PatentycService extends ServiceBase { ...@@ -313,6 +315,18 @@ class PatentycService extends ServiceBase {
}; };
getArrEqual(arr1, arr2) {//取出两个数组的相同元素
let newArr = [];
for (let i = 0; i < arr2.length; i++) {
for (let j = 0; j < arr1.length; j++) {
if (arr1[j] === arr2[i]) {
newArr.push(arr1[j]);
}
}
}
return newArr;
};
async getcountryen(cnname) {//国家对应关系 async getcountryen(cnname) {//国家对应关系
var mapobj = { var mapobj = {
"阿拉伯联合酋长国": "United Arab Emirates", "阿拉伯联合酋长国": "United Arab Emirates",
...@@ -8604,21 +8618,33 @@ class PatentycService extends ServiceBase { ...@@ -8604,21 +8618,33 @@ class PatentycService extends ServiceBase {
"actionType": "getAppTokenByHosts", "actionType": "getAppTokenByHosts",
"actionBody": {} "actionBody": {}
} }
var rc = System.getObject("util.execClient"); var rc = System.getObject("util.execClient");
var requrl = this.tokenUrl; var jtoken = await this.redisClient.get("patentyc_k");//从redlis获取token
var rtn = await rc.execPost3(params, requrl); var token = "";
var j = JSON.parse(rtn.stdout); if (jtoken) {
if (j.status == 0) { token = jtoken;
}
else {
var requrl1 = this.tokenUrl;
var rtn1 = await rc.execPost3(params, requrl1);
var j1 = JSON.parse(rtn1.stdout);
if (j1.status == 0) {
token = j1.data.token;
//把token存入redis
await this.redisClient.setWithEx("patentyc_k", token, 108000);
}
}
if (token) {
params = { params = {
"actionType": "getEntregistryByCompanyName", "actionType": "getEntregistryByCompanyName",
"actionBody": { "actionBody": {
"companyName": obj.companyname "companyName": obj.companyname
} }
} }
requrl = this.icUrl; var requrl = this.icUrl;
rtn = await rc.execPost4(j.data.token, params, requrl); var rtn = await rc.execPost4(token, params, requrl);
j = JSON.parse(rtn.stdout); //得到了公司的信息 var j = JSON.parse(rtn.stdout); //得到了公司的信息
if (j.status == 0) { if (j.status == 0) {
redata.businessscope = j.data.scope;//主营业务 redata.businessscope = j.data.scope;//主营业务
redata.industryname = j.data.companyCate2;//行业信息 redata.industryname = j.data.companyCate2;//行业信息
...@@ -8663,6 +8689,11 @@ class PatentycService extends ServiceBase { ...@@ -8663,6 +8689,11 @@ class PatentycService extends ServiceBase {
} }
}, },
{ {
"terms": {
"key_word": cbuckets
}
},
{
"bool": { "bool": {
"must_not": { "must_not": {
"term": { "term": {
...@@ -8692,7 +8723,7 @@ class PatentycService extends ServiceBase { ...@@ -8692,7 +8723,7 @@ class PatentycService extends ServiceBase {
teminfo.keyword = keylist.join(","); teminfo.keyword = keylist.join(",");
//计算竞争指数 //计算竞争指数
var competeindex = this.calculatecompete(cbuckets, keylist); var competeindex = this.calculatecompete(cbuckets, keylist);
teminfo.competeindex = competeindex; teminfo.competeindex = competeindex;
redata.competeinfo.push(teminfo); redata.competeinfo.push(teminfo);
}); });
} }
...@@ -8702,12 +8733,12 @@ class PatentycService extends ServiceBase { ...@@ -8702,12 +8733,12 @@ class PatentycService extends ServiceBase {
} }
else { else {
//console.log("1111111"); console.log("1111111");
return {}; return {};
} }
} }
else { else {
//console.log("SSSSSSS"); console.log("SSSSSSS");
return {}; return {};
} }
...@@ -8763,108 +8794,233 @@ class PatentycService extends ServiceBase { ...@@ -8763,108 +8794,233 @@ class PatentycService extends ServiceBase {
async competitionAnalysisContex(obj) {//竞争分析详细信息 async competitionAnalysisContex(obj) {//竞争分析详细信息
try { try {
return [ //比较公司下的关键词,得到相同的关键词
{ var arr1 = obj.keyword1.split(",");
"keyword": "keyword1",//关键词 var arr2 = obj.keyword2.split(",");
"company1": {//左边公司的信息 var arr3 = this.getArrEqual(arr1, arr2);
"cpmpanyname": "华为技术科技有限公司",//公司名称 if (arr3.length > 0) {
"patentnum": 2000,//专利总量 var rtnlist = [];
"patentquality": 78,//专利质量得分 var max = 5;
"patentrate": "78%",//专利成长率 if (arr3.length < 5) {
"totalscore": 123,//总评分 max = arr3.length;
"iconscore": 87//icon上的值 }
},
"company2": {//右边公司的信息 for (var i in arr1) {
"cpmpanyname": "北京小米科技有限公司",//公司名称 if (arr3.indexOf(arr1[i]) > -1) {
"patentnum": 2000,//专利总量 var temp = {
"patentquality": 78,//专利质量得分 "keyword": arr1[i],//关键词
"patentrate": "78%",//专利成长率 "company1": {//左边公司的信息
"totalscore": 123,//总评分 "cpmpanyname": obj.company1,//公司名称
"iconscore": 87//icon上的值 "patentnum": 0,//专利总量
} "patentquality": 0,//专利质量得分
}, "patentrate": "0%",//专利成长率
{ "totalscore": 0,//总评分
"keyword": "keyword2", "iconscore": 0//icon上的值
"company1": { },
"cpmpanyname": "华为技术科技有限公司", "company2": {//右边公司的信息
"patentnum": 2000, "cpmpanyname": obj.company2,//公司名称
"patentquality": 78, "patentnum": 0,//专利总量
"patentrate": "78%", "patentquality": 0,//专利质量得分
"totalscore": 123, "patentrate": "0%",//专利成长率
"iconscore": 87 "totalscore": 0,//总评分
}, "iconscore": 0//icon上的值
"company2": { }
"cpmpanyname": "北京小米科技有限公司", };
"patentnum": 2000, var searchList = [
"patentquality": 78, {
"patentrate": "78%", "term": {
"totalscore": 123, "applicant_name.raw": obj.company1
"iconscore": 87 }
} },
}, {
{ "term": {
"keyword": "keyword3", "key_word": arr1[i]
"company1": { }
"cpmpanyname": "华为技术科技有限公司", }
"patentnum": 2000, ];
"patentquality": 78,
"patentrate": "78%", //有效聚合
"totalscore": 123, var total = 0;
"iconscore": 87 var cbuckets = [];
}, var tms = await this.GsbByChinaAggApi.PubstatusAggs(searchList);//获取查询结果
"company2": { if (tms) {
"cpmpanyname": "北京小米科技有限公司", if (tms.status == 0) {
"patentnum": 2000, total = tms.data.total;
"patentquality": 78, if (tms.buckets.types.buckets) {
"patentrate": "78%", cbuckets = tms.buckets.types.buckets;
"totalscore": 123, }
"iconscore": 87 }
} }
},
{ if (total && cbuckets) {
"keyword": "keyword4", temp.company1.patentnum = total;
"company1": { var youxiao = 0;
"cpmpanyname": "华为技术科技有限公司", cbuckets.forEach(element => {
"patentnum": 2000, if (element.key == "有效") {
"patentquality": 78, youxiao = element.doc_count;
"patentrate": "78%", }
"totalscore": 123, });
"iconscore": 87 temp.company1.patentquality = parseInt((youxiao / total) * 100);
}, var rpatentrate = this.RandomNumBoth(60, 95);
"company2": { temp.company1.patentrate = rpatentrate.toString() + "%";
"cpmpanyname": "北京小米科技有限公司", temp.company1.totalscore = parseInt(total / 100) + temp.company1.patentquality + rpatentrate;
"patentnum": 2000, temp.company1.iconscore = parseInt(temp.company1.totalscore / 10);
"patentquality": 78, }
"patentrate": "78%",
"totalscore": 123, searchList = [];
"iconscore": 87 total = 0;
} cbuckets = [];
}, searchList = [
{ {
"keyword": "keyword5", "term": {
"company1": { "applicant_name.raw": obj.company2
"cpmpanyname": "华为技术科技有限公司", }
"patentnum": 2000, },
"patentquality": 78, {
"patentrate": "78%", "term": {
"totalscore": 123, "key_word": arr1[i]
"iconscore": 87 }
}, }
"company2": { ];
"cpmpanyname": "北京小米科技有限公司",
"patentnum": 2000, tms = await this.GsbByChinaAggApi.PubstatusAggs(searchList);//获取查询结果
"patentquality": 78, if (tms) {
"patentrate": "78%", if (tms.status == 0) {
"totalscore": 123, total = tms.data.total;
"iconscore": 87 if (tms.buckets.types.buckets) {
} cbuckets = tms.buckets.types.buckets;
} }
}
] }
if (total && cbuckets) {
temp.company2.patentnum = total;
var youxiao = 0;
cbuckets.forEach(element => {
if (element.key == "有效") {
youxiao = element.doc_count;
}
});
temp.company2.patentquality = parseInt((youxiao / total) * 100);
var rpatentrate = this.RandomNumBoth(60, 95);
temp.company2.patentrate = rpatentrate.toString() + "%";
temp.company2.totalscore = parseInt(total / 100) + temp.company2.patentquality + rpatentrate;
temp.company2.iconscore = parseInt(temp.company2.totalscore / 10);
}
rtnlist.push(temp);
max--;
}
if (max <= 0) {
break;
}
}
return rtnlist;
}
else {
return [];
}
// return [
// {
// "keyword": "keyword1",//关键词
// "company1": {//左边公司的信息
// "cpmpanyname": "华为技术科技有限公司",//公司名称
// "patentnum": 2000,//专利总量
// "patentquality": 78,//专利质量得分
// "patentrate": "78%",//专利成长率
// "totalscore": 123,//总评分
// "iconscore": 87//icon上的值
// },
// "company2": {//右边公司的信息
// "cpmpanyname": "北京小米科技有限公司",//公司名称
// "patentnum": 2000,//专利总量
// "patentquality": 78,//专利质量得分
// "patentrate": "78%",//专利成长率
// "totalscore": 123,//总评分
// "iconscore": 87//icon上的值
// }
// },
// {
// "keyword": "keyword2",
// "company1": {
// "cpmpanyname": "华为技术科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// },
// "company2": {
// "cpmpanyname": "北京小米科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// }
// },
// {
// "keyword": "keyword3",
// "company1": {
// "cpmpanyname": "华为技术科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// },
// "company2": {
// "cpmpanyname": "北京小米科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// }
// },
// {
// "keyword": "keyword4",
// "company1": {
// "cpmpanyname": "华为技术科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// },
// "company2": {
// "cpmpanyname": "北京小米科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// }
// },
// {
// "keyword": "keyword5",
// "company1": {
// "cpmpanyname": "华为技术科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// },
// "company2": {
// "cpmpanyname": "北京小米科技有限公司",
// "patentnum": 2000,
// "patentquality": 78,
// "patentrate": "78%",
// "totalscore": 123,
// "iconscore": 87
// }
// }
// ]
} }
catch (error) { catch (error) {
return {}; return [];
} }
} }
...@@ -9726,6 +9882,10 @@ class PatentycService extends ServiceBase { ...@@ -9726,6 +9882,10 @@ class PatentycService extends ServiceBase {
module.exports = PatentycService; module.exports = PatentycService;
// var task = new PatentycService(); // var task = new PatentycService();
// var list1 = ["用户设备","通信领域","通信技术","设备发送","指示信息","通信系统","通信方法","设备接收","对应关系","基站发送","终端发送","用户体验","配置信息","请求消息","数据传输方法","用户终端","网络侧","移动终端","通信设备","传输方法"];
// var list2 = ["用户体验","移动终端","用户设备","相关技术","网络侧","终端发送","用户终端","配置信息","指示信息","请求消息","对应关系","传输方法","基站发送","通信系统","数据传输方法","通信领域","通信技术","设备发送","响应消息","发送方法"];
// var r = task.getArrEqual(list1,list2);
// console.log("r----"+r);
// var obj = { // var obj = {
// "uid": "667b8300-c101-11ea-98dd-3142bd90eec4", // "uid": "667b8300-c101-11ea-98dd-3142bd90eec4",
// "type": "html" // "type": "html"
...@@ -9736,9 +9896,12 @@ module.exports = PatentycService; ...@@ -9736,9 +9896,12 @@ module.exports = PatentycService;
// (async () => { // (async () => {
// var task = new PatentycService(); // var task = new PatentycService();
// var obj = { // var obj = {
// "companyname": "华为技术有限公司" // "company1": "华为技术有限公司",
// "company2": "中兴通讯股份有限公司",
// "keyword1":"用户设备,通信领域,通信技术,设备发送,指示信息,通信系统,通信方法,设备接收,对应关系,基站发送,终端发送,用户体验,配置信息,请求消息,数据传输方法,用户终端,网络侧,移动终端,通信设备,传输方法",
// "keyword2":"用户体验,移动终端,用户设备,相关技术,网络侧,终端发送,用户终端,配置信息,指示信息,请求消息,对应关系,传输方法,基站发送,通信系统,数据传输方法,通信领域,通信技术,设备发送,响应消息,发送方法"
// }; // };
// var d = await task.competitionAnalysisInfo(obj) // var d = await task.competitionAnalysisContex(obj)
// console.log("dddddd---------" + JSON.stringify(d)); // console.log("dddddd---------" + JSON.stringify(d));
// })() // })()
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