Browse Source

提交开源任务材料

10.0
LAPTOP-SB56SG4Q\86185 3 years ago
parent
commit
d7ce3f7c1b
  1. 5
      README.md
  2. BIN
      lib/fine-plugin-tool.jar
  3. BIN
      lib/sys-org-entity.jar
  4. 32
      plugin.xml
  5. 56
      src/main/java/com/fr/plugin/teshe/TeShePerformanceMonitor.java
  6. 72
      src/main/java/com/fr/plugin/teshe/beans/AuthorityBean.java
  7. 17
      src/main/java/com/fr/plugin/teshe/beans/OrganUserFullPathComparator.java
  8. 105
      src/main/java/com/fr/plugin/teshe/beans/OrganUserModel.java
  9. 23
      src/main/java/com/fr/plugin/teshe/beans/OrganUserModelExtend.java
  10. 28
      src/main/java/com/fr/plugin/teshe/beans/SecondOrganFullPathComparator.java
  11. 167
      src/main/java/com/fr/plugin/teshe/beans/SecondOrganModel.java
  12. 97
      src/main/java/com/fr/plugin/teshe/beans/UserAuthorityModel.java
  13. 85
      src/main/java/com/fr/plugin/teshe/conf/ConfigXmlReader.java
  14. 694
      src/main/java/com/fr/plugin/teshe/controller/TieSheController.java
  15. 12
      src/main/java/com/fr/plugin/teshe/controller/TieSheControllerProvider.java
  16. 28
      src/main/java/com/fr/plugin/teshe/entity/TieSheDBAccessProvider.java
  17. 49
      src/main/java/com/fr/plugin/teshe/entity/TieSheFiliRptDAO.java
  18. 154
      src/main/java/com/fr/plugin/teshe/entity/TieSheFiliRptEntity.java
  19. 156
      src/main/java/com/fr/plugin/teshe/entity/TieSheRoleOperateLogDAO.java
  20. 104
      src/main/java/com/fr/plugin/teshe/entity/TieSheRoleOperateLogEntity.java
  21. 183
      src/main/java/com/fr/plugin/teshe/entity/TieSheSysOrgDAO.java
  22. 167
      src/main/java/com/fr/plugin/teshe/entity/TieSheSysOrgEntity.java
  23. 138
      src/main/java/com/fr/plugin/teshe/entity/UserInOrganDAO.java
  24. 242
      src/main/java/com/fr/plugin/teshe/entity/UserInOrganEntity.java
  25. 551
      src/main/java/com/fr/plugin/teshe/entity/UserRoleMenuItemDAO.java
  26. 73
      src/main/java/com/fr/plugin/teshe/entity/UserRoleMenuItemEntity.java
  27. 87
      src/main/java/com/fr/plugin/teshe/finerecordexecute/TieSheExecuteLogRestriction.java
  28. 17
      src/main/java/com/fr/plugin/teshe/jscss/MainJsCssBridge.java
  29. 32
      src/main/java/com/fr/plugin/teshe/jscss/TeSheMainDef.java
  30. 922
      src/main/java/com/fr/plugin/teshe/services/RemoteReqService.java
  31. 26
      src/main/java/com/fr/plugin/teshe/services/TieSheFiliRptDBAUtil.java
  32. 75
      src/main/java/com/fr/plugin/teshe/services/TieSheOperateLogDBAUtil.java
  33. 356
      src/main/java/com/fr/plugin/teshe/services/TieSheOperateLogService.java
  34. 116
      src/main/java/com/fr/plugin/teshe/services/TieSheSysOrgDBAUtil.java
  35. 146
      src/main/java/com/fr/plugin/teshe/services/TieSheSysOrgService.java
  36. 378
      src/main/java/com/fr/plugin/teshe/services/UserInOrganDBAUtil.java
  37. 526
      src/main/java/com/fr/plugin/teshe/services/UserInOrganService.java
  38. 521
      src/main/java/com/fr/plugin/teshe/services/UserRoleMenuDBAUtil.java
  39. 986
      src/main/java/com/fr/plugin/teshe/services/UserRoleMenuService.java
  40. 34
      src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheOrganSystemOptionOrganManageProvider.java
  41. 35
      src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheSystemOptionAuthorityViewProvider.java
  42. 35
      src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheSystemOptionLogViewProvider.java
  43. 54
      src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheSystemOptionProvider.java
  44. 135
      src/main/java/com/fr/plugin/teshe/task/OrganSyncTask.java
  45. 369
      src/main/java/com/fr/plugin/teshe/utils/TeSheUtil.java
  46. 48
      src/main/resources/com/fr/plugin/teshe/jscss/userRole.css
  47. 9189
      src/main/resources/com/fr/plugin/teshe/jscss/userRole.js
  48. 88
      文档/fineui_tree笔记
  49. 3
      文档/授权文档.txt
  50. BIN
      文档/插件说明文档.docx

5
README.md

@ -1,3 +1,6 @@
# open-JSD-8834
JSD-8834 自定义授权&审计
JSD-8834 自定义授权&审计\
免责说明:该源码为第三方爱好者提供,不保证源码和方案的可靠性,也不提供任何形式的源码教学指导和协助!\
仅作为开发者学习参考使用!禁止用于任何商业用途!\
为保护开发者隐私,开发者信息已隐去!若原开发者希望公开自己的信息,可联系hugh处理。

BIN
lib/fine-plugin-tool.jar

Binary file not shown.

BIN
lib/sys-org-entity.jar

Binary file not shown.

32
plugin.xml

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><plugin>
<id>com.fr.plugin.teshe.roleuser.plugin</id>
<name><![CDATA[用户授权插件]]></name>
<active>yes</active>
<version>1.2</version>
<env-version>10.0</env-version>
<jartime>2018-07-31</jartime>
<vendor>fr.open</vendor>
<description><![CDATA[用户授权插件]]></description>
<change-notes><![CDATA[
[2018-08-01]修改一点问题。<br/>
[2018-07-31]初始化插件。<br/>
1.1版本增加授权与组织结构绑定<br/>
1.2版本组织结构树修改<br/>
]]></change-notes>
<extra-core>
<DBAccessProvider class="com.fr.plugin.teshe.entity.TieSheDBAccessProvider"/>
</extra-core>
<extra-decision>
<ControllerRegisterProvider class="com.fr.plugin.teshe.controller.TieSheControllerProvider"/>
<SystemOptionProvider class="com.fr.plugin.teshe.systemOptionProvider.TeSheSystemOptionProvider"/>
<SystemOptionProvider class="com.fr.plugin.teshe.systemOptionProvider.TeSheSystemOptionAuthorityViewProvider"/>
<SystemOptionProvider class="com.fr.plugin.teshe.systemOptionProvider.TeSheSystemOptionLogViewProvider"/>
</extra-decision>
<function-recorder class="com.fr.plugin.teshe.TeShePerformanceMonitor"/>
<lifecycle-monitor class="com.fr.plugin.teshe.TeShePerformanceMonitor"/>
</plugin>

56
src/main/java/com/fr/plugin/teshe/TeShePerformanceMonitor.java

@ -0,0 +1,56 @@
package com.fr.plugin.teshe;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContext;
import com.fr.plugin.observer.inner.AbstractPluginLifecycleMonitor;
import com.fr.plugin.teshe.conf.ConfigXmlReader;
import com.fr.plugin.teshe.task.OrganSyncTask;
import com.fr.plugin.transform.FunctionRecorder;
import com.fr.record.analyzer.EnableMetrics;
import com.fr.stable.fun.Authorize;
import com.fr.stable.xml.XMLTools;
import com.fr.workspace.WorkContext;
import java.io.File;
import java.util.Timer;
@EnableMetrics
@FunctionRecorder
@Authorize(callSignKey = "com.fr.plugin.teshe.roleuser.plugin")
public class TeShePerformanceMonitor extends AbstractPluginLifecycleMonitor
{
@Override
public void afterRun(PluginContext pluginContext) {
FineLoggerFactory.getLogger().info(pluginContext.getName()+"插件启动完成");
//读取webroot下的配置文件
String envPath = WorkContext.getCurrent().getPath();
FineLoggerFactory.getLogger().info("envPath:"+envPath);
String webReport = (new File(envPath)).getParent();
FineLoggerFactory.getLogger().info("webReport:"+webReport);
File envFile = new File(webReport+File.separator+"conf"+File.separator+"tiejian.xml");;
try {
XMLTools.readFileXML(ConfigXmlReader.getInstance(), envFile);
} catch (Exception e) {
e.printStackTrace();
}
// 计时器 ,定时检查人事系统组织是否有删除
TeShePerformanceMonitor.timer = new Timer();
// 添加执行任务(延迟 1分钟 执行,每 3s 执行一次)
TeShePerformanceMonitor.timer.schedule(OrganSyncTask.taskInstance, ConfigXmlReader.getInstance().delay_duration, ConfigXmlReader.getInstance().timer_duration); //1分钟
}
private static Timer timer;
@Override
public void beforeStop(PluginContext pluginContext) {
FineLoggerFactory.getLogger().info(pluginContext.getName()+"插件即将停止");
if(TeShePerformanceMonitor.timer != null){ //取消定时器
TeShePerformanceMonitor.timer.cancel();
}
}
}

72
src/main/java/com/fr/plugin/teshe/beans/AuthorityBean.java

@ -0,0 +1,72 @@
package com.fr.plugin.teshe.beans;
import com.fr.decision.webservice.bean.BaseBean;
/**
* 设置权限传递的参数bean
*/
public class AuthorityBean extends BaseBean {
private String provinceId;
private String orgId;
private String orgName;
private String authorityUserName;
private String userName;
private String orgCode;
private String authorityInfos;
public String getOrgCode() {
return orgCode;
}
public void setOrgCode(String orgCode) {
this.orgCode = orgCode;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getAuthorityUserName() {
return authorityUserName;
}
public void setAuthorityUserName(String authorityUserName) {
this.authorityUserName = authorityUserName;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public void setOrgId(String orgId) {
this.orgId = orgId;
}
public void setOrgName(String orgName) {
this.orgName = orgName;
}
public void setAuthorityInfos(String authorityInfos) {
this.authorityInfos = authorityInfos;
}
public String getProvinceId() {
return provinceId;
}
public String getOrgId() {
return orgId;
}
public String getOrgName() {
return orgName;
}
public String getAuthorityInfos() {
return authorityInfos;
}
}

17
src/main/java/com/fr/plugin/teshe/beans/OrganUserFullPathComparator.java

@ -0,0 +1,17 @@
package com.fr.plugin.teshe.beans;
import java.util.Comparator;
public class OrganUserFullPathComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
if (o1 instanceof OrganUserModel && o2 instanceof OrganUserModel) {
OrganUserModel s1 = (OrganUserModel) o1;
OrganUserModel s2 = (OrganUserModel) o2;
if (s1.getFullPathOrder().compareTo(s2.getFullPathOrder()) > 0) return 1;
else if (s1.getFullPathOrder().compareTo(s2.getFullPathOrder()) < 0) return -1;
else return 0;
}
return 0;
}
}

105
src/main/java/com/fr/plugin/teshe/beans/OrganUserModel.java

