Commit 1e978a3ff1edbe48b6879f424ad9dd78a97e8ad7
1 parent
127936a8
fix: 抽离公共方法
Showing
3 changed files
with
39 additions
and
16 deletions
Bsth-admin/src/main/java/com/ruoyi/service/impl/AttendanceServiceImpl.java
| ... | ... | @@ -21,6 +21,7 @@ import com.ruoyi.scheduling.service.IRuleSchedulingService; |
| 21 | 21 | import com.ruoyi.scheduling.service.impl.RuleSchedulingServiceImpl; |
| 22 | 22 | import com.ruoyi.service.*; |
| 23 | 23 | import com.ruoyi.utils.ConstDateUtil; |
| 24 | +import com.ruoyi.utils.ToolUtils; | |
| 24 | 25 | import org.springframework.beans.BeanUtils; |
| 25 | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | 27 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -180,7 +181,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 180 | 181 | public void updateAttendance(UpdateAttendanceVo vo) { |
| 181 | 182 | RuleAttendanceMain main = new RuleAttendanceMain(); |
| 182 | 183 | RuleScheduling ruleScheduling = ruleSchedulingService.selectRuleSchedulingById(vo.getRuleId().longValue()); |
| 183 | - BeanUtils.copyProperties(ruleScheduling, main,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | |
| 184 | + ToolUtils.copyRule(ruleScheduling, main); | |
| 184 | 185 | List<RuleAttendanceMain> mainList = handleRuleUpdate(vo, main, ruleScheduling); |
| 185 | 186 | attendanceMainService.updateByJobCodeTotalQuantity(vo, mainList); |
| 186 | 187 | } |
| ... | ... | @@ -323,7 +324,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 323 | 324 | String nowMonth = strDate.substring(0, strDate.lastIndexOf("-")); |
| 324 | 325 | int compare = month.compareTo(nowMonth); |
| 325 | 326 | // 删除生成日志 |
| 326 | - attendanceMainHelpService.deleteNowMathCreateLog(nowMonth,vo.getJobCode()); | |
| 327 | + attendanceMainHelpService.deleteNowMathCreateLog(nowMonth, vo.getJobCode()); | |
| 327 | 328 | if (compare > 0) { |
| 328 | 329 | LocalDate endDay; |
| 329 | 330 | endDay = getEndDay(vo.getMonth()); |
| ... | ... | @@ -350,7 +351,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 350 | 351 | |
| 351 | 352 | |
| 352 | 353 | public List<RuleAttendanceMain> handleAttendanceMain(List<AttendanceDto> peopleList, List<RuleSchedulingDto> ruleList, List<RuleNumDto> ruleNumDtoList, List<LocalDate> dateList) { |
| 353 | - if (CollectionUtil.isEmpty(peopleList) || CollectionUtil.isEmpty(ruleList) || CollectionUtil.isEmpty(ruleNumDtoList) ) { | |
| 354 | + if (CollectionUtil.isEmpty(peopleList) || CollectionUtil.isEmpty(ruleList) || CollectionUtil.isEmpty(ruleNumDtoList)) { | |
| 354 | 355 | return null; |
| 355 | 356 | } |
| 356 | 357 | Map<Integer, List<AttendanceDto>> peopleMap = transformMapByPeople(peopleList); |
| ... | ... | @@ -391,7 +392,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 391 | 392 | // 匹配当天应设置的规则 |
| 392 | 393 | RuleSchedulingDto dto = getNowRuleByFixed(nowDate, startDate, ruleSchedulingDtoList); |
| 393 | 394 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); |
| 394 | - BeanUtils.copyProperties(dto, main,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | |
| 395 | + ToolUtils.copyRule(dto, main); | |
| 395 | 396 | main.setName(attendanceDto.getName()); |
| 396 | 397 | main.setJobCode(attendanceDto.getJobCode()); |
| 397 | 398 | // 处理是否分段 |
| ... | ... | @@ -447,7 +448,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 447 | 448 | RuleSchedulingDto dto = null; |
| 448 | 449 | dto = getRuleByWeek(main, ruleSchedulingDtoList, date, attendanceDto.getStartDate()); |
| 449 | 450 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); |
| 450 | - BeanUtils.copyProperties(dto, main,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | |
| 451 | + ToolUtils.copyRule(dto, main); | |
| 451 | 452 | main.setName(attendanceDto.getName()); |
| 452 | 453 | main.setJobCode(attendanceDto.getJobCode()); |
| 453 | 454 | handleSegmentationByDate(date, main, dto); |
| ... | ... | @@ -526,13 +527,13 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 526 | 527 | } |
| 527 | 528 | |
| 528 | 529 | public void backCreatePeopleListLog(List<AttendanceDto> peopleList, Map<Integer, RuleNumDto> ruleNumDtoList, List<LocalDate> dateList) { |
| 529 | - if (CollectionUtil.isEmpty(dateList)){ | |
| 530 | + if (CollectionUtil.isEmpty(dateList)) { | |
| 530 | 531 | return; |
| 531 | 532 | } |
| 532 | 533 | String month = dateList.get(0).getYear() + "-" + dateList.get(0).getMonthValue(); |
| 533 | - List<RuleAttendanceMainHelp> monthPeople = helpService.queryNowMonthPeopleByJobCodes(peopleList,month); | |
| 534 | - Map<String,Object> map = transFormMonthPeople(monthPeople); | |
| 535 | - peopleList = peopleList.stream().filter(item->Objects.isNull(map.get(item.getJobCode()))).collect(Collectors.toList()); | |
| 534 | + List<RuleAttendanceMainHelp> monthPeople = helpService.queryNowMonthPeopleByJobCodes(peopleList, month); | |
| 535 | + Map<String, Object> map = transFormMonthPeople(monthPeople); | |
| 536 | + peopleList = peopleList.stream().filter(item -> Objects.isNull(map.get(item.getJobCode()))).collect(Collectors.toList()); | |
| 536 | 537 | List<RuleAttendanceMainHelp> helpList = new ArrayList<>(monthPeople.size()); |
| 537 | 538 | LocalDate localDate = dateList.get(0); |
| 538 | 539 | Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| ... | ... | @@ -549,7 +550,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 549 | 550 | private Map<String, Object> transFormMonthPeople(List<RuleAttendanceMainHelp> monthPeople) { |
| 550 | 551 | Map<String, Object> map = new HashMap<>(monthPeople.size()); |
| 551 | 552 | for (RuleAttendanceMainHelp help : monthPeople) { |
| 552 | - map.put(help.getJobCode(),help); | |
| 553 | + map.put(help.getJobCode(), help); | |
| 553 | 554 | } |
| 554 | 555 | return map; |
| 555 | 556 | } |
| ... | ... | @@ -580,8 +581,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 580 | 581 | private void handleOtherMain(RuleScheduling ruleScheduling, RuleAttendanceMain otherMain, String date) { |
| 581 | 582 | RuleSchedulingDto dto = new RuleSchedulingDto(); |
| 582 | 583 | BeanUtils.copyProperties(ruleScheduling, dto); |
| 583 | - | |
| 584 | - BeanUtils.copyProperties(dto, otherMain,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | |
| 584 | + ToolUtils.copyRule(dto, otherMain); | |
| 585 | 585 | RuleNumSettingServiceImpl.handleSegmentationByDate(LocalDate.parse(date), otherMain, dto); |
| 586 | 586 | otherMain.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); |
| 587 | 587 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/RuleNumSettingServiceImpl.java
| ... | ... | @@ -21,6 +21,7 @@ import com.ruoyi.service.RuleAttendanceMainHelpService; |
| 21 | 21 | import com.ruoyi.service.RuleAttendanceMainService; |
| 22 | 22 | import com.ruoyi.service.RuleNumSettingService; |
| 23 | 23 | import com.ruoyi.utils.ConstDateUtil; |
| 24 | +import com.ruoyi.utils.ToolUtils; | |
| 24 | 25 | import org.slf4j.Logger; |
| 25 | 26 | import org.slf4j.LoggerFactory; |
| 26 | 27 | import org.springframework.beans.BeanUtils; |
| ... | ... | @@ -152,7 +153,7 @@ public class RuleNumSettingServiceImpl extends ServiceImpl<RuleNumSettingMapper, |
| 152 | 153 | RuleSchedulingDto dto = null; |
| 153 | 154 | dto = getRuleByWeek(main, ruleSchedulingDtoList, date, attendanceDto.getStartDate()); |
| 154 | 155 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); |
| 155 | - BeanUtils.copyProperties(dto, main,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | |
| 156 | + ToolUtils.copyRule(dto, main); | |
| 156 | 157 | main.setName(attendanceDto.getName()); |
| 157 | 158 | main.setJobCode(attendanceDto.getJobCode()); |
| 158 | 159 | handleSegmentationByDate(date, main, dto); |
| ... | ... | @@ -224,7 +225,7 @@ public class RuleNumSettingServiceImpl extends ServiceImpl<RuleNumSettingMapper, |
| 224 | 225 | // 匹配当天应设置的规则 |
| 225 | 226 | RuleSchedulingDto dto = getNowRuleByFixed(nowDate, startDate, ruleSchedulingDtoList); |
| 226 | 227 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); |
| 227 | - BeanUtils.copyProperties(dto, main,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | |
| 228 | + ToolUtils.copyRule(dto, main); | |
| 228 | 229 | main.setName(attendanceDto.getName()); |
| 229 | 230 | main.setJobCode(attendanceDto.getJobCode()); |
| 230 | 231 | // 处理是否分段 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/utils/ToolUtils.java
| 1 | 1 | package com.ruoyi.utils; |
| 2 | 2 | |
| 3 | 3 | import com.ruoyi.common.utils.uuid.UUID; |
| 4 | +import com.ruoyi.domain.RuleAttendanceMain; | |
| 5 | +import com.ruoyi.pojo.dto.RuleSchedulingDto; | |
| 6 | +import com.ruoyi.scheduling.domain.RuleScheduling; | |
| 7 | +import org.springframework.beans.BeanUtils; | |
| 8 | + | |
| 9 | +import static com.ruoyi.common.RuleSchedulingProperties.TOMORROW_NO; | |
| 4 | 10 | |
| 5 | 11 | public class ToolUtils { |
| 6 | 12 | |
| 7 | - public static String getUUID(){ | |
| 8 | - return UUID.randomUUID().toString().replaceAll("-",""); | |
| 13 | + public static String getUUID() { | |
| 14 | + return UUID.randomUUID().toString().replaceAll("-", ""); | |
| 15 | + } | |
| 16 | + | |
| 17 | + public static void copyRule(RuleScheduling dto, RuleAttendanceMain main) { | |
| 18 | + if (dto.getSecondFlag().equals(TOMORROW_NO)) { | |
| 19 | + BeanUtils.copyProperties(dto, main, "secondWorkSignInTime", "secondSignInWorkingRange", "secondQuittingSignInTime", "secondSignInQuittingRange", "secondSignDayTomorrow"); | |
| 20 | + } else { | |
| 21 | + BeanUtils.copyProperties(dto, main); | |
| 22 | + } | |
| 23 | + } | |
| 24 | + | |
| 25 | + public static void copyRule(RuleSchedulingDto dto, RuleAttendanceMain main) { | |
| 26 | + if (dto.getSecondFlag().equals(TOMORROW_NO)) { | |
| 27 | + BeanUtils.copyProperties(dto, main, "secondWorkSignInTime", "secondSignInWorkingRange", "secondQuittingSignInTime", "secondSignInQuittingRange", "secondSignDayTomorrow"); | |
| 28 | + } else { | |
| 29 | + BeanUtils.copyProperties(dto, main); | |
| 30 | + } | |
| 9 | 31 | } |
| 10 | 32 | } | ... | ... |