Commit c3318ec5 by 宋毅

tj

parent 48c50875
const system = require("../system");
const moment = require('moment');
const settings = require("../../../app/config/settings")
const settings = require("../../../app/config/settings");
const axios = require('axios');
class APIBase {
......@@ -8,6 +8,7 @@ class APIBase {
this.redisClient = system.getObject("util.redisClient");
this.execClient = system.getObject("util.execClient");
this.esUtils = system.getObject("util.esUtils");
this.exTime = 6 * 3600;//缓存过期时间,6小时
}
//-----------------------新的模式------------------开始
......@@ -17,17 +18,17 @@ class APIBase {
if ("LOGS-SYTXPUBLIC-MSGQ" != settings.queuedName) {
pobj.actionBody.resultInfo = result;
pobj.actionBody.requestId = result.requestId;
pobj.actionBody.opTitle = "执行" + methodname + "方法";
this.esUtils.addEsLogs(settings.queuedName + "api-doexecmethod-info", pobj.actionBody);
return result;
pobj.actionBody.opTitle = "reqPath:" + req.path;
this.esUtils.addEsLogs(settings.queuedName + "api-req", pobj.actionBody);
}
return result;
} catch (e) {
console.log(e.stack, "api.base调用出现异常,请联系管理员..........");
var rtnerror = system.getResultFail(-200, "出现异常,error:" + e.stack);
rtnerror.requestId = await this.getBusUid("err");
pobj.actionBody.requestId = rtnerror.requestId;
pobj.actionBody.errorInfo = e.stack;
pobj.actionBody.opTitle = "执行" + methodname + "方法";
pobj.actionBody.opTitle = ",reqPath:" + req.path;
this.esUtils.addEsLogs(settings.queuedName + "apidoexec-error", pobj.actionBody);
return rtnerror;
}
......
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
......@@ -35,11 +35,11 @@ class ConsumerBase {
});
} catch (error) {
this.errorLogDao.addOpErrorLogs(queuedName + "队列执行doConsumer存在异常", null, null, error.stack, 3);
//日志记录
//日志
console.log(JSON.stringify({
optitle: this.serviceName + ",队列执行doConsumer存在异常",
op: "base/db/consumer.base.js",
message: error.stack
message: ""
}));
}
}
......@@ -81,7 +81,7 @@ class ConsumerBase {
console.log(JSON.stringify({
optitle: this.serviceName + ",队列执行execSubDoConsumer存在异常",
op: "base/db/consumer.base.js",
message: ""
message: error.stack
}));
}
}
......
......@@ -18,10 +18,13 @@ class DbFactory{
async initModels(){
var self=this;
var modelpath=path.normalize(path.join(__dirname, '../..'))+"/models/";
console.log(modelpath);
var models=glob.sync(modelpath+"/**/*.js");
console.log(models.length);
models.forEach(function(m){
self.db.import(m);
});
console.log("init models....");
}
async initRelations(){
......@@ -53,4 +56,49 @@ class DbFactory{
return this.db;
}
}
module.exports=DbFactory;
\ No newline at end of file
module.exports=DbFactory;
// const dbf=new DbFactory();
// dbf.getCon().then((db)=>{
// //console.log(db);
// // db.models.user.create({nickName:"jy","description":"cccc",openId:"xxyy",unionId:"zz"})
// // .then(function(user){
// // var acc=db.models.account.build({unionId:"zz",nickName:"jy"});
// // acc.save().then(a=>{
// // user.setAccount(a);
// // });
// // console.log(user);
// // });
// // db.models.user.findAll().then(function(rs){
// // console.log("xxxxyyyyyyyyyyyyyyyyy");
// // console.log(rs);
// // })
// });
// const User = db.define('user', {
// firstName: {
// type: Sequelize.STRING
// },
// lastName: {
// type: Sequelize.STRING
// }
// });
// db
// .authenticate()
// .then(() => {
// console.log('Co+nnection has been established successfully.');
//
// User.sync(/*{force: true}*/).then(() => {
// // Table created
// return User.create({
// firstName: 'John',
// lastName: 'Hancock'
// });
// });
//
// })
// .catch(err => {
// console.error('Unable to connect to the database:', err);
// });
//
// User.findAll().then((rows)=>{
// console.log(rows[0].firstName);
// });
const system = require("../../../system");
const Dao = require("../../dao.base");
const settings = require("../../../../config/settings");
class ErrorLogDao extends Dao {
constructor() {
super(Dao.getModelName(ErrorLogDao));
......@@ -12,9 +14,10 @@ class ErrorLogDao extends Dao {
* @param {*} error 错误信息
* @param {*} logLevel 日志级别信息,debug: 0, info: 1, warn: 2, error: 3, fatal: 4
*/
async addOpErrorLogs(opTitle, actionBody, execResult, error,logLevel) {
async addOpErrorLogs(opTitle, actionBody, execResult, error, logLevel) {
error = typeof error === 'object' ? error : { error_info: error };
var params = {
queued_name: settings.queuedName,
identify_code: actionBody.identifyCode,
op_title: opTitle,
push_content: actionBody || null,
......
const system = require("../../../system");
module.exports = (db, DataTypes) => {
return db.define("errorLog", {
queued_name: DataTypes.STRING(512), //队列名称
identify_code: DataTypes.STRING(100), //标识code
op_title: DataTypes.STRING(100), // 操作标题
push_content: DataTypes.JSON, //推送的内容
......
const system = require("../system");
const moment = require('moment')
const moment = require('moment');
const axios = require('axios');
const settings = require("../../config/settings");
class AppServiceBase {
......@@ -8,13 +9,44 @@ class AppServiceBase {
this.redisClient = system.getObject("util.redisClient");
}
/**
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/
async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) {
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;
}
}
}
}
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params),
timeout: timeOut
});
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");
......@@ -41,7 +73,7 @@ class AppServiceBase {
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
......@@ -59,7 +91,7 @@ class AppServiceBase {
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
......
const system = require("../system");
const axios = require('axios');
const moment = require('moment')
// const settings = require("../../config/settings");
class ServiceBase {
......@@ -15,13 +16,44 @@ class ServiceBase {
return resultStr;
}
/**
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/
* 带超时时间的post请求
* @param {*} params 请求数据-json格式
* @param {*} url 请求地址
* @param {*} ContentType 请求头类型,默认application/json
* @param {*} headData 请求头内容-json格式,如:请求头中传递token,格式:{token:"9098902q849q0434q09439"}
*/
async execPostByTimeOut(params, url, ContentType, headData, timeOut = 60) {
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;
}
}
}
}
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
headers: headers,
method: 'POST',
url: url,
data: JSON.stringify(params),
timeout: timeOut
});
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");
......@@ -39,7 +71,7 @@ class ServiceBase {
返回20位业务订单号
prefix:业务前缀
*/
async getBusUid(prefix) {
async getBusUid(prefix) {
prefix = (prefix || "");
if (prefix) {
prefix = prefix.toUpperCase();
......@@ -57,7 +89,7 @@ class ServiceBase {
len:返回长度
radix:参与计算的长度,最大为62
*/
async getUidInfo(len, radix) {
async getUidInfo(len, radix) {
var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');//长度62,到yz长度为长36
var uuid = [], i;
radix = radix || chars.length;
......
......@@ -33,7 +33,7 @@ class EsUtils {
actionBody.resultInfo = typeof actionBody.resultInfo === 'object' ? JSON.stringify(actionBody.resultInfo) : actionBody.resultInfo;
actionBody.errorInfo = typeof actionBody.errorInfo === 'object' ? JSON.stringify(actionBody.errorInfo) : actionBody.errorInfo;
var params = {
opTitle: actionBody.opTitle || "",
opTitle: moment().format("YYYY-MM-DD HH:mm:ss:SSS") + "," + actionBody.opTitle || "",
identifyCode: actionBody.identifyCode || "",
messageBody: actionBody.messageBody || "",
resultInfo: actionBody.resultInfo || "",
......@@ -51,7 +51,6 @@ class EsUtils {
*/
async execPostEs(queuedName, params, reqUrl, esName, esPwd) {
try {
params.opTitle = moment().format("YYYY-MM-DD HH:mm:ss:SSS") + params.opTitle || "";
if (settings.env === "dev") {
let result = await axios({
// headers: {'Content-Type': 'application/x-www-form-urlencoded'},
......@@ -77,9 +76,14 @@ class EsUtils {
return system.getResult(null, "执行execPostEs存在错误");
return system.getResult(null, "execPostTimeOut data is empty");
}
var stdoutInfo=JSON.parse(result.stdout);
if(stdoutInfo.error){
this.errorLogDao.addOpErrorLogs(queuedName + "执行execPostEs存在错误", params, result, null, 3);
return system.getResult(null, "执行execPostEs存在错误");
}
return system.getResultSuccess();
} catch (error) {
console.log(error.stack, "......execPostEs......error...");
console.log(error.stack, "......execPostEs....error.....");
this.errorLogDao.addOpErrorLogs(queuedName + "执行execPostEs存在异常", params, null, error.stack, 3);
}
}
......
......@@ -15,6 +15,7 @@ class ExecClient {
*/
async execGet(params, url, headData) {
let cmd = this.FetchGetCmd(params, url, headData);
console.log(cmd);
var result = await this.exec(cmd);
return result;
}
......@@ -90,6 +91,7 @@ class ExecClient {
FetchGetCmd(params, url, headData) {
var cmd = this.cmdGetPattern.replace(
/\{data\}/g, params).replace(/\{url\}/g, url);
console.log(cmd);
return cmd;
}
FetchPostCmd(params, url, ContentType, headData) {
......
......@@ -10,14 +10,8 @@ class RedisClient {
this.subclient = this.client.duplicate();
this.client.on("error", function (err) {
//TODO:日志处理
console.log(err, "..redisClient........error");
//TODO:日志记录
// logCtl.error({
// optitle:"redis this.client.on异常:",
// op:"base/utils/redisClient/this.client.on",
// content:err,
// clientIp:""
// });
});
const self = this;
// 监听回调
......@@ -90,11 +84,9 @@ class RedisClient {
messageBody = typeof messageBody === 'object' ? JSON.stringify(messageBody) : messageBody;
this.client.lpush(queuedName, messageBody, function (err, reply) {
if (err) {
//TODO:日志记录
console.log('lpush message error :' + err + ",queuedName:" + queuedName + ",messageBody:" + messageBody);
return new Error('lpush message error :' + err);
return new Error("lpush message error :" + err + ",queuedName:" + queuedName + ",messageBody:" + messageBody);
} else {
console.log('lpush message success');
console.log("lpush message success");
}
});
}
......@@ -120,10 +112,9 @@ class RedisClient {
param = typeof param === 'object' ? JSON.stringify(param) : param;
await this.client.zadd([collectionName + "-SORT", score, param], function (err, data) {
if (err) {
// TDO:日志记录
return new Error('zadd data error :' + err);
return new Error("zaddSortedSet data error :" + err + ",collectionName:" + collectionName + ",param:" + param);
} else {
console.log(data, 'zadd data success');
console.log("zaddSortedSet data success");
}
});
}
......
......@@ -66,8 +66,16 @@ module.exports = function (app) {
app.use(errorHandler());
} else {
app.use(function (err, req, res) {
//TODO:日志记录
console.log(err, "...environment........................error................");
console.log("prod error handler...........................................");
console.log(err);
logCtl.error({
optitle: "environment 调用异常error:",
op: req.url,
content: e.toString(),
clientIp: system.get_client_ip(req),
agent: req.headers["user-agent"],
});
//logerApp.error("prod error handler",err);
res.send("link index");
});
}
......
......@@ -18,10 +18,9 @@ var settings = {
consumerName: ENVINPUT.CONSUMER_NAME,
queuedName: ENVINPUT.QUEUED_NAME,
basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 8080,
port: process.env.NODE_PORT || 8086,
redis: function () {
if (this.env == "dev") {
console.log("dev.........................................................");
if (this.env == "dev" || this.env == "test") {
var localsettings = require("./localsettings");
return localsettings.redis;
} else {
......@@ -34,7 +33,7 @@ var settings = {
}
},
database: function () {
if (this.env == "dev") {
if (this.env == "dev" || this.env == "test") {
var localsettings = require("./localsettings");
return localsettings.database;
} else {
......
......@@ -9,6 +9,7 @@ const app = express();
// var dbf = system.getObject("db.common.connection");
// con = dbf.getCon();
console.log(settings.consumerName, "--consumerName-----start-----");
if (settings.consumerName) {
var consumer = system.getObject("consumer." + settings.consumerName);
(async () => {
......
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