Commit c4d42762 by 宋毅

tj

parent 7b46ecdc
...@@ -42,43 +42,7 @@ class APIBase { ...@@ -42,43 +42,7 @@ class APIBase {
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"} * @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/ */
async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) { async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) {
if (settings.env === "dev") { return await this.execClient.execPostTimeOutByBusiness("api.base", params, url, ContentType, headData, timeOut);
var headers = {
'Content-type': 'application/json'
}
if (headData) {
var headDataKeys = Object.keys(headData);
if (headDataKeys.length > 0) {
for (let index = 0; index < headDataKeys.length; index++) {
const indexKey = headDataKeys[index];
var headValue = headData[indexKey];
if (indexKey && headValue) {
headers[indexKey] = headValue;
}
}
}
}
axios.default.timeout = timeOut;
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params)
});
if (result.status == 200 && result.data) {
return result.data;
}
this.errorLogDao.addOpErrorLogs(queuedName + "执行execPostEs存在错误", params, result, null, 3);
return system.getResult(null, "执行execPostEs存在错误");
}
//方式二
var rtn = await this.execClient.execPostTimeOut(params, url, ContentType, headData, timeOut);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPostTimeOut data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
} }
/** /**
* 返回20位业务订单号 * 返回20位业务订单号
......
const APIBase = require("../../api.base");
const system = require("../../../system");
const settings = require("../../../../config/settings")
class TestDataAPI extends APIBase {
constructor() {
super();
this.redisClient = system.getObject("util.redisClient");
this.configInfoDao = system.getObject("db.opLogs.configInfoDao");
}
/**
* 接口跳转-POST请求
* actionType 执行的功能模块
* action_body 执行的参数
*/
async springBoard(pobj, qobj, req) {
var tmpList = await this.configInfoDao.getList();
console.log(tmpList, ".........configInfoDao...............");
// for (let index = 0; index < 10; index++) {
// var num = index * 100;
// var tmpList = { "retcode": index, "msg": ("sy-success" + index.toString()), "sy-data": { "pageSize": 10, "curPage": 1, "search": {}, "orderArr": null, "total": 6, "rows": [{ "id": 1, "need_num": "N202006031601654", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 2, "need_num": "N202006031601655", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 3, "need_num": "N202006031601656", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 4, "need_num": "N202006031601657", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 5, "need_num": "N202006031601658", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }, { "id": 6, "need_num": "N202006031601659", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }] }, "requestId": "" };
// this.redisClient.zaddSortedSet("FAIL-" + settings.queuedName, num, tmpList);
// console.log(index, "..index................");
// }
// var tmpList = await this.redisClient.zrangeList("FAIL-" + settings.queuedName, 200, 200);
// var tmpList1 = await this.redisClient.zremrangebyscoreData("FAIL-" + settings.queuedName, 200, 200);
// var tmpList2 = await this.redisClient.zrangeList("FAIL-" + settings.queuedName, 200, 200);
// for (let index = 0; index < 1000000; index++) {
// var tmpList = { "retcode": index, "msg": "success", "data": { "pageSize": 10, "curPage": 1, "search": {}, "orderArr": null, "total": 6, "rows": [{ "id": 1, "need_num": "N202006031601654", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 2, "need_num": "N202006031601655", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 3, "need_num": "N202006031601656", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 4, "need_num": "N202006031601657", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": { "memoInfo": "备注信息", "clerkName": "业务员名称", "isWhether": "是否刻章", "clerkPhone": "业务员联系方式", "addressType": "地址类型-实际经营地址||虚拟地址", "companyName": "公司名称", "fullAddress": "注册的详细地址", "serviceArea": "服务地区(注册地区)", "schemeNumber": "方案编号", "statusReason": "退回或关闭的原因", "taxpayerType": "纳税人类型", "businessScope": "经营范围", "currentStatus": "当前状态", "engagedIndustry": "从事行业", "serviceProvider": "分配的服务商", "companyProperties": "公司性质" }, "isRefusal": 0 }, { "id": 5, "need_num": "N202006031601658", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }, { "id": 6, "need_num": "N202006031601659", "user_id": "1", "user_name": "张三", "contacts_name": "张三", "contacts_moblie": "13075556693", "region_id": "1", "region_name": "北京", "consult_type": 2, "consult_type_name": "公司注册", "status": 4, "notes": "测试数据勿删", "need_info": null, "servicer_code": "gsb", "servicer_name": "公司宝", "created_at": "2020-06-03T16:04:45.000Z", "updated_at": "2020-06-03T16:04:52.000Z", "deleted_at": null, "version": null, "solution_content": null, "isRefusal": null }] }, "requestId": "" };
// this.redisClient.setDelayEventData(settings.queuedName, tmpList, 120);
// console.log(index, "..index................");
// }
if (!pobj.actionType) {
return system.getResult(null, "actionType参数不能为空");
}
// var result = await this.opActionType(pobj, pobj.actionType, req);
// return result;
}
async opActionType(pobj, actionType, req) {
var opResult = null;
switch (actionType) {
case "test":
var tmpParam = {
actionType: "test",
actionBody: pobj.actionBody
}
opResult = await this.execPostByTimeOut(tmpParam, "http://192.168.1.189:4012/api/test/testApi/springBoard"
, null, { token: "123456", userId: "sy123" });
break;
default:
opResult = system.getResult(null, "actionType参数错误");
break;
}
return opResult;
}
}
module.exports = TestDataAPI;
\ No newline at end of file
...@@ -34,13 +34,9 @@ class ConsumerBase { ...@@ -34,13 +34,9 @@ class ConsumerBase {
} }
}); });
} catch (error) { } catch (error) {
this.errorLogDao.addOpErrorLogs(queuedName + "队列执行doConsumer存在异常", null, null, error.stack, 3); this.errorLogDao.addOpErrorLogs("队列执行doConsumer存在异常", null, null, error.stack, 3);
//日志 //日志
console.log(JSON.stringify({ console.log(error.stack, ",队列执行doConsumer存在异常");
optitle: this.serviceName + ",队列执行doConsumer存在异常",
op: "base/db/consumer.base.js",
message: ""
}));
} }
} }
...@@ -76,13 +72,9 @@ class ConsumerBase { ...@@ -76,13 +72,9 @@ class ConsumerBase {
} }
execResult = await this.subDoConsumer(queuedName, actionBody); execResult = await this.subDoConsumer(queuedName, actionBody);
} catch (error) { } catch (error) {
this.errorLogDao.addOpErrorLogs(queuedName + "队列执行execSubDoConsumer存在异常", actionBody, execResult, error.stack, 3); this.errorLogDao.addOpErrorLogs("队列执行execSubDoConsumer存在异常", actionBody, execResult, error.stack, 3);
//日志记录 //日志记录
console.log(JSON.stringify({ console.log(error.stack, ",队列执行execSubDoConsumer存在异常");
optitle: this.serviceName + ",队列执行execSubDoConsumer存在异常",
op: "base/db/consumer.base.js",
message: error.stack
}));
} }
} }
...@@ -105,43 +97,7 @@ class ConsumerBase { ...@@ -105,43 +97,7 @@ class ConsumerBase {
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"} * @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/ */
async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) { async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) {
if (settings.env === "dev") { return await this.execClient.execPostTimeOutByBusiness("consumer.base", params, url, ContentType, headData, timeOut);
var headers = {
'Content-type': 'application/json'
}
if (headData) {
var headDataKeys = Object.keys(headData);
if (headDataKeys.length > 0) {
for (let index = 0; index < headDataKeys.length; index++) {
const indexKey = headDataKeys[index];
var headValue = headData[indexKey];
if (indexKey && headValue) {
headers[indexKey] = headValue;
}
}
}
}
axios.default.timeout = timeOut;
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params)
});
if (result.status == 200 && result.data) {
return result.data;
}
this.errorLogDao.addOpErrorLogs(queuedName + "执行execPostEs存在错误", params, result, null, 3);
return system.getResult(null, "执行execPostEs存在错误");
}
//方式二
var rtn = await this.execClient.execPostTimeOut(params, url, ContentType, headData, timeOut);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPostTimeOut data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
} }
/* /*
返回20位业务订单号 返回20位业务订单号
......
...@@ -16,43 +16,7 @@ class AppServiceBase { ...@@ -16,43 +16,7 @@ class AppServiceBase {
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"} * @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/ */
async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) { async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) {
if (settings.env === "dev") { return await this.execClient.execPostTimeOutByBusiness("app.base", params, url, ContentType, headData, timeOut);
var headers = {
'Content-type': 'application/json'
}
if (headData) {
var headDataKeys = Object.keys(headData);
if (headDataKeys.length > 0) {
for (let index = 0; index < headDataKeys.length; index++) {
const indexKey = headDataKeys[index];
var headValue = headData[indexKey];
if (indexKey && headValue) {
headers[indexKey] = headValue;
}
}
}
}
axios.default.timeout = timeOut;
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params)
});
if (result.status == 200 && result.data) {
return result.data;
}
this.errorLogDao.addOpErrorLogs(queuedName + "执行execPostEs存在错误", params, result, null, 3);
return system.getResult(null, "执行execPostEs存在错误");
}
//方式二
var rtn = await this.execClient.execPostTimeOut(params, url, ContentType, headData, timeOut);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPostTimeOut data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
} }
async getConvertSemiangleStr(str) {//去除空格及全角转半角 async getConvertSemiangleStr(str) {//去除空格及全角转半角
......
...@@ -23,43 +23,7 @@ class ServiceBase { ...@@ -23,43 +23,7 @@ class ServiceBase {
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"} * @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/ */
async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) { async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) {
if (settings.env === "dev") { return await this.execClient.execPostTimeOutByBusiness("sve.base", params, url, ContentType, headData, timeOut);
var headers = {
'Content-type': 'application/json'
}
if (headData) {
var headDataKeys = Object.keys(headData);
if (headDataKeys.length > 0) {
for (let index = 0; index < headDataKeys.length; index++) {
const indexKey = headDataKeys[index];
var headValue = headData[indexKey];
if (indexKey && headValue) {
headers[indexKey] = headValue;
}
}
}
}
axios.default.timeout = timeOut;
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params)
});
if (result.status == 200 && result.data) {
return result.data;
}
this.errorLogDao.addOpErrorLogs(queuedName + "执行execPostEs存在错误", params, result, null, 3);
return system.getResult(null, "执行execPostEs存在错误");
}
//方式二
var rtn = await this.execClient.execPostTimeOut(params, url, ContentType, headData, timeOut);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPostTimeOut data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
} }
async create(qobj) { async create(qobj) {
return this.dao.create(qobj); return this.dao.create(qobj);
......
var childproc = require('child_process'); var childproc = require('child_process');
const system = require("../system");
const util = require('util'); const util = require('util');
const exec = util.promisify(require('child_process').exec); const exec = util.promisify(require('child_process').exec);
const settings = require("../../../app/config/settings");
const axios = require('axios');
class ExecClient { class ExecClient {
constructor() { constructor() {
this.cmdGetPattern = "curl -G -X GET '{url}'"; this.cmdGetPattern = "curl -G -X GET '{url}'";
this.cmdPostPattern = "curl -k -H 'Content-type: application/json' -d '{data}' {url}"; this.cmdPostPattern = "curl -k -H 'Content-type: application/json' -d '{data}' {url}";
// this.cmdPushDataPostPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}"; //--已废弃 // this.cmdPushDataPostPattern = "curl -k -H 'Content-type: application/json' -H 'token:{tk}' -H 'request-id:{requestId}' -d '{data}' {url}"; //--已废弃
this.errorLogDao = system.getObject("db.opLogs.errorLogDao");
} }
/** /**
* 带超时时间的post请求
* @param {*} execFile 执行文件
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
* @param {*} timeOut 超时时间设置,单位秒
*/
async execPostTimeOutByBusiness(execFile, params, url, ContentType, headData, timeOut = 5000) {
var rtn = null;
try {
if (settings.env === "dev") {
var headers = {
'Content-type': 'application/json'
}
if (headData) {
var headDataKeys = Object.keys(headData);
if (headDataKeys.length > 0) {
for (let index = 0; index < headDataKeys.length; index++) {
const indexKey = headDataKeys[index];
var headValue = headData[indexKey];
if (indexKey && headValue) {
headers[indexKey] = headValue;
}
}
}
}
axios.default.timeout = timeOut;
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params)
});
if (result.status == 200 && result.data) {
return result.data;
}
this.errorLogDao.addOpErrorLogs(queuedName + "执行execPostTimeOutByBusiness存在错误", params, result, null, 3);
return system.getResult(null, "执行execPostTimeOutByBusiness存在错误");
}
//方式二
rtn = await this.execPostTimeOut(params, url, ContentType, headData, timeOut);
if (!rtn || !rtn.stdout) {
return system.getResult(null, "execPostTimeOut data is empty");
}
var result = JSON.parse(rtn.stdout);
return result;
} catch (error) {
this.errorLogDao.addOpErrorLogs(execFile + "执行execPostByTimeOut存在异常", params, rtn.stdout, error.stack, 3);
return system.getResultFail(-200, execFile + "执行execPostByTimeOut存在异常");
}
}
/**
* get请求 * get请求
* @param {*} params 提交的数据-格式JSON * @param {*} params 提交的数据-格式JSON
* @param {*} url * @param {*} url
......
...@@ -5,6 +5,7 @@ const bluebird = require("bluebird"); ...@@ -5,6 +5,7 @@ const bluebird = require("bluebird");
bluebird.promisifyAll(redis); bluebird.promisifyAll(redis);
class RedisClient { class RedisClient {
constructor() { constructor() {
this.redisConfig = settings.redis();
this.client = this.getCreateClientInstance(); this.client = this.getCreateClientInstance();
this.subclient = this.client.duplicate(); this.subclient = this.client.duplicate();
...@@ -56,12 +57,12 @@ class RedisClient { ...@@ -56,12 +57,12 @@ class RedisClient {
return this.subclient; return this.subclient;
} }
getCreateClientInstance() { getCreateClientInstance() {
const redisConfig = settings.redis() const self = this;
return redis.createClient({ return redis.createClient({
host: redisConfig.host, host: self.redisConfig.host,
port: redisConfig.port, port: self.redisConfig.port,
password: redisConfig.password, password: self.redisConfig.password,
db: redisConfig.db, db: self.redisConfig.db,
retry_strategy: function (options) { retry_strategy: function (options) {
if (options.total_retry_time > 1000 * 60 * 60) { if (options.total_retry_time > 1000 * 60 * 60) {
return new Error('Retry time exhausted'); return new Error('Retry time exhausted');
......
...@@ -5,7 +5,7 @@ var settings = { ...@@ -5,7 +5,7 @@ var settings = {
host: "43.247.184.32", host: "43.247.184.32",
port: 8967, port: 8967,
password: "Gongsibao2018", password: "Gongsibao2018",
db: 5, db: 4,
}, },
database: { database: {
dbname: "tx-queue-log", dbname: "tx-queue-log",
......
...@@ -10,15 +10,15 @@ var ENVINPUT = { ...@@ -10,15 +10,15 @@ var ENVINPUT = {
REDIS_DB: process.env.TASK_REDIS_DB, REDIS_DB: process.env.TASK_REDIS_DB,
DB_NAME: process.env.TASK_DB_NAME, DB_NAME: process.env.TASK_DB_NAME,
APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "test",//运行环境 APP_ENV: process.env.APP_ENV ? process.env.APP_ENV : "test",//运行环境
CONSUMER_NAME: process.env.CONSUMER_NAME || "publicLogs.publicLogsConsumer",//消费者名称 CONSUMER_NAME: process.env.CONSUMER_NAME || "publicServiceAllocation.publicConsumer",//消费者名称
QUEUED_NAME: process.env.QUEUED_NAME || "LOGS-SYTXPUBLIC-MSGQ",//队列名称,FAIL-失败队列(队列和失败队列一对存在进行部署) QUEUED_NAME: process.env.QUEUED_NAME || "SYTXPUBLIC-MSGQ",//队列名称,FAIL-失败队列(队列和失败队列一对存在进行部署)
}; };
var settings = { var settings = {
env: ENVINPUT.APP_ENV, env: ENVINPUT.APP_ENV,
consumerName: ENVINPUT.CONSUMER_NAME, consumerName: ENVINPUT.CONSUMER_NAME,
queuedName: ENVINPUT.QUEUED_NAME, queuedName: ENVINPUT.QUEUED_NAME,
basepath: path.normalize(path.join(__dirname, '../..')), basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 8081, port: process.env.NODE_PORT || 4018,
redis: function () { redis: function () {
if (this.env == "dev" || this.env == "test") { if (this.env == "dev" || this.env == "test") {
var localsettings = require("./localsettings"); var localsettings = require("./localsettings");
......
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