|
@@ -15,7 +15,7 @@ import com.dingtalk.api.response.*;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.management.platform.constant.Constant;
|
|
|
import com.management.platform.entity.*;
|
|
|
-import com.management.platform.entity.vo.LeaveQuotaNum;
|
|
|
+//import com.management.platform.entity.vo.LeaveQuotaNum;
|
|
|
import com.management.platform.entity.vo.LeaveTypeVO;
|
|
|
import com.management.platform.entity.vo.UserVO;
|
|
|
import com.management.platform.mapper.*;
|
|
@@ -72,6 +72,8 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
@Resource
|
|
|
private SysModuleMapper sysModuleMapper;
|
|
|
@Resource
|
|
|
+ private LeaveQuotaNumService leaveQuotaNumService;
|
|
|
+ @Resource
|
|
|
private SysFunctionMapper sysFunctionMapper;
|
|
|
@Resource
|
|
|
private SysRoleModuleService sysRoleModuleService;
|
|
@@ -113,6 +115,8 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
private LeaveSheetMapper leaveSheetMapper;
|
|
|
@Resource
|
|
|
private LeaveSheetService leaveSheetService;
|
|
|
+ @Resource
|
|
|
+ private LeaveTypeService leaveTypeService;
|
|
|
|
|
|
@Value("${configEnv.isPrivateDeploy}")
|
|
|
private boolean isPrivateDeploy;//企业内部应用,私有化部署的情况
|
|
@@ -1346,120 +1350,121 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public HttpRespMsg getLeaveTypeList(String leaveCode, Integer companyId, Integer departmentId, String userId, Integer pageIndex) {
|
|
|
+// public HttpRespMsg getLeaveTypeList(String leaveCode, Integer companyId, Integer departmentId, String userId, Integer pageIndex) {
|
|
|
+// CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
|
|
|
+// HttpRespMsg msg = new HttpRespMsg();
|
|
|
+// HashMap resultMap = new HashMap();
|
|
|
+// DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/vacation/type/list");
|
|
|
+// OapiAttendanceVacationTypeListRequest req = new OapiAttendanceVacationTypeListRequest();
|
|
|
+// List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("role_name", "超级管理员"));
|
|
|
+//// String oaManagerDid = "2221645448842951";
|
|
|
+// String oaManagerDid = userList.get(0).getDingdingUserid();
|
|
|
+// if (leaveCode == null) {
|
|
|
+// req.setOpUserid(oaManagerDid);
|
|
|
+// req.setVacationSource("all");
|
|
|
+// OapiAttendanceVacationTypeListResponse rsp = null;
|
|
|
+// try {
|
|
|
+// rsp = client.execute(req, getInnerCorpToken(dingding));
|
|
|
+// System.out.println(rsp.getBody());
|
|
|
+// JSONObject json = JSONObject.parseObject(rsp.getBody());
|
|
|
+// JSONArray result = json.getJSONArray("result");
|
|
|
+// List<LeaveTypeVO> typeList = new ArrayList<>();
|
|
|
+// LeaveTypeVO defaultType = null;
|
|
|
+// for (int i=0;i<result.size(); i++) {
|
|
|
+// JSONObject obj = result.getJSONObject(i);
|
|
|
+// LeaveTypeVO vo = new LeaveTypeVO();
|
|
|
+// vo.leaveCode = obj.getString("leave_code");
|
|
|
+// vo.leaveName = obj.getString("leave_name");
|
|
|
+// if (vo.leaveName.equals("调休")) {
|
|
|
+// defaultType = vo;
|
|
|
+// }
|
|
|
+// typeList.add(vo);
|
|
|
+// }
|
|
|
+// resultMap.put("leaveTypeList", typeList);
|
|
|
+// if (defaultType == null) defaultType = typeList.get(0);
|
|
|
+// leaveCode = defaultType.leaveCode;
|
|
|
+// resultMap.put("defaultLeaveType", defaultType);
|
|
|
+// System.out.println("本次请求的LeaveCode: "+leaveCode);
|
|
|
+// reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, departmentId, userId, pageIndex, resultMap);
|
|
|
+// } catch (ApiException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, departmentId, userId, pageIndex, resultMap);
|
|
|
+// }
|
|
|
+// msg.data = resultMap;
|
|
|
+// return msg;
|
|
|
+// }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg syncLeaveQuotaData(Integer companyId) {
|
|
|
CompanyDingding dingding = companyDingdingMapper.selectOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
HashMap resultMap = new HashMap();
|
|
|
DingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/vacation/type/list");
|
|
|
OapiAttendanceVacationTypeListRequest req = new OapiAttendanceVacationTypeListRequest();
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId).eq("role_name", "超级管理员"));
|
|
|
-// String oaManagerDid = "2221645448842951";
|
|
|
String oaManagerDid = userList.get(0).getDingdingUserid();
|
|
|
- if (leaveCode == null) {
|
|
|
- req.setOpUserid(oaManagerDid);
|
|
|
- req.setVacationSource("all");
|
|
|
- OapiAttendanceVacationTypeListResponse rsp = null;
|
|
|
- try {
|
|
|
- rsp = client.execute(req, getInnerCorpToken(dingding));
|
|
|
- System.out.println(rsp.getBody());
|
|
|
- JSONObject json = JSONObject.parseObject(rsp.getBody());
|
|
|
- JSONArray result = json.getJSONArray("result");
|
|
|
- List<LeaveTypeVO> typeList = new ArrayList<>();
|
|
|
- LeaveTypeVO defaultType = null;
|
|
|
- for (int i=0;i<result.size(); i++) {
|
|
|
- JSONObject obj = result.getJSONObject(i);
|
|
|
- LeaveTypeVO vo = new LeaveTypeVO();
|
|
|
- vo.leaveCode = obj.getString("leave_code");
|
|
|
- vo.leaveName = obj.getString("leave_name");
|
|
|
- if (vo.leaveName.equals("调休")) {
|
|
|
- defaultType = vo;
|
|
|
- }
|
|
|
- typeList.add(vo);
|
|
|
+ req.setOpUserid(oaManagerDid);
|
|
|
+ req.setVacationSource("all");
|
|
|
+ OapiAttendanceVacationTypeListResponse rsp = null;
|
|
|
+ try {
|
|
|
+ rsp = client.execute(req, getInnerCorpToken(dingding));
|
|
|
+ JSONObject json = JSONObject.parseObject(rsp.getBody());
|
|
|
+ JSONArray result = json.getJSONArray("result");
|
|
|
+ List<LeaveType> typeList = new ArrayList<>();
|
|
|
+ leaveTypeService.remove(new QueryWrapper<LeaveType>().eq("company_id", dingding.getCompanyId()));
|
|
|
+ for (int i=0;i<result.size(); i++) {
|
|
|
+ JSONObject obj = result.getJSONObject(i);
|
|
|
+ LeaveType vo = new LeaveType();
|
|
|
+ vo.setLeaveCode(obj.getString("leave_code"));
|
|
|
+ vo.setLeaveName(obj.getString("leave_name"));
|
|
|
+ if (vo.getLeaveName().equals("调休")) {
|
|
|
+ vo.setIsDefault(1);
|
|
|
}
|
|
|
- resultMap.put("leaveTypeList", typeList);
|
|
|
- if (defaultType == null) defaultType = typeList.get(0);
|
|
|
- leaveCode = defaultType.leaveCode;
|
|
|
- resultMap.put("defaultLeaveType", defaultType);
|
|
|
- System.out.println("本次请求的LeaveCode: "+leaveCode);
|
|
|
- reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, departmentId, userId, pageIndex, resultMap);
|
|
|
- } catch (ApiException e) {
|
|
|
- e.printStackTrace();
|
|
|
+ vo.setCompanyId(dingding.getCompanyId());
|
|
|
+ typeList.add(vo);
|
|
|
}
|
|
|
- } else {
|
|
|
- reqQuotaList(companyId, dingding, leaveCode, oaManagerDid, departmentId, userId, pageIndex, resultMap);
|
|
|
+ leaveTypeService.saveBatch(typeList);
|
|
|
+ List<User> allUsers = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
+ int batchSize = 50;
|
|
|
+ int batchCount = allUsers.size()%50+allUsers.size()/50==0?0:1;
|
|
|
+ //删除老数据
|
|
|
+ leaveQuotaNumService.remove(new QueryWrapper<LeaveQuotaNum>().eq("company_id", companyId));
|
|
|
+ for (LeaveType type : typeList) {
|
|
|
+ //分批请求,50个一批
|
|
|
+ for (int i=0;i<batchCount; i++) {
|
|
|
+ int startIndex = i*batchSize;
|
|
|
+ int endIndex = (i+1)*batchSize;
|
|
|
+ if (endIndex > allUsers.size()) endIndex = allUsers.size();
|
|
|
+ List<User> curUserList = allUsers.subList(startIndex, endIndex);
|
|
|
+ syncQuotaList(type.getLeaveCode(), oaManagerDid, dingding, curUserList, 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (ApiException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ msg.setError(e.getMessage());
|
|
|
+ return msg;
|
|
|
}
|
|
|
- msg.data = resultMap;
|
|
|
- return msg;
|
|
|
- }
|
|
|
|
|
|
- //递归获取子部门
|
|
|
- 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;
|
|
|
+ return new HttpRespMsg();
|
|
|
}
|
|
|
|
|
|
- private void reqQuotaList(Integer companyId, CompanyDingding dingding,
|
|
|
- String leaveCode, String oaManagerDid, Integer departmentId, String userId, Integer pageIndex, HashMap resultMap) {
|
|
|
- //再调用查看假期余额的接口
|
|
|
+
|
|
|
+ //同步公司全部人员的假期余额
|
|
|
+ private void syncQuotaList(String leaveCode,String oaManagerDid, CompanyDingding dingding, List<User> userList, long offset) {
|
|
|
long pageSize = 50L;
|
|
|
DefaultDingTalkClient client = new DefaultDingTalkClient("https://oapi.dingtalk.com/topapi/attendance/vacation/quota/list");
|
|
|
OapiAttendanceVacationQuotaListRequest quoataReq = new OapiAttendanceVacationQuotaListRequest();
|
|
|
quoataReq.setLeaveCode(leaveCode);
|
|
|
quoataReq.setOpUserid(oaManagerDid);
|
|
|
- List<User> userList = null;
|
|
|
- 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(","));
|
|
|
- userIds = collect;
|
|
|
- resultMap.put("total", total);
|
|
|
- } else {
|
|
|
- userList = new ArrayList<>();
|
|
|
- userList.add(userMapper.selectById(userId));
|
|
|
- userIds = userList.get(0).getDingdingUserid();
|
|
|
- resultMap.put("total", 1);
|
|
|
- }
|
|
|
-
|
|
|
+ String collect = userList.stream().map(User::getDingdingUserid).collect(Collectors.joining(","));
|
|
|
+ String userIds = collect;
|
|
|
System.out.println("请求的size="+userList.size());
|
|
|
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.setOffset(0L);
|
|
|
+ quoataReq.setOffset(offset);
|
|
|
quoataReq.setSize(pageSize);
|
|
|
OapiAttendanceVacationQuotaListResponse quotaListResponse = null;
|
|
|
try {
|
|
@@ -1467,7 +1472,7 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
} catch (ApiException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- System.out.println(quotaListResponse.getBody());
|
|
|
+ System.out.println(quotaListResponse.getBody()+":"+quotaListResponse.getErrmsg());
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
JSONObject json = JSONObject.parseObject(quotaListResponse.getBody());
|
|
|
DecimalFormat df = new DecimalFormat("#0.0");
|
|
@@ -1478,33 +1483,152 @@ public class DingDingServiceImpl implements DingDingService {
|
|
|
for (int i=0;i<leaveQuotas.size(); i++) {
|
|
|
JSONObject jsonObject = leaveQuotas.getJSONObject(i);
|
|
|
String userDDid = jsonObject.getString("userid");
|
|
|
- LeaveQuotaNum quotaNum = quotaNumList.stream().filter(qu->qu.userDingdingId.equals(userDDid)).findFirst().get();
|
|
|
+ LeaveQuotaNum quotaNum = new LeaveQuotaNum();
|
|
|
+ quotaNum.setLeaveCode(leaveCode);
|
|
|
+ quotaNum.setUserDingdingId(userDDid);
|
|
|
+ String name = userList.stream().filter(u->u.getDingdingUserid().equals(userDDid)).findFirst().get().getName();
|
|
|
+ quotaNum.setName(name);
|
|
|
+ quotaNum.setCompanyId(dingding.getCompanyId());
|
|
|
Date startDate = new Date(jsonObject.getLongValue("start_time"));
|
|
|
- quotaNum.startTime = sdf.format(startDate);
|
|
|
+ quotaNum.setStartTime(sdf.format(startDate));
|
|
|
Date endDate = new Date(jsonObject.getLongValue("end_time"));
|
|
|
- quotaNum.endTime = sdf.format(endDate);
|
|
|
+ quotaNum.setEndTime(sdf.format(endDate));
|
|
|
Integer quota_num_per_hour = jsonObject.getInteger("quota_num_per_hour");
|
|
|
if (quota_num_per_hour != null) {
|
|
|
//按小时为单位的情况
|
|
|
- quotaNum.quotaInHours = df.format(quota_num_per_hour*1.0/100);
|
|
|
+ quotaNum.setQuotaInHours(df.format(quota_num_per_hour*1.0/100));
|
|
|
Integer used_num_per_hour = jsonObject.getInteger("used_num_per_hour");
|
|
|
- quotaNum.usedInHours = df.format(used_num_per_hour*1.0/100);
|
|
|
+ quotaNum.setUsedInHours(df.format(used_num_per_hour*1.0/100));
|
|
|
//计算剩余
|
|
|
- quotaNum.leftInHours = df.format((quota_num_per_hour - used_num_per_hour)*1.0/100);
|
|
|
+ quotaNum.setLeftInHours(df.format((quota_num_per_hour - used_num_per_hour)*1.0/100));
|
|
|
} else {
|
|
|
//按天单位的情况
|
|
|
Integer quota_num_per_day = jsonObject.getInteger("quota_num_per_day");
|
|
|
- quotaNum.quotaInDays = df.format(quota_num_per_day*1.0/100);
|
|
|
+ quotaNum.setQuotaInDays(df.format(quota_num_per_day*1.0/100));
|
|
|
Integer used_num_per_day = jsonObject.getInteger("used_num_per_day");
|
|
|
- quotaNum.usedInDays = df.format(used_num_per_day*1.0/100);
|
|
|
+ quotaNum.setUsedInDays(df.format(used_num_per_day*1.0/100));
|
|
|
//计算剩余
|
|
|
- quotaNum.leftInDays = df.format((quota_num_per_day - used_num_per_day)*1.0/100);
|
|
|
+ quotaNum.setLeftInDays(df.format((quota_num_per_day - used_num_per_day)*1.0/100));
|
|
|
}
|
|
|
+ System.out.println(quotaNum.getName()+" 假期额度="+quotaNum.getQuotaInDays());
|
|
|
+ quotaNumList.add(quotaNum);
|
|
|
}
|
|
|
+ leaveQuotaNumService.saveBatch(quotaNumList);
|
|
|
+ }
|
|
|
+ if (result.getBooleanValue("has_more")) {
|
|
|
+ //请求下一批
|
|
|
+ offset += pageSize;
|
|
|
+ System.out.println("请求下一批:offset="+offset);
|
|
|
+ syncQuotaList(leaveCode,oaManagerDid, dingding, userList, offset);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
+//
|
|
|
+// 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");
|
|
|
+// OapiAttendanceVacationQuotaListRequest quoataReq = new OapiAttendanceVacationQuotaListRequest();
|
|
|
+// quoataReq.setLeaveCode(leaveCode);
|
|
|
+// quoataReq.setOpUserid(oaManagerDid);
|
|
|
+// List<User> userList = null;
|
|
|
+// String userIds = null;
|
|
|
+// if (StringUtils.isEmpty(userId)) {
|
|
|
+// int total = 0;
|
|
|
+// if (departmentId == null) {
|
|
|
+// //全部员工,包括离职的
|
|
|
+// QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
|
|
|
+// queryWrapper.select("distinct dingding_userid, name").eq("company_id", companyId);
|
|
|
+// userList = userMapper.selectList(queryWrapper);
|
|
|
+// total = userList.size();
|
|
|
+// } 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>().select("distinct dingding_userid, name")
|
|
|
+// .in("department_id", allSubDepts.stream().map(Department::getDepartmentId).collect(Collectors.toList())));
|
|
|
+// total = userList.size();
|
|
|
+// }
|
|
|
+// String collect = userList.stream().map(User::getDingdingUserid).collect(Collectors.joining(","));
|
|
|
+// userIds = collect;
|
|
|
+// resultMap.put("total", total);
|
|
|
+// } else {
|
|
|
+// userList = new ArrayList<>();
|
|
|
+// userList = userMapper.selectList(new QueryWrapper<User>().in("id", ListUtil.convertLongIdsArrayToList(userId)));
|
|
|
+// userIds = userList.stream().map(User::getDingdingUserid).collect(Collectors.joining(","));
|
|
|
+// resultMap.put("total", userList.size());
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.out.println("请求的size="+userList.size());
|
|
|
+// System.out.println("长度=="+userIds.length());
|
|
|
+// List<LeaveQuotaNum> quotaNumList = new ArrayList<>();
|
|
|
+// for (User user : userList) {
|
|
|
+// LeaveQuotaNum quotaNum = new LeaveQuotaNum();
|
|
|
+// quotaNum.userDingdingId = user.getDingdingUserid();
|
|
|
+// quotaNum.name = user.getName();
|
|
|
+// quotaNum.leaveCode = leaveCode;
|
|
|
+// quotaNumList.add(quotaNum);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (quotaNumList.size() == 0) {
|
|
|
+// //无员工数据了
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// quoataReq.setUserids(userIds);
|
|
|
+// quoataReq.setOffset(0L);
|
|
|
+// quoataReq.setSize(pageSize);
|
|
|
+// OapiAttendanceVacationQuotaListResponse quotaListResponse = null;
|
|
|
+// try {
|
|
|
+// quotaListResponse = client.execute(quoataReq, getInnerCorpToken(dingding));
|
|
|
+// } catch (ApiException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// System.out.println(quotaListResponse.getBody()+":"+quotaListResponse.getErrmsg());
|
|
|
+// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
+// JSONObject json = JSONObject.parseObject(quotaListResponse.getBody());
|
|
|
+// DecimalFormat df = new DecimalFormat("#0.0");
|
|
|
+// if (json.getInteger("errcode") == 0) {
|
|
|
+// JSONObject result = json.getJSONObject("result");
|
|
|
+// JSONArray leaveQuotas = result.getJSONArray("leave_quotas");
|
|
|
+// if (leaveQuotas != null) {
|
|
|
+// for (int i=0;i<leaveQuotas.size(); i++) {
|
|
|
+// JSONObject jsonObject = leaveQuotas.getJSONObject(i);
|
|
|
+// String userDDid = jsonObject.getString("userid");
|
|
|
+// for (LeaveQuotaNum quotaNum : quotaNumList) {
|
|
|
+// if (quotaNum.userDingdingId.equals(userDDid)) {
|
|
|
+// Date startDate = new Date(jsonObject.getLongValue("start_time"));
|
|
|
+// quotaNum.startTime = sdf.format(startDate);
|
|
|
+// Date endDate = new Date(jsonObject.getLongValue("end_time"));
|
|
|
+// quotaNum.endTime = sdf.format(endDate);
|
|
|
+// Integer quota_num_per_hour = jsonObject.getInteger("quota_num_per_hour");
|
|
|
+// if (quota_num_per_hour != null) {
|
|
|
+// //按小时为单位的情况
|
|
|
+// quotaNum.quotaInHours = df.format(quota_num_per_hour*1.0/100);
|
|
|
+// Integer used_num_per_hour = jsonObject.getInteger("used_num_per_hour");
|
|
|
+// quotaNum.usedInHours = df.format(used_num_per_hour*1.0/100);
|
|
|
+// //计算剩余
|
|
|
+// quotaNum.leftInHours = df.format((quota_num_per_hour - used_num_per_hour)*1.0/100);
|
|
|
+// } else {
|
|
|
+// //按天单位的情况
|
|
|
+// Integer quota_num_per_day = jsonObject.getInteger("quota_num_per_day");
|
|
|
+// quotaNum.quotaInDays = df.format(quota_num_per_day*1.0/100);
|
|
|
+// Integer used_num_per_day = jsonObject.getInteger("used_num_per_day");
|
|
|
+// quotaNum.usedInDays = df.format(used_num_per_day*1.0/100);
|
|
|
+// //计算剩余
|
|
|
+// quotaNum.leftInDays = df.format((quota_num_per_day - used_num_per_day)*1.0/100);
|
|
|
+// }
|
|
|
+// System.out.println(quotaNum.name+" 假期额度="+quotaNum.quotaInDays);
|
|
|
+// break;
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// resultMap.put("records", quotaNumList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
public void activateSuite(String authCorpid, String tmpAuthCode) throws ApiException {
|
|
|
DingTalkClient client= new DefaultDingTalkClient("https://oapi.dingtalk.com/service/activate_suite?suite_access_token=" + getDDSuiteAccessToken());
|