@ -0,0 +1,105 @@
package com.fr.plugin.teshe.beans;
public class OrganUserModel {
public OrganUserModel() {
}
private String providerId;
private String type;
private int id;
private String pId;
private String orginId;
private boolean isMain;
public boolean isMain() {
return isMain;
}
public void setMain(boolean main) {
isMain = main;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
private String value;
public void setType(String type) {
this.type = type;
}
public void setId(int id) {
this.id = id;
}
public String getpId() {
return pId;
}
public void setpId(String pId) {
this.pId = pId;
}
public void setOrder(int order) {
this.order = order;
}
public void setText(String text) {
this.text = text;
}
public String getType() {
return type;
}
public int getId() {
return id;
}
public int getOrder() {
return order;
}
public String getText() {
return text;
}
public String getProviderId() {
return providerId;
}
public void setProviderId(String providerId) {
this.providerId = providerId;
}
public String getOrginId() {
return orginId;
}
public void setOrginId(String orginId) {
this.orginId = orginId;
}
private int order;
private String fullPathOrder;
private String text;
public void setFullPathOrder(String fullPathOrder) {
this.fullPathOrder = fullPathOrder;
}
public String getFullPathOrder() {
return fullPathOrder;
}
}

23
src/main/java/com/fr/plugin/teshe/beans/OrganUserModelExtend.java

@ -0,0 +1,23 @@
package com.fr.plugin.teshe.beans;
public class OrganUserModelExtend extends OrganUserModel{
private String orginId;
private String fullPath;
public void setOrginId(String orginId) {
this.orginId = orginId;
}
public void setFullPath(String fullPath) {
this.fullPath = fullPath;
}
public String getOrginId() {
return orginId;
}
public String getFullPath() {
return fullPath;
}
}

28
src/main/java/com/fr/plugin/teshe/beans/SecondOrganFullPathComparator.java

@ -0,0 +1,28 @@
package com.fr.plugin.teshe.beans;
import com.fr.plugin.teshe.entity.UserInOrganEntity;
import java.util.Comparator;
public class SecondOrganFullPathComparator implements Comparator {
@Override
public int compare(Object o1, Object o2) {
if (o1 instanceof SecondOrganModel && o2 instanceof SecondOrganModel) {
SecondOrganModel s1 = (SecondOrganModel) o1;
SecondOrganModel s2 = (SecondOrganModel) o2;
if (s1.getFullPathOrder().compareTo(s2.getFullPathOrder()) > 0) return 1;
else if (s1.getFullPathOrder().compareTo(s2.getFullPathOrder()) < 0) return -1;
else return 0;
}
if (o1 instanceof UserInOrganEntity && o2 instanceof UserInOrganEntity) {
UserInOrganEntity s1 = (UserInOrganEntity) o1;
UserInOrganEntity s2 = (UserInOrganEntity) o2;
if (s1.getFullPathOrder().compareTo(s2.getFullPathOrder()) > 0) return 1;
else if (s1.getFullPathOrder().compareTo(s2.getFullPathOrder()) < 0) return -1;
else return 0;
}
return 0;
}
}

167
src/main/java/com/fr/plugin/teshe/beans/SecondOrganModel.java

@ -0,0 +1,167 @@
package com.fr.plugin.teshe.beans;
public class SecondOrganModel {
private String providerId;
private String companyId;
private String text;
private boolean isParent;
private String pId;
private String id;
private String organCode;
private int modelType;
private int order; //排序
private String fullPathOrder; //全路径的排序
private boolean isVirture; //是否是虚拟节点
private int layer;
private String hrOrgId; //人事系统机构id
private int hrType; //人事系统机构type
public SecondOrganModel(String providerId, String companyId) {
this.providerId = providerId;
this.companyId = companyId;
this.id = companyId;
}
public String getHrOrgId() {
return hrOrgId;
}
public void setHrOrgId(String hrOrgId) {
this.hrOrgId = hrOrgId;
}
public int getHrType() {
return hrType;
}
public void setHrType(int hrType) {
this.hrType = hrType;
}
public int getModelType() {
return modelType;
}
public void setModelType(int modelType) {
this.modelType = modelType;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getLayer() {
return layer;
}
public void setLayer(int layer) {
this.layer = layer;
}
public String getOrganCode() {
return organCode;
}
public void setOrganCode(String organCode) {
this.organCode = organCode;
}
public int getOrder() {
return order;
}
public void setOrder(int order) {
this.order = order;
}
public void setVirture(boolean virture) {
isVirture = virture;
}
public boolean isVirture() {
return isVirture;
}
public String getFullPathOrder() {
return fullPathOrder;
}
public void setFullPathOrder(String fullPathOrder) {
this.fullPathOrder = fullPathOrder;
}
/*
@Override
public String toString(){
HashMap<String,Object> hashmap = new HashMap<>();
hashmap.put("providerId",providerId);
hashmap.put("id",companyId);
hashmap.put("value",companyId);
hashmap.put("text",text);
if(isParent == true){
hashmap.put("isParent",true);
}
else{
if(pId != null){
hashmap.put("pId",pId);
}
}
return hashmap.toString();
}*/
public void setText(String text) {
this.text = text;
}
public void setIsParent(boolean parent) {
isParent = parent;
}
public String getText() {
return text;
}
public boolean getIsParent() {
return isParent;
}
public String getpId() {
return pId;
}
public void setpId(String pId) {
this.pId = pId;
}
public String getProviderId() {
return providerId;
}
public void setProviderId(String providerId) {
this.providerId = providerId;
}
public String getCompanyId() {
return companyId;
}
public void setCompanyId(String companyId) {
this.companyId = companyId;
}
}

97
src/main/java/com/fr/plugin/teshe/beans/UserAuthorityModel.java

@ -0,0 +1,97 @@
package com.fr.plugin.teshe.beans;
public class UserAuthorityModel {
private String id;
private String pId;
private String text;
private int viewAuthority;
private int editAuthority;
private int maintainAuthority;
private boolean canViewAuthority; //能查看
private boolean canEditAuthority;//能管理
private boolean canMaintainAuthority; //能维护
private int modelType; //1 首页,2 目录,3 菜单
public boolean isCanViewAuthority() {
return canViewAuthority;
}
public boolean isCanEditAuthority() {
return canEditAuthority;
}
public int getMaintainAuthority() {
return maintainAuthority;
}
public void setMaintainAuthority(int maintainAuthority) {
this.maintainAuthority = maintainAuthority;
}
public boolean isCanMaintainAuthority() {
return canMaintainAuthority;
}
public void setCanMaintainAuthority(boolean canMaintainAuthority) {
this.canMaintainAuthority = canMaintainAuthority;
}
public void setCanViewAuthority(boolean canViewAuthority) {
this.canViewAuthority = canViewAuthority;
}
public void setCanEditAuthority(boolean canEditAuthority) {
this.canEditAuthority = canEditAuthority;
}
public int getModelType() {
return modelType;
}
public void setModelType(int modelType) {
this.modelType = modelType;
}
public void setId(String id) {
this.id = id;
}
public void setpId(String pId) {
this.pId = pId;
}
public void setText(String text) {
this.text = text;
}
public void setViewAuthority(int viewAuthority) {
this.viewAuthority = viewAuthority;
}
public void setEditAuthority(int editAuthority) {
this.editAuthority = editAuthority;
}
public String getId() {
return id;
}
public String getpId() {
return pId;
}
public String getText() {
return text;
}
public int getViewAuthority() {
return viewAuthority;
}
public int getEditAuthority() {
return editAuthority;
}
}

85
src/main/java/com/fr/plugin/teshe/conf/ConfigXmlReader.java

@ -0,0 +1,85 @@
package com.fr.plugin.teshe.conf;
import com.fr.design.actions.file.export.ExcelExportAction;
import com.fr.stable.StringUtils;
import com.fr.stable.xml.XMLReadable;
import com.fr.stable.xml.XMLableReader;
public class ConfigXmlReader implements XMLReadable {
private static ConfigXmlReader instance;
public static ConfigXmlReader getInstance(){
if(instance == null){
instance = new ConfigXmlReader();
}
return instance;
}
public String tokenReqUrl = ""; //获取token
public String secondOrgReqUrl = ""; //获取二级单位i
public String orgReqUrl = ""; //获取该provinceId下所有机构
public String orgNextReqUrl = ""; //获取下级机构
public String personReqUrl = ""; //获取该机构下的员工
public String personStationUrl = "";//获取用户岗位
public String personMainStationUrl = "";//获取用户主岗位
public String orgPathUrl = "";//根据岗位,部门,机构获取全路径
public String searchPersonReqUrl = ""; //获取该机构下的员工
public String getOrgDepUrl = ""; //获取部门信息
public String getOrgUnit = ""; //获取单位信息
public String clientId = "";
public String clientSecret = "";
public long delay_duration = 1000*60*20;
//public long timer_duration = 1000 * 60 ;
public long timer_duration = 1000 * 60 * 60 * 24;
@Override
public void readXML(XMLableReader reader) {
if (reader.isChildNode()) {
String name = reader.getTagName();
if(name.equals("tokenReqUrl")){
this.tokenReqUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("secondOrgReqUrl")){
this.secondOrgReqUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("orgReqUrl")){
this.orgReqUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("orgNextReqUrl")){
this.orgNextReqUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("personReqUrl")){
this.personReqUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("personMainStationUrl")){
this.personMainStationUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("searchPersonReqUrl")){
this.searchPersonReqUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("getOrgDepUrl")){
this.getOrgDepUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("getOrgUnit")){
this.getOrgUnit = StringUtils.trim(reader.getElementValue());
}
if(name.equals("personStationUrl")){
this.personStationUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("orgPathUrl")){
this.orgPathUrl = StringUtils.trim(reader.getElementValue());
}
if(name.equals("clientId")){
this.clientId = StringUtils.trim(reader.getElementValue());
}
if(name.equals("clientSecret")){
this.clientSecret = StringUtils.trim(reader.getElementValue());
}
}
}
}

694
src/main/java/com/fr/plugin/teshe/controller/TieSheController.java

@ -0,0 +1,694 @@
package com.fr.plugin.teshe.controller;
import com.fr.decision.webservice.Response;
import com.fr.decision.webservice.annotation.LoginStatusChecker;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.beans.*;
import com.fr.plugin.teshe.entity.*;
import com.fr.plugin.teshe.services.*;
import com.fr.plugin.teshe.task.OrganSyncTask;
import com.fr.plugin.teshe.utils.TeSheUtil;
import com.fr.stable.query.data.DataList;
import com.fr.third.alibaba.druid.support.json.JSONUtils;
import com.fr.third.jodd.util.StringUtil;
import com.fr.third.springframework.stereotype.Controller;
import com.fr.third.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
@Controller
@LoginStatusChecker(
required = false //不需要验证是否登录
)
public class TieSheController {
public static final boolean isLocal = false;
public static final String ROOT_ORGCODE = "00001";
public static final String ROOT_LOCAL_ORGCODE = "00000";
public static final String WORK_AUTHORITY_ID = "decision-management-user-role-assign";
public static final String SYSTEM_LOG_ID = "decision-management-user-role-log";
public static final String WORKD_AUTHORITY_VIEW_ID = "decision-management-user-role-statistics";
public static final String ORGAN_MANAGE_ID = "decision-management-user-role-organization";
public static final String FUNC_MANAGER_ROOT_ID = "decision-management-root";
public static final String HOME_PAGE_ROOT_ID = "decision-homepage-root";
public static final String DIR_MANAGE_ROOT_ID = "decision-directory-root";
public static final String ROLE_AUTHORITY_ROOT_ID = "decision-role-root";
private final int EXPORT_EXCEL_COUNT = 10000000;
public static final String CARRIER_TYPE = "user";//"depost",role;
//当前用户的信息
private HashMap<String, String> userAndRealNameMap = new HashMap<>();
private HashMap<String, String> userAndOrgFullPathMap = new HashMap<>();
/**
* 登陆后获取配置信息以及token信息
*
* @param req
* @param res
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getConfig"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getConfigInfo(HttpServletRequest req, HttpServletResponse res) throws Exception {
JSONObject jsonObj = new JSONObject();
String currentUser = TeSheUtil.getCurrentLoginUser(req);
jsonObj.put("currentUser", currentUser);
jsonObj.put("currentUser1", currentUser);
if (!"admin".equals(currentUser)) {
if (isLikeAdminUser(currentUser)) {
jsonObj.put("currentUser1", "likeAdmin");
}
if (currentUser.indexOf("_") != -1) {
String[] temp = currentUser.split("_");
String provinceId = temp[0];
String userId = temp[1];
//查询登录用户的机构信息
HashMap<String, String> userOrgInfo = RemoteReqService.getInstance().getOrganInfoByUserId(provinceId, userId);
String orgCode = userOrgInfo.get("orgCode");
String orgId = userOrgInfo.get("orgId");
String realName = TeSheUtil.getCurrentLoginRealName(req);
//保存当前用户的真实姓名
userAndRealNameMap.put(currentUser, realName);
String userOrganFullPath = RemoteReqService.getInstance().getOrgFullPath(provinceId, orgId, true, true);
//保存当前用户的机构全路径
userAndOrgFullPathMap.put(currentUser, userOrganFullPath);
}
} else {
userAndRealNameMap.put("admin", "admin");
userAndOrgFullPathMap.put("admin", "中国铁建");
}
//登录时先获取token。
TieSheController.tieSheToken = TeSheUtil.getAccessToken();
jsonObj.put("token", TieSheController.tieSheToken);
return Response.ok(jsonObj.toString());
}
/**
* 检查该用户在该组织上是否有增加或者删除授权人员的权限,
* 当用户进入工作授权左侧组织结构树节点选中时需要调用该方法来判断该用户是否有管理功能
*
* @param req
* @param res
* @param orgCode
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/checkCanAddOrDeleteUserInOrgan"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response checkCanAddOrDeleteUserInOrgan(HttpServletRequest req, HttpServletResponse res, @RequestParam("orgCode") String orgCode) throws Exception {
//先看这个人是否是admin或者likeAdmin用户
String currentUser = TeSheUtil.getCurrentLoginUser(req);
if (currentUser.equals("admin")) {
return Response.ok(true);
} else {
if (isLikeAdminUser(currentUser) == true) {
return Response.ok(true);
} else {
//查看传进来的orgcode或者它的上面是否有管理工作授权的权限
//首先获取这个人在工作授权的所有组织的管理权限
//这个人只有在该组织上有工作授权的管理功能才能操作加人,删除人
List<UserRoleMenuItemEntity> entitys = UserRoleMenuDBAUtil.getInstance().getWorkAuthorityManageMenuDatasAndParent(TeSheUtil.getCurrentLoginUserId(currentUser), orgCode);
if (entitys == null || entitys.size() == 0) {
return Response.ok(false);
} else {
return Response.ok(true);
}
}
}
}
/**
* admin或者likeAdmin用户可以获取所有的组织机构数据,所以这里不做限制
*
* @param req
* @param res
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getAllOragnList"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getAllOragnList(HttpServletRequest req, HttpServletResponse res) throws Exception {
//检查下人事系统有删除的组织没
OrganSyncTask.taskInstance.syncRemoteOrgan();
ArrayList<SecondOrganModel> infos = RemoteReqService.getInstance().getSecondOrgan(true);
return Response.ok(infos);
}
/**
* 一般用户获取组织机构数据
* 这里需要去重可能将一个人放到一个组织的下级组织这就造成了数据重复所以需要将下级去掉只保留上级
*
* @param req
* @param res
* @param currentUser
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getAllOragnListCommon"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getAllOragnListCommon(HttpServletRequest req, HttpServletResponse res, @RequestParam("currentUser") String currentUser, @RequestParam("isView") boolean isView) throws Exception {
//检查下人事系统有删除的组织没
OrganSyncTask.taskInstance.syncRemoteOrgan();
//获取当前用户的有权限的组织结构,跟授权有关
ArrayList<Object> allOrgans = TieSheSysOrgService.getInstance().getAllOragnListCommon(currentUser, isView);
return Response.ok(allOrgans);
}
/**
* 获取本地下级组织机构
*
* @param req
* @param res
* @param provinceId
* @param orgId
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getOrgNextInfo"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getOrgNextInfo(HttpServletRequest req, HttpServletResponse res, @RequestParam("provinceId") String provinceId, @RequestParam("orgId") String orgId, @RequestParam("from") String from) throws Exception {
//from 1 组织树, 2 加人的组织树
ArrayList<SecondOrganModel> orgs = RemoteReqService.getInstance().getNextOrganInfo(provinceId, orgId, from);
return Response.ok(orgs);
}
@RequestMapping(
value = {"/tieshe/getHrOrgNextInfo"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getHrOrgNextInfo(HttpServletRequest req, HttpServletResponse res, @RequestParam("provinceId") String provinceId, @RequestParam("orgId") String orgId, @RequestParam("from") String from) throws Exception {
//from 1 组织树, 2 加人的组织树
ArrayList<SecondOrganModel> orgs = RemoteReqService.getInstance().getHrNextOrganInfo(provinceId, orgId, from);
return Response.ok(orgs);
}
/**
* 获取当前用户在某个机构下的所有授权对象
*
* @param req
* @param res
* @param organId
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getUsersInOrgan"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getUsersInOrgan(HttpServletRequest req, HttpServletResponse res, @RequestParam("organId") String organId, @RequestParam("searchType") int searchType, @RequestParam("searchUserName") String searchUserName, @RequestParam("orgCode") String orgCode) throws Exception {
FineLoggerFactory.getLogger().info("organId:" + organId);
String currentUser = TeSheUtil.getCurrentLoginUser(req);
//获取该机构下的授权对象, searchType 1 本级 2 所有下级
List<UserInOrganEntity> userOrgans0 = UserInOrganService.getInstance().getUsersInOrgan(searchUserName,orgCode,currentUser,searchType,organId);
return Response.ok(userOrgans0);
}
/**
* 给某个机构组织添加授权对象
*
* @param req
* @param res
* @param param
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/addUsersInOrgan"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response addUsersInOrgan(HttpServletRequest req, HttpServletResponse res, @RequestParam("param") String param) throws Exception {
//解析参数
Object obj = JSONUtils.parse(param);
String provinceId = "";
String organId = "";
String organName = "";
String orgCode = "";
String orgType = "";
if (obj instanceof LinkedHashMap) {
LinkedHashMap itemMap = (LinkedHashMap) obj;
provinceId = itemMap.get("provinceId").toString();
organId = itemMap.get("companyId").toString();
organName = itemMap.get("companyName").toString();
String orgFullPath = "中国铁建";
if ("-1".equals(provinceId) == false) {
TieSheSysOrgEntity entity = TieSheSysOrgDBAUtil.getInstance().getEntityByOrgId(organId);
if (entity != null) {
orgFullPath = entity.getFullPath();
}
}
orgCode = itemMap.get("orgCode").toString();
orgType = itemMap.get("orgType").toString();
ArrayList users = (ArrayList) itemMap.get("users");
String currentUser = TeSheUtil.getCurrentLoginUser(req);
String ipaddress = getIpAddr(req);
String currentFullpath = this.userAndOrgFullPathMap.get(currentUser);
String realUserName = this.getUserRealName(TeSheUtil.getCurrentLoginUser(req));
//参数准备完毕
UserInOrganService.getInstance().addUserInOrgan(users,provinceId,organId,orgCode,currentUser,orgFullPath,organName,orgType,ipaddress,currentFullpath,realUserName);
}
return Response.ok("ok");
}
/**
* 删除某个组织下的某个授权用户
*
* @param req
* @param res
* @param ids
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/deleteUsersInOrgan"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response deleteUsersInOrgan(HttpServletRequest req, HttpServletResponse res, @RequestParam("ids") String ids, @RequestParam("orgCode") String orgCode) throws Exception {
FineLoggerFactory.getLogger().info("ids:" + ids);
String[] idArr = ids.split(",");
String currentUser = TeSheUtil.getCurrentLoginUser(req);
String ipaddress = getIpAddr(req);
String currentFullpath = this.userAndOrgFullPathMap.get(currentUser);
String realUserName = this.getUserRealName(TeSheUtil.getCurrentLoginUser(req));
for (String id : idArr) {
UserInOrganService.getInstance().deleteUsersInOrgan(id,currentUser,ipaddress,currentFullpath,realUserName,orgCode);
}
return Response.ok("ok");
}
/**
* 搜素这些机构下的授权对象有哪些
*
* @param req
* @param res
* @param topIds
* @param username
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/searchUserInOrgan"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response searchUserInOrgan(HttpServletRequest req, HttpServletResponse res, @RequestParam("topIds") String topIds, @RequestParam("username") String username) throws Exception {
ArrayList<OrganUserModelExtend> allOrgans = RemoteReqService.getInstance().searchUserInOrgan(topIds, username);
return Response.ok(allOrgans);
}
/**
* 普通用户从远程获取某个组织机构下的用户
* 当组织机构树点开岗位后就通过该方法查询岗位下的所有用户
*
* @param req
* @param res
* @param provinceId
* @param companyId
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getOrganUserInfos"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getOrganUserInfos(HttpServletRequest req, HttpServletResponse res, @RequestParam("provinceId") String provinceId, @RequestParam("companyId") String companyId) throws Exception {
//第一步先查出这个人被赋予了几个组织,然后需要把这个组织下的所有人查出来。
String result = RemoteReqService.getInstance().getOragnUserInfo(provinceId, companyId);
ArrayList<OrganUserModel> datas = new ArrayList<>();
if (result.equals("[]")) {
} else {
Object obj = JSONUtils.parse(result);
iterateOrganUser(datas, obj, "-1", provinceId);
for (OrganUserModel model : datas) {
model.setOrginId(companyId);
}
}
return Response.ok(datas);
}
/**
* admin用户获取所有的组织下的用户
* 添加授权对象组织机构树用的
*
* @param req
* @param res
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getAdminOrganUserInfos"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getAdminOrganUserInfos(HttpServletRequest req, HttpServletResponse res) throws Exception {
ArrayList<OrganUserModel> datas = TieSheSysOrgService.getInstance().getAdminOrganUserInfos();
FineLoggerFactory.getLogger().info("get datas");
return Response.ok(datas);
}
/**
* 普通用户获取所有的组织下的用户
* 添加授权对象组织机构树用的
*
* @param req
* @param res
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getCommonOrganUserInfos"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getCommonOrganUserInfos(HttpServletRequest req, HttpServletResponse res) throws Exception {
String currentUser = TeSheUtil.getCurrentLoginUser(req);
ArrayList<OrganUserModel> datas = UserInOrganService.getInstance().getCommonOrganUserInfos(currentUser);
return Response.ok(datas);
}
/**
* 普通用户获取授权菜单
*
* @param req
* @param res
* @param loginUserName 待授权用户的登录名
* @param view
* @param operatorUserId 待授权用户是谁添加的
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getCommonAuthorityMenuInfo"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getCommonAuthorityMenuInfo(HttpServletRequest req, HttpServletResponse res, @RequestParam("loginUserName") String loginUserName, @RequestParam("view") boolean view, @RequestParam("operatorUserId") String operatorUserId, @RequestParam("orgCode") String orgCode) throws Exception {
FineLoggerFactory.getLogger().info("普通用户获取授权菜单项");
//loginUserName待授权用户的id,
//先看下待授权用户是登录用户创建的不,这里有可能不是登陆人创建的,需要去找她的创建人,才能正确找到菜单
if (operatorUserId.equals("admin")) {//如果这个待授权用户是admin添加的,
operatorUserId = TeSheUtil.getCurrentLoginUser(req);
}
ArrayList<UserAuthorityModel> userAuthorityModels = UserRoleMenuService.getInstance().getCommonAuthorityMenuInfo(operatorUserId,loginUserName,orgCode,view);
return Response.ok(userAuthorityModels);
}
/**
* //admin获取授权菜单
*
* @param req
* @param res
* @param loginUserName 表格中选择用户的登录名
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getAdminAuthorityMenuInfo"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getAdminAuthorityMenuInfo(HttpServletRequest req, HttpServletResponse res, @RequestParam("loginUserName") String loginUserName, @RequestParam("orgCode") String orgCode) throws Exception {
FineLoggerFactory.getLogger().info("获取授权菜单项");
ArrayList<UserAuthorityModel> userAuthorityModels = UserRoleMenuService.getInstance().getAdminAuthorityMenuInfo(loginUserName,orgCode);
return Response.ok(userAuthorityModels);
}
/**
* 批量授权
*
* @param req
* @param res
* @return
*/
@RequestMapping(
value = {"/tieshe/setUserAuthorityByBatch"},
method = {RequestMethod.POST}
)
@ResponseBody
public Response setUserAuthorityByBatch(HttpServletRequest req, HttpServletResponse res, @RequestBody AuthorityBean authorityBean) throws Exception {
FineLoggerFactory.getLogger().info("开始批量授权");
//获取相关参数
String provinceId = authorityBean.getProvinceId();
String orgId = authorityBean.getOrgId();
String orgName = authorityBean.getOrgName();
String authorityInfos = authorityBean.getAuthorityInfos();
String authorityUserName = authorityBean.getAuthorityUserName();
String userName = authorityBean.getUserName();
String organCode = authorityBean.getOrgCode();
String currentUser = TeSheUtil.getCurrentLoginUser(req);
String ip = getIpAddr(req);
String userFullPath = this.userAndOrgFullPathMap.get(currentUser);
String realName = this.getUserRealName(TeSheUtil.getCurrentLoginUser(req));
UserRoleMenuService.getInstance().setUserAuthorityByBatch(authorityUserName,userName,currentUser,organCode,authorityInfos,provinceId,orgId,orgName,ip,userFullPath,realName);
return Response.ok("ok");
}
/**
* 查询管理日志
* http://localhost:8075/webroot/decision/tieshe/getAllLogs?page=1&count=20
* @param req
* @param res
* @param page
* @param count
* @param startDate
* @param endDate
* @param operateName
* @param operateType
* @param operateIp
* @param operateDescn
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getAllLogs"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getAllLogs(HttpServletRequest req, HttpServletResponse res, @RequestParam("page") int page, @RequestParam("count") int count, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate, @RequestParam("operateName") String operateName, @RequestParam("operateType") String operateType, @RequestParam("operateIp") String operateIp, @RequestParam("operateDescn") String operateDescn) throws Exception {
Map<String, Object> allLogs = getAllLogsUtil(req, page, count, startDate, endDate, operateName, operateType, operateIp, operateDescn);
FineLoggerFactory.getLogger().info("获取所有日志。。。。");
return Response.ok(allLogs);
}
/**
* 导出管理日志
* http://localhost:8075/webroot/decision/tieshe/getAllLogs?page=1&count=20
* @param req
* @param res
* @param page
* @param count
* @param startDate
* @param endDate
* @param operateName
* @param operateType
* @param operateIp
* @param operateDescn
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/exportAllLogs"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response exportAllLogs(HttpServletRequest req, HttpServletResponse res, @RequestParam("page") int page, @RequestParam("count") int count, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate, @RequestParam("operateName") String operateName, @RequestParam("operateType") String operateType, @RequestParam("operateIp") String operateIp, @RequestParam("operateDescn") String operateDescn) throws Exception {
Map<String, Object> allLogs = getAllLogsUtil(req, page, EXPORT_EXCEL_COUNT, startDate, endDate, operateName, operateType, operateIp, operateDescn);
String excelName = TieSheOperateLogService.getInstance().exportAllLogs(allLogs);
return Response.ok(excelName);
}
/**
* 查询操作日志
*http://localhost:8075/webroot/decision/tieshe/getAllLogs?page=1&count=20
* @param req
* @param res
* @param page
* @param count
* @param startDate
* @param endDate
* @param operateName
* @param operateType
* @param operateIp
* @param operateDescn
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/getAllViewLogs"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response getAllViewLogs(HttpServletRequest req, HttpServletResponse res, @RequestParam("page") int page, @RequestParam("count") int count, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate, @RequestParam("operateName") String operateName, @RequestParam("operateType") String operateType, @RequestParam("operateIp") String operateIp, @RequestParam("operateDescn") String operateDescn) throws Exception {
DataList dataList = this.searchExecuteMessageLogs(req, page, count, startDate, endDate, operateName, operateType, operateIp, operateDescn);
return Response.ok(dataList);
}
/**
* 导出操作日志
*http://localhost:8075/webroot/decision/tieshe/getAllLogs?page=1&count=20
* @param req
* @param res
* @param page
* @param count
* @param startDate
* @param endDate
* @param operateName
* @param operateType
* @param operateIp
* @param operateDescn
* @return
* @throws Exception
*/
@RequestMapping(
value = {"/tieshe/exportAllViewLogs"},
method = {RequestMethod.GET}
)
@ResponseBody
public Response exportAllViewLogs(HttpServletRequest req, HttpServletResponse res, @RequestParam("page") int page, @RequestParam("count") int count, @RequestParam("startDate") String startDate, @RequestParam("endDate") String endDate, @RequestParam("operateName") String operateName, @RequestParam("operateType") String operateType, @RequestParam("operateIp") String operateIp, @RequestParam("operateDescn") String operateDescn) throws Exception {
DataList dataList = this.searchExecuteMessageLogs(req, page, EXPORT_EXCEL_COUNT, startDate, endDate, operateName, operateType, operateIp, operateDescn);
String excelName = TieSheOperateLogService.getInstance().exportAllViewLogs(dataList);
return Response.ok(excelName);
}
private void iterateOrganUser(ArrayList<OrganUserModel> datas, Object obj, String pid, String provinceId) {
if (obj instanceof ArrayList) {
ArrayList<LinkedHashMap> arrs = (ArrayList<LinkedHashMap>) obj;
if (arrs != null && arrs.size() > 0) {
for (LinkedHashMap itemMap : arrs) {
OrganUserModel model = new OrganUserModel();
datas.add(model);
model.setProviderId(provinceId);
model.setId(Integer.parseInt(itemMap.get("id").toString()));
model.setOrder(Integer.parseInt(itemMap.get("order").toString()));
model.setText(itemMap.get("name").toString());
model.setValue(model.getText());
model.setMain((boolean) itemMap.get("mainPosition"));
}
}
}
}
private Map<String, Object> getAllLogsUtil(HttpServletRequest req, int page, int count, String startDate, String endDate, String operateName, String operateType, String operateIp, String operateDescn) throws Exception {
String loginUser = TeSheUtil.getCurrentLoginUser(req);
Map<String, Object> allLogs = TieSheOperateLogService.getInstance().findAllLog(loginUser, page, count, startDate, endDate, operateName, operateType, operateIp, operateDescn);
return allLogs;
}
/**
* 查询系统底层日志
*/
private DataList searchExecuteMessageLogs(HttpServletRequest req, int page, int count, String startDate, String endDate, String operateName, String operateType, String operateIp, String operateDescn) throws Exception {
String currentUser = TeSheUtil.getCurrentLoginUser(req);
return TieSheOperateLogService.getInstance().searchExecuteMessageLogs(currentUser, page, count, startDate, endDate, operateName, operateType, operateIp, operateDescn);
}
/**
* 判断该用户是否是中国铁建下的用户
*
* @param currentUser
* @return
*/
private boolean isLikeAdminUser(String currentUser) {
List<UserInOrganEntity> allDatas = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByUserId(currentUser); //TieSheDBAcessProvi
// TieSheSysOrgEntity root = TieSheSysOrgService.getInstance().getRoot();
for (UserInOrganEntity entity : allDatas) {
if (entity.getOrganCode().equals(TieSheController.ROOT_ORGCODE)) {//ROOT_ORGCODE)) {
return true;
}
}
return false;
}
private String getIpAddr(HttpServletRequest request) {
String remoteAddr = request.getHeader("X-Forwarded-For");
if (StringUtil.isBlank(remoteAddr)) {
remoteAddr = request.getHeader("Proxy-Client-IP");
}
if (StringUtil.isBlank(remoteAddr)) {
remoteAddr = request.getHeader("WL-Proxy-Client-IP");
}
return remoteAddr != null ? remoteAddr : request.getRemoteAddr();
}
private String getUserRealName(String userId) {
if (userAndRealNameMap.containsKey(userId)) {
return userAndRealNameMap.get(userId);
}
return userId;
}
//铁建请求需要的token
public static String tieSheToken;
}

12
src/main/java/com/fr/plugin/teshe/controller/TieSheControllerProvider.java

@ -0,0 +1,12 @@
package com.fr.plugin.teshe.controller;
import com.fr.decision.fun.impl.AbstractControllerRegisterProvider;
public class TieSheControllerProvider extends AbstractControllerRegisterProvider {
@Override
public Class<?>[] getControllers() {
return new Class[]{
TieSheController.class
};
}
}

28
src/main/java/com/fr/plugin/teshe/entity/TieSheDBAccessProvider.java

@ -0,0 +1,28 @@
package com.fr.plugin.teshe.entity;
import com.fr.plugin.db.AbstractDBAccessProvider;
import com.fr.stable.db.accessor.DBAccessor;
import com.fr.stable.db.dao.DAOProvider;
public class TieSheDBAccessProvider extends AbstractDBAccessProvider {
public static DBAccessor tieSheDbAccessor;
@Override
public DAOProvider[] registerDAO() {
return new DAOProvider[]{
UserInOrganDAO.DAO,
TieSheFiliRptDAO.DAO,
TieSheRoleOperateLogDAO.DAO,
UserRoleMenuItemDAO.DAO,
TieSheSysOrgDAO.DAO
};
}
@Override
public void onDBAvailable(DBAccessor dbAccessor) {
TieSheDBAccessProvider.tieSheDbAccessor = dbAccessor;
}
}

49
src/main/java/com/fr/plugin/teshe/entity/TieSheFiliRptDAO.java

@ -0,0 +1,49 @@
package com.fr.plugin.teshe.entity;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.HashMap;
import java.util.List;
public class TieSheFiliRptDAO extends BaseDAO<TieSheFiliRptEntity> {
public TieSheFiliRptDAO(DAOSession daoSession) {
super(daoSession);
}
public void updateTaskPersonInfo(String userName) throws Exception {
QueryCondition condition = QueryFactory.create();
condition.addRestriction(RestrictionFactory.eq("taskPerson",userName));
List<TieSheFiliRptEntity> entitys = getSession().find(condition,getEntityClass());
FineLoggerFactory.getLogger().info(userName+" 查询TieSheFiliRptEntity 一共查询到要更新的信息条数为:"+entitys.size());
for(TieSheFiliRptEntity entity:entitys){
HashMap<String, Object> params = new HashMap<>();
params.put("taskPerson", null);
params.put("taskPersonRealName", null);
getSession().update(params, QueryFactory.create().addRestriction(RestrictionFactory.eq("id", entity.getId())), getEntityClass());
}
}
@Override
protected Class<TieSheFiliRptEntity> getEntityClass() {
return TieSheFiliRptEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return TieSheFiliRptEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return TieSheFiliRptDAO.class;
}
};
}

154
src/main/java/com/fr/plugin/teshe/entity/TieSheFiliRptEntity.java

@ -0,0 +1,154 @@
package com.fr.plugin.teshe.entity;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
@Entity
@Table(name = "fill_rpt")
public class TieSheFiliRptEntity extends BaseEntity {
@Column(name = "dpt_id")
private String dptId;
@Column(name = "rpt_name")
private String rptName;
@Column(name = "rpt_order")
private Integer rptOrder;
@Column(name = "status_cycle")
private Integer statusCycle;
@Column(name = "rpt_path")
private String rptPath;
@Column(name = "rpt_type")
private String rptType;
@Column(name = "is_auto")
private Integer isAuto;
@Column(name = "table_name")
private String tableName;
@Column(name = "task_org_name")
private String taskOrgName;
@Column(name = "task_person")
private String taskPerson;
@Column(name = "task_org_realname")
private String taskOrgRealName;
@Column(name = "task_person_realname")
private String taskPersonRealName;
@Column(name = "belong_org")
private String belongOrg;
public void setDptId(String dptId) {
this.dptId = dptId;
}
public void setRptName(String rptName) {
this.rptName = rptName;
}
public void setRptOrder(Integer rptOrder) {
this.rptOrder = rptOrder;
}
public void setStatusCycle(Integer statusCycle) {
this.statusCycle = statusCycle;
}
public void setRptPath(String rptPath) {
this.rptPath = rptPath;
}
public void setRptType(String rptType) {
this.rptType = rptType;
}
public void setIsAuto(Integer isAuto) {
this.isAuto = isAuto;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public void setTaskOrgName(String taskOrgName) {
this.taskOrgName = taskOrgName;
}
public void setTaskPerson(String taskPerson) {
this.taskPerson = taskPerson;
}
public void setTaskOrgRealName(String taskOrgRealName) {
this.taskOrgRealName = taskOrgRealName;
}
public void setTaskPersonRealName(String taskPersonRealName) {
this.taskPersonRealName = taskPersonRealName;
}
public void setBelongOrg(String belongOrg) {
this.belongOrg = belongOrg;
}
public String getDptId() {
return dptId;
}
public String getRptName() {
return rptName;
}
public Integer getRptOrder() {
return rptOrder;
}
public Integer getStatusCycle() {
return statusCycle;
}
public String getRptPath() {
return rptPath;
}
public String getRptType() {
return rptType;
}
public Integer getIsAuto() {
return isAuto;
}
public String getTableName() {
return tableName;
}
public String getTaskOrgName() {
return taskOrgName;
}
public String getTaskPerson() {
return taskPerson;
}
public String getTaskOrgRealName() {
return taskOrgRealName;
}
public String getTaskPersonRealName() {
return taskPersonRealName;
}
public String getBelongOrg() {
return belongOrg;
}
}

156
src/main/java/com/fr/plugin/teshe/entity/TieSheRoleOperateLogDAO.java

@ -0,0 +1,156 @@
package com.fr.plugin.teshe.entity;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.data.DataList;
import com.fr.stable.query.restriction.Restriction;
import com.fr.stable.query.restriction.RestrictionFactory;
import com.fr.stable.query.restriction.impl.LikeRestriction;
import com.crcc.org.entity.LogEntity;
import java.util.*;
public class TieSheRoleOperateLogDAO extends BaseDAO<LogEntity>{
//public class TieSheRoleOperateLogDAO extends BaseDAO<TieSheRoleOperateLogEntity> {
public TieSheRoleOperateLogDAO(DAOSession daoSession) {
super(daoSession);
}
/**
* 增加日志实体
* @param entity
* @throws Exception
*/
public void addEntity(TieSheRoleOperateLogEntity entity) throws Exception {
// entity.setId();
LogEntity en = new LogEntity();
en.setId(UUID.randomUUID().toString());
en.setOpUserName(entity.getOpUserName());
en.setOpType(entity.getOpType());
en.setOpDescn(entity.getOpDescn());
en.setCreateDate(entity.getCreateDate());
en.setOpIp(entity.getOpIp());
en.setUserOrgCode(entity.getUserOrgCode());
en.setUserOrgFullPath(entity.getUserOrgFullPath());
getSession().persist(en);
}
/**
* 根据操作人机构code页数操作开始结束时间来查询
* @param operatorName
* @param orgCodes
* @param page
* @param count
* @param startDate
* @param endDate
* @param operateName
* @param operateType
* @param operateIp
* @param operateDescn
* @return
* @throws Exception
*/
public Map<String, Object> getAllLogs(String operatorName, List<String> orgCodes, int page, int count,String startDate,String endDate, String operateName, String operateType, String operateIp, String operateDescn) throws Exception{
Map<String, Object> result = new HashMap();
QueryCondition condition = QueryFactory.create();
if(!"".equals(startDate)){
condition.addRestriction(RestrictionFactory.gte("createDate",startDate));
}
if(!"".equals(endDate)){
condition.addRestriction(RestrictionFactory.lte("createDate",endDate));
}
List<Restriction> restions = new ArrayList<>();
for(String orgCode : orgCodes){
restions.add(new LikeRestriction("userOrgCode",orgCode));
}
condition.addRestriction(RestrictionFactory.or(restions));
if(operatorName.equals("admin") == false){
condition.addRestriction(RestrictionFactory.neq("opUserName","admin(admin)"));
}
condition.addSort("createDate",true);
if("".equals(operateName) == false){
condition.addRestriction(RestrictionFactory.like("opUserName",operateName));
}
if("".equals(operateDescn) == false){
condition.addRestriction(RestrictionFactory.like("opDescn",operateDescn));
}
if("".equals(operateIp) == false){
condition.addRestriction(RestrictionFactory.like("opIp",operateIp));
}
if("".equals(operateType) == false && "0".equals(operateType) == false){
condition.addRestriction(RestrictionFactory.eq("opType",Integer.parseInt(operateType)));
}
condition = this.getPageQueryCondition(page, count, "", "", condition);
DataList<LogEntity> entitys = this.getSession().findWithTotalCount(condition,getEntityClass());
List<TieSheRoleOperateLogEntity> datas = new ArrayList<>();
for(LogEntity en1:entitys.getList()){
TieSheRoleOperateLogEntity en2 = new TieSheRoleOperateLogEntity();
en2.fromOrgEntity(en1);
datas.add(en2);
}
DataList<TieSheRoleOperateLogEntity> userEntityDataList = new DataList<>();
userEntityDataList.setList(datas);
result.put("items", userEntityDataList);
result.put("total", entitys.getTotalCount());
result.put("page", page);
return result;
}
//获取分页QueryCondition
QueryCondition getPageQueryCondition(int page, int count, String keyword, String searchBy, QueryCondition extraCondition) {
extraCondition = extraCondition == null ? QueryFactory.create() : extraCondition;
extraCondition.skip((long)((page - 1) * count)).count((long)count);
return extraCondition;
}
@Override
protected Class<LogEntity> getEntityClass() {
return LogEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return LogEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return TieSheRoleOperateLogDAO.class;
}
};
/*
@Override
protected Class<TieSheRoleOperateLogEntity> getEntityClass() {
return TieSheRoleOperateLogEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return TieSheRoleOperateLogEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return TieSheRoleOperateLogDAO.class;
}
};
*/
}

104
src/main/java/com/fr/plugin/teshe/entity/TieSheRoleOperateLogEntity.java

@ -0,0 +1,104 @@
package com.fr.plugin.teshe.entity;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
import com.crcc.org.entity.LogEntity;
//@Entity
//@Table(name = "tieshe_operatorlog_record6")
public class TieSheRoleOperateLogEntity extends BaseEntity {
public void fromOrgEntity(LogEntity entity){
this.setOpUserName(entity.getOpUserName());
this.setOpType(entity.getOpType());
this.setOpDescn(entity.getOpDescn());
this.setCreateDate(entity.getCreateDate());
this.setOpIp(entity.getOpIp());
this.setUserOrgCode(entity.getUserOrgCode());
this.setUserOrgFullPath(entity.getUserOrgFullPath());
}
@Column(name = "opUserName")//谁操作的
private String opUserName;
@Column(name = "opType") //操作类型 1 添加授权对象,2 删除授权对象,3 添加授权功能 4 删除授权功能,
private int opType;
@Column(name = "opDescn",length = 20000)
private String opDescn;
@Column(name = "createDate")
private String createDate;
@Column(name = "opIp")
private String opIp;
@Column(name = "userOrgCode")
private String userOrgCode;
@Column(name = "userOrgFullPath")
private String userOrgFullPath;
public String getUserOrgFullPath() {
return userOrgFullPath;
}
public void setUserOrgFullPath(String userOrgFullPath) {
this.userOrgFullPath = userOrgFullPath;
}
public String getUserOrgCode() {
return userOrgCode;
}
public void setUserOrgCode(String userOrgCode) {
this.userOrgCode = userOrgCode;
}
public void setOpUserName(String opUserName) {
this.opUserName = opUserName;
}
public void setOpType(int opType) {
this.opType = opType;
}
public void setOpDescn(String opDescn) {
this.opDescn = opDescn;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public void setOpIp(String opIp) {
this.opIp = opIp;
}
public String getOpUserName() {
return opUserName;
}
public int getOpType() {
return opType;
}
public String getOpDescn() {
return opDescn;
}
public String getCreateDate() {
return createDate;
}
public String getOpIp() {
return opIp;
}
}

183
src/main/java/com/fr/plugin/teshe/entity/TieSheSysOrgDAO.java

@ -0,0 +1,183 @@
package com.fr.plugin.teshe.entity;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import com.crcc.org.entity.OrgEntity;
import java.util.ArrayList;
import java.util.List;
public class TieSheSysOrgDAO extends BaseDAO<OrgEntity> {
//public class TieSheSysOrgDAO extends BaseDAO<TieSheSysOrgEntity> {
public TieSheSysOrgDAO(DAOSession daoSession) {
super(daoSession);
}
/**
* 获取中国铁建这个根的信息
* @return
* @throws Exception
*/
public TieSheSysOrgEntity getRoot() throws Exception {
/*
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("organCode", "0000"));
TieSheSysOrgEntity entity = getSession().findOne(condition,getEntityClass());
return entity;
*/
QueryCondition condition = null;
if(TieSheController.isLocal){
condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("jigouId", "1"));
}
else{
condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("code", TieSheController.ROOT_ORGCODE));
}
OrgEntity entity = getSession().findOne(condition,getEntityClass());
TieSheSysOrgEntity entity1 = new TieSheSysOrgEntity();
entity1.fromOrgEntity(entity);
return entity1;
}
public TieSheSysOrgEntity getEntityByCode(String organCode) throws Exception{
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("code", organCode));
OrgEntity entity = getSession().findOne(condition,getEntityClass());
if(entity != null){
TieSheSysOrgEntity entity1 = new TieSheSysOrgEntity();
entity1.fromOrgEntity(entity);
return entity1;
}
else{
return null;
}
}
/**
* 通过父id来查找子
* @param parentId
* @return
* @throws Exception
*/
public List<TieSheSysOrgEntity> getChildrenByParentId(String parentId) throws Exception{
/*
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("pid", parentId));
return getSession().find(condition,getEntityClass());
*/
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("parentId", parentId)).addRestriction(RestrictionFactory.eq("stopFlag",false));
List<OrgEntity> entitys = getSession().find(condition,getEntityClass());
List<TieSheSysOrgEntity> entitys1 = new ArrayList<>();
for(OrgEntity en:entitys){
TieSheSysOrgEntity en1 = new TieSheSysOrgEntity();
en1.fromOrgEntity(en);
entitys1.add(en1);
}
return entitys1;
}
/**
* 通过机构id来查找
* @param orgId
* @return
* @throws Exception
*/
public TieSheSysOrgEntity getEntityByOrgId(String orgId) throws Exception {
/*
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("organId", orgId));
TieSheSysOrgEntity entity = getSession().findOne(condition,getEntityClass());
return entity;
*/
QueryCondition condition = null;
if(TieSheController.isLocal){
condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("jigouId", orgId));
}
else{
condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("id", orgId));
}
OrgEntity entity = getSession().findOne(condition,getEntityClass());
TieSheSysOrgEntity entity1 = new TieSheSysOrgEntity();
entity1.fromOrgEntity(entity);
return entity1;
}
/**
* 通过机构id来查找该机构再整棵树上的排序符
* @param orgId
* @return
* @throws Exception
*/
public String getEntitySortPathByOrgId(String orgId) throws Exception {
TieSheSysOrgEntity entity = getEntityByOrgId(orgId);
ArrayList<String> sortList = new ArrayList<>();
String order = entity.getOrder();
if (order.length() == 1) {
order = "00" + order;
}
if (order.length() == 2) {
order = "0" + order;
}
sortList.add(order);
while(entity.getPid().equals("0") == false){
entity = getEntityByOrgId(entity.getPid());
order = entity.getOrder();
if (order.length() == 1) {
order = "00" + order;
}
if (order.length() == 2) {
order = "0" + order;
}
sortList.add(order);
}
String result = "";
for (int j = sortList.size()-1; j>=0; j--){
result+= sortList.get(j);
}
return result;
}
/*
@Override
protected Class<TieSheSysOrgEntity> getEntityClass() {
return TieSheSysOrgEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return TieSheSysOrgEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return TieSheSysOrgDAO.class;
}
};
*/
@Override
protected Class<OrgEntity> getEntityClass() {
return OrgEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return OrgEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return TieSheSysOrgDAO.class;
}
};
}

167
src/main/java/com/fr/plugin/teshe/entity/TieSheSysOrgEntity.java

