Commit 5136dd88fa8667bef54d87b2a6d9d110a9abbb54
1 parent
e3af5b24
feat: 签退时间和签到时间相隔过近打卡逻辑进行补充。
Showing
4 changed files
with
68 additions
and
30 deletions
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
| @@ -626,7 +626,10 @@ public class SignInServiceImpl implements ISignInService { | @@ -626,7 +626,10 @@ public class SignInServiceImpl implements ISignInService { | ||
| 626 | 626 | ||
| 627 | private String getPrompt(DriverSignInRecommendation currentScheduling) { | 627 | private String getPrompt(DriverSignInRecommendation currentScheduling) { |
| 628 | if (BC_TYPE_OUT.equals(currentScheduling.getBcType())) { | 628 | if (BC_TYPE_OUT.equals(currentScheduling.getBcType())) { |
| 629 | - return "请在" + ConstDateUtil.formatDate("HH:mm", new Date(currentScheduling.getTimestamps())) + "前一小时内打卡。"; | 629 | + LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())), "yyyy-MM-dd HH:mm:ss"); |
| 630 | + LocalDateTime subHours = time.plusHours(-1); | ||
| 631 | + return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" | ||
| 632 | + + ConstDateUtil.formatDate("HH:mm", subHours) + "之间打卡"; | ||
| 630 | } else { | 633 | } else { |
| 631 | // 延后一小时 | 634 | // 延后一小时 |
| 632 | LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())), "yyyy-MM-dd HH:mm:ss"); | 635 | LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())), "yyyy-MM-dd HH:mm:ss"); |
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
| @@ -145,7 +145,7 @@ public class SchedulingService { | @@ -145,7 +145,7 @@ public class SchedulingService { | ||
| 145 | long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT(); | 145 | long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT(); |
| 146 | long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime())); | 146 | long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime())); |
| 147 | if (SignInServiceImpl.checkTimerSign(nowBetween, scheduling.getBcType())) { | 147 | if (SignInServiceImpl.checkTimerSign(nowBetween, scheduling.getBcType())) { |
| 148 | - if (nowBetween < -60L || (BC_TYPE_IN.equals(scheduling.getBcType()) && nowBetween < 0L) ) { | 148 | + if (nowBetween < -60L || (BC_TYPE_IN.equals(scheduling.getBcType()) && nowBetween < 0L)) { |
| 149 | sb.append(EARLY); | 149 | sb.append(EARLY); |
| 150 | } else { | 150 | } else { |
| 151 | sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType())); | 151 | sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType())); |
| @@ -158,7 +158,6 @@ public class SchedulingService { | @@ -158,7 +158,6 @@ public class SchedulingService { | ||
| 158 | int index = signIn.getRemark().indexOf(ALCOHOL_SIGN_IN_ERROR); | 158 | int index = signIn.getRemark().indexOf(ALCOHOL_SIGN_IN_ERROR); |
| 159 | if (index != -1) { | 159 | if (index != -1) { |
| 160 | sb.append("," + signIn.getRemark().substring(index)); | 160 | sb.append("," + signIn.getRemark().substring(index)); |
| 161 | - | ||
| 162 | } | 161 | } |
| 163 | } | 162 | } |
| 164 | return sb.toString(); | 163 | return sb.toString(); |
| @@ -175,31 +174,55 @@ public class SchedulingService { | @@ -175,31 +174,55 @@ public class SchedulingService { | ||
| 175 | signIn.setRemark("您已经打卡过了,请勿在3分钟内重复打卡"); | 174 | signIn.setRemark("您已经打卡过了,请勿在3分钟内重复打卡"); |
| 176 | return; | 175 | return; |
| 177 | } | 176 | } |
| 178 | - // 目前也有效 -》 无需更新 || 目前无效 -》往后更新 TODO 判断时间 之前的有效 但是时间还在有效范围内打卡的话会导致排班表数据不匹配 | 177 | + // 目前也有效 -》 无需更新 || 目前无效 -》往后更新 |
| 178 | + // TODO 判断时间 之前的有效 但是人员提前打卡且还在上次操作有效范围内需要往后偏移 | ||
| 179 | + // 但是操作一样时间还在有效范围内打卡的话会导致排班表数据不匹配 | ||
| 180 | + int index = dto.size() > globalIndex.getIndex() ? globalIndex.getIndex() + 1 : globalIndex.getIndex(); | ||
| 179 | if (signIn.getExType().equals(SIGN_NO_EX_NUM)) { | 181 | if (signIn.getExType().equals(SIGN_NO_EX_NUM)) { |
| 180 | - return; | 182 | + if (signIn.getType().equals(bcTypeTransform(dto.get(globalIndex.getIndex()).getBcType()))) { |
| 183 | + return; | ||
| 184 | + } | ||
| 185 | + // 校验下一次的时间 | ||
| 186 | + DriverSignInRecommendation nextClosestTimestamp = computedTheCurrentClosestTimestamp(dto, signIn.getCreateTime().getTime(), 1); | ||
| 187 | + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(nextClosestTimestamp.getTimestamps()); | ||
| 188 | + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()); | ||
| 189 | + long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime); | ||
| 190 | + boolean result = SignInServiceImpl.checkTimerSign(nowBetween, nextClosestTimestamp.getBcType()); | ||
| 191 | + // 不在范围内设置异常 | ||
| 192 | + if (result) { | ||
| 193 | + signIn.setExType(SIGN_TIME_OUT_EX_NUM); | ||
| 194 | + } | ||
| 181 | } | 195 | } |
| 182 | - int index = globalIndex.getIndex() + 1; | ||
| 183 | DriverScheduling scheduling = dto.get(index); | 196 | DriverScheduling scheduling = dto.get(index); |
| 184 | long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT(); | 197 | long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT(); |
| 185 | String prompt = getPrompt(new Date(date), scheduling.getBcType()); | 198 | String prompt = getPrompt(new Date(date), scheduling.getBcType()); |
| 186 | signIn.setRemark((scheduling.getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT) + prompt); | 199 | signIn.setRemark((scheduling.getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT) + prompt); |
| 187 | signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。")); | 200 | signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。")); |
| 188 | String remark = getRemark(dto, signIn, index); | 201 | String remark = getRemark(dto, signIn, index); |
| 202 | + signInMapper.updateSignIn(signIn); | ||
| 189 | schedulingMapper.updateRoster(scheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); | 203 | schedulingMapper.updateRoster(scheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake()); |
| 190 | nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex() + 1, signIn); | 204 | nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex() + 1, signIn); |
| 191 | } | 205 | } |
| 192 | 206 | ||
| 207 | + private Integer bcTypeTransform(String bcType) { | ||
| 208 | + if (BC_TYPE_OUT.equals(bcType)) { | ||
| 209 | + return 1; | ||
| 210 | + } else { | ||
| 211 | + return 2; | ||
| 212 | + } | ||
| 213 | + } | ||
| 214 | + | ||
| 193 | private String getPrompt(Date date, String bcType) { | 215 | private String getPrompt(Date date, String bcType) { |
| 194 | if (BC_TYPE_OUT.equals(bcType)) { | 216 | if (BC_TYPE_OUT.equals(bcType)) { |
| 195 | - return "请在" + ConstDateUtil.formatDate("HH:mm", date) + "前后一小时内打卡。"; | 217 | + LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", date), "yyyy-MM-dd HH:mm:ss"); |
| 218 | + LocalDateTime subTime = time.plusHours(-1); | ||
| 219 | + return "请在" + ConstDateUtil.formatDate("HH:mm", subTime) + "到" + | ||
| 220 | + ConstDateUtil.formatDate("HH:mm", time) + "之间打卡"; | ||
| 196 | } else { | 221 | } else { |
| 197 | - // 正两小时 负 1小时 | ||
| 198 | LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", date), "yyyy-MM-dd HH:mm:ss"); | 222 | LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", date), "yyyy-MM-dd HH:mm:ss"); |
| 199 | - LocalDateTime addHours = time.plusHours(2); | ||
| 200 | - LocalDateTime hours = time.plusHours(-1); | ||
| 201 | - return "请在" + ConstDateUtil.formatDate("HH:mm", hours) + "到" | ||
| 202 | - + ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡"; | 223 | + LocalDateTime addHours = time.plusHours(1); |
| 224 | + return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" + | ||
| 225 | + ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡"; | ||
| 203 | } | 226 | } |
| 204 | } | 227 | } |
| 205 | 228 |
Bsth-admin/src/main/java/com/ruoyi/utils/ToolUtils.java
| @@ -70,7 +70,7 @@ public class ToolUtils { | @@ -70,7 +70,7 @@ public class ToolUtils { | ||
| 70 | scheduling.setRemark(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType())); | 70 | scheduling.setRemark(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType())); |
| 71 | } | 71 | } |
| 72 | } | 72 | } |
| 73 | - // 签退客户说把时间约定在正负一小时以内 | 73 | + // 签退客户说把时间约定在负一小时以内 |
| 74 | // 签退 | 74 | // 签退 |
| 75 | if (BC_TYPE_IN.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getSignTime()) && SIGN_STATUS_ZONE_ENUM.getStatus().equals(scheduling.getExType())) { | 75 | if (BC_TYPE_IN.equals(scheduling.getBcType()) && !Objects.isNull(scheduling.getSignTime()) && SIGN_STATUS_ZONE_ENUM.getStatus().equals(scheduling.getExType())) { |
| 76 | // 实际签退时间 | 76 | // 实际签退时间 |
Bsth-admin/src/main/test/com.ruoyi/TestBsthApplication.java
| @@ -3,6 +3,7 @@ package com.ruoyi; | @@ -3,6 +3,7 @@ package com.ruoyi; | ||
| 3 | 3 | ||
| 4 | import com.ruoyi.BsthApplication; | 4 | import com.ruoyi.BsthApplication; |
| 5 | import com.ruoyi.common.cache.NowSchedulingCache; | 5 | import com.ruoyi.common.cache.NowSchedulingCache; |
| 6 | +import com.ruoyi.common.utils.bean.BeanUtils; | ||
| 6 | import com.ruoyi.domain.DriverScheduling; | 7 | import com.ruoyi.domain.DriverScheduling; |
| 7 | import com.ruoyi.driver.service.IDriverService; | 8 | import com.ruoyi.driver.service.IDriverService; |
| 8 | import com.ruoyi.in.domain.SignIn; | 9 | import com.ruoyi.in.domain.SignIn; |
| @@ -38,31 +39,42 @@ public class TestBsthApplication { | @@ -38,31 +39,42 @@ public class TestBsthApplication { | ||
| 38 | 39 | ||
| 39 | @Test | 40 | @Test |
| 40 | public void testAddSignIn() { | 41 | public void testAddSignIn() { |
| 42 | +// 724778 722104 722576 | ||
| 41 | // 模拟前端签到 | 43 | // 模拟前端签到 |
| 42 | String [] params = new String[] { | 44 | String [] params = new String[] { |
| 43 | - "2024-02-19 04:30:06,1,1,0", | ||
| 44 | - "2024-02-19 05:03:06,1,1,0", | ||
| 45 | - "2024-02-19 11:30:30,2,0,0", | ||
| 46 | - "2024-02-19 12:16:15,2,0,0", | ||
| 47 | - "2024-02-19 15:13:03,1,1,0", | ||
| 48 | - "2024-02-19 16:13:03,1,1,0", | ||
| 49 | - "2024-02-19 21:36:03,1,1,0",}; | 45 | + "2024-03-20 3:45:44,1,1,0", |
| 46 | + "2024-03-20 07:45:44,1,1,0", | ||
| 47 | +// "2024-03-20 11:27:57,2,1,0", | ||
| 48 | +// "2024-03-20 11:39:30,2,0,0", | ||
| 49 | + "2024-03-20 12:21:02,2,0,0", | ||
| 50 | +// "2024-03-20 21:45:35,2,1,0", | ||
| 51 | + "2024-03-20 17:45:35,2,1,0", | ||
| 52 | + }; | ||
| 50 | try { | 53 | try { |
| 51 | for (int i = 0; i < params.length; i++) { | 54 | for (int i = 0; i < params.length; i++) { |
| 52 | String[] strings = params[i].split(","); | 55 | String[] strings = params[i].split(","); |
| 53 | - SignIn signIn = new SignIn(); | ||
| 54 | - signIn.setJobCode("722017"); | ||
| 55 | - signIn.setCreateTime(ConstDateUtil.parseDate(strings[0])); | ||
| 56 | - signIn.setType(Integer.parseInt(strings[1])); | ||
| 57 | - signIn.setDeviceId("003"); | ||
| 58 | - signIn.setAlcoholFlag(Integer.parseInt(strings[2])); | ||
| 59 | - signIn.setAlcoholIntake(new BigDecimal(strings[3])); | ||
| 60 | - signInService.addSignIn(signIn); | 56 | + SignIn signIn1 = new SignIn(); |
| 57 | + SignIn signIn2 = new SignIn(); | ||
| 58 | + SignIn signIn3 = new SignIn(); | ||
| 59 | + signIn1.setJobCode("722902"); | ||
| 60 | + signIn1.setCreateTime(ConstDateUtil.parseDate(strings[0])); | ||
| 61 | + signIn1.setType(Integer.parseInt(strings[1])); | ||
| 62 | + signIn1.setDeviceId("003"); | ||
| 63 | + signIn1.setAlcoholFlag(Integer.parseInt(strings[2])); | ||
| 64 | + signIn1.setAlcoholIntake(new BigDecimal(strings[3])); | ||
| 65 | + signInService.addSignIn(signIn1); | ||
| 66 | +// | ||
| 67 | +// BeanUtils.copyProperties(signIn1,signIn2); | ||
| 68 | +// signIn2.setJobCode("722104"); | ||
| 69 | +// signInService.addSignIn(signIn2); | ||
| 70 | +// BeanUtils.copyProperties(signIn1,signIn3); | ||
| 71 | +// signIn3.setJobCode("722576"); | ||
| 72 | +// signInService.addSignIn(signIn3); | ||
| 61 | } | 73 | } |
| 62 | 74 | ||
| 63 | ReportViewRequestVo vo = new ReportViewRequestVo(); | 75 | ReportViewRequestVo vo = new ReportViewRequestVo(); |
| 64 | - vo.setDate("2024-02-19"); | ||
| 65 | - vo.setJobCode("722017"); | 76 | + vo.setDate("2024-3-19"); |
| 77 | + vo.setJobCode("722519"); | ||
| 66 | System.out.println(); | 78 | System.out.println(); |
| 67 | for (ReportViewResponseVo responseVo : reportService.getReportScrollViewTable(vo, null)) { | 79 | for (ReportViewResponseVo responseVo : reportService.getReportScrollViewTable(vo, null)) { |
| 68 | System.out.println(responseVo); | 80 | System.out.println(responseVo); |