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,6 +21,7 @@ import com.ruoyi.scheduling.service.IRuleSchedulingService; | ||
| 21 | import com.ruoyi.scheduling.service.impl.RuleSchedulingServiceImpl; | 21 | import com.ruoyi.scheduling.service.impl.RuleSchedulingServiceImpl; |
| 22 | import com.ruoyi.service.*; | 22 | import com.ruoyi.service.*; |
| 23 | import com.ruoyi.utils.ConstDateUtil; | 23 | import com.ruoyi.utils.ConstDateUtil; |
| 24 | +import com.ruoyi.utils.ToolUtils; | ||
| 24 | import org.springframework.beans.BeanUtils; | 25 | import org.springframework.beans.BeanUtils; |
| 25 | import org.springframework.beans.factory.annotation.Autowired; | 26 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | import org.springframework.stereotype.Service; | 27 | import org.springframework.stereotype.Service; |
| @@ -180,7 +181,7 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -180,7 +181,7 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 180 | public void updateAttendance(UpdateAttendanceVo vo) { | 181 | public void updateAttendance(UpdateAttendanceVo vo) { |
| 181 | RuleAttendanceMain main = new RuleAttendanceMain(); | 182 | RuleAttendanceMain main = new RuleAttendanceMain(); |
| 182 | RuleScheduling ruleScheduling = ruleSchedulingService.selectRuleSchedulingById(vo.getRuleId().longValue()); | 183 | RuleScheduling ruleScheduling = ruleSchedulingService.selectRuleSchedulingById(vo.getRuleId().longValue()); |
| 183 | - BeanUtils.copyProperties(ruleScheduling, main,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | 184 | + ToolUtils.copyRule(ruleScheduling, main); |
| 184 | List<RuleAttendanceMain> mainList = handleRuleUpdate(vo, main, ruleScheduling); | 185 | List<RuleAttendanceMain> mainList = handleRuleUpdate(vo, main, ruleScheduling); |
| 185 | attendanceMainService.updateByJobCodeTotalQuantity(vo, mainList); | 186 | attendanceMainService.updateByJobCodeTotalQuantity(vo, mainList); |
| 186 | } | 187 | } |
| @@ -323,7 +324,7 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -323,7 +324,7 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 323 | String nowMonth = strDate.substring(0, strDate.lastIndexOf("-")); | 324 | String nowMonth = strDate.substring(0, strDate.lastIndexOf("-")); |
| 324 | int compare = month.compareTo(nowMonth); | 325 | int compare = month.compareTo(nowMonth); |
| 325 | // 删除生成日志 | 326 | // 删除生成日志 |
| 326 | - attendanceMainHelpService.deleteNowMathCreateLog(nowMonth,vo.getJobCode()); | 327 | + attendanceMainHelpService.deleteNowMathCreateLog(nowMonth, vo.getJobCode()); |
| 327 | if (compare > 0) { | 328 | if (compare > 0) { |
| 328 | LocalDate endDay; | 329 | LocalDate endDay; |
| 329 | endDay = getEndDay(vo.getMonth()); | 330 | endDay = getEndDay(vo.getMonth()); |
| @@ -350,7 +351,7 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -350,7 +351,7 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 350 | 351 | ||
| 351 | 352 | ||
| 352 | public List<RuleAttendanceMain> handleAttendanceMain(List<AttendanceDto> peopleList, List<RuleSchedulingDto> ruleList, List<RuleNumDto> ruleNumDtoList, List<LocalDate> dateList) { | 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 | return null; | 355 | return null; |
| 355 | } | 356 | } |
| 356 | Map<Integer, List<AttendanceDto>> peopleMap = transformMapByPeople(peopleList); | 357 | Map<Integer, List<AttendanceDto>> peopleMap = transformMapByPeople(peopleList); |
| @@ -391,7 +392,7 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -391,7 +392,7 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 391 | // 匹配当天应设置的规则 | 392 | // 匹配当天应设置的规则 |
| 392 | RuleSchedulingDto dto = getNowRuleByFixed(nowDate, startDate, ruleSchedulingDtoList); | 393 | RuleSchedulingDto dto = getNowRuleByFixed(nowDate, startDate, ruleSchedulingDtoList); |
| 393 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); | 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 | main.setName(attendanceDto.getName()); | 396 | main.setName(attendanceDto.getName()); |
| 396 | main.setJobCode(attendanceDto.getJobCode()); | 397 | main.setJobCode(attendanceDto.getJobCode()); |
| 397 | // 处理是否分段 | 398 | // 处理是否分段 |
| @@ -447,7 +448,7 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -447,7 +448,7 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 447 | RuleSchedulingDto dto = null; | 448 | RuleSchedulingDto dto = null; |
| 448 | dto = getRuleByWeek(main, ruleSchedulingDtoList, date, attendanceDto.getStartDate()); | 449 | dto = getRuleByWeek(main, ruleSchedulingDtoList, date, attendanceDto.getStartDate()); |
| 449 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); | 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 | main.setName(attendanceDto.getName()); | 452 | main.setName(attendanceDto.getName()); |
| 452 | main.setJobCode(attendanceDto.getJobCode()); | 453 | main.setJobCode(attendanceDto.getJobCode()); |
| 453 | handleSegmentationByDate(date, main, dto); | 454 | handleSegmentationByDate(date, main, dto); |
| @@ -526,13 +527,13 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -526,13 +527,13 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 526 | } | 527 | } |
| 527 | 528 | ||
| 528 | public void backCreatePeopleListLog(List<AttendanceDto> peopleList, Map<Integer, RuleNumDto> ruleNumDtoList, List<LocalDate> dateList) { | 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 | return; | 531 | return; |
| 531 | } | 532 | } |
| 532 | String month = dateList.get(0).getYear() + "-" + dateList.get(0).getMonthValue(); | 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 | List<RuleAttendanceMainHelp> helpList = new ArrayList<>(monthPeople.size()); | 537 | List<RuleAttendanceMainHelp> helpList = new ArrayList<>(monthPeople.size()); |
| 537 | LocalDate localDate = dateList.get(0); | 538 | LocalDate localDate = dateList.get(0); |
| 538 | Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); | 539 | Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| @@ -549,7 +550,7 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -549,7 +550,7 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 549 | private Map<String, Object> transFormMonthPeople(List<RuleAttendanceMainHelp> monthPeople) { | 550 | private Map<String, Object> transFormMonthPeople(List<RuleAttendanceMainHelp> monthPeople) { |
| 550 | Map<String, Object> map = new HashMap<>(monthPeople.size()); | 551 | Map<String, Object> map = new HashMap<>(monthPeople.size()); |
| 551 | for (RuleAttendanceMainHelp help : monthPeople) { | 552 | for (RuleAttendanceMainHelp help : monthPeople) { |
| 552 | - map.put(help.getJobCode(),help); | 553 | + map.put(help.getJobCode(), help); |
| 553 | } | 554 | } |
| 554 | return map; | 555 | return map; |
| 555 | } | 556 | } |
| @@ -580,8 +581,7 @@ public class AttendanceServiceImpl implements AttendanceService { | @@ -580,8 +581,7 @@ public class AttendanceServiceImpl implements AttendanceService { | ||
| 580 | private void handleOtherMain(RuleScheduling ruleScheduling, RuleAttendanceMain otherMain, String date) { | 581 | private void handleOtherMain(RuleScheduling ruleScheduling, RuleAttendanceMain otherMain, String date) { |
| 581 | RuleSchedulingDto dto = new RuleSchedulingDto(); | 582 | RuleSchedulingDto dto = new RuleSchedulingDto(); |
| 582 | BeanUtils.copyProperties(ruleScheduling, dto); | 583 | BeanUtils.copyProperties(ruleScheduling, dto); |
| 583 | - | ||
| 584 | - BeanUtils.copyProperties(dto, otherMain,"secondWorkSignInTime","secondSignInWorkingRange","secondQuittingSignInTime","secondSignInQuittingRange","secondSignDayTomorrow"); | 584 | + ToolUtils.copyRule(dto, otherMain); |
| 585 | RuleNumSettingServiceImpl.handleSegmentationByDate(LocalDate.parse(date), otherMain, dto); | 585 | RuleNumSettingServiceImpl.handleSegmentationByDate(LocalDate.parse(date), otherMain, dto); |
| 586 | otherMain.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); | 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,6 +21,7 @@ import com.ruoyi.service.RuleAttendanceMainHelpService; | ||
| 21 | import com.ruoyi.service.RuleAttendanceMainService; | 21 | import com.ruoyi.service.RuleAttendanceMainService; |
| 22 | import com.ruoyi.service.RuleNumSettingService; | 22 | import com.ruoyi.service.RuleNumSettingService; |
| 23 | import com.ruoyi.utils.ConstDateUtil; | 23 | import com.ruoyi.utils.ConstDateUtil; |
| 24 | +import com.ruoyi.utils.ToolUtils; | ||
| 24 | import org.slf4j.Logger; | 25 | import org.slf4j.Logger; |
| 25 | import org.slf4j.LoggerFactory; | 26 | import org.slf4j.LoggerFactory; |
| 26 | import org.springframework.beans.BeanUtils; | 27 | import org.springframework.beans.BeanUtils; |
| @@ -152,7 +153,7 @@ public class RuleNumSettingServiceImpl extends ServiceImpl<RuleNumSettingMapper, | @@ -152,7 +153,7 @@ public class RuleNumSettingServiceImpl extends ServiceImpl<RuleNumSettingMapper, | ||
| 152 | RuleSchedulingDto dto = null; | 153 | RuleSchedulingDto dto = null; |
| 153 | dto = getRuleByWeek(main, ruleSchedulingDtoList, date, attendanceDto.getStartDate()); | 154 | dto = getRuleByWeek(main, ruleSchedulingDtoList, date, attendanceDto.getStartDate()); |
| 154 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); | 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 | main.setName(attendanceDto.getName()); | 157 | main.setName(attendanceDto.getName()); |
| 157 | main.setJobCode(attendanceDto.getJobCode()); | 158 | main.setJobCode(attendanceDto.getJobCode()); |
| 158 | handleSegmentationByDate(date, main, dto); | 159 | handleSegmentationByDate(date, main, dto); |
| @@ -224,7 +225,7 @@ public class RuleNumSettingServiceImpl extends ServiceImpl<RuleNumSettingMapper, | @@ -224,7 +225,7 @@ public class RuleNumSettingServiceImpl extends ServiceImpl<RuleNumSettingMapper, | ||
| 224 | // 匹配当天应设置的规则 | 225 | // 匹配当天应设置的规则 |
| 225 | RuleSchedulingDto dto = getNowRuleByFixed(nowDate, startDate, ruleSchedulingDtoList); | 226 | RuleSchedulingDto dto = getNowRuleByFixed(nowDate, startDate, ruleSchedulingDtoList); |
| 226 | main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG); | 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 | main.setName(attendanceDto.getName()); | 229 | main.setName(attendanceDto.getName()); |
| 229 | main.setJobCode(attendanceDto.getJobCode()); | 230 | main.setJobCode(attendanceDto.getJobCode()); |
| 230 | // 处理是否分段 | 231 | // 处理是否分段 |
Bsth-admin/src/main/java/com/ruoyi/utils/ToolUtils.java
| 1 | package com.ruoyi.utils; | 1 | package com.ruoyi.utils; |
| 2 | 2 | ||
| 3 | import com.ruoyi.common.utils.uuid.UUID; | 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 | public class ToolUtils { | 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 | } |