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

完善工时统计

parent 890285e2
...@@ -114,7 +114,7 @@ ...@@ -114,7 +114,7 @@
<select id="selectListByMonth" resultMap="projectStatisticsByMonth"> <select id="selectListByMonth" resultMap="projectStatisticsByMonth">
select <if test="projectId == null and projectIds == null">'合计' AS project_name,</if> <if test="projectId != null"> project_name, dept_name,</if> <if test=" projectIds != null"> project_id,project_name, 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 select <if test="projectId == null and projectIds == null">'合计' AS project_name,</if> <if test="projectId != null"> project_name, dept_name,</if> <if test=" projectIds != null"> project_id,project_name, 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 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>
<if test="projectId != null "> <if test="projectId != null ">
......
...@@ -213,7 +213,7 @@ ...@@ -213,7 +213,7 @@
) )
</if> </if>
</where> </where>
ORDER BY work_day DESC ORDER BY work_day DESC,create_time DESC
</select> </select>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
......
...@@ -53,7 +53,7 @@ public class ManagerProjectsDto implements Serializable { ...@@ -53,7 +53,7 @@ public class ManagerProjectsDto implements Serializable {
private String deptName; private String deptName;
@ApiModelProperty(name = "workTime",value = "工时预算") @ApiModelProperty(name = "workTime",value = "工时预算")
private Integer workTime; private BigDecimal workTime;
@ApiModelProperty(name = "costBudget",value = "成本预算,以万为单位") @ApiModelProperty(name = "costBudget",value = "成本预算,以万为单位")
private BigDecimal costBudget; private BigDecimal costBudget;
......
...@@ -717,6 +717,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -717,6 +717,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 查询所管理项目的项目统计总计 // 查询所管理项目的项目统计总计
List<ProjectStatisticsByMonth> projectStatisticsByMonths = workProjectTimeCostMapper.selectListByMonth(map); List<ProjectStatisticsByMonth> projectStatisticsByMonths = workProjectTimeCostMapper.selectListByMonth(map);
// 合计统计为空,造合计对象 // 合计统计为空,造合计对象
if (CollectionUtil.isEmpty(projectStatisticsByMonths)) { if (CollectionUtil.isEmpty(projectStatisticsByMonths)) {
ProjectStatisticsByMonth projectStatisticsByMonth = new ProjectStatisticsByMonth(); ProjectStatisticsByMonth projectStatisticsByMonth = new ProjectStatisticsByMonth();
...@@ -726,6 +727,29 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -726,6 +727,29 @@ public class StatisticsServiceImpl implements StatisticsService {
projectStatisticsByMonths.add(projectStatisticsByMonth); projectStatisticsByMonths.add(projectStatisticsByMonth);
} }
// date排序
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes1 = projectStatisticsByMonths.get(0).getStatisticsDateAndWorkTimes();
for (int i = 0; i < statisticsDateAndWorkTimes1.size()-1; i++) {
for (int j = 0; j < statisticsDateAndWorkTimes1.size()-1; j++) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime = statisticsDateAndWorkTimes1.get(j);
String substring = statisticsDateAndWorkTime.getDate().substring(5, 6);
Integer integer = Integer.valueOf(substring);
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime1 = statisticsDateAndWorkTimes1.get(j+1);
String substring1 = statisticsDateAndWorkTime1.getDate().substring(5, 6);
Integer integer1 = Integer.valueOf(substring1);
if (integer > integer1) {
ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime2 = statisticsDateAndWorkTime;
statisticsDateAndWorkTimes1.set(j,statisticsDateAndWorkTimes1.get(j+1));
statisticsDateAndWorkTimes1.set(j + 1, statisticsDateAndWorkTime2);
}
}
}
projectStatisticsByMonths.get(0).setStatisticsDateAndWorkTimes(statisticsDateAndWorkTimes1);
// 查询每个项目单独统计的集合 // 查询每个项目单独统计的集合
List<ProjectStatisticsByMonth> projectStatisticsByMonths1 = workProjectTimeCostMapper.selectListStatistics(map); List<ProjectStatisticsByMonth> projectStatisticsByMonths1 = workProjectTimeCostMapper.selectListStatistics(map);
...@@ -768,12 +792,11 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -768,12 +792,11 @@ public class StatisticsServiceImpl implements StatisticsService {
List<String> yearMonthList = this.getYearMonthList(startDate, endDate); List<String> yearMonthList = this.getYearMonthList(startDate, endDate);
// 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月 // 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月
this.conversionDateFormat(projectStatisticsByMonths, yearMonthList, projectId, true); this.conversionDateFormat(projectStatisticsByMonths, yearMonthList, projectId, false);
this.conversionDateFormat(projectStatisticsByMonths1, yearMonthList, projectId, false); this.conversionDateFormat(projectStatisticsByMonths1, yearMonthList, projectId, false);
// 将查询结果封装在一起 // 将查询结果封装在一起
projectStatisticsByMonths.addAll(0, projectStatisticsByMonths1); projectStatisticsByMonths.addAll(0, projectStatisticsByMonths1);
// 计算项目工时和成本合计 // 计算项目工时和成本合计
this.addProjectStatisticsTotalTime(projectStatisticsByMonths, "项目合计"); this.addProjectStatisticsTotalTime(projectStatisticsByMonths, "项目合计");
......
...@@ -81,11 +81,20 @@ ...@@ -81,11 +81,20 @@
<orderEntry type="library" name="Maven: org.springframework:spring-test:5.1.7.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework:spring-test:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.xmlunit:xmlunit-core:2.6.2" level="project" /> <orderEntry type="library" name="Maven: org.xmlunit:xmlunit-core:2.6.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.2" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.2" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.2" level="project" /> <orderEntry type="library" name="Maven: org.mybatis.spring.boot:mybatis-spring-boot-autoconfigure:2.1.2" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.4" level="project" /> <orderEntry type="library" name="Maven: org.mybatis:mybatis:3.5.4" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.4" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.10" level="project" /> <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-starter:1.2.10" level="project" />
<orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.10" level="project" /> <orderEntry type="library" name="Maven: com.github.pagehelper:pagehelper-spring-boot-autoconfigure:1.2.10" level="project" />
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" /> <orderEntry type="library" name="Maven: mysql:mysql-connector-java:8.0.16" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.1.2" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.1.2" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.1.2" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.1.2" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.1.2" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.1.22" level="project" /> <orderEntry type="library" name="Maven: com.alibaba:druid-spring-boot-starter:1.1.22" level="project" />
<orderEntry type="library" name="Maven: com.alibaba:druid:1.1.22" level="project" /> <orderEntry type="library" name="Maven: com.alibaba:druid:1.1.22" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.1.5.RELEASE" level="project" /> <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-data-redis:2.1.5.RELEASE" level="project" />
...@@ -124,16 +133,6 @@ ...@@ -124,16 +133,6 @@
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" /> <orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
<orderEntry type="library" name="Maven: joda-time:joda-time:2.10.2" level="project" /> <orderEntry type="library" name="Maven: joda-time:joda-time:2.10.2" level="project" />
<orderEntry type="library" name="Maven: cn.hutool:hutool-all:4.6.7" level="project" /> <orderEntry type="library" name="Maven: cn.hutool:hutool-all:4.6.7" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-generator:3.4.1" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-annotation:3.4.0" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-extension:3.4.0" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-core:3.4.0" level="project" />
<orderEntry type="library" name="Maven: org.mybatis:mybatis-spring:2.0.5" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus-boot-starter:3.4.0" level="project" />
<orderEntry type="library" name="Maven: com.baomidou:mybatis-plus:3.4.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-jdbc:2.1.5.RELEASE" level="project" />
<orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" />
<orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.7.RELEASE" level="project" />
<orderEntry type="library" name="Maven: org.apache.velocity:velocity-engine-core:2.0" level="project" /> <orderEntry type="library" name="Maven: org.apache.velocity:velocity-engine-core:2.0" level="project" />
<orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:1.4" level="project" /> <orderEntry type="library" name="Maven: com.github.jsqlparser:jsqlparser:1.4" level="project" />
<orderEntry type="library" name="Maven: org.apache.shiro:shiro-spring-boot-starter:1.4.1" level="project" /> <orderEntry type="library" name="Maven: org.apache.shiro:shiro-spring-boot-starter:1.4.1" level="project" />
......
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