feat(erp/TimesheetInfo): 添加工时填报中的部门信息显示
- 在工时填报查询中增加部门名称字段 - 修改数据库查询语句添加部门表关联 - 更新视图对象添加部门名称属性 - 配置部门名称导出到Excel功能dev
parent
6560c1346f
commit
9dcbb9e3ee
@ -0,0 +1,75 @@
|
|||||||
|
package org.dromara.oa.erp.domain.vo;
|
||||||
|
|
||||||
|
import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
|
||||||
|
import cn.idev.excel.annotation.ExcelProperty;
|
||||||
|
import cn.idev.excel.annotation.write.style.ColumnWidth;
|
||||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat;
|
||||||
|
import org.dromara.common.excel.convert.ExcelDictConvert;
|
||||||
|
import lombok.Data;
|
||||||
|
import java.io.Serial;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目工时统计报表 VO
|
||||||
|
*
|
||||||
|
* @author Yangk
|
||||||
|
* @date 2025-12-26
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ColumnWidth(20)
|
||||||
|
@ExcelIgnoreUnannotated
|
||||||
|
public class ProjectManHourReportVo implements Serializable {
|
||||||
|
|
||||||
|
@Serial
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目ID
|
||||||
|
*/
|
||||||
|
private Long projectId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 部门名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "部门")
|
||||||
|
private String deptName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目经理姓名
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "项目经理")
|
||||||
|
private String managerName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目名称
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "项目名称")
|
||||||
|
private String projectName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目编号
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "项目编号")
|
||||||
|
private String projectCode;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目类别
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "项目类别", converter = ExcelDictConvert.class)
|
||||||
|
@ExcelDictFormat(dictType = "project_category")
|
||||||
|
private String projectCategory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 当月/指定时间段工时
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "当月工时")
|
||||||
|
private BigDecimal totalHours;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 跨部门工时
|
||||||
|
*/
|
||||||
|
@ExcelProperty(value = "跨部门工时")
|
||||||
|
private BigDecimal crossDeptHours;
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,29 @@
|
|||||||
|
package org.dromara.oa.erp.mapper;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
import org.dromara.oa.erp.domain.vo.ProjectManHourReportVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目工时统计报表 Mapper
|
||||||
|
*
|
||||||
|
* @author Yangk
|
||||||
|
* @date 2025-12-26
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface ErpTimesheetReportMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询项目工时统计列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
List<ProjectManHourReportVo> selectProjectManHourList(@Param("bo") ProjectManHourReportVo bo,
|
||||||
|
@Param("startTime") String startTime,
|
||||||
|
@Param("endTime") String endTime);
|
||||||
|
}
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
package org.dromara.oa.erp.service;
|
||||||
|
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.oa.erp.domain.vo.ProjectManHourReportVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工时报表 Service 接口
|
||||||
|
*
|
||||||
|
* @author Yangk
|
||||||
|
* @date 2025-12-26
|
||||||
|
*/
|
||||||
|
public interface IErpTimesheetReportService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询项目工时统计列表
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
TableDataInfo<ProjectManHourReportVo> queryProjectManHourList(ProjectManHourReportVo bo, String startTime,
|
||||||
|
String endTime);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询所有项目工时统计 (导出用)
|
||||||
|
*
|
||||||
|
* @param bo 查询条件
|
||||||
|
* @param startTime 开始时间
|
||||||
|
* @param endTime 结束时间
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
List<ProjectManHourReportVo> queryProjectManHourAll(ProjectManHourReportVo bo, String startTime, String endTime);
|
||||||
|
}
|
||||||
@ -0,0 +1,39 @@
|
|||||||
|
package org.dromara.oa.erp.service.impl;
|
||||||
|
|
||||||
|
import com.github.yulichang.toolkit.JoinWrappers;
|
||||||
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||||
|
import org.dromara.oa.erp.domain.vo.ProjectManHourReportVo;
|
||||||
|
import org.dromara.oa.erp.mapper.ErpTimesheetReportMapper;
|
||||||
|
import org.dromara.oa.erp.service.IErpTimesheetReportService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工时报表 Service 实现
|
||||||
|
*
|
||||||
|
* @author Yangk
|
||||||
|
* @date 2025-12-26
|
||||||
|
*/
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
@Service
|
||||||
|
public class ErpTimesheetReportServiceImpl implements IErpTimesheetReportService {
|
||||||
|
|
||||||
|
private final ErpTimesheetReportMapper reportMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TableDataInfo<ProjectManHourReportVo> queryProjectManHourList(ProjectManHourReportVo bo, String startTime,
|
||||||
|
String endTime) {
|
||||||
|
List<ProjectManHourReportVo> list = reportMapper.selectProjectManHourList(bo, startTime, endTime);
|
||||||
|
return TableDataInfo.build(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<ProjectManHourReportVo> queryProjectManHourAll(ProjectManHourReportVo bo, String startTime,
|
||||||
|
String endTime) {
|
||||||
|
return reportMapper.selectProjectManHourList(bo, startTime, endTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -0,0 +1,60 @@
|
|||||||
|
<?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.oa.erp.mapper.ErpTimesheetReportMapper">
|
||||||
|
|
||||||
|
<select id="selectProjectManHourList" resultType="org.dromara.oa.erp.domain.vo.ProjectManHourReportVo">
|
||||||
|
SELECT
|
||||||
|
t_dept.dept_name,
|
||||||
|
u.nick_name AS manager_name,
|
||||||
|
p.project_id,
|
||||||
|
p.project_name,
|
||||||
|
p.project_code,
|
||||||
|
p.project_category,
|
||||||
|
COALESCE(SUM(tp.hours), 0) AS total_hours,
|
||||||
|
<!-- 计算该项目的总工时,用于最后一列展示 -->
|
||||||
|
SUM(SUM(tp.hours)) OVER(PARTITION BY p.project_id) AS cross_dept_hours
|
||||||
|
FROM
|
||||||
|
erp_project_info p
|
||||||
|
LEFT JOIN sys_user u ON p.manager_id = u.user_id
|
||||||
|
<!-- 关联工时明细 -->
|
||||||
|
LEFT JOIN erp_timesheet_project tp ON p.project_id = tp.project_id AND tp.del_flag = '0'
|
||||||
|
<!-- 关联工时主表以获取日期和人员(从而获取填报部门) -->
|
||||||
|
LEFT JOIN erp_timesheet_info ti ON tp.timesheet_id = ti.timesheet_id AND ti.del_flag = '0'
|
||||||
|
<!-- 关联填报部门 -->
|
||||||
|
LEFT JOIN sys_dept t_dept ON ti.dept_id = t_dept.dept_id
|
||||||
|
<!-- 关联项目所属部门,用于部门筛选 -->
|
||||||
|
LEFT JOIN sys_dept p_dept ON p.dept_id = p_dept.dept_id
|
||||||
|
<where>
|
||||||
|
p.del_flag = '0'
|
||||||
|
<if test="bo.projectName != null and bo.projectName != ''">
|
||||||
|
AND p.project_name LIKE concat('%', #{bo.projectName}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="bo.projectCode != null and bo.projectCode != ''">
|
||||||
|
AND p.project_code LIKE concat('%', #{bo.projectCode}, '%')
|
||||||
|
</if>
|
||||||
|
<if test="bo.projectCategory != null and bo.projectCategory != ''">
|
||||||
|
AND p.project_category = #{bo.projectCategory}
|
||||||
|
</if>
|
||||||
|
<if test="bo.deptName != null and bo.deptName != ''">
|
||||||
|
AND t_dept.dept_name LIKE concat('%', #{bo.deptName}, '%')
|
||||||
|
</if>
|
||||||
|
|
||||||
|
<!-- 日期范围筛选 -->
|
||||||
|
<if test="startTime != null and startTime != ''">
|
||||||
|
AND ti.start_time >= #{startTime}
|
||||||
|
</if>
|
||||||
|
<if test="endTime != null and endTime != ''">
|
||||||
|
AND ti.end_time <= #{endTime}
|
||||||
|
</if>
|
||||||
|
<!-- 仅统计已审批的工时 (3=已审批) -->
|
||||||
|
AND ti.timesheet_status = '3'
|
||||||
|
</where>
|
||||||
|
<!-- 按项目ID 和 填报部门ID 分组 -->
|
||||||
|
GROUP BY p.project_id, ti.dept_id
|
||||||
|
<!-- 仅显示有工时的记录 -->
|
||||||
|
HAVING SUM(tp.hours) > 0
|
||||||
|
ORDER BY p.project_code, t_dept.dept_id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue