Commit 09434842 by 李宏达

Merge branch 'ipop-web' of gitlab.gongsibao.com:jiangyong/zhichan into ipop-web

parents fd066b55 f93f43af
......@@ -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": {
......
......@@ -72,6 +72,48 @@ class PatentycCtl extends CtlBase {
}
}
async competitionAnalysisInfo(pobj,obj,req){//竞争分析基本信息
if (obj.companyname && obj.companyname != 'undefined'){
try{
var result = await this.service.competitionAnalysisInfo(obj);
if (result){
return System.getResult2(result);
}
else{
return System.getErrResult2("结果为空");
}
}
catch(error){
return System.getErrResult2(error);
}
}
else{
return System.getErrResult2("参数companyname不能为空");
}
}
async competitionAnalysisContex(pobj,obj,req){//竞争分析详细信息
if (obj.company1 && obj.company1 != 'undefined' && obj.company2 && obj.company2 != 'undefined'){
try{
var result = await this.service.competitionAnalysisContex(obj);
if (result){
return System.getResult2(result);
}
else{
return System.getErrResult2("结果为空");
}
}
catch(error){
return System.getErrResult2(error);
}
}
else{
return System.getErrResult2("参数不能为空");
}
}
//智能组合分析-获取报告
async ezGetReport(pobj,obj,req){
if (obj.uid && obj.uid != 'undefined' && obj.type && obj.type != 'undefined'){
......@@ -1390,21 +1432,24 @@ module.exports = PatentycCtl;
// var task = new PatentycCtl();
// var obj = {
// "uid": "667b8300-c101-11ea-98dd-3142bd90eec4",
// "type": "html"
// "companyname": "667b8300-c101-11ea-98dd-3142bd90eec4",
// "company2": "html"
// };
// var d = task.ezGetReport({},obj,{})
// console.log("dddddd---------" + JSON.stringify(d));
// task.competitionAnalysisInfo({},obj,{}).then(d=>{
// console.log(JSON.stringify(d));
// //console.log(d[0].analyse);
// })
// (async ()=>{
// var task = new PatentycCtl();
// var obj = {
// //"uid": "735f9cd0-c103-11ea-9ecd-1d1c3e85a974", //old
// "uid": "bb185dd0-c7d1-11ea-b098-d907460e6bad", //1000
// "uid": "a0892db0-c7ee-11ea-b890-f1c3c3e4b831", //1000
// //"uid":"b08b4f30-c7d6-11ea-b0d0-35e49817c337", //100
// "type": "html"
// };
// var d = await task.ReadyReport({},obj,{})
// //var d = await task.ReadyReport({},obj,{})
// var d = await task.ezReportUploadData({},obj,{});
// console.log("dddddd---------" + JSON.stringify(d));
// })()
......@@ -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",
......@@ -8298,7 +8335,7 @@ class PatentycService extends ServiceBase {
async ezReportUploadData(obj) {//智能组合分析-上传数据
var rearray = await this.prasecondition(obj, "");
var capilist = rearray[0];
//var capilist = [{ "term": { "province_name": "上海市" } }];
//var capilist = [ {"match": {"filing_name": "区块链"}}];
if (capilist.length > 0) {
var tms = await this.GsbByChinaPatentSearchApi.patentSearch(capilist);//获取查询结果
// console.log("-----------------------------------------" + JSON.stringify(tms));
......@@ -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,6 +8586,288 @@ class PatentycService extends ServiceBase {
}
}
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 = [
{
"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 = [
{
"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 {};
}
}
else {
//console.log("SSSSSSS");
return {};
}
// 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 {
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) {
return {};
}
}
async aliTrendGr(obj) {//区域专利监控首页 - 趋势详情-授权
var year = obj.year == null ? "" : obj.year;
var type = obj.type == null ? "" : obj.type;
......@@ -9414,13 +9733,12 @@ module.exports = PatentycService;
// var d = task.ezGetReport(obj)
// console.log("dddddd---------" + d);
// (async ()=>{
// (async () => {
// var task = new PatentycService();
// var obj = {
// "uid": "735f9cd0-c103-11ea-9ecd-1d1c3e85a974",
// "type": "html"
// "companyname": "华为技术有限公司"
// };
// var d = await task.ezReadyReport(obj)
// 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