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

修改工时统计类型顺序

parent cf56f4d3
...@@ -93,6 +93,14 @@ public interface WorkTimeOrderMapper extends BaseMapper<WorkTimeOrder> { ...@@ -93,6 +93,14 @@ 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("userIds") List<Integer> userIds);
/**
* 根据工单状态获取填报条数
* @param userId
* @param firstDayOfMonth
* @param status
* @return
*/
List<MonthlyWorkingHoursStatistics> selectCountByTypeAndStatus(@Param("userId") Integer userId, @Param("firstDayOfMonth") Date firstDayOfMonth,@Param("status") Integer[] status);
} }
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
<resultMap id="projectStatisticsByMonth" type="cn.wisenergy.model.dto.ProjectStatisticsByMonth"> <resultMap id="projectStatisticsByMonth" type="cn.wisenergy.model.dto.ProjectStatisticsByMonth">
<result property="projectId" column="project_id"/> <result property="projectId" column="project_id"/>
<result property="projectName" column="project_name"/> <result property="projectName" column="project_name"/>
<result property="deptName" column="dept_name"/>
<collection property="statisticsDateAndWorkTimes" ofType="cn.wisenergy.model.dto.ProjectStatisticsByMonth$StatisticsDateAndWorkTime"> <collection property="statisticsDateAndWorkTimes" ofType="cn.wisenergy.model.dto.ProjectStatisticsByMonth$StatisticsDateAndWorkTime">
<result property="date" column="date"/> <result property="date" column="date"/>
<result property="totalTime" column="total_time"/> <result property="totalTime" column="total_time"/>
...@@ -50,6 +51,7 @@ ...@@ -50,6 +51,7 @@
INSERT INTO work_project_time_cost ( INSERT INTO work_project_time_cost (
project_id, project_id,
user_id, user_id,
dept_id,
statistics_start, statistics_start,
statistics_end, statistics_end,
total_time, total_time,
...@@ -59,6 +61,7 @@ ...@@ -59,6 +61,7 @@
SELECT SELECT
project_id, project_id,
t.user_id, t.user_id,
t.dept_id,
min(work_day), min(work_day),
max(work_day), max(work_day),
sum(work_time / 8), sum(work_time / 8),
...@@ -72,6 +75,7 @@ ...@@ -72,6 +75,7 @@
AND t.`status` IN (2, 5) AND project_id is not null AND t.`status` IN (2, 5) AND project_id is not null
GROUP BY GROUP BY
project_id, project_id,
t.dept_id,
t.user_id, t.user_id,
YEAR (work_day), YEAR (work_day),
MONTH (work_day) MONTH (work_day)
...@@ -80,7 +84,7 @@ ...@@ -80,7 +84,7 @@
<select id="selectList" resultMap="workTimeAndCostCollect"> <select id="selectList" resultMap="workTimeAndCostCollect">
SELECT case `type` when 1 then "项目" else "商机" end AS type ,dept_name,dept_id,ptc.project_id AS SELECT type ,dept_name,ptc.dept_id,ptc.project_id AS
project_id,project_name,min(statistics_start) AS statistics_start,max(statistics_end) AS project_id,project_name,min(statistics_start) AS statistics_start,max(statistics_end) AS
statistics_end,sum(total_time) AS total_time,sum(cost) AS cost statistics_end,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 p.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
...@@ -105,16 +109,16 @@ ...@@ -105,16 +109,16 @@
<select id="selectListByMonth" resultMap="projectStatisticsByMonth"> <select id="selectListByMonth" 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, group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,
sum(total_time) AS total_time, sum(cost) AS cost sum(total_time) AS total_time, sum(cost) AS cost <if test="projectId != null "> ,d.dept_name AS dept_name</if>
from work_project_time_cost ptc join work_project p on ptc.project_id = p.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
<where> <where>
<if test="projectId != null "> <if test="projectId != null ">
ptc.project_id = #{projectId} ptc.project_id = #{projectId}
</if> </if>
<if test="deptId != null"> <if test="deptId != null">
AND dept_id = #{deptId} AND year(statistics_start) = #{year} AND p.dept_id = #{deptId} AND year(statistics_start) = #{year}
</if> </if>
</where> </where>
group by ptc.project_id,project_name,year(statistics_start),MONTH(statistics_start) group by ptc.project_id,project_name,year(statistics_start),MONTH(statistics_start) <if test="projectId != null "> ,ptc.dept_id</if>
</select> </select>
</mapper> </mapper>
\ No newline at end of file
...@@ -89,7 +89,9 @@ ...@@ -89,7 +89,9 @@
<resultMap id="monthlyWorkHourStatistics" type="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics"> <resultMap id="monthlyWorkHourStatistics" type="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics">
<result property="count" column="count(1)"/> <result property="count" column="count(1)"/>
<result property="workTime" column="sum(work_time)"/> <result property="workTime" column="sum(work_time)"/>
<result property="projectType" column="type"/> <result property="projectType" column="id"/>
<result property="typeName" column="name"/>
<result property="approved" column="approved"/>
</resultMap> </resultMap>
<sql id="table"> <sql id="table">
...@@ -180,10 +182,9 @@ ...@@ -180,10 +182,9 @@
</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 t2.id AS id , t2.name AS name ,count(1),sum(work_time)
from from work_time_order t join work_type t2 on t.type = t2.id
<include refid="table"/> where user_id = #{userId} 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>
...@@ -230,7 +231,7 @@ ...@@ -230,7 +231,7 @@
</select> </select>
<select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect" > <select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect" >
SELECT CASE t.type WHEN 1 THEN "项目" WHEN 2 THEN "商机" WHEN 3 THEN "请假" WHEN 4 THEN "调休" WHEN 5 THEN "外部商务/技术交流" WHEN 6 THEN "内部培训/技术准备/管理" WHEN 7 THEN "其他非项目/商机工作" END AS type,t.dept_id AS dept_id, SELECT t.type AS type,t.dept_id AS dept_id,
t.project_id AS project_id ,MIN(t.work_day) AS first_time,MAX(t.work_day) AS last_time,ROUND(SUM(t.work_time)/8,2) AS t.project_id AS project_id ,MIN(t.work_day) AS first_time,MAX(t.work_day) AS last_time,ROUND(SUM(t.work_time)/8,2) AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost,dept_name AS dept_name,project_name total_time, SUM(t.work_time * s.day_salary)/8 AS cost,dept_name AS dept_name,project_name
FROM work_time_order t LEFT JOIN work_project p ON t.project_id=p.id LEFT JOIN work_dept d ON t.dept_id=d.id LEFT JOIN work_user_salary s ON s.user_id = t.user_id FROM work_time_order t LEFT JOIN work_project p ON t.project_id=p.id LEFT JOIN work_dept d ON t.dept_id=d.id LEFT JOIN work_user_salary s ON s.user_id = t.user_id
...@@ -297,7 +298,7 @@ ...@@ -297,7 +298,7 @@
<select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject"> <select id="getUserProjectWorkTimeStatistics" resultMap="userWorkTimeStatisticsByProject">
SELECT u.id AS user_id ,u.`name` AS user_name, t.project_id AS project_id 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 ,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 ,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 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 where
...@@ -319,7 +320,7 @@ ...@@ -319,7 +320,7 @@
<if test="userIds != null"> <if test="userIds != null">
UNION UNION
SELECT u.id AS user_id ,u.`name` AS user_name, t.project_id AS project_id 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 ,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 ,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 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 where
...@@ -330,4 +331,14 @@ ...@@ -330,4 +331,14 @@
GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime
</if> </if>
</select> </select>
<select id="selectCountByTypeAndStatus" resultType="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics">
select type AS projectType, count(1) AS approved
from <include refid="table"/>
where user_id = #{userId} and work_day >= #{firstDayOfMonth} AND status in
<foreach collection="status" open="(" close=")" separator="," item="s">
#{s}
</foreach>
GROUP BY type
</select>
</mapper> </mapper>
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
SELECT id,name,reviewer SELECT id,name,reviewer
FROM work_type FROM work_type
</select> </select>
<select id="getIdByReviewer" resultType="java.lang.Integer"> <select id="getIdByReviewer" resultType="java.lang.Integer">
SELECT id SELECT id
FROM work_type FROM work_type
......
...@@ -13,38 +13,55 @@ import java.io.Serializable; ...@@ -13,38 +13,55 @@ import java.io.Serializable;
**/ **/
@Data @Data
@ApiModel(value = "MonthlyWorkingHoursStatistics", description = "统计本月的填报信息") @ApiModel(value = "MonthlyWorkingHoursStatistics", description = "统计本月的填报信息")
public class MonthlyWorkingHoursStatistics implements Serializable { public class MonthlyWorkingHoursStatistics implements Serializable ,Comparable{
private static final long serialVersionUID = -8216457470821285624L; private static final long serialVersionUID = -8216457470821285624L;
// 工单类型展示顺序,存储为类型id
private final static Integer[] TYPE_ORDER = {1, 2, 5, 6, 7, 3, 4};
/** /**
* 工单类型:商机/项目 * 工单类型
*/ */
@ApiModelProperty(name = "projectType", value = "工单类型:商机/项目") @ApiModelProperty(name = "projectType", value = "工单类型:商机/项目")
private String projectType; private Integer projectType;
/** /**
* 填报次数 * 工单类型名称
*/ */
@ApiModelProperty(name = "count", value = "填报次数") @ApiModelProperty(name = "typeName", value = "类型名称")
private int count; private String typeName;
/** /**
* 填报工时 * 已审批
*/ */
@ApiModelProperty(name = "workTime", value = "填报工时") @ApiModelProperty(name = "approved", value = "已审批条数")
private int workTime; private Integer approved;
/** /**
* 未填报天 * 填报次
*/ */
@ApiModelProperty(name = "notFilledCount", value = "未填报天数") @ApiModelProperty(name = "count", value = "填报次数")
private int notFilledCount; private int count;
/** /**
* 现存被驳回数 * 填报工时
*/ */
@ApiModelProperty(name = "rejectCount", value = "现存被驳回数") @ApiModelProperty(name = "workTime", value = "合计填报工时")
private int rejectCount; private int workTime;
@Override
public int compareTo(Object o) {
MonthlyWorkingHoursStatistics monthlyWorkingHoursStatistics = (MonthlyWorkingHoursStatistics) o;
int thisI = 0;
int oI = 0;
for (int i = 0; i < TYPE_ORDER.length; i++) {
if (projectType == TYPE_ORDER[i]) {
thisI = i;
}
if (monthlyWorkingHoursStatistics.getProjectType() == TYPE_ORDER[i]) {
oI = i;
}
}
return thisI - oI;
}
} }
...@@ -24,6 +24,9 @@ public class ProjectStatisticsByMonth implements Serializable { ...@@ -24,6 +24,9 @@ public class ProjectStatisticsByMonth implements Serializable {
@ApiModelProperty(name = "projectName", value = "项目名称") @ApiModelProperty(name = "projectName", value = "项目名称")
private String projectName; private String projectName;
@ApiModelProperty(name = "deptName", value = "部门名称")
private String deptName;
@ApiModelProperty(name = "statisticsDateAndWorkTime", value = "项目统计的时间段、工时和成本") @ApiModelProperty(name = "statisticsDateAndWorkTime", value = "项目统计的时间段、工时和成本")
List<StatisticsDateAndWorkTime> statisticsDateAndWorkTimes; List<StatisticsDateAndWorkTime> statisticsDateAndWorkTimes;
......
...@@ -15,14 +15,20 @@ import java.util.List; ...@@ -15,14 +15,20 @@ import java.util.List;
**/ **/
@Data @Data
@ApiModel(value = "WorkTimeAndCostCollect", description = "项目的工时和工时成本统计") @ApiModel(value = "WorkTimeAndCostCollect", description = "项目的工时和工时成本统计")
public class WorkTimeAndCostCollect implements Serializable { public class WorkTimeAndCostCollect implements Serializable, Comparable {
private static final long serialVersionUID = 7207732278277982917L; private static final long serialVersionUID = 7207732278277982917L;
// 工单类型展示顺序,存储为类型id
private final static Integer[] TYPE_ORDER = {1, 2, 5, 6, 7, 3, 4};
@ApiModelProperty(name = "type", value = "工时类型主键")
private Integer type;
/** /**
* 工时类型 * 工时类型
*/ */
@ApiModelProperty(name = "type", value = "工时类型") @ApiModelProperty(name = "typeName", value = "工时类型")
private String type; private String typeName;
/** /**
* 部门工时统计 * 部门工时统计
...@@ -36,4 +42,19 @@ public class WorkTimeAndCostCollect implements Serializable { ...@@ -36,4 +42,19 @@ public class WorkTimeAndCostCollect implements Serializable {
@ApiModelProperty(name = "workTime", value = "工时总计") @ApiModelProperty(name = "workTime", value = "工时总计")
private BigDecimal workTime; private BigDecimal workTime;
@Override
public int compareTo(Object o) {
WorkTimeAndCostCollect workTimeAndCostCollect = (WorkTimeAndCostCollect) o;
int thisI = 0;
int oI = 0;
for (int i = 0; i < TYPE_ORDER.length; i++) {
if (type == TYPE_ORDER[i]) {
thisI = i;
}
if (workTimeAndCostCollect.getType() == TYPE_ORDER[i]) {
oI = i;
}
}
return thisI - oI;
}
} }
...@@ -5,8 +5,8 @@ public enum ProjectTypeEnum { ...@@ -5,8 +5,8 @@ public enum ProjectTypeEnum {
BUSINESS_OPPORTUNITY(2, "商机", 1), BUSINESS_OPPORTUNITY(2, "商机", 1),
LEAVE(3, "请假", 2), LEAVE(3, "请假", 2),
COMPENSATORY_LEAVE(4, "调休", 2), COMPENSATORY_LEAVE(4, "调休", 2),
EXTERNAL_BUSINESS(5, "外部商务/技术交流", 3), EXTERNAL_BUSINESS(5, "外部商务技术交流", 3),
INTERNAL_TRAINING(6, "内部培训/技术准备/管理", 3), INTERNAL_TRAINING(6, "内部培训、技术准备、管理", 3),
OTHER_NON_PROJECTS(7, "其他非项目/商机工作", 3), OTHER_NON_PROJECTS(7, "其他非项目/商机工作", 3),
; ;
......
...@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo; ...@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.util.List; import java.util.List;
import java.util.Map;
public interface StatisticsService { public interface StatisticsService {
...@@ -25,7 +26,7 @@ public interface StatisticsService { ...@@ -25,7 +26,7 @@ public interface StatisticsService {
* @param userId * @param userId
* @return * @return
*/ */
List<Object> getMonthlyStatistics(Integer userId); Map<String,Object> getMonthlyStatistics(Integer userId);
/** /**
* 获取负责项目的工时汇总:花费工时,工时成本 * 获取负责项目的工时汇总:花费工时,工时成本
......
...@@ -8,6 +8,7 @@ import cn.wisenergy.common.utils.exception.BaseCustomException; ...@@ -8,6 +8,7 @@ import cn.wisenergy.common.utils.exception.BaseCustomException;
import cn.wisenergy.mapper.*; import cn.wisenergy.mapper.*;
import cn.wisenergy.model.app.WorkHoliday; import cn.wisenergy.model.app.WorkHoliday;
import cn.wisenergy.model.app.WorkProject; import cn.wisenergy.model.app.WorkProject;
import cn.wisenergy.model.app.WorkType;
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.*; import cn.wisenergy.model.enums.*;
...@@ -60,6 +61,9 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -60,6 +61,9 @@ public class StatisticsServiceImpl implements StatisticsService {
@Autowired @Autowired
private UserRoleLevelUtils userRoleLevelUtils; private UserRoleLevelUtils userRoleLevelUtils;
@Autowired
private WorkTypeMapper workTypeMapper;
@Autowired @Autowired
private WorkProjectTimeCostMapper workProjectTimeCostMapper; private WorkProjectTimeCostMapper workProjectTimeCostMapper;
...@@ -132,14 +136,14 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -132,14 +136,14 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
@Override @Override
public List<Object> getMonthlyStatistics(Integer userId) { public Map<String,Object> getMonthlyStatistics(Integer userId) {
log.info("WorkTimeOrderServiceImpl[]getMonthlyStatistics[]input.param" + userId); log.info("WorkTimeOrderServiceImpl[]getMonthlyStatistics[]input.param" + userId);
WorkUser user = workUserService.getById(userId); WorkUser user = workUserService.getById(userId);
List<Integer> role = userRoleLevelUtils.getRole(user.getId()); List<Integer> role = userRoleLevelUtils.getRole(user.getId());
//本月第一天 //本月第一天
Date firstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth(); Date firstDayOfMonth = DateUtil.getCurrentFirstDayOfMonth();
//返回数据对象 //返回数据对象
List<Object> objects = new ArrayList<>(); Map<String,Object> objects = new HashMap<>();
//存放查询条件 //存放查询条件
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
//用户是项目或部门级别,查询审批统计 //用户是项目或部门级别,查询审批统计
...@@ -182,7 +186,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -182,7 +186,7 @@ public class StatisticsServiceImpl implements StatisticsService {
approvalStatistics.setApprovalCount(completedCount); approvalStatistics.setApprovalCount(completedCount);
approvalStatistics.setRejectNotSubmit(rejectAndNotResubmit); approvalStatistics.setRejectNotSubmit(rejectAndNotResubmit);
approvalStatistics.setNotApprovalCount(notCompletedCount); approvalStatistics.setNotApprovalCount(notCompletedCount);
objects.add(approvalStatistics); objects.put("manager",approvalStatistics);
} }
// 填报情况 // 填报情况
...@@ -201,28 +205,44 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -201,28 +205,44 @@ 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);
Integer[] status = {StatusEnum.APPROVED.getCode(), StatusEnum.AUTOMATIC_AUDIT.getCode()};
// 已审批的类型和统计条数
List<MonthlyWorkingHoursStatistics> monthlyWorkingHoursStatistics1 = workTimeOrderMapper.selectCountByTypeAndStatus(userId, firstDayOfMonth, status);
for (MonthlyWorkingHoursStatistics workingHoursStatistics : monthlyWorkingHoursStatistics1) {
for (MonthlyWorkingHoursStatistics monthlyWorkingHoursStatistic : monthlyWorkingHoursStatistics) {
if (workingHoursStatistics.getProjectType().equals(monthlyWorkingHoursStatistic.getProjectType())) {
monthlyWorkingHoursStatistic.setApproved(workingHoursStatistics.getApproved());
}
}
}
List<Integer> types = monthlyWorkingHoursStatistics.stream().map(MonthlyWorkingHoursStatistics::getProjectType).collect(Collectors.toList());
// 如果没填写填报类型其中某项,造对象传前端 // 如果没填写填报类型其中某项,造对象传前端
if (monthlyWorkingHoursStatistics.size() < 5) { List<WorkType> workTypes = workTypeMapper.getAll();
// 获取工时类型(项目或商机) if (monthlyWorkingHoursStatistics.size() < workTypes.size()) {
List<String> projectTypes = monthlyWorkingHoursStatistics.stream().map(MonthlyWorkingHoursStatistics::getProjectType).collect(Collectors.toList()); for (WorkType workType : workTypes) {
for (ProjectTypeEnum value : ProjectTypeEnum.values()) { if (!types.contains(workType.getId())) {
// 除开请假、调休
if (!projectTypes.contains(value.getTypeName()) && !value.getTypeName().equals(ProjectTypeEnum.LEAVE.getTypeName()) && !value.getTypeName().equals(ProjectTypeEnum.COMPENSATORY_LEAVE.getTypeName())) {
MonthlyWorkingHoursStatistics workingHoursStatistics = new MonthlyWorkingHoursStatistics(); MonthlyWorkingHoursStatistics workingHoursStatistics = new MonthlyWorkingHoursStatistics();
workingHoursStatistics.setProjectType(value.getTypeName()); workingHoursStatistics.setTypeName(workType.getName());
workingHoursStatistics.setProjectType(workType.getId());
workingHoursStatistics.setCount(0); workingHoursStatistics.setCount(0);
workingHoursStatistics.setWorkTime(0); workingHoursStatistics.setWorkTime(0);
monthlyWorkingHoursStatistics.add(workingHoursStatistics); monthlyWorkingHoursStatistics.add(workingHoursStatistics);
} }
} }
} }
// 调整类型顺序
Collections.sort(monthlyWorkingHoursStatistics);
// 赋值未填报天数、被驳回未重报天 // 赋值未填报天数、被驳回未重报天
for (MonthlyWorkingHoursStatistics monthlyWorkingHoursStatistic : monthlyWorkingHoursStatistics) { for (MonthlyWorkingHoursStatistics monthlyWorkingHoursStatistic : monthlyWorkingHoursStatistics) {
monthlyWorkingHoursStatistic.setNotFilledCount(notFilledCount); if (monthlyWorkingHoursStatistic.getApproved() == null) {
monthlyWorkingHoursStatistic.setRejectCount(countByCondition); monthlyWorkingHoursStatistic.setApproved(0);
}
} }
objects.add(monthlyWorkingHoursStatistics); objects.put("notFilledCount", notFilledCount);
objects.put("countByCondition", countByCondition);
objects.put("user" ,monthlyWorkingHoursStatistics);
return objects; return objects;
} }
...@@ -265,8 +285,9 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -265,8 +285,9 @@ public class StatisticsServiceImpl implements StatisticsService {
// 工时类型包含:项目,商机 // 工时类型包含:项目,商机
List<Integer> types = new ArrayList<>(); List<Integer> types = new ArrayList<>();
types.add(ProjectTypeEnum.PROJECT.getType()); List<WorkType> workTypes = workTypeMapper.getAll();
types.add(ProjectTypeEnum.BUSINESS_OPPORTUNITY.getType()); types.add(workTypes.get(1).getId());
types.add(workTypes.get(2).getId());
map.put("types", types); map.put("types", types);
// 查询项目和商机的工时统计 // 查询项目和商机的工时统计
...@@ -277,10 +298,11 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -277,10 +298,11 @@ public class StatisticsServiceImpl implements StatisticsService {
// 请假、调休、外部商务、技术交流,内部培训、技术准备、管理,其他非项目/商机工作 // 请假、调休、外部商务、技术交流,内部培训、技术准备、管理,其他非项目/商机工作
types.clear(); types.clear();
map.clear(); map.clear();
for (ProjectTypeEnum value : ProjectTypeEnum.values()) {
for (WorkType workType : workTypes) {
// 查询条件排除项目和商机 // 查询条件排除项目和商机
if (!value.getTypeName().equals(ProjectTypeEnum.PROJECT.getTypeName()) && !value.getTypeName().equals(ProjectTypeEnum.BUSINESS_OPPORTUNITY.getTypeName())) { if (!workType.getName().equals(workTypes.get(1).getName()) && !workType.getName().equals(workTypes.get(2).getName())) {
types.add(value.getType()); types.add(workType.getId());
} }
} }
// 用户仅为部门管理 // 用户仅为部门管理
...@@ -291,13 +313,19 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -291,13 +313,19 @@ public class StatisticsServiceImpl implements StatisticsService {
List<WorkTimeAndCostCollect> workTimeAndCostCollect = workTimeOrderMapper.getWorkTimeAndCostCollect(map); List<WorkTimeAndCostCollect> workTimeAndCostCollect = workTimeOrderMapper.getWorkTimeAndCostCollect(map);
// 将查询结果封装在一起 // 将查询结果封装在一起
collect.addAll(workTimeAndCostCollect); collect.addAll(workTimeAndCostCollect);
for (WorkTimeAndCostCollect timeAndCostCollect : collect) {
WorkType workType = workTypes.get(timeAndCostCollect.getType()-1);
timeAndCostCollect.setTypeName(workType.getName());
}
// 获取查询结果中的类型 // 获取查询结果中的类型
List<String> typeList = collect.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList()); List<Integer> typeList = collect.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList());
// 如果查询结果不包含查询条件中的类型,造对象传前端 // 如果查询结果不包含查询条件中的类型,造对象传前端
for (ProjectTypeEnum value : ProjectTypeEnum.values()) { for (WorkType workType : workTypes) {
if (!typeList.contains(value.getTypeName())) { if (!typeList.contains(workType.getId())) {
WorkTimeAndCostCollect workTimeAndCostCollect1 = new WorkTimeAndCostCollect(); WorkTimeAndCostCollect workTimeAndCostCollect1 = new WorkTimeAndCostCollect();
workTimeAndCostCollect1.setType(value.getTypeName()); workTimeAndCostCollect1.setType(workType.getId());
workTimeAndCostCollect1.setTypeName(workType.getName());
collect.add(workTimeAndCostCollect1); collect.add(workTimeAndCostCollect1);
} }
} }
...@@ -316,6 +344,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -316,6 +344,7 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
workTimeAndCostCollect.setWorkTime(typeTotalTime); workTimeAndCostCollect.setWorkTime(typeTotalTime);
} }
Collections.sort(collect);
return collect; return collect;
} }
...@@ -681,20 +710,21 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -681,20 +710,21 @@ public class StatisticsServiceImpl implements StatisticsService {
public List<ProjectWorkTimeAndType> createProjectWorkTimeAndTypeListByType() { public List<ProjectWorkTimeAndType> createProjectWorkTimeAndTypeListByType() {
List<ProjectWorkTimeAndType> list = new ArrayList<>(6); List<ProjectWorkTimeAndType> list = new ArrayList<>(6);
ProjectWorkTimeAndType timeAndType; ProjectWorkTimeAndType timeAndType;
List<WorkType> workTypes = workTypeMapper.getAll();
// 外部商务、技术交流 // 外部商务、技术交流
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.EXTERNAL_BUSINESS.getTypeName(), "正常"); timeAndType = createProjectWorkTimeAndTypeByType(workTypes.get(5).getName(), "正常");
list.add(timeAndType); list.add(timeAndType);
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.EXTERNAL_BUSINESS.getTypeName(), "加班"); timeAndType = createProjectWorkTimeAndTypeByType(workTypes.get(5).getName(), "加班");
list.add(timeAndType); list.add(timeAndType);
// 内部培训、技术准备、管理 // 内部培训、技术准备、管理
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.INTERNAL_TRAINING.getTypeName(), "正常"); timeAndType = createProjectWorkTimeAndTypeByType(workTypes.get(6).getName(), "正常");
list.add(timeAndType); list.add(timeAndType);
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.INTERNAL_TRAINING.getTypeName(), "加班"); timeAndType = createProjectWorkTimeAndTypeByType(workTypes.get(6).getName(), "加班");
list.add(timeAndType); list.add(timeAndType);
// 其他非项目/商机工作 // 其他非项目/商机工作
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.OTHER_NON_PROJECTS.getTypeName(), "正常"); timeAndType = createProjectWorkTimeAndTypeByType(workTypes.get(7).getName(), "正常");
list.add(timeAndType); list.add(timeAndType);
timeAndType = createProjectWorkTimeAndTypeByType(ProjectTypeEnum.OTHER_NON_PROJECTS.getTypeName(), "加班"); timeAndType = createProjectWorkTimeAndTypeByType(workTypes.get(7).getName(), "加班");
list.add(timeAndType); list.add(timeAndType);
return list; return list;
} }
...@@ -745,4 +775,16 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -745,4 +775,16 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
} }
} }
// public void adjust(List<MonthlyWorkingHoursStatistics> monthlyWorkingHoursStatistics, List<WorkType> workTypes) {
// for (Integer integer : TYPE_ORDER) {
// int i = 0;
// MonthlyWorkingHoursStatistics workingHoursStatistics = monthlyWorkingHoursStatistics.get(i);
// if (!workingHoursStatistics.getProjectType().equals(workTypes.get(integer))) {
// monthlyWorkingHoursStatistics.
// }
// i++;
// }
//
// }
} }
...@@ -226,19 +226,15 @@ public class WorkUserServiceImpl implements WorkUserService { ...@@ -226,19 +226,15 @@ public class WorkUserServiceImpl implements WorkUserService {
if (user.getStatus() != ON_THE_JOB_STATUS) { if (user.getStatus() != ON_THE_JOB_STATUS) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.LEAVE_JOB_USER); throw new BaseCustomException(BASE_RESP_CODE_ENUM.LEAVE_JOB_USER);
} }
/*
if (user.getModifyTime() != user.getCreateTime()) { // 如果登录来源是PC,判断用户是不是管理员
修改密码
}
*/
//如果登录来源是PC,判断用户是不是管理员
List<Integer> roles = UserRoleLevelUtils.getRole(user.getId()); List<Integer> roles = UserRoleLevelUtils.getRole(user.getId());
if (LOGIN_SOURCE.equals(source)) { if (LOGIN_SOURCE.equals(source)) {
if (roles.contains(ManagerEnum.NOT_MANAGER.getCode())) { if (roles.contains(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);
} }
} }
// 限制审核的天数
WorkSubmitAdopt byId = workSubmitAdoptService.getById(1); WorkSubmitAdopt byId = workSubmitAdoptService.getById(1);
//将用户对象转换为dto //将用户对象转换为dto
......
...@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -26,6 +26,7 @@ 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;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* @description: * @description:
...@@ -74,12 +75,12 @@ public class StatisticsController extends BaseController { ...@@ -74,12 +75,12 @@ public class StatisticsController extends BaseController {
@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<Map<String,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);
} }
List<Object> monthlyStatistics = statisticsService.getMonthlyStatistics(userId); Map<String,Object> monthlyStatistics = statisticsService.getMonthlyStatistics(userId);
return getResult(monthlyStatistics); return getResult(monthlyStatistics);
} }
......
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