Sfoglia il codice sorgente

修改获取今日考勤打卡数据处理,修复BUG

seyason 1 anno fa
parent
commit
718b4281f1

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

@@ -439,6 +439,19 @@ public class UserCorpwxTimeController {
             if (changedCorpwxTimes.size() > 0) {
                 UserCorpwxTime time = changedCorpwxTimes.get(0);
                 resultMap.put("time", time);
+
+                //如果考勤时间为0,获取当日打卡记录
+                if (time.getWorkHours() == 0) {
+                    LocalDateTime start1 = LocalDateTime.of(localDate, LocalTime.MIN);
+                    LocalDateTime end1 = LocalDateTime.of(localDate, LocalTime.MAX).withSecond(0).withNano(0);
+                    wxCorpInfoService.getUserPunchRecord(user.getCompanyId(),user.getId(),start1,end1,false);
+                    List<UserCorpwxTime> changedCorpwxTimes1 = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>()
+                            .eq("corpwx_userid", user.getCorpwxUserid()).eq("create_date", date));
+                    if (changedCorpwxTimes1.size() > 0) {
+                        UserCorpwxTime time1 = changedCorpwxTimes1.get(0);
+                        resultMap.put("time", time1);
+                    }
+                }
             }
             msg.data=resultMap;
         } else {

+ 14 - 7
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/WxCorpInfoServiceImpl.java

@@ -985,25 +985,32 @@ public class WxCorpInfoServiceImpl extends ServiceImpl<WxCorpInfoMapper, WxCorpI
                     }
                     Integer min = Collections.min(upList);
                     Integer max = Collections.max(downList);
+
                     String minTime = DateTimeUtil.getTimeFromSeconds(min);
                     String maxTime = DateTimeUtil.getTimeFromSeconds(max);
                     DateTimeFormatter df = DateTimeFormatter.ofPattern("HH:mm");
-                    userCorpwxTime.setStartTime(LocalTime.parse(minTime,df).plusHours(8).format(df));
-                    userCorpwxTime.setEndTime(LocalTime.parse(maxTime,df).plusHours(8).format(df));
+                    LocalTime startCardTime = LocalTime.parse(minTime,df).plusHours(8);
+                    LocalTime endCardTime = LocalTime.parse(maxTime,df).plusHours(8);
+                    if (showLog) System.out.println("min=" + min + ",max=" + max+", startTime="+startCardTime.format(df)
+                                +"endTime="+endCardTime.format(df));
+                    userCorpwxTime.setStartTime(startCardTime.format(df));
+                    userCorpwxTime.setEndTime(endCardTime.format(df));
                     userCorpwxTime.setWxCorpid(corpInfo.getCorpid());
                     userCorpwxTime.setCreateDate(date);
                     userCorpwxTime.setWeekDay(date.getDayOfWeek().getValue());
                     userCorpwxTime.setWeekDayTxt(DateTimeUtil.getWeekDayTxt(userCorpwxTime.getWeekDay()));
                     //下班打卡时间在第二天的情况下设置为前一天的23:59
-                    if(LocalTime.parse(maxTime,df).isBefore(LocalTime.parse(minTime,df))){
-                        maxTime="23:59";
+                    if(endCardTime.isBefore(startCardTime)){
+                        maxTime="15:59";//23:59减去8小时的偏差
+                        endCardTime.withHour(23).withMinute(59).withSecond(0).withNano(0);
                     }
-                    BigDecimal bigDecimal=new BigDecimal(Duration.between(LocalTime.parse(minTime,df).plusHours(8),LocalTime.parse(maxTime,df).plusHours(8)).toMinutes());
-
+                    BigDecimal bigDecimal = new BigDecimal(Duration.between(startCardTime,endCardTime).toMinutes());
+                    if (showLog) System.out.println("打卡时长(分钟):" + bigDecimal);
                     //开始时间在上午,结束时间在下午,要减去午休时长
-                    if (LocalTime.parse(minTime,df).plusHours(8).compareTo(LocalTime.parse(baseMorningEnd,df)) <= 0 && LocalTime.parse(maxTime,df).plusHours(8).compareTo(LocalTime.parse(baseAfternoonStart,df)) >= 0) {
+                    if (startCardTime.compareTo(LocalTime.parse(baseMorningEnd,df)) <= 0 && endCardTime.compareTo(LocalTime.parse(baseAfternoonStart,df)) >= 0) {
                         //重新计算打卡工时时,需要减去中间午休时间
                         bigDecimal = bigDecimal.divide(BigDecimal.valueOf(60),1,BigDecimal.ROUND_HALF_UP).subtract(new BigDecimal(restTime));
+                        if (showLog) System.out.println("午休时间:"+restTime+", 减去后,工作时长="+bigDecimal);
                     } else {
                         bigDecimal = bigDecimal.divide(BigDecimal.valueOf(60),1,BigDecimal.ROUND_HALF_UP);
                     }

+ 1 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/UserCorpwxTimeMapper.xml

@@ -45,7 +45,7 @@
         user left join department on department.department_id = user.department_id
             LEFT JOIN
         (SELECT a.corpwx_userid,a.name, SUM(a.work_hours) AS workHours FROM user_corpwx_time a, user b WHERE a.company_id = #{companyId}
-        AND a.`corpwx_userid` = b.`corpwx_userid`
+        AND (a.`corpwx_userid` = b.`corpwx_userid` OR (a.corpwx_userid IS NULL AND a.name = b.name))
             AND (a.`create_date` &gt;= b.`induction_date` OR b.`induction_date` IS NULL)
             AND  a.create_date in
            <foreach collection="dateList" item="date" open="(" separator="," close=")">