修改考勤报表导出看不出请假类型bug

This commit is contained in:
aikai 2024-12-06 16:40:09 +08:00
parent 3ceabc2e7c
commit 5cd5935e2f
9 changed files with 101 additions and 64 deletions

View File

@ -4,11 +4,10 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.bpm.api.oa.vo.BpmOALeaveRpcVO;
import cn.iocoder.yudao.module.bpm.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
@ -18,9 +17,9 @@ public interface BpmOALeaveApi {
String PREFIX = ApiConstants.PREFIX + "/oa/leave";
@GetMapping(PREFIX + "/leaveListByTime")
@Operation(summary = "根据时间获取请假列表")
@Parameter(name = "time", description = "时间格式yyyy-MM-dd", required = true, example = "2024-05-11")
CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByTime(@RequestParam(name = "time") String time);
@PostMapping(PREFIX + "/getLeaveListByIds")
@Operation(summary = "根据请假ids获取请假列表")
CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByIds(@RequestBody List<Long> ids);
}

View File

@ -1,29 +1,74 @@
package cn.iocoder.yudao.module.bpm.api.oa.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Data
public class BpmOALeaveRpcVO {
@Schema(description = "请假表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
/**
* 请假表单主键
*/
private Long id;
@Schema(description = "用户id")
/**
* 申请人的用户编号
* <p>
* 关联 AdminUserDO id 属性
*/
private Long userId;
@Schema(description = "请假的开始时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "开始时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
/**
* 假期设置id
*/
private Long holidaySettingId;
/**
* 原因
*/
private String reason;
/**
* 假期名称
*/
private String leaveName;
/**
* 开始时间
*/
private LocalDateTime startTime;
@Schema(description = "请假的结束时间", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "结束时间不能为空")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
/**
* 结束时间
*/
private LocalDateTime endTime;
@Schema(description = "请假类型-参见 bpm_oa_leave_type 枚举", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "请假类型不能为空")
private Integer type;
/**
* 请假时长单位根据请假最小单位来 按天or按半天 单位为天 按小时单位为小时
*/
private BigDecimal duration;
/**
* 开始时间额外字段 根据请假最小单位来 1按天则为空 2按半天则1为上午 2为下午 3按小时则 格式为 HH:mm
*/
private String startTimeExtraFields;
/**
* 结束时间额外字段 根据请假最小单位来 1按天则为空 2按半天则1为上午 2为下午 3按小时则 格式为 HH:mm
*/
private String endTimeExtraFields;
/**
* 请假最小单位 1按天 2按半天 3按小时
*/
private Integer minUnit;
/**
* 请假的结果
* <p>
* 枚举 {@link BpmProcessInstanceResultEnum}
* 考虑到简单所以直接复用了 BpmProcessInstanceResultEnum 枚举也可以自己定义一个枚举哈
*/
private Integer result;
/**
* 对应的流程编号
* <p>
* 关联 ProcessInstance id 属性
*/
private String processInstanceId;
}

View File

@ -24,9 +24,9 @@ public class BpmOALeaveApiImpl implements BpmOALeaveApi {
@Resource
private BpmOALeaveService leaveService;
@Override
public CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByTime(String time) {
return success(leaveService.getLeaveListByTime(time));
}
@Override
public CommonResult<List<BpmOALeaveRpcVO>> getLeaveListByIds(List<Long> ids) {
return CommonResult.success(leaveService.getLeaveListByIds(ids));
}
}

View File

@ -29,10 +29,4 @@ public interface BpmOALeaveMapper extends BaseMapperX<BpmOALeaveDO> {
.orderByDesc(BpmOALeaveDO::getId));
}
/**
*
* @param time
* @return
*/
List<BpmOALeaveRpcVO> getLeaveListByTime(@Param("time") String time);
}

View File

@ -58,14 +58,6 @@ public interface BpmOALeaveService {
*/
PageResult<BpmOALeaveDO> getLeavePage(Long userId, BpmOALeavePageReqVO pageReqVO);
/**
* 根据时间获取请假列表
*
* @param time
* @return
*/
List<BpmOALeaveRpcVO> getLeaveListByTime(String time);
/**
* 获得指定请假申请
*
@ -82,4 +74,12 @@ public interface BpmOALeaveService {
* @return
*/
BigDecimal calculateAndVerifyTheNumberOfLeaveDays(Long loginUserId, CalculateAndVerifyLeaveDTO dto);
/**
* 根据请假ids获取请假列表
*
* @param ids
* @return
*/
List<BpmOALeaveRpcVO> getLeaveListByIds(List<Long> ids);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.bpm.service.oa;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.json.JSONUtil;
@ -524,10 +525,6 @@ public class BpmOALeaveServiceImpl extends BpmOABaseService implements BpmOALeav
return leaveMapper.selectPage(userId, pageReqVO);
}
@Override
public List<BpmOALeaveRpcVO> getLeaveListByTime(String time) {
return leaveMapper.getLeaveListByTime(time);
}
@Override
public BpmOALeaveDO getByProcessInstanceId(String processInstanceId) {
@ -545,4 +542,13 @@ public class BpmOALeaveServiceImpl extends BpmOABaseService implements BpmOALeav
this.builderLeaveTime(leave);
return this.calculateAndVerifyTheNumberOfLeaveDays(leave);
}
@Override
public List<BpmOALeaveRpcVO> getLeaveListByIds(List<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
List<BpmOALeaveDO> bpmOALeaveDOS = leaveMapper.selectBatchIds(ids);
return BeanUtil.copyToList(bpmOALeaveDOS, BpmOALeaveRpcVO.class);
}
}

View File

