Commit 8481d1b6 by 庄冰

push2fqandui

parent 3851cee4
......@@ -47,6 +47,9 @@ class Template extends APIBase {
case "submitFormRecord"://提交表单记录
opResult = await this.formsubmitrecordSve.submitFormRecord(pobj);
break;
case "pushFormInfo2Fq"://推送需求表单信息至蜂擎
opResult = await this.formsubmitrecordSve.pushFormInfo2Fq();
break;
default:
opResult = system.getResult(null, "action_type参数错误");
break;
......
......@@ -20,6 +20,8 @@ module.exports = (db, DataTypes) => {
},
record_status_name: DataTypes.STRING(60),//记录状态名称
templatelink_snapshot:DataTypes.JSON,//模板链接快照
form_snapshot:DataTypes.JSON,//表单快照
ali_code:DataTypes.STRING,
record_content:DataTypes.JSON,//记录内容
push_status:DataTypes.INTEGER,//推送状态 0:未推送,1:已推送 2:异常
op_notes:DataTypes.STRING,//操作备注
......
const system = require("../../../system");
const settings = require("../../../../config/settings");
// const fqBaseUrl="https://fq.gongsibao.com";//生产环境
const fqBaseUrl="https://fqdev.gongsibao.com";//测试环境
class FqUtilsService {
constructor() {
this.execClient = system.getObject("util.execClient");
this.logClient = system.getObject("util.logClient");
}
async pushNeedInfo2Fq(pobj,code){
try {
var url = fqBaseUrl+"/open/ex/flux/advisory?code="+code;
var rtn = await this.execClient.execPost(pobj, url);
var data = JSON.parse(rtn.stdout);
this.logClient.pushlog("测试数据---推送需求数据至蜂擎返回结果-pushNeedInfo2Fq-success",pobj, rtn, null);
return data;
} catch (e) {
this.logClient.pushlog("测试数据---推送需求数据至蜂擎返回异常-pushNeedInfo2Fq-error", pobj, null, e.stack);
return null;
}
}
}
module.exports = FqUtilsService;
\ No newline at end of file
......@@ -9,6 +9,7 @@ class FormsubmitrecordService extends ServiceBase {
this.templatelinkDao = system.getObject("db.template.templatelinkDao");
this.forminfoDao = system.getObject("db.configmag.forminfoDao");
this.formitemDao = system.getObject("db.configmag.formitemDao");
this.fqUtilsSve = system.getObject("service.common.fqUtilsSve");
}
/**
......@@ -27,6 +28,9 @@ class FormsubmitrecordService extends ServiceBase {
if(!ab.form_id){
return system.getResultFail(-102,"表单id不能为空");
}
if(!ab.ali_code){
return system.getResultFail(-103,"校验编码不能为空");
}
//获取模板链接信息
var linkInfo = await this.templatelinkDao.model.findOne({
where:{code:ab.link_code},raw:true
......@@ -62,15 +66,16 @@ class FormsubmitrecordService extends ServiceBase {
}
var params = res;
var addObj={
ali_code:ab.ali_code,
template_id:linkInfo.template_id,templatelink_id:linkInfo.id,
form_id:forminfo.id,record_status:1,templatelink_snapshot:linkInfo,
form_snapshot:{forminfo:forminfo,formitems:formitems},
form_snapshot:forminfo,
record_content:params,business_code:templateinfo.business_code,
push_status:0
}
if(ab.push_status==1){
addObj.push_status=1;
}
// if(ab.push_status==1){
// addObj.push_status=1;
// }
await this.dao.create(addObj);//创建记录
return system.getResultSuccess();
}
......@@ -111,6 +116,63 @@ class FormsubmitrecordService extends ServiceBase {
}
return params;
}
//将需求信息推送至蜂擎
async pushFormInfo2Fq(){
var limit = 100;
var formRecords = await this.dao.model.findAll({
attributes:["id","templatelink_snapshot","form_snapshot","ali_code","record_content"],
where:{
push_status:0,
ali_code:{[this.db.Op.ne]:null},form_snapshot:{[this.db.Op.ne]:null},
ali_code:{[this.db.Op.ne]:''},templatelink_snapshot:{[this.db.Op.ne]:null},
record_content:{[this.db.Op.ne]:null}
},
limit:limit,
order:[["id","asc"]],
raw:true
});
var recordList = await this.packageRecordList(formRecords);
for(var a=0;a<recordList.length;a++){
var pushRes = await this.fqUtilsSve.pushNeedInfo2Fq(recordList[a],recordList[a].code);
console.log(pushRes,"pushRes############################3");
if(pushRes && pushRes.data && pushRes.data=="success"){//推送成功
await this.dao.update({id:recordList[a].id,push_status:1});
}else{
await this.dao.update({id:recordList[a].id,push_status:2});
}
}
}
//封装表单记录信息
async packageRecordList(formRecords){
var recordList=[];
for(var i=0;i<formRecords.length;i++){
var fr = formRecords[i];
var rc = fr.record_content;
var linkinfo = fr.templatelink_snapshot;
var forminfo = fr.form_snapshot;
if(forminfo && forminfo.form_table && forminfo.form_table.main && forminfo.form_table.main[0] && forminfo.form_table.main[0].ctls ){
var ctls = forminfo.form_table.main[0].ctls;
var pushInfo = {
id:fr.id,
customer_name:rc.contact_name,customer_phone:rc.contact_mobile,source:"marketplat",
source_type:linkinfo.name || "未知",code:fr.ali_code
};
var advisory_content="";
for(var j=0;j<ctls.length;j++){
var ctl = ctls[j];
if(ctl.label && ctl.prop && rc[ctl.prop]){
advisory_content = advisory_content+ctl.label+":"+rc[ctl.prop]+";"
}
}
pushInfo["advisory_content"] = advisory_content || "未知";
recordList.push(pushInfo);
}
}
return recordList;
}
}
module.exports = FormsubmitrecordService;
\ No newline at end of file
......@@ -29,5 +29,24 @@ class LogClient {
}
}
async pushlog(title,params,rtninfo,errinfo) {
try {
rtninfo.requestId = this.getUUID();
//第三个字段应该存公司id
system.execLogs(title,params,"gsb-marketplat",rtninfo, errinfo).then(res => {
if (res && res.status == 1) {
console.log("log.....success")
} else {
console.log("log.....fail")
}
}).catch(e => {
console.log("log.....fail")
})
} catch (error) {
console.log(error);
}
}
}
module.exports = LogClient;
[data-v-1044d171] .ivu-input,[data-v-1044d171] .ivu-input-group-append{height:40px;border-radius:0;border-color:transparent;background:transparent}[data-v-1044d171] .ivu-input-group-append .ivu-btn,[data-v-1044d171] .ivu-input .ivu-btn{height:40px}[data-v-1044d171] .ivu-input-group-prepend{display:none}.form-footer{width:70%;position:fixed;bottom:0;right:0;border-top:1px solid #e8e8e8;padding:10px 16px;text-align:right;background:#fff}
\ No newline at end of file
[data-v-495a4b54] .ivu-input,[data-v-495a4b54] .ivu-input-group-append{height:40px;border-radius:0;border-color:transparent;background:transparent}[data-v-495a4b54] .ivu-input-group-append .ivu-btn,[data-v-495a4b54] .ivu-input .ivu-btn{height:40px}[data-v-495a4b54] .ivu-input-group-prepend{display:none}.form-footer{width:70%;position:fixed;bottom:0;right:0;border-top:1px solid #e8e8e8;padding:10px 16px;text-align:right;background:#fff}
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/ccc.png><link rel=stylesheet href=//at.alicdn.com/t/font_1996389_21r6b2e5cqci.css><title></title><link href=/css/chunk-0f609be6.0194931c.css rel=prefetch><link href=/css/chunk-0fb760a4.5c30cb40.css rel=prefetch><link href=/css/chunk-14b9857b.0dc416de.css rel=prefetch><link href=/css/chunk-2c359864.0dc416de.css rel=prefetch><link href=/css/chunk-3385141a.0dc416de.css rel=prefetch><link href=/css/chunk-3cca9940.6014cc43.css rel=prefetch><link href=/css/chunk-60962e1f.73690a1f.css rel=prefetch><link href=/css/chunk-6feb7ee6.c24e44b5.css rel=prefetch><link href=/css/chunk-7e6a0141.971f439c.css rel=prefetch><link href=/css/chunk-c2e406ea.2a62fa9e.css rel=prefetch><link href=/css/chunk-cc77621c.8797b2b5.css rel=prefetch><link href=/js/chunk-0f609be6.545e515d.js rel=prefetch><link href=/js/chunk-0fb760a4.56bf0a09.js rel=prefetch><link href=/js/chunk-14b9857b.ae43b7c1.js rel=prefetch><link href=/js/chunk-1f11ec07.766ad876.js rel=prefetch><link href=/js/chunk-2c359864.f1f45686.js rel=prefetch><link href=/js/chunk-2d210f61.9e612a95.js rel=prefetch><link href=/js/chunk-3385141a.16d7705b.js rel=prefetch><link href=/js/chunk-3cca9940.f6b28725.js rel=prefetch><link href=/js/chunk-5a4e13d5.6ebd883c.js rel=prefetch><link href=/js/chunk-60962e1f.166552bd.js rel=prefetch><link href=/js/chunk-6feb7ee6.9d37210b.js rel=prefetch><link href=/js/chunk-780401d4.2594e2ad.js rel=prefetch><link href=/js/chunk-7e6a0141.ea0fb0ef.js rel=prefetch><link href=/js/chunk-c2e406ea.de958dcc.js rel=prefetch><link href=/js/chunk-cc77621c.209c3f4a.js rel=prefetch><link href=/js/chunk-d710b6d2.9eff4b27.js rel=prefetch><link href=/css/app.a0c5a847.css rel=preload as=style><link href=/css/chunk-vendors.a0428467.css rel=preload as=style><link href=/js/app.0b2c2afc.js rel=preload as=script><link href=/js/chunk-vendors.ca1af405.js rel=preload as=script><link href=/css/chunk-vendors.a0428467.css rel=stylesheet><link href=/css/app.a0c5a847.css rel=stylesheet></head><body><noscript><strong>We're sorry but iview-admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ca1af405.js></script><script src=/js/app.0b2c2afc.js></script></body></html>
\ No newline at end of file
<!DOCTYPE html><html><head><meta charset=utf-8><meta http-equiv=X-UA-Compatible content="IE=edge"><meta name=viewport content="width=device-width,initial-scale=1"><link rel=icon href=/ccc.png><link rel=stylesheet href=//at.alicdn.com/t/font_1996389_21r6b2e5cqci.css><title></title><link href=/css/chunk-06b6ea4a.41c5bd35.css rel=prefetch><link href=/css/chunk-0fb760a4.5c30cb40.css rel=prefetch><link href=/css/chunk-14b9857b.0dc416de.css rel=prefetch><link href=/css/chunk-2c359864.0dc416de.css rel=prefetch><link href=/css/chunk-3385141a.0dc416de.css rel=prefetch><link href=/css/chunk-3cca9940.6014cc43.css rel=prefetch><link href=/css/chunk-60962e1f.73690a1f.css rel=prefetch><link href=/css/chunk-6feb7ee6.c24e44b5.css rel=prefetch><link href=/css/chunk-70803511.55f9f276.css rel=prefetch><link href=/css/chunk-7e6a0141.971f439c.css rel=prefetch><link href=/css/chunk-cc77621c.8797b2b5.css rel=prefetch><link href=/js/chunk-06b6ea4a.2eaa3090.js rel=prefetch><link href=/js/chunk-0fb760a4.56bf0a09.js rel=prefetch><link href=/js/chunk-14b9857b.ae43b7c1.js rel=prefetch><link href=/js/chunk-1f11ec07.766ad876.js rel=prefetch><link href=/js/chunk-2c359864.f1f45686.js rel=prefetch><link href=/js/chunk-2d210f61.9e612a95.js rel=prefetch><link href=/js/chunk-3385141a.16d7705b.js rel=prefetch><link href=/js/chunk-3cca9940.f6b28725.js rel=prefetch><link href=/js/chunk-5a4e13d5.6ebd883c.js rel=prefetch><link href=/js/chunk-60962e1f.166552bd.js rel=prefetch><link href=/js/chunk-6feb7ee6.9d37210b.js rel=prefetch><link href=/js/chunk-70803511.12c17b86.js rel=prefetch><link href=/js/chunk-780401d4.2594e2ad.js rel=prefetch><link href=/js/chunk-7e6a0141.ea0fb0ef.js rel=prefetch><link href=/js/chunk-cc77621c.209c3f4a.js rel=prefetch><link href=/js/chunk-d710b6d2.9eff4b27.js rel=prefetch><link href=/css/app.a0c5a847.css rel=preload as=style><link href=/css/chunk-vendors.a0428467.css rel=preload as=style><link href=/js/app.ca92d6c7.js rel=preload as=script><link href=/js/chunk-vendors.ca1af405.js rel=preload as=script><link href=/css/chunk-vendors.a0428467.css rel=stylesheet><link href=/css/app.a0c5a847.css rel=stylesheet></head><body><noscript><strong>We're sorry but iview-admin doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript><div id=app></div><script src=/js/chunk-vendors.ca1af405.js></script><script src=/js/app.ca92d6c7.js></script></body></html>
\ No newline at end of file
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