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

优化

parent c2fd5480
...@@ -3,6 +3,7 @@ package cn.wisenergy.mapper; ...@@ -3,6 +3,7 @@ package cn.wisenergy.mapper;
import cn.wisenergy.model.app.WorkTimeOrder; import cn.wisenergy.model.app.WorkTimeOrder;
import cn.wisenergy.model.dto.DayWorkTimeAndType; import cn.wisenergy.model.dto.DayWorkTimeAndType;
import cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics; import cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics;
import cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject;
import cn.wisenergy.model.dto.WorkTimeAndCostCollect; import cn.wisenergy.model.dto.WorkTimeAndCostCollect;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -24,21 +25,22 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -24,21 +25,22 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
/** /**
* 功能:获取某个月的数据 * 功能:获取某个月的数据
*
* @param userId * @param userId
* @param workMonth * @param workMonth
* @return * @return
*/ */
List<WorkTimeOrder> geByMonth(@Param("userId")Integer userId,@Param("workMonth") Date workMonth ,@Param("status")Integer status); List<WorkTimeOrder> geByMonth(@Param("userId") Integer userId, @Param("workMonth") Date workMonth, @Param("status") Integer status);
List<WorkTimeOrder> getByDay(@Param("userId") Integer userId,@Param("workDay") Date workDay); List<WorkTimeOrder> getByDay(@Param("userId") Integer userId, @Param("workDay") Date workDay);
int save(WorkTimeOrder workTimeOrder); int save(WorkTimeOrder workTimeOrder);
int updateByIds(@Param("reviewerId") Integer reviewerId, @Param("ids") List<Integer> ids); int updateByIds(@Param("reviewerId") Integer reviewerId, @Param("ids") List<Integer> ids);
int updateStatusById(@Param("reviewerId") Integer reviewerId,@Param("id") Integer id,@Param("reason") String reason); int updateStatusById(@Param("reviewerId") Integer reviewerId, @Param("id") Integer id, @Param("reason") String reason);
List<WorkTimeOrder> queryByPage(@Param("status") Integer status, @Param("projectId")Integer projectId, @Param("type")Integer type,@Param("deptId") Integer deptId); List<WorkTimeOrder> queryByPage(@Param("status") Integer status, @Param("projectId") Integer projectId, @Param("type") Integer type, @Param("deptId") Integer deptId);
/** /**
* 根据填报项目类型获取次数和工时汇总 * 根据填报项目类型获取次数和工时汇总
...@@ -67,18 +69,30 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -67,18 +69,30 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> {
*/ */
Integer getCountByCondition(Map<String, Object> map); Integer getCountByCondition(Map<String, Object> map);
/**
* 获取项目或商机的成本
*
* @param projectIds
* @param firstDayOfMonth
* @return
*/
List<WorkTimeAndCostCollect> getWorkTimeAndCostCollect(@Param("projectIds") List<Integer> projectIds, @Param("firstDayOfMonth") String firstDayOfMonth); List<WorkTimeAndCostCollect> getWorkTimeAndCostCollect(@Param("projectIds") List<Integer> projectIds, @Param("firstDayOfMonth") String firstDayOfMonth);
/** /**
* 获取上班日期集合 * 获取上班日期集合
*
* @param firstDayOfMonth * @param firstDayOfMonth
* @return * @return
*/ */
List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth,@Param("userId") Integer userId); List<Date> getDaysByDateAndStatus(@Param("firstDayOfMonth") Date firstDayOfMonth, @Param("userId") Integer userId);
List<WorkTimeOrder> getAutoOrder(Integer autoExamine); List<WorkTimeOrder> getAutoOrder(Integer autoExamine);
int updateAutoExamine(@Param("workIds") List<Integer> workIds); int updateAutoExamine(@Param("workIds") List<Integer> workIds);
/**
* 获取人员项目工时
*/
List<UserWorkTimeStatisticsByProject> getUserProjectWorkTimeStatistics(@Param("startDate") String startDate, @Param("endDate") String endDate, @Param("status") Integer status, @Param("projectIds") List<Integer> projectIds);
} }
...@@ -4,21 +4,33 @@ ...@@ -4,21 +4,33 @@
<!-- 通用查询映射结果 --> <!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkTimeOrder"> <resultMap id="BaseResultMap" type="cn.wisenergy.model.app.WorkTimeOrder">
<id column="work_id" property="workId" /> <id column="work_id" property="workId"/>
<result column="user_id" property="userId" /> <result column="user_id" property="userId"/>
<result column="project_id" property="projectId" /> <result column="project_id" property="projectId"/>
<result column="dept_id" property="deptId" /> <result column="dept_id" property="deptId"/>
<result column="work_time" property="workTime" /> <result column="work_time" property="workTime"/>
<result column="work_day" property="workDay" /> <result column="work_day" property="workDay"/>
<result column="status" property="status" /> <result column="status" property="status"/>
<result column="reviewer_id" property="reviewerId" /> <result column="reviewer_id" property="reviewerId"/>
<result column="des" property="des" /> <result column="des" property="des"/>
<result column="reason" property="reason" /> <result column="reason" property="reason"/>
<result column="type" property="type" /> <result column="type" property="type"/>
<result column="is_overtime" property="isOvertime" /> <result column="is_overtime" property="isOvertime"/>
<result column="reject_time" property="rejectTime" /> <result column="reject_time" property="rejectTime"/>
<result column="create_time" property="createTime" /> <result column="create_time" property="createTime"/>
<result column="modify_time" property="modifyTime" /> <result column="modify_time" property="modifyTime"/>
</resultMap>
<resultMap id="userWorkTimeStatisticsByProject" type="cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject">
<result property="userId" column="user_id"/>
<result property="userName" column="user_name"/>
<collection property="projectWorkTimeAndType" ofType="cn.wisenergy.model.dto.ProjectWorkTimeAndType">
<result property="projectId" column="project_id"/>
<result property="projectType" column="project_type"/>
<result property="projectName" column="project_name"/>
<result property="isOvertime" column="is_overtime"/>
<result property="workTime" column="work_time"/>
</collection>
</resultMap> </resultMap>
...@@ -36,7 +48,7 @@ ...@@ -36,7 +48,7 @@
<if test="projectId != null">and project_id =#{projectId}</if> <if test="projectId != null">and project_id =#{projectId}</if>
<if test="deptId != null">and dept_id = #{deptId}</if> <if test="deptId != null">and dept_id = #{deptId}</if>
<if test="workTime != null">and work_time = #{workTime}</if> <if test="workTime != null">and work_time = #{workTime}</if>
<if test="workDay != null">and work_day = #{workDay}</if> <if test="workDay != null">and work_day = #{workDay}</if>
<if test=" status != null">and `status` = #{status}</if> <if test=" status != null">and `status` = #{status}</if>
<if test=" reviewerId != null">and reviewer_id = #{reviewerId}</if> <if test=" reviewerId != null">and reviewer_id = #{reviewerId}</if>
<if test="des != null">and des =#{des}</if> <if test="des != null">and des =#{des}</if>
...@@ -64,7 +76,7 @@ ...@@ -64,7 +76,7 @@
work_time_order work_time_order
</sql> </sql>
<insert id="save" keyProperty="workId" useGeneratedKeys="true"> <insert id="save" keyProperty="workId" useGeneratedKeys="true">
insert into insert into
<include refid="table"/> <include refid="table"/>
(<include refid="cols_exclude_id"/>) (<include refid="cols_exclude_id"/>)
...@@ -95,7 +107,7 @@ ...@@ -95,7 +107,7 @@
UPDATE UPDATE
<include refid="table"/> <include refid="table"/>
SET status = 5,modify_time=now() SET status = 5,modify_time=now()
<where> work_id IN <where>work_id IN
<foreach collection="workIds" item="id" open="(" close=")" separator=","> <foreach collection="workIds" item="id" open="(" close=")" separator=",">
#{id} #{id}
</foreach> </foreach>
...@@ -104,15 +116,17 @@ ...@@ -104,15 +116,17 @@
<select id="getByDay" resultType="cn.wisenergy.model.app.WorkTimeOrder"> <select id="getByDay" resultType="cn.wisenergy.model.app.WorkTimeOrder">
SELECT <include refid="Base_Column_List"/> SELECT
FROM <include refid="table"/> <include refid="Base_Column_List"/>
FROM
<include refid="table"/>
<where> <where>
<if test="null !=userId"> <if test="null !=userId">
<if test="null != userId"> <if test="null != userId">
AND user_id = #{userId} AND user_id = #{userId}
</if> </if>
<if test="null != workDay"> <if test="null != workDay">
AND DATE_FORMAT(work_day, '%Y%m%d') = DATE_FORMAT(#{workDay} ,'%Y%m%d') AND DATE_FORMAT(work_day, '%Y%m%d') = DATE_FORMAT(#{workDay} ,'%Y%m%d')
</if> </if>
</if> </if>
</where> </where>
...@@ -125,13 +139,13 @@ ...@@ -125,13 +139,13 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="null != projectId"> <if test="null != projectId">
AND project_id = #{projectId} AND project_id = #{projectId}
</if> </if>
<if test="null != status"> <if test="null != status">
AND status = #{status} AND status = #{status}
</if> </if>
<if test="null != type"> <if test="null != type">
AND type = #{type} AND type = #{type}
</if> </if>
<if test="null != type"> <if test="null != type">
AND dept_id = #{deptId} AND dept_id = #{deptId}
...@@ -146,26 +160,30 @@ ...@@ -146,26 +160,30 @@
</sql> </sql>
<select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics"> <select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics">
select CASE WHEN type= 1 THEN "项目" WHEN type= 2 THEN "商机" END AS type, count(1),sum(work_time) select CASE WHEN type = 1 THEN "项目" WHEN type = 2 THEN "商机" END AS type, count(1),sum(work_time)
from <include refid="table"/> from
<include refid="table"/>
where user_id = #{userId} AND type in (1,2) AND work_day >= #{currentMonthFirstDay} where user_id = #{userId} AND type in (1,2) AND work_day >= #{currentMonthFirstDay}
group by type group by type
</select> </select>
<select id="listByDateAndUserId" resultMap="dayWorkTimeAndType"> <select id="listByDateAndUserId" resultMap="dayWorkTimeAndType">
select user_id,day(work_day),CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else "正常" end AS `type`, sum(work_time) select user_id,day(work_day),CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else "正常" end AS `type`,
from <include refid="table"/> sum(work_time)
where year(work_day) = #{year} AND month(work_day) = #{month} AND (status = 2 OR status=5)AND user_id IN from
<foreach collection="userIds" separator="," close=")" item="userId" open="("> <include refid="table"/>
#{userId} where year(work_day) = #{year} AND month(work_day) = #{month} AND (status = 2 OR status=5)AND user_id IN
</foreach> <foreach collection="userIds" separator="," close=")" item="userId" open="(">
group by user_id,day(work_day), CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else "正常" end #{userId}
order by day(work_day) </foreach>
group by user_id,day(work_day), CASE when `type` = 3 then "请假" when `type` = 4 then "调休" else "正常" end
order by day(work_day)
</select> </select>
<select id="getCountByCondition" resultType="integer" parameterType="map"> <select id="getCountByCondition" resultType="integer" parameterType="map">
select count(1) select count(1)
from <include refid="table"/> from
<include refid="table"/>
<where> <where>
<include refid="criteria"/> <include refid="criteria"/>
<if test="startDay != null"> <if test="startDay != null">
...@@ -179,7 +197,8 @@ ...@@ -179,7 +197,8 @@
</if> </if>
<if test="statusArray != null"> <if test="statusArray != null">
AND `status` IN AND `status` IN
<foreach collection="statusArray" item="workStatus" open="(" close=")" separator=",">#{workStatus}</foreach> <foreach collection="statusArray" item="workStatus" open="(" close=")" separator=",">#{workStatus}
</foreach>
</if> </if>
<if test="typeArray != null"> <if test="typeArray != null">
AND `type` IN AND `type` IN
...@@ -190,10 +209,13 @@ ...@@ -190,10 +209,13 @@
</where> </where>
</select> </select>
<select id="getWorkTimeAndCostCollect" resultType="cn.wisenergy.model.dto.WorkTimeAndCostCollect" parameterType="integer"> <select id="getWorkTimeAndCostCollect" resultType="cn.wisenergy.model.dto.WorkTimeAndCostCollect"
select CASE WHEN t.type= 1 THEN "项目" WHEN t.type= 2 THEN "商机" END AS type,t.dept_id, t.project_id,MIN(t.work_day) AS firstTime,MAX(t.work_day) AS lastTime,SUM(t.work_time)/8 AS totalTime,(SUM(t.work_time))/8*10 AS cost,dept_name AS deptName,project_name AS projectName parameterType="integer">
select CASE WHEN t.type= 1 THEN "项目" WHEN t.type= 2 THEN "商机" END AS type,t.dept_id,
t.project_id,MIN(t.work_day) AS firstTime,MAX(t.work_day) AS lastTime,SUM(t.work_time)/8 AS
totalTime,(SUM(t.work_time))/8*10 AS cost,dept_name AS deptName,project_name AS projectName
from work_time_order t JOIN work_dept d ON t.dept_id=d.id from work_time_order t JOIN work_dept d ON t.dept_id=d.id
JOIN work_project p ON t.project_id=p.id JOIN work_project p ON t.project_id=p.id
where status IN (2,5) AND t.type IN (1,2) AND project_id IN where status IN (2,5) AND t.type IN (1,2) AND project_id IN
<foreach collection="projectIds" item="projectId" open="(" close=")" separator=","> <foreach collection="projectIds" item="projectId" open="(" close=")" separator=",">
#{projectId} #{projectId}
...@@ -204,9 +226,10 @@ ...@@ -204,9 +226,10 @@
group by t.type,dept_id, project_id,dept_name,project_name group by t.type,dept_id, project_id,dept_name,project_name
</select> </select>
<select id="getDaysByDateAndStatus" resultType="date" > <select id="getDaysByDateAndStatus" resultType="date">
select distinct(work_day) select distinct(work_day)
from <include refid="table"/> from
<include refid="table"/>
where work_day >= #{firstDayOfMonth} AND user_id = #{userId} where work_day >= #{firstDayOfMonth} AND user_id = #{userId}
</select> </select>
<select id="geByMonth" resultType="cn.wisenergy.model.app.WorkTimeOrder"> <select id="geByMonth" resultType="cn.wisenergy.model.app.WorkTimeOrder">
...@@ -227,7 +250,6 @@ ...@@ -227,7 +250,6 @@
</where> </where>
</select> </select>
<select id="getAutoOrder" resultType="cn.wisenergy.model.app.WorkTimeOrder"> <select id="getAutoOrder" resultType="cn.wisenergy.model.app.WorkTimeOrder">
select select
...@@ -236,9 +258,25 @@ ...@@ -236,9 +258,25 @@
<include refid="table"/> <include refid="table"/>
<where> <where>
status IN (1,4) status IN (1,4)
AND TIMESTAMPDIFF(HOUR,modify_time,now()) > #{autoExamine} AND TIMESTAMPDIFF(HOUR,modify_time,now()) > #{autoExamine}
</where> </where>
</select> </select>
<select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject">
SELECT u.id AS user_id ,u.`name` AS user_name, t.project_id AS project_id
,case t.type when 1 then '项目' when 2 then '商机' when 5 then '外部商务/技术交流' when 6 then '内部培训/技术准备/管理' when 7 then '其他非项目/商机工作' end 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 join work_project p on t.project_id = p.id join work_user u on t.user_id = u.id
where DATE(t.work_day) > #{startDate} AND DATE(t.work_day) &lt; #{endDate} AND p.is_conclusion=#{status} AND t.type not in(3,4)
<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
</select>
</mapper> </mapper>
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "ProjectWorkTimeAndType", description = "人员工时统计中存储项目和工时信息")
public class ProjectWorkTimeAndType{
/**
* 项目编号
*/
@ApiModelProperty(name = "projectId", value = "项目编号")
private Integer projectId;
/**
* 项目名称
*/
@ApiModelProperty(name = "projectName", value = "项目名称")
private String projectName;
/**
* 项目类型
*/
@ApiModelProperty(name = "projectType", value = "项目类型")
private String projectType;
/**
* 是否加班
*/
@ApiModelProperty(name = "isOvertime", value = "是否加班")
private String isOvertime;
/**
* 总工时
*/
@ApiModelProperty(name = "workTime", value = "总工时")
private String workTime;
}
\ No newline at end of file
package cn.wisenergy.model.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @description: 用户的项目工时统计
* @author: nh
* @create: 2021-02-03 15:45
**/
@Data
@ApiModel(value = "UserWorkTimeStatisticsByProject",description = "用户参与正在进行的项目工时统计")
public class UserWorkTimeStatisticsByProject implements Serializable {
private static final long serialVersionUID = -4059589583836766681L;
/**
* 用户主键
*/
@ApiModelProperty(name = "userId",value = "用户主键")
private Integer userId;
/**
* 用户名
*/
@ApiModelProperty(name = "userName", value = "用户名")
private String userName;
/**
* 项目工时列表
*/
@ApiModelProperty(name = "projectWorkTimeAndType", value = "项目工时列表")
private List<ProjectWorkTimeAndType> projectWorkTimeAndType;
}
package cn.wisenergy.service; package cn.wisenergy.service;
import cn.wisenergy.model.dto.GetMonthlyCollectParam; import cn.wisenergy.model.dto.GetMonthlyCollectParam;
import cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject;
import cn.wisenergy.model.dto.WorkTimeAndCostCollect; import cn.wisenergy.model.dto.WorkTimeAndCostCollect;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
...@@ -36,4 +37,13 @@ public interface StatisticsService { ...@@ -36,4 +37,13 @@ public interface StatisticsService {
* @return * @return
*/ */
HSSFWorkbook exportWorkTimeExcel(GetMonthlyCollectParam param); HSSFWorkbook exportWorkTimeExcel(GetMonthlyCollectParam param);
/**
* 获取用户所在未结项目的工时统计
* @param startDate
* @param endDate
* @param status
* @return
*/
List<UserWorkTimeStatisticsByProject> getUserWorkTimeStatisticsReport(Integer userId, String startDate, String endDate, Integer status);
} }
...@@ -13,10 +13,7 @@ import cn.wisenergy.model.app.WorkHoliday; ...@@ -13,10 +13,7 @@ import cn.wisenergy.model.app.WorkHoliday;
import cn.wisenergy.model.app.WorkProject; import cn.wisenergy.model.app.WorkProject;
import cn.wisenergy.model.app.WorkUser; import cn.wisenergy.model.app.WorkUser;
import cn.wisenergy.model.dto.*; import cn.wisenergy.model.dto.*;
import cn.wisenergy.model.enums.HolidayTypeEnum; import cn.wisenergy.model.enums.*;
import cn.wisenergy.model.enums.ManagerEnum;
import cn.wisenergy.model.enums.WorkOrderStatus;
import cn.wisenergy.model.enums.WorkOrderType;
import cn.wisenergy.service.StatisticsService; import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkDeptService; import cn.wisenergy.service.WorkDeptService;
import cn.wisenergy.service.WorkProjectService; import cn.wisenergy.service.WorkProjectService;
...@@ -24,6 +21,7 @@ import cn.wisenergy.service.WorkUserService; ...@@ -24,6 +21,7 @@ import cn.wisenergy.service.WorkUserService;
import com.alibaba.excel.util.StringUtils; import com.alibaba.excel.util.StringUtils;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.github.pagehelper.util.StringUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.*; import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
...@@ -118,7 +116,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -118,7 +116,7 @@ public class StatisticsServiceImpl implements StatisticsService {
ArrayList<DayWorkTimeAndType> dayWorkTimeAndTypes1 = new ArrayList<>(); ArrayList<DayWorkTimeAndType> dayWorkTimeAndTypes1 = new ArrayList<>();
// 查询出的工时信息遍历 // 查询出的工时信息遍历
Iterator<DayWorkTimeAndType> workTimeAndTypeIterator = dayWorkTimeAndTypes.iterator(); Iterator<DayWorkTimeAndType> workTimeAndTypeIterator = dayWorkTimeAndTypes.iterator();
while (workTimeAndTypeIterator.hasNext()){ while (workTimeAndTypeIterator.hasNext()) {
DayWorkTimeAndType dayWorkTimeAndType = workTimeAndTypeIterator.next(); DayWorkTimeAndType dayWorkTimeAndType = workTimeAndTypeIterator.next();
if (dayWorkTimeAndType.getUserId().equals(statisticsTableDto.getUserId())) { if (dayWorkTimeAndType.getUserId().equals(statisticsTableDto.getUserId())) {
dayWorkTimeAndTypes1.add(dayWorkTimeAndType); dayWorkTimeAndTypes1.add(dayWorkTimeAndType);
...@@ -201,11 +199,27 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -201,11 +199,27 @@ public class StatisticsServiceImpl implements StatisticsService {
Integer countByCondition = workTimeOrderMapper.getCountByCondition(map); Integer countByCondition = workTimeOrderMapper.getCountByCondition(map);
List<MonthlyWorkingHoursStatistics> monthlyWorkingHoursStatistics = workTimeOrderMapper.statisticsByProjectType(userId, firstDayOfMonth); List<MonthlyWorkingHoursStatistics> monthlyWorkingHoursStatistics = workTimeOrderMapper.statisticsByProjectType(userId, firstDayOfMonth);
// 如果不存在商机或项目其中某项,造对象传前端
while (monthlyWorkingHoursStatistics.size() < 2) {
// 获取工时类型(项目或商机)
List<String> projectTypes = monthlyWorkingHoursStatistics.stream().map(MonthlyWorkingHoursStatistics::getProjectType).collect(Collectors.toList());
MonthlyWorkingHoursStatistics workingHoursStatistics = new MonthlyWorkingHoursStatistics();
// 如果不存在项目或商机工时
if (!projectTypes.contains(ProjectTypeEnum.PROJECT.getTypeName())) {
workingHoursStatistics.setProjectType(ProjectTypeEnum.PROJECT.getTypeName());
} else if (!projectTypes.contains(ProjectTypeEnum.BUSINESS_OPPORTUNITY.getTypeName())){
workingHoursStatistics.setProjectType(ProjectTypeEnum.BUSINESS_OPPORTUNITY.getTypeName());
}
workingHoursStatistics.setCount(0);
workingHoursStatistics.setWorkTime(0);
monthlyWorkingHoursStatistics.add(workingHoursStatistics);
}
// 赋值未填报天数、被驳回未重报天
for (MonthlyWorkingHoursStatistics monthlyWorkingHoursStatistic : monthlyWorkingHoursStatistics) { for (MonthlyWorkingHoursStatistics monthlyWorkingHoursStatistic : monthlyWorkingHoursStatistics) {
monthlyWorkingHoursStatistic.setNotFilledCount(notFilledCount); monthlyWorkingHoursStatistic.setNotFilledCount(notFilledCount);
monthlyWorkingHoursStatistic.setRejectCount(countByCondition); monthlyWorkingHoursStatistic.setRejectCount(countByCondition);
} }
objects.add(monthlyWorkingHoursStatistics); objects.add(monthlyWorkingHoursStatistics);
} }
return objects; return objects;
...@@ -217,6 +231,11 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -217,6 +231,11 @@ public class StatisticsServiceImpl implements StatisticsService {
if (userId == null) { if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
} }
// 时间不为空,赋值当月第一天
if (StringUtil.isNotEmpty(startTime)) {
Date currentFirstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth();
startTime = DateUtil.convertDateToYMDStr(currentFirstDayOfMonth);
}
WorkUser user = workUserService.getById(userId); WorkUser user = workUserService.getById(userId);
if (user.getLevel().equals(ManagerEnum.NOT_MANAGER.getCode())) { if (user.getLevel().equals(ManagerEnum.NOT_MANAGER.getCode())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN); throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
...@@ -258,9 +277,9 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -258,9 +277,9 @@ public class StatisticsServiceImpl implements StatisticsService {
// 创建一行 // 创建一行
HSSFRow row1 = sheet.createRow(0); HSSFRow row1 = sheet.createRow(0);
// 给第一行赋值 // 给第一行赋值
row1.createCell(0).setCellValue("序号"); row1.createCell(0).setCellValue("序号");
row1.createCell(1).setCellValue("部门名称"); row1.createCell(1).setCellValue("部门名称");
row1.createCell(2).setCellValue("姓名"); row1.createCell(2).setCellValue("姓名");
for (int i = 1; i <= dayCount; i++) { for (int i = 1; i <= dayCount; i++) {
HSSFCell cell = row1.createCell(2 + i); HSSFCell cell = row1.createCell(2 + i);
cell.setCellValue(i + "日"); cell.setCellValue(i + "日");
...@@ -302,6 +321,26 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -302,6 +321,26 @@ public class StatisticsServiceImpl implements StatisticsService {
return sheets; return sheets;
} }
@Override
public List<UserWorkTimeStatisticsByProject> getUserWorkTimeStatisticsReport(Integer userId, String startDate, String endDate, Integer status) {
log.info("StatisticsServiceImpl[]getUserWorkTimeStatisticsReport[]");
// 默认统计截至时间为前一天
if (StringUtil.isEmpty(endDate)) {
endDate = DateUtil.convertDateToYMDStr(new Date());
}
// 获取用户负责项目主键集合
List<WorkProject> userManageProjects = workProjectService.getUserManageProjects(userId);
if (CollectionUtil.isEmpty(userManageProjects)) {
// throw new BaseCustomException(BASE_RESP_CODE_ENUM.MANAGER_NOT_PROJECT);
}
List<Integer> projectIds = userManageProjects.stream().map(WorkProject::getId).collect(Collectors.toList());
List<UserWorkTimeStatisticsByProject> userProjectWorkTimeStatistics = workTimeOrderMapper.getUserProjectWorkTimeStatistics(startDate, endDate, status, projectIds);
return userProjectWorkTimeStatistics;
}
//获取本月应上班日期 //获取本月应上班日期
public List<Date> currentMonthWorkDays() { public List<Date> currentMonthWorkDays() {
log.info("StatisticsServiceImpl[]currentMonthWorkDays[]input.method"); log.info("StatisticsServiceImpl[]currentMonthWorkDays[]input.method");
......
...@@ -5,6 +5,7 @@ import cn.wisenergy.common.utils.exception.BaseCustomException; ...@@ -5,6 +5,7 @@ import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.common.utils.exception.Result; import cn.wisenergy.common.utils.exception.Result;
import cn.wisenergy.model.app.WorkDept; import cn.wisenergy.model.app.WorkDept;
import cn.wisenergy.model.dto.GetMonthlyCollectParam; import cn.wisenergy.model.dto.GetMonthlyCollectParam;
import cn.wisenergy.model.dto.UserWorkTimeStatisticsByProject;
import cn.wisenergy.model.dto.WorkTimeAndCostCollect; import cn.wisenergy.model.dto.WorkTimeAndCostCollect;
import cn.wisenergy.service.StatisticsService; import cn.wisenergy.service.StatisticsService;
import cn.wisenergy.service.WorkDeptService; import cn.wisenergy.service.WorkDeptService;
...@@ -52,27 +53,27 @@ public class StatisticsController extends BaseController { ...@@ -52,27 +53,27 @@ public class StatisticsController extends BaseController {
@ApiOperation(value = "获取全部部门信息或单条信息", notes = "获取全部部门信息或单条信息") @ApiOperation(value = "获取全部部门信息或单条信息", notes = "获取全部部门信息或单条信息")
@ApiImplicitParam(name = "deptId", value = "部门主键") @ApiImplicitParam(name = "deptId", value = "部门主键")
@GetMapping("/getDeptInfo") @GetMapping("/getDeptInfo")
public List<WorkDept> getDeptInfo( Integer deptId) { public List<WorkDept> getDeptInfo(Integer deptId) {
log.info("StatisticsController[]getDeptInfo[]input.param" + deptId); log.info("StatisticsController[]getDeptInfo[]input.param" + deptId);
List<WorkDept> workDepts = workDeptService.getDeptInfo(deptId); List<WorkDept> workDepts = workDeptService.getDeptInfo(deptId);
return workDepts; return workDepts;
} }
@ApiOperation(value = "获取负责项目工时汇总", notes = "获取负责项目工时汇总") @ApiOperation(value = "获取负责项目工时汇总", notes = "获取负责项目工时汇总")
@GetMapping("/getCurrentMonthWorkTimeCollect") @GetMapping("/getCurrentMonthWorkTimeCollect")
public List<WorkTimeAndCostCollect> getWorkTimeCollect(Integer userId,String startTime) { public Result<List<WorkTimeAndCostCollect>> getWorkTimeCollect(Integer userId, String startTime) {
log.info("WorkUserController[]getCurrentMonthWorkTimeCollect[]input.param" + userId,startTime); log.info("WorkUserController[]getCurrentMonthWorkTimeCollect[]input.param" + userId, startTime);
if (userId == null) { if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
} }
List<WorkTimeAndCostCollect> currentMonthWorkTimeCollect = statisticsService.getCurrentMonthWorkTimeCollect(userId,startTime); List<WorkTimeAndCostCollect> currentMonthWorkTimeCollect = statisticsService.getCurrentMonthWorkTimeCollect(userId, startTime);
return currentMonthWorkTimeCollect; return getResult(currentMonthWorkTimeCollect);
} }
@ApiOperation(value = "获取本月工时统计和审核统计", notes = "获取本月",httpMethod = "GET") @ApiOperation(value = "获取本月工时统计和审核统计", notes = "获取本月", httpMethod = "GET")
@ApiImplicitParam(name = "userId", value = "用户主键",dataType = "int", required = true) @ApiImplicitParam(name = "userId", value = "用户主键", dataType = "int", required = true)
@GetMapping("/getMonthlyWorkingHours") @GetMapping("/getMonthlyWorkingHours")
public Result<List<Object>> getMonthlyWorkingHours(Integer userId){ public Result<List<Object>> getMonthlyWorkingHours(Integer userId) {
log.info("WorkOrderController[]getMonthlyWorkingHours[]input.param" + userId); log.info("WorkOrderController[]getMonthlyWorkingHours[]input.param" + userId);
if (userId == null) { if (userId == null) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL); throw new BaseCustomException(BASE_RESP_CODE_ENUM.INPUT_PARAM_IS_NULL);
...@@ -110,4 +111,13 @@ public class StatisticsController extends BaseController { ...@@ -110,4 +111,13 @@ 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);
return getResult(userWorkTimeStatisticsByProjects);
}
}
\ No newline at end of file
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