调整首页中岗位、角色通过定时器进行数据处理,在进行统计分析。

This commit is contained in:
袁东强 2025-08-27 08:57:04 +08:00
parent 786d656b7e
commit 613b37e207
4 changed files with 277 additions and 133 deletions

View File

@ -0,0 +1,170 @@
package com.awspaas.user.apps.nqms.portal.indexpage.job;
import com.actionsoft.apps.coe.pal.pal.repository.PALRepositoryQueryAPIManager;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.DesignerShapeRelationDao;
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.schedule.IJob;
import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.bpms.util.DBSql;
import com.actionsoft.sdk.local.SDK;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.awspaas.user.apps.nqms.portal.indexpage.constant.PalCategoryEnum;
import com.awspaas.user.apps.nqms.portal.indexpage.service.UtilService;
import org.apache.commons.lang.StringUtils;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
/**
* Created with IntelliJ IDEA.
*
* @Author: yuandongqiang
* @Date: 2025/8/26
* @Description:
*/
public class CountRoleAndPostJob implements IJob {
Logger log = LoggerFactory.getLogger(CountRoleAndPostJob.class);
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
log.info("抓取组织分类下岗位和角色数据定时器=========开始执行");
UtilService service = UtilService.getInstance();
String wsId = service.getDefaultWsId();
if (StringUtils.isEmpty(wsId)) {
log.info("抓取组织分类下岗位和角色数据定时器=========获取资产库ID失败取消执行");
throw new RuntimeException("获取资产库ID失败");
}
List<JSONObject> firstProcessPalByPid = service.getFirstProcessPalByPid(wsId, PalCategoryEnum.ORG.getKey());
String postId = "";
String roleId = "";
for (JSONObject process : firstProcessPalByPid) {
String name = process.getString("name");
String versionId = process.getString("versionId");
String version = process.getString("version");
String id = process.getString("id");
if (!"1.0".equals(version) && StringUtils.isNotBlank(versionId)) {
id = versionId;
}
if ("岗位模型".equals(name)) {
postId = id;
continue;
}
if ("角色模型".equals(name)) {
roleId = id;
continue;
}
}
log.info("抓取组织分类下岗位和角色数据定时器=========开始获取岗位数据");
List<BO> postDutyData = getPostDutyData(wsId, postId);
log.info("抓取组织分类下岗位和角色数据定时器=========获取岗位数据完成");
log.info("抓取组织分类下岗位和角色数据定时器=========开始获取角色数据");
List<BO> roleData = getRoleData(wsId,roleId);
log.info("抓取组织分类下岗位和角色数据定时器=========获取角色数据完成");
log.info("抓取组织分类下岗位和角色数据定时器=========清空岗位表数据");
DBSql.update("TRUNCATE TABLE BO_EU_PORTAL_INDEX_POST");
log.info("抓取组织分类下岗位和角色数据定时器=========创建最新岗位数据");
SDK.getBOAPI().createDataBO("BO_EU_PORTAL_INDEX_POST", postDutyData, UserContext.fromUID("admin"));
log.info("抓取组织分类下岗位和角色数据定时器=========创建最新角色数据完成");
log.info("抓取组织分类下岗位和角色数据定时器=========清空角色数据");
DBSql.update("TRUNCATE TABLE BO_EU_PORTAL_INDEX_ROLE");
log.info("抓取组织分类下岗位和角色数据定时器=========创建最新角色数据");
SDK.getBOAPI().createDataBO("BO_EU_PORTAL_INDEX_ROLE", roleData, UserContext.fromUID("admin"));
log.info("抓取组织分类下岗位和角色数据定时器=========创建最新角色数据完成");
log.info("抓取组织分类下岗位和角色数据定时器=========执行完成");
}
/**
* 获取岗位数据
* wsId 资产库ID
* id 父级ID
*
* @return
*/
public List<BO> getPostDutyData(String wsId, String id) {
List<BO> data = new ArrayList<>();
List<PALRepositoryModel> list = new ArrayList<>();
PALRepositoryQueryAPIManager.getInstance().getAllPublishedPalRepositoryModelsByPid(wsId, id, list);
for (PALRepositoryModel model : list) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId());
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");// 形状列表
for (String key : elements.keySet()) {
BO bo = new BO();
JSONObject value = elements.getJSONObject(key);
bo.set("POST_ID", value.getString("id"));
JSONArray dataAttributes = value.getJSONArray("dataAttributes");
for (int i = 0; i < dataAttributes.size(); i++) {
String attId = dataAttributes.getJSONObject(i).getString("id");
if ("number".equals(attId)) {
bo.set("POST_NUM", dataAttributes.getJSONObject(i).getString("value"));
break;
}
}
bo.set("POST_NAME", value.getString("text"));
bo.set("FILE_ID", model.getId());
bo.set("FILE_NAME", model.getName());
data.add(bo);
}
}
return data;
}
/**
* 获取角色数据
* wsId 资产库ID
* id 父级ID
*
* @return
*/
public List<BO> getRoleData(String wsId, String id) {
List<BO> data = new ArrayList<>();
List<PALRepositoryModel> list = new ArrayList<>();
PALRepositoryQueryAPIManager.getInstance().getAllPublishedPalRepositoryModelsByPid(wsId, id, list);
for (PALRepositoryModel model : list) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId());
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");// 形状列表
for (String key : elements.keySet()) {
BO bo = new BO();
JSONObject value = elements.getJSONObject(key);
bo.set("ROLE_ID",value.getString("id"));
JSONArray dataAttributes = value.getJSONArray("dataAttributes");
JSONArray jsonArray = new JSONArray();
if (dataAttributes != null && dataAttributes.size() > 0) {
jsonArray = dataAttributes.getJSONObject(0).getJSONArray("attributesJsonArray");
}
for (int i = 0; i < jsonArray.size(); i++) {
String attId = jsonArray.getJSONObject(i).getString("id");
if ("number".equals(attId)) {
bo.set("ROLE_NUM",jsonArray.getJSONObject(i).getString("value"));
break;
}
}
List<DesignerShapeRelationModel> listByShapeIdAndRelationShapeId = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(model.getId(), value.getString("id"), null, null);
if (listByShapeIdAndRelationShapeId != null && listByShapeIdAndRelationShapeId.size() > 0) {
List<String> postName = new ArrayList<>();
List<String> postId = new ArrayList<>();
for (DesignerShapeRelationModel post : listByShapeIdAndRelationShapeId) {
if ("post".equals(post.getAttrId())) {
postName.add(post.getRelationShapeText());
postId.add(post.getRelationShapeId());
}
}
bo.set("POST_NAME",String.join(",", postName));
bo.set("POST_ID",String.join(",", postId));
}
bo.set("ROLE_NAME",value.getString("text"));
bo.set("FILE_ID", model.getId());
bo.set("FILE_NAME", model.getName());
data.add(bo);
}
}
return data;
}
}

