Commit 48f04948 by 庄冰

同步代码

parent bebf1fa0
...@@ -12,6 +12,7 @@ class Template extends APIBase { ...@@ -12,6 +12,7 @@ class Template extends APIBase {
this.formsubmitrecordSve= system.getObject("service.configmag.formsubmitrecordSve"); this.formsubmitrecordSve= system.getObject("service.configmag.formsubmitrecordSve");
this.forminfoSve= system.getObject("service.configmag.forminfoSve"); this.forminfoSve= system.getObject("service.configmag.forminfoSve");
this.redisClient = system.getObject("util.redisClient"); this.redisClient = system.getObject("util.redisClient");
this.formCache={};
} }
/** /**
* 接口跳转-POST请求 * 接口跳转-POST请求
...@@ -46,6 +47,9 @@ class Template extends APIBase { ...@@ -46,6 +47,9 @@ class Template extends APIBase {
case "submitFormRecord"://提交表单记录 case "submitFormRecord"://提交表单记录
opResult = await this.formsubmitrecordSve.submitFormRecord(pobj); opResult = await this.formsubmitrecordSve.submitFormRecord(pobj);
break; break;
case "pushFormInfo2Fq"://推送需求表单信息至蜂擎
opResult = await this.formsubmitrecordSve.pushFormInfo2Fq();
break;
default: default:
opResult = system.getResult(null, "action_type参数错误"); opResult = system.getResult(null, "action_type参数错误");
break; break;
...@@ -55,7 +59,16 @@ class Template extends APIBase { ...@@ -55,7 +59,16 @@ class Template extends APIBase {
async getFormInfoById(pobj, qobj, req){ async getFormInfoById(pobj, qobj, req){
var shaStr = "forminfo_"+pobj.id; var shaStr = "forminfo_"+pobj.id;
var rtn = await this.redisClient.get(shaStr); // 先试图从redis读取数据 var rtn = null;
console.log(this.formCache,"+++++++++++++getFormInfoById++++++++++++++++++++++");
if(this.formCache[shaStr]){
rtn = this.formCache[shaStr];
}else{
rtn = await this.redisClient.get(shaStr); // 先试图从redis读取数据
if(rtn){
this.formCache[shaStr] = rtn;
}
}
//---- 从redis中读取到数据 //---- 从redis中读取到数据
if (rtn) { if (rtn) {
var rtnObj = JSON.parse(rtn); var rtnObj = JSON.parse(rtn);
...@@ -64,9 +77,15 @@ class Template extends APIBase { ...@@ -64,9 +77,15 @@ class Template extends APIBase {
let result = await this.forminfoSve.findOne({id:pobj.id},[]); let result = await this.forminfoSve.findOne({id:pobj.id},[]);
// 将数据保存到redis中 // 将数据保存到redis中
await this.redisClient.set(shaStr, JSON.stringify(result)); await this.redisClient.set(shaStr, JSON.stringify(result));
this.formCache[shaStr] = JSON.stringify(result);
return system.getResult(result); return system.getResult(result);
}
}
//删除表单缓存
async delTemplateFormCache(key){
if(key && this.formCache[key]){
delete this.formCache[key];
} }
} }
} }
module.exports = Template; module.exports = Template;
...@@ -20,6 +20,8 @@ module.exports = (db, DataTypes) => { ...@@ -20,6 +20,8 @@ module.exports = (db, DataTypes) => {
}, },
record_status_name: DataTypes.STRING(60),//记录状态名称 record_status_name: DataTypes.STRING(60),//记录状态名称
templatelink_snapshot:DataTypes.JSON,//模板链接快照 templatelink_snapshot:DataTypes.JSON,//模板链接快照
form_snapshot:DataTypes.JSON,//表单快照
ali_code:DataTypes.STRING,
record_content:DataTypes.JSON,//记录内容 record_content:DataTypes.JSON,//记录内容
push_status:DataTypes.INTEGER,//推送状态 0:未推送,1:已推送 2:异常 push_status:DataTypes.INTEGER,//推送状态 0:未推送,1:已推送 2:异常
op_notes:DataTypes.STRING,//操作备注 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
...@@ -130,6 +130,7 @@ class ForminfoService extends ServiceBase { ...@@ -130,6 +130,7 @@ class ForminfoService extends ServiceBase {
let result = await this.updateByWhere(upData,{id:pobj.id}) let result = await this.updateByWhere(upData,{id:pobj.id})
var shaStr = "forminfo_"+pobj.id; var shaStr = "forminfo_"+pobj.id;
await this.redisClient.delete(shaStr); await this.redisClient.delete(shaStr);
await this.redisClient.publish("delTemplateFormCache",shaStr);
return system.getResult(result); return system.getResult(result);
} }
...@@ -149,8 +150,10 @@ class ForminfoService extends ServiceBase { ...@@ -149,8 +150,10 @@ class ForminfoService extends ServiceBase {
items.forEach(async (item) =>{ items.forEach(async (item) =>{
delete item.dataValues.id; delete item.dataValues.id;
delete item.dataValues.created_at; delete item.dataValues.created_at;
let iCode = await this.getBusUid('it'); if(item.code!="contact_name" && item.code!="contact_mobile"){
item.code = iCode; let iCode = await this.getBusUid('it');
item.code = iCode;
}
item.form_id = saveRt.id item.form_id = saveRt.id
this.formitemDao.create(item.dataValues); this.formitemDao.create(item.dataValues);
}) })
......
...@@ -9,6 +9,7 @@ class FormsubmitrecordService extends ServiceBase { ...@@ -9,6 +9,7 @@ class FormsubmitrecordService extends ServiceBase {
this.templatelinkDao = system.getObject("db.template.templatelinkDao"); this.templatelinkDao = system.getObject("db.template.templatelinkDao");
this.forminfoDao = system.getObject("db.configmag.forminfoDao"); this.forminfoDao = system.getObject("db.configmag.forminfoDao");
this.formitemDao = system.getObject("db.configmag.formitemDao"); this.formitemDao = system.getObject("db.configmag.formitemDao");
this.fqUtilsSve = system.getObject("service.common.fqUtilsSve");
} }
/** /**
...@@ -27,6 +28,9 @@ class FormsubmitrecordService extends ServiceBase { ...@@ -27,6 +28,9 @@ class FormsubmitrecordService extends ServiceBase {
if(!ab.form_id){ if(!ab.form_id){
return system.getResultFail(-102,"表单id不能为空"); return system.getResultFail(-102,"表单id不能为空");
} }
if(!ab.ali_code){
return system.getResultFail(-103,"校验编码不能为空");
}
//获取模板链接信息 //获取模板链接信息
var linkInfo = await this.templatelinkDao.model.findOne({ var linkInfo = await this.templatelinkDao.model.findOne({
where:{code:ab.link_code},raw:true where:{code:ab.link_code},raw:true
...@@ -62,15 +66,16 @@ class FormsubmitrecordService extends ServiceBase { ...@@ -62,15 +66,16 @@ class FormsubmitrecordService extends ServiceBase {
} }
var params = res; var params = res;
var addObj={ var addObj={
ali_code:ab.ali_code,
template_id:linkInfo.template_id,templatelink_id:linkInfo.id, template_id:linkInfo.template_id,templatelink_id:linkInfo.id,
form_id:forminfo.id,record_status:1,templatelink_snapshot:linkInfo, 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, record_content:params,business_code:templateinfo.business_code,
push_status:0 push_status:0
} }
if(ab.push_status==1){ // if(ab.push_status==1){
addObj.push_status=1; // addObj.push_status=1;
} // }
await this.dao.create(addObj);//创建记录 await this.dao.create(addObj);//创建记录
return system.getResultSuccess(); return system.getResultSuccess();
} }
...@@ -111,6 +116,63 @@ class FormsubmitrecordService extends ServiceBase { ...@@ -111,6 +116,63 @@ class FormsubmitrecordService extends ServiceBase {
} }
return params; 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; module.exports = FormsubmitrecordService;
\ No newline at end of file
...@@ -29,5 +29,24 @@ class LogClient { ...@@ -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; module.exports = LogClient;
...@@ -63,8 +63,13 @@ class RedisClient { ...@@ -63,8 +63,13 @@ class RedisClient {
var tempLinkSve = system.getObject("service.template.templatelinkSve"); var tempLinkSve = system.getObject("service.template.templatelinkSve");
await tempLinkSve.clearTemplateLinkInfoCache(message); await tempLinkSve.clearTemplateLinkInfoCache(message);
} }
if(channel=="delTemplateFormCache" && message ){
var template = system.getObject("api.action.template");
await template.delTemplateFormCache(message);
}
}); });
this.subscribe("delTemplateCache",null); this.subscribe("delTemplateCache",null);
this.subscribe("delTemplateFormCache",null);
} }
async subscribe(channel, chatserver) { async subscribe(channel, chatserver) {
......
...@@ -16,7 +16,7 @@ var settings = { ...@@ -16,7 +16,7 @@ var settings = {
salt: "%iatpD1gcxz7iF#B", salt: "%iatpD1gcxz7iF#B",
defaultpwd: "gsb2020", defaultpwd: "gsb2020",
basepath: path.normalize(path.join(__dirname, '../..')), basepath: path.normalize(path.join(__dirname, '../..')),
port: process.env.NODE_PORT || 8002, port: process.env.NODE_PORT || 8003,
logindex: "center_manage", logindex: "center_manage",
appname: "gsb_marketplat", appname: "gsb_marketplat",
kongurl: function () { if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.kongurl; } else { return ENVINPUT.KONG_ADMIAN; } }, kongurl: function () { if (this.env == "dev") { var localsettings = require("./localsettings"); return localsettings.kongurl; } else { return ENVINPUT.KONG_ADMIAN; } },
......
[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-0014cc2a.245d6048.css rel=prefetch><link href=/css/chunk-0fb760a4.5c30cb40.css rel=prefetch><link href=/css/chunk-13b3d2d2.23496209.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-c2e406ea.2a62fa9e.css rel=prefetch><link href=/css/chunk-cc77621c.8797b2b5.css rel=prefetch><link href=/js/chunk-0014cc2a.915108c9.js rel=prefetch><link href=/js/chunk-0fb760a4.56bf0a09.js rel=prefetch><link href=/js/chunk-13b3d2d2.142b3257.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-c2e406ea.1241e966.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.37a00d86.js rel=preload as=script><link href=/js/chunk-vendors.4f6ffd43.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.4f6ffd43.js></script><script src=/js/app.37a00d86.js></script></body></html> <!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-43de808c.513a3016.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-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-43de808c.6c659714.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-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.c02f30cb.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.c02f30cb.js></script></body></html>
\ No newline at end of file \ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
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