@ -0,0 +1,167 @@
package com.fr.plugin.teshe.entity;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.stable.AssistUtils;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
import com.crcc.org.entity.OrgEntity;
//@Entity
//@Table(name = "sys_org")
public class TieSheSysOrgEntity extends BaseEntity{
public void fromOrgEntity(OrgEntity entity){
this.setId(entity.getId());
if(TieSheController.isLocal){
this.setOrganId(entity.getJigouId());
}
else{
this.setOrganId(entity.getId());
}
this.setOrder(entity.getSortCode());
this.setOrganName(entity.getName());
this.setShortName(entity.getShortName());
this.setPid(entity.getParentId());
this.setType(entity.getOrgType());
this.setOrganCode(entity.getCode());
this.setHrScope(entity.getHrScope());
this.setFullPath(entity.getFullPathName());
}
@Column(name = "jigou_id")
private String organId;
@Column(name = "sort_code")
private String order;
@Column(name = "name")
private String organName;
@Column(name = "short_Name")
private String shortName;
@Column(name = "parent_id")
private String pid;
@Column(name = "org_type")
private int type;
@Column(name = "code")
private String organCode;
@Column(name = "hr_scope") // 对应人事组织范围 格式为hr_123_1,二级单位id_单位id_组织类型'
private String hrScope;
@Column(name = "full_path_name")
private String fullPath;
@Column(name = "accept_type")
private Integer acceptType;
@Column(name = "virtual_flag")
private Boolean virtualFlag;
@Column(name = "delete_flag")
private Boolean deleteFlag;
public String getShortName() {
return shortName;
}
public void setShortName(String shortName) {
this.shortName = shortName;
}
public void setAcceptType(Integer acceptType) {
this.acceptType = acceptType;
}
public void setVirtualFlag(Boolean virtualFlag) {
this.virtualFlag = virtualFlag;
}
public void setDeleteFlag(Boolean deleteFlag) {
this.deleteFlag = deleteFlag;
}
public Integer getAcceptType() {
return acceptType;
}
public Boolean getVirtualFlag() {
return virtualFlag;
}
public Boolean getDeleteFlag() {
return deleteFlag;
}
public String getFullPath() {
return fullPath;
}
public void setFullPath(String fullPath) {
this.fullPath = fullPath;
}
public void setOrganId(String organId) {
this.organId = organId;
}
public void setOrder(String order) {
this.order = order;
}
public void setOrganName(String organName) {
this.organName = organName;
}
public void setPid(String pid) {
this.pid = pid;
}
public void setType(int type) {
this.type = type;
}
public void setOrganCode(String organCode) {
this.organCode = organCode;
}
public void setHrScope(String hrScope) {
this.hrScope = hrScope;
}
public String getOrganId() {
return organId;
}
public String getOrder() {
return order;
}
public String getOrganName() {
return organName;
}
public String getPid() {
return pid;
}
public int getType() {
return type;
}
public String getOrganCode() {
return organCode;
}
public String getHrScope() {
return hrScope;
}
}

138
src/main/java/com/fr/plugin/teshe/entity/UserInOrganDAO.java

@ -0,0 +1,138 @@
package com.fr.plugin.teshe.entity;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.List;
import java.util.UUID;
public class UserInOrganDAO extends BaseDAO<UserInOrganEntity> {
public UserInOrganDAO(DAOSession daoSession) {
super(daoSession);
}
/**
* 添加授权对象
* @param entity
* @throws Exception
*/
public void addEntity(UserInOrganEntity entity) throws Exception {
entity.setId(UUID.randomUUID().toString());
getSession().persist(entity);
}
/**
* 通过用户id机构id添加人来查询授权对象
* @param userId
* @param organId
* @param operatorUserId
* @return
* @throws Exception
*/
public UserInOrganEntity findEntityByUserIdAndOrganId(String userId,String organId,String operatorUserId) throws Exception {
QueryCondition condition = QueryFactory.create().addRestriction(RestrictionFactory.eq("userId", userId)).addRestriction(RestrictionFactory.eq("organId", organId)).addRestriction(RestrictionFactory.eq("operatorUserId", operatorUserId));
UserInOrganEntity entity = getSession().findOne(condition,getEntityClass());
return entity;
}
/**
* 获取所有的授权对象
* @return
* @throws Exception
*/
public List<UserInOrganEntity> getAllDatas() throws Exception {
return getSession().find(QueryFactory.create(),getEntityClass());
}
/**
* 通过登录用户名字来查询授权对象
* @param loginUserName
* @return
* @throws Exception
*/
public List<UserInOrganEntity> findEntityByLoginUserName(String loginUserName) throws Exception {
return getSession().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("loginUserName",loginUserName)),getEntityClass());
}
/**
* 通过用户id来查找授权对象
* @param userId
* @return
* @throws Exception
*/
public List<UserInOrganEntity> findEntityByUserId(String userId) throws Exception {
if("admin".equals(userId)){
return getSession().find(QueryFactory.create(),getEntityClass());
}
else{
return getSession().find(QueryFactory.create().addRestriction(RestrictionFactory.eq("userId",userId)),getEntityClass());
}
}
/**
* 通过用户id机构code来查询授权对象
* @param userId
* @param orgCode
* @return
* @throws Exception
*/
public UserInOrganEntity findEntityByUserIdAndOrgCode(String userId,String orgCode) throws Exception {
return getSession().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("organCode",orgCode)).addRestriction(RestrictionFactory.eq("userId",userId)),getEntityClass());
}
/**
* 通过机构code来查找哦授权对象
* @param orgCode
* @return
* @throws Exception
*/
public List<UserInOrganEntity> findEntityByOrgCode(String orgCode) throws Exception {
return getSession().find(QueryFactory.create().addRestriction(RestrictionFactory.like("organCode",orgCode)),getEntityClass());
}
/**
* 删除授权实体
* @param id
* @throws Exception
*/
public void removeEntity(String id) throws Exception {
getSession().remove(QueryFactory.create()
.addRestriction(RestrictionFactory.eq("id", id)),
this.getEntityClass());
}
/**
* 通过id获取授权对象
* @param id
* @return
* @throws Exception
*/
public UserInOrganEntity getEntityById(String id) throws Exception{
return getSession().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("id",id)),getEntityClass());
}
@Override
protected Class<UserInOrganEntity> getEntityClass() {
return UserInOrganEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return UserInOrganEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return UserInOrganDAO.class;
}
};
}

242
src/main/java/com/fr/plugin/teshe/entity/UserInOrganEntity.java

@ -0,0 +1,242 @@
package com.fr.plugin.teshe.entity;
import com.fr.stable.AssistUtils;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
//员工被分在某个组织下
@Entity
@Table(name = "tieshe_user_organ_conf6")
public class UserInOrganEntity extends BaseEntity {
//谁授权的,就是谁加的这人,那么一个人可以被不同的人加吗
@Column(name = "operatorUserId")
private String operatorUserId;
//授权用户
@Column(name = "userId")
private String userId;
@Column(name = "userName")
private String userName;
//授权类型
@Column(name = "userType")
private int userType; // 1 admin用户(加载中国铁建下的用户), 0 普通用户
//被授权的组织的provinceId
@Column(name = "provinceId")
private String provinceId;
//被授权的组织
@Column(name = "organId")
private String organId;
@Column(name = "organName")
private String organName;
@Column(name = "organFullPath")
private String organFullPath;
@Column(name = "organType") //授权组织的类型,1 组织,2 部门,3 岗位,用来确定点击它的子节点时,是继续查组织,还是查人了,如果是岗位就开始查人了。
private String organType;
@Column(name = "organCode")
private String organCode;
// 授权用户所属组织
@Column(name = "orginOrganId")
private String orginOrganId;
@Column(name = "orginOrganName")
private String orginOrganName;
@Column(name = "orginProvinceId")
private String orginProvinceId;
@Column(name = "createDate")
private String createDate;
@Column(name = "loginUserName")
private String loginUserName;
@Column(name = "isMain")
private String isMain; //是否是主岗位
@Column(name = "stationId")
private String stationId; //岗位id
//排序用
private String fullPathOrder;
public void setIsMain(String isMain) {
this.isMain = isMain;
}
public String getIsMain() {
return isMain;
}
public void setStationId(String stationId) {
this.stationId = stationId;
}
public String getStationId() {
return stationId;
}
public void setMain(String main) {
isMain = main;
}
public String isMain() {
return isMain;
}
public String getOrganFullPath() {
return organFullPath;
}
public void setOrganFullPath(String organFullPath) {
this.organFullPath = organFullPath;
}
public String getFullPathOrder() {
return fullPathOrder;
}
public void setFullPathOrder(String fullPathOrder) {
this.fullPathOrder = fullPathOrder;
}
public String getOrganType() {
return organType;
}
public void setOrganType(String organType) {
this.organType = organType;
}
public String getLoginUserName() {
return loginUserName;
}
public void setOrginProvinceId(String orginProvinceId) {
this.orginProvinceId = orginProvinceId;
}
public String getOrginProvinceId() {
return orginProvinceId;
}
public void setOrganCode(String organCode) {
this.organCode = organCode;
}
public String getOrganCode() {
return organCode;
}
public void setLoginUserName(String loginUserName) {
this.loginUserName = loginUserName;
}
public String getCreateDate() {
return createDate;
}
public void setCreateDate(String createDate) {
this.createDate = createDate;
}
public String getProvinceId() {
return provinceId;
}
public void setProvinceId(String provinceId) {
this.provinceId = provinceId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setOrganId(String organId) {
this.organId = organId;
}
public void setOrganName(String organName) {
this.organName = organName;
}
public void setOrginOrganId(String orginOrganId) {
this.orginOrganId = orginOrganId;
}
public void setOrginOrganName(String orginOrganName) {
this.orginOrganName = orginOrganName;
}
public String getUserId() {
return userId;
}
public String getUserName() {
return userName;
}
public String getOrganId() {
return organId;
}
public String getOrganName() {
return organName;
}
public String getOrginOrganId() {
return orginOrganId;
}
public String getOrginOrganName() {
return orginOrganName;
}
public String getOperatorUserId() {
return operatorUserId;
}
public void setUserType(int userType) {
this.userType = userType;
}
public int getUserType() {
return userType;
}
public void setOperatorUserId(String operatorUserId) {
this.operatorUserId = operatorUserId;
}
public boolean isAdminType(){
if(this.getUserType() == 1) return true;
else return false;
}
@Override
public String toString() {
return AssistUtils.toString(this);
}
}

551
src/main/java/com/fr/plugin/teshe/entity/UserRoleMenuItemDAO.java

@ -0,0 +1,551 @@
package com.fr.plugin.teshe.entity;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.context.PluginContexts;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.stable.db.dao.BaseDAO;
import com.fr.stable.db.dao.DAOProvider;
import com.fr.stable.db.session.DAOSession;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
public class UserRoleMenuItemDAO extends BaseDAO<UserRoleMenuItemEntity> {
public UserRoleMenuItemDAO(DAOSession daoSession) {
super(daoSession);
}
/**
* 添加或更新实体
* @param entity
* @throws Exception
*/
public void addEntityOrUpdate(UserRoleMenuItemEntity entity) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
UserRoleMenuItemEntity oldEntity = this.getUserRoleMenuItemEntityByUserIdAndMenuId(entity.getUserId(), entity.getMenuId());
if (oldEntity == null) {
entity.setId(UUID.randomUUID().toString());
getSession().persist(entity);
} else {
HashMap<String, Object> params = new HashMap<>();
params.put("authorityValue", entity.getAuthorityValue());
getSession().update(params, QueryFactory.create().addRestriction(RestrictionFactory.eq("id", oldEntity.getId())), getEntityClass());
}
}
}
/**
* 根据userid与menuid获取权限
* @param userId
* @param menuId
* @return
* @throws Exception
*/
public UserRoleMenuItemEntity getUserRoleMenuItemEntityByUserIdAndMenuId(String userId, String menuId) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
UserRoleMenuItemEntity entity = getSession().findOne(QueryFactory.create().addRestriction(RestrictionFactory.eq("userId", userId)).addRestriction(RestrictionFactory.eq("menuId", menuId)), this.getEntityClass());
return entity;
}
return null;
}
/**
* 更新权限值
* @param userId
* @param menuId
* @param authorityValue
* @throws Exception
*/
public void updateEntityByUserIdAndMenuId(String userId, String menuId, int authorityValue) throws Exception {
UserRoleMenuItemEntity oldEntity = this.getUserRoleMenuItemEntityByUserIdAndMenuId(userId, menuId);
if (oldEntity != null) {
HashMap<String, Object> params = new HashMap<>();
params.put("authorityValue", authorityValue);
getSession().update(params, QueryFactory.create().addRestriction(RestrictionFactory.eq("id", oldEntity.getId())), getEntityClass());
}
}
/**
* 删除权限
* @param userId
* @param menuId
* @throws Exception
*/
public void removeEntityByUserIdAndMenuId(String userId, String menuId) throws Exception {
UserRoleMenuItemEntity entity = this.getUserRoleMenuItemEntityByUserIdAndMenuId(userId, menuId);
if (entity != null) {
getSession().remove(QueryFactory.create()
.addRestriction(RestrictionFactory.eq("id", entity.getId())),
this.getEntityClass());
}
}
/**
* 删除权限
* @param id
* @throws Exception
*/
public void removeEntityById(String id) throws Exception {
getSession().remove(QueryFactory.create()
.addRestriction(RestrictionFactory.eq("id", id)),
this.getEntityClass());
}
/**
* 获取权限
* @param userId
* @param menuId
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> findAll(String userId,String menuId) throws Exception {
QueryCondition queryCondition = QueryFactory.create();
if(userId.equals("all") == false){
queryCondition.addRestriction(RestrictionFactory.eq("userId",userId));
}
if(menuId.equals("all") == false){
queryCondition.addRestriction(RestrictionFactory.eq("menuId",menuId));
}
return getSession().find(queryCondition,getEntityClass());
}
/**
* 根据用户id获取权限
* @param userId
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> findAllByUserId(String userId) throws Exception {
QueryCondition queryCondition = QueryFactory.create();
queryCondition.addRestriction(RestrictionFactory.eq("userId",userId));
return getSession().find(queryCondition,getEntityClass());
}
//升级后的方法
//下面权限需要跟组织绑定再一起了。
/**
*genuine用户id机构code来删除权限
* @param userId
* @param organCode
* @throws Exception
*/
public void deleteByUserIdAndOrgCode(String userId,String organCode) throws Exception{
QueryCondition queryCondition = QueryFactory.create();
queryCondition.addRestriction(RestrictionFactory.eq("userId",userId));
queryCondition.addRestriction(RestrictionFactory.eq("organCode",organCode));
List<UserRoleMenuItemEntity> allentitys = getSession().find(queryCondition,getEntityClass());
for(UserRoleMenuItemEntity eneity : allentitys){
getSession().remove(QueryFactory.create().addRestriction(RestrictionFactory.eq("id",eneity.getId())),getEntityClass());
}
}
/**
* 获取该用户在该机构及其最近父的工作授权数据管理功能数据
*
* @param userId
* @return
*/
public List<UserRoleMenuItemEntity> getWorkAuthorityManageMenuDatasAndParent(String userId,String orgCode) throws Exception {
List<UserRoleMenuItemEntity> list = new ArrayList<>();
if (PluginContexts.currentContext().isAvailable()) {
String orginOrgCode = orgCode;
while(orginOrgCode.length() > 8 && list.size() == 0){
list = getWorkAuthorityManageMenuDatas(userId,orginOrgCode);
orginOrgCode = orginOrgCode.substring(0,orginOrgCode.length()-1);
}
//如果还是为空,看这个用户再中国铁建下是否有授权数据
if(list.size() == 0)
list = getWorkAuthorityManageMenuDatas(userId,TieSheController.ROOT_ORGCODE);
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return list;
}
/**
* 获取该用户在该机构上工作授权数据管理功能数据
*
* @param userId
* @return
*/
private List<UserRoleMenuItemEntity> getWorkAuthorityManageMenuDatas(String userId,String orgCode) throws Exception {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,TieSheController.WORK_AUTHORITY_ID,orgCode,3);
queryCondition.addRestriction(RestrictionFactory.eq("authorityValue", 2));
return getSession().find(queryCondition, getEntityClass());
}
/**
* 获取某个用户在某个机构上是否有工作授权的查看权限
*
* @param userId
* @param orgCode
* @return
* @throws Exception
*/
public UserRoleMenuItemEntity getViewAuthorityInOrgan(String userId, String orgCode) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,TieSheController.WORK_AUTHORITY_ID,orgCode,1);
queryCondition.addRestriction(RestrictionFactory.eq("authorityValue", 2));
return getSession().findOne(queryCondition, getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return null;
}
/**
* 获取某个用户在某个机构上是否有授权查询的查看权限
*
* @param userId
* @param orgCode
* @return
* @throws Exception
*/
public UserRoleMenuItemEntity getViewAuthorityViewInOrgan(String userId, String orgCode) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,TieSheController.WORKD_AUTHORITY_VIEW_ID,orgCode,1);
queryCondition.addRestriction(RestrictionFactory.eq("authorityValue", 2));
return getSession().findOne(queryCondition, getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return null;
}
/**
* 获取某个用户在某个机构上是否有日志查看的的查看权限
*
* @param userId
* @param orgCode
* @return
* @throws Exception
*/
public UserRoleMenuItemEntity getViewOperateLogViewInOrgan(String userId, String orgCode) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,TieSheController.SYSTEM_LOG_ID,orgCode,1);
queryCondition.addRestriction(RestrictionFactory.eq("authorityValue", 2));
return getSession().findOne(queryCondition, getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return null;
}
/**
* 获取某个用户在某个机构上是否有工作授权的管理权限
*
* @param userId
* @param orgCode
* @return
* @throws Exception
*/
public UserRoleMenuItemEntity getManageAuthorityInOrgan(String userId, String orgCode) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,TieSheController.WORK_AUTHORITY_ID,orgCode,3);
queryCondition.addRestriction(RestrictionFactory.eq("authorityValue", 2));
return getSession().findOne(queryCondition, getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return null;
}
/**
* 获取该用户在所有组织上该授权菜单的查看权限数据
*
* @param userId 用户id
* @param menuId 菜单id
* @param authrotityValue 0 不限制1 关闭2 打开
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getAllViewAuthorityByAuthorityId(String userId, String menuId, int authrotityValue) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = QueryFactory.create();
queryCondition.addRestriction(RestrictionFactory.eq("userId", userId));
queryCondition.addRestriction(RestrictionFactory.eq("menuId", menuId));
queryCondition.addRestriction(RestrictionFactory.eq("authorityType", 1));
if (authrotityValue == 1 || authrotityValue == 2) {
queryCondition.addRestriction(RestrictionFactory.eq("authorityValue", authrotityValue));
}
return getSession().find(queryCondition, getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
return new ArrayList<>();
}
}
/**
* 获取该用户在所有组织上该授权菜单的查看管理数据
*
* @param userId 用户id
* @param menuId 菜单id
* @param authrotityValue 0 不限制1 关闭2 打开
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getAllManageAuthorityByAuthorityId(String userId, String menuId, int authrotityValue) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = QueryFactory.create();
queryCondition.addRestriction(RestrictionFactory.eq("userId", userId));
queryCondition.addRestriction(RestrictionFactory.eq("menuId", menuId));
queryCondition.addRestriction(RestrictionFactory.eq("authorityType", 3));
if (authrotityValue == 1 || authrotityValue == 2) {
queryCondition.addRestriction(RestrictionFactory.eq("authorityValue", authrotityValue));
}
return getSession().find(queryCondition, getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
return new ArrayList<>();
}
}
/**
* 设置用户在某个授权菜单在某个组织上的查看权限
* @param userId 用户id
* @param menuId 授权菜单id
* @param orgCode 机构code
* @param authorityValue 权限值 1 关闭2打开
* @throws Exception
*/
public void setViewAuthority(String userId, String menuId, String orgCode,int authorityValue) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,menuId,orgCode,1);
UserRoleMenuItemEntity entity = getSession().findOne(queryCondition,getEntityClass());
if(entity != null){//如果存在,就更新
HashMap<String, Object> params = new HashMap<>();
params.put("authorityValue", authorityValue);
getSession().update(params, QueryFactory.create().addRestriction(RestrictionFactory.eq("id", entity.getId())), getEntityClass());
}
else{//如果不存在,就添加
UserRoleMenuItemEntity entity1 = new UserRoleMenuItemEntity();
entity1.setId(UUID.randomUUID().toString());
entity1.setAuthorityType(1);
entity1.setAuthorityValue(authorityValue);
entity1.setUserId(userId);
entity1.setMenuId(menuId);
entity1.setOrganCode(orgCode);
try{
getSession().persist(entity1);
}
catch(Exception ex){
ex.printStackTrace();
}
}
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
}
/**
* 设置用户在某个授权菜单在某个组织上的维护权限
* @param userId 用户id
* @param menuId 授权菜单id
* @param orgCode 机构code
* @param authorityValue 权限值 1 关闭2打开
* @throws Exception
*/
public Boolean setMaintainAuthority(String userId, String menuId, String orgCode,int authorityValue) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,menuId,orgCode,4);
UserRoleMenuItemEntity entity = getSession().findOne(queryCondition,getEntityClass());
if(entity != null){//如果存在,就更新
HashMap<String, Object> params = new HashMap<>();
params.put("authorityValue", authorityValue);
getSession().update(params, QueryFactory.create().addRestriction(RestrictionFactory.eq("id", entity.getId())), getEntityClass());
}
else{//如果不存在,就添加
entity = new UserRoleMenuItemEntity();
entity.setId(UUID.randomUUID().toString());
entity.setAuthorityType(4);
entity.setAuthorityValue(authorityValue);
entity.setUserId(userId);
entity.setMenuId(menuId);
entity.setOrganCode(orgCode);
getSession().persist(entity);
}
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return true;
}
/**
* 设置用户在某个授权菜单在某个组织上的管理权限
* @param userId 用户id
* @param menuId 授权菜单id
* @param orgCode 机构code
* @param authorityValue 权限值 1 关闭2打开
* @throws Exception
*/
public Boolean setManageAuthority(String userId, String menuId, String orgCode,int authorityValue) throws Exception {
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(userId,menuId,orgCode,3);
UserRoleMenuItemEntity entity = getSession().findOne(queryCondition,getEntityClass());
if(entity != null){//如果存在,就更新
HashMap<String, Object> params = new HashMap<>();
params.put("authorityValue", authorityValue);
getSession().update(params, QueryFactory.create().addRestriction(RestrictionFactory.eq("id", entity.getId())), getEntityClass());
}
else{//如果不存在,就添加
entity = new UserRoleMenuItemEntity();
entity.setId(UUID.randomUUID().toString());
entity.setAuthorityType(3);
entity.setAuthorityValue(authorityValue);
entity.setUserId(userId);
entity.setMenuId(menuId);
entity.setOrganCode(orgCode);
getSession().persist(entity);
}
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return true;
}
/**
* 获取用户在某个组织上的某个授权菜单的授权数据
* @param userId
* @param menuId
* @param orgCode
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getUserRoleDataInOrgan(String userId,String menuId,String orgCode) throws Exception{
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = QueryFactory.create();
queryCondition.addRestriction(RestrictionFactory.eq("userId", userId));
queryCondition.addRestriction(RestrictionFactory.eq("menuId", menuId));
queryCondition.addRestriction(RestrictionFactory.eq("organCode", orgCode));
return getSession().find(queryCondition,getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return new ArrayList<>();
}
/**
* 获取用户再某个组织上的授权数据
* @param userId
* @param orgCode
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getUserAuthorityDataInOrgan(String userId,String orgCode) throws Exception{
if (PluginContexts.currentContext().isAvailable()) {
QueryCondition queryCondition = QueryFactory.create();
queryCondition.addRestriction(RestrictionFactory.eq("userId", userId));
queryCondition.addRestriction(RestrictionFactory.eq("organCode", orgCode));
return getSession().find(queryCondition,getEntityClass());
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return new ArrayList<>();
}
public void removeAuthorityDataInOrgan(String userId,String orgCode) throws Exception{
List<UserRoleMenuItemEntity> allDatas = getUserAuthorityDataInOrgan(userId,orgCode);
for(UserRoleMenuItemEntity entity:allDatas){
removeEntityById(entity.getId());
}
}
/**
* 获取用户的某个授权菜单在某个组织及最近父亲的权限数据
* @param userId
* @param menuId
* @param orgCode
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getUserRoleDataInOrganAndParent(String userId,String menuId,String orgCode) throws Exception{
List<UserRoleMenuItemEntity> list = new ArrayList<>();
if (PluginContexts.currentContext().isAvailable()) {
String orginOrgCode = orgCode;
while(orginOrgCode.length() > 8 && list.size() == 0){
list = getUserRoleDataInOrgan(userId,menuId,orginOrgCode);
orginOrgCode = orginOrgCode.substring(0,orginOrgCode.length()-1);
}
//如果还是为空,看这个用户再中国铁建下是否有授权数据
if(list.size() == 0)
list = getUserRoleDataInOrgan(userId,menuId,TieSheController.ROOT_ORGCODE);
}
else{
FineLoggerFactory.getLogger().info("过期了,请联系商家");
}
return list;
}
private QueryCondition getQueryConditionByUserIdAndMenuIdAndOrganCodeAndType(String userId, String menuId, String orgCode,int authorityType){
QueryCondition queryCondition = QueryFactory.create();
queryCondition.addRestriction(RestrictionFactory.eq("userId", userId));
queryCondition.addRestriction(RestrictionFactory.eq("menuId", menuId));
queryCondition.addRestriction(RestrictionFactory.eq("organCode", orgCode));
queryCondition.addRestriction(RestrictionFactory.eq("authorityType", authorityType));
return queryCondition;
}
@Override
protected Class<UserRoleMenuItemEntity> getEntityClass() {
return UserRoleMenuItemEntity.class;
}
public final static DAOProvider DAO = new DAOProvider() {
@Override
public Class getEntityClass() {
return UserRoleMenuItemEntity.class;
}
@Override
public Class<? extends BaseDAO> getDAOClass() {
return UserRoleMenuItemDAO.class;
}
};
}

73
src/main/java/com/fr/plugin/teshe/entity/UserRoleMenuItemEntity.java

@ -0,0 +1,73 @@
package com.fr.plugin.teshe.entity;
import com.fr.stable.db.entity.BaseEntity;
import com.fr.third.javax.persistence.Column;
import com.fr.third.javax.persistence.Entity;
import com.fr.third.javax.persistence.Table;
/**
* 记录工作授权是否打开管理权限
* 存的是UserId-MenuItemId的映射关系
*/
@Entity
@Table(name = "tieshe_user_function_authority6")
public class UserRoleMenuItemEntity extends BaseEntity {
//授权用户
@Column(name = "userId")
private String userId;
//授权用户在这个组织的权限。同一个人在不同组织中授权不同
@Column(name = "organCode")
private String organCode;
//授权功能
@Column(name = "menuId")
private String menuId = "decision-management-user-role-assign";
@Column(name = "authorityType")
private int authorityType = 1; //1 查看,3 管理 对应底层三个类型 4 维护
@Column(name = "authorityValue")
private int authorityValue = 1; //1 关闭,2 打开
public int getAuthorityValue() {
return authorityValue;
}
public void setAuthorityValue(int authorityValue) {
this.authorityValue = authorityValue;
}
public String getUserId() {
return userId;
}
public String getMenuId() {
return menuId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public void setMenuId(String menuId) {
this.menuId = menuId;
}
public String getOrganCode() {
return organCode;
}
public void setOrganCode(String organCode) {
this.organCode = organCode;
}
public int getAuthorityType() {
return authorityType;
}
public void setAuthorityType(int authorityType) {
this.authorityType = authorityType;
}
}

87
src/main/java/com/fr/plugin/teshe/finerecordexecute/TieSheExecuteLogRestriction.java

@ -0,0 +1,87 @@
package com.fr.plugin.teshe.finerecordexecute;
import com.fr.intelli.webservice.log.restriction.ExecuteLogRestriction;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.ArrayList;
public class TieSheExecuteLogRestriction extends ExecuteLogRestriction {
private String ip;
private String operateName;
private String operateType;
private String operateDescn;
public QueryCondition createCommonQueryCondition(ArrayList<String> userIds) throws Exception {
ArrayList var1 = new ArrayList();
this.addTimeRangeRestriction(var1);
this.addUsernameRestriction(var1, "username");
// this.addIpRestriction(var1, "ip");
//this.addTypeRestriction(var1, "type");
// this.addTemplateNameRestriction(var1, "tname");
// this.addResourceRestriction(var1, "displayName");
QueryCondition var2 = this.initQueryCondition1();
if("".equals(getIp()) == false){
var2.addRestriction(RestrictionFactory.like("ip",getIp()));
}
if("".equals(getOperateDescn()) == false){
var2.addRestriction(RestrictionFactory.like("tname",getOperateDescn()));
}
if("".equals(getOperateName()) == false){
var2.addRestriction(RestrictionFactory.like("username",getOperateName()));
}
if("".equals(operateType) == false && "-1".equals(operateType) == false){
var2.addRestriction(RestrictionFactory.eq("type",Integer.parseInt(operateType)));
}
return var1.isEmpty() ? var2 : var2.addRestriction(RestrictionFactory.and(var1));
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public void setOperateName(String operateName) {
this.operateName = operateName;
}
public void setOperateType(String operateType) {
this.operateType = operateType;
}
public void setOperateDescn(String operateDescn) {
this.operateDescn = operateDescn;
}
public String getOperateName() {
return operateName;
}
public String getOperateType() {
return operateType;
}
public String getOperateDescn() {
return operateDescn;
}
public QueryCondition createAdminQueryCondition() throws Exception {
QueryCondition var2 = this.initQueryCondition1();
return var2;
}
QueryCondition initQueryCondition1() {
int var1 = this.getPage();
QueryCondition var2 = QueryFactory.create().skip(var1 > 0 ? (long)((var1 - 1) * this.getCount()) : 0L).count((long)this.getCount()).addSort("time", true);
return var2;
}
}

17
src/main/java/com/fr/plugin/teshe/jscss/MainJsCssBridge.java

@ -0,0 +1,17 @@
package com.fr.plugin.teshe.jscss;
import com.fr.decision.fun.impl.AbstractWebResourceProvider;
import com.fr.decision.web.MainComponent;
import com.fr.web.struct.Atom;
public class MainJsCssBridge extends AbstractWebResourceProvider {
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return TeSheMainDef.KEY;
}
}

32
src/main/java/com/fr/plugin/teshe/jscss/TeSheMainDef.java

@ -0,0 +1,32 @@
package com.fr.plugin.teshe.jscss;
import com.fr.web.struct.Component;
import com.fr.web.struct.Filter;
import com.fr.web.struct.browser.RequestClient;
import com.fr.web.struct.category.ScriptPath;
import com.fr.web.struct.category.StylePath;
public class TeSheMainDef extends Component {
public static final TeSheMainDef KEY = new TeSheMainDef();
public ScriptPath script(RequestClient client ) {
return ScriptPath.build("com/fr/plugin/teshe/jscss/userRole.js");
}
public StylePath style(RequestClient var1){
return StylePath.build("com/fr/plugin/teshe/jscss/userRole.css");
}
public Filter filter() {
return new Filter(){
@Override
public boolean accept() {
return true;
}
};
}
}

922
src/main/java/com/fr/plugin/teshe/services/RemoteReqService.java

@ -0,0 +1,922 @@
package com.fr.plugin.teshe.services;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.beans.OrganUserModelExtend;
import com.fr.plugin.teshe.beans.SecondOrganFullPathComparator;
import com.fr.plugin.teshe.beans.SecondOrganModel;
import com.fr.plugin.teshe.conf.ConfigXmlReader;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.TieSheSysOrgEntity;
import com.fr.third.alibaba.druid.support.json.JSONUtils;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*;
import com.fine.plugin.tools.HttpUtil;
/**
* 该service主要通过远程接口获取中国铁建那边发布出来的数据
*/
public class RemoteReqService {
private static RemoteReqService instance;
public static RemoteReqService getInstance(){
if(instance == null){
instance = new RemoteReqService();
}
return instance;
}
/**
* 获取中国铁建https请求需要的token
* @param base64str
* @return
*/
public String getTieSheToken(String base64str) {
String tieJianToken = "";
try {
URL url = new URL(ConfigXmlReader.getInstance().tokenReqUrl);
FineLoggerFactory.getLogger().info("开始获取token url:" + url);
HttpURLConnection conn = getConnection(url,"Basic " +base64str);
int statuCode = conn.getResponseCode();
if (statuCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof LinkedHashMap) {
LinkedHashMap linkObj = (LinkedHashMap) obj;
Object token = linkObj.get("access_token");
if (token != null) {
tieJianToken = token.toString();
}
}
FineLoggerFactory.getLogger().info("tieSheToken:" + tieJianToken);
} else {
FineLoggerFactory.getLogger().info("token获取失败.... statuCode:" + statuCode);
}
} catch (Exception e) {
e.printStackTrace();
FineLoggerFactory.getLogger().info("token获取失败.... :" + e.toString());
} finally {
return tieJianToken;
}
}
/**
* 查询出该授权对象的所有岗位id
* @param providerId
* @param userId
* @return
*/
public List<LinkedHashMap> getAllStationIdByUserId(String providerId, String userId) {
List<LinkedHashMap> stationIds = new ArrayList<>();
try {
String newUrl = ConfigXmlReader.getInstance().personStationUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{userid}", userId);
FineLoggerFactory.getLogger().info("根据用户id获取岗位idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList aa = (ArrayList) obj;
if (aa.size() > 0) {
for(Object objMap1 : aa){
LinkedHashMap objMap = (LinkedHashMap) objMap1;
/**
* map属性:
* type:
* id:
* name:
* code:
* order:
* mainPosition
*/
stationIds.add(objMap);
}
}
}
// FineLoggerFactory.getLogger().info("二级单位数据:" + obj);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return stationIds;
}
}
/**
* 看目标岗位id是否还存在
* @param providerId
* @param userId
* @param targetStationId
* @return
*/
public boolean isExistStation(String providerId, String userId,String targetStationId){
boolean isExist = false;
try {
String newUrl = ConfigXmlReader.getInstance().personStationUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{userid}", userId);
FineLoggerFactory.getLogger().info("根据用户id获取岗位idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList aa = (ArrayList) obj;
if (aa.size() > 0) {
for(Object objMap1 : aa) {
LinkedHashMap objMap = (LinkedHashMap) objMap1;
if (objMap != null && objMap.containsKey("id")) {
String stationId = objMap.get("id").toString();
if(stationId.equals(targetStationId) == true){
isExist = true;
}
}
}
}
}
// FineLoggerFactory.getLogger().info("二级单位数据:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return isExist;
}
}
/**
* 看目标岗位id是否还存在,如果存在还是主岗位不
* @param providerId
* @param userId
* @param targetStationId
* @return
*/
public boolean isExistMainStation(String providerId, String userId,String targetStationId){
boolean isExist = false;
try {
String newUrl = ConfigXmlReader.getInstance().personStationUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{userid}", userId);
FineLoggerFactory.getLogger().info("根据用户id获取岗位idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList aa = (ArrayList) obj;
if (aa.size() > 0) {
for(Object objMap1 : aa) {
LinkedHashMap objMap = (LinkedHashMap) objMap1;
if (objMap != null && objMap.containsKey("id")) {
String stationId = objMap.get("id").toString();
boolean isMain = (boolean)objMap.get("mainPosition");
if(stationId.equals(targetStationId) == true && isMain == true){
isExist = true;
}
}
}
}
}
// FineLoggerFactory.getLogger().info("二级单位数据:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return isExist;
}
}
/**
* 根据用户id获取第一个岗位id
* @param providerId
* @param userId
* @return
*/
public String getStationIdByUserId(String providerId, String userId) {
String stationId = "";
try {
String newUrl = ConfigXmlReader.getInstance().personStationUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{userid}", userId);
FineLoggerFactory.getLogger().info("根据用户id获取岗位idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList aa = (ArrayList) obj;
if (aa.size() > 0) {
LinkedHashMap objMap = (LinkedHashMap) aa.get(0);
if (objMap != null && objMap.containsKey("id")) {
stationId = objMap.get("id").toString();
}
}
}
// FineLoggerFactory.getLogger().info("二级单位数据:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return stationId;
}
}
/**
* 根据用户id获取主岗位idw
* @param providerId
* @param userId
* @return
*/
public String getMainStationIdByUserId(String providerId, String userId) {
String stationId = "";
try {
String newUrl = ConfigXmlReader.getInstance().personStationUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{userid}", userId);
FineLoggerFactory.getLogger().info("根据用户id获取岗位idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList aa = (ArrayList) obj;
if (aa.size() > 0) {
for(Object ob: aa){
LinkedHashMap objMap = (LinkedHashMap)ob;
boolean isMain = (boolean)objMap.get("mainPosition");
if(isMain == true){
stationId = objMap.get("id").toString();
}
}
}
}
// FineLoggerFactory.getLogger().info("二级单位数据:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return stationId;
}
}
/**
* 根据岗位id获取组织机构全路径
* @param providerId
* @param orgId
* @param asic 倒叙还是正序
* @param isVirtual 是否包含虚拟节点
* @return
*/
public String getOrgFullPath(String providerId, String orgId, boolean asic, boolean isVirtual) {
String fullPath = "";
try {
String newUrl = ConfigXmlReader.getInstance().orgPathUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{orgid}", orgId);
FineLoggerFactory.getLogger().info("根据岗位id获取组织机构全路径idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
fullPath = "";
ArrayList objArr = (ArrayList) obj;
if (asic == true) { //倒序
int leng = objArr.size();
for (int i = (leng - 1); i >= 0; i--) {
LinkedHashMap objMap = (LinkedHashMap) objArr.get(i);
if (isVirtual == true) {
if (objMap.containsKey("virtual") && (boolean) objMap.get("virtual") == true) {
} else {
fullPath += (objMap.get("name") + "/");
}
} else {
fullPath += (objMap.get("name") + "/");
}
}
fullPath = fullPath.substring(0, fullPath.length() - 1);
} else {
for (Object objItem : objArr) {
LinkedHashMap objMap = (LinkedHashMap) objItem;
if (isVirtual == true) {
if (objMap.containsKey("virtual") && (boolean) objMap.get("virtual") == true) {
} else {
fullPath += (objMap.get("name") + "/");
}
} else {
fullPath += (objMap.get("name") + "/");
}
}
fullPath = fullPath.substring(0, fullPath.length() - 1);
}
}
// FineLoggerFactory.getLogger().info("单位全路径:" + fullPath);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
fullPath = "error";
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return fullPath;
}
}
/**
* 根据岗位id获取组织机构的排序全路径
* @param providerId
* @param orgId
* @param asic
* @return
*/
public String getOrgFullPathSort(String providerId, String orgId, boolean asic) {
String fullPath = "";
try {
String newUrl = ConfigXmlReader.getInstance().orgPathUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{orgid}", orgId);
FineLoggerFactory.getLogger().info("根据岗位id获取组织机构全路径idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
fullPath = "";
ArrayList objArr = (ArrayList) obj;
if (asic == true) { //倒序
int leng = objArr.size();
for (int i = (leng - 1); i >= 0; i--) {
LinkedHashMap objMap = (LinkedHashMap) objArr.get(i);
String order = objMap.get("order").toString();
if (order.length() == 1) {
order = "00" + order;
}
if (order.length() == 2) {
order = "0" + order;
}
fullPath += (order);
}
//fullPath = fullPath.substring(0, fullPath.length() - 1);
} else {
for (Object objItem : objArr) {
LinkedHashMap objMap = (LinkedHashMap) objItem;
String order = objMap.get("order").toString();
if (order.length() == 1) {
order = "00" + order;
}
if (order.length() == 2) {
order = "0" + order;
}
fullPath += (order);
}
fullPath = fullPath.substring(0, fullPath.length() - 1);
}
}
// FineLoggerFactory.getLogger().info("二级单位数据:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return fullPath;
}
}
/**
* 获取下级组织
* @param provinceId
* @param companyId
* @param from
* @return
*/
public ArrayList<SecondOrganModel> getNextOrganInfo(String provinceId, String companyId, String from) {
ArrayList<SecondOrganModel> allOrgans = new ArrayList<>();
List<TieSheSysOrgEntity> children = TieSheSysOrgDBAUtil.getInstance().getChildrenByParentId(companyId);
for(TieSheSysOrgEntity entity:children){
SecondOrganModel parentModel = new SecondOrganModel(provinceId, entity.getOrganId());
allOrgans.add(parentModel);
parentModel.setId(provinceId + "_" + entity.getOrganId());
parentModel.setText(entity.getOrganName());
int order = Integer.parseInt(entity.getOrder());
parentModel.setOrder(order);
parentModel.setFullPathOrder(entity.getOrder());
parentModel.setIsParent(true);
parentModel.setOrganCode(entity.getOrganCode());
parentModel.setModelType(entity.getType());
}
Collections.sort(allOrgans, new SecondOrganFullPathComparator());
return allOrgans;
}
/**
* 获取hr下级组织
* @param provinceId
* @param companyId
* @param from
* @return
*/
public ArrayList<SecondOrganModel> getHrNextOrganInfo(String provinceId, String companyId, String from) {
ArrayList<SecondOrganModel> allOrgans = new ArrayList<>();
try {
String newUrl = ConfigXmlReader.getInstance().orgNextReqUrl;
newUrl = newUrl.replace("{providerId}", provinceId);
newUrl = newUrl.replace("{orgid}", companyId);
FineLoggerFactory.getLogger().info("获取所有下级组织url:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList arr = (ArrayList) obj;
for (Object linkObj : arr) {
if (linkObj instanceof LinkedHashMap) {
LinkedHashMap lhmMap = (LinkedHashMap) linkObj;
//临时方案,只要总部下的
if ("986436".equals(companyId)) {
if ("1".equals(from)) {
// if (lhmMap.get("name").toString().equals("机关")) {
SecondOrganModel parentModel = new SecondOrganModel(provinceId, lhmMap.get("id").toString());
allOrgans.add(parentModel);
parentModel.setId(provinceId + "_" + lhmMap.get("id").toString());
parentModel.setText(lhmMap.get("name").toString());
int order = (int) lhmMap.get("order");
parentModel.setOrder(order);
parentModel.setIsParent(true);
if (lhmMap.containsKey("virtual")) {
parentModel.setVirture((boolean) lhmMap.get("virtual"));
} else {
parentModel.setVirture(false);
}
parentModel.setOrganCode(lhmMap.get("code").toString());
if (lhmMap.containsKey("type")) {
parentModel.setModelType((int) lhmMap.get("type"));
}
// }
} else {
SecondOrganModel parentModel = new SecondOrganModel(provinceId, lhmMap.get("id").toString());
allOrgans.add(parentModel);
parentModel.setId(provinceId + "_" + lhmMap.get("id").toString());
parentModel.setText(lhmMap.get("name").toString());
int order = (int) lhmMap.get("order");
parentModel.setOrder(order);
parentModel.setIsParent(true);
if (lhmMap.containsKey("virtual")) {
parentModel.setVirture((boolean) lhmMap.get("virtual"));
} else {
parentModel.setVirture(false);
}
parentModel.setOrganCode(lhmMap.get("code").toString());
if (lhmMap.containsKey("type")) {
parentModel.setModelType((int) lhmMap.get("type"));
}
}
} else {
SecondOrganModel parentModel = new SecondOrganModel(provinceId, lhmMap.get("id").toString());
allOrgans.add(parentModel);
parentModel.setId(provinceId + "_" + lhmMap.get("id").toString());
parentModel.setText(lhmMap.get("name").toString());
int order = (int) lhmMap.get("order");
parentModel.setOrder(order);
parentModel.setIsParent(true);
if (lhmMap.containsKey("virtual")) {
parentModel.setVirture((boolean) lhmMap.get("virtual"));
} else {
parentModel.setVirture(false);
}
parentModel.setOrganCode(lhmMap.get("code").toString());
if (lhmMap.containsKey("type")) {
parentModel.setModelType((int) lhmMap.get("type"));
}
}
}
}
}
// FineLoggerFactory.getLogger().info("下级单位数据:" + obj);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return allOrgans;
}
}
/**
* 根据provinceid部门id获取部门信息
* @param providerId
* @param deptid
* @return
*/
public String getOrgDepInfo(String providerId, String deptid) {
String result = "";
try {
String newUrl = ConfigXmlReader.getInstance().getOrgDepUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{deptid}", deptid);
FineLoggerFactory.getLogger().info("根据provinceid,部门id获取部门信息url:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
result = parseStringHttpsReq(conn);
FineLoggerFactory.getLogger().info("部门信息:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
result = "error";
}
} catch (Exception e) {
e.printStackTrace();
result = "error";
} finally {
return result;
}
}
/**
* 根据provinceid部门id获取单位信息
* @param providerId
* @param orgid
* @return
*/
public String getOrgUnitInfo(String providerId, String orgid) {
String result = "";
try {
String newUrl = ConfigXmlReader.getInstance().getOrgUnit;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{orgid}", orgid);
FineLoggerFactory.getLogger().info("根据provinceid,部门id获取单位信息url:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
result = parseStringHttpsReq(conn);
FineLoggerFactory.getLogger().info("部门信息:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
result = "error";
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return result;
}
}
/**
* 实时查询用户的机构信息
*
* @param providerId
* @param userId
* @return
*/
public HashMap<String, String> getOrganInfoByUserId(String providerId, String userId) {
HashMap<String, String> maps = new HashMap<>();
try {
String newUrl = ConfigXmlReader.getInstance().personStationUrl;
newUrl = newUrl.replace("{providerId}", providerId);
newUrl = newUrl.replace("{userid}", userId);
FineLoggerFactory.getLogger().info("根据用户id获取岗位idurl:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList aa = (ArrayList) obj;
if (aa.size() > 0) {
LinkedHashMap objMap = (LinkedHashMap) aa.get(0);
if (objMap != null && objMap.containsKey("id")) {
maps.put("orgId", objMap.get("id").toString());
maps.put("orgCode", objMap.get("code").toString());
}
}
}
// FineLoggerFactory.getLogger().info("二级单位数据:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return maps;
}
}
/**
* /获取所有二级单位id
* @param isHaveRoot
* @return
*/
public ArrayList<SecondOrganModel> getSecondOrgan(boolean isHaveRoot) {
BufferedReader bufferedReader = null;
InputStream inputStream = null;
ArrayList<SecondOrganModel> allOrgans = new ArrayList<>();
TieSheSysOrgEntity root = TieSheSysOrgDBAUtil.getInstance().getRoot();
FineLoggerFactory.getLogger().info("root:" + root.getHrScope());
if (isHaveRoot == true) {
//初始化一个根节点
SecondOrganModel rootNode = new SecondOrganModel("hr", root.getOrganId());
rootNode.setLayer(0);
rootNode.setText(root.getOrganName());
rootNode.setOrganCode(root.getOrganCode());
rootNode.setIsParent(true);
rootNode.setModelType(1);
allOrgans.add(rootNode);
}
List<TieSheSysOrgEntity> children = TieSheSysOrgDBAUtil.getInstance().getChildrenByParentId(root.getOrganId());
for(TieSheSysOrgEntity entity:children){
String hrscope = entity.getHrScope();
String[] temps = hrscope.split("_");
String provinceId = temps[0];
String companyId = entity.getOrganId();
SecondOrganModel model = new SecondOrganModel(provinceId, companyId);
if (isHaveRoot == false) {
model.setModelType(entity.getType());
}
model.setHrOrgId(temps[1]);
model.setHrType(Integer.parseInt(temps[2]));
allOrgans.add(model);
model.setLayer(1);
model.setText(entity.getOrganName());
model.setIsParent(true);
model.setpId("hr"+"_"+root.getOrganId());// "-1_0");
model.setOrganCode(entity.getOrganCode());
}
return allOrgans;
}
/**
* 根据provinceId与CompanyId查询users
* @param provinceId
* @param companyId
* @return
*/
public String getOragnUserInfo(String provinceId, String companyId) {
String result = "{}";
// ArrayList<SecondOrganModel> allOrgans = new ArrayList<>();
try {
String newUrl = ConfigXmlReader.getInstance().personReqUrl;
newUrl = newUrl.replace("{providerId}", provinceId);
newUrl = newUrl.replace("{companyid}", companyId);
newUrl = newUrl.replace("{positionId}", companyId);
FineLoggerFactory.getLogger().info("获取所有组织下用户url:" + newUrl);
URL url = new URL(newUrl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(newUrl + "请求的状态信息为:" + statusCode);
if (statusCode == 200) {
result = parseStringHttpsReq(conn);
FineLoggerFactory.getLogger().info("user数据:" + result);
} else {
FineLoggerFactory.getLogger().info(newUrl + "请求失败");
}
} catch (Exception e) {
e.printStackTrace();
} finally {
return result;
}
}
public ArrayList<OrganUserModelExtend> searchUserInOrgan(String topIds,String username){
ArrayList<OrganUserModelExtend> allOrgans = new ArrayList<>();
String[] ids = topIds.split(",");
for (String id : ids) {
String[] idtemps = id.split("_");
String provinceId = idtemps[0];
String companyId = idtemps[1];
//先根据本地机构companyId
try {
String newurl = ConfigXmlReader.getInstance().searchPersonReqUrl;
newurl = newurl.replace("{providerId}", provinceId);
newurl = newurl.replace("{orgid}", companyId);
newurl = newurl.replace("{username}", URLEncoder.encode(username, "utf-8"));
URL url = new URL(newurl);
HttpURLConnection conn = getConnection(url,"Bearer " + TieSheController.tieSheToken);
int statusCode = conn.getResponseCode();
FineLoggerFactory.getLogger().info(url.toString() + "的状态码为:" + statusCode);
if (statusCode == 200) {
Object obj = parseHttpsReq(conn);
if (obj instanceof ArrayList) {
ArrayList objArr = (ArrayList) obj;
for (Object obj1 : objArr) {
if (obj1 instanceof LinkedHashMap) {
LinkedHashMap itemMap = (LinkedHashMap) obj1;
if (itemMap.containsKey("user")) {
LinkedHashMap userMap = (LinkedHashMap) itemMap.get("user");
if (userMap != null) {
List<LinkedHashMap> stations1 = RemoteReqService.getInstance().getAllStationIdByUserId(provinceId, userMap.get("id").toString());
//判断当前选择的机构id再岗位里有没有,有就只显示这一个,没有就全显示
List<LinkedHashMap> stations = new ArrayList<>();
boolean isExist = false;
for(LinkedHashMap stationMap1:stations1){
String stationId = stationMap1.get("id").toString();
if(stationId.equals(companyId)){
isExist = true;
stations.add(stationMap1);
}
}
if(isExist == false){
stations = stations1;
}
for(LinkedHashMap stationMap:stations){
String stationId = stationMap.get("id").toString();
OrganUserModelExtend model = new OrganUserModelExtend();
allOrgans.add(model);
model.setProviderId(provinceId);
model.setId( Integer.parseInt(userMap.get("id").toString()));
model.setOrginId(stationId);
if (stationId.equals("") == false) {
String fullPath = RemoteReqService.getInstance().getOrgFullPath(provinceId, stationId, false, true);
model.setFullPath(fullPath);
FineLoggerFactory.getLogger().info("fullPath:" + fullPath);
}
model.setMain((boolean)stationMap.get("mainPosition"));
model.setValue(userMap.get("name").toString());
model.setText(userMap.get("name").toString());
model.setOrder(Integer.parseInt(userMap.get("order").toString()));
}
}
}
}
}
}
FineLoggerFactory.getLogger().info("二级单位数据:" + obj);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
// return allOrgans;
}
}
return allOrgans;
}
private HttpURLConnection getConnection(URL url,String authorization) throws IOException {
HttpUtil.trustAllHosts();
HttpURLConnection conn = null;
HttpsURLConnection https = (HttpsURLConnection) url.openConnection();
https.setHostnameVerifier(HttpUtil.DO_NOT_VERIFY);
conn = https;
conn.setRequestMethod("GET");//设置请求方式
conn.setConnectTimeout(15000);//设置连接超时时间
conn.setReadTimeout(60000);//设置读取远程超时时间
conn.setDoInput(true);
conn.setDoOutput(true);
// conn.setRequestProperty("Authorization", "Basic " + authorization);
conn.setRequestProperty("Authorization", authorization);
return conn;
}
private Object parseHttpsReq(HttpURLConnection conn) throws IOException {
String result = parseStringHttpsReq(conn);
Object obj = JSONUtils.parse(result);
return obj;
}
private String parseStringHttpsReq(HttpURLConnection conn) throws IOException {
InputStream inputStream = conn.getInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buf = new byte[1024];
int len = 0;
while ((len = inputStream.read(buf)) != -1) {
baos.write(buf, 0, len);
}
baos.flush();
String result = baos.toString();
inputStream.close();
baos.close();
return result;
}
}

26
src/main/java/com/fr/plugin/teshe/services/TieSheFiliRptDBAUtil.java

@ -0,0 +1,26 @@
package com.fr.plugin.teshe.services;
import com.fr.plugin.teshe.entity.*;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
public class TieSheFiliRptDBAUtil {
private static TieSheFiliRptDBAUtil instance;
public static TieSheFiliRptDBAUtil getInstance(){
if(instance == null){
instance = new TieSheFiliRptDBAUtil();
}
return instance;
}
public void updateTaskPersonInfo(String userName) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<TieSheFiliRptEntity>() {
@Override
public TieSheFiliRptEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(TieSheFiliRptDAO.class).updateTaskPersonInfo(userName);
return null;
}
});
}
}

75
src/main/java/com/fr/plugin/teshe/services/TieSheOperateLogDBAUtil.java

@ -0,0 +1,75 @@
package com.fr.plugin.teshe.services;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.entity.TieSheDBAccessProvider;
import com.fr.plugin.teshe.entity.TieSheRoleOperateLogDAO;
import com.fr.plugin.teshe.entity.TieSheRoleOperateLogEntity;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import java.util.List;
import java.util.Map;
public class TieSheOperateLogDBAUtil {
private static TieSheOperateLogDBAUtil instance;
public static TieSheOperateLogDBAUtil getInstance(){
if(instance == null){
instance = new TieSheOperateLogDBAUtil();
}
return instance;
}
/**
* 插入日志
* @param entity
* @throws Exception
*/
public void inserOperateLog(TieSheRoleOperateLogEntity entity) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<TieSheRoleOperateLogEntity>() {
@Override
public TieSheRoleOperateLogEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(TieSheRoleOperateLogDAO.class).addEntity(entity);
return entity;
}
});
}
/**
* 获取日志的分页数据
* @param userName
* @param orgCodes
* @param page
* @param count
* @param startDate
* @param endDate
* @param operateName
* @param operateType
* @param operateIp
* @param operateDescn
* @return
*/
public Map<String, Object> findAllLog(String userName, List<String> orgCodes, int page, int count, String startDate, String endDate, String operateName, String operateType, String operateIp, String operateDescn){
//查询数据库
try{
Map<String, Object> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<Map<String, Object>>() {
@Override
public Map<String, Object> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(TieSheRoleOperateLogDAO.class).getAllLogs(userName,orgCodes,page,count,startDate,endDate,operateName,operateType,operateIp,operateDescn);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
FineLoggerFactory.getLogger().info("日志查询出错:"+ex.toString());
return null;
}
}
}

