package cn.iocoder.yudao.module.hrm.api.workhour;
|
|
import cn.iocoder.yudao.module.hrm.api.workhour.dto.HrmWorkHourSummaryRespDTO;
|
import cn.iocoder.yudao.module.hrm.dal.dataobject.employee.HrmEmployeeDO;
|
import cn.iocoder.yudao.module.hrm.dal.dataobject.workhour.HrmWorkHourSummaryDO;
|
import cn.iocoder.yudao.module.hrm.dal.mysql.workhour.HrmWorkHourSummaryMapper;
|
import cn.iocoder.yudao.module.hrm.service.employee.HrmEmployeeService;
|
import cn.iocoder.yudao.module.system.api.dept.DeptApi;
|
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
|
import jakarta.annotation.Resource;
|
import org.springframework.stereotype.Service;
|
|
import java.util.List;
|
|
/**
|
* 月度工时汇总 API 实现
|
*
|
* @author 超级管理员
|
*/
|
@Service
|
public class HrmWorkHourSummaryApiImpl implements HrmWorkHourSummaryApi {
|
|
@Resource
|
private HrmWorkHourSummaryMapper workHourSummaryMapper;
|
@Resource
|
private HrmEmployeeService employeeService;
|
@Resource
|
private DeptApi deptApi;
|
|
@Override
|
public List<HrmWorkHourSummaryRespDTO> getSummaryByPeriod(String period) {
|
return workHourSummaryMapper.selectListByPeriod(period).stream()
|
.map(this::convert)
|
.toList();
|
}
|
|
@Override
|
public HrmWorkHourSummaryRespDTO getSummaryByEmployeeAndPeriod(Long employeeId, String period) {
|
HrmWorkHourSummaryDO summary = workHourSummaryMapper.selectByEmployeeIdAndPeriod(employeeId, period);
|
return summary == null ? null : convert(summary);
|
}
|
|
private HrmWorkHourSummaryRespDTO convert(HrmWorkHourSummaryDO summary) {
|
HrmWorkHourSummaryRespDTO dto = new HrmWorkHourSummaryRespDTO();
|
dto.setEmployeeId(summary.getEmployeeId());
|
dto.setDeptId(summary.getDeptId());
|
dto.setPeriod(summary.getPeriod());
|
dto.setWorkDays(summary.getWorkDays());
|
dto.setWorkHours(summary.getWorkHours());
|
dto.setOvertimeHours(summary.getOvertimeHours());
|
HrmEmployeeDO employee = employeeService.getEmployee(summary.getEmployeeId());
|
if (employee != null) {
|
dto.setEmployeeNo(employee.getEmployeeNo());
|
dto.setEmployeeName(employee.getName());
|
}
|
if (summary.getDeptId() != null) {
|
DeptRespDTO dept = deptApi.getDept(summary.getDeptId());
|
if (dept != null) {
|
dto.setDeptName(dept.getName());
|
}
|
}
|
return dto;
|
}
|
|
}
|