Commit 376523b0 by 宋毅

增加日志

parent 230e90cf
......@@ -10,7 +10,7 @@ module.exports = (db, DataTypes) => {
pushActionType: DataTypes.STRING,//调用参数
pushtimes:DataTypes.INTEGER,//推送次数
pushStatus:DataTypes.STRING,//推送状态
error:DataTypes.STRING,//错误信息
error:DataTypes.STRING(5000),//错误信息
}, {
paranoid: false,//假的删除
underscored: true,
......
......@@ -3,61 +3,70 @@ const ServiceBase = require("../../sve.base");
var settings = require("../../../../config/settings");
const uuidv4 = require('uuid/v4');
const getRawBody = require('raw-body');
class GatewaypushlogService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(GatewaypushlogService));
this.execClient = system.getObject("util.execClient");
this.dingClient = system.getObject("util.dingClient");
}
constructor() {
super("common", ServiceBase.getDaoName(GatewaypushlogService));
this.execClient = system.getObject("util.execClient");
this.dingClient = system.getObject("util.dingClient");
}
async taskAliIcapi() {
try {
var sql = "select * from gateway_pushlog where pushStatus='wts' and pushtimes<4"
var icloginfos = await this.customQuery(sql);
if (icloginfos.length > 0) {
var count = 100;
if (icloginfos.length < count) {
count = icloginfos.length;
}
var self = this;
for (var i = 0; i < count; i++) {
try {
var icloginfo = icloginfos[i];
var requestdata = null;
if (icloginfo && icloginfo.requestjson) {
requestdata = JSON.parse(icloginfo.requestjson);
}
var url = settings.gatewayUrl() + "action/intentionapi/springBoard";
var rtn = await self.execClient.execPost(requestdata, url);
var data = rtn
data = JSON.parse(rtn.stdout);
if (data.success) {
icloginfo.pushStatus = "yts";
} else {
if (data.errorMsg!="状态错误") {//除1 2 4 11其它状态没处理、返回的状态错误
data.push_url = url
data.api = "center-channel/taskAliIcapi"
this.dingClient.gatewayPushError(data)
}
icloginfo.pushtimes += 1;
async taskAliIcapi() {
try {
var sql = "select * from gateway_pushlog where pushStatus='wts' and pushtimes<4"
var icloginfos = await this.customQuery(sql);
if (icloginfos.length > 0) {
var count = 100;
if (icloginfos.length < count) {
count = icloginfos.length;
}
var self = this;
for (var i = 0; i < count; i++) {
try {
var icloginfo = icloginfos[i];
var requestdata = null;
if (icloginfo && icloginfo.requestjson) {
requestdata = JSON.parse(icloginfo.requestjson);
}
var url = settings.gatewayUrl() + "action/intentionapi/springBoard";
var rtn = await self.execClient.execPost(requestdata, url);
var data = rtn
data = JSON.parse(rtn.stdout);
if (data.success) {
icloginfo.pushStatus = "yts";
} else {
if (data.errorMsg != "状态错误") {//除1 2 4 11其它状态没处理、返回的状态错误
data.push_url = url;
data.api = "center-channel/taskAliIcapi-for";
data.requestdata = requestdata;
data.message = "error info";
this.dingClient.gatewayPushError(data);
}
icloginfo.error = JSON.stringify(data);
icloginfo.pushtimes += 1;
}
this.update(icloginfo);
} catch (e) {
const stackStr = e.stack ? e.stack : JSON.stringify(e);
icloginfo.error = stackStr;
this.update(icloginfo);
this.dingClient.gatewayPushError({
message: "Exception info",
api: "center-channel/taskAliIcapi-for",
e
})
}
}
}
this.update(icloginfo);
}catch (e) {
icloginfo.error=JSON.stringify(e)
this.update(icloginfo);
this.dingClient.gatewayPushError({message:"Exception",api:"center-channel/taskAliIcapi",e})
}
}
}
return system.getResultSuccess();
return system.getResultSuccess();
} catch (error) {
this.dingClient.gatewayPushError({message:"Exception",api:"center-channel/taskAliIcapi",error})
return system.getResultFail(-1,error);
} catch (error) {
this.dingClient.gatewayPushError({message: "Exception", api: "center-channel/taskAliIcapi", error})
return system.getResultFail(-1, error);
}
}
}
}
module.exports = GatewaypushlogService;
......@@ -192,12 +192,12 @@ module.exports = SignService;
// };
//需求
// var obj={
// "intentionBizId": "baidu_test_00091",
// "intentionBizId": "baidu_test_000101",
// "phone": "18506013355",
// "userName": "测试03",
// "description": "测试03描述",
// "area": "上海",
// "consultType": "7"
// "consultType": "GSREG"
// };
// task.createSign(obj,"7cbb892450174167b5c7e01we4716t51").then(sign=>{
// console.log(sign,"..............Sign");
......
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