Browse Source

考勤合并规则修改多打卡如果等于考勤可以通过

anderx 1 year ago
parent
commit
666a613d97

+ 0 - 1
ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserRecordMapper.java

@@ -35,7 +35,6 @@ public interface UserRecordMapper {
 
     int checkUserRecord(@Param("userId") Long userId, @Param("status") Integer status);
 
-    int checkClockUserRecord(@Param("userId") Long userId);
 
     void userRecordMerge(Long userId);
 

+ 20 - 3
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -980,9 +980,26 @@ public class SysUserServiceImpl implements ISysUserService
         if (i>0){
             return  AjaxResult.error("当前用户存在缺卡的考勤,请处理后再提交");
         }
-        int x = userRecordMapper.checkClockUserRecord(userId);
-        if (x>0){
-            return  AjaxResult.error("当前用户存的考勤存在多打卡,请处理后再提交");
+        List<UserRecord> list = userRecordMapper.selectByUserId(userId);
+        List<UserRecord> list2 = list.stream().filter(e -> e.getClockStatus() == 1).collect(Collectors.toList());
+        //存在多打卡的时候
+        if (!list2.isEmpty()){
+            //判定多打卡状态是否正常
+            for (UserRecord e : list2) {
+                e.getRecordTime().toInstant();
+                LocalDateTime localDateTime = LocalDateTime.ofInstant(e.getRecordTime().toInstant(), ZoneId.systemDefault());
+                LocalDate localDate = localDateTime.toLocalDate();
+                List<ProjectStaffRecord> list3 = projectStaffRecordMapper.selectByDDUidAndTime(e.getDdUserId(), localDate);
+                BigDecimal sum = BigDecimal.ZERO;
+                for (ProjectStaffRecord e2 : list3) {
+                    sum = sum.add(BigDecimal.valueOf(e2.getCheckDuration()));
+                }
+                BigDecimal sum2 = BigDecimal.valueOf(e.getSumDuration());
+                if (sum.compareTo(sum2) != 0){
+                    String dateStr = DateUtils.parseStrYYYYnMMyDD(e.getRecordTime());
+                    return  AjaxResult.error(String.format("[%S]考勤[%S]存在多打卡,请处理后再提交",e.getName(),dateStr));
+                }
+            }
         }
         return AjaxResult.success();
     }

+ 1 - 7
ruoyi-system/src/main/resources/mapper/UserRecordMapper.xml

@@ -184,13 +184,7 @@
         where create_id = #{userId}
         and status = #{status}
     </select>
-    <select id="checkClockUserRecord" resultType="java.lang.Integer">
-        select count(*)
-        from user_record
-        where create_id = #{userId,jdbcType=BIGINT}
-        and  status in(0,1)
-        and clock_status =1
-    </select>
+
     <select id="selectByUserId" parameterType="java.lang.Long" resultMap="BaseResultMap">
         select
         <include refid="Base_Column_List" />