Commit 8e052980 authored by nie'hong's avatar nie'hong

完善工时统计

parent 3619954e
......@@ -22,8 +22,7 @@
ofType="cn.wisenergy.model.dto.ProjectWorkTimeAndCostStatistics">
<result property="projectId" column="project_id"/>
<result property="projectName" column="project_name"/>
<result property="firstTime" column="statistics_start"/>
<result property="lastTime" column="statistics_end"/>
<result property="statisticsTime" column="statistics_time"/>
<result property="totalTime" column="total_time"/>
<result property="cost" column="cost"/>
</collection>
......@@ -84,9 +83,8 @@
<select id="selectList" resultMap="workTimeAndCostCollect">
SELECT type ,<if test="centreId == null">'汇总' AS dept_name,</if> <if test="centreId != null"> dept_name,ptc.dept_id,</if>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
SELECT 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
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 project_id in
<foreach collection="projectIds" open="(" close=")" separator="," item="projectId">
......@@ -107,7 +105,8 @@
<if test="firstDayOfMonth != null">
AND statistics_start >= #{firstDayOfMonth}
</if>
GROUP BY type, <if test="centreId == null"> dept_name,</if> <if test="centreId != null"> dept_name,ptc.dept_id,</if>ptc.project_id,project_name
GROUP BY 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 </if>
</select>
......
......@@ -46,8 +46,7 @@
<collection property="projectWorkTimeAndCostStatistics" ofType="cn.wisenergy.model.dto.ProjectWorkTimeAndCostStatistics">
<result property="projectId" column="project_id"/>
<result property="projectName" column="project_name"/>
<result property="firstTime" column="first_time"/>
<result property="lastTime" column="last_time"/>
<result property="statisticsTime" column="statistics_time"/>
<result property="totalTime" column="total_time"/>
<result property="cost" column="cost"/>
</collection>
......@@ -233,7 +232,7 @@
<select id="getWorkTimeAndCostCollect" resultMap="workTimeAndCostCollect" >
SELECT t.type AS type, t.dept_id AS dept_id,dept_name,
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 ,IF (YEAR (work_day) = YEAR (NOW()), concat(YEAR (work_day),'年',MONTH (work_day),'月') , concat(YEAR(work_day), '年')) AS statistics_time ,ROUND(SUM(t.work_time)/8,2) AS
total_time, SUM(t.work_time * s.day_salary)/8 AS cost ,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
WHERE status IN (2,5) AND s.create_time &lt; t.work_day AND s.end_time > t.work_day
......@@ -254,8 +253,8 @@
<foreach collection="types" item="type" open="(" close=")" separator=",">
#{type}
</foreach>
group by t.type,t.dept_id, dept_name, t.project_id,p.project_name
order by t.dept_id
group by t.type,t.dept_id, dept_name, t.project_id,p.project_name, if(YEAR (work_day) = YEAR(NOW()),',month(work_day)','')
order by t.dept_id,work_day
</select>
<select id="getDaysByDateAndStatus" resultType="date">
......@@ -317,7 +316,7 @@
<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
where user_id = #{userId} and work_day >= #{firstDayOfMonth} AND `type` is not null AND status in
<foreach collection="status" open="(" close=")" separator="," item="s">
#{s}
</foreach>
......
......@@ -30,16 +30,16 @@ public class ProjectWorkTimeAndCostStatistics implements Serializable {
private String projectName;
/**
* 开始统计日期
* 统计时间
*/
@ApiModelProperty(name = "firstTime", value = "开始统计的日期")
private String firstTime;
private String statisticsTime;
/**
*最后统计日期
*/
@ApiModelProperty(name = "lastTime", value = "最后统计的日期")
private String lastTime;
// /**
// *最后统计日期
// */
// @ApiModelProperty(name = "lastTime", value = "最后统计的日期")
// private String lastTime;
/**
* 工时总计:人/天
......
......@@ -321,9 +321,8 @@ public class StatisticsServiceImpl implements StatisticsService {
map.remove("centreId");
types.clear();
// 请假、调休、外部商务、技术交流,内部培训、技术准备、管理,其他非项目/商机工作
for (WorkType workType : workTypes) {
// 查询条件排除项目和商机
for (WorkType workType : workTypes) {
if (!workType.getName().equals(workTypes.get(0).getName()) && !workType.getName().equals(workTypes.get(1).getName())) {
types.add(workType.getId());
}
......@@ -353,9 +352,12 @@ public class StatisticsServiceImpl implements StatisticsService {
}
// 给类型赋值类型名称
for (WorkTimeAndCostCollect timeAndCostCollect : collect) {
WorkType workType = workTypes.get(timeAndCostCollect.getType() - 1);
for (WorkType workType : workTypes) {
if (timeAndCostCollect.getType().equals(workType.getId())) {
timeAndCostCollect.setTypeName(workType.getName());
}
}
}
for (WorkTimeAndCostCollect workTimeAndCostCollect : collect) {
// 类型的总工时
......
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