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

完善工时统计

parent 2df1d160
...@@ -108,8 +108,8 @@ ...@@ -108,8 +108,8 @@
<select id="selectListByMonth" resultMap="projectStatisticsByMonth"> <select id="selectListByMonth" resultMap="projectStatisticsByMonth">
select <if test="projectId == null">'合计' AS project_name,</if> <if test="projectId != null || projectIds != null"> project_name,'合计' AS dept_name,</if> group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,year(statistics_start) AS year, sum(total_time) AS total_time, sum(cost) AS cost select <if test="projectId == null and projectIds == null">'合计' AS project_name,</if> <if test="projectId != null"> project_name, dept_name,</if> <if test=" projectIds != null"> project_name, dept_name,</if> group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,year(statistics_start) AS year, sum(total_time) AS total_time, sum(cost) AS cost
from work_project_time_cost ptc join work_project p on ptc.project_id = p.id join work_dept d on ptc.dept_id = d.id from work_project_time_cost ptc join work_project p on ptc.project_id = p.id join work_dept d on p.dept_id = d.id
<where> <where>
<if test="projectId != null "> <if test="projectId != null ">
ptc.project_id = #{projectId} ptc.project_id = #{projectId}
...@@ -131,13 +131,13 @@ ...@@ -131,13 +131,13 @@
AND p.manager_id = #{managerId} AND year(statistics_start) = #{year} AND p.manager_id = #{managerId} AND year(statistics_start) = #{year}
</if> </if>
</where> </where>
group by <if test="projectId != null"> project_name,</if> year(statistics_start),MONTH(statistics_start) group by <if test="projectId != null and projectIds == null"> project_name,</if> <if test="projectId == null and projectIds != null"> project_name,dept_name,</if>year(statistics_start),MONTH(statistics_start)
</select> </select>
<select id="selectListStatistics" resultMap="projectStatisticsByMonth"> <select id="selectListStatistics" resultMap="projectStatisticsByMonth">
select ptc.project_id AS project_id, project_name, select ptc.project_id AS project_id, project_name,
group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,year(statistics_start) AS year, group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,year(statistics_start) AS year,
sum(total_time) AS total_time, sum(cost) AS cost <if test="projectId != null "> ,d.dept_name AS dept_name</if> <if test="projectIds != null">,d.dept_name AS dept_name,u.name </if> sum(total_time) AS total_time, sum(cost) AS cost <if test="projectId != null || (projectIds != null and !isAll)"> ,d.dept_name AS dept_name</if> <if test="projectIds != null and isAll">,d.dept_name AS dept_name,u.name AS user_name </if>
from work_project_time_cost ptc join work_project p on ptc.project_id = p.id join work_dept d on ptc.dept_id = d.id join work_user u on ptc.user_id = u.id from work_project_time_cost ptc join work_project p on ptc.project_id = p.id join work_dept d on ptc.dept_id = d.id join work_user u on ptc.user_id = u.id
<where> <where>
<if test="projectId != null "> <if test="projectId != null ">
...@@ -148,6 +148,7 @@ ...@@ -148,6 +148,7 @@
<foreach collection="projectIds" open="(" close=")" separator="," item="projectId"> <foreach collection="projectIds" open="(" close=")" separator="," item="projectId">
#{projectId} #{projectId}
</foreach> </foreach>
AND year(statistics_start) = #{year}
</if> </if>
<if test="deptId != null and managerId == null"> <if test="deptId != null and managerId == null">
AND p.dept_id = #{deptId} AND year(statistics_start) = #{year} AND p.dept_id = #{deptId} AND year(statistics_start) = #{year}
...@@ -159,7 +160,7 @@ ...@@ -159,7 +160,7 @@
AND p.manager_id = #{managerId} AND year(statistics_start) = #{year} AND p.manager_id = #{managerId} AND year(statistics_start) = #{year}
</if> </if>
</where> </where>
group by ptc.project_id,project_name,year(statistics_start),MONTH(statistics_start) <if test="projectId != null "> ,d.dept_name</if> <if test="projectIds != null">,d.dept_name AS dept_name,u.name </if> group by ptc.project_id,project_name,year(statistics_start),MONTH(statistics_start) <if test="projectId != null || (projectIds != null and !isAll) "> ,d.dept_name</if> <if test="projectIds != null and isAll">,d.dept_name ,u.name </if>
</select> </select>
......
...@@ -12,14 +12,14 @@ import cn.wisenergy.service.StatisticsService; ...@@ -12,14 +12,14 @@ import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkDeptService; import cn.wisenergy.service.WorkDeptService;
import cn.wisenergy.web.admin.controller.common.BaseController; import cn.wisenergy.web.admin.controller.common.BaseController;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType; import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder; import java.net.URLEncoder;
...@@ -156,11 +156,9 @@ public class StatisticsController extends BaseController { ...@@ -156,11 +156,9 @@ public class StatisticsController extends BaseController {
} }
} }
@ApiOperation(value = "导出项目工时统计", notes = "导出项目工时统计")
// @ApiImplicitParams({@ApiImplicitParam(name = "userId",value = "用户主键"),
// @ApiImplicitParam(name = "projectIds",value = "项目主键集合",allowMultiple = true)})
@GetMapping("/exportProjectStatistics") @GetMapping("/exportProjectStatistics")
public void exportProjectStatistics(Integer userId, Integer year, @ApiParam("projectIds") List<Integer> projectIds, HttpServletResponse response) { public void exportProjectStatistics(Integer userId, Integer year, @RequestParam("projectIds") List<Integer> projectIds, HttpServletResponse response) {
log.info("StatisticsController[]exportUserStatistics[]input.param" + userId + year + projectIds); log.info("StatisticsController[]exportUserStatistics[]input.param" + userId + year + projectIds);
// 获取excel // 获取excel
HSSFWorkbook sheets = statisticsService.exportProjectStatistics(userId, year, projectIds); HSSFWorkbook sheets = statisticsService.exportProjectStatistics(userId, year, projectIds);
......
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