Browse Source

处理非工作日的加班数据

QuYueTing 4 months ago
parent
commit
c704ebc967

+ 8 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserCorpwxTimeController.java

@@ -231,14 +231,14 @@ public class UserCorpwxTimeController {
         list = userCorpwxTimeMapper.getUserDataList(user.getCompanyId(), startDate, endDate, null, user.getId());
         //工作日处理,排除常规周末和法定节假日
         DateTimeFormatter dtf =  DateTimeFormatter.ofPattern("yyyy/MM/dd");
-        list = list.stream().filter(time->{
-            String date = (String)time.get("createDate");
-            if (WorkDayCalculateUtils.isWorkDay(LocalDate.parse(date, dtf))) {
-                return true;
-            } else {
-                return false;
-            }
-        }).collect(Collectors.toList());
+//        list = list.stream().filter(time->{
+//            String date = (String)time.get("createDate");
+//            if (WorkDayCalculateUtils.isWorkDay(LocalDate.parse(date, dtf))) {
+//                return true;
+//            } else {
+//                return false;
+//            }
+//        }).collect(Collectors.toList());
         DateTimeFormatter standFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         HashMap item = new HashMap();
         item.put("list", list);

+ 40 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -1348,12 +1348,13 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     ct.setAskLeaveTime(0.0);
                     ct.setWorkHours(0.0);
                     ct.setOutdoorTime(0.0);
+
                     if (isCrossDay) {
                         //直接用cardTime作为工作时长
                         ct.setName(name);
                         ct.setWorkHours(DateTimeUtil.getHoursFromDouble(ct.getCardTime()));
                     }
-                    //工作日或者非工作日有打卡,需要校正请假,外出的时长数据
+                    //工作日或者非工作日有打卡/加班,需要校正请假,外出的时长数据
                     else if (timeTypeService.isWorkDay(corpInfo.getCompanyId(), localDate, timeType) || sTime > 0 || eTime > 0) {
                         JSONArray holidayItems = jsonObject.getJSONArray("holiday_infos");
                         //开始时间和结束时间一样,说明下班没有打卡,需要提取请假的最晚时间作为下班打卡时间
@@ -1800,6 +1801,44 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                 }
                             }
                         }
+                    } else {
+                        //以上不满足,存在非工作日仅有加班无打卡的情况,以加班申请时长为准
+                        JSONObject otInfo = jsonObject.getJSONObject("ot_info");
+                        if (otInfo != null && otInfo.getIntValue("ot_duration") > 0 && otInfo.getIntValue("ot_status") == 1) {
+                            double otTime = DateTimeUtil.getHoursFromSeconds(otInfo.getIntValue("ot_duration"));
+                            ct.setWorkHours(otTime);
+                            ct.setCardTime(0.0);
+                            ct.setAskLeaveTime(0.0);
+                            ct.setOutdoorTime(0.0);
+                            ct.setOtStatus(1);
+                            ct.setOtTime(otTime);
+                            JSONArray holidayItems = jsonObject.getJSONArray("holiday_infos");
+                            for (int t = 0; t < holidayItems.size(); t++) {
+                                JSONObject holiday = holidayItems.getJSONObject(t);
+                                JSONObject spTitle = holiday.getJSONObject("sp_title");
+                                JSONArray data = spTitle.getJSONArray("data");
+                                for (int m = 0; m < data.size(); m++) {
+                                    String leaveText = data.getJSONObject(m).getString("text");
+                                    if (leaveText.startsWith("加班")) {
+                                        //获取对应位置的加班时间段
+                                        String string = holiday.getJSONObject("sp_description").getJSONArray("data").getJSONObject(m).getString("text");
+                                        String[] s = string.split(" |\\~");
+                                        //获取到请假的开始时间和结束时间
+                                        String otStart = s[1];
+                                        String otEnd = s[s.length-1];
+                                        if (otStart.equals("上午")) {
+                                            otStart = baseMorningStart;
+                                        }
+                                        if (otEnd.equals("下午")) {
+                                            otEnd = baseAfternoonEnd;
+                                        }
+                                        ct.setStartTime(otStart);
+                                        ct.setEndTime(otEnd);
+                                        break;
+                                    }
+                                }
+                            }
+                        }
                     }
 
                     List<UserCorpwxTime> itemList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", curUserid)