|
@@ -467,82 +467,94 @@ public class KYCDServiceImpl extends ServiceImpl<AdvancedLeaveMapper, AdvancedLe
|
|
|
.eq(AdvancedLeave::getValidFlag,"1");
|
|
|
AdvancedLeave advancedLeave = advancedLeaveMapper.selectOne(advancedLeaveLambdaQueryWrapper);
|
|
|
*/
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
|
|
|
Map leaveMap = new HashMap();
|
|
|
- //查询员工年假余额
|
|
|
- Map body1 = new HashMap();
|
|
|
-// body1.put("leave_code","609a84ed-54d4-4ecd-a44f-4c55b04c37ea");//年假(测试)
|
|
|
- body1.put("leave_code","f7e0de92-806f-457e-9aa1-c20b245d741e");//年假
|
|
|
- body1.put("op_userid",ddConf.getOperator());
|
|
|
- body1.put("userids",userId);
|
|
|
- body1.put("offset",0);
|
|
|
- body1.put("size",10);
|
|
|
- DDR_New ddrNew1 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/attendance/vacation/quota/list", null, ddClient.initTokenParams(), body1, DDR_New.class);
|
|
|
- Map result1 = (Map)ddrNew1.getResult();
|
|
|
-
|
|
|
|
|
|
//年假余额
|
|
|
- double annualLeaveNum = 0.00;
|
|
|
- //预支年假数量
|
|
|
- double advancedLeaveNum = 8.00;
|
|
|
-
|
|
|
- if (Objects.nonNull(result1.get("leave_quotas"))){
|
|
|
- for (Map leaveQuotas : (List<Map>) result1.get("leave_quotas")) {
|
|
|
- if (Objects.isNull(leaveQuotas.get("quota_num_per_hour")) && Objects.nonNull(leaveQuotas.get("quota_num_per_day"))){
|
|
|
- annualLeaveNum += ((int) leaveQuotas.get("quota_num_per_day")) / 100.0;
|
|
|
+ BigDecimal annualLeaveNum = new BigDecimal(0.00);
|
|
|
+
|
|
|
+ //查询员工年假余额
|
|
|
+ List<Map> leaveQuotasList = new ArrayList<>();
|
|
|
+ getLeaveNum("f7e0de92-806f-457e-9aa1-c20b245d741e",userId,0,50,leaveQuotasList);
|
|
|
+
|
|
|
+ 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_hour")) && Objects.nonNull(leaveQuotas.get("quota_num_per_day"))){
|
|
|
+ annualLeaveNum = annualLeaveNum.add(new BigDecimal(String.valueOf(leaveQuotas.get("quota_num_per_day"))).divide(new BigDecimal(100)));
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(leaveQuotas.get("used_num_per_day"))){
|
|
|
+ annualLeaveNum = annualLeaveNum.subtract(new BigDecimal(String.valueOf(leaveQuotas.get("used_num_per_day"))).divide(new BigDecimal(100)));
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- /*if (Objects.nonNull(advancedLeave)){
|
|
|
- advancedLeaveNum = advancedLeave.getLeaveNum();
|
|
|
- }else{
|
|
|
- advancedLeaveNum = annualLeaveNum >= 8 ? 8 : (int)annualLeaveNum;
|
|
|
- }*/
|
|
|
-
|
|
|
- if (annualLeaveNum >= 8){
|
|
|
- annualLeaveNum = advancedLeaveNum - 8;
|
|
|
+ if (annualLeaveNum.compareTo(new BigDecimal(8)) == 1 || annualLeaveNum.compareTo(new BigDecimal(8)) == 0){
|
|
|
+ annualLeaveNum = annualLeaveNum.subtract(new BigDecimal(8));
|
|
|
leaveMap.put("可预支年假",8);
|
|
|
leaveMap.put("实际年假余额",annualLeaveNum);
|
|
|
leaveMap.put("已预支年假",0);
|
|
|
}else {
|
|
|
- double relYearLeave = annualLeaveNum % 0.5;
|
|
|
- leaveMap.put("可预支年假",annualLeaveNum - relYearLeave);
|
|
|
- leaveMap.put("实际年假余额",annualLeaveNum - 8);
|
|
|
- leaveMap.put("已预支年假",8 - (annualLeaveNum - relYearLeave));
|
|
|
+ BigDecimal relYearLeave = annualLeaveNum.remainder(new BigDecimal(0.5));
|
|
|
+ leaveMap.put("可预支年假",annualLeaveNum.subtract(relYearLeave));
|
|
|
+ leaveMap.put("实际年假余额",annualLeaveNum.subtract(new BigDecimal(8)));
|
|
|
+ leaveMap.put("已预支年假",new BigDecimal(8).subtract(annualLeaveNum).add(relYearLeave));
|
|
|
}
|
|
|
-/* leaveMap.put("可预支年假",Math.min(8,annualLeaveNum));
|
|
|
- leaveMap.put("实际年假余额",NumberUtil.sub(annualLeaveNum,advancedLeaveNum));
|
|
|
- leaveMap.put("已预支年假",Math.max(0,Math.ceil(advancedLeaveNum-annualLeaveNum)));*/
|
|
|
-
|
|
|
-
|
|
|
|
|
|
+ //获取员工调休假余额
|
|
|
+ List<Map> leaveQuotasList2 = new ArrayList<>();
|
|
|
+ getLeaveNum("c7beb5e9-73ee-45f8-ae66-dfdb2a5ad0b8",userId,0,10,leaveQuotasList2);
|
|
|
|
|
|
- //查询员工调休假余额
|
|
|
- Map body2 = new HashMap();
|
|
|
- body2.put("leave_code","c7beb5e9-73ee-45f8-ae66-dfdb2a5ad0b8");//调休假
|
|
|
- body2.put("op_userid",ddConf.getOperator());
|
|
|
- body2.put("userids",userId);
|
|
|
- body2.put("offset",0);
|
|
|
- body2.put("size",10);
|
|
|
- DDR_New ddrNew2 = (DDR_New) UtilHttp.doPost("https://oapi.dingtalk.com/topapi/attendance/vacation/quota/list", null, ddClient.initTokenParams(), body2, DDR_New.class);
|
|
|
- Map result2 = (Map)ddrNew2.getResult();
|
|
|
//调休假余额
|
|
|
int compensatoryLeaveNum = 0;
|
|
|
- if (Objects.nonNull(result2.get("leave_quotas"))){
|
|
|
- for (Map leaveQuotas : (List<Map>) result2.get("leave_quotas")) {
|
|
|
- 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(leaveQuotasList2)){
|
|
|
+ for (Map leaveQuotas : leaveQuotasList2) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ }
|
|
|
+ if (compensatoryLeaveNum >= 80){
|
|
|
+ leaveMap.put("可预支调休",80);
|
|
|
+ leaveMap.put("实际加班小时数",compensatoryLeaveNum-80);
|
|
|
+ leaveMap.put("已预支调休",0);
|
|
|
+ }else {
|
|
|
leaveMap.put("可预支调休",compensatoryLeaveNum);
|
|
|
- leaveMap.put("实际加班小时数",Math.max(0,compensatoryLeaveNum-80));
|
|
|
- leaveMap.put("已预支调休",Math.max(0,80-compensatoryLeaveNum));
|
|
|
+ leaveMap.put("实际加班小时数",0);
|
|
|
+ leaveMap.put("已预支调休",80-compensatoryLeaveNum);
|
|
|
}
|
|
|
+
|
|
|
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;
|
|
|
+ }
|
|
|
+
|
|
|
private int getAnnualLeaveBaseNum(String positionLevel) {
|
|
|
int annualLeave = 0;
|
|
|
if (positionLevel.equals("MGR") || positionLevel.equals("DH") || positionLevel.equals("副主任医师")){
|