排班bug修改
This commit is contained in:
parent
14b6077ea7
commit
f9fe218f7a
@ -50,7 +50,7 @@ public class AttendanceArrangementController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@SaCheckPermission("Property:arrangement:explore")
|
@SaCheckPermission("Property:arrangement:explore")
|
||||||
@GetMapping("/explore")
|
@GetMapping("/explore")
|
||||||
public List<AttendanceArrangementVo> list(AttendanceArrangementBo bo) {
|
public TableDataInfo<AttendanceArrangementVo> list(AttendanceArrangementBo bo) {
|
||||||
return attendanceArrangementService.queryList(bo);
|
return attendanceArrangementService.queryList(bo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
package org.dromara.property.controller;
|
|
||||||
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.dromara.common.web.core.BaseController;
|
|
||||||
import org.springframework.validation.annotation.Validated;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排班考勤组的中间表控制层
|
|
||||||
* 前端访问路由地址为:/Property/arrangementGroup
|
|
||||||
*
|
|
||||||
* @author mocheng
|
|
||||||
* @date 2025-07-15
|
|
||||||
*/
|
|
||||||
@Validated
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/arrangementGroup")
|
|
||||||
public class AttendanceArrangementGroupController extends BaseController {
|
|
||||||
|
|
||||||
}
|
|
@ -7,7 +7,9 @@ import lombok.EqualsAndHashCode;
|
|||||||
import org.dromara.common.tenant.core.TenantEntity;
|
import org.dromara.common.tenant.core.TenantEntity;
|
||||||
|
|
||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 排班对象 attendance_arrangement
|
* 排班对象 attendance_arrangement
|
||||||
@ -52,12 +54,12 @@ public class AttendanceArrangement extends TenantEntity {
|
|||||||
/**
|
/**
|
||||||
* 开始日期
|
* 开始日期
|
||||||
*/
|
*/
|
||||||
private Date startDate;
|
private LocalDate startDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束日期(仅date_type=3时有效)
|
* 结束日期(仅date_type=3时有效)
|
||||||
*/
|
*/
|
||||||
private Date endDate;
|
private LocalDate endDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态:0-未生效,1-已生效
|
* 状态:0-未生效,1-已生效
|
||||||
@ -65,4 +67,5 @@ public class AttendanceArrangement extends TenantEntity {
|
|||||||
private Long status;
|
private Long status;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,35 +0,0 @@
|
|||||||
package org.dromara.property.domain;
|
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import org.dromara.common.tenant.core.TenantEntity;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 考勤排班组中间表对象 attendance_arrangement_group
|
|
||||||
*
|
|
||||||
* @author ruoyi
|
|
||||||
* @date 2025-07-30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@TableName("attendance_arrangement_group")
|
|
||||||
public class AttendanceArrangementGroup extends TenantEntity
|
|
||||||
{
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
/** 主键ID */
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/** 排班id */
|
|
||||||
private Long arrangementId;
|
|
||||||
|
|
||||||
/** 考勤组ID */
|
|
||||||
private Long groupId;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -12,6 +12,7 @@ import org.dromara.property.domain.AttendanceScheduleCycle;
|
|||||||
import org.dromara.property.domain.AttendanceUserGroup;
|
import org.dromara.property.domain.AttendanceUserGroup;
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.time.LocalDate;
|
||||||
import java.time.YearMonth;
|
import java.time.YearMonth;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -58,19 +59,19 @@ public class AttendanceArrangementBo extends BaseEntity {
|
|||||||
* 开始日期
|
* 开始日期
|
||||||
*/
|
*/
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date startDate;
|
private LocalDate startDate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 结束日期(仅date_type=3时有效)
|
* 结束日期(仅date_type=3时有效)
|
||||||
*/
|
*/
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
private Date endDate;
|
private LocalDate endDate;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 前端传某天的当前日期
|
* 前端传某天的当前日期
|
||||||
*/
|
*/
|
||||||
private Date currentDate;
|
private LocalDate currentDate;
|
||||||
/**
|
/**
|
||||||
* 日期月份
|
* 日期月份
|
||||||
*/
|
*/
|
||||||
|
@ -1,54 +0,0 @@
|
|||||||
package org.dromara.property.domain.bo;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateTime;
|
|
||||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
|
||||||
import org.dromara.property.domain.AttendanceArrangementGroup;
|
|
||||||
import org.dromara.common.mybatis.core.domain.BaseEntity;
|
|
||||||
import org.dromara.common.core.validate.AddGroup;
|
|
||||||
import org.dromara.common.core.validate.EditGroup;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
import jakarta.validation.constraints.*;
|
|
||||||
import org.dromara.property.domain.AttendanceScheduleCycle;
|
|
||||||
import org.dromara.property.domain.AttendanceUserGroup;
|
|
||||||
import org.dromara.property.domain.AttendanceWeekSet;
|
|
||||||
import org.dromara.property.domain.AttendanceShift;
|
|
||||||
import org.springframework.format.annotation.DateTimeFormat;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.YearMonth;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 考勤排班组业务对象 attendance_arrangement_group
|
|
||||||
*
|
|
||||||
* @author mocheng
|
|
||||||
* @date 2025-07-30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(callSuper = true)
|
|
||||||
@AutoMapper(target = AttendanceArrangementGroup.class, reverseConvertGenerate = false)
|
|
||||||
public class AttendanceArrangementGroupBo extends BaseEntity {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@NotNull(message = "主键ID不能为空", groups = {EditGroup.class})
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排班名称
|
|
||||||
*/
|
|
||||||
@NotBlank(message = "排班id不能为空", groups = {AddGroup.class, EditGroup.class})
|
|
||||||
private Long arrangementId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 考勤组ID
|
|
||||||
*/
|
|
||||||
@NotNull(message = "考勤组ID不能为空", groups = {AddGroup.class, EditGroup.class})
|
|
||||||
private Long groupId;
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,7 +1,7 @@
|
|||||||
package org.dromara.property.domain.constant;
|
package org.dromara.property.domain.constant;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态常量,启用或者禁用
|
* 状态常量
|
||||||
*/
|
*/
|
||||||
public class StatusConstant {
|
public class StatusConstant {
|
||||||
|
|
||||||
|
@ -1,46 +0,0 @@
|
|||||||
package org.dromara.property.domain.vo;
|
|
||||||
|
|
||||||
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
|
||||||
import cn.idev.excel.annotation.ExcelProperty;
|
|
||||||
import io.github.linpeilie.annotations.AutoMapper;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.dromara.property.domain.*;
|
|
||||||
|
|
||||||
import java.io.Serial;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 考勤排班组视图对象 attendance_arrangement_group
|
|
||||||
*
|
|
||||||
* @author mocheng
|
|
||||||
* @date 2025-07-30
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
@ExcelIgnoreUnannotated
|
|
||||||
@AutoMapper(target = AttendanceArrangementGroup.class)
|
|
||||||
public class AttendanceArrangementGroupVo implements Serializable {
|
|
||||||
|
|
||||||
@Serial
|
|
||||||
private static final long serialVersionUID = 1L;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 主键ID
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "主键ID")
|
|
||||||
private Long id;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排班名称
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "排班id")
|
|
||||||
private Long arrangementId;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 考勤组ID
|
|
||||||
*/
|
|
||||||
@ExcelProperty(value = "考勤组ID")
|
|
||||||
private Long groupId;
|
|
||||||
|
|
||||||
}
|
|
@ -9,6 +9,7 @@ import org.dromara.property.domain.*;
|
|||||||
import java.io.Serial;
|
import java.io.Serial;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.time.LocalDate;
|
import java.time.LocalDate;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
@ -74,6 +75,8 @@ public class AttendanceArrangementVo implements Serializable {
|
|||||||
@ExcelProperty(value = "状态:0-未生效,1-已生效")
|
@ExcelProperty(value = "状态:0-未生效,1-已生效")
|
||||||
private Long status;
|
private Long status;
|
||||||
|
|
||||||
|
private AttendanceGroup attendanceGroup;
|
||||||
|
|
||||||
private List<AttendanceUserGroup> userGroupList;
|
private List<AttendanceUserGroup> userGroupList;
|
||||||
|
|
||||||
private AttendanceWeekSet weekSet;
|
private AttendanceWeekSet weekSet;
|
||||||
@ -82,4 +85,6 @@ public class AttendanceArrangementVo implements Serializable {
|
|||||||
|
|
||||||
private AttendanceScheduleCycle cycle;
|
private AttendanceScheduleCycle cycle;
|
||||||
|
|
||||||
|
private AttendanceUserGroup userGroup;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
package org.dromara.property.mapper;
|
|
||||||
|
|
||||||
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
|
|
||||||
import org.dromara.property.domain.AttendanceArrangementGroup;
|
|
||||||
import org.dromara.property.domain.vo.AttendanceArrangementGroupVo;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排班Mapper接口
|
|
||||||
*
|
|
||||||
* @author mocheng
|
|
||||||
* @date 2025-07-15
|
|
||||||
*/
|
|
||||||
public interface AttendanceArrangementGroupMapper extends BaseMapperPlus<AttendanceArrangementGroup, AttendanceArrangementGroupVo> {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -1,12 +0,0 @@
|
|||||||
package org.dromara.property.service;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排班Service接口
|
|
||||||
*
|
|
||||||
* @author mocheng
|
|
||||||
* @date 2025-07-15
|
|
||||||
*/
|
|
||||||
public interface IAttendanceArrangementGroupService {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -39,7 +39,7 @@ public interface IAttendanceArrangementService {
|
|||||||
* @param bo 查询条件
|
* @param bo 查询条件
|
||||||
* @return 排班列表
|
* @return 排班列表
|
||||||
*/
|
*/
|
||||||
List<AttendanceArrangementVo> queryList(AttendanceArrangementBo bo);
|
TableDataInfo<AttendanceArrangementVo> queryList(AttendanceArrangementBo bo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增排班
|
* 新增排班
|
||||||
|
@ -1,40 +0,0 @@
|
|||||||
package org.dromara.property.service.impl;
|
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.dromara.common.core.utils.MapstructUtils;
|
|
||||||
import org.dromara.common.core.utils.StringUtils;
|
|
||||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
||||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
||||||
import org.dromara.property.domain.*;
|
|
||||||
import org.dromara.property.domain.bo.AttendanceArrangementBo;
|
|
||||||
import org.dromara.property.domain.constant.StatusConstant;
|
|
||||||
import org.dromara.property.domain.vo.AttendanceArrangementVo;
|
|
||||||
import org.dromara.property.mapper.*;
|
|
||||||
import org.dromara.property.service.IAttendanceArrangementGroupService;
|
|
||||||
import org.dromara.property.service.IAttendanceArrangementService;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
|
||||||
|
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.ZoneId;
|
|
||||||
import java.util.*;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排班Service业务层处理
|
|
||||||
*
|
|
||||||
* @author mocheng
|
|
||||||
* @date 2025-07-15
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
@Service
|
|
||||||
public class AttendanceArrangementGroupServiceImpl implements IAttendanceArrangementGroupService {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
@ -41,11 +41,11 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
|
|
||||||
private final AttendanceGroupMapper attendanceGroupMapper;
|
private final AttendanceGroupMapper attendanceGroupMapper;
|
||||||
|
|
||||||
private final AttendanceArrangementGroupMapper arrangementGroupMapper;
|
// private final AttendanceArrangementGroupMapper arrangementGroupMapper;
|
||||||
|
|
||||||
private final AttendanceWeekSetMapper weekSetMapper;
|
private final AttendanceWeekSetMapper weekSetMapper;
|
||||||
|
|
||||||
private final AttendanceShiftMapper attendanceShiftMapper;
|
private final AttendanceShiftMapper attendanceShiftMapper;
|
||||||
|
|
||||||
private final AttendanceScheduleCycleMapper scheduleCycleMapper;
|
private final AttendanceScheduleCycleMapper scheduleCycleMapper;
|
||||||
|
|
||||||
@ -81,65 +81,68 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
|
|
||||||
|
|
||||||
Page<AttendanceArrangementVo> attendanceArrangementVoPage = result.setRecords(result.getRecords().stream().peek(vo -> {
|
Page<AttendanceArrangementVo> attendanceArrangementVoPage = result.setRecords(result.getRecords().stream().peek(vo -> {
|
||||||
//1.根据当前日期查询在开始时间和结束时间之间的排班信息
|
//1.根据当前日期查询在开始时间和结束时间之间的排班信息
|
||||||
//查询指定日期在哪些排班中
|
//查询指定日期在哪些排班中,并返回arrangementList
|
||||||
List<AttendanceArrangement> arrangementList = baseMapper.selectList(Wrappers.<AttendanceArrangement>lambdaQuery().ge(AttendanceArrangement::getStartDate, bo.getCurrentDate()).le(AttendanceArrangement::getEndDate, bo.getCurrentDate()));
|
List<AttendanceArrangement> arrangementList = baseMapper.selectList(Wrappers.<AttendanceArrangement>lambdaQuery().ge(AttendanceArrangement::getStartDate, bo.getCurrentDate()).le(AttendanceArrangement::getEndDate, bo.getCurrentDate()));
|
||||||
//根据排班查询出考勤组id
|
//根据排班查询出考勤组id
|
||||||
List<Long> groupIds = arrangementList.stream().map(AttendanceArrangement::getGroupId).distinct().toList();
|
List<Long> groupIds = arrangementList.stream().map(AttendanceArrangement::getGroupId).distinct().toList();
|
||||||
|
|
||||||
// 2.循环将所有的考勤组id设置到考勤组中
|
// 2.循环将所有的考勤组id设置到考勤组中
|
||||||
//循环groupIds,循环和AttendanceGroup中的id做对比,如果有相同的,则取出attendanceGroup中的所有数据
|
//循环groupIds,循环和AttendanceGroup中的id做对比,如果有相同的,则取出attendanceGroup中的所有数据
|
||||||
groupIds.forEach(
|
groupIds.forEach(
|
||||||
groupId -> {
|
groupId -> {
|
||||||
//从数据库查询出当前考勤组的所有数据
|
//从数据库查询出当前考勤组的所有数据
|
||||||
AttendanceGroup group = attendanceGroupMapper.selectOne(Wrappers.<AttendanceGroup>lambdaQuery().eq(AttendanceGroup::getId, groupId));
|
AttendanceGroup group = attendanceGroupMapper.selectOne(Wrappers.<AttendanceGroup>lambdaQuery().eq(AttendanceGroup::getId, groupId));
|
||||||
|
|
||||||
// 3.查询出当前考勤组的所有数据,从考勤组判断当前id是固定班制还是排班制
|
// 3.查询出当前考勤组的所有数据,从考勤组判断当前id是固定班制还是排班制
|
||||||
if (group.getAttendanceType().equals(StatusConstant.FIXEDSCHEDULE)) {
|
if (group.getAttendanceType().equals(StatusConstant.FIXEDSCHEDULE)) {
|
||||||
// 3.1固定班制:将当前的日期转为周几,然后与数据库中的班次周数作对比,取出当前日期的班次信息
|
// 3.1固定班制:将当前的日期转为周几,然后与数据库中的班次周数作对比,取出当前日期的班次信息
|
||||||
//将传来的日期参数转为周几
|
//将传来的日期参数转为周几
|
||||||
int week = DateUtil.dayOfWeek(bo.getCurrentDate());
|
// int week = DateUtil.dayOfWeek(bo.getCurrentDate());
|
||||||
//取出当前日期的周数,与数据库中的班次周数作对比,取出当前日期的班次信息
|
int week = 1;
|
||||||
AttendanceWeekSet weekSet = weekSetMapper.selectOne(Wrappers.<AttendanceWeekSet>lambdaQuery().eq(AttendanceWeekSet::getGroupId, groupId).eq(AttendanceWeekSet::getDayOfWeek, week));
|
//取出当前日期的周数,与数据库中的班次周数作对比,取出当前日期的班次信息
|
||||||
//将weekSet存到结果中
|
AttendanceWeekSet weekSet = weekSetMapper.selectOne(Wrappers.<AttendanceWeekSet>lambdaQuery().eq(AttendanceWeekSet::getGroupId, groupId).eq(AttendanceWeekSet::getDayOfWeek, week));
|
||||||
AttendanceArrangementVo arrangementVo = new AttendanceArrangementVo();
|
//将weekSet存到结果中
|
||||||
arrangementVo.setWeekSet(weekSet);
|
vo.setWeekSet(weekSet);
|
||||||
//根据weekSet取出id,根据id查询出attendanceWeekSetShift表中的shiftId
|
//根据weekSet取出id,根据id查询出attendanceWeekSetShift表中的shiftId
|
||||||
Long shiftId = weekSet.getId();
|
Long shiftId = weekSet.getId();
|
||||||
//根据shiftId查询attendanceShift表中对应的id的数据
|
//根据shiftId查询attendanceShift表中对应的id的数据
|
||||||
AttendanceShift shift = attendanceShiftMapper.selectById(shiftId);
|
AttendanceShift shift = attendanceShiftMapper.selectById(shiftId);
|
||||||
//将shift存到结果中
|
//将shift存到结果中
|
||||||
arrangementVo.setShift(shift);
|
vo.setShift(shift);
|
||||||
|
} else if (group.getAttendanceType().equals(StatusConstant.SHIFTSCHEDULE)) {
|
||||||
|
// 3.2排班制:判断第一天是从几号开始,循环判断,判断当前是循环中的第几天,取出当前天数的班次信息。
|
||||||
|
//取出排班中的开始时间和结束时间
|
||||||
|
LocalDate startDate = bo.getStartDate();
|
||||||
|
LocalDate endDate = bo.getEndDate();
|
||||||
|
LocalDate currentDate = bo.getCurrentDate();
|
||||||
|
//统计当前考勤组有多少条数据
|
||||||
|
int count = Math.toIntExact(scheduleCycleMapper.selectCount(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)));
|
||||||
|
|
||||||
} else if (group.getAttendanceType().equals(StatusConstant.SHIFTSCHEDULE)) {
|
|
||||||
// 3.2排班制:判断第一天是从几号开始,循环判断,判断当前是循环中的第几天,取出当前天数的班次信息。
|
//todo: 匹配天数
|
||||||
//取出排班中的开始时间和结束时间
|
|
||||||
Date startDate = bo.getStartDate();
|
|
||||||
Date endDate = bo.getEndDate();
|
//取出attendanceScheduleCycle表中的天数
|
||||||
Date currentDate = bo.getCurrentDate();
|
Integer cycleDays = scheduleCycleMapper.selectOne(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)).getDayNumber();
|
||||||
//取出attendanceScheduleCycle表中的天数
|
//在startDate和endDate之间循环,判端当前日期是cycleDays中的第几天
|
||||||
Integer cycleDays = scheduleCycleMapper.selectOne(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId)).getDayNumber();
|
int cycleDay = 0;
|
||||||
//在startDate和endDate之间循环,判端当前日期是cycleDays中的第几天
|
while (startDate.isBefore(currentDate) || endDate.isAfter(currentDate)) {
|
||||||
int cycleDay = 0;
|
cycleDay++;
|
||||||
while (startDate.before(currentDate) || endDate.after(currentDate)) {
|
// startDate = DateUtil.offsetDay(startDate, 1);
|
||||||
cycleDay++;
|
//判断当前日期是clcleDays中的第几天
|
||||||
startDate = DateUtil.offsetDay(startDate, 1);
|
if (cycleDay > cycleDays) {
|
||||||
//判断当前日期是clcleDays中的第几天
|
cycleDay = 1;
|
||||||
if (cycleDay > cycleDays) {
|
}
|
||||||
cycleDay = 1;
|
|
||||||
}
|
}
|
||||||
|
//根据cycleDay查询出当前日期的班次信息
|
||||||
|
AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId).eq(AttendanceScheduleCycle::getDayNumber, cycleDay));
|
||||||
|
//将cycle存到结果中
|
||||||
|
vo.setCycle(cycle);
|
||||||
|
|
||||||
}
|
}
|
||||||
//根据cycleDay查询出当前日期的班次信息
|
|
||||||
AttendanceScheduleCycle cycle = scheduleCycleMapper.selectOne(Wrappers.<AttendanceScheduleCycle>lambdaQuery().eq(AttendanceScheduleCycle::getGroupId, groupId).eq(AttendanceScheduleCycle::getDayNumber, cycleDay));
|
|
||||||
//将cycle存到结果中
|
|
||||||
AttendanceArrangementVo arrangementVo = new AttendanceArrangementVo();
|
|
||||||
arrangementVo.setCycle(cycle);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
);
|
||||||
);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// AttendanceArrangementVo arrangementvo = baseMapper.selectVoByTime(bo.getCurrentDate());
|
// AttendanceArrangementVo arrangementvo = baseMapper.selectVoByTime(bo.getCurrentDate());
|
||||||
@ -167,7 +170,7 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
* @return 排班列表
|
* @return 排班列表
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AttendanceArrangementVo> queryList(AttendanceArrangementBo bo) {
|
public TableDataInfo<AttendanceArrangementVo> queryList(AttendanceArrangementBo bo) {
|
||||||
|
|
||||||
LocalDate month = bo.getMonth().atEndOfMonth();
|
LocalDate month = bo.getMonth().atEndOfMonth();
|
||||||
// 1. 拿到日历的开始时间和结束时间
|
// 1. 拿到日历的开始时间和结束时间
|
||||||
@ -178,13 +181,28 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
// 2.1 循环日历的开始时间和结束时间,判断 calendarStartDate 在哪些排班中
|
// 2.1 循环日历的开始时间和结束时间,判断 calendarStartDate 在哪些排班中
|
||||||
List<AttendanceArrangementVo> result = new ArrayList<>();
|
List<AttendanceArrangementVo> result = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
for (LocalDate date = calendarStartDate; date.isBefore(calendarEndDate); date = date.plusDays(1)) {
|
for (LocalDate date = calendarStartDate; date.isBefore(calendarEndDate); date = date.plusDays(1)) {
|
||||||
|
// 2.2 根据当前日期查询在开始时间和结束时间之间的排班信息
|
||||||
|
//查询当前日期在哪些排班中,当前日期大于等于排班开始日期,小于等于排班结束日期
|
||||||
// 查询指定日期在哪些排班中
|
// 查询指定日期在哪些排班中
|
||||||
List<AttendanceArrangement> arrangementList = baseMapper.selectList(
|
List<AttendanceArrangement> arrangementList = baseMapper.selectList(
|
||||||
Wrappers.<AttendanceArrangement>lambdaQuery()
|
Wrappers.<AttendanceArrangement>lambdaQuery()
|
||||||
.ge(AttendanceArrangement::getStartDate, date.atStartOfDay(ZoneId.systemDefault()).toInstant())
|
.between(AttendanceArrangement::getStartDate, date.atStartOfDay(ZoneId.systemDefault()).toInstant(),
|
||||||
.le(AttendanceArrangement::getEndDate, date.atStartOfDay(ZoneId.systemDefault()).plusDays(1).toInstant().minusSeconds(1))
|
date.atStartOfDay(ZoneId.systemDefault()).plusDays(1).toInstant().minusSeconds(1)));
|
||||||
);
|
|
||||||
|
|
||||||
|
//查询出的多个排班进行循环,取出所有的考勤组
|
||||||
|
arrangementList.forEach(arrangement -> {
|
||||||
|
// // 2.3 根据排班查询出考勤组id
|
||||||
|
// List<Long> groupIds = arrangementList.stream()
|
||||||
|
// .map(AttendanceArrangement::getGroupId)
|
||||||
|
// .distinct()
|
||||||
|
// .toList();
|
||||||
|
//将考勤组信息添加到排班信息中
|
||||||
|
result.add(MapstructUtils.convert(arrangement, AttendanceArrangementVo.class));
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
// 根据排班查询出考勤组id
|
// 根据排班查询出考勤组id
|
||||||
List<Long> groupIds = arrangementList.stream()
|
List<Long> groupIds = arrangementList.stream()
|
||||||
@ -203,21 +221,26 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
if (attendanceGroup != null) {
|
if (attendanceGroup != null) {
|
||||||
// 创建 AttendanceArrangementVo 对象并设置属性
|
// 创建 AttendanceArrangementVo 对象并设置属性
|
||||||
AttendanceArrangementVo vo = new AttendanceArrangementVo();
|
AttendanceArrangementVo vo = new AttendanceArrangementVo();
|
||||||
vo.setStartDate(LocalDate.from(date.atStartOfDay(ZoneId.systemDefault())));
|
//vo中设置开始时间和结束时间分别加一天
|
||||||
vo.setEndDate(LocalDate.from(date.atStartOfDay(ZoneId.systemDefault()).plusDays(1).toInstant().minusSeconds(1)));
|
vo.setStartDate(date.plusDays(1));
|
||||||
// 设置其他属性...
|
vo.setEndDate(date.plusDays(1));
|
||||||
|
|
||||||
|
//新建attendanceGroup对象,将排班信息和考勤组信息添加到vo中
|
||||||
|
vo.setAttendanceGroup(attendanceGroup);
|
||||||
|
|
||||||
result.add(vo);
|
result.add(vo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 如果 collected 不为空,则返回 result
|
// 如果 collected 不为空,则返回 result
|
||||||
if (!result.isEmpty()) {
|
if (result.isEmpty()) {
|
||||||
return result;
|
return TableDataInfo.build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 循环结束后如果 result 仍为空,则返回空列表
|
// 循环结束后如果 result 仍为空,则返回空列表
|
||||||
return Collections.emptyList();
|
return TableDataInfo.build(result);
|
||||||
|
|
||||||
// // 计算交集的开始时间(取较晚的开始时间)和结束时间(取较早的结束时间)
|
// // 计算交集的开始时间(取较晚的开始时间)和结束时间(取较早的结束时间)
|
||||||
// Date overlapStart = calendarStartDate.after(startDate)
|
// Date overlapStart = calendarStartDate.after(startDate)
|
||||||
@ -228,7 +251,6 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
//根据交集的时间范围查询排班信息
|
//根据交集的时间范围查询排班信息
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -265,11 +287,11 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
|
|
||||||
judgeDate(bo, add);
|
judgeDate(bo, add);
|
||||||
|
|
||||||
AttendanceArrangementGroup attendanceArrangementGroup = new AttendanceArrangementGroup();
|
// AttendanceArrangementGroup attendanceArrangementGroup = new AttendanceArrangementGroup();
|
||||||
//向排班和考勤组中间表中插入数据
|
// //向排班和考勤组中间表中插入数据
|
||||||
attendanceArrangementGroup.setGroupId(add.getGroupId());
|
// attendanceArrangementGroup.setGroupId(add.getGroupId());
|
||||||
attendanceArrangementGroup.setArrangementId(bo.getId());
|
// attendanceArrangementGroup.setArrangementId(bo.getId());
|
||||||
arrangementGroupMapper.insert(attendanceArrangementGroup);
|
// arrangementGroupMapper.insert(attendanceArrangementGroup);
|
||||||
|
|
||||||
//取出当前新增的排班的id
|
//取出当前新增的排班的id
|
||||||
Long ArrangementId = add.getId();
|
Long ArrangementId = add.getId();
|
||||||
@ -294,7 +316,7 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
if (bo.getDateType().equals(StatusConstant.LONGTIME)) {
|
if (bo.getDateType().equals(StatusConstant.LONGTIME)) {
|
||||||
//设置长期时间为2099年12月31日
|
//设置长期时间为2099年12月31日
|
||||||
LocalDate longTimeEndDate = LocalDate.of(2099, 12, 31);
|
LocalDate longTimeEndDate = LocalDate.of(2099, 12, 31);
|
||||||
add.setEndDate(Date.from(longTimeEndDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
|
add.setEndDate(longTimeEndDate);
|
||||||
}
|
}
|
||||||
if (bo.getDateType().equals(StatusConstant.SHORTTIME)) {
|
if (bo.getDateType().equals(StatusConstant.SHORTTIME)) {
|
||||||
add.setEndDate(bo.getEndDate());
|
add.setEndDate(bo.getEndDate());
|
||||||
@ -351,7 +373,7 @@ public class AttendanceArrangementServiceImpl implements IAttendanceArrangementS
|
|||||||
List<Long> idList = new ArrayList<>(ids);
|
List<Long> idList = new ArrayList<>(ids);
|
||||||
|
|
||||||
//根据当前排班的id 删除attendanceArrangementGroup表中的数据
|
//根据当前排班的id 删除attendanceArrangementGroup表中的数据
|
||||||
arrangementGroupMapper.delete(Wrappers.<AttendanceArrangementGroup>lambdaQuery().in(AttendanceArrangementGroup::getArrangementId, idList));
|
// arrangementGroupMapper.delete(Wrappers.<AttendanceArrangementGroup>lambdaQuery().in(AttendanceArrangementGroup::getArrangementId, idList));
|
||||||
|
|
||||||
//根据获取的id删除attendanceUserGroup表中的数据
|
//根据获取的id删除attendanceUserGroup表中的数据
|
||||||
userGroupMapper.delete(Wrappers.<AttendanceUserGroup>lambdaQuery().in(AttendanceUserGroup::getScheduleId, idList));
|
userGroupMapper.delete(Wrappers.<AttendanceUserGroup>lambdaQuery().in(AttendanceUserGroup::getScheduleId, idList));
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
|
||||||
<!DOCTYPE mapper
|
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="org.dromara.property.mapper.AttendanceArrangementGroupMapper">
|
|
||||||
|
|
||||||
</mapper>
|
|
Loading…
Reference in New Issue
Block a user