Commit 91f66031 by 高宇强

gyq

parent 8b64d42e
var APIBase = require("../../api.base");
var system = require("../../../system");
class EnterpriseQueryAPI extends APIBase {
constructor() {
super();
this.enterSve = system.getObject("service.enterprise.enterpriseSve");
}
/**
* 接口跳转-POST请求
* action_type 执行的类型
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
var result = await this.opActionProcess(pobj.actionType, pobj.actionBody);
return result;
}
async opActionProcess(action_type, action_body) {
var opResult = null;
switch (action_type) {
case "test"://测试
opResult = system.getResultSuccess(null, "测试成功");
break;
case "gxCountByAuthor"://获取企业高薪信息数量
opResult = await this.enterSve.gxCountByAuthor(action_body);
break;
case "gxListByAuthor"://获取企业高薪信息列表
opResult = await this.enterSve.gxListByAuthor(action_body);
break;
case "gameCountByAuthor"://获取企业游戏出版及运营数量
opResult = await this.enterSve.gameCountByAuthor(action_body);
break;
case "gameListByAuthor"://获取企业游戏出版及运营信息列表
opResult = await this.enterSve.gameListByAuthor(action_body);
break;
case "licenseCountByAuthor"://获取企业证照信息数量
opResult = await this.enterSve.licenseCountByAuthor(action_body);
break;
case "licenseListByAuthor"://获取企业证照信息列表
opResult = await this.enterSve.licenseListByAuthor(action_body);
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
}
return opResult;
}
}
module.exports = EnterpriseQueryAPI;
// var tesk = new EnterpriseQueryAPI();
// var parm = {
// actionType:"getLicenses",
// actionBody:{name:"上海盛霄云计算技术有限公司"}
// };
// tesk.springBoard(parm).then(function(result){
// console.log(result);
// //console.log(result.data.data[0]);
// }).catch(function(e){
// console.log(e);
// });
\ No newline at end of file
...@@ -64,18 +64,10 @@ class CopyRightSearchApi extends ApiBase { ...@@ -64,18 +64,10 @@ class CopyRightSearchApi extends ApiBase {
try { try {
rtn = await rc.execPost(params, requrl); rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout); var j = JSON.parse(rtn.stdout);
return rtn = { return System.getResult2(j.hits.total, null);
status: 0,
msg: "操作成功",
data: j.hits.total
};
} }
catch (e) { catch (e) {
return rtn = { return System.getResult2(null, "获取数据出错");
status: -1,
msg: "操作失败",
data: null
};
}; };
}; };
...@@ -133,7 +125,9 @@ class CopyRightSearchApi extends ApiBase { ...@@ -133,7 +125,9 @@ class CopyRightSearchApi extends ApiBase {
"reg_num", "reg_num",
"cat_num", "cat_num",
"reg_time", "reg_time",
"reg_date",
"publish_time", "publish_time",
"publish_date",
"software_version" "software_version"
], ],
"sort": [ "sort": [
...@@ -275,19 +269,12 @@ class CopyRightSearchApi extends ApiBase { ...@@ -275,19 +269,12 @@ class CopyRightSearchApi extends ApiBase {
try { try {
rtn = await rc.execPost(params, requrl); rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout); var j = JSON.parse(rtn.stdout);
return rtn = { return System.getResult2(j.hits.total, null);
status: 0,
msg: "操作成功",
data: j.hits.total
};
} }
catch (e) { catch (e) {
return rtn = { return System.getResult2(null, "获取数据出错");
status: -1,
msg: "操作失败",
data: null
};
}; };
}; };
/*查询某一个作品著作权人名下作品著作权列表(author:作品著作权人-精确、page_size:每页大小、current_page:当前第几页,从1开始) /*查询某一个作品著作权人名下作品著作权列表(author:作品著作权人-精确、page_size:每页大小、current_page:当前第几页,从1开始)
......
const System = require("../../../system");
var settings = require("../../../../config/settings");
const querystring = require('querystring');
class EnterpriseService {
constructor() {
this.gxgyUrl = settings.reqEsAddrIc() + "enterprise_chain_gxgy/_search";
this.licenseUrl = settings.reqEsAddrIc() + "enterprise_chain_license/_search";
this.gameUrl = settings.reqEsAddrIc() + "enterprise_chain_game/_search";
};
async getConvertSemiangleStr(str) {//半角转全角
var result = "";
var len = str.length;
for (var i = 0; i < len; i++) {
var cCode = str.charCodeAt(i);
//全角与半角相差(除空格外):65248(十进制)
cCode = (cCode >= 0xFF01 && cCode <= 0xFF5E) ? (cCode - 65248) : cCode;
//处理空格
cCode = (cCode == 0x03000) ? 0x0020 : cCode;
result += String.fromCharCode(cCode);
}
return result;
};
async gxCountByAuthor(obj) {//获取企业高薪信息数量
var author = obj.author == null || obj.author == "" || obj.author == "undefined" ? "" : obj.author;
if (author == "") {
return System.getResult2(null, "企业名称不能为空");
}
author = await this.getConvertSemiangleStr(author);
var params = {
"query": {
"term": {
"companyName.raw": author
}
},
"size": 0
};
var rc = System.getObject("util.execClient");
var rtn = null;
var requrl = this.gxgyUrl;
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return System.getResult2(j.hits.total, null);
}
catch (e) {
return System.getResult2(null, "获取数据出错");
};
};
async gxListByAuthor(obj) {//获取企业高薪信息列表
var author = obj.author == null || obj.author == "" || obj.author == "undefined" ? "" : obj.author;
var pagesize = obj.page_size == null || obj.page_size == "" || obj.page_size == "undefined" ? 10 : obj.page_size;
var from = obj.current_page == null || obj.current_page == "" || obj.current_page == "undefined" ? 0 : Number((obj.current_page - 1) * pagesize);
if (author == "") {
return System.getResult2(null, "企业名称不能为空");
}
author = await this.getConvertSemiangleStr(author);
var params = {
"query": {
"term": {
"companyName.raw": author
}
},
"from": from,
"size": pagesize,
"_source": [
"techType",
"area",
"certificateNo",
"address",
"year",
"businessScope"
],
"sort": [
{
"year": "desc"
}
]
};
var rc = System.getObject("util.execClient");
var rtn = null;
var requrl = this.gxgyUrl;
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
var res = {};
res.total = 0;
res.data = [];
if (j.hits.total > 0) {
res.total = j.hits.total;
for (var x in j.hits.hits) {
res.data.push(j.hits.hits[x]["_source"]);
}
}
return System.getResult2(res, null);
}
catch (e) {
return System.getResult2(null, "获取数据出错");
};
};
async gameCountByAuthor(obj) {//获取游戏出版及运营数量
var author = obj.author == null || obj.author == "" || obj.author == "undefined" ? "" : obj.author;
var type = obj.type == null || obj.type == "" || obj.type == "undefined" ? "" : obj.type;
if (author == "" || type == "") {
return System.getResult2(null, "企业名称和证照类型不能为空");
}
author = await this.getConvertSemiangleStr(author);
var params = null;
if (type == "网络游戏出版备案") {
params = {
"query": {
"term": {
"publishing_unit.raw": author
}
},
"size": 0
}
}
else if (type == "网络游戏运营备案") {
params = {
"query": {
"term": {
"operation_unit.raw": author
}
},
"size": 0
}
}
else {
return System.getResult2(null, "证照类型不正确");
}
var rc = System.getObject("util.execClient");
var rtn = null;
var requrl = this.gameUrl;
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
return System.getResult2(j.hits.total, null);
}
catch (e) {
return System.getResult2(null, "获取数据出错");
};
};
async gameListByAuthor(obj) {//获取游戏出版信息列表
var author = obj.author == null || obj.author == "" || obj.author == "undefined" ? "" : obj.author;
var type = obj.type == null || obj.type == "" || obj.type == "undefined" ? "" : obj.type;
var pagesize = obj.page_size == null || obj.page_size == "" || obj.page_size == "undefined" ? 10 : obj.page_size;
var from = obj.current_page == null || obj.current_page == "" || obj.current_page == "undefined" ? 0 : Number((obj.current_page - 1) * pagesize);
if (author == "" || type == "") {
return System.getResult2(null, "企业名称和证照类型不能为空");
}
author = await this.getConvertSemiangleStr(author);
var params = null;
if (type == "网络游戏出版备案") {
params = {
"query": {
"term": {
"publishing_unit.raw": author
}
},
"from": from,
"size": pagesize,
"_source": [
"game_name",
"declaration_category",
"publishing_unit",
"operation_unit",
"symbol",
"publishing_number",
"publish_time",
"publishing_record",
"operation_record",
"industry_type"
],
"sort": [
{
"publish_time": "desc"
}
]
}
}
else if (type == "网络游戏运营备案") {
params = {
"query": {
"term": {
"operation_unit.raw": author
}
},
"from": from,
"size": pagesize,
"_source": [
"game_name",
"declaration_category",
"publishing_unit",
"operation_unit",
"symbol",
"publishing_number",
"publish_time",
"publishing_record",
"operation_record",
"industry_type"
],
"sort": [
{
"publish_time": "desc"
}
]
}
}
else {
return System.getResult2(null, "证照类型不正确");
}
var rc = System.getObject("util.execClient");
var rtn = null;
var requrl = this.gameUrl;
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
var res = {};
res.total = 0;
res.data = [];
if (j.hits.total > 0) {
res.total = j.hits.total;
for (var x in j.hits.hits) {
res.data.push(j.hits.hits[x]["_source"]);
}
}
return System.getResult2(res, null);
}
catch (e) {
return System.getResult2(null, "获取数据出错");
};
};
async licenseCountByAuthor(obj) {//获取企业证照信息数量
var author = obj.author == null || obj.author == "" || obj.author == "undefined" ? "" : obj.author;
if (author == "") {
return System.getResult2(null, "企业名称不能为空");
}
author = await this.getConvertSemiangleStr(author);
var params = {
"query": {
"term": {
"companyName.raw": author
}
},
"from": 0,
"size": 0,
"aggregations": {
"group_by_licence": {
"terms": {
"field": "licence",
"size": 1000
}
}
}
};
var rc = System.getObject("util.execClient");
var rtn = null;
var requrl = this.licenseUrl;
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
var res = {};
res.total = 0;
res.data = [];
if (j.hits.total > 0) {
res.total = j.hits.total;
for (var x in j.aggregations.group_by_licence.buckets) {
res.data.push(j.aggregations.group_by_licence.buckets[x]);
}
}
return System.getResult2(res, null);
}
catch (e) {
return System.getResult2(null, "获取数据出错");
};
};
async licenseListByAuthor(obj) {//获取企业证照信息列表
var author = obj.author == null || obj.author == "" || obj.author == "undefined" ? "" : obj.author;
var licence = obj.licence == null || obj.licence == "" || obj.licence == "undefined" ? "" : obj.licence;
var pagesize = obj.page_size == null || obj.page_size == "" || obj.page_size == "undefined" ? 10 : obj.page_size;
var from = obj.current_page == null || obj.current_page == "" || obj.current_page == "undefined" ? 0 : Number((obj.current_page - 1) * pagesize);
if (author == "" || licence == "") {
return System.getResult2(null, "企业名称和证照类型不能为空");
}
author = await this.getConvertSemiangleStr(author);
var params = {
"query": {
"bool": {
"must": [
{
"term": {
"companyName.raw": author
}
},
{
"term": {
"licence": licence
}
},
]
}
},
"from": from,
"size": pagesize,
"_source": [
"companyName",
"licence",
"licence_no",
"service_category",
"start_date",
"end_date",
"industry_type"
],
"sort": [
{
"end_date": "desc"
}
]
};
var rc = System.getObject("util.execClient");
var rtn = null;
var requrl = this.licenseUrl;
try {
rtn = await rc.execPost(params, requrl);
var j = JSON.parse(rtn.stdout);
var res = {};
res.total = 0;
res.data = [];
if (j.hits.total > 0) {
res.total = j.hits.total;
for (var x in j.hits.hits) {
res.data.push(j.hits.hits[x]["_source"]);
}
}
return System.getResult2(res, null);
}
catch (e) {
return System.getResult2(null, "获取数据出错");
};
};
}
module.exports = EnterpriseService;
// var tesk = new EnterpriseService();
// var parm = {
// author: "上海橙域网络科技有限公司",
// licence: "IDC许可证"
// };
// tesk.licenseListByAuthor(parm).then(function (result) {
// console.log(result);
// console.log(result.data.data[0]);
// }).catch(function (e) {
// console.log(e);
// });
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