Commit 0abd66c5 by 宋毅

tj

parent 8f279bb7
......@@ -6,6 +6,7 @@ class ProducerAPI extends APIBase {
constructor() {
super();
this.utilsProduceSve = system.getObject("service.utilsSve.utilsProduceSve");
this.utilsLogsSve = system.getObject("service.utilsSve.utilsLogsSve");
}
/**
* 接口跳转-POST请求
......@@ -31,6 +32,9 @@ class ProducerAPI extends APIBase {
}
opResult = await this.utilsProduceSve.produceLogsData(pobj, req);
break;
case "queryLogsData":
opResult = await this.utilsLogsSve.getListByIndexName(pobj.actionBody, req);
break;
default:
opResult = system.getResult(null, "actionType参数错误");
break;
......
......@@ -43,25 +43,7 @@ class UtilsIcService extends AppServiceBase {
"from": from,
"size": pageSize,
"_source": [
"company_name"//公司名称
// "company_org_type",//公司类型
// "credit_code",//统一社会信用代码
// "legal_person",//法人姓名
// "from_time",//营业期限开始日期
// "to_time",//营业期限结束日期
// "estiblish_time",//成立时间
// "reg_status",//公司状态
// "reg_number",//注册号
// "org_number",//组织机构代码
// "reg_location",//公司地址
// "reg_capital",//注册资本
// "business_scope",//公司经营范围
// "reg_institute",//登记机关
// "company_province",//公司省份
// "company_city",//公司二级市
// "company_cate_1",//行业分类一级分类
// "company_cate_2",//行业分类二级分类
// "company_cate_3"//行业分类三级分类
"company_name"
]
// ,
// "sort": [
......@@ -82,7 +64,10 @@ class UtilsIcService extends AppServiceBase {
"currentPage": from === 0 ? from : (from - 1),
"list": sources
};
if (!resultData.data.hits) {
if (resultData.status != 1) {
return system.getResult(null, resultData.message);
}
if (!resultData.data || !resultData.data.hits) {
return system.getResult(null, "data is empty");
}
if (!resultData.data.hits.hits || resultData.data.hits.hits.length === 0) {
......@@ -91,25 +76,6 @@ class UtilsIcService extends AppServiceBase {
resultData.data.hits.hits.forEach(function (c) {
var source = {
"companyName": c._source.company_name//公司名称
// "companyOrgType": c._source.company_org_type || "",//公司类型
// "creditCode": c._source.credit_code || "",//统一社会信用代码
// "legalPerson": c._source.legal_person,//法人姓名
// "fromTime": c._source.from_time ? moment(c._source.from_time * 1000).format("YYYY-MM-DD") : "",//营业期限开始日期
// "toTime": c._source.to_time ? moment(c._source.to_time * 1000).format("YYYY-MM-DD") : "",//营业期限结束日期
// "estiblishTime": c._source.estiblish_time ? moment(c._source.estiblish_time * 1000).format("YYYY-MM-DD") : "",//成立时间
// "regStatus": c._source.reg_status || "",//公司状态
// "regNumber": c._source.reg_number || "",//注册号
// "orgNumber": c._source.org_number || "",//组织机构代码
// "regLocation": c._source.reg_location || "",//公司地址
// "regCapital": c._source.reg_capital || "",//注册资本
// "businessScope": c._source.business_scope || "",//公司经营范围
// "regInstitute": c._source.reg_institute || "",//登记机关
// "companyProvince": c._source.company_province || "",//公司省份
// "companyCity": c._source.company_city || "",//公司二级市
// "companyCate1": c._source.company_cate_1 || "",//行业分类一级分类
// "companyCate2": c._source.company_cate_2 || "",//行业分类二级分类
// "companyCate3": c._source.company_cate_3 || ""//行业分类三级分类
};
sources.push(source);
});
......@@ -179,7 +145,10 @@ class UtilsIcService extends AppServiceBase {
var resultData = null;
try {
resultData = await this.esUtils.execPostEs(settings.queuedName, params, esIndexName);
if (!resultData.data.hits) {
if (resultData.status != 1) {
return system.getResult(null, resultData.message);
}
if (!resultData.data || !resultData.data.hits) {
return system.getResult(null, "data is empty");
}
if (!resultData.data.hits.hits || resultData.data.hits.hits.length === 0) {
......
const system = require("../../../system");
const AppServiceBase = require("../../app.base");
const settings = require("../../../../config/settings");
const moment = require('moment');
//用户权限操作
class UtilsLogsService extends AppServiceBase {
constructor() {
super();
this.esUtils = system.getObject("util.esUtils");
}
/**
* 公司模糊查询
* actionBody
* {
* indexName:索引名称,
* opTitle:标题-否,
* identifyCode:标识-否,
* messageBody:参数内容-否,
* errorInfo:错误信息-否,
* currentPage:第几页,
* pageSize:每页大小
* }
*/
async getListByIndexName(actionBody, req) {
if (!actionBody.indexName) {
return system.getResult(null, "indexName can not be empty");
}
var pageSize = !actionBody.pageSize ? 20 : Number(actionBody.pageSize);
if (pageSize < 0) {
pageSize = 20;
}
if (pageSize > 200) {
pageSize = 200;
}
var from = !actionBody.currentPage ? 0 : Number((actionBody.currentPage - 1) * pageSize);
if (from < 0) {
from = 0;
}
var esIndexName = actionBody.indexName + "/_search";
var params = {
"query": {
"bool": {
"must": []
}
},
"from": from,
"size": pageSize,
"_source": [
"opTitle",
"identifyCode",
"messageBody",
"resultInfo",
"errorInfo",
"requestId",
"created_at"
]
,
"sort": [
{
"created_at": "desc"
}
]
}
if (actionBody.opTitle) {
params.query.bool.must.push({
"query_string": {
"default_field": "opTitle",
"query": '\"' + actionBody.opTitle + '\"'
}
});
}
if (actionBody.identifyCode) {
params.query.bool.must.push({
"query_string": {
"default_field": "identifyCode",
"query": '\"' + actionBody.identifyCode + '\"'
}
});
}
if (actionBody.messageBody) {
params.query.bool.must.push({
"query_string": {
"default_field": "messageBody",
"query": '\"' + actionBody.messageBody + '\"'
}
});
}
if (actionBody.errorInfo) {
params.query.bool.must.push({
"query_string": {
"default_field": "errorInfo",
"query": '\"' + actionBody.errorInfo + '\"'
}
});
}
if (actionBody.requestId) {
params.query.bool.must.push({
"query_string": {
"default_field": "requestId",
"query": '\"' + actionBody.requestId + '\"'
}
});
}
var resultData = null;
try {
resultData = await this.esUtils.execPostEs(settings.queuedName, params, esIndexName);
var sources = [];
var data = {
"totalCount": resultData.data && resultData.data.hits ? resultData.data.hits.total : 0,
"pageSize": pageSize,
"currentPage": from === 0 ? from : (from - 1),
"list": sources
};
if (resultData.status != 1) {
return system.getResult(null, resultData.message);
}
if (!resultData.data || !resultData.data.hits) {
return system.getResult(null, "data is empty");
}
if (!resultData.data.hits.hits || resultData.data.hits.hits.length === 0) {
return system.getResult(null, "data is empty!");
}
resultData.data.hits.hits.forEach(function (c) {
var source = {
"opTitle": c._source.opTitle,
"identifyCode": c._source.identifyCode,
"messageBody": c._source.messageBody,
"resultInfo": c._source.resultInfo,
"errorInfo": c._source.errorInfo,
"requestId": c._source.requestId,
"created_at": c._source.created_at
};
sources.push(source);
});
return system.getResultSuccess(data);
} catch (error) {
var stackStr = error.stack ? error.stack : JSON.stringify(error);
console.log(stackStr, ".. getListByLikeCompanyName query is error");
//TODO:日志
return system.getResultError("query is error");
}
}
}
module.exports = UtilsLogsService;
......@@ -98,7 +98,45 @@
status: 1, //1为成功,否则为失败
msg: "测试成功",
data: null
}
}
3.日志查询接口
地址:http://192.168.1.128:4019/api/queueAction/producer/springBoard
请求方式:post
参数:
{
"actionType": "queryLogsData",// Y 功能名称
"actionBody": {
"opTitle": "",// N 操作的业务标题
"indexName": "sytxpublic-msgq-request",// Y es索引值,同一个项目用一个值
"identifyCode": "needSubmit",// Y 操作的业务标识
"messageBody":"",//N 日志的描述信息
"resultInfo":"",//N 返回信息
"errorInfo": "",//N 错误信息
"requestId": ""//N 请求返回的requestId
}
}
返回参数:
{
"status": 1,//1为成功,否则为失败
"message": "success",
"data": {
"totalCount": 1,
"pageSize": 20,
"currentPage": 0,
"list": [
{
"opTitle": "2020-07-04 12:35:30:949,reqPath:/api/queueAction/producer/springBoard",
"identifyCode": "needSubmit",
"messageBody": "{\"Action\":\"SubmitNeed\",\"UserName\":\"婷亭婷\",\"UserId\":\"100000013569\",\"ContactsMobile\":\"19139640302\",\"ContactsName\":\"test07042034\",\"RegionId\":\"110100\",\"RegionName\":\"北京\",\"ConsultType\":\"/ic/kzfw/\",\"ConsultTypeName\":\"/工商服务/刻章服务/\",\"VerificationCode\":\"478582\",\"Notes\":\"test-20200704-2034\",\"Email\":\"\",\"WechatNo\":\"o_x4KwdEMLqJXkjaksRJZ5zE7e68\",\"ServicerCode\":\"S_202006201810vrHKgE\",\"ServicerName\":\"公司宝\",\"NeedNum\":\"N202007042035JE2gJxy\"};actionType=needSubmit;pushUrl=http://tx.g.com:8000/entService/consultation/springBoard",
"resultInfo": "{\"status\":1,\"message\":\"success\",\"data\":null,\"requestId\":\"SCZ2020070412352wq9O\"}",
"errorInfo": "",
"requestId": "SCZ2020070412352wq9O",
"created_at": "2020-07-04T12:35:30.949Z"
}
]
},
"requestId": "SCZ202007151641Kc4j9"
}
三.业务查询接口
1.tx cos 信息获取
......
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