Ver código fonte

针对赛元微电子,半天请假的情况,写死请假和考勤时长

seyason 2 anos atrás
pai
commit
77a2cab71f

+ 47 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -1149,6 +1149,15 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     String baseMorningEnd = workRules.size() <= 1 ? "12:00" : DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(0).getIntValue("off_work_sec"));
                     String baseAfternoonStart = workRules.size() <= 1 ? "13:00" : DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(1).getIntValue("work_sec"));
                     String baseAfternoonEnd = workRules.size() <= 1 ? "18:00" : DateTimeUtil.getTimeFromSeconds(workRules.getJSONObject(1).getIntValue("off_work_sec"));
+                    //获取上下午考勤规则中的工作时长
+                    double baseMorningWorkTime = 0;
+                    double baseAfternoonWorkTime = 0;
+                    if (corpInfo.getCorpid().equals("wpy9TkCAAAgNp4jvqxKTpXrhvwFvyFHg")) {
+                        JSONObject morTime = workRules.getJSONObject(0);
+                        baseMorningWorkTime = DateTimeUtil.getHoursFromSeconds(morTime.getIntValue("off_work_sec") - morTime.getIntValue("work_sec"));
+                        JSONObject aftTime = workRules.getJSONObject(1);
+                        baseAfternoonWorkTime = DateTimeUtil.getHoursFromSeconds(aftTime.getIntValue("off_work_sec") - aftTime.getIntValue("work_sec"));
+                    }
                     if (workRules.size() == 0) {
                         baseMorningStart = "09:00";
                         baseMorningEnd = "12:00";
@@ -1314,8 +1323,10 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                     //格式 "10/17 09:00 / 10/19 18:00"
                                     String string = holiday.getJSONObject("sp_description").getJSONArray("data").getJSONObject(m).getString("text");
                                     String[] s = string.split(" \\/ | |\\~");
-                                    for (String ss : s) {
-                                        System.out.println(ss);
+                                    if (showLog) {
+                                        for (String ss : s) {
+                                            System.out.println(ss);
+                                        }
                                     }
                                     //获取到外出的开始时间和结束时间
                                     boolean isOldFormat = false;
@@ -1393,7 +1404,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         double timeDelta = 0;
                         //时间有变化,需要重新计算
                         if (needRecaculate) {
-                            System.out.println("" + ct.getStartTime() + "--" + ct.getEndTime());
                             timeDelta = DateTimeUtil.getHoursFromSeconds(DateTimeUtil.getSecondsFromTime(ct.getEndTime()) - DateTimeUtil.getSecondsFromTime(ct.getStartTime()));
                             //超过下午上班的开始时间,需要减去午休的时间
                             System.out.println("下午上班时间=="+baseAfternoonStart);
@@ -1444,6 +1454,8 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                             }
                         }
 
+                        boolean morningLeave = false;
+                        boolean afternoonLeave = false;
                         //获取请假的最早和最晚时间
                         for (int t = 0; t < holidayItems.size(); t++) {
                             JSONObject holiday = holidayItems.getJSONObject(t);
@@ -1451,7 +1463,7 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                             JSONArray data = spTitle.getJSONArray("data");
                             for (int m = 0; m < data.size(); m++) {
                                 String leaveText = data.getJSONObject(m).getString("text");
-                                if (leaveText.startsWith("请假")) {
+                                if (leaveText.contains("假") || leaveText.contains("休")) {
                                     //获取对应位置的请假时间段
                                     String string = holiday.getJSONObject("sp_description").getJSONArray("data").getJSONObject(m).getString("text");
                                     String[] s = string.split(" |\\~");
@@ -1472,6 +1484,12 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                             //12小时以上的,是请假半天或者全天的。 防止1天有2次上下午分开的请假,导致计算两次的错误
                                             ct.setAskLeaveTime(ct.getAskLeaveTime() / 24 * 8.0);//转换成一天8小时工作制
                                         }
+                                        if ("上午".equals(leaveStart)) {
+                                            morningLeave = true;
+                                        }
+                                        if ("下午".equals(leaveEnd)) {
+                                            afternoonLeave = true;
+                                        }
                                     } else if (ct.getStartTime().compareTo(leaveStart) <= 0 && ct.getEndTime().compareTo(leaveEnd) >= 0) {
                                         String hourLeaveTime = leaveText.replaceAll("请假", "").replaceAll("小时", "");
                                         if (showLog) System.out.println("请假时长=" + hourLeaveTime);
@@ -1516,12 +1534,6 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                         } else {
                             ct.setWorkHours(DateTimeUtil.getHoursFromDouble(workHours));
                         }
-
-//                        if (regular_work_sec < standard_work_sec) {
-//                            ct.setWorkHours(DateTimeUtil.getHoursFromDouble(ct.getCardTime() + ct.getOutdoorTime()));
-//                        } else {
-//                            ct.setWorkHours(DateTimeUtil.getHoursFromDouble(ct.getCardTime()));
-//                        }
                         if (showLog) System.out.println("ct.getStartTime()==" + ct.getStartTime()+", ct.getEndTime()="+ct.getEndTime());
                         //仅有一次打卡,需要补足下班的打卡时间;重新计算工作时长
                         if (hitOnce) {
@@ -1548,6 +1560,31 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                                 if (showLog) System.out.println("workTime="+workTime+", 二次校正后workHours="+ct.getWorkHours());
                             }
                         }
+                        //针对赛元微电子,请半天假的情况下。重新校正打卡和工作时长
+                        if (corpInfo.getCorpid().equals("wpy9TkCAAAgNp4jvqxKTpXrhvwFvyFHg")) {
+                            if (morningLeave && afternoonLeave) {
+                                ct.setAskLeaveTime(baseMorningWorkTime + baseAfternoonWorkTime);
+                                ct.setWorkHours(0.0);
+                                ct.setCardTime(0.0);
+                                ct.setStartTime(baseMorningStart);
+                                ct.setEndTime(baseAfternoonEnd);
+                                if (showLog) System.out.println("再次校正,全天请假");
+                            } else if (morningLeave){
+                                ct.setAskLeaveTime(baseMorningWorkTime);
+                                ct.setWorkHours(baseAfternoonWorkTime);
+                                ct.setCardTime(baseAfternoonWorkTime);
+                                ct.setStartTime(baseAfternoonStart);
+                                ct.setEndTime(baseAfternoonEnd);
+                                if (showLog) System.out.println("再次校正,上午请假");
+                            } else if (afternoonLeave) {
+                                ct.setAskLeaveTime(baseAfternoonWorkTime);
+                                ct.setWorkHours(baseMorningWorkTime);
+                                ct.setCardTime(baseMorningWorkTime);
+                                ct.setStartTime(baseMorningStart);
+                                ct.setEndTime(baseMorningEnd);
+                                if (showLog) System.out.println("再次校正,下午请假");
+                            }
+                        }
                     }
 
                     List<UserCorpwxTime> itemList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", curUserid)