|
@@ -1346,14 +1346,15 @@ public class DingDingServiceImpl implements DingDingService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public HttpRespMsg getLeaveTypeList(String leaveCode, Integer companyId, String userIds, long offset) {
|
|
|
|
|
|
+ public HttpRespMsg getLeaveTypeList(String leaveCode, Integer companyId, Integer departmentId, String userId, Integer pageIndex) {
|
|
CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
|
|
CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HashMap resultMap = new HashMap();
|
|
HashMap resultMap = new HashMap();
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/vacation/type/list");
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/vacation/type/list");
|
|
OapiAttendanceVacationTypeListRequest req = new OapiAttendanceVacationTypeListRequest();
|
|
OapiAttendanceVacationTypeListRequest req = new OapiAttendanceVacationTypeListRequest();
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("role_name", "超级管理员"));
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("role_name", "超级管理员"));
|
|
- String oaManagerDid = "2221645448842951";//userList.get(0).getDingdingUserid();
|
|
|
|
|
|
+// String oaManagerDid = "2221645448842951";
|
|
|
|
+ String oaManagerDid = userList.get(0).getDingdingUserid();
|
|
if (leaveCode == null) {
|
|
if (leaveCode == null) {
|
|
req.setOpUserid(oaManagerDid);
|
|
req.setOpUserid(oaManagerDid);
|
|
req.setVacationSource("all");
|
|
req.setVacationSource("all");
|
|
@@ -1370,48 +1371,96 @@ public class DingDingServiceImpl implements DingDingService {
|
|
LeaveTypeVO vo = new LeaveTypeVO();
|
|
LeaveTypeVO vo = new LeaveTypeVO();
|
|
vo.leaveCode = obj.getString("leave_code");
|
|
vo.leaveCode = obj.getString("leave_code");
|
|
vo.leaveName = obj.getString("leave_name");
|
|
vo.leaveName = obj.getString("leave_name");
|
|
|
|
+ if (vo.leaveName.equals("调休")) {
|
|
|
|
+ defaultType = vo;
|
|
|
|
+ }
|
|
typeList.add(vo);
|
|
typeList.add(vo);
|
|
}
|
|
}
|
|
resultMap.put("leaveTypeList", typeList);
|
|
resultMap.put("leaveTypeList", typeList);
|
|
- leaveCode = typeList.get(0).leaveCode;
|
|
|
|
|
|
+ if (defaultType == null) defaultType = typeList.get(0);
|
|
|
|
+ leaveCode = defaultType.leaveCode;
|
|
|
|
+ resultMap.put("defaultLeaveType", defaultType);
|
|
System.out.println("本次请求的LeaveCode: "+leaveCode);
|
|
System.out.println("本次请求的LeaveCode: "+leaveCode);
|
|
- reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, userIds, offset, resultMap);
|
|
|
|
|
|
+ reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, departmentId, userId, pageIndex, resultMap);
|
|
} catch (ApiException e) {
|
|
} catch (ApiException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, userIds, offset, resultMap);
|
|
|
|
|
|
+ reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, departmentId, userId, pageIndex, resultMap);
|
|
}
|
|
}
|
|
msg.data = resultMap;
|
|
msg.data = resultMap;
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
- private void reqQuotaList(Integer companyId, CompanyDingding dingding,
|
|
|
|
- String leaveCode, String oaManagerDid, String userIds, long offset, HashMap resultMap) {
|
|
|
|
|
|
+ //递归获取子部门
|
|
|
|
+ private List<Department> getSubDeptList(List<Department> allDeptList, Department department) {
|
|
|
|
+ List<Department> deptList = new ArrayList<>();
|
|
|
|
+ deptList.add(department);
|
|
|
|
+ //查找子部门的数据
|
|
|
|
+ List<Department> collect = allDeptList.stream().filter(sub -> sub.getSuperiorId() != null && sub.getSuperiorId().equals(department.getDepartmentId())).collect(Collectors.toList());
|
|
|
|
+ for (Department subItem : collect) {
|
|
|
|
+ deptList.addAll(getSubDeptList(allDeptList, subItem));
|
|
|
|
+ }
|
|
|
|
+ return deptList;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ private void reqQuotaList(Integer companyId, CompanyDingding dingding,
|
|
|
|
+ String leaveCode, String oaManagerDid, Integer departmentId, String userId, Integer pageIndex, HashMap resultMap) {
|
|
//再调用查看假期余额的接口
|
|
//再调用查看假期余额的接口
|
|
|
|
+ long pageSize = 50L;
|
|
DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/vacation/quota/list");
|
|
DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/vacation/quota/list");
|
|
OapiAttendanceVacationQuotaListRequest quoataReq = new OapiAttendanceVacationQuotaListRequest();
|
|
OapiAttendanceVacationQuotaListRequest quoataReq = new OapiAttendanceVacationQuotaListRequest();
|
|
quoataReq.setLeaveCode(leaveCode);
|
|
quoataReq.setLeaveCode(leaveCode);
|
|
quoataReq.setOpUserid(oaManagerDid);
|
|
quoataReq.setOpUserid(oaManagerDid);
|
|
List<User> userList = null;
|
|
List<User> userList = null;
|
|
- if (StringUtils.isEmpty(userIds)) {
|
|
|
|
- //获取全部员工,离职的不看
|
|
|
|
- userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("is_active", 1));
|
|
|
|
|
|
+ String userIds = null;
|
|
|
|
+ if (StringUtils.isEmpty(userId)) {
|
|
|
|
+ int total = 0;
|
|
|
|
+ if (departmentId == null) {
|
|
|
|
+ //全部员工,包括离职的
|
|
|
|
+ userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).orderByAsc("id").last("limit " + (pageIndex-1)*pageSize+", "+pageSize));
|
|
|
|
+ total = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
|
+ } else {
|
|
|
|
+ //指定部门
|
|
|
|
+ Department dept = departmentMapper.selectById(departmentId);
|
|
|
|
+ List<Department> allDept = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
|
+ List<Department> allSubDepts = getSubDeptList(allDept, dept);
|
|
|
|
+ userList = userMapper.selectList(
|
|
|
|
+ new QueryWrapper<User>()
|
|
|
|
+ .in("department_id", allSubDepts.stream().map(Department::getDepartmentId).collect(Collectors.toList()))
|
|
|
|
+ .orderByAsc("id").last("limit " + (pageIndex-1)*pageSize+", "+pageSize));
|
|
|
|
+ total = userMapper.selectCount(new QueryWrapper<User>()
|
|
|
|
+ .in("department_id", allSubDepts.stream().map(Department::getDepartmentId).collect(Collectors.toList())));
|
|
|
|
+ }
|
|
String collect = userList.stream().map(User::getDingdingUserid).collect(Collectors.joining(","));
|
|
String collect = userList.stream().map(User::getDingdingUserid).collect(Collectors.joining(","));
|
|
userIds = collect;
|
|
userIds = collect;
|
|
|
|
+ resultMap.put("total", total);
|
|
} else {
|
|
} else {
|
|
- List<String> strings = ListUtil.convertLongIdsArrayToList(userIds);
|
|
|
|
- userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).in("dingding_userid", strings));
|
|
|
|
- }
|
|
|
|
- if (userList.size() > 10) {
|
|
|
|
- userList = userList.subList(0, 10);
|
|
|
|
|
|
+ userList = new ArrayList<>();
|
|
|
|
+ userList.add(userMapper.selectById(userId));
|
|
|
|
+ userIds = userList.get(0).getDingdingUserid();
|
|
|
|
+ resultMap.put("total", 1);
|
|
}
|
|
}
|
|
|
|
+
|
|
System.out.println("请求的userIds: "+userIds);
|
|
System.out.println("请求的userIds: "+userIds);
|
|
|
|
+ System.out.println("长度=="+userIds.length());
|
|
|
|
+ List<LeaveQuotaNum> quotaNumList = new ArrayList<>();
|
|
|
|
+ for (User user : userList) {
|
|
|
|
+ LeaveQuotaNum quotaNum = new LeaveQuotaNum();
|
|
|
|
+ quotaNum.userId = user.getId();
|
|
|
|
+ quotaNum.userDingdingId = user.getDingdingUserid();
|
|
|
|
+ quotaNum.name = user.getName();
|
|
|
|
+ quotaNum.leaveCode = leaveCode;
|
|
|
|
+ quotaNumList.add(quotaNum);
|
|
|
|
+ }
|
|
|
|
+ resultMap.put("records", quotaNumList);
|
|
|
|
+ if (quotaNumList.size() == 0) {
|
|
|
|
+ //无员工数据了
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
quoataReq.setUserids(userIds);
|
|
quoataReq.setUserids(userIds);
|
|
-
|
|
|
|
- quoataReq.setOffset(offset);
|
|
|
|
- quoataReq.setSize(50L);
|
|
|
|
|
|
+ quoataReq.setOffset(0L);
|
|
|
|
+ quoataReq.setSize(pageSize);
|
|
OapiAttendanceVacationQuotaListResponse quotaListResponse = null;
|
|
OapiAttendanceVacationQuotaListResponse quotaListResponse = null;
|
|
try {
|
|
try {
|
|
quotaListResponse = client.execute(quoataReq, getInnerCorpToken(dingding));
|
|
quotaListResponse = client.execute(quoataReq, getInnerCorpToken(dingding));
|
|
@@ -1424,18 +1473,12 @@ public class DingDingServiceImpl implements DingDingService {
|
|
DecimalFormat df = new DecimalFormat("#0.0");
|
|
DecimalFormat df = new DecimalFormat("#0.0");
|
|
if (json.getInteger("errcode") == 0) {
|
|
if (json.getInteger("errcode") == 0) {
|
|
JSONObject result = json.getJSONObject("result");
|
|
JSONObject result = json.getJSONObject("result");
|
|
- resultMap.put("hasMore", result.getBooleanValue("has_more"));
|
|
|
|
JSONArray leaveQuotas = result.getJSONArray("leave_quotas");
|
|
JSONArray leaveQuotas = result.getJSONArray("leave_quotas");
|
|
if (leaveQuotas != null) {
|
|
if (leaveQuotas != null) {
|
|
- List<LeaveQuotaNum> quotaNumList = new ArrayList<>();
|
|
|
|
for (int i=0;i<leaveQuotas.size(); i++) {
|
|
for (int i=0;i<leaveQuotas.size(); i++) {
|
|
JSONObject jsonObject = leaveQuotas.getJSONObject(i);
|
|
JSONObject jsonObject = leaveQuotas.getJSONObject(i);
|
|
String userDDid = jsonObject.getString("userid");
|
|
String userDDid = jsonObject.getString("userid");
|
|
- LeaveQuotaNum quotaNum = new LeaveQuotaNum();
|
|
|
|
- quotaNum.userDingdingId = userDDid;
|
|
|
|
- User user = userList.stream().filter(u -> u.getDingdingUserid().equals(userDDid)).findFirst().get();
|
|
|
|
- quotaNum.userId = user.getId();
|
|
|
|
- quotaNum.name = user.getName();
|
|
|
|
|
|
+ LeaveQuotaNum quotaNum = quotaNumList.stream().filter(qu->qu.userDingdingId.equals(userDDid)).findFirst().get();
|
|
Date startDate = new Date(jsonObject.getLongValue("start_time"));
|
|
Date startDate = new Date(jsonObject.getLongValue("start_time"));
|
|
quotaNum.startTime = sdf.format(startDate);
|
|
quotaNum.startTime = sdf.format(startDate);
|
|
Date endDate = new Date(jsonObject.getLongValue("end_time"));
|
|
Date endDate = new Date(jsonObject.getLongValue("end_time"));
|
|
@@ -1459,10 +1502,8 @@ public class DingDingServiceImpl implements DingDingService {
|
|
}
|
|
}
|
|
quotaNumList.add(quotaNum);
|
|
quotaNumList.add(quotaNum);
|
|
}
|
|
}
|
|
- resultMap.put("quotaNumList", quotaNumList);
|
|
|
|
- } else {
|
|
|
|
- resultMap.put("quotaNumList", new ArrayList<>());
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|