Commit 02d00cd6 by 王栋源

wdy

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