Commit 7edeb56f by 李宏达

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

parents a80d57a5 373ce68b
var System=require("../../system");
var settings=require("../../../config/settings");
var System = require("../../system");
var settings = require("../../../config/settings");
const querystring = require('querystring');
const ApiBase =require("../api.base");
const ApiBase = require("../api.base");
class ChinaPatentSearchApi extends ApiBase{
constructor(){
class ChinaPatentSearchApi extends ApiBase {
constructor() {
super();
this.patentUrl = settings.reqEsAddrIc()+"bigdata_patent_op/_search";
this.patentUrl = settings.reqEsAddrIc() + "bigdata_patent_op/_search";
};
buildDate(date){
buildDate(date) {
var date = new Date(date);
var time = Date.parse(date);
time=time / 1000;
time = time / 1000;
return time;
};
async ObtainChinaPatentInfo(obj){
async ObtainChinaPatentInfo(obj) {
console.log("----------------api-ObtainChinaPatentInfo----------------");
console.log(obj);
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var params= {
var params = {
"query": {
"bool": {
"must": []
}
},
};
var applynum=obj.applynum==null?"":obj.applynum;//专利申请号
if (applynum != null && applynum != ""){
var applynum = obj.applynum == null ? "" : obj.applynum;//专利申请号
if (applynum != null && applynum != "") {
var param = {
"term": {
"filing_no": applynum
"filing_no": applynum
}
}
params.query.bool.must.push(param)
}
var publishnum=obj.publishnum==null?"":obj.publishnum;//专利公开号
if (publishnum != null && publishnum != ""){
var arr= publishnum.split("");
if(arr[arr.length-1]=="A"){
var publishnum = obj.publishnum == null ? "" : obj.publishnum;//专利公开号
if (publishnum != null && publishnum != "") {
var arr = publishnum.split("");
if (arr[arr.length - 1] == "A") {
var param = {
"term": {
"pub_no": publishnum
"pub_no": publishnum
}
};
}else{
} else {
var param = {
"term": {
"gr_no": publishnum
"gr_no": publishnum
}
};
}
params.query.bool.must.push(param)
}
var rc=System.getObject("util.execClient");
var rtn=null;
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);
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return rtn = {
status:0,
msg:"操作成功",
data:j.hits.hits
status: 0,
msg: "操作成功",
data: j.hits.hits
};
}catch(e){
return rtn={
status:-1,
msg:"操作失败",
data:null
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null
};
}
};
async CommomSearchbyTitle(obj){//根据标题查询聚合
async CommomSearchbyTitle(obj) {//根据标题查询聚合
console.log("--------CommomSearchbyTitle----------");
console.log(obj);
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var pagesize = obj.pagesize == null ? 10 : obj.pagesize;
if (obj.page == null) {
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
} else {
var from = Number((obj.page - 1) * obj.pagesize);
}
var title = obj.title==null?"":obj.title;
if(title==""){
return {status:-1,msg:"传入标题信息为空",data:null,buckets:null};
var title = obj.title == null ? "" : obj.title;
if (title == "") {
return { status: -1, msg: "传入标题信息为空", data: null, buckets: null };
}
var params= {
var params = {
"query": {
"bool": {
"must": []
......@@ -119,30 +119,30 @@ class ChinaPatentSearchApi extends ApiBase{
],
"aggregations": {
"group_by_pub_type": {
"terms": {
"field": "pub_type",
"size": 1000
}
"terms": {
"field": "pub_type",
"size": 1000
}
},
"group_by_pub_status": {
"terms": {
"field": "pub_status",
"size": 1000
}
"terms": {
"field": "pub_status",
"size": 1000
}
},
"group_by_filing_year": {
"terms": {
"field": "filing_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "filing_year",
"size": 1000,
"order": { "_term": "desc" }
}
},
"group_by_pub_year": {
"terms": {
"field": "pub_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "pub_year",
"size": 1000,
"order": { "_term": "desc" }
}
}
}
};
......@@ -154,96 +154,96 @@ class ChinaPatentSearchApi extends ApiBase{
}
params.query.bool.must.push(param);
var pubtype=obj.pubtype==null?"":obj.pubtype;//专利类型
if (pubtype != null && pubtype != ""){
var pubtype = obj.pubtype == null ? "" : obj.pubtype;//专利类型
if (pubtype != null && pubtype != "") {
param = {
"term": {
"pub_type": pubtype
"pub_type": pubtype
}
}
params.query.bool.must.push(param)
}
var pubstatus = obj.pubstatus==null?"":obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != ""){
var pubstatus = obj.pubstatus == null ? "" : obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != "") {
param = {
"term": {
"pub_status": pubstatus
"pub_status": pubstatus
}
}
params.query.bool.must.push(param)
}
var filingyear = obj.filingyear==null?"":obj.filingyear;//申请年份
if (filingyear != null && filingyear !=""){
var filingyear = obj.filingyear == null ? "" : obj.filingyear;//申请年份
if (filingyear != null && filingyear != "") {
param = {
"term": {
"filing_year": filingyear
"filing_year": filingyear
}
}
params.query.bool.must.push(param)
}
var pubyear = obj.pubyear==null?"":obj.pubyear;//公开年份
if (pubyear != null && pubyear != ""){
var pubyear = obj.pubyear == null ? "" : obj.pubyear;//公开年份
if (pubyear != null && pubyear != "") {
param = {
"term": {
"pub_year": pubyear
"pub_year": pubyear
}
}
params.query.bool.must.push(param)
}
var rc=System.getObject("util.execClient");
var rtn=null;
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);
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return rtn = {
status:0,
msg:"操作成功",
data:j.hits,
buckets:j.aggregations
status: 0,
msg: "操作成功",
data: j.hits,
buckets: j.aggregations
};
}catch(e){
return rtn={
status:-1,
msg:"操作失败",
data:null,
buckets:null
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null,
buckets: null
};
}
};
async CommomSearchbyFilingno(obj){//根据申请号查询聚合
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
async CommomSearchbyFilingno(obj) {//根据申请号查询聚合
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var pagesize = obj.pagesize == null ? 10 : obj.pagesize;
if (obj.page == null) {
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
} else {
var from = Number((obj.page - 1) * obj.pagesize);
}
var filingno = obj.filingno==null?"":obj.filingno;
if(filingno==""){
return {status:-1,msg:"传入的申请号信息为空",data:null,buckets:null};
var filingno = obj.filingno == null ? "" : obj.filingno;
if (filingno == "") {
return { status: -1, msg: "传入的申请号信息为空", data: null, buckets: null };
}
else{
filingno = filingno.replace("CN","").replace("cn","").replace(".","");
if (filingno.length == 13){
filingno = filingno.substr(0,12);
else {
filingno = filingno.replace("CN", "").replace("cn", "").replace(".", "");
if (filingno.length == 13) {
filingno = filingno.substr(0, 12);
}
else if (filingno.length == 9){
filingno = filingno.substr(0,8);
else if (filingno.length == 9) {
filingno = filingno.substr(0, 8);
}
}
var params= {
var params = {
"query": {
"bool": {
"must": []
......@@ -266,123 +266,123 @@ class ChinaPatentSearchApi extends ApiBase{
],
"aggregations": {
"group_by_pub_type": {
"terms": {
"field": "pub_type",
"size": 1000
}
"terms": {
"field": "pub_type",
"size": 1000
}
},
"group_by_pub_status": {
"terms": {
"field": "pub_status",
"size": 1000
}
"terms": {
"field": "pub_status",
"size": 1000
}
},
"group_by_filing_year": {
"terms": {
"field": "filing_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "filing_year",
"size": 1000,
"order": { "_term": "desc" }
}
},
"group_by_pub_year": {
"terms": {
"field": "pub_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "pub_year",
"size": 1000,
"order": { "_term": "desc" }
}
}
}
};
var param = {
"wildcard": {
"filing_no": "*"+filingno+"*"
"filing_no": "*" + filingno + "*"
}
}
params.query.bool.must.push(param);
var pubtype=obj.pubtype==null?"":obj.pubtype;//专利类型
if (pubtype != null && pubtype != ""){
var pubtype = obj.pubtype == null ? "" : obj.pubtype;//专利类型
if (pubtype != null && pubtype != "") {
param = {
"term": {
"pub_type": pubtype
"pub_type": pubtype
}
}
params.query.bool.must.push(param)
}
var pubstatus = obj.pubstatus==null?"":obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != ""){
var pubstatus = obj.pubstatus == null ? "" : obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != "") {
param = {
"term": {
"pub_status": pubstatus
"pub_status": pubstatus
}
}
params.query.bool.must.push(param)
}
var filingyear = obj.filingyear==null?"":obj.filingyear;//申请年份
if (filingyear != null && filingyear !=""){
var filingyear = obj.filingyear == null ? "" : obj.filingyear;//申请年份
if (filingyear != null && filingyear != "") {
param = {
"term": {
"filing_year": filingyear
"filing_year": filingyear
}
}
params.query.bool.must.push(param)
}
var pubyear = obj.pubyear==null?"":obj.pubyear;//公开年份
if (pubyear != null && pubyear != ""){
var pubyear = obj.pubyear == null ? "" : obj.pubyear;//公开年份
if (pubyear != null && pubyear != "") {
param = {
"term": {
"pub_year": pubyear
"pub_year": pubyear
}
}
params.query.bool.must.push(param)
}
var rc=System.getObject("util.execClient");
var rtn=null;
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);
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return rtn = {
status:0,
msg:"操作成功",
data:j.hits,
buckets:j.aggregations
status: 0,
msg: "操作成功",
data: j.hits,
buckets: j.aggregations
};
}catch(e){
return rtn={
status:-1,
msg:"操作失败",
data:null,
buckets:null
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null,
buckets: null
};
}
};
async CommomSearchbyPubno(obj){//根据公开号查询聚合
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
async CommomSearchbyPubno(obj) {//根据公开号查询聚合
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var pagesize = obj.pagesize == null ? 10 : obj.pagesize;
if (obj.page == null) {
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
} else {
var from = Number((obj.page - 1) * obj.pagesize);
}
var pubno = obj.pubno==null?"":obj.pubno;
if(pubno==""){
return {status:-1,msg:"传入的公开号信息为空",data:null,buckets:null};
var pubno = obj.pubno == null ? "" : obj.pubno;
if (pubno == "") {
return { status: -1, msg: "传入的公开号信息为空", data: null, buckets: null };
}
var params= {
var params = {
"query": {
"bool": {
"must": []
......@@ -405,138 +405,138 @@ class ChinaPatentSearchApi extends ApiBase{
],
"aggregations": {
"group_by_pub_type": {
"terms": {
"field": "pub_type",
"size": 1000
}
"terms": {
"field": "pub_type",
"size": 1000
}
},
"group_by_pub_status": {
"terms": {
"field": "pub_status",
"size": 1000
}
"terms": {
"field": "pub_status",
"size": 1000
}
},
"group_by_filing_year": {
"terms": {
"field": "filing_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "filing_year",
"size": 1000,
"order": { "_term": "desc" }
}
},
"group_by_pub_year": {
"terms": {
"field": "pub_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "pub_year",
"size": 1000,
"order": { "_term": "desc" }
}
}
}
};
var param = {
"bool": {
"should": [
]
"should": [
]
}
}
var parr = {
"wildcard": {
"pub_no": "*"+pubno+"*"
"pub_no": "*" + pubno + "*"
}
}
param.bool.should.push(parr)
parr = {
"wildcard": {
"gr_no": "*"+pubno+"*"
"gr_no": "*" + pubno + "*"
}
}
param.bool.should.push(parr)
params.query.bool.must.push(param);
var pubtype=obj.pubtype==null?"":obj.pubtype;//专利类型
if (pubtype != null && pubtype != ""){
var pubtype = obj.pubtype == null ? "" : obj.pubtype;//专利类型
if (pubtype != null && pubtype != "") {
param = {
"term": {
"pub_type": pubtype
"pub_type": pubtype
}
}
params.query.bool.must.push(param)
}
var pubstatus = obj.pubstatus==null?"":obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != ""){
var pubstatus = obj.pubstatus == null ? "" : obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != "") {
param = {
"term": {
"pub_status": pubstatus
"pub_status": pubstatus
}
}
params.query.bool.must.push(param)
}
var filingyear = obj.filingyear==null?"":obj.filingyear;//申请年份
if (filingyear != null && filingyear !=""){
var filingyear = obj.filingyear == null ? "" : obj.filingyear;//申请年份
if (filingyear != null && filingyear != "") {
param = {
"term": {
"filing_year": filingyear
"filing_year": filingyear
}
}
params.query.bool.must.push(param)
}
var pubyear = obj.pubyear==null?"":obj.pubyear;//公开年份
if (pubyear != null && pubyear != ""){
var pubyear = obj.pubyear == null ? "" : obj.pubyear;//公开年份
if (pubyear != null && pubyear != "") {
param = {
"term": {
"pub_year": pubyear
"pub_year": pubyear
}
}
params.query.bool.must.push(param)
}
var rc=System.getObject("util.execClient");
var rtn=null;
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);
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return rtn = {
status:0,
msg:"操作成功",
data:j.hits,
buckets:j.aggregations
status: 0,
msg: "操作成功",
data: j.hits,
buckets: j.aggregations
};
}catch(e){
return rtn={
status:-1,
msg:"操作失败",
data:null,
buckets:null
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null,
buckets: null
};
}
};
async CommomSearchbyApplicant(obj){//根据申请人查询聚合
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
async CommomSearchbyApplicant(obj) {//根据申请人查询聚合
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var pagesize = obj.pagesize == null ? 10 : obj.pagesize;
if (obj.page == null) {
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
} else {
var from = Number((obj.page - 1) * obj.pagesize);
}
var applicant = obj.applicant==null?"":obj.applicant;
if(applicant==""){
return {status:-1,msg:"传入的申请人信息为空",data:null,buckets:null};
var applicant = obj.applicant == null ? "" : obj.applicant;
if (applicant == "") {
return { status: -1, msg: "传入的申请人信息为空", data: null, buckets: null };
}
var params= {
var params = {
"query": {
"bool": {
"must": []
......@@ -559,30 +559,30 @@ class ChinaPatentSearchApi extends ApiBase{
],
"aggregations": {
"group_by_pub_type": {
"terms": {
"field": "pub_type",
"size": 1000
}
"terms": {
"field": "pub_type",
"size": 1000
}
},
"group_by_pub_status": {
"terms": {
"field": "pub_status",
"size": 1000
}
"terms": {
"field": "pub_status",
"size": 1000
}
},
"group_by_filing_year": {
"terms": {
"field": "filing_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "filing_year",
"size": 1000,
"order": { "_term": "desc" }
}
},
"group_by_pub_year": {
"terms": {
"field": "pub_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "pub_year",
"size": 1000,
"order": { "_term": "desc" }
}
}
}
};
......@@ -590,92 +590,92 @@ class ChinaPatentSearchApi extends ApiBase{
var param = {
"query_string": {
"default_field": "applicant_name",
"query": "\""+ applicant +"\""
"query": "\"" + applicant + "\""
}
}
params.query.bool.must.push(param);
var pubtype=obj.pubtype==null?"":obj.pubtype;//专利类型
if (pubtype != null && pubtype != ""){
var pubtype = obj.pubtype == null ? "" : obj.pubtype;//专利类型
if (pubtype != null && pubtype != "") {
param = {
"term": {
"pub_type": pubtype
"pub_type": pubtype
}
}
params.query.bool.must.push(param)
}
var pubstatus = obj.pubstatus==null?"":obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != ""){
var pubstatus = obj.pubstatus == null ? "" : obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != "") {
param = {
"term": {
"pub_status": pubstatus
"pub_status": pubstatus
}
}
params.query.bool.must.push(param)
}
var filingyear = obj.filingyear==null?"":obj.filingyear;//申请年份
if (filingyear != null && filingyear !=""){
var filingyear = obj.filingyear == null ? "" : obj.filingyear;//申请年份
if (filingyear != null && filingyear != "") {
param = {
"term": {
"filing_year": filingyear
"filing_year": filingyear
}
}
params.query.bool.must.push(param)
}
var pubyear = obj.pubyear==null?"":obj.pubyear;//公开年份
if (pubyear != null && pubyear != ""){
var pubyear = obj.pubyear == null ? "" : obj.pubyear;//公开年份
if (pubyear != null && pubyear != "") {
param = {
"term": {
"pub_year": pubyear
"pub_year": pubyear
}
}
params.query.bool.must.push(param)
}
var rc=System.getObject("util.execClient");
var rtn=null;
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);
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return rtn = {
status:0,
msg:"操作成功",
data:j.hits,
buckets:j.aggregations
status: 0,
msg: "操作成功",
data: j.hits,
buckets: j.aggregations
};
}catch(e){
return rtn={
status:-1,
msg:"操作失败",
data:null,
buckets:null
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null,
buckets: null
};
}
};
async CommomSearchbyInventor(obj){//根据发明人查询聚合
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
async CommomSearchbyInventor(obj) {//根据发明人查询聚合
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var pagesize = obj.pagesize == null ? 10 : obj.pagesize;
if (obj.page == null) {
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
} else {
var from = Number((obj.page - 1) * obj.pagesize);
}
var inventor = obj.inventor==null?"":obj.inventor;
if(inventor==""){
return {status:-1,msg:"传入的发明人信息为空",data:null,buckets:null};
var inventor = obj.inventor == null ? "" : obj.inventor;
if (inventor == "") {
return { status: -1, msg: "传入的发明人信息为空", data: null, buckets: null };
}
var params= {
var params = {
"query": {
"bool": {
"must": []
......@@ -698,30 +698,30 @@ class ChinaPatentSearchApi extends ApiBase{
],
"aggregations": {
"group_by_pub_type": {
"terms": {
"field": "pub_type",
"size": 1000
}
"terms": {
"field": "pub_type",
"size": 1000
}
},
"group_by_pub_status": {
"terms": {
"field": "pub_status",
"size": 1000
}
"terms": {
"field": "pub_status",
"size": 1000
}
},
"group_by_filing_year": {
"terms": {
"field": "filing_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "filing_year",
"size": 1000,
"order": { "_term": "desc" }
}
},
"group_by_pub_year": {
"terms": {
"field": "pub_year",
"size": 1000,
"order":{"_term":"desc"}
}
"terms": {
"field": "pub_year",
"size": 1000,
"order": { "_term": "desc" }
}
}
}
};
......@@ -729,85 +729,85 @@ class ChinaPatentSearchApi extends ApiBase{
var param = {
"query_string": {
"default_field": "inventor_name",
"query": "\""+ inventor +"\""
"query": "\"" + inventor + "\""
}
}
params.query.bool.must.push(param);
var pubtype=obj.pubtype==null?"":obj.pubtype;//专利类型
if (pubtype != null && pubtype != ""){
var pubtype = obj.pubtype == null ? "" : obj.pubtype;//专利类型
if (pubtype != null && pubtype != "") {
param = {
"term": {
"pub_type": pubtype
"pub_type": pubtype
}
}
params.query.bool.must.push(param)
}
var pubstatus = obj.pubstatus==null?"":obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != ""){
var pubstatus = obj.pubstatus == null ? "" : obj.pubstatus;//法律状态
if (pubstatus != null && pubstatus != "") {
param = {
"term": {
"pub_status": pubstatus
"pub_status": pubstatus
}
}
params.query.bool.must.push(param)
}
var filingyear = obj.filingyear==null?"":obj.filingyear;//申请年份
if (filingyear != null && filingyear !=""){
var filingyear = obj.filingyear == null ? "" : obj.filingyear;//申请年份
if (filingyear != null && filingyear != "") {
param = {
"term": {
"filing_year": filingyear
"filing_year": filingyear
}
}
params.query.bool.must.push(param)
}
var pubyear = obj.pubyear==null?"":obj.pubyear;//公开年份
if (pubyear != null && pubyear != ""){
var pubyear = obj.pubyear == null ? "" : obj.pubyear;//公开年份
if (pubyear != null && pubyear != "") {
param = {
"term": {
"pub_year": pubyear
"pub_year": pubyear
}
}
params.query.bool.must.push(param)
}
var rc=System.getObject("util.execClient");
var rtn=null;
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);
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return rtn = {
status:0,
msg:"操作成功",
data:j.hits,
buckets:j.aggregations
status: 0,
msg: "操作成功",
data: j.hits,
buckets: j.aggregations
};
}catch(e){
return rtn={
status:-1,
msg:"操作失败",
data:null,
buckets:null
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null,
buckets: null
};
}
};
async seniorSearch(obj){//高级检索,根据用户输入的不同多条件进行检索
var data=await this.checkKey(obj.appKey);
if(data && data.status && data.status==-1){
async seniorSearch(obj) {//高级检索,根据用户输入的不同多条件进行检索
var data = await this.checkKey(obj.appKey);
if (data && data.status && data.status == -1) {
return data;
}
var pagesize = obj.pagesize==null?10:obj.pagesize;
if(obj.page==null){
var pagesize = obj.pagesize == null ? 10 : obj.pagesize;
if (obj.page == null) {
var from = 0;
}else{
var from = Number((obj.page-1)*obj.pagesize);
} else {
var from = Number((obj.page - 1) * obj.pagesize);
}
var params = {
......@@ -835,37 +835,37 @@ class ChinaPatentSearchApi extends ApiBase{
var param = null;
//对关键词
var title=obj.title==null?"":obj.title;
if (title != null && title != ""){
param ={
var title = obj.title == null ? "" : obj.title;
if (title != null && title != "") {
param = {
"match": {
"filing_name": title
"filing_name": title
}
}
params.query.bool.must.push(param)
}
var abstr = obj.abstr==null?"":obj.abstr;
if (abstr != null && abstr != ""){
param ={
var abstr = obj.abstr == null ? "" : obj.abstr;
if (abstr != null && abstr != "") {
param = {
"match": {
"abstr_text": abstr
"abstr_text": abstr
}
}
params.query.bool.must.push(param)
}
var filingno=obj.filingno==null?"":obj.filingno;
if(filingno!=null && filingno!=""){
filingno = filingno.replace("CN","").replace("cn","").replace(".","");
if (filingno.length == 13){
filingno = filingno.substr(0,12);
var filingno = obj.filingno == null ? "" : obj.filingno;
if (filingno != null && filingno != "") {
filingno = filingno.replace("CN", "").replace("cn", "").replace(".", "");
if (filingno.length == 13) {
filingno = filingno.substr(0, 12);
}
else if (filingno.length == 9){
filingno = filingno.substr(0,8);
else if (filingno.length == 9) {
filingno = filingno.substr(0, 8);
}
param= {
param = {
"term": {
"filing_no": filingno
}
......@@ -873,12 +873,12 @@ class ChinaPatentSearchApi extends ApiBase{
params.query.bool.must.push(param)
}
var pubno=obj.pubno==null?"":obj.pubno;
if (pubno!=null && pubno!=""){
var pubno = obj.pubno == null ? "" : obj.pubno;
if (pubno != null && pubno != "") {
param = {
"bool": {
"should": [
]
"should": [
]
}
}
......@@ -898,15 +898,15 @@ class ChinaPatentSearchApi extends ApiBase{
params.query.bool.must.push(param);
}
var priorno=obj.priorno==null?"":obj.priorno;
if (priorno != null && priorno != ""){
param= {
var priorno = obj.priorno == null ? "" : obj.priorno;
if (priorno != null && priorno != "") {
param = {
"nested": {
"path": "prior_info",
"query": {
"bool": {
"must": [
{ "term": { "prior_info.pri_no": priorno}}
{ "term": { "prior_info.pri_no": priorno } }
]
}
}
......@@ -915,27 +915,27 @@ class ChinaPatentSearchApi extends ApiBase{
params.query.bool.must.push(param)
}
var appl=obj.applname==null?"":obj.applname;
if (appl!=null && appl!=""){
param= {
var appl = obj.applname == null ? "" : obj.applname;
if (appl != null && appl != "") {
param = {
"term": {
"applicant_name.raw": appl
}
}
params.query.bool.must.push(param)
}
var inv=obj.invname==null?"":obj.invname;
if (inv!=null && inv!=""){
param= {
var inv = obj.invname == null ? "" : obj.invname;
if (inv != null && inv != "") {
param = {
"term": {
"inventor_name.raw": inv
}
}
params.query.bool.must.push(param)
}
var ipc=obj.ipcno==null?"":obj.ipcno;
if (ipc!=null && ipc!=""){
var param= {
var ipc = obj.ipcno == null ? "" : obj.ipcno;
if (ipc != null && ipc != "") {
var param = {
"term": {
"other_ipc": ipc
}
......@@ -943,102 +943,150 @@ class ChinaPatentSearchApi extends ApiBase{
params.query.bool.must.push(param)
}
if(obj.filingdate1!=null && obj.filingdate1!=""){
var filingdate1=obj.filingdate1;
if (obj.filingdate1 != null && obj.filingdate1 != "") {
var filingdate1 = obj.filingdate1;
}
else {
var filingdate1 ="";
var filingdate1 = "";
}
if(obj.filingdate2!=null && obj.filingdate2!=""){
var filingdate2=obj.filingdate2;
if (obj.filingdate2 != null && obj.filingdate2 != "") {
var filingdate2 = obj.filingdate2;
}
else {
var filingdate2 = "";
}
if (filingdate1!="" || filingdate2!=""){
param={
if (filingdate1 != "" || filingdate2 != "") {
param = {
"range": {
"filing_time": {
}
}
};
if (filingdate1!=""){
param.range.filing_time["gte"]=filingdate1;
if (filingdate1 != "") {
param.range.filing_time["gte"] = filingdate1;
}
if (filingdate2!=""){
param.range.filing_time["lte"]=filingdate2;
if (filingdate2 != "") {
param.range.filing_time["lte"] = filingdate2;
}
params.query.bool.must.push(param);
}
if(obj.pubdate1!=null && obj.pubdate1!=""){
var pubdate1=obj.pubdate1;
if (obj.pubdate1 != null && obj.pubdate1 != "") {
var pubdate1 = obj.pubdate1;
}
else {
var pubdate1 ="";
var pubdate1 = "";
}
if(obj.pubdate2!=null && obj.pubdate2!=""){
var pubdate2=obj.pubdate2;
if (obj.pubdate2 != null && obj.pubdate2 != "") {
var pubdate2 = obj.pubdate2;
}
else {
var pubdate2 = "";
}
if (pubdate1!="" || pubdate2!=""){
param={
if (pubdate1 != "" || pubdate2 != "") {
param = {
"range": {
"pub_time": {
}
}
};
if (pubdate1!=""){
param.range.pub_time["gte"]=pubdate1;
if (pubdate1 != "") {
param.range.pub_time["gte"] = pubdate1;
}
if (pubdate2!=""){
param.range.pub_time["lte"]=pubdate2;
if (pubdate2 != "") {
param.range.pub_time["lte"] = pubdate2;
}
params.query.bool.must.push(param);
}
if(obj.grdate1!=null && obj.grdate1!=""){
var grdate1=obj.grdate1;
if (obj.grdate1 != null && obj.grdate1 != "") {
var grdate1 = obj.grdate1;
}
else {
var grdate1 ="";
var grdate1 = "";
}
if(obj.grdate2!=null && obj.grdate2!=""){
var grdate2=obj.grdate2;
if (obj.grdate2 != null && obj.grdate2 != "") {
var grdate2 = obj.grdate2;
}
else {
var grdate2 = "";
}
if (grdate1!="" || grdate2!=""){
param={
if (grdate1 != "" || grdate2 != "") {
param = {
"range": {
"gr_time": {
}
}
};
if (grdate1!=""){
param.range.gr_time["gte"]=grdate1;
if (grdate1 != "") {
param.range.gr_time["gte"] = grdate1;
}
if (grdate2!=""){
param.range.gr_time["lte"]=grdate2;
if (grdate2 != "") {
param.range.gr_time["lte"] = grdate2;
}
params.query.bool.must.push(param);
}
var rc=System.getObject("util.execClient");
var rtn=null;
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 System.getResult2(j.hits,null);
}catch(e){
return rtn=System.getResult2(null,null);
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return System.getResult2(j.hits, null);
} catch (e) {
return rtn = System.getResult2(null, null);
}
};
async patentSearch(obj) {//根据条件检索
var params = {
"query": {
"bool": {
"must": []
}
},
"from": 0,
"size": 1000,
};
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);
// console.log("jjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjjj" + rtn.stdout);
var j = JSON.parse(rtn.stdout);
if (j.hits.hits.length > 0){
return rtn = {
status: 0,
msg: "操作成功",
data: j.hits.hits
};
}
else{
return rtn = {
status: -1,
msg: "检索结果为空",
data: null
};
}
} catch (e) {
return rtn = {
status: -1,
msg: "操作失败",
data: null
};
}
};
}
module.exports = ChinaPatentSearchApi;
......@@ -14,8 +14,85 @@ class PatentycCtl extends CtlBase {
async patentrank(pobj,obj,req){
var result = await this.service.patentrank(obj);
return System.getResult2(result,null);
}
}
//对比分析
async webInsight(pobj,obj,req){
if (obj.type && obj.type != 'undefined'){
var result = await this.service.webInsight(obj);
if (result){
return System.getResult2(result);
}
else{
return System.getErrResult2("返回结果为空");
}
}
else{
return System.getErrResult2("参数type不能为空");
}
}
//智能组合分析-上传数据
async ezReportUploadData(pobj,obj,req){
try{
var result = await this.service.ezReportUploadData(obj);
if (result){
return System.getResult2(result);//"result":true,"uid":"735f9cd0-c103-11ea-9ecd-1d1c3e85a974"}
}
else{
return System.getErrResult2("返回结果为空");
}
}
catch(error){
return System.getErrResult2(error);
}
}
//智能组合分析-判断报告是否生成,用于轮询
async ReadyReport(pobj,obj,req){
if (obj.uid && obj.uid != 'undefined'){
try{
var result = await this.service.ezReadyReport(obj);
if (result == 1){
return System.getResult2(result);
}
else{
return System.getResult2("报告尚未生成");
}
}
catch(error){
return System.getErrResult2(error);
}
}
else{
return System.getErrResult2("参数uid不能为空");
}
}
//智能组合分析-获取报告
async ezGetReport(pobj,obj,req){
if (obj.uid && obj.uid != 'undefined' && obj.type && obj.type != 'undefined'){
try{
var result = await this.service.ezGetReport(obj);
if (result){
return System.getResult2(result);
}
else{
return System.getErrResult2("返回结果为空");
}
}
catch(error){
return System.getErrResult2(error);
}
}
else{
return System.getErrResult2("参数type和uid不能为空");
}
}
//专利价值评价报告
async obtainreport(pobj,obj,req){
var result = await this.service.obtainreport(obj);
......@@ -1310,3 +1387,22 @@ class PatentycCtl extends CtlBase {
}
module.exports = PatentycCtl;
// var task = new PatentycCtl();
// var obj = {
// "uid": "667b8300-c101-11ea-98dd-3142bd90eec4",
// "type": "html"
// };
// var d = task.ezGetReport({},obj,{})
// console.log("dddddd---------" + JSON.stringify(d));
// (async ()=>{
// var task = new PatentycCtl();
// var obj = {
// "uid": "735f9cd0-c103-11ea-9ecd-1d1c3e85a974",
// "type": "html"
// };
// var d = await task.ezGetReport({},obj,{})
// console.log("dddddd---------" + JSON.stringify(d));
// })()
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -11,7 +11,9 @@ class ExecClient {
async exec(cmd) {
//await后面表达式返回的promise对象,是then的语法糖,await返回then函数的返回值
//异常需要try/catch自己捕获或外部catch捕获
const {stdout, stderr} = await exec(cmd);
const {stdout, stderr} = await exec(cmd,{
maxBuffer: 40960 * 1024
});
return {stdout, stderr};
}
......@@ -49,7 +51,9 @@ class ExecClient {
async execGet(subData, url) {
let cmd = this.FetchGetCmd(subData, url);
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
console.log(cmd);
console.log("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
var result = await this.exec(cmd);
return result;
}
......
......@@ -67,6 +67,7 @@
"gulp-tap": "^1.0.1",
"imagemin-pngquant": "^7.0.0",
"merge-stream": "^2.0.0",
"minimist": "^1.2.0"
"minimist": "^1.2.0",
"soap": "^0.31.0"
}
}
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