Commit 1e56cac37db31981e8290e05030eca91a2861850
1 parent
69520f13
feat: 重新生成排班
Showing
15 changed files
with
252 additions
and
35 deletions
Bsth-admin/src/main/java/com/ruoyi/controller/AttendanceController.java
| ... | ... | @@ -8,6 +8,7 @@ import com.ruoyi.common.global.Result; |
| 8 | 8 | import com.ruoyi.domain.RuleAttendanceMain; |
| 9 | 9 | import com.ruoyi.pojo.dto.SchedulingDto; |
| 10 | 10 | import com.ruoyi.pojo.dto.SchedulingSettingDto; |
| 11 | +import com.ruoyi.pojo.request.AgainCreateRequestVo; | |
| 11 | 12 | import com.ruoyi.pojo.vo.*; |
| 12 | 13 | import com.ruoyi.service.AttendanceService; |
| 13 | 14 | import io.swagger.annotations.Api; |
| ... | ... | @@ -157,5 +158,12 @@ public class AttendanceController extends BaseController { |
| 157 | 158 | return Result.OK(); |
| 158 | 159 | } |
| 159 | 160 | |
| 161 | + @ApiOperation("生成指定月份的指定人员的排班") | |
| 162 | + @PostMapping("/again/create/attendance") | |
| 163 | + public Result<?> againCreateAttendance(@RequestBody @Validated AgainCreateRequestVo vo){ | |
| 164 | + attendanceService.againCreateAttendance(vo); | |
| 165 | + return Result.OK(); | |
| 166 | + } | |
| 167 | + | |
| 160 | 168 | |
| 161 | 169 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/mapper/RuleAttendanceMainHelpMapper.java
| ... | ... | @@ -3,6 +3,7 @@ package com.ruoyi.mapper; |
| 3 | 3 | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| 4 | 4 | import com.ruoyi.domain.RuleAttendanceMainHelp; |
| 5 | 5 | import com.ruoyi.pojo.vo.PeopleRequestVo; |
| 6 | +import org.apache.ibatis.annotations.Param; | |
| 6 | 7 | |
| 7 | 8 | import java.util.List; |
| 8 | 9 | |
| ... | ... | @@ -20,6 +21,12 @@ public interface RuleAttendanceMainHelpMapper extends BaseMapper<RuleAttendanceM |
| 20 | 21 | * @return |
| 21 | 22 | */ |
| 22 | 23 | List<RuleAttendanceMainHelp> queryNowMonthPeople(PeopleRequestVo vo); |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 插入日志 | |
| 27 | + * @param helpList | |
| 28 | + */ | |
| 29 | + void insertHelpList(@Param("list") List<RuleAttendanceMainHelp> helpList); | |
| 23 | 30 | } |
| 24 | 31 | |
| 25 | 32 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/pojo/request/AgainCreateRequestVo.java
0 → 100644
| 1 | +package com.ruoyi.pojo.request; | |
| 2 | + | |
| 3 | +import io.swagger.annotations.ApiModel; | |
| 4 | +import io.swagger.annotations.ApiModelProperty; | |
| 5 | +import lombok.Data; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotBlank; | |
| 8 | +import javax.validation.constraints.NotEmpty; | |
| 9 | +import javax.validation.constraints.Null; | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * @author 20412 | |
| 14 | + */ | |
| 15 | +@ApiModel("重新生成对象") | |
| 16 | +@Data | |
| 17 | +public class AgainCreateRequestVo { | |
| 18 | + /** | |
| 19 | + * 工号集合 | |
| 20 | + */ | |
| 21 | + @ApiModelProperty("工号集合") | |
| 22 | + @NotEmpty(message = "请选择要更新的人员") | |
| 23 | + private List<String> jobCode; | |
| 24 | + | |
| 25 | + @NotBlank(message = "请选择正确的月份") | |
| 26 | + @ApiModelProperty("月份") | |
| 27 | + private String month; | |
| 28 | + | |
| 29 | + @Null | |
| 30 | + @ApiModelProperty(hidden = true) | |
| 31 | + private String date; | |
| 32 | +} | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/scheduling/mapper/RuleSchedulingMapper.java
| ... | ... | @@ -2,21 +2,21 @@ package com.ruoyi.scheduling.mapper; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | 4 | |
| 5 | +import com.ruoyi.pojo.dto.AttendanceDto; | |
| 5 | 6 | import com.ruoyi.pojo.dto.RuleSchedulingDto; |
| 6 | 7 | import com.ruoyi.scheduling.domain.RuleScheduling; |
| 7 | 8 | import org.apache.ibatis.annotations.Param; |
| 8 | 9 | |
| 9 | 10 | /** |
| 10 | 11 | * 排版规则Mapper接口 |
| 11 | - * | |
| 12 | + * | |
| 12 | 13 | * @author guzijian |
| 13 | 14 | * @date 2023-08-04 |
| 14 | 15 | */ |
| 15 | -public interface RuleSchedulingMapper | |
| 16 | -{ | |
| 16 | +public interface RuleSchedulingMapper { | |
| 17 | 17 | /** |
| 18 | 18 | * 查询排版规则 |
| 19 | - * | |
| 19 | + * | |
| 20 | 20 | * @param id 排版规则主键 |
| 21 | 21 | * @return 排版规则 |
| 22 | 22 | */ |
| ... | ... | @@ -24,7 +24,7 @@ public interface RuleSchedulingMapper |
| 24 | 24 | |
| 25 | 25 | /** |
| 26 | 26 | * 查询排版规则列表 |
| 27 | - * | |
| 27 | + * | |
| 28 | 28 | * @param ruleScheduling 排版规则 |
| 29 | 29 | * @return 排版规则集合 |
| 30 | 30 | */ |
| ... | ... | @@ -32,7 +32,7 @@ public interface RuleSchedulingMapper |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * 新增排版规则 |
| 35 | - * | |
| 35 | + * | |
| 36 | 36 | * @param ruleScheduling 排版规则 |
| 37 | 37 | * @return 结果 |
| 38 | 38 | */ |
| ... | ... | @@ -40,7 +40,7 @@ public interface RuleSchedulingMapper |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | 42 | * 修改排版规则 |
| 43 | - * | |
| 43 | + * | |
| 44 | 44 | * @param ruleScheduling 排版规则 |
| 45 | 45 | * @return 结果 |
| 46 | 46 | */ |
| ... | ... | @@ -48,7 +48,7 @@ public interface RuleSchedulingMapper |
| 48 | 48 | |
| 49 | 49 | /** |
| 50 | 50 | * 删除排版规则 |
| 51 | - * | |
| 51 | + * | |
| 52 | 52 | * @param id 排版规则主键 |
| 53 | 53 | * @return 结果 |
| 54 | 54 | */ |
| ... | ... | @@ -56,7 +56,7 @@ public interface RuleSchedulingMapper |
| 56 | 56 | |
| 57 | 57 | /** |
| 58 | 58 | * 批量删除排版规则 |
| 59 | - * | |
| 59 | + * | |
| 60 | 60 | * @param ids 需要删除的数据主键集合 |
| 61 | 61 | * @return 结果 |
| 62 | 62 | */ |
| ... | ... | @@ -64,10 +64,15 @@ public interface RuleSchedulingMapper |
| 64 | 64 | |
| 65 | 65 | /** |
| 66 | 66 | * 根据设置表id返回排班规则 |
| 67 | + * | |
| 67 | 68 | * @param settingId |
| 68 | 69 | * @return |
| 69 | 70 | */ |
| 70 | 71 | List<RuleScheduling> selectRuleSchedulingListVoBySettingId(@Param("settingId") Integer settingId); |
| 71 | 72 | |
| 72 | 73 | List<RuleSchedulingDto> selectRuleSchedulingListVoBySettingIds(List<Integer> list); |
| 74 | + | |
| 75 | + void deletePeopleSchedule(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("list") List<String> list); | |
| 76 | + | |
| 77 | + List<AttendanceDto> getPeopleListByJobCodes(@Param("list") List<String> jobCode); | |
| 73 | 78 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/IRuleSchedulingService.java
| ... | ... | @@ -2,6 +2,7 @@ package com.ruoyi.scheduling.service; |
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | 4 | |
| 5 | +import com.ruoyi.pojo.dto.AttendanceDto; | |
| 5 | 6 | import com.ruoyi.pojo.dto.RuleSchedulingDto; |
| 6 | 7 | import com.ruoyi.pojo.vo.RuleSchedulingResponseVo; |
| 7 | 8 | import com.ruoyi.pojo.vo.RuleSchedulingVo; |
| ... | ... | @@ -9,15 +10,14 @@ import com.ruoyi.scheduling.domain.RuleScheduling; |
| 9 | 10 | |
| 10 | 11 | /** |
| 11 | 12 | * 排版规则Service接口 |
| 12 | - * | |
| 13 | + * | |
| 13 | 14 | * @author guzijian |
| 14 | 15 | * @date 2023-08-04 |
| 15 | 16 | */ |
| 16 | -public interface IRuleSchedulingService | |
| 17 | -{ | |
| 17 | +public interface IRuleSchedulingService { | |
| 18 | 18 | /** |
| 19 | 19 | * 查询排版规则 |
| 20 | - * | |
| 20 | + * | |
| 21 | 21 | * @param id 排版规则主键 |
| 22 | 22 | * @return 排版规则 |
| 23 | 23 | */ |
| ... | ... | @@ -25,7 +25,7 @@ public interface IRuleSchedulingService |
| 25 | 25 | |
| 26 | 26 | /** |
| 27 | 27 | * 查询排版规则列表 |
| 28 | - * | |
| 28 | + * | |
| 29 | 29 | * @param ruleScheduling 排版规则 |
| 30 | 30 | * @return 排版规则集合 |
| 31 | 31 | */ |
| ... | ... | @@ -33,7 +33,7 @@ public interface IRuleSchedulingService |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | 35 | * 新增排版规则 |
| 36 | - * | |
| 36 | + * | |
| 37 | 37 | * @param ruleScheduling 排版规则 |
| 38 | 38 | * @return 结果 |
| 39 | 39 | */ |
| ... | ... | @@ -41,7 +41,7 @@ public interface IRuleSchedulingService |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | 43 | * 修改排版规则 |
| 44 | - * | |
| 44 | + * | |
| 45 | 45 | * @param ruleScheduling 排版规则 |
| 46 | 46 | * @return 结果 |
| 47 | 47 | */ |
| ... | ... | @@ -49,7 +49,7 @@ public interface IRuleSchedulingService |
| 49 | 49 | |
| 50 | 50 | /** |
| 51 | 51 | * 批量删除排版规则 |
| 52 | - * | |
| 52 | + * | |
| 53 | 53 | * @param ids 需要删除的排版规则主键集合 |
| 54 | 54 | * @return 结果 |
| 55 | 55 | */ |
| ... | ... | @@ -57,7 +57,7 @@ public interface IRuleSchedulingService |
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * 删除排版规则信息 |
| 60 | - * | |
| 60 | + * | |
| 61 | 61 | * @param id 排版规则主键 |
| 62 | 62 | * @return 结果 |
| 63 | 63 | */ |
| ... | ... | @@ -70,4 +70,9 @@ public interface IRuleSchedulingService |
| 70 | 70 | List<RuleSchedulingVo> selectRuleSchedulingListVoBySettingId(Integer settingId); |
| 71 | 71 | |
| 72 | 72 | List<RuleSchedulingDto> selectRuleSchedulingListVoBySettingIds(List<Integer> settingList); |
| 73 | + | |
| 74 | + | |
| 75 | + void deletePeopleSchedule(String startDate, String endDate, List<String> jobCode); | |
| 76 | + | |
| 77 | + List<AttendanceDto> getPeopleListByJobCodes(List<String> jobCode); | |
| 73 | 78 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/impl/RuleSchedulingServiceImpl.java
| ... | ... | @@ -9,6 +9,7 @@ import java.util.stream.Collectors; |
| 9 | 9 | import cn.hutool.core.collection.CollectionUtil; |
| 10 | 10 | import com.ruoyi.common.utils.DateUtils; |
| 11 | 11 | import com.ruoyi.common.utils.SecurityUtils; |
| 12 | +import com.ruoyi.pojo.dto.AttendanceDto; | |
| 12 | 13 | import com.ruoyi.pojo.dto.RuleSchedulingDto; |
| 13 | 14 | import com.ruoyi.pojo.vo.RuleSchedulingResponseVo; |
| 14 | 15 | import com.ruoyi.pojo.vo.RuleSchedulingVo; |
| ... | ... | @@ -75,7 +76,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { |
| 75 | 76 | |
| 76 | 77 | private void handleNewAddScheduling(RuleScheduling ruleScheduling) { |
| 77 | 78 | // 如果没有分班则重置第一段后的规则 |
| 78 | - if (NO_SEGMENTATION.equals(ruleScheduling.getSecondFlag())){ | |
| 79 | + if (NO_SEGMENTATION.equals(ruleScheduling.getSecondFlag())) { | |
| 79 | 80 | ruleScheduling.setSecondSignDayTomorrow(null); |
| 80 | 81 | ruleScheduling.setSecondSignInWorkingRange(null); |
| 81 | 82 | ruleScheduling.setSecondWorkSignInTime(null); |
| ... | ... | @@ -146,12 +147,22 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { |
| 146 | 147 | |
| 147 | 148 | @Override |
| 148 | 149 | public List<RuleSchedulingDto> selectRuleSchedulingListVoBySettingIds(List<Integer> settingList) { |
| 149 | - if (CollectionUtil.isEmpty(settingList)){ | |
| 150 | + if (CollectionUtil.isEmpty(settingList)) { | |
| 150 | 151 | return new ArrayList<>(); |
| 151 | 152 | } |
| 152 | 153 | return ruleSchedulingMapper.selectRuleSchedulingListVoBySettingIds(settingList); |
| 153 | 154 | } |
| 154 | 155 | |
| 156 | + @Override | |
| 157 | + public void deletePeopleSchedule(String startDate, String endDate, List<String> jobCode) { | |
| 158 | + ruleSchedulingMapper.deletePeopleSchedule(startDate, endDate, jobCode); | |
| 159 | + } | |
| 160 | + | |
| 161 | + @Override | |
| 162 | + public List<AttendanceDto> getPeopleListByJobCodes(List<String> jobCode) { | |
| 163 | + return ruleSchedulingMapper.getPeopleListByJobCodes(jobCode); | |
| 164 | + } | |
| 165 | + | |
| 155 | 166 | public static List<RuleSchedulingVo> handleRuleScheduling(List<RuleScheduling> list) { |
| 156 | 167 | if (CollectionUtil.isEmpty(list)) { |
| 157 | 168 | return null; |
| ... | ... | @@ -164,7 +175,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { |
| 164 | 175 | RuleSchedulingVo vo = new RuleSchedulingVo(); |
| 165 | 176 | vo.setRuleName(item.getRuleName()); |
| 166 | 177 | vo.setId(item.getId()); |
| 167 | - if (item.getRuleName().equals(FREE.getDescription())){ | |
| 178 | + if (item.getRuleName().equals(FREE.getDescription())) { | |
| 168 | 179 | return vo; |
| 169 | 180 | } |
| 170 | 181 | vo.setRangeTime(handleRuleSchedulingRangeTime(item)); | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/AttendanceService.java
| ... | ... | @@ -4,6 +4,7 @@ import com.ruoyi.common.core.page.TableDataInfo; |
| 4 | 4 | import com.ruoyi.domain.RuleAttendanceMain; |
| 5 | 5 | import com.ruoyi.pojo.dto.SchedulingDto; |
| 6 | 6 | import com.ruoyi.pojo.dto.SchedulingSettingDto; |
| 7 | +import com.ruoyi.pojo.request.AgainCreateRequestVo; | |
| 7 | 8 | import com.ruoyi.pojo.vo.*; |
| 8 | 9 | |
| 9 | 10 | import java.util.List; |
| ... | ... | @@ -80,4 +81,10 @@ public interface AttendanceService { |
| 80 | 81 | * @param month |
| 81 | 82 | */ |
| 82 | 83 | void createAttendance(String month); |
| 84 | + | |
| 85 | + /** | |
| 86 | + * 重新生成指定月份的排班 | |
| 87 | + * @param vo | |
| 88 | + */ | |
| 89 | + void againCreateAttendance(AgainCreateRequestVo vo); | |
| 83 | 90 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/RuleAttendanceMainHelpService.java
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
| ... | ... | @@ -460,8 +460,8 @@ public class ThreadJobService { |
| 460 | 460 | } |
| 461 | 461 | } |
| 462 | 462 | // 测试用例 |
| 463 | - bcList.add(getDriverSchedulingTest("2023-09-26 03:20:00","2023-09-26 09:30:00","out")); | |
| 464 | - bcList.add(getDriverSchedulingTest("2023-09-26 03:20:00","2023-09-26 09:30:00","in")); | |
| 463 | +// bcList.add(getDriverSchedulingTest("2023-09-26 03:20:00","2023-09-26 09:30:00","out")); | |
| 464 | +// bcList.add(getDriverSchedulingTest("2023-09-26 03:20:00","2023-09-26 09:30:00","in")); | |
| 465 | 465 | return bcList; |
| 466 | 466 | } |
| 467 | 467 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/AttendanceServiceImpl.java
| ... | ... | @@ -14,6 +14,7 @@ import com.ruoyi.driver.mapper.DriverMapper; |
| 14 | 14 | import com.ruoyi.num.domain.RuleNum; |
| 15 | 15 | import com.ruoyi.num.service.IRuleNumService; |
| 16 | 16 | import com.ruoyi.pojo.dto.*; |
| 17 | +import com.ruoyi.pojo.request.AgainCreateRequestVo; | |
| 17 | 18 | import com.ruoyi.pojo.vo.*; |
| 18 | 19 | import com.ruoyi.scheduling.domain.RuleScheduling; |
| 19 | 20 | import com.ruoyi.scheduling.service.IRuleSchedulingService; |
| ... | ... | @@ -46,7 +47,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 46 | 47 | /** |
| 47 | 48 | * 中文星期声明 |
| 48 | 49 | */ |
| 49 | - private static String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"}; | |
| 50 | + private static final String[] weekDays = {"周日", "周一", "周二", "周三", "周四", "周五", "周六"}; | |
| 50 | 51 | |
| 51 | 52 | @Autowired |
| 52 | 53 | private DriverMapper driverMapper; |
| ... | ... | @@ -276,25 +277,75 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 276 | 277 | return; |
| 277 | 278 | } |
| 278 | 279 | // 不能生成以前的排班 |
| 279 | - if (ConstDateUtil.formatDate("yyyy-MM").compareTo(month) > 0){ | |
| 280 | + if (ConstDateUtil.formatDate("yyyy-MM").compareTo(month) > 0) { | |
| 280 | 281 | throw new RuntimeException("只能生成未来的排班"); |
| 281 | 282 | } |
| 282 | 283 | String[] split = month.split("-"); |
| 284 | + // 处理规则 | |
| 285 | + List<LocalDate> dateList = ConstDateUtil.getDateSetFromTheCurrentDayToTheEndOfTheMonth(Integer.parseInt(split[0]), Integer.parseInt(split[1])); | |
| 283 | 286 | List<AttendanceDto> peopleList = ruleNumSettingService.getPeopleListByMonth(month); |
| 287 | + createScheduleMethod(dateList, peopleList); | |
| 288 | + } | |
| 289 | + | |
| 290 | + public void createScheduleMethod(List<LocalDate> dateList, List<AttendanceDto> peopleList) { | |
| 284 | 291 | List<Integer> settingList = peopleList.stream().map(AttendanceDto::getSettingId).distinct().collect(Collectors.toList()); |
| 285 | 292 | // 获取规则集合 |
| 286 | 293 | List<RuleSchedulingDto> ruleList = schedulingService.selectRuleSchedulingListVoBySettingIds(settingList); |
| 287 | 294 | // 获取班次 |
| 288 | 295 | List<RuleNumDto> ruleNumDtoList = ruleNumSettingService.selectRuleNumBySettingId(settingList); |
| 289 | - // 处理规则 | |
| 290 | - List<LocalDate> dateList = ConstDateUtil.getDateSetFromTheCurrentDayToTheEndOfTheMonth(Integer.parseInt(split[0]), Integer.parseInt(split[1])); | |
| 291 | - List<RuleAttendanceMain> attendanceMains = handleAttendanceMain(peopleList, ruleList, ruleNumDtoList, dateList, month); | |
| 296 | + List<RuleAttendanceMain> attendanceMains = handleAttendanceMain(peopleList, ruleList, ruleNumDtoList, dateList); | |
| 292 | 297 | attendanceMainService.saveBatch(attendanceMains); |
| 293 | 298 | } |
| 294 | 299 | |
| 300 | + @Override | |
| 301 | + @Transactional(rollbackFor = Exception.class) | |
| 302 | + public void againCreateAttendance(AgainCreateRequestVo vo) { | |
| 303 | + // 删除排班 | |
| 304 | + deleteScheduleByRule(vo); | |
| 305 | + //生成排班 | |
| 306 | + createAttendanceByStartDate(vo); | |
| 307 | + } | |
| 308 | + | |
| 309 | + private void createAttendanceByStartDate(AgainCreateRequestVo vo) { | |
| 310 | + List<AttendanceDto> peopleList = ruleSchedulingService.getPeopleListByJobCodes(vo.getJobCode()); | |
| 311 | + LocalDate parse = LocalDate.parse(vo.getDate()); | |
| 312 | + int day = Integer.parseInt(vo.getDate().split("-")[2]); | |
| 313 | + List<LocalDate> dateList = ConstDateUtil.getDateSetFromTheCurrentDayToTheEndOfTheMonth(parse.getYear(), parse.getMonthValue(), day); | |
| 314 | + createScheduleMethod(dateList, peopleList); | |
| 315 | + } | |
| 316 | + | |
| 317 | + private void deleteScheduleByRule(AgainCreateRequestVo vo) { | |
| 318 | + String strDate = LocalDate.now().toString(); | |
| 319 | + String month = vo.getMonth().substring(0, vo.getMonth().lastIndexOf("-")); | |
| 320 | + String nowMonth = strDate.substring(0, strDate.lastIndexOf("-")); | |
| 321 | + int compare = month.compareTo(nowMonth); | |
| 322 | + if (compare > 0) { | |
| 323 | + LocalDate endDay; | |
| 324 | + endDay = getEndDay(vo.getMonth()); | |
| 325 | + vo.setDate(vo.getMonth() + "-" + "01"); | |
| 326 | + ruleSchedulingService.deletePeopleSchedule(vo.getDate(), endDay.toString(), vo.getJobCode()); | |
| 327 | + } else if (compare == 0) { | |
| 328 | + LocalDate endDay = getEndDay(vo.getMonth()); | |
| 329 | + LocalDate localDate = LocalDate.now().plusDays(1); | |
| 330 | + vo.setDate(localDate.toString()); | |
| 331 | + ruleSchedulingService.deletePeopleSchedule(vo.getDate(), endDay.toString(), vo.getJobCode()); | |
| 332 | + } else { | |
| 333 | + throw new RuntimeException("过去的日期排班无法改变!!!"); | |
| 334 | + } | |
| 335 | + } | |
| 336 | + | |
| 337 | + private LocalDate getEndDay(@NotBlank String endDayStr) { | |
| 338 | + String[] split = endDayStr.split("-"); | |
| 339 | + if (Integer.parseInt(split[1]) == 12) { | |
| 340 | + return LocalDate.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]), 31); | |
| 341 | + } else { | |
| 342 | + return LocalDate.of(Integer.parseInt(split[0]), Integer.parseInt(split[1]) + 1, 1).minusDays(1); | |
| 343 | + } | |
| 344 | + } | |
| 295 | 345 | |
| 296 | - private List<RuleAttendanceMain> handleAttendanceMain(List<AttendanceDto> peopleList, List<RuleSchedulingDto> ruleList, List<RuleNumDto> ruleNumDtoList, List<LocalDate> dateList, String month) { | |
| 297 | - if (CollectionUtil.isEmpty(peopleList)) { | |
| 346 | + | |
| 347 | + public List<RuleAttendanceMain> handleAttendanceMain(List<AttendanceDto> peopleList, List<RuleSchedulingDto> ruleList, List<RuleNumDto> ruleNumDtoList, List<LocalDate> dateList) { | |
| 348 | + if (CollectionUtil.isEmpty(peopleList) || CollectionUtil.isEmpty(ruleList) || CollectionUtil.isEmpty(ruleNumDtoList) ) { | |
| 298 | 349 | return null; |
| 299 | 350 | } |
| 300 | 351 | Map<Integer, List<AttendanceDto>> peopleMap = transformMapByPeople(peopleList); |
| ... | ... | @@ -431,7 +482,6 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 431 | 482 | } |
| 432 | 483 | |
| 433 | 484 | |
| 434 | - | |
| 435 | 485 | private Map<Integer, List<AttendanceDto>> transformMapByPeople(List<AttendanceDto> peopleList) { |
| 436 | 486 | Map<Integer, List<AttendanceDto>> map = new HashMap<>(16); |
| 437 | 487 | for (AttendanceDto dto : peopleList) { |
| ... | ... | @@ -469,7 +519,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 469 | 519 | return map; |
| 470 | 520 | } |
| 471 | 521 | |
| 472 | - private void backCreatePeopleListLog(List<AttendanceDto> peopleList, Map<Integer, RuleNumDto> ruleNumDtoList, List<LocalDate> dateList) { | |
| 522 | + public void backCreatePeopleListLog(List<AttendanceDto> peopleList, Map<Integer, RuleNumDto> ruleNumDtoList, List<LocalDate> dateList) { | |
| 473 | 523 | List<RuleAttendanceMainHelp> helpList = new ArrayList<>(peopleList.size()); |
| 474 | 524 | LocalDate localDate = dateList.get(0); |
| 475 | 525 | Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant()); |
| ... | ... | @@ -480,7 +530,7 @@ public class AttendanceServiceImpl implements AttendanceService { |
| 480 | 530 | help.setRuleDictName(ruleNumDtoList.get(dto.getSettingId()).getRuleDictName()); |
| 481 | 531 | helpList.add(help); |
| 482 | 532 | } |
| 483 | - helpService.saveBatch(helpList); | |
| 533 | + helpService.insertHelpList(helpList); | |
| 484 | 534 | } |
| 485 | 535 | |
| 486 | 536 | private List<PeopleResponseVo> mainTransformPeopleResponseVo(List<RuleAttendanceMain> mainList) { | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/service/impl/RuleAttendanceMainHelpServiceImpl.java
| ... | ... | @@ -21,6 +21,11 @@ public class RuleAttendanceMainHelpServiceImpl extends ServiceImpl<RuleAttendanc |
| 21 | 21 | public List<RuleAttendanceMainHelp> queryNowMonthPeople(PeopleRequestVo vo) { |
| 22 | 22 | return baseMapper.queryNowMonthPeople(vo); |
| 23 | 23 | } |
| 24 | + | |
| 25 | + @Override | |
| 26 | + public void insertHelpList(List<RuleAttendanceMainHelp> helpList) { | |
| 27 | + baseMapper.insertHelpList(helpList); | |
| 28 | + } | |
| 24 | 29 | } |
| 25 | 30 | |
| 26 | 31 | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
| ... | ... | @@ -125,6 +125,28 @@ public class ConstDateUtil { |
| 125 | 125 | |
| 126 | 126 | return dateList; |
| 127 | 127 | } |
| 128 | + public static List<LocalDate> getDateSetFromTheCurrentDayToTheEndOfTheMonth(int year,int month,int day){ | |
| 129 | + LocalDate today = LocalDate.of(year,month,day); | |
| 130 | + | |
| 131 | + // 获取本月的最后一天 | |
| 132 | + LocalDate endDay; | |
| 133 | + if (month == 12) { | |
| 134 | + endDay = LocalDate.of(year, month, 31); | |
| 135 | + } else { | |
| 136 | + endDay = LocalDate.of(year, month + 1, 1).minusDays(1); | |
| 137 | + } | |
| 138 | + | |
| 139 | + // 生成日期列表 | |
| 140 | + List<LocalDate> dateList = new ArrayList<>(); | |
| 141 | + LocalDate currentDay = today; | |
| 142 | + while (!currentDay.isAfter(endDay)) { | |
| 143 | + dateList.add(currentDay); | |
| 144 | + currentDay = currentDay.plusDays(1); | |
| 145 | + } | |
| 146 | + | |
| 147 | + return dateList; | |
| 148 | + } | |
| 149 | + | |
| 128 | 150 | |
| 129 | 151 | |
| 130 | 152 | /** | ... | ... |
Bsth-admin/src/main/resources/mapper/RuleAttendanceMainHelpMapper.xml
| ... | ... | @@ -15,9 +15,24 @@ |
| 15 | 15 | </resultMap> |
| 16 | 16 | |
| 17 | 17 | <sql id="Base_Column_List"> |
| 18 | - id,name,job_code, | |
| 18 | + id,`name`,job_code, | |
| 19 | 19 | posts,date_flag,fleet_name |
| 20 | 20 | </sql> |
| 21 | + <insert id="insertHelpList" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> | |
| 22 | + insert into rule_attendance_main_help (`name`,job_code,posts,date_flag,fleet_name,rule_dict_name) values | |
| 23 | + <foreach collection="list" separator="," item="item" index="index"> | |
| 24 | + ( | |
| 25 | + #{item.name}, | |
| 26 | + #{item.jobCode}, | |
| 27 | + #{item.posts}, | |
| 28 | + #{item.dateFlag}, | |
| 29 | + #{item.fleetName}, | |
| 30 | + #{item.ruleDictName} | |
| 31 | + ) | |
| 32 | + </foreach> | |
| 33 | + on duplicate key update | |
| 34 | + job_code = values(job_code) | |
| 35 | + </insert> | |
| 21 | 36 | <select id="queryNowMonthPeople" resultMap="BaseResultMap" resultType="com.ruoyi.domain.RuleAttendanceMainHelp"> |
| 22 | 37 | SELECT * from rule_attendance_main_help WHERE DATE_FORMAT( date_flag, '%Y-%m' ) = #{date} |
| 23 | 38 | <if test="jobCode != null and jobCode != ''"> | ... | ... |
Bsth-admin/src/main/resources/mapper/RuleNumSettingMapper.xml
Bsth-admin/src/main/resources/mapper/scheduling/RuleSchedulingMapper.xml
| ... | ... | @@ -51,6 +51,15 @@ |
| 51 | 51 | <result property="createBy" column="create_by" /> |
| 52 | 52 | <result property="updateBy" column="update_by" /> |
| 53 | 53 | </resultMap> |
| 54 | + <resultMap id="AttendanceResult" type="com.ruoyi.pojo.dto.AttendanceDto"> | |
| 55 | + <result property="jobCode" column="job_code" jdbcType="VARCHAR"/> | |
| 56 | + <result property="name" column="personnel_name" jdbcType="VARCHAR"/> | |
| 57 | + <result property="posts" column="posts" jdbcType="VARCHAR"/> | |
| 58 | + <result property="name" column="personnel_name" jdbcType="VARCHAR"/> | |
| 59 | + <result property="settingId" column="setting_id" jdbcType="INTEGER"/> | |
| 60 | + <result property="startDate" column="start_date" jdbcType="DATE"/> | |
| 61 | + <result property="fleetName" column="fleet_name" jdbcType="VARCHAR"/> | |
| 62 | + </resultMap> | |
| 54 | 63 | |
| 55 | 64 | <sql id="selectRuleSchedulingVo"> |
| 56 | 65 | select id, rule_name, working_hour_plan, working_hour_type, first_work_sign_in_time, first_sign_in_working_range, first_quitting_sign_in_time, first_sign_in_day_tomorrow, first_sign_in_quitting_range, sign_in_time_out_range, second_flag, second_work_sign_in_time, second_sign_in_working_range, second_quitting_sign_in_time, second_sign_in_quitting_range, second_sign_day_tomorrow,update_by,update_time,create_by,create_time from rule_scheduling |
| ... | ... | @@ -99,6 +108,25 @@ |
| 99 | 108 | #{item} |
| 100 | 109 | </foreach> |
| 101 | 110 | </select> |
| 111 | + <select id="getPeopleListByJobCodes" resultType="com.ruoyi.pojo.dto.AttendanceDto" resultMap="AttendanceResult"> | |
| 112 | + SELECT | |
| 113 | + driver.job_code, | |
| 114 | + driver.personnel_name, | |
| 115 | + driver.fleet_name, | |
| 116 | + driver.posts, | |
| 117 | + rule_setting_driver.setting_id, | |
| 118 | + rule_setting_driver.start_date | |
| 119 | + FROM | |
| 120 | + driver, | |
| 121 | + rule_setting_driver | |
| 122 | + WHERE | |
| 123 | + driver.job_code = rule_setting_driver.job_code | |
| 124 | + AND rule_setting_driver.job_code IN ( | |
| 125 | + <foreach collection="list" index="index" item="item" separator=","> | |
| 126 | + #{item} | |
| 127 | + </foreach> | |
| 128 | + ) | |
| 129 | + </select> | |
| 102 | 130 | |
| 103 | 131 | <insert id="insertRuleScheduling" parameterType="RuleScheduling" useGeneratedKeys="true" keyProperty="id"> |
| 104 | 132 | insert into rule_scheduling |
| ... | ... | @@ -180,4 +208,25 @@ |
| 180 | 208 | #{id} |
| 181 | 209 | </foreach> |
| 182 | 210 | </delete> |
| 211 | + <delete id="deletePeopleSchedule"> | |
| 212 | + DELETE | |
| 213 | + FROM | |
| 214 | + rule_attendance_main | |
| 215 | + WHERE | |
| 216 | + id IN ( | |
| 217 | + SELECT | |
| 218 | + id | |
| 219 | + FROM | |
| 220 | + ( | |
| 221 | + SELECT id | |
| 222 | + FROM rule_attendance_main | |
| 223 | + WHERE job_code | |
| 224 | + IN ( | |
| 225 | + <foreach collection="list" item="item" index="index" separator=","> | |
| 226 | + #{item} | |
| 227 | + </foreach> | |
| 228 | + ) AND scheduling_date >= #{startDate} AND scheduling_date <= #{endDate} | |
| 229 | + ) t1 | |
| 230 | + ) | |
| 231 | + </delete> | |
| 183 | 232 | </mapper> |
| 184 | 233 | \ No newline at end of file | ... | ... |