|
@@ -408,9 +408,31 @@ public class KYNTServiceImpl implements KYNTService {
|
|
|
|
|
|
@Override
|
|
|
public Map getUserLeaveInfo(String userId) {
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
+
|
|
|
Map leaveMap = new HashMap();
|
|
|
+
|
|
|
+ //获取员工调休假余额
|
|
|
+ List<Map> leaveQuotasList = new ArrayList<>();
|
|
|
+ getLeaveNum("8a10b574-4274-47bc-9bad-1df1c4308f60",userId,0,50,leaveQuotasList);
|
|
|
+
|
|
|
//查询员工调休假余额
|
|
|
- Map body2 = new HashMap();
|
|
|
+ int compensatoryLeaveNum = 0;
|
|
|
+ if (Objects.nonNull(leaveQuotasList)){
|
|
|
+ for (Map leaveQuotas : leaveQuotasList) {
|
|
|
+ if ((long) leaveQuotas.get("start_time") <= currentTime && currentTime <= (long) leaveQuotas.get("end_time")){
|
|
|
+ if (Objects.isNull(leaveQuotas.get("quota_num_per_day")) && Objects.nonNull(leaveQuotas.get("quota_num_per_hour"))){
|
|
|
+ compensatoryLeaveNum += ((int) leaveQuotas.get("quota_num_per_hour")) / 100;
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(leaveQuotas.get("used_num_per_hour"))){
|
|
|
+ compensatoryLeaveNum -= ((int) leaveQuotas.get("used_num_per_hour")) / 100;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /*Map body2 = new HashMap();
|
|
|
body2.put("leave_code","8a10b574-4274-47bc-9bad-1df1c4308f60");//调休假
|
|
|
body2.put("op_userid",ddConf.getOperator());
|
|
|
body2.put("userids",userId);
|
|
@@ -425,13 +447,45 @@ public class KYNTServiceImpl implements KYNTService {
|
|
|
leaveNum += ((int) leaveQuotas.get("quota_num_per_hour")) / 100;
|
|
|
}
|
|
|
}
|
|
|
- leaveMap.put("可预支调休",leaveNum);
|
|
|
- leaveMap.put("实际加班小时数",Math.max(0,leaveNum-80));
|
|
|
- leaveMap.put("已预支调休",Math.max(0,80-leaveNum));
|
|
|
+
|
|
|
+ }*/
|
|
|
+ if (compensatoryLeaveNum >= 80){
|
|
|
+ leaveMap.put("可预支调休",80);
|
|
|
+ leaveMap.put("实际加班小时数",compensatoryLeaveNum-80);
|
|
|
+ leaveMap.put("已预支调休",0);
|
|
|
+ }else {
|
|
|
+ leaveMap.put("可预支调休",compensatoryLeaveNum);
|
|
|
+ leaveMap.put("实际加班小时数",0);
|
|
|
+ leaveMap.put("已预支调休",80-compensatoryLeaveNum);
|
|
|
}
|
|
|
+ /*leaveMap.put("可预支调休",leaveNum);
|
|
|
+ leaveMap.put("实际加班小时数",Math.max(0,leaveNum-80));
|
|
|
+ leaveMap.put("已预支调休",Math.max(0,80-leaveNum));*/
|
|
|
+
|
|
|
return leaveMap;
|
|
|
}
|
|
|
|
|
|
+ private List<Map> getLeaveNum(String leave_code,String userId,int offset,int size,List<Map> leaveQuotasList) {
|
|
|
+ Map body = new HashMap();
|
|
|
+ body.put("leave_code",leave_code);
|
|
|
+ body.put("op_userid",ddConf.getOperator());
|
|
|
+ body.put("userids",userId);
|
|
|
+ body.put("offset",offset);
|
|
|
+ body.put("size",size);
|
|
|
+
|
|
|
+ DDR_New ddrNew = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/attendance/vacation/quota/list", null, ddClient.initTokenParams(), body, DDR_New.class);
|
|
|
+ Map result = (Map) ddrNew.getResult();
|
|
|
+
|
|
|
+ if (Objects.nonNull(result.get("leave_quotas"))){
|
|
|
+ leaveQuotasList.addAll((List<Map>) result.get("leave_quotas"));
|
|
|
+ }
|
|
|
+
|
|
|
+ if ((boolean) result.get("has_more")){
|
|
|
+ getLeaveNum(leave_code,userId,offset+size,size,leaveQuotasList);
|
|
|
+ }
|
|
|
+ return leaveQuotasList;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 检查该更新事件在5s内是否处理过,应对钉钉瞬间重复回调
|
|
|
*
|