Commit 02d00cd6 by 王栋源

wdy

parent ec80560a
...@@ -10,7 +10,8 @@ class TmtransactionApi extends ApiBase { ...@@ -10,7 +10,8 @@ class TmtransactionApi extends ApiBase {
this.utilstmtasktradeSve = System.getObject("service.utilstmtasktradeSve"); this.utilstmtasktradeSve = System.getObject("service.utilstmtasktradeSve");
this.pytmreportSve = System.getObject("service.pytmreportSve"); this.pytmreportSve = System.getObject("service.pytmreportSve");
this.mailClient = System.getObject("util.mailClient"); this.mailClient = System.getObject("util.mailClient");
this.redisClient=System.getObject("util.redisClient"); this.redisClient = System.getObject("util.redisClient");
this.execClient = System.getObject("util.execClient");
}; };
//获取某类型的交易商标 post //获取某类型的交易商标 post
async findByTmType(obj) { async findByTmType(obj) {
...@@ -50,13 +51,20 @@ class TmtransactionApi extends ApiBase { ...@@ -50,13 +51,20 @@ class TmtransactionApi extends ApiBase {
async tmreport() { async tmreport() {
var id = await this.redisClient.lpop("create_tmrepotCache"); var id = await this.redisClient.lpop("create_repotCache");
console.log(id, "商标检索报告执行开始................."); console.log(id, "商标检索报告执行开始.................");
if (id) { if (id) {
var info = await this.pytmreportSve.dao.findById(id); var info = await this.pytmreportSve.dao.findById(id);
console.log(info.dataValues); console.log(info.dataValues);
if (info) { if (info) {
var url = "http://43.247.184.92:8015/tmdoc/api/createdoc?mycompanyname=" + encodeURIComponent(info.companyname); var cpush = "";
if (info.push_type == 1) {
cpush = "http://43.247.184.92:8015/tmdoc/api/createdoc?mycompanyname=";
}
if (info.push_type == 2) {
cpush = "http://43.247.184.94:19500/patentdoc/api/createdoc?mycompanyname=";
}
var url = cpush + encodeURIComponent(info.companyname);
var rc = System.getObject("util.execClient"); var rc = System.getObject("util.execClient");
var rtn = null; var rtn = null;
try { try {
...@@ -66,26 +74,41 @@ class TmtransactionApi extends ApiBase { ...@@ -66,26 +74,41 @@ class TmtransactionApi extends ApiBase {
// console.log("fanhui"); // console.log("fanhui");
console.log(j); console.log(j);
if (j.indexOf("gsb-zc.oss-cn-beijing.aliyuncs.com") >= 0) { if (j.indexOf("gsb-zc.oss-cn-beijing.aliyuncs.com") >= 0) {
var text = "企业监控报告"; if (info.push_type == 1) {
var html = '<a href="' + j + '">企业监控报告</a>' if (info.type == 1) {
var mresult = this.mailClient.sendMsg(info.email, "企业监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom var html = '<a href="' + j + '">企业商标监控报告</a>'
this.mailClient.sendMsg(info.email, "企业商标监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom
}
if (info.type == 2) {
var html = '<a href="' + j + '">企业专利监控报告</a>'
this.mailClient.sendMsg(info.email, "企业专利监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom
}
}
if (info.push_type == 2) {
var pobj = {
fid: info.wxuser_id,
title: info.companyname,
linkUrl: j
}
var rtn = await this.execClient.execPost(pobj, info.notifyUrl);
} }
info.dataValues.filepath = j; info.dataValues.filepath = j;
info.dataValues.status = 1; info.dataValues.status = 1;
var result = await this.pytmreportSve.dao.model.update(info.dataValues, { where: { id: id } }); var result = await this.pytmreportSve.dao.model.update(info.dataValues, { where: { id: id } });
logCtl.info({ logCtl.info({
optitle: "商标检索报告执行结果", optitle: "检索报告执行结果",
op: "/igirl-web/app/base/db/task/CreatetmrepotTask.js", op: "/igirl-web/app/base/db/task/CreaterepotTask.js",
content: "id=" + id + "执行结果:" + j, content: "id=" + id + "执行结果:" + j,
clientIp: "" clientIp: ""
}); });
return result; return result;
}
} catch (e) { } catch (e) {
console.log(e); console.log(e);
//日志记录 //日志记录
logCtl.error({ logCtl.error({
optitle: "商标检索报告执行结果-error", optitle: "检索报告执行结果-error",
op: "/igirl-web/app/base/db/task/CreatetmrepotTask.js", op: "/igirl-web/app/base/db/task/CreaterepotTask.js",
content: e.stack, content: e.stack,
clientIp: "" clientIp: ""
}); });
......
...@@ -18,10 +18,11 @@ class ToolCtl { ...@@ -18,10 +18,11 @@ class ToolCtl {
this.cacheManager = System.getObject("db.cacheManager"); this.cacheManager = System.getObject("db.cacheManager");
this.appKeyStr = "wx76a324c5d201d1a4"; this.appKeyStr = "wx76a324c5d201d1a4";
this.mailClient = System.getObject("util.mailClient"); this.mailClient = System.getObject("util.mailClient");
this.redisClient=System.getObject("util.redisClient"); this.redisClient = System.getObject("util.redisClient");
this.pytmreportSve = System.getObject("service.pytmreportSve"); this.pytmreportSve = System.getObject("service.pytmreportSve");
this.companySve = System.getObject("service.companySve"); this.companySve = System.getObject("service.companySve");
this.wxuserSve = System.getObject("service.wxuserSve"); this.wxuserSve = System.getObject("service.wxuserSve");
this.execClient = System.getObject("util.execClient");
} }
async getUidStr(len, radix) { async getUidStr(len, radix) {
var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split(''); var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'.split('');
...@@ -410,197 +411,205 @@ class ToolCtl { ...@@ -410,197 +411,205 @@ class ToolCtl {
} }
//生成企业监控报告 //生成企业监控报告
async createMonitoringReport(obj){ async createMonitoringReport(obj) {
var mycompanyname = obj.companyname; var mycompanyname = obj.companyname;
var email = obj.email; var email = obj.email;
if(!mycompanyname){ if (!mycompanyname) {
return {code:-1,msg:"企业名称参数错误"}; return { code: -1, msg: "企业名称参数错误" };
} }
mycompanyname= await this.getConvertSemiangleStr(mycompanyname); mycompanyname = await this.getConvertSemiangleStr(mycompanyname);
if(!email){ if (!email) {
return {code:-2,msg:"邮箱参数错误"}; return { code: -2, msg: "邮箱参数错误" };
} }
var url = "http://43.247.184.92:8015/tmdoc/api/createdoc?mycompanyname="+encodeURIComponent(mycompanyname); var url = "http://43.247.184.92:8015/tmdoc/api/createdoc?mycompanyname=" + encodeURIComponent(mycompanyname);
var rc = System.getObject("util.execClient"); var rc = System.getObject("util.execClient");
var rtn = null; var rtn = null;
try { try {
rc.execGet({}, url).then(rtn=>{ rc.execGet({}, url).then(rtn => {
var j = rtn.stdout; var j = rtn.stdout;
console.log("fanhui"); console.log("fanhui");
console.log(j); console.log(j);
if(j.indexOf("gsb-zc.oss-cn-beijing.aliyuncs.com")>=0){ if (j.indexOf("gsb-zc.oss-cn-beijing.aliyuncs.com") >= 0) {
var text="企业监控报告"; var text = "企业监控报告";
var html = '<a href="'+j+'">企业监控报告</a>' var html = '<a href="' + j + '">企业监控报告</a>'
var result = this.mailClient.sendMsg(email, "企业监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom var result = this.mailClient.sendMsg(email, "企业监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom
} }
}) })
return {code:1}; return { code: 1 };
} catch (e) { } catch (e) {
console.log(e); console.log(e);
return {code:-200,msg:"操作失败"}; return { code: -200, msg: "操作失败" };
} }
} }
//生成企业监控报告-h5 //生成企业监控报告-h5
async createMonitoringReportH5(obj,p,r){ async createMonitoringReportH5(obj, p, r) {
var key="create_tmrepotCache" var key = "create_repotCache";
if(!obj.companyname){ if (!obj.companyname) {
return {code:-1,msg:"企业名称参数错误"}; return { code: -1, msg: "企业名称参数错误" };
} }
if(!obj.email){ if (!obj.email) {
return {code:-2,msg:"邮箱参数错误"}; return { code: -2, msg: "邮箱参数错误" };
} }
obj.companyname= await this.getConvertSemiangleStr(obj.companyname); obj.companyname = await this.getConvertSemiangleStr(obj.companyname);
var source={ var source = {
companyname:obj.companyname, companyname: obj.companyname,
phonenum:obj.phonenum, phonenum: obj.phonenum,
email:obj.email, email: obj.email,
type:1 type: 1
} }
if(obj.entcode){ if (obj.entcode) {
var ent = await this.companySve.dao.model.findOne({where:{code:obj.entcode,isEnabled:1},raw:true}); var ent = await this.companySve.dao.model.findOne({ where: { code: obj.entcode, isEnabled: 1 }, raw: true });
if(ent){ if (ent) {
source["channel_company_id"]=ent.id; source["channel_company_id"] = ent.id;
if(obj.wxuser_id){ if (obj.wxuser_id) {
source["wxuser_id"]=obj.wxuser_id; source["wxuser_id"] = obj.wxuser_id;
} }
} }
} }
logCtl.info({ logCtl.info({
optitle: "生成企业监控报告-h5", optitle: "生成企业监控报告-h5",
op: "tooCtl/createMonitoringReportH5", op: "tooCtl/createMonitoringReportH5",
content: JSON.stringify(obj)+"---------------"+JSON.stringify(source), content: JSON.stringify(obj) + "---------------" + JSON.stringify(source),
clientIp: "" clientIp: ""
}); });
var search={companyname:obj.companyname,status:1,type:1}; var search = { companyname: obj.companyname, status: 1, type: 1 };
var info=await this.pytmreportSve.findOne(search); var info = await this.pytmreportSve.findOne(search);
if(info){ if (info) {
var html = '<a href="'+info.filepath+'">企业监控报告</a>' var html = '<a href="' + info.filepath + '">企业商标监控报告</a>'
var result = await this.mailClient.sendMsg(obj.email, "企业监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom var result = await this.mailClient.sendMsg(obj.email, "企业商标监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom
source.filepath=info.filepath; source.filepath = info.filepath;
source.status=1; source.status = 1;
await this.pytmreportSve.create(source); await this.pytmreportSve.create(source);
return {code:1}; return { code: 1 };
}else{ } else {
var result=await this.pytmreportSve.create(source); var result = await this.pytmreportSve.create(source);
if(result){ if (result) {
this.redisClient.rpush(key,result.id); this.redisClient.rpush(key, result.id);
} }
return {code:1}; return { code: 1 };
} }
} }
//生成企业监控报告-h5 post //生成企业监控报告-h5 post
async createMonitoringReportH5p(pobj,obj,r){ async createMonitoringReportH5p(pobj, obj, r) {
var key="create_tmrepotCache" var key = "create_repotCache"
if(!obj.companyname){ if (!obj.companyname) {
return {code:-1,msg:"企业名称参数错误"}; return { code: -1, msg: "企业名称参数错误" };
} }
if(!obj.email){ obj.companyname = await this.getConvertSemiangleStr(obj.companyname);
return {code:-2,msg:"邮箱参数错误"}; var source = {
} wxuser_id: obj.wxuser_id,
obj.companyname= await this.getConvertSemiangleStr(obj.companyname); companyname: obj.companyname,
var source={ phonenum: obj.phonenum,
companyname:obj.companyname, email: obj.email,
phonenum:obj.phonenum, notifyUrl: obj.notifyUrl,
email:obj.email, source: obj.appid,
type:1 push_type:obj.push_type,
} type: obj.type
if(obj.entcode){
var ent = await this.companySve.dao.model.findOne({where:{code:obj.entcode,isEnabled:1},raw:true});
if(ent){
source["channel_company_id"]=ent.id;
if(obj.wxuser_id){
source["wxuser_id"]=obj.wxuser_id;
}
}
} }
logCtl.info({ logCtl.info({
optitle: "生成企业监控报告-h5", optitle: "生成企业监控报告-h5",
op: "tooCtl/createMonitoringReportH5", op: "tooCtl/createMonitoringReportH5",
content: JSON.stringify(obj)+"---------------"+JSON.stringify(source), content: JSON.stringify(obj) + "---------------" + JSON.stringify(source),
clientIp: "" clientIp: ""
}); });
var search={companyname:obj.companyname,status:1,type:1}; var search = { companyname: obj.companyname, status: 1, type: obj.type };
var info=await this.pytmreportSve.findOne(search); var info = await this.pytmreportSve.findOne(search);
if(info){ if (info) {
var html = '<a href="'+info.filepath+'">企业监控报告</a>' if (obj.push_type == 1) {
var result = await this.mailClient.sendMsg(obj.email, "企业监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom if (obj.type == 1) {
source.filepath=info.filepath; var html = '<a href="' + info.filepath + '">企业商标监控报告</a>'
source.status=1; this.mailClient.sendMsg(info.email, "企业商标监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom
}
if (obj.type == 2) {
var html = '<a href="' + info.filepath + '">企业专利监控报告</a>'
this.mailClient.sendMsg(info.email, "企业专利监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom
}
}
if (obj.push_type == 2) {
var pobj = {
fid: obj.wxuser_id,
title: obj.companyname,
linkUrl: info.filepath
}
var rtn = await this.execClient.execPost(pobj, obj.notifyUrl);
}
source.filepath = info.filepath;
source.status = 1;
await this.pytmreportSve.create(source); await this.pytmreportSve.create(source);
return {code:1}; return { code: 1 };
}else{ } else {
var result=await this.pytmreportSve.create(source); var result = await this.pytmreportSve.create(source);
if(result){ if (result) {
this.redisClient.rpush(key,result.id); this.redisClient.rpush(key, result.id);
} }
return {code:1}; return { code: 1 };
} }
} }
//生成企业专利监控报告-h5 //生成企业专利监控报告-h5
async createPatentReportH5(obj){ async createPatentReportH5(obj) {
var key="create_patentrepotCache" var key = "create_patentrepotCache"
if(!obj.companyname){ if (!obj.companyname) {
return {code:-1,msg:"企业名称参数错误"}; return { code: -1, msg: "企业名称参数错误" };
} }
if(!obj.email){ if (!obj.email) {
return {code:-2,msg:"邮箱参数错误"}; return { code: -2, msg: "邮箱参数错误" };
} }
obj.companyname= await this.getConvertSemiangleStr(obj.companyname); obj.companyname = await this.getConvertSemiangleStr(obj.companyname);
var source={ var source = {
companyname:obj.companyname, companyname: obj.companyname,
phonenum:obj.phonenum, phonenum: obj.phonenum,
email:obj.email, email: obj.email,
type:2 type: 2
} }
if(obj.entcode){ if (obj.entcode) {
var ent = await this.companySve.dao.model.findOne({where:{code:obj.entcode,isEnabled:1},raw:true}); var ent = await this.companySve.dao.model.findOne({ where: { code: obj.entcode, isEnabled: 1 }, raw: true });
if(ent){ if (ent) {
source["channel_company_id"]=ent.id; source["channel_company_id"] = ent.id;
if(obj.wxuser_id){ if (obj.wxuser_id) {
source["wxuser_id"]=obj.wxuser_id; source["wxuser_id"] = obj.wxuser_id;
} }
} }
} }
logCtl.info({ logCtl.info({
optitle: "生成企业专利监控报告-h5", optitle: "生成企业专利监控报告-h5",
op: "tooCtl/createPatentReportH5", op: "tooCtl/createPatentReportH5",
content: JSON.stringify(obj)+"---------------"+JSON.stringify(source), content: JSON.stringify(obj) + "---------------" + JSON.stringify(source),
clientIp: "" clientIp: ""
}); });
var search={companyname:obj.companyname,status:1,type:2}; var search = { companyname: obj.companyname, status: 1, type: 2 };
var info=await this.pytmreportSve.findOne(search); var info = await this.pytmreportSve.findOne(search);
if(info){ if (info) {
var html = '<a href="'+info.filepath+'">企业专利监控报告</a>' var html = '<a href="' + info.filepath + '">企业专利监控报告</a>'
var result = await this.mailClient.sendMsg(obj.email, "企业专利监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom var result = await this.mailClient.sendMsg(obj.email, "企业专利监控报告", null, html, null, null, []); //发送成功后result的值:250 Data Ok: queued as freedom
source.filepath=info.filepath; source.filepath = info.filepath;
source.status=1; source.status = 1;
await this.pytmreportSve.create(source); await this.pytmreportSve.create(source);
return {code:1}; return { code: 1 };
}else{ } else {
var result=await this.pytmreportSve.create(source); var result = await this.pytmreportSve.create(source);
if(result){ if (result) {
this.redisClient.rpush(key,result.id); this.redisClient.rpush(key, result.id);
} }
return {code:1}; return { code: 1 };
} }
} }
//获取渠道企业商标报告统计信息 //获取渠道企业商标报告统计信息
async getChannelMonitoringReportStatistic(obj){ async getChannelMonitoringReportStatistic(obj) {
var entcode = obj.entcode; var entcode = obj.entcode;
if(!entcode){ if (!entcode) {
return {code:-1,msg:"渠道码参数错误"}; return { code: -1, msg: "渠道码参数错误" };
} }
try { try {
var ent = await this.companySve.dao.model.findOne({where:{code:obj.entcode,isEnabled:1},raw:true}); var ent = await this.companySve.dao.model.findOne({ where: { code: obj.entcode, isEnabled: 1 }, raw: true });
if(!ent && ent.id){ if (!ent && ent.id) {
return {code:-1,msg:"渠道公司不存在"}; return { code: -1, msg: "渠道公司不存在" };
} }
// var datalist = await this.pytmreportSve.dao.model.findAll({ // var datalist = await this.pytmreportSve.dao.model.findAll({
// where:{channel_company_id:ent.id}, // where:{channel_company_id:ent.id},
...@@ -611,19 +620,19 @@ class ToolCtl { ...@@ -611,19 +620,19 @@ class ToolCtl {
// }], // }],
// raw:true // raw:true
// }); // });
var sql = "SELECT tmreport.id AS tmreport_id, companyname, filepath, phonenum, email, channel_company_id, wxuser_id, openid, nick_name, head_img "+ var sql = "SELECT tmreport.id AS tmreport_id, companyname, filepath, phonenum, email, channel_company_id, wxuser_id, openid, nick_name, head_img " +
"FROM "+ "FROM " +
"( "+ "( " +
"SELECT id, companyname, filepath, phonenum, email, channel_company_id, wxuser_id FROM `py_tmreport` "+ "SELECT id, companyname, filepath, phonenum, email, channel_company_id, wxuser_id FROM `py_tmreport` " +
"WHERE deleted_at IS NULL AND channel_company_id IS NOT NULL and channel_company_id="+ent.id+ "WHERE deleted_at IS NULL AND channel_company_id IS NOT NULL and channel_company_id=" + ent.id +
" ) AS tmreport "+ " ) AS tmreport " +
"LEFT JOIN ( "+ "LEFT JOIN ( " +
"SELECT id, openid, nick_name, head_img FROM wx_user WHERE deleted_at IS NULL "+ "SELECT id, openid, nick_name, head_img FROM wx_user WHERE deleted_at IS NULL " +
") AS wxuser ON wxuser.id = tmreport.wxuser_id"; ") AS wxuser ON wxuser.id = tmreport.wxuser_id";
var tmpResult = await this.pytmreportSve.dao.customQuery(sql); var tmpResult = await this.pytmreportSve.dao.customQuery(sql);
return {code:1,data:tmpResult}; return { code: 1, data: tmpResult };
} catch (e) { } catch (e) {
return {code:-100,msg:"操作失败",err:e.stack}; return { code: -100, msg: "操作失败", err: e.stack };
} }
......
...@@ -4,11 +4,14 @@ module.exports = (db, DataTypes) => { ...@@ -4,11 +4,14 @@ module.exports = (db, DataTypes) => {
filepath: DataTypes.STRING, filepath: DataTypes.STRING,
phonenum: DataTypes.STRING, phonenum: DataTypes.STRING,
email: DataTypes.STRING, email: DataTypes.STRING,
status:DataTypes.INTEGER, status: DataTypes.INTEGER,
type:DataTypes.INTEGER, type: DataTypes.INTEGER,
channel_company_id:DataTypes.INTEGER,//统计公司id(通过公司渠道码获取,用于渠道用户统计使用商标报告功能情况) channel_company_id: DataTypes.INTEGER,//统计公司id(通过公司渠道码获取,用于渠道用户统计使用商标报告功能情况)
wxuser_id:DataTypes.INTEGER //微信用户id(使用商标报告功能的微信用户id,存在于wx_user表中) wxuser_id: DataTypes.INTEGER, //微信用户id(使用商标报告功能的微信用户id,存在于wx_user表中)
},{ notifyUrl: DataTypes.STRING,
source: DataTypes.STRING,
push_type: DataTypes.STRING,
}, {
paranoid: true,//假的删除 paranoid: true,//假的删除
underscored: true, underscored: true,
version: true, version: true,
......
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