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

完善工时统计

parent 9b707d69
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<select id="selectList" resultMap="workTimeAndCostCollect"> <select id="selectList" resultMap="workTimeAndCostCollect">
SELECT type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id AS SELECT p.type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id AS
project_id,project_name,concat(min(statistics_start),'~' ,max(statistics_end)) AS statistics_time ,sum(total_time) AS total_time,sum(cost) AS cost project_id,project_name,concat(min(statistics_start),'~' ,max(statistics_end)) AS statistics_time ,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
<where> <where>
...@@ -102,8 +102,8 @@ ...@@ -102,8 +102,8 @@
AND statistics_start >= #{firstDayOfMonth} AND statistics_start >= #{firstDayOfMonth}
</if> </if>
</where> </where>
GROUP BY type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id,project_name GROUP BY p.type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,p.dept_id,</if>p.id,project_name
<if test="centreId != null"> ORDER BY d.sort</if> ORDER BY <if test="centreId != null"> d.sort,</if> p.type
</select> </select>
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
<resultMap id="workTimeAndCostCollect" type="cn.wisenergy.model.dto.WorkTimeAndCostCollect"> <resultMap id="workTimeAndCostCollect" type="cn.wisenergy.model.dto.WorkTimeAndCostCollect">
<result property="type" column="type"/> <result property="type" column="type"/>
<result property="typeName" column="type_name"/>
<collection property="deptProjectWorkTimeAndCosts" resultMap="deptProjectWorkTimeAndCosts"> <collection property="deptProjectWorkTimeAndCosts" resultMap="deptProjectWorkTimeAndCosts">
</collection> </collection>
</resultMap> </resultMap>
...@@ -202,7 +203,7 @@ ...@@ -202,7 +203,7 @@
from work_time_order t join work_type ty on t.type = ty.id from work_time_order t join work_type ty on t.type = ty.id
where user_id = #{userId} AND work_day >= #{currentMonthFirstDay} AND t.status != 3 where user_id = #{userId} AND work_day >= #{currentMonthFirstDay} AND t.status != 3
group by type group by type
order by field(ty.id, 1, 2, 5, 6, 7, 3, 4) order by ty.sort
</select> </select>
<select id="listByDateAndUserId" resultMap="dayWorkTimeAndType"> <select id="listByDateAndUserId" resultMap="dayWorkTimeAndType">
...@@ -262,8 +263,8 @@ ...@@ -262,8 +263,8 @@
IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day), IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day),
'年')) AS statistics_time ,SUM(t.work_time)/8 AS '年')) AS statistics_time ,SUM(t.work_time)/8 AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost total_time, SUM(t.work_time * s.day_salary)/8 AS cost
FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id FROM work_time_order t join work_dept d on d.id = t.dept_id join work_user_salary s on s.user_id = t.user_id join work_type ty on t.type = ty.id
WHERE status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day WHERE t.status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day
<if test="firstDayOfMonth != null"> <if test="firstDayOfMonth != null">
AND work_day >= #{firstDayOfMonth} AND work_day >= #{firstDayOfMonth}
</if> </if>
...@@ -278,7 +279,7 @@ ...@@ -278,7 +279,7 @@
AND centre_id = #{centreId} AND centre_id = #{centreId}
</if> </if>
group by t.type,d.id, dept_name, if(YEAR (work_day) = YEAR(NOW()),',month(work_day)','') group by t.type,d.id, dept_name, if(YEAR (work_day) = YEAR(NOW()),',month(work_day)','')
order by d.id,work_day order by d.id,work_day,ty.sort
</select> </select>
<select id="getDaysByDateAndStatus" resultType="date"> <select id="getDaysByDateAndStatus" resultType="date">
...@@ -329,7 +330,7 @@ ...@@ -329,7 +330,7 @@
IF(t.is_overtime = 0, <if test="!isAll">0</if> IF(t.is_overtime = 0, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS over_time, IF(t.is_overtime=1, <if test="!isAll">0</if> <if test="isAll">null</if>, sum(t.work_time)) AS over_time, IF(t.is_overtime=1, <if test="!isAll">0</if>
<if test="isAll">null</if>, sum(t.work_time)) AS normal_time <if test="isAll">null</if>, sum(t.work_time)) AS normal_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 join work_type ty on t.type = ty.id
where where
t.status in (2,5) AND t.status in (2,5) AND
t.work_day &lt;= #{endDate} t.work_day &lt;= #{endDate}
...@@ -339,7 +340,7 @@ ...@@ -339,7 +340,7 @@
</if> </if>
GROUP BY <if test="isAll">u.id,u.`name`,</if> t.project_id,t.type,p.project_name, t.is_overtime GROUP BY <if test="isAll">u.id,u.`name`,</if> t.project_id,t.type,p.project_name, t.is_overtime
ORDER BY <if test="isAll">convert(u.`name` using gbk) asc</if> ORDER BY <if test="isAll">convert(u.`name` using gbk) asc</if>
<if test="!isAll">field(t.type,1,2,5,6,7,3,4)</if> ,t.project_id <if test="!isAll">ty.sort</if> ,t.project_id
</select> </select>
<select id="selectCountByTypeAndStatus" resultType="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics"> <select id="selectCountByTypeAndStatus" resultType="cn.wisenergy.model.dto.MonthlyWorkingHoursStatistics">
......
...@@ -15,7 +15,7 @@ import java.util.List; ...@@ -15,7 +15,7 @@ import java.util.List;
**/ **/
@Data @Data
@ApiModel(value = "WorkTimeAndCostCollect", description = "项目的工时和工时成本统计") @ApiModel(value = "WorkTimeAndCostCollect", description = "项目的工时和工时成本统计")
public class WorkTimeAndCostCollect implements Serializable, Comparable { public class WorkTimeAndCostCollect implements Serializable {
private static final long serialVersionUID = 7207732278277982917L; private static final long serialVersionUID = 7207732278277982917L;
// 工单类型展示顺序,存储为类型id // 工单类型展示顺序,存储为类型id
...@@ -42,19 +42,4 @@ public class WorkTimeAndCostCollect implements Serializable, Comparable { ...@@ -42,19 +42,4 @@ public class WorkTimeAndCostCollect implements Serializable, Comparable {
@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;
}
} }
...@@ -370,8 +370,6 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -370,8 +370,6 @@ public class StatisticsServiceImpl implements StatisticsService {
workTimeAndCostCollect1.setWorkTime(typeTotalTime); workTimeAndCostCollect1.setWorkTime(typeTotalTime);
} }
// 排序
Collections.sort(workTimeAndCostCollects);
return workTimeAndCostCollects; return workTimeAndCostCollects;
} }
......
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