Commit f8dd35c0 authored by nie'hong's avatar nie'hong

完善项目工时统计

parent ed34748f
......@@ -26,6 +26,8 @@ public interface WorkProjectMapper extends BaseMapper<WorkProject> {
*/
List<WorkProject> getProjectsByCriteria(Map<String, Object> map);
/**
* 获取项目
* @param ids 项目id
......@@ -47,4 +49,6 @@ public interface WorkProjectMapper extends BaseMapper<WorkProject> {
int updateIsConclusionById(Integer id);
int updateProject(ModifyProjectVo modifyProjectVo);
List<WorkProject> getListByDeptAndIsConclusion(@Param("deptId") Integer deptId,@Param("isConclusion") Integer isConclusion);
}
......@@ -93,14 +93,18 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/**
* 获取人员项目工时
*/
List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("projectIds") List<Integer> projectIds, @Param("userIds") List<Integer> userIds);
List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("projectIds") List<Integer> projectIds, @Param("isAll") Boolean isAll);
/**
* 根据工单状态获取填报条数
*
* @param userId
* @param firstDayOfMonth
* @param status
* @return
*/
List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth,@Param("status") Integer[] status);
List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth, @Param("status") Integer[] status);
List<UserWorkTimeStatisticsByProject> selectListByType(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("isConclusion") Integer isConclusion, @Param("queryType") List<Integer> queryType, @Param("userIds") List<Integer> userIds, @Param("isAll") Boolean isAll);
}
......@@ -161,4 +161,11 @@ ORDER BY p.is_conclusion DESC
</select>
<select id="getListByDeptAndIsConclusion" resultType="cn.wisenergy.model.app.WorkProject">
select <include refid="Base_Column_List"/>
from <include refid="table"/>
where dept=#{deptId} AND isConclusion=#{isConclusion}
</select>
</mapper>
......@@ -28,6 +28,7 @@
<result property="projectId" column="project_id"/>
<result property="projectType" column="project_type"/>
<result property="projectName" column="project_name"/>
<result property="projectTypeName" column="type_name"/>
<result property="isOvertime" column="is_overtime"/>
<result property="workTime" column="work_time"/>
</collection>
......@@ -297,7 +298,7 @@
<select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject">
SELECT u.id AS user_id, u.`name` AS user_name, t.project_id AS project_id, t.type AS project_type, p.project_name AS project_name, case t.is_overtime when 1 then '加班' ELSE '正常' end AS is_overtime,SUM(t.work_time) AS work_time
SELECT <if test="isAll == true"> u.id AS user_id, u.`name` AS user_name,</if> <if test="isAll == false">'合计' AS user_name ,</if> t.project_id AS project_id, t.type AS project_type, p.project_name AS project_name, case t.is_overtime when 1 then '加班' ELSE '正常' end AS is_overtime,SUM(t.work_time) AS work_time
from work_time_order t left join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id
where
t.status in (2,5) AND
......@@ -308,25 +309,11 @@
<if test="startDate != null">
AND t.work_day > #{startDate}
</if>
<if test="projectIds != null">
AND project_id in
<foreach collection="projectIds" item="projectId" open="(" close=")" separator=",">
#{projectId}
</foreach>
</if>
GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime
<if test="userIds != null">
UNION
SELECT u.id AS user_id ,u.`name` AS user_name, t.project_id AS project_id,t.type AS project_type
,p.project_name AS project_name, case t.is_overtime when 1 then '加班' ELSE '正常' end AS is_overtime,SUM(t.work_time) AS work_time
from work_time_order t left join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id
where
t.status in (2,5) AND t.type in(5,6,7) AND t.user_id in
<foreach collection="userIds" item="userId" separator="," open="(" close=")" >
#{userId}
</foreach>
GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime
</if>
AND project_id in
<foreach collection="projectIds" item="projectId" open="(" close=")" separator=",">
#{projectId}
</foreach>
GROUP BY <if test="isAll == true"> u.id,u.`name`,</if>t.project_id,t.type,p.project_name, t.is_overtime
</select>
<select id="selectCountByTypeAndStatus" resultType="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics">
......@@ -338,4 +325,27 @@
</foreach>
GROUP BY type
</select>
<select id="selectListByType" resultMap="userWorkTimeStatisticsByProject">
SELECT <if test="isAll == true"> u.id AS user_id, u.`name` AS user_name,</if> <if test="isAll == false"> '合计' AS user_name,</if> ty.id AS project_type, ty.name AS project_name, case t.is_overtime when 1 then '加班' ELSE '正常' end AS is_overtime,IFNULL(SUM(t.work_time),0) AS work_time
from work_type ty left join work_time_order t on t.type = ty.id left join work_user u on t.user_id = u.id
where
(t.work_day &lt;= #{endDate} or t.work_day is null) AND (t.status IN (2, 5) or t.status is null)
<if test="isConclusion != null">
AND (p.is_conclusion = #{isConclusion} or p.is_conclusion is null)
</if>
<if test="startDate != null">
AND (t.work_day > #{startDate} or t.work_day is null)
</if>
AND ty.id in
<foreach collection="queryType" item="type" open="(" close=")" separator=",">
#{type}
</foreach>
AND (t.user_id in
<foreach collection="userIds" item="userId" open="(" close=")" separator=",">
#{userId}
</foreach>
or t.user_id is null)
GROUP BY <if test="isAll == true">u.id,u.`name`,</if> ty.id,ty.name, t.is_overtime
</select>
</mapper>
......@@ -49,10 +49,10 @@ public interface StatisticsService {
*
* @param startDate
* @param endDate
* @param status
* @param isConclusion
* @return
*/
List<UserWorkTimeStatisticsByProject> getUserWorkTimeStatisticsReport(Integer userId, String startDate, String endDate, Integer status);
List<UserWorkTimeStatisticsByProject> getUserWorkTimeStatisticsReport(Integer userId, Integer deptId, String startDate, String endDate, Integer isConclusion);
/**
* 获取项目统计
......
......@@ -70,4 +70,6 @@ public interface WorkProjectService {
Boolean modifyProject(ModifyProjectVo modifyProjectVo);
Boolean addProject(CreateProjectVo createProjectVo);
}
......@@ -75,12 +75,12 @@ public class StatisticsController extends BaseController {
@ApiOperation(value = "获取本月工时统计和审核统计", notes = "获取本月", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户主键", dataType = "int", required = true)
@GetMapping("/getMonthlyWorkingHours")
public Result<Map<String,Object>> getMonthlyWorkingHours(Integer userId) {
public Result<Map<String, Object>> getMonthlyWorkingHours(Integer userId) {
log.info("WorkOrderController[]getMonthlyWorkingHours[]input.param" + userId);
if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
}
Map<String,Object> monthlyStatistics = statisticsService.getMonthlyStatistics(userId);
Map<String, Object> monthlyStatistics = statisticsService.getMonthlyStatistics(userId);
return getResult(monthlyStatistics);
}
......@@ -115,15 +115,15 @@ public class StatisticsController extends BaseController {
@ApiOperation(value = "获取人员工时统计报表", notes = "获取人员工时统计报表")
@GetMapping("/getUserWorkTimeStatisticsReport")
public Result<List<UserWorkTimeStatisticsByProject>> getUserWorkTimeStatisticsReport(Integer userId, String startDate, String endDate, Integer status) {
log.info("StatisticsController[]getUserWorkTimeStatisticsReport[]input.param{}" + userId, startDate, endDate, status);
List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjects = statisticsService.getUserWorkTimeStatisticsReport(userId, startDate, endDate, status);
public Result<List<UserWorkTimeStatisticsByProject>> getUserWorkTimeStatisticsReport(Integer userId, Integer deptId, String startDate, String endDate, Integer isConclusion) {
log.info("StatisticsController[]getUserWorkTimeStatisticsReport[]input.param{}" + userId, deptId, startDate, endDate, isConclusion);
List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsByProjects = statisticsService.getUserWorkTimeStatisticsReport(userId,deptId, startDate, endDate, isConclusion);
return getResult(userWorkTimeStatisticsByProjects);
}
@ApiOperation(value = "获取项目统计报表", notes = "获取项目统计报表")
@GetMapping("/getProjectStatistics")
public Result<List<ProjectStatisticsByMonth>> getProjectStatistics(Integer userId, Integer deptId,Integer year, Integer projectId) {
public Result<List<ProjectStatisticsByMonth>> getProjectStatistics(Integer userId, Integer deptId, Integer year, Integer projectId) {
log.info("StatisticsController[]getProjectStatistics[]input.param" + userId + deptId + year, projectId);
List<ProjectStatisticsByMonth> projectStatisticsByMonths = statisticsService.getProjectStatistics(userId, deptId, year, projectId);
return getResult(projectStatisticsByMonths);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment