Commit 583e7ba6 authored by nie'hong's avatar nie'hong

完善工时统计

parent 409af0aa
......@@ -34,6 +34,7 @@
<result property="deptName" column="dept_name"/>
<collection property="statisticsDateAndWorkTimes" ofType="cn.wisenergy.model.dto.ProjectStatisticsByMonth$StatisticsDateAndWorkTime">
<result property="date" column="date"/>
<result property="year" column="year"/>
<result property="totalTime" column="total_time"/>
<result property="cost" column="cost"/>
</collection>
......@@ -109,7 +110,7 @@
<select id="selectListByMonth" resultMap="projectStatisticsByMonth">
select <if test="projectId == null">'合计' AS project_name,</if> <if test="projectId != null"> project_name,'合计' AS dept_name,</if> group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date, sum(total_time) AS total_time, sum(cost) AS cost
select <if test="projectId == null">'合计' AS project_name,</if> <if test="projectId != null"> project_name,'合计' AS dept_name,</if> group_CONCAT(DISTINCT YEAR (statistics_start),'年',MONTH (statistics_start),'月') AS date,year(statistics_start) AS year, 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 ptc.dept_id = d.id
<where>
<if test="projectId != null ">
......@@ -130,7 +131,7 @@
<select id="selectListStatistics" resultMap="projectStatisticsByMonth">
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,year(statistics_start) AS year,
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>
......
......@@ -38,6 +38,11 @@ public class ProjectStatisticsByMonth implements Serializable {
*/
String date;
/**
* 年
*/
Integer year;
/**
* 总工时
*/
......
......@@ -807,36 +807,6 @@ public class StatisticsServiceImpl implements StatisticsService {
}
}
}
/**
if (projectId != null) {
// 项目的全周期统计
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonths.get(0).getStatisticsDateAndWorkTimes();
// 遍历各个部门对改项目的贡献集合
for (ProjectStatisticsByMonth statisticsByMonth : projectStatisticsByMonths1) {
// 部门的各个月对项目的贡献工时
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes1 = statisticsByMonth.getStatisticsDateAndWorkTimes();
// 如果该部门对该项目的贡献的时间不是和该项目周期一样
if (statisticsDateAndWorkTimes1.size() < statisticsDateAndWorkTimes.size()) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime1 = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime();
statisticsDateAndWorkTime1.setDate("");
statisticsDateAndWorkTimes1.add(statisticsDateAndWorkTime1);
for (int i = 0; i < statisticsDateAndWorkTimes.size(); i++) {
if (!statisticsDateAndWorkTimes.get(i).getDate().equals(statisticsDateAndWorkTimes1.get(i).getDate())) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = new ProjectStatisticsByMonth.StatisticsDateAndWorkTime();
statisticsDateAndWorkTime.setTotalTime(new BigDecimal("0"));
statisticsDateAndWorkTime.setCost(new BigDecimal("0"));
statisticsDateAndWorkTime.setDate(statisticsDateAndWorkTimes.get(i).getDate());
statisticsDateAndWorkTimes1.add(i, statisticsDateAndWorkTime);
} else {
continue;
}
}
statisticsDateAndWorkTimes1.remove(statisticsDateAndWorkTimes1.size() - 1);
}
}
}
**/
// 将查询结果封装在一起
projectStatisticsByMonths.addAll(0, projectStatisticsByMonths1);
......@@ -847,12 +817,15 @@ public class StatisticsServiceImpl implements StatisticsService {
startDate = projectStatisticsByMonths.get(0).getStatisticsDateAndWorkTimes().get(0).getDate();
endDate = workProjectMapper.getLastDate(projectId);
} else {
if (year != DateUtil.getYear(new Date())) {
if (year < DateUtil.getYear(new Date())) {
startDate = year + "年1月";
endDate = year + "年12月";
}else {
}else if (year == DateUtil.getYear(new Date())){
startDate = DateUtil.convertDateToStr(DateUtil.getFirstDayOfYear(new Date()), "yyyy年M月");
endDate = DateUtil.convertDateToStr(new Date(), "yyyy年M月");
}else {
startDate = "";
endDate = "";
}
}
// 项目的周期年月集合
......@@ -990,6 +963,7 @@ public class StatisticsServiceImpl implements StatisticsService {
statisticsDateAndWorkTime.setDate(s);
statisticsDateAndWorkTime.setTotalTime(new BigDecimal("0"));
statisticsDateAndWorkTime.setCost(new BigDecimal("0"));
statisticsDateAndWorkTime.setYear(Integer.valueOf(s.substring(0,4)));
statisticsDateAndWorkTimes.add(i, statisticsDateAndWorkTime);
}
SimpleDateFormat format = new SimpleDateFormat("yyyy年M月");
......@@ -1041,10 +1015,14 @@ public class StatisticsServiceImpl implements StatisticsService {
return rank;
}
// 获取开始时间到结束时间这个时间段的所有年月集合
List<String> getYearMonthList(String startDate, String endDate) {
String pattern = "yyyy年M月";
SimpleDateFormat sdf = new SimpleDateFormat(pattern);
List<String> list = new ArrayList<>();
if ("".equals(startDate)) {
return list;
}
Calendar calendar = DateUtil.convertStrToCalendar(startDate, pattern);
Calendar calendar2 = DateUtil.convertStrToCalendar(endDate, pattern);
list.add(startDate);
......
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