|
|
@ -1,23 +1,16 @@
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
import com.cloudstore.eccom.result.WeaResultMsg;
|
|
|
|
import com.engine.common.service.HrmCommonService;
|
|
|
|
|
|
|
|
import com.engine.common.service.impl.HrmCommonServiceImpl;
|
|
|
|
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.core.impl.Service;
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
import com.engine.organization.component.OrganizationWeaTable;
|
|
|
|
import com.engine.organization.entity.personnelcard.po.CardAccessPO;
|
|
|
|
import com.engine.organization.entity.personnelcard.po.CardAccessPO;
|
|
|
|
import com.engine.organization.entity.personnelcard.vo.CardAccessVO;
|
|
|
|
import com.engine.organization.entity.personnelcard.vo.CardAccessVO;
|
|
|
|
import com.engine.organization.exception.OrganizationRunTimeException;
|
|
|
|
|
|
|
|
import com.engine.organization.mapper.personnelcard.CardAccessMapper;
|
|
|
|
import com.engine.organization.mapper.personnelcard.CardAccessMapper;
|
|
|
|
import com.engine.organization.service.CardAccessService;
|
|
|
|
import com.engine.organization.service.CardAccessService;
|
|
|
|
import com.engine.organization.util.HasRightUtil;
|
|
|
|
import com.engine.organization.util.HasRightUtil;
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
import weaver.general.Util;
|
|
|
|
import weaver.hrm.User;
|
|
|
|
import weaver.hrm.User;
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
|
@ -95,60 +88,4 @@ public class CardAccessServiceImpl extends Service implements CardAccessService
|
|
|
|
return getCardAccessMapper().updateTabName(name, id);
|
|
|
|
return getCardAccessMapper().updateTabName(name, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 判断当前人员、是否有查看当前数据、当前模块的权限
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @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 = getCardAccessMapper().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 || 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));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return hasAccess;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|