Commit af61bdb071d1f35aa2272e190257386940a7599e
1 parent
1b7bcae8
feat: 新增规则修改校验,修改签退时间规则.
Showing
6 changed files
with
52 additions
and
28 deletions
Bsth-admin/src/main/java/com/ruoyi/controller/AttendanceController.java
| ... | ... | @@ -132,7 +132,7 @@ public class AttendanceController extends BaseController { |
| 132 | 132 | |
| 133 | 133 | @ApiOperation("获取一个月的排班table") |
| 134 | 134 | @GetMapping("/list/people") |
| 135 | - public TableDataInfo getTableMonth(@ModelAttribute PeopleRequestVo vo){ | |
| 135 | + public TableDataInfo getTableMonth(@ModelAttribute PeopleRequestVo vo) { | |
| 136 | 136 | return attendanceService.getTableMonth(vo); |
| 137 | 137 | } |
| 138 | 138 | |
| ... | ... | @@ -140,21 +140,21 @@ public class AttendanceController extends BaseController { |
| 140 | 140 | @ApiOperation("用户顶班") |
| 141 | 141 | @PutMapping("/update/people/attendance") |
| 142 | 142 | @Log(title = "用户顶班", businessType = BusinessType.UPDATE) |
| 143 | - public Result<?> updateSchedulingByUser( @RequestBody @Validated UpdatePeopleAttendanceRequestVo vo){ | |
| 143 | + public Result<?> updateSchedulingByUser(@RequestBody @Validated UpdatePeopleAttendanceRequestVo vo) { | |
| 144 | 144 | attendanceService.updateSchedulingByUser(vo); |
| 145 | 145 | return Result.OK("顶班成功"); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | @ApiOperation("获取当日休息的用户") |
| 149 | 149 | @GetMapping("/getToday/freeUser") |
| 150 | - public Result<?> getTodayFreeUser(@RequestParam("date") String date){ | |
| 150 | + public Result<?> getTodayFreeUser(@RequestParam("date") String date) { | |
| 151 | 151 | return Result.OK(attendanceService.getTodayFreeUser(date)); |
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | @ApiOperation("生成指定月份的排班") |
| 155 | 155 | @PostMapping("/create/attendance/{month}") |
| 156 | 156 | @Log(title = "生成当月", businessType = BusinessType.INSERT) |
| 157 | - public Result<?> createAttendance(@PathVariable("month") String month){ | |
| 157 | + public Result<?> createAttendance(@PathVariable("month") String month) { | |
| 158 | 158 | attendanceService.createAttendance(month); |
| 159 | 159 | return Result.OK(); |
| 160 | 160 | } |
| ... | ... | @@ -162,10 +162,17 @@ public class AttendanceController extends BaseController { |
| 162 | 162 | @ApiOperation("生成指定月份的指定人员的排班") |
| 163 | 163 | @PostMapping("/again/create/attendance") |
| 164 | 164 | @Log(title = "重新生成", businessType = BusinessType.INSERT) |
| 165 | - public Result<?> againCreateAttendance(@RequestBody @Validated AgainCreateRequestVo vo){ | |
| 165 | + public Result<?> againCreateAttendance(@RequestBody @Validated AgainCreateRequestVo vo) { | |
| 166 | 166 | attendanceService.againCreateAttendance(vo); |
| 167 | 167 | return Result.OK(); |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | + /** | |
| 171 | + * 规则检查 | |
| 172 | + */ | |
| 173 | + @GetMapping("/check/scheduleRule/{ruleId}") | |
| 174 | + public Result<?> checkScheduleRule(@PathVariable("ruleId") String ruleId) { | |
| 175 | + return attendanceService.checkScheduleRule(ruleId); | |
| 176 | + } | |
| 170 | 177 | |
| 171 | 178 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
| ... | ... | @@ -287,12 +287,13 @@ public class SignInServiceImpl implements ISignInService { |
| 287 | 287 | |
| 288 | 288 | @Override |
| 289 | 289 | public List<SignInResponseVo> selectSignInByIds(List<Long> collect) { |
| 290 | - if (CollectionUtil.isEmpty(collect)){ | |
| 290 | + if (CollectionUtil.isEmpty(collect)) { | |
| 291 | 291 | return new ArrayList<>(); |
| 292 | 292 | } |
| 293 | 293 | return signInMapper.selectSignInByIds(collect); |
| 294 | 294 | } |
| 295 | 295 | |
| 296 | + | |
| 296 | 297 | private String handleDate(String dateString) { |
| 297 | 298 | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd"); |
| 298 | 299 | // 解析字符串日期为 LocalDate 对象 |
| ... | ... | @@ -544,8 +545,8 @@ public class SignInServiceImpl implements ISignInService { |
| 544 | 545 | globalIndex.setIndex(lastClosestTimestamp.getIndex()); |
| 545 | 546 | result = false; |
| 546 | 547 | } |
| 547 | - // 上一次无记无|签到,type:签退 当前时间小于最近签到时间 -> 早签 或者 超时 | |
| 548 | - else { | |
| 548 | + // 当前无记|签到,type:签退 当前时间小于最近签到时间 -> 早签 或者 超时 | |
| 549 | + else { | |
| 549 | 550 | signIn.setRemark(SIGN_IN_TIMEOUT + getPrompt(currentScheduling)); |
| 550 | 551 | globalIndex.setIndex(currentScheduling.getIndex()); |
| 551 | 552 | result = false; |
| ... | ... | @@ -578,7 +579,6 @@ public class SignInServiceImpl implements ISignInService { |
| 578 | 579 | globalIndex.setIndex(nextScheduling.getIndex()); |
| 579 | 580 | prompt = getPrompt(nextScheduling); |
| 580 | 581 | signIn.setRemark((nextScheduling.getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT) + prompt); |
| 581 | - | |
| 582 | 582 | } else { |
| 583 | 583 | globalIndex.setIndex(currentScheduling.getIndex()); |
| 584 | 584 | prompt = getPrompt(currentScheduling); |
| ... | ... | @@ -600,8 +600,8 @@ public class SignInServiceImpl implements ISignInService { |
| 600 | 600 | } |
| 601 | 601 | |
| 602 | 602 | private boolean handleTimeOut(String bcType, long nowBetween, GlobalIndex globalIndex, DriverSignInRecommendation currentScheduling) { |
| 603 | - if ((BC_TYPE_OUT.equals(bcType) && nowBetween > 0 ) | |
| 604 | - ||( BC_TYPE_IN.equals(bcType) && nowBetween <= 60L)) { | |
| 603 | + if ((BC_TYPE_OUT.equals(bcType) && nowBetween > 0L) | |
| 604 | + || (BC_TYPE_IN.equals(bcType) && nowBetween > 60L)) { | |
| 605 | 605 | return true; |
| 606 | 606 | } else { |
| 607 | 607 | return false; |
| ... | ... | @@ -612,23 +612,22 @@ public class SignInServiceImpl implements ISignInService { |
| 612 | 612 | if (BC_TYPE_OUT.equals(currentScheduling.getBcType())) { |
| 613 | 613 | return "请在" + ConstDateUtil.formatDate("HH:mm", new Date(currentScheduling.getTimestamps())) + "前一小时内打卡。"; |
| 614 | 614 | } else { |
| 615 | - // 正1小时 负 1小时 | |
| 615 | + // 延后一小时 | |
| 616 | 616 | LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())), "yyyy-MM-dd HH:mm:ss"); |
| 617 | 617 | LocalDateTime addHours = time.plusHours(1); |
| 618 | - LocalDateTime hours = time.plusHours(-1); | |
| 619 | - return "请在" + ConstDateUtil.formatDate("HH:mm", hours) + "到" | |
| 618 | + return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" | |
| 620 | 619 | + ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡"; |
| 621 | 620 | } |
| 622 | 621 | } |
| 623 | 622 | |
| 624 | 623 | |
| 625 | 624 | public static boolean checkTimerSign(long nowBetween, String bcType) { |
| 626 | - // 如果是签到就是正负一小时内有效 | |
| 625 | + // 如果是签到就是提前一小时内有效 | |
| 627 | 626 | if (BC_TYPE_OUT.equals(bcType)) { |
| 628 | 627 | return !(nowBetween <= 0L && nowBetween >= -60L); |
| 629 | 628 | } else { |
| 630 | - // 如果是签退就是就是正负一小时内有效 | |
| 631 | - return !(Math.abs(nowBetween) <= 60); | |
| 629 | + // 如果是签退就是就是延后一小时内有效 | |
| 630 | + return !(nowBetween <= 60 && nowBetween >= 0L); | |
| 632 | 631 | } |
| 633 | 632 | } |
| 634 | 633 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/impl/RuleSchedulingServiceImpl.java
| ... | ... | @@ -109,16 +109,6 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { |
| 109 | 109 | @Override |
| 110 | 110 | public int updateRuleScheduling(RuleScheduling ruleScheduling) { |
| 111 | 111 | handleNewAddScheduling(ruleScheduling); |
| 112 | - // TODO 规则是否绑定 | |
| 113 | - LambdaQueryWrapper<RuleSettingScheduling> qw = new LambdaQueryWrapper<>(); | |
| 114 | - qw.eq(RuleSettingScheduling::getRuleSchedulingId,ruleScheduling.getId()); | |
| 115 | - List<RuleSettingScheduling> list = ruleSettingSchedulingService.list(qw); | |
| 116 | - if (CollectionUtil.isNotEmpty(list)) { | |
| 117 | - String ruleDictName = ruleNumSettingService.listByIds(list.stream() | |
| 118 | - .map(RuleSettingScheduling::getSettingId).collect(Collectors.toList())) | |
| 119 | - .stream().map(RuleNumSetting::getRuleDictName).distinct().collect(Collectors.joining(",")); | |
| 120 | - throw new ServiceException("该规则已经与" + ruleDictName + "等班次绑定,请解绑对应班次后修改!"); | |
| 121 | - } | |
| 122 | 112 | ruleScheduling.setUpdateTime(DateUtils.getNowDate()); |
| 123 | 113 | ruleScheduling.setUpdateBy(SecurityUtils.getUsername()); |
| 124 | 114 | ToolUtils.handleRuleScheduling(ruleScheduling); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/AttendanceService.java
| 1 | 1 | package com.ruoyi.service; |
| 2 | 2 | |
| 3 | 3 | import com.ruoyi.common.core.page.TableDataInfo; |
| 4 | +import com.ruoyi.common.global.Result; | |
| 4 | 5 | import com.ruoyi.domain.RuleAttendanceMain; |
| 5 | 6 | import com.ruoyi.pojo.dto.SchedulingDto; |
| 6 | 7 | import com.ruoyi.pojo.dto.SchedulingSettingDto; |
| ... | ... | @@ -87,4 +88,11 @@ public interface AttendanceService { |
| 87 | 88 | * @param vo |
| 88 | 89 | */ |
| 89 | 90 | void againCreateAttendance(AgainCreateRequestVo vo); |
| 91 | + | |
| 92 | + /** | |
| 93 | + * 检查规则 | |
| 94 | + * @param ruleId | |
| 95 | + * @return | |
| 96 | + */ | |
| 97 | + Result<?> checkScheduleRule(String ruleId); | |
| 90 | 98 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
| ... | ... | @@ -145,7 +145,7 @@ public class SchedulingService { |
| 145 | 145 | long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT(); |
| 146 | 146 | long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime())); |
| 147 | 147 | if (SignInServiceImpl.checkTimerSign(nowBetween, scheduling.getBcType())) { |
| 148 | - if (nowBetween < -60L) { | |
| 148 | + if (nowBetween < -60L || (BC_TYPE_IN.equals(scheduling.getBcType()) && nowBetween < 0L) ) { | |
| 149 | 149 | sb.append(EARLY); |
| 150 | 150 | } else { |
| 151 | 151 | sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType())); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/AttendanceServiceImpl.java
| 1 | 1 | package com.ruoyi.service.impl; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 4 | +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 4 | 5 | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| 5 | 6 | import com.github.pagehelper.PageInfo; |
| 6 | 7 | import com.ruoyi.common.constant.HttpStatus; |
| 7 | 8 | import com.ruoyi.common.core.page.TableDataInfo; |
| 9 | +import com.ruoyi.common.exception.ServiceException; | |
| 10 | +import com.ruoyi.common.global.Result; | |
| 11 | +import com.ruoyi.common.global.ResultCode; | |
| 8 | 12 | import com.ruoyi.common.utils.DateUtils; |
| 9 | 13 | import com.ruoyi.common.utils.PageUtils; |
| 10 | 14 | import com.ruoyi.common.utils.SecurityUtils; |
| ... | ... | @@ -65,6 +69,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 65 | 69 | @Autowired |
| 66 | 70 | private RuleSettingSchedulingService settingSchedulingService; |
| 67 | 71 | |
| 72 | + | |
| 68 | 73 | @Autowired |
| 69 | 74 | private RuleAttendanceMainService attendanceMainService; |
| 70 | 75 | |
| ... | ... | @@ -310,6 +315,21 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 310 | 315 | createAttendanceByStartDate(vo); |
| 311 | 316 | } |
| 312 | 317 | |
| 318 | + @Override | |
| 319 | + public Result<?> checkScheduleRule(String ruleId) { | |
| 320 | + // TODO 规则是否绑定 | |
| 321 | + LambdaQueryWrapper<RuleSettingScheduling> qw = new LambdaQueryWrapper<>(); | |
| 322 | + qw.eq(RuleSettingScheduling::getRuleSchedulingId,ruleId); | |
| 323 | + List<RuleSettingScheduling> list = settingSchedulingService.list(qw); | |
| 324 | + if (CollectionUtil.isNotEmpty(list)) { | |
| 325 | + String ruleDictName = ruleNumSettingService.listByIds(list.stream() | |
| 326 | + .map(RuleSettingScheduling::getSettingId).collect(Collectors.toList())) | |
| 327 | + .stream().map(RuleNumSetting::getRuleDictName).distinct().collect(Collectors.joining(",")); | |
| 328 | + return Result.ERROR(ResultCode.CODE_202,"该规则已经与" + ruleDictName + "等班次绑定!"); | |
| 329 | + } | |
| 330 | + return Result.OK(); | |
| 331 | + } | |
| 332 | + | |
| 313 | 333 | private void createAttendanceByStartDate(AgainCreateRequestVo vo) { |
| 314 | 334 | List<AttendanceDto> peopleList = ruleSchedulingService.getPeopleListByJobCodes(vo.getJobCode()); |
| 315 | 335 | LocalDate parse = LocalDate.parse(vo.getDate()); | ... | ... |