Commit 3b101b11 by 王悦

add推送管理、组织结构监控

parent ae750f27
......@@ -9,6 +9,7 @@ class CompanyCtl extends CtlBase {
super("common", CtlBase.getServiceName(CompanyCtl));
this.userSve = system.getObject("service.auth.userSve");
}
async update(p, q, req) {
let u = await super.update(p, q, req)
//缓存失效
......@@ -16,6 +17,7 @@ class CompanyCtl extends CtlBase {
let company = await this.cacheManager["CompanyCache"].cache(p.companykey)
return system.getResult(company)
}
async getMyApps(p, q, req) {
let userfind = await this.cacheManager["UserCache"].cache(p.username)
let isSuper = userfind.isSuper
......@@ -30,6 +32,7 @@ class CompanyCtl extends CtlBase {
return []
}
}
async bindApps(p, q, req) {
let appids = p.appids
let cmpid = p.postcmpid
......@@ -40,11 +43,13 @@ class CompanyCtl extends CtlBase {
await this.service.bindApps(appidstrs, cmpid)
return system.getResult(appids)
}
async setOrgs(p, q, req) {
//let companynew=await this.service.findById(p.company_id)
let orgs = await this.service.setOrgs(p)
return system.getResult(orgs)
}
async getOrgs(p, q, req) {
//let companynew=await this.cacheManager["CompanyCache"].cache(req.xctx.fromcompanykey)
let companynew = await this.service.findById(p.company_id);
......@@ -58,13 +63,17 @@ class CompanyCtl extends CtlBase {
}
if (userData) {
if (userData.isAdmin || userData.isSuper) {
return system.getResult({ orgJson: rtnjson });
return system.getResult({orgJson: rtnjson});
} else {
return system.getResult({ orgJson: this.service.buildOrgs(rtnjson, userData.ptags) });
return system.getResult({orgJson: this.service.buildOrgs(rtnjson, userData.ptags)});
}
} else {
return system.getResult({ orgJson: [] });
return system.getResult({orgJson: []});
}
}
async getWatchOrgNodes(p, q, req) {
return await this.service.getWatchOrgNodes(p.company_id);
}
async refQuery(pobj, qobj, req) {
......@@ -72,4 +81,5 @@ class CompanyCtl extends CtlBase {
return rtn
}
}
module.exports = CompanyCtl;
var system = require("../../../system")
const http = require("http")
const querystring = require('querystring');
var settings = require("../../../../config/settings");
const CtlBase = require("../../ctl.base");
class PushCtl extends CtlBase {
constructor() {
super("common", CtlBase.getServiceName(PushCtl));
}
async findAndCountAll(pobj, qobj, req) {
let query = {
pageSize: pobj.pageInfo.pageSize,
pageIndex: pobj.pageInfo.pageNo
};
if (pobj.messageBody)
query.messageBody = pobj.messageBody;
if (pobj.identify_code)
query.identifyCode = pobj.identify_code;
if (pobj.request_id)
query.requestIdInfo = pobj.request_id;
let actionType;
switch (pobj.bizpath) {
case "/sysmag/pushfail":
actionType = "getPushFailureList";
break;
case "/sysmag/pusherror":
actionType = "getPushErrorList";
break
}
let rtn = await system.postJsonTypeReq(settings.pushUrl(), {
"actionType": actionType,
"actionBody": query
});
if (rtn.statusCode === 200) {
rtn = rtn.data;
if (rtn && rtn.status === 1) {
return system.getResult({
results: {
count: rtn.totalCount,
rows: rtn && rtn.data || []
}
});
} else {
return system.getResultFail(rtn && rtn.message || '请联系管理员');
}
} else {
return system.getResultFail(rtn)
}
}
async repush(pobj, qobj, req) {
let rtn = await system.postJsonTypeReq(settings.pushUrl(), {
"actionType": "pushAgainFailureLog",
"actionBody": {
id: pobj.id
}
});
if (rtn.statusCode === 200) {
return rtn.data;
} else {
return system.getResultFail(rtn)
}
}
}
module.exports = PushCtl;
const system = require("../../../system");
const ServiceBase = require("../../sve.base");
const settings = require("../../../../config/settings");
class CompanyService extends ServiceBase {
constructor() {
super("common", ServiceBase.getDaoName(CompanyService));
}
async getMyApps(appids, isSuper) {
let appsrtn = null
if (isSuper) {
appsrtn = this.db.models.app.findAll({
where:
{
id: { [this.db.Op.ne]: settings.pmappid }
id: {[this.db.Op.ne]: settings.pmappid}
}
})
} else {
appsrtn = this.db.models.app.findAll({
where:
{
id: { [this.db.Op.in]: appids }
id: {[this.db.Op.in]: appids}
}
})
}
return appsrtn
}
async bindApps(appids, companyid) {
var self = this
return this.db.transaction(async function (t) {
let u = await self.dao.update({ appids: appids, id: companyid }, t)
let u = await self.dao.update({appids: appids, id: companyid}, t)
return appids
})
}
buildNoPositionNode(treejson, rtnArray) {
treejson.forEach((n) => {
if (n.children) {
this.buildNoPositionNode(n.children, rtnArray)
}
if (n.hasOwnProperty("isPosition") && !n.isPosition) {
rtnArray.push(n)
}
})
}
async getWatchOrgNodes(cmid) {
let rtn = []
let companynew = await this.findById(cmid)
let orgjsonstr = companynew.orgJson
if (orgjsonstr && orgjsonstr != "") {
let treejson = JSON.parse(companynew.orgJson)
this.buildNoPositionNode(treejson, rtn)
}
return rtn
}
async setOrgs(p, cmk) {
var self = this
let curNodeData = p.curdata
......@@ -42,14 +68,14 @@ class CompanyService extends ServiceBase {
let oldopath = ''
if (!oldNodeData) {//如果不传老对象,表示当前操作是删除节点操作,检查是否存在用户,如果已经存在
//那么就提示不能删除
let us = await self.db.models.user.findOne({ where: { opath: { [self.db.Op.like]: `%${opathstr}%` } } })
let us = await self.db.models.user.findOne({where: {opath: {[self.db.Op.like]: `%${opathstr}%`}}})
if (us) {
let companytmp = await this.dao.model.findOne({ where: { id: p.company_id } });
return { orgJson: JSON.parse(companytmp.orgJson) }
let companytmp = await this.dao.model.findOne({where: {id: p.company_id}});
return {orgJson: JSON.parse(companytmp.orgJson)}
} else {
let u = await this.dao.update(p)
let companytmp = await this.dao.model.findOne({ where: { id: p.company_id } });
return { orgJson: JSON.parse(companytmp.orgJson) }
let companytmp = await this.dao.model.findOne({where: {id: p.company_id}});
return {orgJson: JSON.parse(companytmp.orgJson)}
}
} else {
oldopath = oldNodeData.orgpath == '' ? '123456' : oldNodeData.orgpath
......@@ -63,7 +89,10 @@ class CompanyService extends ServiceBase {
if (curNodeData) {
if (curNodeData.isPosition) {
let us = await self.db.models.user.findAll({ where: { opath: { [self.db.Op.like]: `%${oldopath}%` } }, transaction: t })
let us = await self.db.models.user.findAll({
where: {opath: {[self.db.Op.like]: `%${oldopath}%`}},
transaction: t
})
//查询出角色
let roleids = curNodeData.roles
// let rs=await self.db.models.role.findAll({where:{id:{[self.db.Op.in]:roleids},app_id:p.app_id,company_id:p.company_id},transaction:t})
......@@ -74,13 +103,16 @@ class CompanyService extends ServiceBase {
roleids.push(settings.pmroleid["pr"])
}
}
let rs = await self.db.models.role.findAll({ where: { id: { [self.db.Op.in]: roleids } }, transaction: t })
let rs = await self.db.models.role.findAll({
where: {id: {[self.db.Op.in]: roleids}},
transaction: t
})
for (let u of us) {
await u.setRoles(rs, { transaction: t })
await u.setRoles(rs, {transaction: t})
//if (opathstr != oldopath) {
u.opath = opathstr + "/" + u.userName
u.ptags = curNodeData.ptags
u.save({ transaction: t })
u.save({transaction: t})
// }
//令用户缓存失效
await self.cacheManager["UserCache"].invalidate(u.userName)
......@@ -88,12 +120,15 @@ class CompanyService extends ServiceBase {
} else {//不是岗位节点,检查修改后的路径是否和原始一致,如果不一致,那么需要查出原始的用户数据
//把原来的路径替换当前新的code
if (opathstr != oldopath) {
let us2 = await self.db.models.user.findAll({ where: { opath: { [self.db.Op.like]: `%${oldopath}%` } }, transaction: t })
let us2 = await self.db.models.user.findAll({
where: {opath: {[self.db.Op.like]: `%${oldopath}%`}},
transaction: t
})
for (let u of us2) {
let curpath = u.opath
let newpath = curpath.replace(oldNodeData.code, curNodeData.code)
u.opath = newpath
u.save({ transaction: t })
u.save({transaction: t})
//令用户缓存失效
await self.cacheManager["UserCache"].invalidate(u.userName)
}
......@@ -102,10 +137,11 @@ class CompanyService extends ServiceBase {
}
}
let companytmp = await self.dao.model.findOne({ where: { id: p.company_id }, transaction: t });
return { orgJson: JSON.parse(companytmp.orgJson) }
let companytmp = await self.dao.model.findOne({where: {id: p.company_id}, transaction: t});
return {orgJson: JSON.parse(companytmp.orgJson)}
})
}
buildOrgs(rtnjson, code) {
if (rtnjson.length > 0) {
for (let val of rtnjson) {
......@@ -120,4 +156,5 @@ class CompanyService extends ServiceBase {
}
}
}
module.exports = CompanyService;
......@@ -53,6 +53,13 @@ var settings = {
return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard";
}
},
pushUrl: function () {
if (this.env == "localhost") {
return "http://192.168.1.128:4018/api/queueAction/producer/springBoard";
} else {
return "http://logs-sytxpublic-msgq-service/api/queueAction/producer/springBoard";
}
},
pmappname: "center-app",
pmappid: 1,
pmcompanyid: 1,
......
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