|
|
|
@ -1,5 +1,7 @@
|
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
import com.engine.common.service.HrmCommonService;
|
|
|
|
|
import com.engine.common.service.impl.HrmCommonServiceImpl;
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
|
import com.engine.organization.entity.extend.ExtendInfoOperateType;
|
|
|
|
|
import com.engine.organization.entity.extend.bo.ExtendGroupBO;
|
|
|
|
@ -8,11 +10,14 @@ import com.engine.organization.entity.extend.po.ExtendGroupPO;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendInfoPO;
|
|
|
|
|
import com.engine.organization.entity.extend.po.ExtendTitlePO;
|
|
|
|
|
import com.engine.organization.entity.personnelcard.*;
|
|
|
|
|
import com.engine.organization.entity.personnelcard.po.CardAccessPO;
|
|
|
|
|
import com.engine.organization.exception.OrganizationRunTimeException;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendGroupMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendInfoMapper;
|
|
|
|
|
import com.engine.organization.mapper.extend.ExtendTitleMapper;
|
|
|
|
|
import com.engine.organization.mapper.hrmresource.HrmResourceMapper;
|
|
|
|
|
import com.engine.organization.mapper.personnelcard.CardAccessMapper;
|
|
|
|
|
import com.engine.organization.mapper.personnelcard.PersonnelCardMapper;
|
|
|
|
|
import com.engine.organization.service.HrmPersonnelCardService;
|
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
@ -29,12 +34,10 @@ import weaver.crm.CrmShareBase;
|
|
|
|
|
import weaver.docs.search.DocSearchComInfo;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
import weaver.workflow.search.WorkflowRequestUtil;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -88,8 +91,7 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel
|
|
|
|
|
Statistical statistical = getStatistical(ecResourceId);
|
|
|
|
|
List<ExtendGroupPO> extendGroupList = getExtendGroupMapper().listByType(4, IS_SHOW);
|
|
|
|
|
// 过滤卡片权限
|
|
|
|
|
CardAccessServiceImpl cardAccessService = new CardAccessServiceImpl(user);
|
|
|
|
|
extendGroupList.removeIf(item -> !cardAccessService.hasGroupAccess(item.getId().intValue(), ecResourceId));
|
|
|
|
|
extendGroupList.removeIf(item -> !hasGroupAccess(item.getId().intValue(), ecResourceId));
|
|
|
|
|
|
|
|
|
|
// 获取所有模块的信息
|
|
|
|
|
List<FormItem> formItemList = new ArrayList<>();
|
|
|
|
@ -209,5 +211,64 @@ public class HrmPersonnelCardServiceImpl extends Service implements HrmPersonnel
|
|
|
|
|
return formItem;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 判断当前人员、是否有查看当前数据、当前模块的权限
|
|
|
|
|
*
|
|
|
|
|
* @param typeId 人员卡片分组ID
|
|
|
|
|
* @param userId 当前卡片人员EcId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
public boolean hasGroupAccess(Integer typeId, String userId) {
|
|
|
|
|
// 人员信息有误,返回false
|
|
|
|
|
OrganizationAssert.notBlank(userId, "未获取到对应人员");
|
|
|
|
|
|
|
|
|
|
// 系统管理员、查看本人卡片直接返回true
|
|
|
|
|
if (user.isAdmin() || userId.equals(String.valueOf(user.getUID()))) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
boolean hasAccess = false;
|
|
|
|
|
CardAccessPO cardAccessPO = MapperProxyFactory.getProxy(CardAccessMapper.class).selectById(typeId);
|
|
|
|
|
OrganizationAssert.notNull(cardAccessPO, "未查询到对应卡片权限,");
|
|
|
|
|
// 所有人,返回true
|
|
|
|
|
if (1 == cardAccessPO.getAllPeople()) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
ResourceComInfo resourceComInfo = new ResourceComInfo();
|
|
|
|
|
// 上级
|
|
|
|
|
if ("1".equals(Util.null2String(cardAccessPO.getSuperior()))) {
|
|
|
|
|
String managerID = resourceComInfo.getManagerID(userId);
|
|
|
|
|
hasAccess = Arrays.asList(managerID.split(",")).contains(Util.null2String(user.getUID()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 所有上级
|
|
|
|
|
if (!hasAccess || "1".equals(Util.null2String(cardAccessPO.getAllSuperior()))) {
|
|
|
|
|
String managersIDs = resourceComInfo.getManagersIDs(userId);
|
|
|
|
|
hasAccess = hasAccess || Arrays.asList(managersIDs.split(",")).contains(Util.null2String(user.getUID()));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
new BaseBean().writeLog(e);
|
|
|
|
|
throw new OrganizationRunTimeException("人员卡片权限");
|
|
|
|
|
}
|
|
|
|
|
// 角色判断
|
|
|
|
|
if (!hasAccess || org.apache.commons.lang.StringUtils.isNotBlank(cardAccessPO.getCustom())) {
|
|
|
|
|
List<String> accessRoleIds = Arrays.asList(cardAccessPO.getCustom().split(","));
|
|
|
|
|
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
|
|
|
|
|
List<Object> roleInfo = hrmCommonService.getRoleInfo(user.getUID());
|
|
|
|
|
for (Object o : roleInfo) {
|
|
|
|
|
Map<String, String> roleDetailMap = (Map<String, String>) o;
|
|
|
|
|
int roleid = Util.getIntValue(roleDetailMap.get("roleid"), -1);
|
|
|
|
|
// 判断角色是否满足,角色等级是否满足
|
|
|
|
|
hasAccess = hasAccess || accessRoleIds.contains(Util.null2String(roleid));
|
|
|
|
|
if (hasAccess) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return hasAccess;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|