Commit 376523b0 by 宋毅

增加日志

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