|
|
package com.engine.aisin.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.engine.aisin.entity.AccessCustomPo;
|
|
|
import com.engine.aisin.entity.KqStatisticsItemVo;
|
|
|
import com.engine.aisin.entity.KqStatisticsVo;
|
|
|
import com.engine.aisin.entity.ResourceParam;
|
|
|
import com.engine.aisin.service.AccessCustomService;
|
|
|
import com.engine.common.service.HrmCommonService;
|
|
|
import com.engine.common.service.impl.HrmCommonServiceImpl;
|
|
|
import com.engine.core.impl.Service;
|
|
|
import com.engine.kq.biz.KQWorkTime;
|
|
|
import com.engine.kq.entity.WorkTimeEntity;
|
|
|
import com.engine.kq.util.KQDurationCalculatorUtil;
|
|
|
import com.engine.kq.wfset.util.KQSignUtil;
|
|
|
import com.weaver.general.BaseBean;
|
|
|
import com.weaver.general.Util;
|
|
|
import lombok.SneakyThrows;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import weaver.conn.RecordSet;
|
|
|
import weaver.hrm.company.DepartmentComInfo;
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
/**
|
|
|
* @Author liang.cheng
|
|
|
* @Date 2024/11/15 3:17 PM
|
|
|
* @Description: TODO
|
|
|
* @Version 1.0
|
|
|
*/
|
|
|
public class AccessCustomServiceImpl extends Service implements AccessCustomService {
|
|
|
|
|
|
@SneakyThrows
|
|
|
@Override
|
|
|
public boolean customAccess(String userId) {
|
|
|
boolean result;
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
ResourceComInfo rc = new ResourceComInfo();
|
|
|
HrmCommonService hrmCommonService = new HrmCommonServiceImpl();
|
|
|
|
|
|
//1.根据userId获取人员相关信息
|
|
|
String subCompanyId = rc.getSubCompanyID(userId);
|
|
|
|
|
|
//2.判断该人员是否在需要控制权限的分部
|
|
|
List<AccessCustomPo> accessSub = new ArrayList<>();
|
|
|
rs.executeQuery("select xykzdfb,qxxz,fb,bm,ry,js from uf_txlxsldzqxkzgt where xykzdfb = ?",subCompanyId);
|
|
|
while (rs.next()) {
|
|
|
accessSub.add(AccessCustomPo.builder()
|
|
|
.checks(Arrays.asList(Util.null2String(rs.getString("qxxz")).split(",")))
|
|
|
.subCompanyIds(Arrays.asList(Util.null2String(rs.getString("fb")).split(",")))
|
|
|
.departmentIds(Arrays.asList(Util.null2String(rs.getString("bm")).split(",")))
|
|
|
.userIds(Arrays.asList(Util.null2String(rs.getString("ry")).split(",")))
|
|
|
.roleIds(Arrays.asList(Util.null2String(rs.getString("js")).split(",")))
|
|
|
.build());
|
|
|
}
|
|
|
|
|
|
if (accessSub.size() == 0) {
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
//3.若存在,判断是否在可查看权限范围
|
|
|
result = false;
|
|
|
String departmentId = rc.getDepartmentID(userId);
|
|
|
String roleIds = hrmCommonService.getRoleIds(Integer.parseInt(userId));
|
|
|
|
|
|
for (AccessCustomPo item : accessSub) {
|
|
|
List<String> checks = item.getChecks();
|
|
|
for (String e : checks) {
|
|
|
switch (e) {
|
|
|
case "0":
|
|
|
List<String> subCompanyIds = item.getSubCompanyIds();
|
|
|
boolean sub = subCompanyIds.stream()
|
|
|
.anyMatch(element -> element.equals(subCompanyId));
|
|
|
if (sub) {
|
|
|
return true;
|
|
|
}
|
|
|
break;
|
|
|
case "1":
|
|
|
List<String> departmentIds = item.getDepartmentIds();
|
|
|
boolean dept = departmentIds.stream()
|
|
|
.anyMatch(element -> element.equals(departmentId));
|
|
|
if (dept) {
|
|
|
return true;
|
|
|
}
|
|
|
break;
|
|
|
case "2":
|
|
|
List<String> userIds = item.getUserIds();
|
|
|
boolean user = userIds.stream()
|
|
|
.anyMatch(element -> element.equals(departmentId));
|
|
|
if (user) {
|
|
|
return true;
|
|
|
}
|
|
|
break;
|
|
|
case "3":
|
|
|
List<String> roleIdsT = item.getRoleIds();
|
|
|
boolean role = roleIdsT.stream()
|
|
|
.anyMatch(roleIds::contains);
|
|
|
if (role) {
|
|
|
return true;
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public KqStatisticsVo getKqAccess(Map<String,Object> params) {
|
|
|
//班次
|
|
|
String value = weaver.general.Util.null2String(params.get("value"));
|
|
|
//日期
|
|
|
String kqDate = weaver.general.Util.null2String(params.get("date"));
|
|
|
|
|
|
BaseBean bb = new BaseBean();
|
|
|
String matrixtableName = bb.getPropValue("aisinsecond", "matrixtableName");
|
|
|
String subcompanyid = bb.getPropValue("aisinsecond", "subcompanyid");
|
|
|
int departmentid = Integer.parseInt(bb.getPropValue("aisinsecond", "departmentid"));
|
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
//1.建模表获取班次信息 uf_atbpbcstbdzgx |