You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.3 KiB
XML

<?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.ErpTimesheetSummaryMapper">
<resultMap type="org.dromara.oa.erp.domain.vo.ErpTimesheetSummaryVo" id="ErpTimesheetSummaryResult">
</resultMap>
<select id="selectCustomErpTimesheetSummaryVoList" resultType="org.dromara.oa.erp.domain.vo.ErpTimesheetSummaryVo">
select t.*, d.dept_name, u.nick_name as leader_name
from erp_timesheet_summary t
left join sys_dept d on t.dept_id = d.dept_id and d.del_flag = '0'
left join sys_user u on d.leader = u.user_id and u.del_flag = '0'
${ew.getCustomSqlSegment}
</select>
<select id="selectProjectAggregation" resultType="org.dromara.oa.erp.domain.vo.ErpTimesheetSummaryDetailVo">
SELECT
i.user_id AS staffUserId,
u.nick_name AS staffName,
'1' AS isProject,
p.project_id AS originalProjectId,
p.project_code AS originalProjectCode,
p.project_name AS originalProjectName,
SUM(p.hours) AS originalHours
FROM erp_timesheet_info i
JOIN erp_timesheet_project p ON i.timesheet_id = p.timesheet_id
LEFT JOIN sys_user u ON i.user_id = u.user_id
WHERE i.dept_id = #{deptId}
AND i.timesheet_status = '3'
AND i.start_time &lt;= #{endDate}
AND i.end_time &gt;= #{startDate}
AND i.del_flag = '0' AND p.del_flag = '0'
GROUP BY i.user_id, u.nick_name, p.project_id, p.project_code, p.project_name
</select>
<select id="selectDeptAggregation" resultType="org.dromara.oa.erp.domain.vo.ErpTimesheetSummaryDetailVo">
SELECT
i.user_id AS staffUserId,
u.nick_name AS staffName,
'0' AS isProject,
SUM(d.hours) AS originalHours
FROM erp_timesheet_info i
JOIN erp_timesheet_dept d ON i.timesheet_id = d.timesheet_id
LEFT JOIN sys_user u ON i.user_id = u.user_id
WHERE i.dept_id = #{deptId}
AND i.timesheet_status = '3'
AND i.start_time &lt;= #{endDate}
AND i.end_time &gt;= #{startDate}
AND i.del_flag = '0' AND d.del_flag = '0'
GROUP BY i.user_id, u.nick_name
</select>
</mapper>