356
src/main/java/com/fr/plugin/teshe/services/TieSheOperateLogService.java

@ -0,0 +1,356 @@
package com.fr.plugin.teshe.services;
import com.fr.decision.authority.data.User;
import com.fr.decision.log.ExecuteMessage;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.intelli.record.MetricRegistry;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.*;
import com.fr.plugin.teshe.finerecordexecute.TieSheExecuteLogRestriction;
import com.fr.plugin.teshe.utils.TeSheUtil;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.data.DataList;
import com.fr.third.v2.org.apache.poi.xssf.streaming.SXSSFCell;
import com.fr.third.v2.org.apache.poi.xssf.streaming.SXSSFRow;
import com.fr.third.v2.org.apache.poi.xssf.streaming.SXSSFSheet;
import com.fr.third.v2.org.apache.poi.xssf.streaming.SXSSFWorkbook;
import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.fr.workspace.WorkContext;
import com.fine.plugin.tools.DateUtil;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.*;
/**
* 管理日志的service
*/
public class TieSheOperateLogService {
private static TieSheOperateLogService instance;
public static TieSheOperateLogService getInstance(){
if(instance == null){
instance = new TieSheOperateLogService();
}
return instance;
}
/**
* 插入日志
* @param opUserName
* @param datef
* @param opType
* @param descn
* @param orgCode
* @param realName
* @param ip
* @param userFullPath
* @throws Exception
*/
public void addOperateLog(String opUserName, String datef, int opType, String descn, String orgCode, String realName,String ip,String userFullPath) throws Exception {
TieSheRoleOperateLogEntity logEntity = new TieSheRoleOperateLogEntity();
String nowdate = datef;
if (nowdate == null) {
nowdate = TeSheUtil.getNowDate();
}
logEntity.setCreateDate(nowdate);
logEntity.setOpUserName(realName + "(" + opUserName + ")");
logEntity.setOpIp(ip);
logEntity.setUserOrgCode(orgCode);
logEntity.setUserOrgFullPath(userFullPath);
if ("中国铁建".equals(logEntity.getUserOrgFullPath()) == true) {
logEntity.setUserOrgFullPath("");
}
logEntity.setOpType(opType);
logEntity.setOpDescn(descn);
TieSheOperateLogDBAUtil.getInstance().inserOperateLog(logEntity);
}
/**
* 获取日志的分页数据
* @param
* @param
* @param page
* @param count
* @param startDate
* @param endDate
* @param operateName
* @param operateType
* @param operateIp
* @param operateDescn
* @return
*/
public Map<String, Object> findAllLog(String loginUser,int page, int count, String startDate, String endDate, String operateName, String operateType, String operateIp, String operateDescn) throws Exception{
ArrayList<String> orgCodes = new ArrayList<>();
//把登录者管理的所有组织查询出来
List<UserInOrganEntity> userInOrgans = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByUserId(loginUser);
List<UserInOrganEntity> userInOrgans1 = new ArrayList<>();
for (UserInOrganEntity entity : userInOrgans) {
if (!orgCodes.contains(entity.getOrganCode())) {
//这个组织必须有日志查看功能
if (!"admin".equals(loginUser)) {
if (entity.getOrganCode().equals(TieSheController.ROOT_ORGCODE)) {
List<UserInOrganEntity> allorgans = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByUserId("admin");
for (UserInOrganEntity entity1 : allorgans) {
if (!orgCodes.contains(entity1.getOrganCode())) {
//UserRoleMenuItemEntity roleEntity1 = TieSheDBAcessProvider.getViewOperateLogViewInOrgan(getCurrentLoginUserId(entity1.getUserId()), entity1.getOrganCode());
// if(roleEntity1 != null){
orgCodes.add(entity1.getOrganCode());
userInOrgans1.add(entity1);
// }
}
}
} else {
UserRoleMenuItemEntity roleEntity = UserRoleMenuDBAUtil.getInstance().getViewOperateLogViewInOrgan(TeSheUtil.getCurrentLoginUserId(entity.getUserId()), entity.getOrganCode());
if (roleEntity != null) {
orgCodes.add(entity.getOrganCode());
userInOrgans1.add(entity);
}
}
} else {
orgCodes.add(entity.getOrganCode());
userInOrgans1.add(entity);
}
}
}
TeSheUtil.getUniqueCodes(userInOrgans1,orgCodes);
Map<String, Object> allLogs = TieSheOperateLogDBAUtil.getInstance().findAllLog(loginUser, orgCodes, page, count, startDate, endDate, operateName, operateType, operateIp, operateDescn);
return allLogs;
}
/**
* 查询系统底层日志
*/
public DataList searchExecuteMessageLogs(String currentUser, int page, int count, String startDate, String endDate, String operateName, String operateType, String operateIp, String operateDescn) throws Exception {
TieSheExecuteLogRestriction var1 = new TieSheExecuteLogRestriction();
var1.setCount(count);
var1.setIp(operateIp);
var1.setOperateDescn(operateDescn);
var1.setOperateName(operateName);
var1.setOperateType(operateType);
if ("".equals(startDate) == false) {
var1.setStart(DateUtil.parseYMDHMSDateStr2Date(startDate));
}
if ("".equals(endDate) == false) {
var1.setEnd(DateUtil.parseYMDHMSDateStr2Date(endDate));
}
var1.setPage(page);
ArrayList<String> userIds = new ArrayList<>();
QueryCondition queryCondition = null;
// String currentUser = TeSheUtil.getCurrentLoginUser(req);
if (currentUser.equals("admin")) {
userIds.add("admin(admin)");
}
HashMap<String, String> userAndOrgFullPathMap = new HashMap<>();
//先查出该用户有哪些机构
List<UserInOrganEntity> allEntitys = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByUserId(currentUser);
if (allEntitys.size() == 1 && allEntitys.get(0).getOrganCode().equals(TieSheController.ROOT_ORGCODE)) {
allEntitys = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByUserId("admin");
}
//在根据机构的orgcode将该机构及其子下的用户都查询出来
for (UserInOrganEntity entity : allEntitys) {
List<UserInOrganEntity> newAllEntitys = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByOrganCode(entity.getOrganCode());
if (newAllEntitys != null) {
for (UserInOrganEntity entity1 : newAllEntitys) {
//获取这些用户的id,
User user = UserService.getInstance().getUserByUserName(entity1.getUserId());
if (user != null) {
if (!userIds.contains(user.getId())) {
String userNameStr = user.getRealName() + "(" + user.getUserName() + ")";
userAndOrgFullPathMap.put(userNameStr, entity1.getOrginOrganName());
userIds.add(userNameStr);
}
}
}
}
}
var1.setUsernameList(userIds);
//根据用户id再去查日志
queryCondition = var1.createCommonQueryCondition(userIds);
DataList var2 = MetricRegistry.getMetric().find(ExecuteMessage.class, queryCondition);
Iterator var3 = var2.getList().iterator();
while (var3.hasNext()) {
ExecuteMessage var4 = (ExecuteMessage) var3.next();
var4.setSql((String) null);
}
List<ExecuteMessage> dataList = var2.getList();
List<TieSheRoleOperateLogEntity> newDataList = new ArrayList<>();
var2.setList(newDataList);
for (ExecuteMessage message : dataList) {
TieSheRoleOperateLogEntity newMesage = new TieSheRoleOperateLogEntity();
newDataList.add(newMesage);
newMesage.setUserOrgFullPath(userAndOrgFullPathMap.get(message.getUsername()));
// newMesage.setOpDescn(message.getUsername() + "访问了资源" + message.getTemplate());
newMesage.setOpDescn(message.getTemplate());
newMesage.setOpType(message.getType());
newMesage.setCreateDate(DateUtil.parseDate2YMDMSF(message.getTime()));
newMesage.setOpIp(message.getIp());
newMesage.setOpUserName(message.getUsername());
}
return var2;
}
public String exportAllLogs(Map<String, Object> allLogs) throws IOException {
DataList<TieSheRoleOperateLogEntity> dataList = (DataList<TieSheRoleOperateLogEntity>) allLogs.get("items");
ArrayList<String[]> datas = new ArrayList<>();
List<TieSheRoleOperateLogEntity> list = dataList.getList();
for (int index = 0; index < list.size(); index++) {
TieSheRoleOperateLogEntity entity1 = (TieSheRoleOperateLogEntity) list.get(index);
String[] data = new String[7];
datas.add(data);
data[0] = "" + (index + 1);
data[1] = entity1.getCreateDate();
data[2] = entity1.getOpUserName();
String opTypeName = "";
if (entity1.getOpType() == 1) { //1 添加授权对象,2 删除授权对象,3 添加授权功能 4 删除授权功能
opTypeName = "添加授权对象";
}
if (entity1.getOpType() == 2) {
opTypeName = "删除授权对象";
}
if (entity1.getOpType() == 3) {
opTypeName = "添加授权功能";
}
if (entity1.getOpType() == 4) {
opTypeName = "删除授权功能";
}
data[3] = opTypeName;
data[4] = entity1.getOpIp();
data[5] = entity1.getOpDescn();
data[6] = entity1.getUserOrgFullPath();
}
String excelName = TieSheOperateLogService.getInstance().createExportXlsFile(datas);
return excelName;
}
public String exportAllViewLogs( DataList dataList) throws IOException {
List list = dataList.getList();
ArrayList<String[]> datas = new ArrayList<>();
for (int index = 0; index < list.size(); index++) {
TieSheRoleOperateLogEntity entity1 = (TieSheRoleOperateLogEntity) list.get(index);
String[] data = new String[7];
datas.add(data);
data[0] = "" + (index + 1);
data[1] = entity1.getCreateDate();
data[2] = entity1.getOpUserName();
String opTypeName = "决策报表预览";
data[3] = opTypeName;
data[4] = entity1.getOpIp();
data[5] = entity1.getOpDescn();
data[6] = entity1.getUserOrgFullPath();
}
String excelName = TieSheOperateLogService.getInstance().createExportXlsFile(datas);
return excelName;
}
public String createExportXlsFile(ArrayList<String[]> datas) throws IOException {
SXSSFWorkbook workbook = null;
String envPath = WorkContext.getCurrent().getPath();
FineLoggerFactory.getLogger().info("envPath:" + envPath);
String webReport = (new File(envPath)).getParent();
FineLoggerFactory.getLogger().info("webReport:" + webReport);
File excelDir = new File(webReport + File.separator + "excels");
if (excelDir.exists() == false) {
excelDir.mkdir();
}
String excelFileName = UUID.randomUUID().toString() + ".xls";
FileOutputStream outStram = new FileOutputStream(new File(excelDir.getPath() + File.separator + excelFileName));//"E:\\任务\\铁建\\test.xls"));
try {
workbook = new SXSSFWorkbook((XSSFWorkbook) null, 100, false, true);
} catch (Throwable var10) {
workbook = new SXSSFWorkbook(100);
}
SXSSFSheet sheet = workbook.createSheet();
SXSSFRow row = sheet.createRow(0);
SXSSFCell cell = row.createCell(0);
cell.setCellValue("序号");
cell = row.createCell(1);
cell.setCellValue("操作时间");
cell = row.createCell(2);
cell.setCellValue("操作人");
cell = row.createCell(3);
cell.setCellValue("操作类型");
cell = row.createCell(4);
cell.setCellValue("操作ip");
cell = row.createCell(5);
cell.setCellValue("操作描述");
cell = row.createCell(6);
cell.setCellValue("操作人信息");
int index = 1;
for (String[] data : datas) {
row = sheet.createRow(index);
cell = row.createCell(0);
cell.setCellValue(data[0]);
cell = row.createCell(1);
cell.setCellValue(data[1]);
cell = row.createCell(2);
cell.setCellValue(data[2]);
cell = row.createCell(3);
cell.setCellValue(data[3]);
cell = row.createCell(4);
cell.setCellValue(data[4]);
cell = row.createCell(5);
cell.setCellValue(data[5]);
cell = row.createCell(6);
cell.setCellValue(data[6]);
index++;
}
workbook.write(outStram);
outStram.close();
return excelFileName;
}
}

116
src/main/java/com/fr/plugin/teshe/services/TieSheSysOrgDBAUtil.java

@ -0,0 +1,116 @@
package com.fr.plugin.teshe.services;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.entity.TieSheDBAccessProvider;
import com.fr.plugin.teshe.entity.TieSheSysOrgDAO;
import com.fr.plugin.teshe.entity.TieSheSysOrgEntity;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import java.util.List;
public class TieSheSysOrgDBAUtil {
private static TieSheSysOrgDBAUtil instance;
public static TieSheSysOrgDBAUtil getInstance(){
if(instance == null){
instance = new TieSheSysOrgDBAUtil();
}
return instance;
}
public List<TieSheSysOrgEntity> getChildrenByParentId(String parentId){
try{
List<TieSheSysOrgEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<TieSheSysOrgEntity>>() {
@Override
public List<TieSheSysOrgEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(TieSheSysOrgDAO.class).getChildrenByParentId(parentId);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
public TieSheSysOrgEntity getEntityByOrgId(String organId){
try{
TieSheSysOrgEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<TieSheSysOrgEntity>() {
@Override
public TieSheSysOrgEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(TieSheSysOrgDAO.class).getEntityByOrgId(organId);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
FineLoggerFactory.getLogger().info("系统组织实体查询报错:"+ex.toString());
return null;
}
}
public TieSheSysOrgEntity getRoot(){
try{
TieSheSysOrgEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<TieSheSysOrgEntity>() {
@Override
public TieSheSysOrgEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(TieSheSysOrgDAO.class).getRoot();
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
public TieSheSysOrgEntity getEntityByCode(String organCode){
try{
TieSheSysOrgEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<TieSheSysOrgEntity>() {
@Override
public TieSheSysOrgEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(TieSheSysOrgDAO.class).getEntityByCode(organCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
public String getEntitySortPathByOrgId(String orgId){
try{
String entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<String>() {
@Override
public String run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(TieSheSysOrgDAO.class).getEntitySortPathByOrgId(orgId);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
}

146
src/main/java/com/fr/plugin/teshe/services/TieSheSysOrgService.java

@ -0,0 +1,146 @@
package com.fr.plugin.teshe.services;
import com.fr.plugin.teshe.beans.OrganUserModel;
import com.fr.plugin.teshe.beans.SecondOrganFullPathComparator;
import com.fr.plugin.teshe.beans.SecondOrganModel;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.*;
import com.fr.plugin.teshe.utils.TeSheUtil;
import com.fr.third.alibaba.druid.support.json.JSONUtils;
import java.util.*;
public class TieSheSysOrgService {
private static TieSheSysOrgService instance;
public static TieSheSysOrgService getInstance(){
if(instance == null){
instance = new TieSheSysOrgService();
}
return instance;
}
public ArrayList<OrganUserModel> getAdminOrganUserInfos(){
ArrayList<OrganUserModel> datas = new ArrayList<>();
ArrayList<SecondOrganModel> infos1 = RemoteReqService.getInstance().getSecondOrgan(false);
ArrayList<SecondOrganModel> infos = new ArrayList<>();
for (SecondOrganModel model : infos1) {
//这里需要根据本地系统去查询到人事系统机构信息
String hrOrganId = model.getHrOrgId();
String provinceId = model.getProviderId();
int hrType = model.getHrType();
String orgInfo = "";
if (hrType == 1) {
orgInfo = RemoteReqService.getInstance().getOrgUnitInfo(provinceId, hrOrganId);
} else {
orgInfo = RemoteReqService.getInstance().getOrgDepInfo(provinceId, hrOrganId);
}
Object obj = JSONUtils.parse(orgInfo);
if (obj instanceof LinkedHashMap) {
LinkedHashMap root = (LinkedHashMap) obj;
// String companyId = root.get("id").toString();
SecondOrganModel model1 = new SecondOrganModel(provinceId, hrOrganId);
infos.add(model1);
if (root.containsKey("type")) {
model1.setModelType((int) root.get("type"));
}
//这里是懒加载加的代码
model1.setLayer(1);
model1.setText(root.get("name").toString());
model1.setIsParent(true);
model1.setpId("-1_0");
model1.setOrganCode(root.get("code").toString());
}
}
for (SecondOrganModel model : infos) {
OrganUserModel userModel = new OrganUserModel();
datas.add(userModel);
userModel.setProviderId(model.getProviderId());
userModel.setValue(model.getText());
userModel.setText(model.getText());
userModel.setType(model.getModelType() + "");
userModel.setOrder(model.getOrder());
userModel.setId(Integer.parseInt(model.getId()));
}
return datas;
}
/**
* 一般用户获取组织机构数据
* 这里需要去重可能将一个人放到一个组织的下级组织这就造成了数据重复所以需要将下级去掉只保留上级
* @param currentUser
* @param isView
* @return
* @throws Exception
*/
public ArrayList<Object> getAllOragnListCommon(String currentUser,boolean isView) throws Exception {
//获取这个人参与的所有组织机构数据
ArrayList<UserInOrganEntity> entitys0 = (ArrayList<UserInOrganEntity>) UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByLoginUserName(currentUser);
ArrayList<UserInOrganEntity> entitys = new ArrayList<>();
HashMap<String, UserInOrganEntity> orgCodeAndEntityMap = new HashMap<>();
for (UserInOrganEntity en : entitys0) {
if (isView == false) {//工作授权菜单 先把有工作授权的查看功能的组织过滤出来,有才能看这个机构的数据
UserRoleMenuItemEntity roleEntity = UserRoleMenuDBAUtil.getInstance().getViewAuthorityInOrgan(TeSheUtil.getCurrentLoginUserId(en.getUserId()), en.getOrganCode());
if (roleEntity != null) {
entitys.add(en);
orgCodeAndEntityMap.put(en.getOrganCode(), en);
}
} else {//授权查看菜单 先把有授权查看的查看功能的组织过滤出来,有才能看这个机构的数据
UserRoleMenuItemEntity roleEntity = UserRoleMenuDBAUtil.getInstance().getViewAuthorityViewInOrgan(TeSheUtil.getCurrentLoginUserId(en.getUserId()), en.getOrganCode());
if (roleEntity != null) {
entitys.add(en);
orgCodeAndEntityMap.put(en.getOrganCode(), en);
}
}
}
ArrayList<Object> allOrgans = new ArrayList<>();
//去重
ArrayList<String> orgCodes = new ArrayList<>();
TeSheUtil.getUniqueCodes(entitys, orgCodes);
//上面去重完毕
ArrayList<UserInOrganEntity> newEntitys = new ArrayList<>();
for (String key : orgCodes) {
newEntitys.add(orgCodeAndEntityMap.get(key));
}
if (orgCodes.contains(TieSheController.ROOT_ORGCODE)) {
ArrayList<SecondOrganModel> infos = RemoteReqService.getInstance().getSecondOrgan(true);
//return infos;
allOrgans.addAll(infos);
} else {
//这里需要加入权限,如果这些机构这个人有查看权限,那么就可以看到这些数据,没有就看不到
for (UserInOrganEntity en : newEntitys) {
//看下这个人在这个组织上是否有工作授权的查看功能,有才能看这个机构的数据
// UserRoleMenuItemEntity roleEntity = TieSheDBAcessProvider.getViewAuthorityInOrgan(getCurrentLoginUserId(en.getUserId()), en.getOrganCode());
// if (roleEntity != null) {
String organId = en.getOrganId();
String[] temp = organId.split("_");
String fullPathSort = TieSheSysOrgDBAUtil.getInstance().getEntitySortPathByOrgId(temp[1]);//RemoteReqService.getInstance().getOrgFullPathSort(temp[0], temp[1], true);
TieSheSysOrgEntity sysOrgEntity = TieSheSysOrgDBAUtil.getInstance().getEntityByOrgId(temp[1]);
SecondOrganModel node = new SecondOrganModel(temp[0], temp[1]);
allOrgans.add(node);
node.setIsParent(true);
node.setFullPathOrder(fullPathSort);
node.setText(en.getOrganName());
node.setLayer(0);
node.setModelType(sysOrgEntity.getType());
node.setOrganCode(en.getOrganCode());
// }
}
}
Collections.sort(allOrgans, new SecondOrganFullPathComparator());
return allOrgans;
}
}

378
src/main/java/com/fr/plugin/teshe/services/UserInOrganDBAUtil.java

@ -0,0 +1,378 @@
package com.fr.plugin.teshe.services;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.TieSheDBAccessProvider;
import com.fr.plugin.teshe.entity.UserInOrganDAO;
import com.fr.plugin.teshe.entity.UserInOrganEntity;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import com.fr.stable.query.QueryFactory;
import com.fr.stable.query.condition.QueryCondition;
import com.fr.stable.query.restriction.RestrictionFactory;
import java.util.List;
public class UserInOrganDBAUtil {
private static UserInOrganDBAUtil instance;
public static UserInOrganDBAUtil getInstance(){
if(instance == null){
instance = new UserInOrganDBAUtil();
}
return instance;
}
/**
* 获取所有的授权对象
* @return
*/
public List<UserInOrganEntity> findAllUserInGroupData(){
//查询数据库
try{
List<UserInOrganEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserInOrganEntity>>() {
@Override
public List<UserInOrganEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserInOrganDAO.class).getAllDatas();
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
FineLoggerFactory.getLogger().info("查询机构中的授权对象出错:"+ex.toString());
return null;
}
}
/**
* 根据id删除授权对象
* @param id
*/
public void deleteUserInGroupDataById(String id){
try{
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserInOrganEntity>() {
@Override
public UserInOrganEntity run(DAOContext context) throws Exception {
context.getDAO(UserInOrganDAO.class).removeEntity(id);
return null;
}
});
}catch(Throwable e){
e.printStackTrace();
}
}
/**
* 根据机构id操作人id类型(本级下级),给机构code授权对象名字模糊查询
* @param companyId
* @param operatorUserId
* @param searchType
* @param orgCode
* @param searchUserName
* @return
*/
public List<UserInOrganEntity> findAllUserInGroupDataByOrgIdAndOreatorId(String companyId,String operatorUserId,int searchType,String orgCode,String searchUserName){
//查询数据库
try{
List<UserInOrganEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserInOrganEntity>>() {
@Override
public List<UserInOrganEntity> run(DAOContext daoContext) throws Exception {
QueryCondition queryCondition ;
if(operatorUserId.equals("admin")){
if(searchType == 1){ //查询本级
queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.eq("organId",companyId));
if("".equals(searchUserName) == false){
queryCondition.addRestriction(RestrictionFactory.like("userName",searchUserName));
}
return daoContext.getDAO(UserInOrganDAO.class).find(queryCondition);
}
else{
if(TieSheController.ROOT_ORGCODE.equals(orgCode)){
queryCondition = QueryFactory.create();
}
else{
queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.like("organCode",orgCode));
}
if("".equals(searchUserName) == false){
queryCondition.addRestriction(RestrictionFactory.like("userName",searchUserName));
}
return daoContext.getDAO(UserInOrganDAO.class).find(queryCondition);
}
}
else{
if(searchType == 1){
queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.eq("organId",companyId)).addRestriction(RestrictionFactory.neq("userId",operatorUserId));//.addRestriction(RestrictionFactory.eq("operatorUserId",operatorUserId));
if("".equals(searchUserName) == false){
queryCondition.addRestriction(RestrictionFactory.like("userName",searchUserName));
}
return daoContext.getDAO(UserInOrganDAO.class).find(queryCondition);
}
else{
if(TieSheController.ROOT_ORGCODE.equals(orgCode)){
queryCondition = QueryFactory.create();
}
else{
queryCondition = QueryFactory.create().addRestriction(RestrictionFactory.like("organCode",orgCode));
}
queryCondition.addRestriction(RestrictionFactory.neq("userId",operatorUserId));
if("".equals(searchUserName) == false){
queryCondition.addRestriction(RestrictionFactory.like("userName",searchUserName));
}
return daoContext.getDAO(UserInOrganDAO.class).find(queryCondition);
}
}
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据用户id获取授权对象
* @param userId
* @return
*/
public List<UserInOrganEntity> findAllUserInGroupDataByUserId(String userId){
//查询数据库
try{
List<UserInOrganEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserInOrganEntity>>() {
@Override
public List<UserInOrganEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserInOrganDAO.class).findEntityByUserId(userId);
// return daoContext.getDAO(UserInOrganDAO.class).find(QueryConditionKit.newQueryCondition().addRestriction(RestrictionKit.gte("salary", 10000.0)));
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据机构code用户id获取授权对象
* @param organCode
* @param userId
* @return
*/
public UserInOrganEntity findEntityByUserIdAndOrgCode(String organCode,String userId){
//查询数据库
try{
UserInOrganEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserInOrganEntity>() {
@Override
public UserInOrganEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserInOrganDAO.class).findEntityByUserIdAndOrgCode(organCode,userId);
// return daoContext.getDAO(UserInOrganDAO.class).find(QueryConditionKit.newQueryCondition().addRestriction(RestrictionKit.gte("salary", 10000.0)));
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据机构code获取授权对象
* @param organCode
* @return
*/
public List<UserInOrganEntity> findAllUserInGroupDataByOrganCode(String organCode){
//查询数据库
try{
List<UserInOrganEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserInOrganEntity>>() {
@Override
public List<UserInOrganEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserInOrganDAO.class).findEntityByOrgCode(organCode);
// return daoContext.getDAO(UserInOrganDAO.class).find(QueryConditionKit.newQueryCondition().addRestriction(RestrictionKit.gte("salary", 10000.0)));
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据userid获取授权对象
* @param userId
* @return
*/
public List<UserInOrganEntity> findUserInGroupDataByUserId(String userId){
//查询数据库
try{
List<UserInOrganEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserInOrganEntity>>() {
@Override
public List<UserInOrganEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserInOrganDAO.class).findEntityByUserId(userId); // return daoContext.getDAO(UserInOrganDAO.class).find(QueryConditionKit.newQueryCondition().addRestriction(RestrictionKit.gte("salary", 10000.0)));
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据id获取授权对象
* @param id
* @return
*/
public UserInOrganEntity findUserInGroupDataById(String id){
//查询数据库
try{
UserInOrganEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserInOrganEntity>() {
@Override
public UserInOrganEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserInOrganDAO.class).getEntityById(id); // return daoContext.getDAO(UserInOrganDAO.class).find(QueryConditionKit.newQueryCondition().addRestriction(RestrictionKit.gte("salary", 10000.0)));
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 添加授权对象
* @param entity
* @throws Exception
*/
//插入数据
public void insertUserInOrganData(UserInOrganEntity entity) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserInOrganEntity>() {
@Override
public UserInOrganEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(UserInOrganDAO.class).addEntity(entity);
return entity;
}
});
}
/**
* 根据登录人获取授权对象
* @param loginUserName
* @return
*/
public static List<UserInOrganEntity> findAllUserInGroupDataByLoginUserName(String loginUserName){
//查询数据库
try{
List<UserInOrganEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserInOrganEntity>>() {
@Override
public List<UserInOrganEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserInOrganDAO.class).findEntityByLoginUserName(loginUserName);
// return daoContext.getDAO(UserInOrganDAO.class).find(QueryConditionKit.newQueryCondition().addRestriction(RestrictionKit.gte("salary", 10000.0)));
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
public List<UserInOrganEntity> findAllUserInGroupDataByOrgIdAndUserId(String orgCode,String userId,int searchType){
//查询数据库
try{
List<UserInOrganEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserInOrganEntity>>() {
@Override
public List<UserInOrganEntity> run(DAOContext daoContext) throws Exception {
if(searchType == 1){ //本级
return daoContext.getDAO(UserInOrganDAO.class).find(QueryFactory.create().addRestriction(RestrictionFactory.eq("organCode",orgCode)).addRestriction(RestrictionFactory.eq("userId",userId)));
}
else{ //下级
return daoContext.getDAO(UserInOrganDAO.class).find(QueryFactory.create().addRestriction(RestrictionFactory.like("organCode",orgCode)).addRestriction(RestrictionFactory.eq("userId",userId)));
}
// return daoContext.getDAO(UserInOrganDAO.class).find(QueryConditionKit.newQueryCondition().addRestriction(RestrictionKit.gte("salary", 10000.0)));
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据机构id用户id操作人id获取授权对象
* @param companyId
* @param userId
* @param operatorUserId
* @return
*/
public UserInOrganEntity findAllUserInGroupDataByIdAndUserId(String companyId,String userId,String operatorUserId){
//查询数据库
try{
UserInOrganEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserInOrganEntity>() {
@Override
public UserInOrganEntity run(DAOContext daoContext) throws Exception {
UserInOrganEntity entity = daoContext.getDAO(UserInOrganDAO.class).findEntityByUserIdAndOrganId(userId,companyId,operatorUserId);
return entity;
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
}

526
src/main/java/com/fr/plugin/teshe/services/UserInOrganService.java

@ -0,0 +1,526 @@
package com.fr.plugin.teshe.services;
import com.fr.decision.authority.data.User;
import com.fr.decision.webservice.bean.authority.PrivilegeBean;
import com.fr.decision.webservice.bean.authority.PrivilegeDetailBean;
import com.fr.decision.webservice.bean.user.UserUpdateBean;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.beans.OrganUserFullPathComparator;
import com.fr.plugin.teshe.beans.OrganUserModel;
import com.fr.plugin.teshe.beans.SecondOrganFullPathComparator;
import com.fr.plugin.teshe.beans.SecondOrganModel;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.*;
import com.fr.plugin.teshe.utils.TeSheUtil;
import com.fr.third.alibaba.druid.support.json.JSONUtils;
import java.util.*;
/**
* 处理再组织中添加授权对象
*/
public class UserInOrganService {
private static UserInOrganService instance;
public static UserInOrganService getInstance(){
if(instance == null){
instance = new UserInOrganService();
}
return instance;
}
/**
* 删除某个组织下的某个授权用户
* @param id
* @param currentUser
* @param ipaddress
* @param currentFullpath
* @param realUserName
* @param orgCode
* @throws Exception
*/
public void deleteUsersInOrgan(String id,String currentUser,String ipaddress,String currentFullpath,String realUserName,String orgCode) throws Exception {
//通过id找到该实体
UserInOrganEntity entity = UserInOrganDBAUtil.getInstance().findUserInGroupDataById(id);
User deleteUser = UserService.getInstance().getUserByUserName(entity.getUserId());
//找到该用户所有的授权组织,如果只有一个组织了,那么底层权限数据,登录账号也要删除,如果大于1个,那么只删除封装权限数据就行了。
List<UserInOrganEntity> allEntity = UserInOrganDBAUtil.getInstance().findUserInGroupDataByUserId(entity.getUserId());
//这里要查询删除的用户在其他组织里还存在吗。如果还存在,
if (allEntity.size() == 1) {
//删除登录账号
if (deleteUser != null) {
FineLoggerFactory.getLogger().info("该删除了");
UserUpdateBean bean = new UserUpdateBean();
String[] removeIds = new String[1];
removeIds[0] = deleteUser.getId();
bean.setRemoveUserIds(removeIds);
TieSheFiliRptDBAUtil.getInstance().updateTaskPersonInfo(entity.getUserId());
//删除底层权限
String carrierType = TieSheController.CARRIER_TYPE;
// String carrierId = "decision-dep-root"; // 7a012927-254f-4b4b-85b6-c8bd7d57d200
String externalType = "";
PrivilegeBean privilege = new PrivilegeBean();
PrivilegeDetailBean[] values = new PrivilegeDetailBean[2];
PrivilegeDetailBean detailBean = new PrivilegeDetailBean();
values[0] = detailBean;
//使用
detailBean.setPrivilegeType(1);
detailBean.setPrivilegeValue(1);
PrivilegeDetailBean detailBean2 = new PrivilegeDetailBean(); //权限
values[1] = detailBean2;
detailBean2.setPrivilegeType(2);
detailBean2.setPrivilegeValue(1);
privilege.setValues(values);
try {
privilege.setId(TieSheController.WORK_AUTHORITY_ID);
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, deleteUser.getId(), externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
privilege.setId(TieSheController.WORKD_AUTHORITY_VIEW_ID);
try {
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, deleteUser.getId(), externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
privilege.setId(TieSheController.SYSTEM_LOG_ID);
try {
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, deleteUser.getId(), externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
privilege.setId(TieSheController.ORGAN_MANAGE_ID);
try {
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, deleteUser.getId(), externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
privilege = new PrivilegeBean();
PrivilegeDetailBean[] values1 = new PrivilegeDetailBean[3];
PrivilegeDetailBean detailBean1 = new PrivilegeDetailBean(); //查看
values1[0] = detailBean1;
//增加查看权限
detailBean1.setPrivilegeType(1);
detailBean1.setPrivilegeValue(1);
PrivilegeDetailBean detailBean4 = new PrivilegeDetailBean(); //管理
values1[1] = detailBean4;
detailBean4.setPrivilegeType(3);
detailBean4.setPrivilegeValue(1);
PrivilegeDetailBean detailBean3 = new PrivilegeDetailBean(); //权限
values1[2] = detailBean3;
detailBean3.setPrivilegeType(2);
detailBean3.setPrivilegeValue(1);
privilege.setValues(values1);
privilege.setId("decision-homepage-root");
try {
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, deleteUser.getId(), externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
privilege.setId("decision-directory-root");
try {
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, deleteUser.getId(), externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
//删除登录用户
UserService.getInstance().deleteUsers(bean);
}
}
//在该组织上删除该用户
UserInOrganDBAUtil.getInstance().deleteUserInGroupDataById(id);
//this.addOperateLog(req, null, 2, this.getUserRealName(TeSheUtil.getCurrentLoginUser(req)) + "在" + entity.getOrganFullPath() + "中删除了授权对象:" + entity.getUserName(), orgCode, this.getUserRealName(TeSheUtil.getCurrentLoginUser(req)));
String opUserName = currentUser;
String fullpath = currentFullpath;
TeSheUtil.addOperateLog(opUserName,ipaddress,fullpath,null, 2, realUserName + "在" + entity.getOrganFullPath() + "中删除了授权对象:" + entity.getUserName(), orgCode, realUserName);
//这里要看该用户再这个组织上的授权如果再别的组织上是否也有授权,如果没有,底层授权也要关闭了
//用户再该组织上的所有授权
List<UserRoleMenuItemEntity> allAuthorityDatasInOrgan = UserRoleMenuDBAUtil.getInstance().getUserAuthorityDataInOrgan(TeSheUtil.getCurrentLoginUserId(entity.getUserId()), orgCode);
if (allAuthorityDatasInOrgan.size() > 0) {
//用户的所有授权
List<UserRoleMenuItemEntity> allAuthorityDatas = UserRoleMenuDBAUtil.getInstance().findAllUserAuthorityDatasByUserId(TeSheUtil.getCurrentLoginUserId(entity.getUserId()));
List<String> deleteAuthorityMenuIds = new ArrayList<>();
HashMap<String, Integer> authorityMaps = new HashMap<>();
for (UserRoleMenuItemEntity entity1 : allAuthorityDatas) {
if (entity1.getOrganCode().equals(orgCode) == false) {
authorityMaps.put(entity1.getMenuId(), 1);
}
}
for (UserRoleMenuItemEntity entity2 : allAuthorityDatasInOrgan) {
if (authorityMaps.containsKey(entity2.getMenuId()) == false) {
if (deleteAuthorityMenuIds.contains(entity2.getMenuId()) == false) {
deleteAuthorityMenuIds.add(entity2.getMenuId());
}
}
}
if (deleteAuthorityMenuIds.size() > 0) {
//删除底层
for (String menuId : deleteAuthorityMenuIds) {
try {
UserRoleMenuService.getInstance().closePrivilege(currentUser, menuId, deleteUser.getId());
} catch (Exception ex) {
FineLoggerFactory.getLogger().info("关闭底层权限异常.....");
}
}
}
}
//删除该用户在该组织上的封装授权数据
UserRoleMenuDBAUtil.getInstance().deleteByUserIdAndOrgCode(TeSheUtil.getCurrentLoginUserId(entity.getUserId()), entity.getOrganCode());
// this.addOperateLog(req, null, 4, this.getUserRealName(TeSheUtil.getCurrentLoginUser(req)) + "删除了:" + entity.getUserName() + "在" + entity.getOrganFullPath() + "上的授权数据", orgCode, this.getUserRealName(TeSheUtil.getCurrentLoginUser(req)));
opUserName = currentUser;
String ip = ipaddress;
String userFullPath = currentFullpath;
TeSheUtil.addOperateLog(opUserName,ip,userFullPath,null, 4, realUserName + "删除了:" + entity.getUserName() + "在" + entity.getOrganFullPath() + "上的授权数据", orgCode, realUserName);
}
/**
* 给某个机构组织添加授权对象
* @param users
* @param provinceId
* @param organId
* @param orgCode
* @param currentUser
* @param orgFullPath
* @param organName
* @param orgType
* @param ipaddress
* @param currentFullpath
* @param realUserName
* @throws Exception
*/
public void addUserInOrgan(ArrayList users,String provinceId,String organId,String orgCode,String currentUser,String orgFullPath,String organName,String orgType,String ipaddress,String currentFullpath,String realUserName) throws Exception {
if (users != null) {
for (Object user : users) {
LinkedHashMap userMap = (LinkedHashMap) user;
if (userMap != null) {
UserInOrganEntity entity = new UserInOrganEntity();
entity.setOrganId(provinceId + "_" + organId);
entity.setOrganCode(orgCode);
String userId = userMap.get("userId").toString();
if (userId.indexOf("_") == -1) {
userId = userMap.get("userProvinceId").toString() + "_" + userId;
}
entity.setUserId(userId);
entity.setStationId(userMap.get("orginOrganId").toString());
entity.setIsMain(userMap.get("isMain").toString());
UserInOrganEntity oldEntity = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByIdAndUserId(entity.getOrganId(), entity.getUserId(), currentUser);
if (oldEntity == null) {
String datef = TeSheUtil.getNowDate();
entity.setOperatorUserId(currentUser);
entity.setCreateDate(datef);
entity.setUserName(userMap.get("userName").toString());
if ("error".equals(orgFullPath)) {
entity.setOrganFullPath(organName);
} else {
entity.setOrganFullPath(orgFullPath);
}
entity.setOrganName(organName);
entity.setOrginOrganId(userMap.get("orginOrganId").toString());
entity.setOrginOrganName(userMap.get("orginOrganName").toString());
entity.setProvinceId(provinceId);
entity.setOrginProvinceId(userMap.get("userProvinceId").toString());
if (provinceId.equals("-1") && organId.equals("0")) {
entity.setUserType(1);
} else {
entity.setUserType(0);
}
entity.setOrganType(orgType);
//entity.setLoginUserName( userMap.get("userProvinceId").toString() +"_"+entity.getUserId());
entity.setLoginUserName(entity.getUserId());//用户登录名=provinceId+id
UserInOrganDBAUtil.getInstance().insertUserInOrganData(entity);
String opUserName = currentUser;
String fullpath = currentFullpath;
TeSheUtil.addOperateLog(opUserName,ipaddress,fullpath,datef, 1, realUserName + "在" + orgFullPath + "下添加授权人员[" + entity.getUserName() + "](" + entity.getOrginOrganName() + ")", orgCode, realUserName);
} else {
FineLoggerFactory.getLogger().info(entity.getUserName() + "已经存在,不能再往该组织添加授权对象了");
}
}
}
}
}
/**
* 普通用户获取所有的组织下的用户
* 添加授权对象组织机构树用的
* @param currentUser
* @return
* @throws Exception
*/
public ArrayList<OrganUserModel> getCommonOrganUserInfos(String currentUser) throws Exception {
ArrayList<OrganUserModel> datas = new ArrayList<>();
List<UserInOrganEntity> entitys1 = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByLoginUserName(currentUser);
HashMap<String, UserInOrganEntity> orgCodeAndEntityMap = new HashMap<>();
List<UserInOrganEntity> entitys = new ArrayList<>();
//先看这些人在这些机构中是否有工作授权的管理功能,没有就抛弃
for (UserInOrganEntity entity : entitys1) {
//看下这个人在这个组织上是否有工作授权的管理功能,有才能看这个机构的数据
UserRoleMenuItemEntity roleEntity = UserRoleMenuDBAUtil.getInstance().getManageAuthorityInOrgan(TeSheUtil.getCurrentLoginUserId(entity.getUserId()), entity.getOrganCode());
if (roleEntity != null) {
entitys.add(entity);
orgCodeAndEntityMap.put(entity.getOrganCode(), entity);
}
}
//去重,有可能子部门跟父部门都添加了这个人
ArrayList<String> orgCodes = new ArrayList<>();
TeSheUtil.getUniqueCodes(entitys,orgCodes);
for (UserInOrganEntity en : entitys) {
orgCodeAndEntityMap.put(en.getOrganCode(), en);
}
ArrayList<UserInOrganEntity> newEntitys = new ArrayList<>();
for (String key : orgCodes) {
newEntitys.add(orgCodeAndEntityMap.get(key));
}
ArrayList<SecondOrganModel> alls = new ArrayList<>();
if (orgCodes.contains(TieSheController.ROOT_ORGCODE)) {
datas.clear();
ArrayList<SecondOrganModel> infos = RemoteReqService.getInstance().getSecondOrgan(false);
alls.addAll(infos);
} else {
for (UserInOrganEntity userEntity : newEntitys) {
String porganId = userEntity.getOrganId();
String[] tms = porganId.split("_");
//查询本地机构再人事系统的id
TieSheSysOrgEntity entity = TieSheSysOrgDBAUtil.getInstance().getEntityByOrgId(tms[1]);
String hrscope = entity.getHrScope();
String[] temps = hrscope.split("_");
String provinceId = temps[0];
String companyId = entity.getOrganId();
SecondOrganModel model = new SecondOrganModel(provinceId, companyId);
model.setModelType(entity.getType());
model.setHrOrgId(temps[1]);
model.setHrType(Integer.parseInt(temps[2]));
alls.add(model);
model.setLayer(1);
model.setText(entity.getOrganName());
model.setIsParent(true);
model.setpId(provinceId + "_" + entity.getPid());// "-1_0");
model.setOrganCode(entity.getOrganCode());
}
}
datas.clear();
ArrayList<SecondOrganModel> infos = new ArrayList<>();
for (SecondOrganModel model : alls) {
//这里需要根据本地系统去查询到人事系统机构信息
String hrOrganId = model.getHrOrgId();
String provinceId = model.getProviderId();
int hrType = model.getHrType();
String orgInfo = "";
if (hrType == 1) {//查单位
orgInfo = RemoteReqService.getInstance().getOrgUnitInfo(provinceId, hrOrganId);
} else {//查部门
orgInfo = RemoteReqService.getInstance().getOrgDepInfo(provinceId, hrOrganId);
}
Object obj = JSONUtils.parse(orgInfo);
if (obj instanceof LinkedHashMap) {
LinkedHashMap root = (LinkedHashMap) obj;
// String companyId = root.get("id").toString();
SecondOrganModel model1 = new SecondOrganModel(provinceId, hrOrganId);
infos.add(model1);
if (root.containsKey("type")) {
model1.setModelType((int) root.get("type"));
}
//这里是懒加载加的代码
model1.setLayer(1);
model1.setText(root.get("name").toString());
model1.setIsParent(true);
model1.setpId("-1_0");
model1.setOrganCode(root.get("code").toString());
}
}
for (SecondOrganModel model : infos) {
OrganUserModel userModel = new OrganUserModel();
datas.add(userModel);
userModel.setProviderId(model.getProviderId());
userModel.setValue(model.getText());
userModel.setText(model.getText());
userModel.setType(model.getModelType() + "");
userModel.setOrder(model.getOrder());
userModel.setId(Integer.parseInt(model.getId()));
String fullPathSort = RemoteReqService.getInstance().getOrgFullPathSort(model.getProviderId(), model.getId(), true);
userModel.setFullPathOrder(fullPathSort);
}
Collections.sort(datas, new OrganUserFullPathComparator());
return datas;
}
/**
* 获取当前用户在某个机构下的所有授权对象
* @param searchUserName
* @param orgCode
* @param currentUser
* @param searchType
* @param organId
* @return
*/
public List<UserInOrganEntity> getUsersInOrgan(String searchUserName,String orgCode,String currentUser,int searchType,String organId){
//把自己也要加进来
List<UserInOrganEntity> userOrgans2 = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByOrgIdAndUserId(orgCode, currentUser, searchType);
List<UserInOrganEntity> userOrgans0 = new ArrayList<>();
if (searchUserName.equals("") == false) {
for (UserInOrganEntity entity : userOrgans2) {
if (entity.getUserName().indexOf(searchUserName) == -1) {
// userOrgans0.remove(entity);
} else {
userOrgans0.add(entity);
}
}
} else {
userOrgans0.addAll(userOrgans2);
}
//AuthorityDataCheckerOperator
List<UserInOrganEntity> userOrgans1 = UserInOrganDBAUtil.getInstance().findAllUserInGroupDataByOrgIdAndOreatorId(organId, currentUser, searchType, orgCode, searchUserName);
userOrgans0.addAll(userOrgans1);
//先查人的岗位再查询全路径,因为人的岗位可能会变
for (UserInOrganEntity entity : userOrgans0) {
String userId = entity.getUserId();
String[] temp = userId.split("_");
if (temp.length == 2) {
String provinceId = temp[0];
String userRealId = temp[1];
String orginFullPath = "";
if (entity.getIsMain() == null && entity.getStationId() == null) {
//照顾旧数据
String stationId = RemoteReqService.getInstance().getStationIdByUserId(provinceId, userRealId);
orginFullPath = RemoteReqService.getInstance().getOrgFullPath(provinceId, stationId, true, true);
if ("".equals(orginFullPath) == false && "error".equals(orginFullPath) == false) {
entity.setOrginOrganName(orginFullPath);
}
} else {
//如果是主岗位,如果该用户的岗位没有了,重新查这个人的主岗位,如果是非主岗位,如果没了,那就标记为非主任职发生变动
//如果是主岗位,看下这个岗位已经不上主岗位或者不存在了,重新查主岗位
boolean isExist = false;
String stationId = entity.getStationId();
if(entity.getIsMain().equals("true") == true){
isExist = RemoteReqService.getInstance().isExistMainStation(provinceId, userRealId, stationId);
if (isExist == false){
String mainStationId = RemoteReqService.getInstance().getMainStationIdByUserId(provinceId,userRealId);
if(mainStationId.equals("")){//此时找不到主岗位了。
entity.setOrginOrganName("主岗位发生变动并且无法匹配");
}
else{
orginFullPath = RemoteReqService.getInstance().getOrgFullPath(provinceId, mainStationId, true, true);
if ("".equals(orginFullPath) == false && "error".equals(orginFullPath) == false) {
entity.setOrginOrganName(orginFullPath);
}
}
}
else{//如果存在,实时查下,免得名字那些有改变
orginFullPath = RemoteReqService.getInstance().getOrgFullPath(provinceId, stationId, true, true);
if ("".equals(orginFullPath) == false && "error".equals(orginFullPath) == false) {
entity.setOrginOrganName(orginFullPath);
}
}
}
else{//如果是非主岗位,如果没了,那就标记为非主任职发生变动
isExist = RemoteReqService.getInstance().isExistStation(provinceId, userRealId, stationId);
if (isExist == false){
entity.setOrginOrganName("非主任职发生变动");
}
else{ //如果存在,实时查下,免得名字那些有改变
orginFullPath = RemoteReqService.getInstance().getOrgFullPath(provinceId, stationId, true, true);
if ("".equals(orginFullPath) == false && "error".equals(orginFullPath) == false) {
entity.setOrginOrganName(orginFullPath);
}
}
}
}
entity.setOrganName(entity.getOrganFullPath());
FineLoggerFactory.getLogger().info(entity.getUserName()+"的provinceId为:"+entity.getProvinceId());
if ("-1".equals(entity.getProvinceId()) == false) {
temp = entity.getOrganId().split("_");
provinceId = temp[0];
String orgId = temp[1];
// orginFullPath = RemoteReqService.getInstance().getOrgFullPath(provinceId, orgId, true, false);
// if ("".equals(orginFullPath) == false && "error".equals(orginFullPath) == false) {
// entity.setOrganName(orginFullPath);
// }
// String fullPathSort = RemoteReqService.getInstance().getOrgFullPathSort(provinceId, orgId, true);
String fullPathSort = TieSheSysOrgDBAUtil.getInstance().getEntitySortPathByOrgId(orgId);
FineLoggerFactory.getLogger().info(entity.getUserName()+"的orgId为:"+orgId);
FineLoggerFactory.getLogger().info(entity.getUserName()+"的fullPathSort为:"+fullPathSort);
entity.setFullPathOrder(fullPathSort);
} else { //中国铁建
entity.setFullPathOrder("00000000000");
entity.setOrganName("中国铁建");
}
}
if(entity.getFullPathOrder() == null){
entity.setFullPathOrder("00000000000");
}
}
Collections.sort(userOrgans0, new SecondOrganFullPathComparator());
return userOrgans0;
}
}

521
src/main/java/com/fr/plugin/teshe/services/UserRoleMenuDBAUtil.java

@ -0,0 +1,521 @@
package com.fr.plugin.teshe.services;
import com.fr.plugin.teshe.entity.TieSheDBAccessProvider;
import com.fr.plugin.teshe.entity.UserInOrganEntity;
import com.fr.plugin.teshe.entity.UserRoleMenuItemDAO;
import com.fr.plugin.teshe.entity.UserRoleMenuItemEntity;
import com.fr.stable.db.action.DBAction;
import com.fr.stable.db.dao.DAOContext;
import java.util.ArrayList;
import java.util.List;
public class UserRoleMenuDBAUtil {
private static UserRoleMenuDBAUtil instance;
public static UserRoleMenuDBAUtil getInstance(){
if(instance == null){
instance = new UserRoleMenuDBAUtil();
}
return instance;
}
/**
* 获取该用户在所有组织上的工作授权上的管理功能数据
* @param userId
* @return
*/
public List<UserRoleMenuItemEntity> getWorkAuthorityManageMenuDatasAndParent(String userId,String orgCode){
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getWorkAuthorityManageMenuDatasAndParent(userId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return new ArrayList<>();
}
}
/**
* 删除机构上的用户授权数据
* @param userId
* @param organCode
*/
public void removeAuthorityDataInOrgan(String userId,String organCode){
try{
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserInOrganEntity>() {
@Override
public UserInOrganEntity run(DAOContext context) throws Exception {
// UserInOrganEntity entity = context.getDAO(UserInOrganDAO.class).getById(id);
context.getDAO(UserRoleMenuItemDAO.class).removeAuthorityDataInOrgan(userId,organCode);
return null;
}
});
}catch(Throwable e){
e.printStackTrace();
}
}
/**
* 删除授权数据
* @param id
*/
public void deleteUserRoleMenuById(String id){
try{
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserInOrganEntity>() {
@Override
public UserInOrganEntity run(DAOContext context) throws Exception {
// UserInOrganEntity entity = context.getDAO(UserInOrganDAO.class).getById(id);
context.getDAO(UserRoleMenuItemDAO.class).removeEntityById(id);
return null;
}
});
}catch(Throwable e){
e.printStackTrace();
}
}
/**
* 根据用户id获取授权数据
* @param userId
* @return
*/
public List<UserRoleMenuItemEntity> findAllUserAuthorityDatasByUserId(String userId){
//查询数据库
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).findAllByUserId(userId);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据用户id授权数据id来获取授权数据
* @param userId
* @param menuId
* @return
*/
public List<UserRoleMenuItemEntity> findAllUserAuthorityDatas(String userId, String menuId){
//查询数据库
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).findAll(userId,menuId);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 添加授权数据
* @param entity
* @throws Exception
*/
public void insertUserRoleMenuItemData(UserRoleMenuItemEntity entity) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(UserRoleMenuItemDAO.class).addEntityOrUpdate(entity);
return entity;
}
});
}
/**
* 更新授权数据
* @param userId
* @param menuId
* @param authorityValue
*/
public void updateUserRoleMenuItemDataByUserIdAndMenuId(String userId,String menuId,int authorityValue){
try{
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext context) throws Exception {
// UserInOrganEntity entity = context.getDAO(UserInOrganDAO.class).getById(id);
context.getDAO(UserRoleMenuItemDAO.class).updateEntityByUserIdAndMenuId(userId,menuId,authorityValue);
return null;
}
});
}catch(Throwable e){
e.printStackTrace();
}
}
/**
* 删除授权数据
* @param userId
* @param menuId
*/
public void deleteUserRoleMenuItemDataByUserIdAndMenuId(String userId,String menuId){
try{
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext context) throws Exception {
// UserInOrganEntity entity = context.getDAO(UserInOrganDAO.class).getById(id);
context.getDAO(UserRoleMenuItemDAO.class).removeEntityByUserIdAndMenuId(userId,menuId);
return null;
}
});
}catch(Throwable e){
e.printStackTrace();
}
}
/**
* 根据用户id授权id来获取授权数据
* @param userId
* @param menuId
* @return
*/
public UserRoleMenuItemEntity getUserRoleMenuItemEntityByUserIdAndMenuId(String userId,String menuId){
//查询数据库
try{
UserRoleMenuItemEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getUserRoleMenuItemEntityByUserIdAndMenuId(userId,menuId);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
public List<UserRoleMenuItemEntity> getUserAuthorityDataInOrgan(String userId,String orgCode) {
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getUserAuthorityDataInOrgan(userId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
*设置维护授权数据
* @param userId
* @param menuId
* @param orgCode
* @param authorityValue
* @throws Exception
*/
public void setMaintainAuthority(String userId, String menuId, String orgCode,int authorityValue) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(UserRoleMenuItemDAO.class).setMaintainAuthority(userId,menuId,orgCode,authorityValue);
return null;
}
});
}
/**
*设置管理授权数据
* @param userId
* @param menuId
* @param orgCode
* @param authorityValue
* @throws Exception
*/
public void setManageAuthority(String userId, String menuId, String orgCode,int authorityValue) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(UserRoleMenuItemDAO.class).setManageAuthority(userId,menuId,orgCode,authorityValue);
return null;
}
});
}
/**
* 设置查看授权数据
* @param userId
* @param menuId
* @param orgCode
* @param authorityValue
* @throws Exception
*/
public void setViewAuthority(String userId, String menuId, String orgCode,int authorityValue) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(UserRoleMenuItemDAO.class).setViewAuthority(userId,menuId,orgCode,authorityValue);
return null;
}
});
}
/**
* 删除授权数据
* @param userId
* @param organCode
* @throws Exception
*/
public void deleteByUserIdAndOrgCode(String userId,String organCode) throws Exception {
TieSheDBAccessProvider.tieSheDbAccessor.runDMLAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
daoContext.getDAO(UserRoleMenuItemDAO.class).deleteByUserIdAndOrgCode(userId,organCode);
return null;
}
});
}
/**
* 获取该用户在所有组织上该授权菜单的管理权限数据
* @param userId 用户id
* @param menuId 菜单id
* @param authrotityValue 0 不限制1 关闭2 打开
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getAllManageAuthorityByAuthorityId(String userId,String menuId,int authrotityValue) throws Exception {
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getAllManageAuthorityByAuthorityId(userId,menuId,authrotityValue);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 获取该用户在所有组织上该授权菜单的查看权限数据
* @param userId 用户id
* @param menuId 菜单id
* @param authrotityValue 0 不限制1 关闭2 打开
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getAllViewAuthorityByAuthorityId(String userId,String menuId,int authrotityValue) throws Exception {
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getAllViewAuthorityByAuthorityId(userId,menuId,authrotityValue);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 获取某个用户在某个机构上是否有日志查看的的查看权限
* @param userId
* @param orgCode
* @return
*/
public UserRoleMenuItemEntity getViewOperateLogViewInOrgan(String userId,String orgCode){
try{
UserRoleMenuItemEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getViewOperateLogViewInOrgan(userId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 获取授权数据
* @param userId
* @param menuId
* @param orgCode
* @return
* @throws Exception
*/
public List<UserRoleMenuItemEntity> getUserRoleDataInOrgan(String userId,String menuId,String orgCode) throws Exception{
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getUserRoleDataInOrgan(userId,menuId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return new ArrayList<>();
}
}
public List<UserRoleMenuItemEntity> getUserRoleDataInOrganAndParent(String userId, String menuId, String orgCode) throws Exception{
try{
List<UserRoleMenuItemEntity> entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<List<UserRoleMenuItemEntity>>() {
@Override
public List<UserRoleMenuItemEntity> run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getUserRoleDataInOrganAndParent(userId,menuId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return new ArrayList<>();
}
}
/**
* 获取管理授权数据
* @param userId
* @param orgCode
* @return
*/
public UserRoleMenuItemEntity getManageAuthorityInOrgan(String userId,String orgCode){
try{
UserRoleMenuItemEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getManageAuthorityInOrgan(userId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 根据用户id机构code获取查看授权数据
* @param userId
* @param orgCode
* @return
*/
public UserRoleMenuItemEntity getViewAuthorityInOrgan(String userId, String orgCode){
try{
UserRoleMenuItemEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getViewAuthorityInOrgan(userId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
/**
* 获取查看权限数据
* @param userId
* @param orgCode
* @return
*/
public static UserRoleMenuItemEntity getViewAuthorityViewInOrgan(String userId,String orgCode){
try{
UserRoleMenuItemEntity entities = TieSheDBAccessProvider.tieSheDbAccessor.runQueryAction(new DBAction<UserRoleMenuItemEntity>() {
@Override
public UserRoleMenuItemEntity run(DAOContext daoContext) throws Exception {
return daoContext.getDAO(UserRoleMenuItemDAO.class).getViewAuthorityViewInOrgan(userId,orgCode);
}
});
return entities;
}
catch(Exception ex){
ex.printStackTrace();
return null;
}
}
}

986
src/main/java/com/fr/plugin/teshe/services/UserRoleMenuService.java

@ -0,0 +1,986 @@
package com.fr.plugin.teshe.services;
import com.fr.decision.authority.data.User;
import com.fr.decision.webservice.annotation.RoleCheckerType;
import com.fr.decision.webservice.bean.authority.PrivilegeBean;
import com.fr.decision.webservice.bean.authority.PrivilegeDetailBean;
import com.fr.decision.webservice.bean.entry.EntryBean;
import com.fr.decision.webservice.bean.user.UserBean;
import com.fr.decision.webservice.bean.user.UserUpdateBean;
import com.fr.decision.webservice.v10.authority.AuthorityService;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.plugin.teshe.beans.UserAuthorityModel;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.*;
import com.fr.plugin.teshe.utils.TeSheUtil;
import com.fr.security.encryption.transmission.impl.AESTransmissionEncryption;
import com.fr.third.alibaba.druid.support.json.JSONUtils;
import com.fr.third.guava.collect.Sets;
import java.util.*;
/**
* 管理授权数据的service
*/
public class UserRoleMenuService {
private static UserRoleMenuService instance;
public static UserRoleMenuService getInstance(){
if(instance == null){
instance = new UserRoleMenuService();
}
return instance;
}
public ArrayList<UserAuthorityModel> getAdminAuthorityMenuInfo(String loginUserName,String orgCode) throws Exception{
ArrayList<UserAuthorityModel> userAuthorityModels = TeSheUtil.getUserAssignMenus(loginUserName, loginUserName, orgCode, false);
//下面将组织管理放到平台功能的上面
ArrayList<UserAuthorityModel> userAuthorityModels1 = new ArrayList<>();
UserAuthorityModel roleAssign = null;
UserAuthorityModel roleView = null;
UserAuthorityModel roleLog = null;
UserAuthorityModel orgManage = null;
for (UserAuthorityModel model : userAuthorityModels) {
model.setCanViewAuthority(true);
model.setCanEditAuthority(true);
model.setCanMaintainAuthority(true);
if(model.getId().equals(TieSheController.WORK_AUTHORITY_ID) == false && model.getId().equals(TieSheController.SYSTEM_LOG_ID) == false && model.getId().equals(TieSheController.WORKD_AUTHORITY_VIEW_ID) == false && model.getId().equals(TieSheController.ORGAN_MANAGE_ID) == false){
userAuthorityModels1.add(model);
}
else{
if(model.getId().equals(TieSheController.WORK_AUTHORITY_ID) == true){
roleAssign = model;
}
if(model.getId().equals(TieSheController.SYSTEM_LOG_ID) == true){
roleLog = model;
}
if(model.getId().equals(TieSheController.WORKD_AUTHORITY_VIEW_ID) == true){
roleView = model;
}
if(model.getId().equals(TieSheController.ORGAN_MANAGE_ID) == true){
orgManage = model;
}
}
}
if(orgManage != null){
userAuthorityModels1.add(orgManage);
}
if(roleAssign != null){
userAuthorityModels1.add(roleAssign);
}
if(roleView != null){
userAuthorityModels1.add(roleView);
}
if(roleLog != null){
userAuthorityModels1.add(roleLog);
}
return userAuthorityModels1;
}
public void setUserAuthorityByBatch(String authorityUserName,String userName,String currentUser,String organCode,String authorityInfos,String provinceId,String orgId,String orgName,String ip,String userFullPath,String realName) throws Exception {
//先创建登录账号
User authrotyUser = UserService.getInstance().getUserByUserName(authorityUserName);
if (authrotyUser == null) {
UserBean userBean = new UserBean();
userBean.setRealName(userName);
userBean.setUsername(authorityUserName);
userBean.setPassword(AESTransmissionEncryption.getInstance().encrypt("123456"));
userBean.setEmail("");
userBean.setMobile("");
userBean.setRoleIds(new String[]{});
userBean.setCreationType(0);
userBean.setEnable(true);
userBean.setDepartmentPostIds(new ArrayList<>());
userBean.setExtraAttribute(new HashMap<>());
UserService.getInstance().addUser(userBean);
authrotyUser = UserService.getInstance().getUserByUserName(authorityUserName);
}
String authorityUserId = "";
if (authrotyUser != null) {
authorityUserId = authrotyUser.getId();
}
//先关闭在这个组织上的授权
//先关闭首页
this.cleanAllPlatformHomeAuthority(currentUser, authorityUserId);
//关闭非首页
//先把平台目录,平台功能的所有底层功能(包括查看,管理,权限)关闭,然后统计平台目录,平台功能授予了哪些权限,再来打开
//先将该用户在所有组织上的授权数据查询出来,
List<UserRoleMenuItemEntity> allAuthorityDatas = UserRoleMenuDBAUtil.getInstance().findAllUserAuthorityDatasByUserId(authorityUserId);
ArrayList<String> authortyMenuIds = new ArrayList<>();
//去重一下,因为一个菜单授权包括查看,管理,存了两条数据,所以这里去重下
for (UserRoleMenuItemEntity urie : allAuthorityDatas) {
if (authortyMenuIds.contains(urie.getMenuId()) == false) {
authortyMenuIds.add(urie.getMenuId());
}
}
//关闭授权
for (String menuId : authortyMenuIds) {
try {
closePrivilege(currentUser, menuId, authorityUserId);
} catch (Exception ex) {
ex.printStackTrace();
}
}
//先删除在这个组织上的授权数据
UserRoleMenuDBAUtil.getInstance().removeAuthorityDataInOrgan(authorityUserId, organCode);
String operateLogMsg = "";
//平台首页要特殊处理
Object oauthorityObj = JSONUtils.parse(authorityInfos);
//将平台首页的挑选出来单独处理
ArrayList<LinkedHashMap> authorityList = (ArrayList<LinkedHashMap>) oauthorityObj;
ArrayList<LinkedHashMap> noPlatformHomeList = new ArrayList<>();
if (authorityList.size() > 0) {
// AuthorityResource
if (authorityUserId != null) {
for (LinkedHashMap linkMap : authorityList) {
//先将平台首页的全关掉,然后用新授权数据再次授权
if ((Integer) linkMap.get("modeType") == 1) { //平台首页的
String menuId = linkMap.get("menuId").toString();
int authorityType = (Integer) linkMap.get("authrotityType");
int authrotityValue = (Integer) linkMap.get("authrotityValue");
String menuName = linkMap.get("menuName").toString();
operateLogMsg += ("" + menuName + "的" + (authorityType == 1 ? "查看权限" : "管理权限") + ",");
this.setPlatFormHomeAuthorityEntity(currentUser, authorityUserId, menuId, authorityType, authrotityValue);
} else {
noPlatformHomeList.add(linkMap);
}
}
}
//处理非平台首页的授权
if (noPlatformHomeList.size() > 0) {
//重新插入
for (LinkedHashMap linkMap : noPlatformHomeList) {
String menuId = linkMap.get("menuId").toString();
int authorityType = (Integer) linkMap.get("authrotityType");
int authrotityValue = (Integer) linkMap.get("authrotityValue");
if ((Integer) linkMap.get("modeType") == 2) { //平台目录
this.setPlatFormDirAuthorityEntity( authorityUserId, menuId, authorityType, authrotityValue, organCode, false);
}
if ((Integer) linkMap.get("modeType") == 3) { //平台功能
this.setPlatFormModuleAuthorityEntity(authorityUserId, menuId, authorityType, authrotityValue, organCode);
}
String menuName = linkMap.get("menuName").toString();
String temp = "";
if (authorityType == 1) {
temp = "查看权限";
}
if (authorityType == 3) {
temp = "管理权限";
}
if (authorityType == 4) {
temp = "维护权限";
}
operateLogMsg += ("" + menuName + "的" + temp + ",");
}
}
}
//计算底层授权
//这里在计算该用户在所有组织上一共有多少授权,然后再把底层授权打开
List<UserRoleMenuItemEntity> allMenuItems = UserRoleMenuDBAUtil.getInstance().findAllUserAuthorityDatasByUserId(authorityUserId);
//这里可能一个菜单在一个组织是打开,在另外一个组织是关闭的,所以这里我们要把同一个菜单的所有权限设置找到
HashMap<String, ArrayList<UserRoleMenuItemEntity>> menuIdMapItem = new HashMap<>();
for (UserRoleMenuItemEntity entity : allMenuItems) {
if (menuIdMapItem.containsKey(entity.getMenuId()) == false) {
menuIdMapItem.put(entity.getMenuId(), new ArrayList<>());
}
menuIdMapItem.get(entity.getMenuId()).add(entity);
}
//然后对每一个菜单在分类对比(查看,管理)
for (String key : menuIdMapItem.keySet()) {
ArrayList<UserRoleMenuItemEntity> menuItems = menuIdMapItem.get(key);
ArrayList<UserRoleMenuItemEntity> viewItems = new ArrayList<>();
ArrayList<UserRoleMenuItemEntity> manageItems = new ArrayList<>();
for (UserRoleMenuItemEntity entity : menuItems) {
if (entity.getAuthorityType() == 1) { //查看
viewItems.add(entity);
}
if (entity.getAuthorityType() == 3) {//管理
manageItems.add(entity);
}
}
if (viewItems.size() > 0) {
boolean isOpen = false;
for (UserRoleMenuItemEntity entity : viewItems) {
if (entity.getAuthorityValue() == 2) {
isOpen = true;
}
}
if (isOpen == true) { // 至少在一个组织中该权限菜单是打开的
//底层打开查看权限
this.openViewPrivilege(currentUser, key, authorityUserId);
}
}
if (manageItems.size() > 0) {
boolean isOpen = false;
for (UserRoleMenuItemEntity entity : manageItems) {
if (entity.getAuthorityValue() == 2) {
isOpen = true;
}
}
if (isOpen == true) { // 至少在一个组织中该权限菜单是打开的
//底层打开管理与权限权限
this.openManagePrivilege(currentUser, key, authorityUserId);
}
}
}
String fullPath = "中国铁建";
if ("-1".equals(provinceId) == false) {
TieSheSysOrgEntity sysOrgEntity = TieSheSysOrgDBAUtil.getInstance().getEntityByOrgId(orgId);
fullPath = sysOrgEntity.getFullPath();//TieSheSysOrgService.getInstance().get//RemoteReqService.getInstance().getOrgFullPath(provinceId, orgId, true, false);
if ("error".equals(fullPath) == true) {
fullPath = orgName;
}
}
if (operateLogMsg.equals("")) {
//清除了权限,检查下这个人再所有组织上都没权限了,就应该删除这个人了。
List<UserRoleMenuItemEntity> allRoles = UserRoleMenuDBAUtil.getInstance().findAllUserAuthorityDatasByUserId(authorityUserId);
if(allRoles.size() == 0){
//登录用户删除这个人
UserUpdateBean bean = new UserUpdateBean();
String[] removeIds = new String[1];
removeIds[0] = authrotyUser.getId();
bean.setRemoveUserIds(removeIds);//删除登录用户
UserService.getInstance().deleteUsers(bean);
TieSheFiliRptDBAUtil.getInstance().updateTaskPersonInfo(authorityUserName);
}
TeSheUtil.addOperateLog(currentUser,ip,userFullPath, null, 3, realName+ "在" + fullPath + "给授权对象" + authrotyUser.getRealName() + "清除了所有权限", organCode, realName);
} else {
TeSheUtil.addOperateLog(currentUser,ip,userFullPath, null, 3, realName + "在" + fullPath + "给授权对象" + authrotyUser.getRealName() + "添加了" + operateLogMsg, organCode, realName);
}
}
/**
* 打开底层管理权限
*
* @param req
* @param menuId
* @param authorityUserId
* @throws Exception
*/
private void openManagePrivilege(String currentUser, String menuId, String authorityUserId) throws Exception {
try {
String carrierType = TieSheController.CARRIER_TYPE;
String externalType = "";
PrivilegeBean privilege = new PrivilegeBean();
//privilege.setId(DIR_MANAGE_ROOT_ID);
privilege.setId(menuId);
PrivilegeDetailBean[] values = new PrivilegeDetailBean[2];
PrivilegeDetailBean detailBean1 = new PrivilegeDetailBean(); //管理
values[0] = detailBean1;
detailBean1.setPrivilegeType(3);
detailBean1.setPrivilegeValue(2);
PrivilegeDetailBean detailBean2 = new PrivilegeDetailBean(); //权限
values[1] = detailBean1;
detailBean1.setPrivilegeType(2);
detailBean1.setPrivilegeValue(2);
privilege.setValues(values);
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, authorityUserId, externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* 打开底层查看权限
*
* @param req
* @param menuId
* @param authorityUserId
* @throws Exception
*/
private void openViewPrivilege(String currentUser, String menuId, String authorityUserId) throws Exception {
try {
String carrierType = TieSheController.CARRIER_TYPE;
String externalType = "";
PrivilegeBean privilege = new PrivilegeBean();
privilege.setId(menuId);
PrivilegeDetailBean[] values = new PrivilegeDetailBean[1];
PrivilegeDetailBean detailBean1 = new PrivilegeDetailBean(); //查看
values[0] = detailBean1;
detailBean1.setPrivilegeType(1);
detailBean1.setPrivilegeValue(2);
privilege.setValues(values);
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, authorityUserId, externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
}
/**
* 关闭底层权限
*
* @param req
* @param menuId
* @param authorityUserId
* @throws Exception
*/
public void closePrivilege(String currentUser, String menuId, String authorityUserId) throws Exception {
String carrierType = TieSheController.CARRIER_TYPE;
String externalType = "";
PrivilegeBean privilege = new PrivilegeBean();
//privilege.setId(DIR_MANAGE_ROOT_ID);
privilege.setId(menuId);
PrivilegeDetailBean[] values = new PrivilegeDetailBean[3];
PrivilegeDetailBean detailBean1 = new PrivilegeDetailBean(); //管理
values[0] = detailBean1;
detailBean1.setPrivilegeType(3);
detailBean1.setPrivilegeValue(1);
PrivilegeDetailBean detailBean2 = new PrivilegeDetailBean(); //权限
values[1] = detailBean2;
detailBean2.setPrivilegeType(2);
detailBean2.setPrivilegeValue(1);
PrivilegeDetailBean detailBean3 = new PrivilegeDetailBean(); //查看
values[2] = detailBean3;
detailBean3.setPrivilegeType(1);
detailBean3.setPrivilegeValue(1);
privilege.setValues(values);
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, authorityUserId, externalType, privilege);
}
//功能授权
private void setPlatFormModuleAuthorityEntity( String authorityUserId, String menuItemId, int authrotityType, int authrotityValue, String orgCode) throws Exception {
if (authrotityType == 4) {//开启维护功能
if (authrotityValue == 2) { //开启维护,查看也开启
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 2);
UserRoleMenuDBAUtil.getInstance().setMaintainAuthority(authorityUserId, menuItemId, orgCode, 2);
}
if (authrotityValue == 3) { //开启维护,管理也开启了,查看也开启
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 2);
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, menuItemId, orgCode, 2);
UserRoleMenuDBAUtil.getInstance().setMaintainAuthority(authorityUserId, menuItemId, orgCode, 2);
}
}
if (authrotityType == 3) { //管理功能的开启或者关闭
if (authrotityValue == 1) { //关闭
//关闭组织管理
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, menuItemId, orgCode, 1);
}
if (authrotityValue == 2) { //打开
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 2);
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, menuItemId, orgCode, 2);
}
}
if (authrotityType == 1) { //查看功能
if (authrotityValue == 2) {//打开查看,那么底层每次都打开
//在组织上打开这个权限
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 2);
}
if (authrotityValue == 1) { //关闭查看,需要看该用户是否在所有组织上的的查看都关闭了,如果关闭了,那么底层也关闭,如果不是,底层就先暂时不关闭
//先将组织上关闭这个权限
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 1);
//查看关闭,管理也关闭
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, menuItemId, orgCode, 1);
}
}
}
//目录授权
public void setPlatFormDirAuthorityEntity( String authorityUserId, String menuItemId, int authrotityType, int authrotityValue, String orgCode, boolean isParentChild) throws Exception {
//目录管理有可能传来的是父id,我们自己存的话,需要把它的子以及孙子等都找出来操作。
List<String> menuIds = null;
List<String> parentMenuIds = null;
if (isParentChild) {
HashMap<String, List> dirMenuMap = TeSheUtil.getAdminAllAuthorityMenuItems(2);
List<EntryBean> dirMenuList = dirMenuMap.get("dirEntryBeans");
menuIds = this.findDirChilds(dirMenuList, menuItemId);
//还需要把它的父找出来,如果是关闭,那么它的父也应该是关闭的
parentMenuIds = this.findDirParents(dirMenuList, menuItemId);
}
if (authrotityType == 3) { //管理功能的开启或者关闭
if (authrotityValue == 1) { //关闭
//关闭组织管理
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, menuItemId, orgCode, 1);
if (isParentChild && menuIds != null && parentMenuIds != null) {
for (String newMenuId : menuIds) {
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, newMenuId, orgCode, 1);
}
for (String parentMenuId : parentMenuIds) {
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, parentMenuId, orgCode, 1);
}
}
}
if (authrotityValue == 2) { //增加管理权限与查看权限
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 2);
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, menuItemId, orgCode, 2);
if (isParentChild && menuIds != null && parentMenuIds != null) {
for (String newMenuId : menuIds) {
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, newMenuId, orgCode, 2);
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, newMenuId, orgCode, 2);
}
}
}
}
if (authrotityType == 1) { //查看
if (authrotityValue == 1) { //关闭
//先将组织上关闭这个权限
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 1);
//查看关闭,管理也关闭
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, menuItemId, orgCode, 1);
if (isParentChild && menuIds != null && parentMenuIds != null) {
for (String newMenuId : menuIds) {
//先将组织上关闭这个权限
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, newMenuId, orgCode, 1);
//查看关闭,管理也关闭
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, newMenuId, orgCode, 1);
}
for (String parentMenuId : parentMenuIds) {
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, parentMenuId, orgCode, 1);
UserRoleMenuDBAUtil.getInstance().setManageAuthority(authorityUserId, parentMenuId, orgCode, 1);
}
}
} else {//打开查看,那么底层每次都打开
//组织上打开这个权限
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, menuItemId, orgCode, 2);
if (isParentChild && menuIds != null) {
for (String newMenuId : menuIds) {
//子也打开
UserRoleMenuDBAUtil.getInstance().setViewAuthority(authorityUserId, newMenuId, orgCode, 2);
}
}
}
}
}
/**
* 找寻某个授权菜单的父爷爷id
*
* @param list
* @param targetId
* @return
*/
private List<String> findDirParents(List<EntryBean> list, String targetId) {
ArrayList<String> results = new ArrayList<>();
HashMap<String, EntryBean> beanMap = new HashMap<>();
for (EntryBean entry : list) {
beanMap.put(entry.getId(), entry);
if (targetId.equals(entry.getId()) && entry.getpId() == null) { //targetId直接是根元素,所以不需要找父了。
return results;
}
}
EntryBean targetNode = beanMap.get(targetId);
EntryBean parent = beanMap.get(targetNode.getpId());
while (parent != null) {
results.add(parent.getId());
parent = beanMap.get(parent.getpId());
}
return results;
}
/**
* 找寻某个授权菜单的子孙子id
*
* @param list
* @param targetId
* @return
*/
private List<String> findDirChilds(List<EntryBean> list, String targetId) {
ArrayList<String> results = new ArrayList<>();
HashMap<String, EntryBean> beanMap = new HashMap<>();
for (EntryBean entry : list) {
beanMap.put(entry.getId(), entry);
if (targetId.equals(entry.getId()) && entry.isIsParent() == false) { //targetId直接是根元素,所以不需要找子了
return results;
}
}
//EntryBean parent = beanMap.get(targetId);
iterateDirChilds(beanMap, results, targetId);
return results;
}
private void iterateDirChilds(HashMap<String, EntryBean> beanMap, ArrayList<String> results, String pid) {
for (String key : beanMap.keySet()) {
if (beanMap.get(key).getpId() != null && beanMap.get(key).getpId().equals(pid)) {
results.add(beanMap.get(key).getId());
if (beanMap.get(key).isIsParent() == false) {
// results.add(beanMap.get(key).getId());
} else {
iterateDirChilds(beanMap, results, beanMap.get(key).getId());
}
}
}
}
/**
* 清除该用户在平台首页上的所有授权
*
* @param userId
* @throws Exception
*/
private void cleanAllPlatformHomeAuthority(String userName, String userId) throws Exception {
HashMap<String, List> adminAllMenuMap = TeSheUtil.getAdminAllAuthorityMenuItems(1);
List<EntryBean> entryBeans1 = (List<EntryBean>) adminAllMenuMap.get("homeEntryBeans");
for (EntryBean eb : entryBeans1) {
String carrierType = TieSheController.CARRIER_TYPE;
String externalType = "";
PrivilegeBean privilege = new PrivilegeBean();
privilege.setId(eb.getId());
PrivilegeDetailBean[] newvalues = new PrivilegeDetailBean[3];
PrivilegeDetailBean detailBean1 = new PrivilegeDetailBean(); //查看
newvalues[0] = detailBean1;
detailBean1.setPrivilegeType(1);
detailBean1.setPrivilegeValue(1);
PrivilegeDetailBean detailBean2 = new PrivilegeDetailBean(); //权限
newvalues[1] = detailBean2;
detailBean2.setPrivilegeType(2);
detailBean2.setPrivilegeValue(1);
PrivilegeDetailBean detailBean3 = new PrivilegeDetailBean(); //管理
newvalues[2] = detailBean3;
detailBean2.setPrivilegeType(3);
detailBean2.setPrivilegeValue(1);
privilege.setValues(newvalues);
try {
this.updateAuthorityEntityByCarrier(userName, carrierType, userId, externalType, privilege);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
public void updateAuthorityEntityByCarrier(String userName, String carrierType, String carrierId, String externalType, PrivilegeBean privilege) throws Exception {
String userId = TeSheUtil.getCurrentLoginUserId(userName); //UserService.getInstance().getCurrentUserId(req);
RoleCheckerType.checkAuthorizeAuthority(userId, carrierId, carrierType);
AuthorityService.getInstance().checkUserAssignAuthority(userId, Sets.newHashSet(new String[]{privilege.getId()}), privilege.getAuthorityTypes(), externalType);
AuthorityService.getInstance().updateAuthorityEntityByCarrier(userId, carrierType, carrierId, privilege, externalType);
}
/**
* 普通用户获取授权菜单
* @param operatorUserId
* @param loginUserName
* @param orgCode
* @param view
* @return
* @throws Exception
*/
public ArrayList<UserAuthorityModel> getCommonAuthorityMenuInfo(String operatorUserId,String loginUserName,String orgCode,boolean view) throws Exception {
//先查出登录用户具有哪些权限菜单
//获取授权用户的添加人有多少授权数据
ArrayList<UserAuthorityModel> authorityModels = TeSheUtil.getUserAssignMenus(operatorUserId, loginUserName, orgCode, true);
HashMap<String, UserAuthorityModel> idMapUserAuthorityModel = new HashMap<>();
for (UserAuthorityModel model1 : authorityModels) {
model1.setCanEditAuthority(false);
model1.setCanEditAuthority(false);
model1.setCanMaintainAuthority(false);
idMapUserAuthorityModel.put(model1.getId(), model1);
}
ArrayList<UserAuthorityModel> userAuthorityModels = new ArrayList<>();
for (UserAuthorityModel model : authorityModels) {
//这里只获取该用户拥有的管理功能,查看不需要,因为管理功能授权才能给其他人授权这个功能,查看是不能授权给别人的。
//if (model.getViewAuthority() == 2 || model.getEditAuthority() == 2) {
if (view == true) {
if (model.getEditAuthority() == 2 || model.getViewAuthority() == 2) {
if (userAuthorityModels.contains(model) == false) {
userAuthorityModels.add(model);
// model.setpId("decision-role-root");
//寻找父亲
String pid = model.getpId();
UserAuthorityModel parentModel = null;
while (pid != null) {
parentModel = idMapUserAuthorityModel.get(pid);
if (parentModel != null) {
if (userAuthorityModels.contains(parentModel) == false && !pid.equals("decision-homepage-root") && !pid.equals("decision-directory-root") && !pid.equals("decision-management-root")) {
userAuthorityModels.add(parentModel);
}
pid = parentModel.getpId();
if (parentModel.getpId() == null) {
parentModel.setpId("decision-role-root");
}
} else {
pid = null;
}
}
if (model.getViewAuthority() == 2) {
model.setCanViewAuthority(true);
}
if (model.getEditAuthority() == 2) {
model.setCanEditAuthority(true);
}
if (model.getMaintainAuthority() == 2) {
model.setCanMaintainAuthority(true);
}
}
}
} else {
if (model.getMaintainAuthority() == 2) {
model.setCanMaintainAuthority(true);
}
if (model.getEditAuthority() == 2) {
if (userAuthorityModels.contains(model) == false) {
userAuthorityModels.add(model);
// model.setpId("decision-role-root");
//寻找父亲
String pid = model.getpId();
UserAuthorityModel parentModel = null;
while (pid != null) {
parentModel = idMapUserAuthorityModel.get(pid);
if (parentModel != null) {
if (userAuthorityModels.contains(parentModel) == false && !pid.equals("decision-homepage-root") && !pid.equals("decision-directory-root") && !pid.equals("decision-management-root")) {
userAuthorityModels.add(parentModel);
}
pid = parentModel.getpId();
if (parentModel.getpId() == null) {
parentModel.setpId("decision-role-root");
}
} else {
pid = null;
}
}
}
}
if (model.getEditAuthority() == 2) {
model.setCanEditAuthority(true);
model.setCanViewAuthority(true);
}
}
}
//把我该有的权限找出来之后,应该把一些值还原,然后再去看这个用户有哪些权限
for (UserAuthorityModel model : userAuthorityModels) {
model.setViewAuthority(1);
model.setEditAuthority(1);
model.setMaintainAuthority(1);
if (view == true) {
model.setCanEditAuthority(false);
model.setCanViewAuthority(false);
model.setCanMaintainAuthority(false);
}
}
//查询分配这个人以前是否分了哪些权限.
String userId = "";
User user = UserService.getInstance().getUserByUserName(loginUserName);
if (user != null) {
userId = user.getId();
ArrayList<String> homeIds = new ArrayList<>();
ArrayList<String> dirIds = new ArrayList<>();
ArrayList<String> functionIds = new ArrayList<>();
HashMap<String, UserAuthorityModel> hashMap = new HashMap<>();
for (UserAuthorityModel model : userAuthorityModels) {
model.setViewAuthority(1);
model.setEditAuthority(1);
model.setMaintainAuthority(1);
hashMap.put(model.getId(), model);
if (model.getModelType() == 1) {
homeIds.add(model.getId());
}
if (model.getModelType() == 2) {
dirIds.add(model.getId());
}
if (model.getId().equals(TieSheController.WORK_AUTHORITY_ID) || model.getId().equals(TieSheController.WORKD_AUTHORITY_VIEW_ID) || model.getId().equals(TieSheController.SYSTEM_LOG_ID) || model.getId().equals(TieSheController.ORGAN_MANAGE_ID)) {
functionIds.add(model.getId());
}
}
Map<String, Object> authorityMap;
ArrayList authorityMapValues;
if (homeIds.size() > 0) {
authorityMap = TeSheUtil.getPlatFormHomePageAuthorityEntity(homeIds, userId);
authorityMapValues = (ArrayList) authorityMap.get("homepage");
for (Object pb : authorityMapValues) {
if (pb instanceof PrivilegeBean) {
PrivilegeBean pb1 = (PrivilegeBean) pb;
UserAuthorityModel authorityModel = hashMap.get(pb1.getId());
if (authorityModel != null) {
PrivilegeDetailBean[] values = pb1.getValues();
for (PrivilegeDetailBean pdb : values) {
if (pdb.getPrivilegeType() == 1) {
authorityModel.setViewAuthority(pdb.getPrivilegeValue());
if (pdb.getPrivilegeValue() == 2 && view == true) {
authorityModel.setCanViewAuthority(true);
}
}
if (pdb.getPrivilegeType() == 3) {
authorityModel.setEditAuthority(pdb.getPrivilegeValue());
if (pdb.getPrivilegeValue() == 2 && view == true) {
authorityModel.setCanEditAuthority(true);
}
}
}
}
}
}
}
if (dirIds.size() > 0) {
for (String newMenuId : dirIds) {
List<UserRoleMenuItemEntity> roleEntitys = UserRoleMenuDBAUtil.getInstance().getUserRoleDataInOrgan(userId, newMenuId, orgCode);
for (UserRoleMenuItemEntity roleEntity : roleEntitys) {
UserAuthorityModel authorityModel = hashMap.get(roleEntity.getMenuId());
if (roleEntity.getAuthorityType() == 1) {
authorityModel.setViewAuthority(roleEntity.getAuthorityValue());
if (roleEntity.getAuthorityValue() == 2 && view == true) {
authorityModel.setCanViewAuthority(true);
}
}
if (roleEntity.getAuthorityType() == 3) {
authorityModel.setEditAuthority(roleEntity.getAuthorityValue());
if (roleEntity.getAuthorityValue() == 2 && view == true) {
authorityModel.setCanEditAuthority(true);
}
}
}
}
}
if (functionIds.size() > 0) {
for (String newMenuId : functionIds) {
List<UserRoleMenuItemEntity> roleEntitys = UserRoleMenuDBAUtil.getInstance().getUserRoleDataInOrgan(userId, newMenuId, orgCode);
for (UserRoleMenuItemEntity roleEntity : roleEntitys) {
UserAuthorityModel authorityModel = hashMap.get(roleEntity.getMenuId());
if (roleEntity.getAuthorityType() == 1) {
authorityModel.setViewAuthority(roleEntity.getAuthorityValue());
if (roleEntity.getAuthorityValue() == 2 && view == true) {
authorityModel.setCanViewAuthority(true);
}
}
if (roleEntity.getAuthorityType() == 3) {
authorityModel.setEditAuthority(roleEntity.getAuthorityValue());
if (roleEntity.getAuthorityValue() == 2 && view == true) {
authorityModel.setCanEditAuthority(true);
}
}
if (roleEntity.getAuthorityType() == 4) {
authorityModel.setMaintainAuthority(roleEntity.getAuthorityValue());
if (roleEntity.getAuthorityValue() == 2 && view == true) {
authorityModel.setCanMaintainAuthority(true);
}
}
}
}
}
}
ArrayList<UserAuthorityModel> userAuthorityModels1 = new ArrayList<>();
UserAuthorityModel roleAssign = null;
UserAuthorityModel roleView = null;
UserAuthorityModel roleLog = null;
UserAuthorityModel orgManage = null;
for (UserAuthorityModel model : userAuthorityModels) {
if(model.getId().equals(TieSheController.WORK_AUTHORITY_ID) == false && model.getId().equals(TieSheController.SYSTEM_LOG_ID) == false && model.getId().equals(TieSheController.WORKD_AUTHORITY_VIEW_ID) == false && model.getId().equals(TieSheController.ORGAN_MANAGE_ID) == false){
userAuthorityModels1.add(model);
}
else{
if(model.getId().equals(TieSheController.WORK_AUTHORITY_ID) == true){
roleAssign = model;
}
if(model.getId().equals(TieSheController.SYSTEM_LOG_ID) == true){
roleLog = model;
}
if(model.getId().equals(TieSheController.WORKD_AUTHORITY_VIEW_ID) == true){
roleView = model;
}
if(model.getId().equals(TieSheController.ORGAN_MANAGE_ID) == true){
orgManage = model;
}
}
}
if(orgManage != null){
userAuthorityModels1.add(orgManage);
}
if(roleAssign != null){
userAuthorityModels1.add(roleAssign);
}
if(roleView != null){
userAuthorityModels1.add(roleView);
}
if(roleLog != null){
userAuthorityModels1.add(roleLog);
}
return userAuthorityModels1;
}
//首页授权
private void setPlatFormHomeAuthorityEntity(String currentUser, String authorityUserId, String menuItemId, int authrotityType, int authrotityValue) throws Exception {
String carrierType = TieSheController.CARRIER_TYPE;
// String carrierId = "decision-dep-root"; // 7a012927-254f-4b4b-85b6-c8bd7d57d200 部门id或者角色id或者人id
String externalType = "";
PrivilegeBean privilege = new PrivilegeBean();
// privilege.setId("decision-management-user-role-assign"); // 08173d40-9886-4f69-841f-c281f2a90882 目录id,菜单id或者人员id
privilege.setId(menuItemId);
if (authrotityType == 3) { //管理功能的开启或者关闭
if (authrotityValue == 1) { //关闭
//删除管理权限
PrivilegeDetailBean[] values = new PrivilegeDetailBean[2];
PrivilegeDetailBean detailBean1 = new PrivilegeDetailBean(); //查看
values[0] = detailBean1;
detailBean1.setPrivilegeType(3);
detailBean1.setPrivilegeValue(1);
PrivilegeDetailBean detailBean2 = new PrivilegeDetailBean(); //权限
values[1] = detailBean2;
detailBean2.setPrivilegeType(2);
detailBean2.setPrivilegeValue(1);
privilege.setValues(values);
}
if (authrotityValue == 2) { //增加管理权限
PrivilegeDetailBean[] values = new PrivilegeDetailBean[2];
PrivilegeDetailBean detailBean2 = new PrivilegeDetailBean(); //管理
values[0] = detailBean2;
detailBean2.setPrivilegeType(3);
detailBean2.setPrivilegeValue(2);
PrivilegeDetailBean detailBean3 = new PrivilegeDetailBean(); //权限
values[1] = detailBean3;
detailBean3.setPrivilegeType(2);
detailBean3.setPrivilegeValue(2);
privilege.setValues(values);
}
if (authrotityValue == 3) { //查看,管理都选了
PrivilegeDetailBean[] values = new PrivilegeDetailBean[3];
PrivilegeDetailBean detailBean2 = new PrivilegeDetailBean(); //管理
values[0] = detailBean2;
detailBean2.setPrivilegeType(3);
detailBean2.setPrivilegeValue(2);
PrivilegeDetailBean detailBean3 = new PrivilegeDetailBean(); //权限
values[1] = detailBean3;
detailBean3.setPrivilegeType(2);
detailBean3.setPrivilegeValue(2);
PrivilegeDetailBean detailBean4 = new PrivilegeDetailBean(); //查看
values[2] = detailBean4;
detailBean4.setPrivilegeType(1);
detailBean4.setPrivilegeValue(2);
privilege.setValues(values);
}
}
if (authrotityType == 1) {
PrivilegeDetailBean[] values = new PrivilegeDetailBean[2];
PrivilegeDetailBean detailBean1 = new PrivilegeDetailBean(); //查看
values[0] = detailBean1;
detailBean1.setPrivilegeType(authrotityType);
detailBean1.setPrivilegeValue(authrotityValue);
PrivilegeDetailBean detailBean3 = new PrivilegeDetailBean(); //权限
values[1] = detailBean3;
detailBean3.setPrivilegeType(2);
detailBean3.setPrivilegeValue(authrotityValue);
privilege.setValues(values);
}
UserRoleMenuService.getInstance().updateAuthorityEntityByCarrier(currentUser, carrierType, authorityUserId, externalType, privilege);
}
}

34
src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheOrganSystemOptionOrganManageProvider.java

@ -0,0 +1,34 @@
package com.fr.plugin.teshe.systemOptionProvider;
import com.fr.decision.fun.impl.AbstractSystemOptionProvider;
import com.fr.decision.web.MainComponent;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.jscss.TeSheMainDef;
import com.fr.web.struct.Atom;
public class TeSheOrganSystemOptionOrganManageProvider extends AbstractSystemOptionProvider {
@Override
public String id() {
return TieSheController.ORGAN_MANAGE_ID;
}
@Override
public String displayName() {
return "组织管理";
}
@Override
public int sortIndex() {
return 4;
}
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return TeSheMainDef.KEY;
}
}

35
src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheSystemOptionAuthorityViewProvider.java

@ -0,0 +1,35 @@
package com.fr.plugin.teshe.systemOptionProvider;
import com.fr.decision.fun.impl.AbstractSystemOptionProvider;
import com.fr.decision.web.MainComponent;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.jscss.TeSheMainDef;
import com.fr.web.struct.Atom;
public class TeSheSystemOptionAuthorityViewProvider extends AbstractSystemOptionProvider {
@Override
public String id() {
return TieSheController.WORKD_AUTHORITY_VIEW_ID;
}
@Override
public String displayName() {
return "授权查询";
}
@Override
public int sortIndex() {
return 2;
}
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return TeSheMainDef.KEY;
}
}

35
src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheSystemOptionLogViewProvider.java

@ -0,0 +1,35 @@
package com.fr.plugin.teshe.systemOptionProvider;
import com.fr.decision.fun.impl.AbstractSystemOptionProvider;
import com.fr.decision.web.MainComponent;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.jscss.TeSheMainDef;
import com.fr.web.struct.Atom;
public class TeSheSystemOptionLogViewProvider extends AbstractSystemOptionProvider {
@Override
public String id() {
return TieSheController.SYSTEM_LOG_ID;
}
@Override
public String displayName() {
return "系统日志";
}
@Override
public int sortIndex() {
return 3;
}
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return TeSheMainDef.KEY;
}
}

54
src/main/java/com/fr/plugin/teshe/systemOptionProvider/TeSheSystemOptionProvider.java

@ -0,0 +1,54 @@
package com.fr.plugin.teshe.systemOptionProvider;
import com.fr.decision.authority.base.AuthorityConstants;
import com.fr.decision.authority.base.constant.AuthorityStaticItemId;
import com.fr.decision.fun.impl.AbstractSystemOptionProvider;
import com.fr.decision.web.MainComponent;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.jscss.TeSheMainDef;
import com.fr.web.struct.Atom;
public class TeSheSystemOptionProvider extends AbstractSystemOptionProvider {
@Override
public String id() {
return TieSheController.WORK_AUTHORITY_ID;
}
@Override
public String displayName() {
return "工作授权";
}
@Override
public int sortIndex() {
return 1;
}
/*
@Override
public String fullPath() {
//用来控制后台实际权限判断的,
return AuthorityStaticItemId.DEC_MANAGEMENT_ID+
AuthorityConstants.FULL_PATH_SPLITTER+
AuthorityStaticItemId.DEC_MANAGEMENT_USER_ID;
}
@Override
public String parentId() {
//一般说来用不到,因为决策平台自身可折叠的管理菜单本身只有
return AuthorityStaticItemId.DEC_MANAGEMENT_MAINTENANCE_ID;
}
*/
@Override
public Atom attach() {
return MainComponent.KEY;
}
@Override
public Atom client() {
return TeSheMainDef.KEY;
}
}

135
src/main/java/com/fr/plugin/teshe/task/OrganSyncTask.java

@ -0,0 +1,135 @@
package com.fr.plugin.teshe.task;
import com.fr.base.Base64;
import com.fr.base.ServerConfig;
import com.fr.decision.authority.data.User;
import com.fr.decision.webservice.bean.user.UserUpdateBean;
import com.fr.decision.webservice.v10.user.UserService;
import com.fr.design.actions.file.export.ExcelExportAction;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.conf.ConfigXmlReader;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.*;
import com.fr.plugin.teshe.services.*;
import com.fr.plugin.teshe.utils.TeSheUtil;
import com.fr.third.org.quartz.core.QuartzScheduler;
import com.fr.web.controller.decision.api.entry.EntryResource;
import java.util.ArrayList;
import java.util.List;
import java.util.TimerTask;
public class OrganSyncTask extends TimerTask {
public static OrganSyncTask taskInstance = new OrganSyncTask();
public void syncRemoteOrgan() throws Exception {
List<UserInOrganEntity> allUserInOrgan = UserInOrganDBAUtil.getInstance().findAllUserInGroupData();
List<UserInOrganEntity> remoteOrgans = new ArrayList<>();
FineLoggerFactory.getLogger().info("一共查询到:" + allUserInOrgan.size() + "个授权用户");
//将中国铁建下的用户下的用户排除掉
for (UserInOrganEntity entity : allUserInOrgan) {
if (entity.getOrganCode().equals(TieSheController.ROOT_ORGCODE) == false) { //不是中国铁建下的用户.
remoteOrgans.add(entity);
}
}
FineLoggerFactory.getLogger().info("排除中国铁建下的,一共需要处理:" + remoteOrgans.size() + "个用户机构需要处理");
for (UserInOrganEntity entity1 : remoteOrgans) {
FineLoggerFactory.getLogger().info("现在处理:" + entity1.getUserName() + "在 " + entity1.getOrganName());
String orgId = entity1.getOrganId();
String[] temps = orgId.split("_");
String provinceId = temps[0];
orgId = temps[1];
//通过本地组织数据得到人事系统对应机构id。
boolean canDelete = false;
TieSheSysOrgEntity sysOrgEntity = TieSheSysOrgDBAUtil.getInstance().getEntityByOrgId(orgId);
if (sysOrgEntity != null) {
String hrscope = sysOrgEntity.getHrScope();
if(hrscope != null){
temps = hrscope.split("_");
if (temps.length == 3) {
provinceId = temps[0];
orgId = temps[1];
String orgType = temps[2];
String orgInfo = "";
//获取人事系统组织信息
if (orgType.equals("2")) { //部门
orgInfo = RemoteReqService.getInstance().getOrgDepInfo(provinceId, orgId);
} else { //单位
orgInfo = RemoteReqService.getInstance().getOrgUnitInfo(provinceId, orgId);
}
if (orgInfo.equals("") == true) { //表示人事系统组织被删除了
FineLoggerFactory.getLogger().info(entity1.getOrganName() + "已经不存在了,准备删除该组织下的所有用户数据,包括权限");
canDelete = true;
}
}
}
}
else{
FineLoggerFactory.getLogger().info("本地组织不存在了,准备删除该用户以及授权");
canDelete = true;
}
if(canDelete == true){
FineLoggerFactory.getLogger().info("开始删除 ");
//找到该对象的所有授权组织
List<UserInOrganEntity> allUserEntity = UserInOrganDBAUtil.getInstance().findUserInGroupDataByUserId(entity1.getUserId());
//找到登录账号
User deleteUser = UserService.getInstance().getUserByUserName(entity1.getUserId());
if (deleteUser != null) {
//找到该用户的所有授权对象
List<UserRoleMenuItemEntity> allwRoleEntity = UserRoleMenuDBAUtil.getInstance().findAllUserAuthorityDatasByUserId(deleteUser.getId());
//删除
UserUpdateBean bean = new UserUpdateBean();
String[] removeIds = new String[1];
removeIds[0] = deleteUser.getId();
bean.setRemoveUserIds(removeIds);
FineLoggerFactory.getLogger().info("删除登录账号: "+deleteUser.getUserName());
//删除登录用户
UserService.getInstance().deleteUsers(bean);
TieSheFiliRptDBAUtil.getInstance().updateTaskPersonInfo(entity1.getUserId());
//删除授权数据
FineLoggerFactory.getLogger().info("删除授权数据 ");
for (UserRoleMenuItemEntity roleEn : allwRoleEntity) {
UserRoleMenuDBAUtil.getInstance().deleteUserRoleMenuById(roleEn.getId());
}
}
//删除授权对象
FineLoggerFactory.getLogger().info("删除授权对象 ");
for (UserInOrganEntity userEn : allUserEntity) {
UserInOrganDBAUtil.getInstance().deleteUserInGroupDataById(userEn.getId());
}
}
}
}
@Override
public void run() {
try {
FineLoggerFactory.getLogger().info("定时任务开始...");
//先获取token
TieSheController.tieSheToken = TeSheUtil.getAccessToken();
FineLoggerFactory.getLogger().info("先获取最新token:" + TieSheController.tieSheToken);
//检查人事系统组织是否有删除,有的话本地组织也要删除
syncRemoteOrgan();
} catch (Exception ex) {
FineLoggerFactory.getLogger().info("定时任务异常:" + ex.toString());
}
}
}

369
src/main/java/com/fr/plugin/teshe/utils/TeSheUtil.java

@ -0,0 +1,369 @@
package com.fr.plugin.teshe.utils;
import com.fr.base.Base64;
import com.fr.base.ServerConfig;
import com.fr.decision.authority.data.User;
import com.fr.decision.webservice.bean.authority.PrivilegeBean;
import com.fr.decision.webservice.bean.authority.PrivilegeDetailBean;
import com.fr.decision.webservice.bean.authority.PrivilegeOperator;
import com.fr.decision.webservice.bean.entry.DecisionMgrModuleBean;
import com.fr.decision.webservice.bean.entry.EntryBean;
import com.fr.decision.webservice.v10.authority.AuthorityService;
import com.fr.decision.webservice.v10.entry.EntryService;
import com.fr.decision.webservice.v10.login.LoginService;
import com.fr.decision.webservice.v10.module.ManagerModuleService;
import com.fr.decision.webservice.v10.user.UserService;
import com.fine.plugin.tools.DateUtil;
import com.fr.log.FineLoggerFactory;
import com.fr.plugin.teshe.beans.UserAuthorityModel;
import com.fr.plugin.teshe.conf.ConfigXmlReader;
import com.fr.plugin.teshe.controller.TieSheController;
import com.fr.plugin.teshe.entity.UserInOrganEntity;
import com.fr.plugin.teshe.entity.UserRoleMenuItemEntity;
import com.fr.plugin.teshe.services.RemoteReqService;
import com.fr.plugin.teshe.services.TieSheOperateLogService;
import com.fr.plugin.teshe.services.UserRoleMenuDBAUtil;
import com.fr.plugin.teshe.services.UserRoleMenuService;
import javax.servlet.http.HttpServletRequest;
import java.io.UnsupportedEncodingException;
import java.util.*;
public class TeSheUtil {
//获取当前用户的登录名
public static String getCurrentLoginUser(HttpServletRequest req) {
//HomePageResource
return LoginService.getInstance().getCurrentUserNameFromRequestCookie(req);
// return "hrwx_143770";
}
//获取当前用户的用户id
public static String getCurrentLoginUserId(String userName) throws Exception {
//HomePageResource
User user = UserService.getInstance().getUserByUserName(userName);
if (user != null) {
return user.getId();
}
return "";
}
//获取当前用户的真实姓名
public static String getCurrentLoginRealName(HttpServletRequest req) {
//HomePageResource
String userName = "";
try {
userName = getCurrentLoginUser(req);
User user = UserService.getInstance().getUserByUserName(userName);
if (user != null) {
return user.getRealName();
}
return userName;
} catch (Exception ex) {
ex.printStackTrace();
return userName;
}
}
//获取当前时间
public static String getNowDate() {
return DateUtil.getNowDateYMDHMS();
}
public static String getAccessToken() throws UnsupportedEncodingException {
String base64str = ConfigXmlReader.getInstance().clientId + ":" + ConfigXmlReader.getInstance().clientSecret;
base64str = new String(Base64.encode(base64str.getBytes(ServerConfig.getInstance().getServerCharset())));
return RemoteReqService.getInstance().getTieSheToken(base64str);
}
/**
* 获取机构id并且要去重
* @param userInOrgans
* @return
*/
public static void getUniqueCodes(List<UserInOrganEntity> userInOrgans,ArrayList<String> orgCodes){
orgCodes.clear();
//orgCode去重,有可能父orgCode再里面,子也再里面,那么这里只需要保留子就行了。
HashMap<String, UserInOrganEntity> orgCodeAndEntityMap = new HashMap<>();
for (UserInOrganEntity en : userInOrgans) {
orgCodeAndEntityMap.put(en.getOrganCode(), en);
}
Set<String> keys = orgCodeAndEntityMap.keySet();
//先排序
Set<String> sortKeys = new TreeSet<String>(new Comparator<String>() {
@Override
public int compare(String o1, String o2) {
return o2.compareTo(o1);
}
});
sortKeys.addAll(keys);
ArrayList<String> newKeys = new ArrayList<>();
while (sortKeys.size() > 0) {
Object[] keyStrings = sortKeys.toArray();
String element = keyStrings[keyStrings.length - 1].toString();
for (int i = keyStrings.length - 2; i >= 0; i--) {
String otherElement = keyStrings[i].toString();
if (otherElement.indexOf(element) != -1) {
sortKeys.remove(otherElement);
}
}
newKeys.add(element);
sortKeys.remove(element);
}
for (String key : newKeys) {
orgCodes.add(key);
}
}
/**
* 获取该用户的授权项
* @param loginUserName
* @param selfUserName
* @param orgCode
* @param isFindParent
* @return
* @throws Exception
*/
public static ArrayList<UserAuthorityModel> getUserAssignMenus(String loginUserName, String selfUserName, String orgCode, boolean isFindParent) throws Exception {
String userId = "";
//查找这个待授权用户是谁添加的这个人的信息,这个人的菜单数据就是待授权用户的可授权菜单数据
User user = UserService.getInstance().getUserByUserName(loginUserName);
ArrayList<UserAuthorityModel> userAuthorityModels = new ArrayList<>();
User adminUser = UserService.getInstance().getUserByUserName("admin");
//admin用户所有的可授权菜单数据
HashMap<String, List> adminAllMenuMap = getAdminAllAuthorityMenuItems(0);
if (user != null) {
userId = user.getId();
} else {
//如果待授权用户的添加人被删除了,那么就只能找当前登录人的可授权菜单数据了。
FineLoggerFactory.getLogger().info("授权或者查看授权时,发现用户:" + loginUserName + "不存在了....");
user = UserService.getInstance().getUserByUserName(selfUserName);
if (user != null) {
userId = user.getId();
}
}
ArrayList<String> ids = new ArrayList<>();
HashMap<String, UserAuthorityModel> hashMap = new HashMap<>();
Map<String, Object> authorityMap;
ArrayList authorityMapValues;
//获取管理首页数据
List<EntryBean> entryBeans1 = (List<EntryBean>) adminAllMenuMap.get("homeEntryBeans"); //EntryService.getInstance().getHomePages(adminUser.getId(), "");
for (EntryBean eb : entryBeans1) {
ids.add(eb.getId());
UserAuthorityModel authorityModel = new UserAuthorityModel();
userAuthorityModels.add(authorityModel);
authorityModel.setId(eb.getId());
authorityModel.setpId(eb.getpId());
authorityModel.setText(eb.getText());
authorityModel.setEditAuthority(1);
authorityModel.setViewAuthority(1);
authorityModel.setModelType(1);
hashMap.put(eb.getId(), authorityModel);
}
if (!userId.equals("")) {
//查看该用户在首页上有多少授权数据
authorityMap = getPlatFormHomePageAuthorityEntity(ids, userId);
authorityMapValues = (ArrayList) authorityMap.get("homepage");
for (Object pb : authorityMapValues) {
if (pb instanceof PrivilegeBean) {
PrivilegeBean pb1 = (PrivilegeBean) pb;
UserAuthorityModel authorityModel = hashMap.get(pb1.getId());
if (authorityModel != null) {
PrivilegeDetailBean[] values = pb1.getValues();
for (PrivilegeDetailBean pdb : values) {
if (pdb.getPrivilegeType() == 1) {
authorityModel.setViewAuthority(pdb.getPrivilegeValue());
}
if (pdb.getPrivilegeType() == 3) {
authorityModel.setEditAuthority(pdb.getPrivilegeValue());
}
}
}
}
}
}
//获取管理目录数据
ids.clear();
List<EntryBean> entryBeans2 = (List<EntryBean>) adminAllMenuMap.get("dirEntryBeans");//EntryService.getInstance().getAllEntries(adminUser.getId());
HashMap<String, EntryBean> dirBeanMap = new HashMap<>();
for (EntryBean eb1 : entryBeans2) {
dirBeanMap.put(eb1.getId(), eb1);
}
//排除企业文档,综合数据管理中心、综合报表中心,综合分析决策中心,后三个是目录,所以要包括子
for (EntryBean eb : entryBeans2) {
ids.add(eb.getId());
UserAuthorityModel authorityModel = new UserAuthorityModel();
userAuthorityModels.add(authorityModel);
authorityModel.setId(eb.getId());
authorityModel.setpId(eb.getpId());
authorityModel.setText(eb.getText());
authorityModel.setEditAuthority(1);
authorityModel.setViewAuthority(1);
authorityModel.setModelType(2);
hashMap.put(eb.getId(), authorityModel);
}
if (!userId.equals("")) {
//获取该用户在目录管理上的授权数据
ArrayList<UserRoleMenuItemEntity> funcRoleList = new ArrayList<>();
for (String funcId : ids) {
List<UserRoleMenuItemEntity> eneitys = null;
if (isFindParent == true) { //是否需要找上一级,如果本级找不到
eneitys = UserRoleMenuDBAUtil.getInstance().getUserRoleDataInOrganAndParent(userId, funcId, orgCode);
} else {
eneitys = UserRoleMenuDBAUtil.getInstance().getUserRoleDataInOrgan(userId, funcId, orgCode);
}
funcRoleList.addAll(eneitys);
}
for (UserRoleMenuItemEntity entity : funcRoleList) {
UserAuthorityModel authorityModel = hashMap.get(entity.getMenuId());
if (authorityModel != null) {
if (entity.getAuthorityType() == 1) {
authorityModel.setViewAuthority(entity.getAuthorityValue());
}
if (entity.getAuthorityType() == 3) {
authorityModel.setEditAuthority(entity.getAuthorityValue());
}
}
}
}
// AuthorityResource
// authority
// DecisionMgrResource
//获取功能菜单
ids.clear();
//查询是否有管理功能
List<DecisionMgrModuleBean> moduleBeans = (List<DecisionMgrModuleBean>) adminAllMenuMap.get("moduleEntryBeans");//ManagerModuleService.getInstance().getAllDecisionMgrModules(adminUser.getId(), null, 2);
for (DecisionMgrModuleBean dmb : moduleBeans) {
if (dmb.getId().equals(TieSheController.WORK_AUTHORITY_ID) || dmb.getId().equals(TieSheController.WORKD_AUTHORITY_VIEW_ID) || dmb.getId().equals(TieSheController.SYSTEM_LOG_ID) || dmb.getId().equals(TieSheController.ORGAN_MANAGE_ID)) {
ids.add(dmb.getId());
UserAuthorityModel authorityModel = new UserAuthorityModel();
userAuthorityModels.add(authorityModel);
authorityModel.setId(dmb.getId());
authorityModel.setpId(dmb.getpId());
authorityModel.setText(dmb.getText());
authorityModel.setEditAuthority(1);
authorityModel.setViewAuthority(1);
authorityModel.setMaintainAuthority(1);
authorityModel.setModelType(3);
hashMap.put(dmb.getId(), authorityModel);
}
}
if (!userId.equals("")) {
ArrayList<UserRoleMenuItemEntity> funcRoleList = new ArrayList<>();
for (String funcId : ids) {
List<UserRoleMenuItemEntity> eneitys = null;
if (isFindParent == true) {//是否需要找上一级,如果本级找不到
eneitys = UserRoleMenuDBAUtil.getInstance().getUserRoleDataInOrganAndParent(userId, funcId, orgCode);
} else {
eneitys = UserRoleMenuDBAUtil.getInstance().getUserRoleDataInOrgan(userId, funcId, orgCode);
}
funcRoleList.addAll(eneitys);
}
for (UserRoleMenuItemEntity entity : funcRoleList) {
UserAuthorityModel authorityModel = hashMap.get(entity.getMenuId());
if (authorityModel != null) {
if (entity.getAuthorityType() == 1) {
authorityModel.setViewAuthority(entity.getAuthorityValue());
}
if (entity.getAuthorityType() == 3) {
authorityModel.setEditAuthority(entity.getAuthorityValue());
}
if (entity.getAuthorityType() == 4) {
authorityModel.setMaintainAuthority(entity.getAuthorityValue());
}
}
}
}
return userAuthorityModels;
}
/**
* 获取admin用户下平台首页平台目录平台功能中的权限项
* @param type
* @return
* @throws Exception
*/
public static HashMap<String, List> getAdminAllAuthorityMenuItems(int type) throws Exception {
User adminUser = UserService.getInstance().getUserByUserName("admin");
HashMap<String, List> maps = new HashMap();
//获取管理首页数据
if (type == 0) { //获取平台首页,平台目录,平台功能中的权限项
List<EntryBean> entryBeans1 = EntryService.getInstance().getHomePages(adminUser.getId(), "");
List<EntryBean> entryBeans2 = EntryService.getInstance().getAllEntries(adminUser.getId());
List<DecisionMgrModuleBean> moduleBeans = ManagerModuleService.getInstance().getAllDecisionMgrModules(adminUser.getId(), null, 2);
maps.put("homeEntryBeans", entryBeans1);
maps.put("dirEntryBeans", entryBeans2);
maps.put("moduleEntryBeans", moduleBeans);
}
if (type == 1) {//获取平台首页
List<EntryBean> entryBeans1 = EntryService.getInstance().getHomePages(adminUser.getId(), "");
maps.put("homeEntryBeans", entryBeans1);
}
if (type == 2) {//获取平台目录
List<EntryBean> entryBeans2 = EntryService.getInstance().getAllEntries(adminUser.getId());
maps.put("dirEntryBeans", entryBeans2);
}
if (type == 3) {//获取平台功能
List<DecisionMgrModuleBean> moduleBeans = ManagerModuleService.getInstance().getAllDecisionMgrModules(adminUser.getId(), null, 2);
maps.put("moduleEntryBeans", moduleBeans);
}
return maps;
}
//获取首页授权情况
public static Map<String, Object> getPlatFormHomePageAuthorityEntity(List<String> ids, String userId) throws Exception {
PrivilegeOperator privilegeOperator = new PrivilegeOperator();
privilegeOperator.carrierType(TieSheController.CARRIER_TYPE);
privilegeOperator.carrierId(userId);
privilegeOperator.entityType("homepage");
privilegeOperator.setEntityIds(ids);
Set<Integer> privilegeTypes = new HashSet<>();
privilegeTypes.add(1);
privilegeTypes.add(3);
privilegeOperator.setPrivilegeTypes(privilegeTypes);
Map<String, Object> platModuleAuthoritys = AuthorityService.getInstance().getAuthorityEntityByCarrier(privilegeOperator);
return platModuleAuthoritys;
}
public static void addOperateLog(String opUserName,String ipaddress,String userFullPath, String datef, int opType, String descn, String orgCode, String realName) throws Exception {
//String opUserName = TeSheUtil.getCurrentLoginUser(req);
// String ip = getIpAddr(req);
// String userFullPath = this.userAndOrgFullPathMap.get(opUserName);
TieSheOperateLogService.getInstance().addOperateLog(opUserName, datef, opType, descn, orgCode, realName, ipaddress, userFullPath);
}
}

48
src/main/resources/com/fr/plugin/teshe/jscss/userRole.css

@ -0,0 +1,48 @@
.setting-font1 .b-font:before,.setting-font1.disabled .b-font:before {
content: "\e632";
color: inherit
}
.setting-font2 .b-font:before,.setting-font2.disabled .b-font:before {
content: "\e683";
color: inherit
}
.setting-font3 .b-font:before,.setting-font3.disabled .b-font:before {
content: "\e6dd";
color: inherit
}
.dec-user-row-tools1{
width: 200px;
position: absolute;
top: 0px;
bottom: 0px;
right: 0px;
}
.font-icon1,
.font-icon1 > i {
display: inline-block;
width: 24px;
height: 24px;
background-size: 16px 16px;
background-repeat: no-repeat;
background-position: center;
}
/* 根组织 xnzz */
.xnzz1 > i {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAhpJREFUWEfN1z9o1FAcB/DvL7lKi+TVE9pNcHASB5FeIupSKNVBcOnQgoPVTRy0LUiTk0pt7tChY4tQbEFEiptOIoKIeNy7ShfdHF1rezlE6DXvJwne2Qpq7o/vmiHT7/f7fvIeIS+EDl/U4XzEACdXOR6GO/1/w6zdSb/5H1hy/GCZgSsJhhdBuCVdUUhQm7iEbD/gxNXAhlLhSDtXo1FAbFUqHGwXoilADdHAyqEr1fOlMN39+feepgGNhNdqCVgpemJ8d69WQBQsPbHn1d+XgG0mvG9miZP0lFwx+MctYGA81WOtFiboe5Jh7ajZtQX0WnrWUMYvPyXQaDuG/2PGC9M4MFEHsMJVGPSNwKsawuMIBi/UAaFSx0yTboLphi4AgEc1QEF64oztV9YBPqkLQKCxGuA+m/SYQv6oKzzKCavo+wngi2A+AjIWtQGYP8hs70AM6EpZoloNHoJoTBuA8EC64jbZucpL6VrnbT/YAHBYF4CghoveoVfkzAVTbOwUwam3usIBbElPpKM8yuTLGSjjAoFndQEYeF7yxKUYEN0cP3jHwFldADAmZVbMx4Bz+a30tjK+aguPTlSGeWpt+uB6DHBylRFmfqYNQPRJutaJ+iHFnguWQLimDQBelF7v9V+Ae+W7MGhGF4CZRktZq/7Bo9P5zaOszJmE/watOZmeyKx1ec+BpLWJrXfvj3/D1p+j+QkdX4EfahPNR6dh8wsAAAAASUVORK5CYII=);
}
/* 机构组织 jgxt */
.jgxt1 > i {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAAAZ9JREFUWEftV7FOwzAQvUsnJEgLIys7UiUSRto/4DcYkBATaihJVSUjMPIXIPEBLWugMPANMLCgJkuRSA4Z1VGqBOO0oQlSPFp35+e7985nhIIXFnw+pALQHO9EATwkok1JgLcBhNbIaDxK2kdmCQB6f2yBgiYhDGWDIUELEV9XPla3hj2cyPoxuwSAXcd/IYI311hrygbSHW8fCK6BwgP3tHEl65cKQLc9Yre/76ht2UA7/feWotQGEFLP7dYtWb/yA9AcbxC/DcsK4wjVcI/vs70/ywADwAjGDuNl4STlAFxDxeUCsH0TgKI6zwAQFJ8QLxHozu2oN3GzpAxjJEwtge2bhPSdFbbiJRBJl2UyjdxCALJslimB5vgXSHQUBJ/bo7ONZx57aQA4d8IwaD9016MmV24A88rwJz/W4jNlYF4ZivwWByCS4bQV5wog0QkFMuRvQW4lyFOG/1MFhWegkmGqnCoZpjBT5jWsZPhrBnR7fE6ITT65yPaAaLCYTjwiPx4biZ5co348M5bHGZ/18Kz28dGsnJ/TrDdaxP4LlYSeP9TxY7kAAAAASUVORK5CYII=);
}
/* 正常部门 zcbm */
.zcbm1 > i {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAAXNSR0IArs4c6QAABXJJREFUWEfFVmtsFGUUPfdb2hranW0aTEnAiIpG8BWl3S0hCipBjfERfIsvItEIPxS12s5su33szrZURIkmYmKAEAlBjWICKuILg2VmaRQENPCDxkgiorS7Wwptd75rZnaX7rbddotN+JL+6My995w93z13LuECH7rA+DgvAhWh6F0CuAv2H4k+SN4GErtNreSr8f6gcRGoDPw9FYVFfgKtcIAIf4FhAZiWBOb3XFwQbPdPPp4vkbwJ+ELRJxhUD+BKAD8RY5XhV7bZQL5g7D4QVAa8IHSSlGHDX/p+PiTGJDA3fHamJfvrADwFIM4MPaK5W0HEmQCzAwcLiwsu0UiIWjAXAPiUiPyG6j48GpFRCVTq8RcI3AZGMZg3kRAtYxWs0nt9khMagHsAnCGg2dCUcC4SIxKoCJ++0WUlVjHRQgAHiGSzoZZ+nI+k6RiHPLNNZBoBe5hQbapK+9AawwhUBqONRM5dg5mbTg8oocON1D8e8HSsL/DvdC4sCABYlnrWampKTWatcwS8oegdAL0JYDaAbQzRENFKfjkf4KE5Fc2xe0lQgMA3EfC7lLwyUuf5Mmmk1PHq8YNgLmagMaIpGyYCeGgNb3O0AYJsRTpNTbksm8DgS5vVF0TcuFf1GBNBpDIYXUJAAES2hQHJjWadpyGLgP3PzLVHi8ri5Z8AuDs1WNYMkAj/rLpPng+RqqaoT7rItnCyHmP/2aLeeQeqp55O1xvRBb5gbxWT9RnA5QAdB6HZVN3r8iUxNxAtSxSgjoheSuXEmHl5xO/5cEwXZAZUBuPLifhdRyqiXbCsNqOudOdoRFL2qwaQumPeYGiepblyzingC8XWg7DbUJX1mcEV4e7LhSVUEJ5NPV9HklcbdZ6jWXHN3QsFUTWIFjlqM753Sa7ZW5/dRz49tpQtvnRYD3hDsWMAZgC0FS7SzZqS/ZkAvnD8ASmh2lYCcJKA7WwPGCBBTAtBvCTVN51grDb9nncy870tPTfAYhXgh0F0yFTd1w5rQm8otjE182PMCEf8SktmkevbuPiivrithjqSpASsFv2stzd6TmVfZayGCLUAFPsbYWrK4pxNWNUanyUt7ATzdAA/kJT60HuvCnfNsKRrgQDmS6CfmHZRgavdeH3yn1mqNXcvYiFssvMBdEHQg2at+9vMmJwfI1+w+zkmke78NVYR9I5XlX/yccKcN2JTXH2OSitT9tto+pVncqiWu2RV+MwM5kQLMz8C4DdiDht+z6bRSPiC0SeZyJZ7FgEms1xh+kv3jekCbyi2B4DFQuiR2hJnTqdPcpLRWyBMAXgzW0KP1LsPZcU0xa8hl1QBetzZG4hWRVR3MCsm3HMnSamCqGxYE3pD8QDAqfFIbwO9YUMrP5Eu4Av1lEtY9QRaDuAUAZ8nXcBnCWKe091AGUCbQdxoqsqRwdwT5cDkWga/6DzLNYoXBLiktzC+A8DNAI6AoZt+xXbGoBp612Ji8RpAviGythN4raF5tmTZLxh7OuWaq+ya1gDmdTQM9tLIozjcs4ildDZcBm+Z5HLp7TUlv2YWTjuBhOgjIX4c6oC5LT3XJSxLJdCjyTx+2dQ8a4b2Qk4XPLSVXX8ciQeZYC8Q3QB0U1Pa8nGBNxSzR7HtglIwdlgXu+/veJ4Gxu0CO6Ey2HWLIFebs/EC30kp9X11pbtGKlZhj+Ok728FcAyEkKkqH4xGesyteNAJzjRzlkt74iWsxMaO+jLnWubosasnMZYx8Irznnmt4fckG26MkzcBR42maCUlv+/2xmufTgZbBLoi1S9fA67WiFbyzVjA6ffjIpBO8gajj4HoNoBvB+y75e1g0W763R/lC/y/CIwXZEJ6YCJBM2v9B4/dLj8zqREpAAAAAElFTkSuQmCC);
}

9189
src/main/resources/com/fr/plugin/teshe/jscss/userRole.js

File diff suppressed because it is too large Load Diff

88
文档/fineui_tree笔记

@ -0,0 +1,88 @@
fineUi的Tree我们一般这么配
var items = this._formatTreeItems(BI.Tree.transformToTreeFormat(this.store.getTreeJsonWithNode()), 0);
t = {
type: "bi.custom_tree",
$testId: "decision-normal-table-tree-scroll",
$value: e.authType + "-" + e.entityType,
ref: function (e) {
n.tree = e
},
expander: {
type: "dec.base.tree_expander",
isDefaultInit: !1,
el: {},
popup: {
type: "bi.custom_tree"
}
},
items: t,
itemsCreator: function (t, i) {
e.itemsCreator(t, function (e) {
e = n.store.cacheTreeData(e, t);
var a = n._formatTreeItems(e, t.node ? t.node.layer : 0)
console.log("a:" + a)
i(a)
})
},
el: {
type: e.lazy ? "dec.component.lazy_loader" : "dec.component.gradually_loader",
next: !1,
getScrollParent: function () {
return n.tree.element
},
el: {
type: "bi.button_tree",
chooseType: 1,
layouts: [{
type: "bi.vertical"
}]
}
},
listeners: [{
eventName: BI.Controller.EVENT_CHANGE,
action: function (e, t, i) {
n.fireEvent(BI.Controller.EVENT_CHANGE, arguments)
}
}]
};
itemsCreator是异步数据回调接口,
itemsCreator: function (t, i) {
e.itemsCreator(t, function (e) {
e = n.store.cacheTreeData(e, t);
var a = n._formatTreeItems(e, t.node ? t.node.layer : 0)
console.log("a:" + a)
i(a)
})
},
这里是调用options中的itemsCreator来获取数据,回调函数获取到数据后,调用i(a)来渲染数据。
a的数据格式一般为:[
{
children: Array(5)
id: "-1_0"
isParent: true
layer: 0 //控制层级
open: true //是否打开
order: 0
pId: null //父id
selected: true //是否选中
text: "中国铁建"
}
]
options的itemsCreator中一般这么写:
if(e.node){
i.store.getSubItemsByPId(e.node.id, e.node.layer + 1, function (e) {
console.log(e);
t(e)
})
}
else{
var rootnodes = i.store.getRootNodes();
console.log("rootnodes:"+rootnodes)
t(rootnodes)
}

3
文档/授权文档.txt

@ -0,0 +1,3 @@
1 底层分为三个部分,查看1,管理3,隐藏一个给别人能授权菜单的权限2
2 某个人在所有组织中只要有一个组织里有查看,那么这个菜单就能看见,底层查看权限要打开
2 某个人在所有组织中只要有一个组织里有管理,那么底层管理3,权菜单的权限2就要打开

BIN
文档/插件说明文档.docx

Binary file not shown.
Loading…
Cancel
Save