@ -9,15 +9,4 @@
文档可见https://www.iocoder.cn/MyBatis/x-plugins/
-->
<select id="getLeaveListByTime" resultType="cn.iocoder.yudao.module.bpm.api.oa.vo.BpmOALeaveRpcVO">
SELECT
*
FROM
bpm_oa_leave
<where>
result = 2
AND DATE_FORMAT( end_time, '%Y-%m-%d' ) &gt;= #{time}
AND DATE_FORMAT( start_time, '%Y-%m-%d') &lt;= #{time}
</where>
</select>
</mapper>

View File

@ -11,6 +11,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {FileApi.class, WebSocketSenderApi.class, FactoryInfoApi.class, BpmModelApi.class, BpmOAGoOutApi.class, BpmOAEntryApi.class, ConfigApi.class,
BpmOAEvectionApi.class, BpmOAReplacementCardApi.class, BpmOARefundApi.class})
BpmOAEvectionApi.class, BpmOAReplacementCardApi.class, BpmOARefundApi.class, BpmOALeaveApi.class})
public class RpcConfiguration {
}

View File

@ -15,9 +15,11 @@ import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.framework.common.util.distance.GeoUtil;
import cn.iocoder.yudao.module.bpm.api.oa.BpmOALeaveApi;
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAReplacementCardApi;
import cn.iocoder.yudao.module.bpm.api.oa.vo.BpmOALeaveRpcVO;
import cn.iocoder.yudao.module.system.api.attendance.dto.AttendanceTimeRangeInfoDTO;
import cn.iocoder.yudao.module.system.api.attendance.vo.AttendanceTimeRangeInfoVO;
import cn.iocoder.yudao.module.bpm.api.oa.BpmOAReplacementCardApi;
import cn.iocoder.yudao.module.system.controller.admin.attendance.dto.*;
import cn.iocoder.yudao.module.system.controller.admin.attendance.vo.*;
import cn.iocoder.yudao.module.system.controller.admin.punchrecord.vo.AttendancePunchRecordSaveReqVO;
@ -28,7 +30,6 @@ import cn.iocoder.yudao.module.system.dal.dataobject.attendance.groupshiftitem.A
import cn.iocoder.yudao.module.system.dal.dataobject.attendance.punchrecord.AttendancePunchRecordDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.DeptDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dept.PostDO;
import cn.iocoder.yudao.module.system.dal.dataobject.dict.DictDataDO;
import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO;
import cn.iocoder.yudao.module.system.dal.mysql.attendance.group.AttendanceGroupMapper;
import cn.iocoder.yudao.module.system.dal.mysql.attendance.punchrecord.AttendancePunchRecordMapper;
@ -117,7 +118,8 @@ public class AttendanceServiceImpl implements AttendanceService {
@Resource
private BpmOAReplacementCardApi replacementCardApi;
@Resource
private BpmOALeaveApi leaveApi;
// 定义一些常量以提高代码的可读性和可维护性
/**
@ -1224,9 +1226,11 @@ public class AttendanceServiceImpl implements AttendanceService {
List<List<String>> data = new ArrayList<>();
// -- 根据部门分组 - 根据考勤组分组
Map<Long, List<AttendancePunchRecordDO>> userPunchMap = list.stream().collect(Collectors.groupingBy(AttendancePunchRecordDO::getUserId));
List<DictDataDO> bpmOaLeaveType = dictDataService.getDictDataList(CommonStatusEnum.ENABLE.getStatus(), "bpm_oa_leave_type");
//根据字典值分组
Map<String, String> leaveTypeMap = bpmOaLeaveType.stream().collect(Collectors.toMap(DictDataDO::getValue, DictDataDO::getLabel));
// 获取到这段时间请假的Ids
List<Long> leaveIds = list.stream().map(AttendancePunchRecordDO::getLeaveId).filter(Objects::nonNull).distinct().collect(Collectors.toList());
List<BpmOALeaveRpcVO> leaveRpcVOS = leaveApi.getLeaveListByIds(leaveIds).getCheckedData();
Map<Long, String> leaveTypeMap = leaveRpcVOS.stream().collect(Collectors.toMap(BpmOALeaveRpcVO::getId, BpmOALeaveRpcVO::getLeaveName));
//
// -- 先计算下要循环几次 - 一个用户一个部门一个考勤组一个班次一个日期 最大的打卡次数 -
Map<String, List<AttendancePunchRecordDO>> map = list.stream().collect(Collectors.groupingBy(
a -> a.getUserId() + "_"
@ -1275,7 +1279,7 @@ public class AttendanceServiceImpl implements AttendanceService {
for (Map.Entry<Long, List<AttendancePunchRecordDO>> groupShiftItemEntry : workMap.entrySet()) {
for (AttendancePunchRecordDO attendancePunchRecordDO : groupShiftItemEntry.getValue()) {
row.add(attendancePunchRecordDO.getPunchTime() == null ? "/" : attendancePunchRecordDO.getPunchTime().format(Constants.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND));
String statusStr = attendancePunchRecordDO.getStatus().equals(AttendanceOnTheDayDTO.ASK_FOR_LEAVE) ? "请假-" + leaveTypeMap.get(attendancePunchRecordDO.getLeaveType()) : this.statusToStr(attendancePunchRecordDO.getStatus());
String statusStr = attendancePunchRecordDO.getStatus().equals(AttendanceOnTheDayDTO.ASK_FOR_LEAVE) ? "请假-" + leaveTypeMap.get(attendancePunchRecordDO.getLeaveId()) : this.statusToStr(attendancePunchRecordDO.getStatus());
row.add(statusStr);
}
}