Browse Source

合并无匹配的数据直接新增

anderx 1 year ago
parent
commit
15a7a5cdd8

+ 17 - 2
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java

@@ -822,7 +822,20 @@ public class SysUserServiceImpl implements ISysUserService
                     ur.setClockStatus(0);
                     ur.setPsrId(projectStaffRecords.get(0).getId());
                 }else if (projectStaffRecords.size()>1){
-                    ur.setClockStatus(1);
+                    //判定打卡状态
+                    BigDecimal sum = BigDecimal.ZERO;
+                    BigDecimal sum2 =BigDecimal.ZERO;
+                    if (e.getDuration()!=null){
+                        sum2 = BigDecimal.valueOf(e.getDuration());
+                    }
+                    for (ProjectStaffRecord e2 : projectStaffRecords) {
+                        sum = sum.add(BigDecimal.valueOf(e2.getDuration()));
+                    }
+                    if(sum.compareTo(sum2) == 0){
+                        ur.setClockStatus(1);
+                    }else {
+                        ur.setClockStatus(3);
+                    }
                     ur.setList(projectStaffRecords);
                 }
                 ur.setCreateId(SecurityUtils.getUserId());
@@ -1029,7 +1042,9 @@ public class SysUserServiceImpl implements ISysUserService
                     List<ProjectStaffRecord> list3 = projectStaffRecordMapper.selectByDDUidAndTime(e.getDdUserId(), localDate);
                     BigDecimal sum = BigDecimal.ZERO;
                     for (ProjectStaffRecord e2 : list3) {
-                        sum = sum.add(BigDecimal.valueOf(e2.getCheckDuration()));
+                        if (e2.getCheckDuration()!=null){
+                            sum = sum.add(BigDecimal.valueOf(e2.getCheckDuration()));
+                        }
                     }
                     BigDecimal sum2 = BigDecimal.valueOf(e.getCheckDuration());
                     if (sum.compareTo(sum2) != 0){