View File

@ -6,6 +6,7 @@ import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.dao.Designer
import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel; import com.actionsoft.apps.coe.pal.pal.repository.designer.relation.model.DesignerShapeRelationModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryModel;
import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel; import com.actionsoft.apps.coe.pal.pal.repository.model.PALRepositoryPropertyModel;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.bpms.commons.mvc.view.ResponseObject; import com.actionsoft.bpms.commons.mvc.view.ResponseObject;
import com.actionsoft.bpms.server.UserContext; import com.actionsoft.bpms.server.UserContext;
import com.actionsoft.i18n.I18nRes; import com.actionsoft.i18n.I18nRes;
@ -86,13 +87,8 @@ public class IndexService {
* @param ux * @param ux
* @return * @return
*/ */
public String getPostOrRoleData(UserContext ux, String lab了Name, String palName) { public String getPostOrRoleData(UserContext ux, String lableName, String palName) {
UtilService service = UtilService.getInstance(); IndexVO roleOrPost = getRoleOrPost(lableName, palName);
String wsId = service.getDefaultWsId();
if (StringUtils.isEmpty(wsId)) {
return service.getWsIdWarnMsg();
}
IndexVO roleOrPost = getRoleOrPost(wsId, lab了Name, palName);
ResponseObject ro = ResponseObject.newOkResponse(); ResponseObject ro = ResponseObject.newOkResponse();
ro.setData(roleOrPost); ro.setData(roleOrPost);
return ro.toString(); return ro.toString();
@ -120,37 +116,24 @@ public class IndexService {
/** /**
* 设置角色/岗位 * 设置角色/岗位
* *
* @param wsId
* @return * @return
*/ */
public IndexVO getRoleOrPost(String wsId, String lableName, String palName) { public IndexVO getRoleOrPost(String lableName, String palName) {
System.out.println(lableName + "开始时间" + System.currentTimeMillis()); System.out.println(lableName + "开始时间" + System.currentTimeMillis());
IndexVO indexVO = new IndexVO("role", "role", lableName, "FeatureClass", 0, 0, null); IndexVO indexVO = new IndexVO("role", "role", lableName, "FeatureClass", 0, 0, null);
UtilService service = UtilService.getInstance(); String boName = "";
List<JSONObject> firstProcessPalByPid = service.getFirstProcessPalByPid(wsId, PalCategoryEnum.ORG.getKey()); switch (palName) {
String id = ""; case "岗位模型":
for (JSONObject process : firstProcessPalByPid) { boName = "BO_EU_PORTAL_INDEX_POST";
String name = process.getString("name"); break;
if (palName.equals(name)) { case "角色模型":
String versionId = process.getString("versionId"); boName = "BO_EU_PORTAL_INDEX_ROLE";
String version = process.getString("version"); break;
id = process.getString("id"); default:
if (!"1.0".equals(version) && StringUtils.isNotBlank(versionId)) {
id = versionId;
}
break; break;
}
} }
List<PALRepositoryModel> list = new ArrayList<>(); long count = SDK.getBOAPI().query(boName).count();
PALRepositoryQueryAPIManager.getInstance().getAllPublishedPalRepositoryModelsByPid(wsId, id, list); indexVO.setPubCount(Integer.parseInt(String.valueOf(count)));
int pubCount = 0;
for (PALRepositoryModel model : list) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId());
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");// 形状列表
pubCount += elements.size();
}
indexVO.setPubCount(pubCount);
System.out.println(lableName + "结束时间" + System.currentTimeMillis()); System.out.println(lableName + "结束时间" + System.currentTimeMillis());
return indexVO; return indexVO;
} }
@ -375,9 +358,9 @@ public class IndexService {
return ro.toString(); return ro.toString();
} else if (type.equals("role")) { } else if (type.equals("role")) {
list = getRoleData(wsId); list = getRoleData();
} else if (type.equals("post")) { } else if (type.equals("post")) {
list = getPostDutyData(wsId); list = getPostDutyData();
} else { } else {
String factorData = getFactor(ux, wsId, type, page, size); String factorData = getFactor(ux, wsId, type, page, size);
JSONObject jsonObject = JSONObject.parseObject(factorData); JSONObject jsonObject = JSONObject.parseObject(factorData);
@ -400,46 +383,11 @@ public class IndexService {
* *
* @return * @return
*/ */
public List<PostVO> getPostDutyData(String wsId) { public List<PostVO> getPostDutyData() {
List<BO> bos = SDK.getBOAPI().query("BO_EU_PORTAL_INDEX_POST").list();
List<PostVO> data = new ArrayList<>(); List<PostVO> data = new ArrayList<>();
UtilService service = UtilService.getInstance(); for (BO bo : bos) {
List<JSONObject> firstProcessPalByPid = service.getFirstProcessPalByPid(wsId, PalCategoryEnum.ORG.getKey()); data.add(PostVO.getBoToPost(bo));
String id = "";
for (JSONObject process : firstProcessPalByPid) {
String name = process.getString("name");
if ("岗位模型".equals(name)) {
String versionId = process.getString("versionId");
String version = process.getString("version");
id = process.getString("id");
if (!"1.0".equals(version) && StringUtils.isNotBlank(versionId)) {
id = versionId;
}
break;
}
}
List<PALRepositoryModel> list = new ArrayList<>();
PALRepositoryQueryAPIManager.getInstance().getAllPublishedPalRepositoryModelsByPid(wsId, id, list);
for (PALRepositoryModel model : list) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId());
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");// 形状列表
for (String key : elements.keySet()) {
PostVO postVO = new PostVO();
JSONObject value = elements.getJSONObject(key);
postVO.setPostId(value.getString("id"));
JSONArray dataAttributes = value.getJSONArray("dataAttributes");
for (int i = 0; i < dataAttributes.size(); i++) {
String attId = dataAttributes.getJSONObject(i).getString("id");
if ("number".equals(attId)) {
postVO.setPostNO(dataAttributes.getJSONObject(i).getString("value"));
break;
}
}
postVO.setPostName(value.getString("text"));
postVO.setFileId(model.getId());
postVO.setFileName(model.getName());
data.add(postVO);
}
} }
return data; return data;
} }
@ -449,60 +397,11 @@ public class IndexService {
* *
* @return * @return
*/ */
public List<RoleVO> getRoleData(String wsId) { public List<RoleVO> getRoleData() {
List<BO> bos = SDK.getBOAPI().query("BO_EU_PORTAL_INDEX_ROLE").list();
List<RoleVO> data = new ArrayList<>(); List<RoleVO> data = new ArrayList<>();
UtilService service = UtilService.getInstance(); for (BO bo : bos) {
List<JSONObject> firstProcessPalByPid = service.getFirstProcessPalByPid(wsId, PalCategoryEnum.ORG.getKey()); data.add(RoleVO.getBoToRole(bo));
String id = "";
for (JSONObject process : firstProcessPalByPid) {
String name = process.getString("name");
if ("角色模型".equals(name)) {
String versionId = process.getString("versionId");
String version = process.getString("version");
id = process.getString("id");
if (!"1.0".equals(version) && StringUtils.isNotBlank(versionId)) {
id = versionId;
}
break;
}
}
List<PALRepositoryModel> list = new ArrayList<>();
PALRepositoryQueryAPIManager.getInstance().getAllPublishedPalRepositoryModelsByPid(wsId, id, list);
for (PALRepositoryModel model : list) {
String define = PALRepositoryQueryAPIManager.getInstance().getProcessDefinition(null, model.getId());
JSONObject definition = JSONObject.parseObject(define);
JSONObject elements = definition.getJSONObject("elements");// 形状列表
for (String key : elements.keySet()) {
RoleVO roleVO = new RoleVO();
JSONObject value = elements.getJSONObject(key);
roleVO.setRoleId(value.getString("id"));
JSONArray dataAttributes = value.getJSONArray("dataAttributes");
JSONArray jsonArray = new JSONArray();
if (dataAttributes != null && dataAttributes.size() > 0) {
jsonArray = dataAttributes.getJSONObject(0).getJSONArray("attributesJsonArray");
}
for (int i = 0; i < jsonArray.size(); i++) {
String attId = jsonArray.getJSONObject(i).getString("id");
if ("number".equals(attId)) {
roleVO.setRoleNo(jsonArray.getJSONObject(i).getString("value"));
break;
}
}
List<DesignerShapeRelationModel> listByShapeIdAndRelationShapeId = new DesignerShapeRelationDao().getModelListByShapeIdAndRelationShapeId(model.getId(), value.getString("id"), null, null);
if (listByShapeIdAndRelationShapeId != null && listByShapeIdAndRelationShapeId.size() > 0) {
List<String> postName = new ArrayList<>();
for (DesignerShapeRelationModel post : listByShapeIdAndRelationShapeId) {
if ("post".equals(post.getAttrId())) {
postName.add(post.getRelationShapeText());
}
}
roleVO.setRelPost(postName);
}
roleVO.setName(value.getString("text"));
roleVO.setFileId(model.getId());
roleVO.setFileName(model.getName());
data.add(roleVO);
}
} }
return data; return data;
} }
@ -634,13 +533,13 @@ public class IndexService {
String fileNo = getFileProper(id, "file_number"); String fileNo = getFileProper(id, "file_number");
//发布部门 //发布部门
String dutyDept = getFileProper(id, "Issuing_department"); String dutyDept = getFileProper(id, "Issuing_department");
if (StringUtils.isNotEmpty(dutyDept)){ if (StringUtils.isNotEmpty(dutyDept)) {
try { try {
JSONObject jsonObject = JSONObject.parseObject(dutyDept); JSONObject jsonObject = JSONObject.parseObject(dutyDept);
dutyDept = jsonObject.getString("shapeText"); dutyDept = jsonObject.getString("shapeText");
}catch (Exception e){ } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
System.out.println("发布部门非JSON格式转化失败显示原值。文件ID"+ id); System.out.println("发布部门非JSON格式转化失败显示原值。文件ID" + id);
} }
} }
//流程架构L1 //流程架构L1

View File

@ -1,5 +1,6 @@
package com.awspaas.user.apps.nqms.portal.indexpage.vo; package com.awspaas.user.apps.nqms.portal.indexpage.vo;
import com.actionsoft.bpms.bo.engine.BO;
import com.actionsoft.sdk.local.SDK; import com.actionsoft.sdk.local.SDK;
import com.alipay.remoting.util.StringUtils; import com.alipay.remoting.util.StringUtils;
@ -80,4 +81,36 @@ public class PostVO {
public void setPostName(String postName) { public void setPostName(String postName) {
this.postName = postName; this.postName = postName;
} }
/**
* 岗位模型转BO模型
*
* @param postVO
* @return
*/
public static BO getPostToBo(PostVO postVO) {
BO bo = new BO();
bo.set("FILE_NAME", postVO.getFileName());
bo.set("FILE_ID", postVO.getFileId());
bo.set("POST_NUM", postVO.getPostNO());
bo.set("POST_NAME", postVO.getPostName());
bo.set("POST_ID", postVO.getPostId());
return bo;
}
/**
* BO模型转岗位模型
*
* @param bo
* @return
*/
public static PostVO getBoToPost(BO bo) {
PostVO postVO = new PostVO();
postVO.setFileName(bo.getString("FILE_NAME"));
postVO.setFileId(bo.getString("FILE_ID"));
postVO.setPostNO(bo.getString("POST_NUM"));
postVO.setPostName(bo.getString("POST_NAME"));
postVO.setPostId(bo.getString("POST_ID"));
return postVO;
}
} }

View File

@ -1,6 +1,7 @@
package com.awspaas.user.apps.nqms.portal.indexpage.vo; package com.awspaas.user.apps.nqms.portal.indexpage.vo;
import com.actionsoft.bpms.bo.engine.BO;
import java.util.List; import java.util.List;
@ -19,11 +20,11 @@ public class RoleVO {
*/ */
private String roleId; private String roleId;
/** /**
*角色编号 * 角色编号
*/ */
private String roleNo; private String roleNo;
/** /**
*角色名称 * 角色名称
*/ */
private String name; private String name;
/** /**
@ -35,9 +36,9 @@ public class RoleVO {
*/ */
private String fileName; private String fileName;
/** /**
*关联岗位的名称 * 关联岗位的名称
*/ */
private String relPost=""; private String relPost = "";
public RoleVO() { public RoleVO() {
} }
@ -84,6 +85,7 @@ public class RoleVO {
public void setFileId(String fileId) { public void setFileId(String fileId) {
this.fileId = fileId; this.fileId = fileId;
} }
public String getFileName() { public String getFileName() {
return fileName; return fileName;
} }
@ -102,6 +104,10 @@ public class RoleVO {
this.relPost = join; this.relPost = join;
} }
public void setRelPost(String relPost) {
this.relPost = relPost;
}
@Override @Override
public String toString() { public String toString() {
return "RoleVO{" + return "RoleVO{" +
@ -113,4 +119,40 @@ public class RoleVO {
", relPost=" + relPost + ", relPost=" + relPost +
'}'; '}';
} }
/**
* 角色模型转化BO模型
*
* @param roleVO
* @return
*/
public static BO getRoleToBo(RoleVO roleVO) {
BO bo = new BO();
bo.set("FILE_NAME", roleVO.getFileName());
bo.set("FILE_ID", roleVO.getFileId());
bo.set("POST_ID", "");
bo.set("POST_NAME", roleVO.getRelPost());
bo.set("ROLE_NUM", roleVO.getRoleNo());
bo.set("ROLE_NAME", roleVO.getName());
bo.set("ROLE_ID", roleVO.getRoleId());
return bo;
}
/**
* BO模型转化角色模型
*
* @param bo
* @return
*/
public static RoleVO getBoToRole(BO bo) {
RoleVO roleVO = new RoleVO();
roleVO.setRelPost(bo.getString("POST_NAME"));
roleVO.setFileName(bo.getString("FILE_NAME"));
roleVO.setFileId(bo.getString("FILE_ID"));
roleVO.setRoleId(bo.getString("ROLE_ID"));
roleVO.setRoleNo(bo.getString("ROLE_NUM"));
roleVO.setName(bo.getString("ROLE_NAME"));
return roleVO;
}
} }