|
|
|
@ -1,17 +1,23 @@
|
|
|
|
|
package com.engine.organization.service.impl;
|
|
|
|
|
|
|
|
|
|
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.organization.component.OrganizationWeaTable;
|
|
|
|
|
import com.engine.organization.entity.detach.vo.ManagerDetachVO;
|
|
|
|
|
import com.engine.organization.entity.personnelcard.po.CardAccessPO;
|
|
|
|
|
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.service.CardAccessService;
|
|
|
|
|
import com.engine.organization.util.HasRightUtil;
|
|
|
|
|
import com.engine.organization.util.OrganizationAssert;
|
|
|
|
|
import com.engine.organization.util.db.MapperProxyFactory;
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
|
import weaver.general.BaseBean;
|
|
|
|
|
import weaver.general.Util;
|
|
|
|
|
|
|
|
|
|
import weaver.hrm.User;
|
|
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@ -25,10 +31,15 @@ public class CardAccessServiceImpl extends Service implements CardAccessService
|
|
|
|
|
|
|
|
|
|
private static final String RIGHT_NAME = "CardAccess:All";
|
|
|
|
|
|
|
|
|
|
private CardAccessMapper getCardAccessMapper() {
|
|
|
|
|
private static CardAccessMapper getCardAccessMapper() {
|
|
|
|
|
return MapperProxyFactory.getProxy(CardAccessMapper.class);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public CardAccessServiceImpl(User user) {
|
|
|
|
|
super();
|
|
|
|
|
this.user = user;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> tablePage() {
|
|
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
@ -57,13 +68,13 @@ public class CardAccessServiceImpl extends Service implements CardAccessService
|
|
|
|
|
List<HashMap<String, Object>> dataList = new ArrayList<>();
|
|
|
|
|
for (int i = 0; i < rowNum; i++) {
|
|
|
|
|
HashMap<String, Object> data = new HashMap<>();
|
|
|
|
|
data.put("id",params.get("id_"+i));
|
|
|
|
|
data.put("status",params.get("status_"+i));
|
|
|
|
|
data.put("allPeople",params.get("all_people_"+i));
|
|
|
|
|
data.put("superior",params.get("superior_"+i));
|
|
|
|
|
data.put("allSuperior",params.get("all_superior_"+i));
|
|
|
|
|
data.put("custom",params.get("custom"+i));
|
|
|
|
|
data.put("updateTime",new Date());
|
|
|
|
|
data.put("id", params.get("id_" + i));
|
|
|
|
|
data.put("status", params.get("status_" + i));
|
|
|
|
|
data.put("allPeople", params.get("all_people_" + i));
|
|
|
|
|
data.put("superior", params.get("superior_" + i));
|
|
|
|
|
data.put("allSuperior", params.get("all_superior_" + i));
|
|
|
|
|
data.put("custom", params.get("custom" + i));
|
|
|
|
|
data.put("updateTime", new Date());
|
|
|
|
|
dataList.add(data);
|
|
|
|
|
}
|
|
|
|
|
return getCardAccessMapper().saveCardAccess(dataList);
|
|
|
|
@ -80,9 +91,64 @@ public class CardAccessServiceImpl extends Service implements CardAccessService
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public int updateTabName(String name,Integer id) {
|
|
|
|
|
return getCardAccessMapper().updateTabName(name,id);
|
|
|
|
|
public int updateTabName(String name, Integer 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|