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

修改工时统计类型顺序

parent cf56f4d3
......@@ -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 @@
<resultMap id="projectStatisticsByMonth" type="cn.wisenergy.model.dto.ProjectStatisticsByMonth">
<result property="projectId" column="project_id"/>
<result property="projectName" column="project_name"/>
<result property="deptName" column="dept_name"/>
<collection property="statisticsDateAndWorkTimes" ofType="cn.wisenergy.model.dto.ProjectStatisticsByMonth$StatisticsDateAndWorkTime">
<result property="date" column="date"/>
<result property="totalTime" column="total_time"/>
......@@ -50,6 +51,7 @@
INSERT INTO work_project_time_cost (
project_id,
user_id,
dept_id,
statistics_start,
statistics_end,
total_time,
......@@ -59,6 +61,7 @@
SELECT
project_id,
t.user_id,
t.dept_id,
min(work_day),
max(work_day),
sum(work_time / 8),
......@@ -72,6 +75,7 @@
AND t.`status` IN (2, 5) AND project_id is not null
GROUP BY
project_id,
t.dept_id,
t.user_id,
YEAR (work_day),
MONTH (work_day)
......@@ -80,7 +84,7 @@
<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
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
......@@ -105,16 +109,16 @@
<select id="selectListByMonth" resultMap="projectStatisticsByMonth">
select ptc.project_id AS project_id, project_name,
group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,
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
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 join work_dept d on ptc.dept_id = d.id
<where>
<if test="projectId != null ">
ptc.project_id = #{projectId}
</if>
<if test="deptId != null">
AND dept_id = #{deptId} AND year(statistics_start) = #{year}
AND p.dept_id = #{deptId} AND year(statistics_start) = #{year}
</if>
</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>
</mapper>
\ No newline at end of file
......@@ -89,7 +89,9 @@
<resultMap id="monthlyWorkHourStatistics" type="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics">
<result property="count" column="count(1)"/>
<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>
<sql id="table">
......@@ -180,10 +182,9 @@
</sql>
<select id="statisticsByProjectType" resultMap="monthlyWorkHourStatistics">
select CASE WHEN type = 1 THEN "项目" WHEN type = 2 THEN "商机" END AS type, count(1),sum(work_time)
from
<include refid="table"/>
where user_id = #{userId} AND type in (1,2) AND work_day >= #{currentMonthFirstDay}
select t2.id AS id , t2.name AS name ,count(1),sum(work_time)
from work_time_order t join work_type t2 on t.type = t2.id
where user_id = #{userId} AND work_day >= #{currentMonthFirstDay}
group by type
</select>
......@@ -230,7 +231,7 @@
</select>
<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
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
......@@ -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
,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
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
......@@ -319,7 +320,7 @@
<if test="userIds != null">
UNION
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
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
......@@ -330,4 +331,14 @@
GROUP BY u.id,u.`name`,t.project_id,t.type,p.project_name, t.is_overtime
</if>
</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>
......@@ -7,6 +7,7 @@
SELECT id,name,reviewer
FROM work_type
</select>
<select id="getIdByReviewer" resultType="java.lang.Integer">
SELECT id
FROM work_type
......
......@@ -13,38 +13,55 @@ import java.io.Serializable;
**/
@Data
@ApiModel(value = "MonthlyWorkingHoursStatistics", description = "统计本月的填报信息")
public class MonthlyWorkingHoursStatistics implements Serializable {
public class MonthlyWorkingHoursStatistics implements Serializable ,Comparable{
private static final long serialVersionUID = -8216457470821285624L;
// 工单类型展示顺序,存储为类型id
private final static Integer[] TYPE_ORDER = {1, 2, 5, 6, 7, 3, 4};
/**
* 工单类型:商机/项目
* 工单类型
*/
@ApiModelProperty(name = "projectType", value = "工单类型:商机/项目")
private String projectType;
private Integer projectType;
/**
* 填报次数
* 工单类型名称
*/
@ApiModelProperty(name = "count", value = "填报次数")
private int count;
@ApiModelProperty(name = "typeName", value = "类型名称")
private String typeName;
/**
* 填报工时
* 已审批
*/
@ApiModelProperty(name = "workTime", value = "填报工时")
private int workTime;
@ApiModelProperty(name = "approved", value = "已审批条数")
private Integer approved;
/**
* 未填报天
* 填报次
*/
@ApiModelProperty(name = "notFilledCount", value = "未填报天数")
private int notFilledCount;
@ApiModelProperty(name = "count", value = "填报次数")
private int count;
/**
* 现存被驳回数
* 填报工时
*/
@ApiModelProperty(name = "rejectCount", value = "现存被驳回数")
private int rejectCount;
@ApiModelProperty(name = "workTime", value = "合计填报工时")
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 {
@ApiModelProperty(name = "projectName", value = "项目名称")
private String projectName;
@ApiModelProperty(name = "deptName", value = "部门名称")
private String deptName;
@ApiModelProperty(name = "statisticsDateAndWorkTime", value = "项目统计的时间段、工时和成本")
List<StatisticsDateAndWorkTime> statisticsDateAndWorkTimes;
......
......@@ -15,14 +15,20 @@ import java.util.List;
**/
@Data
@ApiModel(value = "WorkTimeAndCostCollect", description = "项目的工时和工时成本统计")
public class WorkTimeAndCostCollect implements Serializable {
public class WorkTimeAndCostCollect implements Serializable, Comparable {
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 = "工时类型")
private String type;
@ApiModelProperty(name = "typeName", value = "工时类型")
private String typeName;
/**
* 部门工时统计
......@@ -36,4 +42,19 @@ public class WorkTimeAndCostCollect implements Serializable {
@ApiModelProperty(name = "workTime", value = "工时总计")
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 {
BUSINESS_OPPORTUNITY(2, "商机", 1),
LEAVE(3, "请假", 2),
COMPENSATORY_LEAVE(4, "调休", 2),
EXTERNAL_BUSINESS(5, "外部商务/技术交流", 3),
INTERNAL_TRAINING(6, "内部培训/技术准备/管理", 3),
EXTERNAL_BUSINESS(5, "外部商务技术交流", 3),
INTERNAL_TRAINING(6, "内部培训、技术准备、管理", 3),
OTHER_NON_PROJECTS(7, "其他非项目/商机工作", 3),
;
......
......@@ -8,6 +8,7 @@ import com.github.pagehelper.PageInfo;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import java.util.List;
import java.util.Map;
public interface StatisticsService {
......@@ -25,7 +26,7 @@ public interface StatisticsService {
* @param userId
* @return
*/
List<Object> getMonthlyStatistics(Integer userId);
Map<String,Object> getMonthlyStatistics(Integer userId);
/**
* 获取负责项目的工时汇总:花费工时,工时成本
......
......@@ -226,19 +226,15 @@ public class WorkUserServiceImpl implements WorkUserService {
if (user.getStatus() != ON_THE_JOB_STATUS) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.LEAVE_JOB_USER);
}
/*
if (user.getModifyTime() != user.getCreateTime()) {
修改密码
}
*/
//如果登录来源是PC,判断用户是不是管理员
// 如果登录来源是PC,判断用户是不是管理员
List<Integer> roles = UserRoleLevelUtils.getRole(user.getId());
if (LOGIN_SOURCE.equals(source)) {
if (roles.contains(ManagerEnum.NOT_MANAGER.getCode())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.THE_USER_NOT_MANAGER_PLASE_MANAGER_LOGIN);
}
}
// 限制审核的天数
WorkSubmitAdopt byId = workSubmitAdoptService.getById(1);
//将用户对象转换为dto
......
......@@ -26,6 +26,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
/**
* @description:
......@@ -74,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<List<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);
}
List<Object> monthlyStatistics = statisticsService.getMonthlyStatistics(userId);
Map<String,Object> monthlyStatistics = statisticsService.getMonthlyStatistics(userId);
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