Commit 2d2986bc authored by nie'hong's avatar nie'hong

完善工时统计

parent 99b61ac1
......@@ -55,6 +55,7 @@
SET is_conclusion = 0, conclusion_time = now()
WHERE id = #{id}
</update>
<update id="updateProject">
UPDATE
<include refid="table"/>
......@@ -137,6 +138,7 @@
</if>
</where>
</select>
<select id="getManagerProjectsDto" resultType="cn.wisenergy.model.dto.ManagerProjectsDto">
select
p.id,p.oa_project_id,p.project_name,p.business_id,p.business_name,p.manager_id,d.dept_name,lu.manager_name,p.dept_id,p.modify_time,p.type,p.create_time,p.is_conclusion,
......
......@@ -106,12 +106,12 @@
</if>
</where>
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
ORDER BY <if test="centreId != null"> d.sort,</if> p.type
ORDER BY p.type<if test="centreId != null">, d.sort</if>
</select>
<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_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">project_id,'合计' 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
<where>
<if test="projectId != null ">
......
......@@ -914,7 +914,10 @@ public class StatisticsServiceImpl implements StatisticsService {
setBorderStyle(BorderStyle.THIN, cellRangeAddress3, sheet1);
// 项目行和总计行,正常工时和加班工时表头列数
short lastCellNum = row_2.getLastCellNum();
for (int i = 0; i < lastCellNum / 2-1; i++) {
for (int i = 0; i < lastCellNum / 2; i++) {
if (row_1.getCell(2 * i).getStringCellValue().equals("请假") || row_1.getCell(2 * i).getStringCellValue().equals("调休")) {
continue;
}
// 总计行
CellRangeAddress cellRangeAddress4 = new CellRangeAddress(userWorkTimeStatisticsReport.size() + 2, userWorkTimeStatisticsReport.size() + 2, i * 2, i * 2 + 1);
sheet1.addMergedRegion(cellRangeAddress4);
......@@ -960,11 +963,29 @@ public class StatisticsServiceImpl implements StatisticsService {
Map<String, Object> map = new HashMap<>();
map.put("year", year);
map.put("projectIds", projectIdList);
// 项目的统计
List<ProjectStatisticsByMonth> projectStatisticsByMonths = workProjectTimeCostMapper.selectListByMonth(map);
// 部门对于这些项目的贡献
map.put("isAll", false);
List<ProjectStatisticsByMonth> projectStatisticsByMonths1 = workProjectTimeCostMapper.selectListStatistics(map);
List<Integer> collect1 = projectStatisticsByMonths1.stream().map(ProjectStatisticsByMonth::getProjectId).collect(Collectors.toList());
// 个人对于项目的贡献
map.replace("isAll", true);
List<ProjectStatisticsByMonth> projectStatisticsByMonths2 = workProjectTimeCostMapper.selectListStatistics(map);
// 补齐未查找到数据的项目
List<Integer> projectCollect = projectStatisticsByMonths.stream().map(ProjectStatisticsByMonth::getProjectId).collect(Collectors.toList());
projectIdList.removeAll(projectCollect);
List<WorkProject> projectsByIds = workProjectMapper.getProjectsByIds(projectIdList, null);
for (WorkProject projectsById : projectsByIds) {
ProjectStatisticsByMonth projectStatisticsByMonth = new ProjectStatisticsByMonth();
projectStatisticsByMonth.setProjectId(projectsById.getId());
projectStatisticsByMonth.setProjectName(projectsById.getProjectName());
projectStatisticsByMonth.setStatisticsDateAndWorkTimes(new ArrayList<>());
projectStatisticsByMonths.add(projectStatisticsByMonth);
}
// 如果没有项目统计数据,返回Excel显示暂无数据
if (CollectionUtil.isEmpty(projectStatisticsByMonths)) {
HSSFWorkbook sheets = creatEmptyHSSFWorkbook();
......@@ -985,7 +1006,14 @@ public class StatisticsServiceImpl implements StatisticsService {
for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) {
// 项目名作为sheet名
String projectName = projectStatisticsByMonth.getProjectName();
HSSFSheet sheet = sheets.createSheet(projectName);
// sheet名不能存在“/”
String s = projectName.replaceAll("/", "_");
HSSFSheet sheet = sheets.createSheet(s);
// 项目无部门下的数据,改sheet页为空白
if (!collect1.contains(projectStatisticsByMonth.getProjectId())) {
sheet.createRow(0).createCell(0).setCellValue("暂无数据");
continue;
}
// 普通样式
HSSFCellStyle ordinaryCellStyle = this.createOrdinaryCellStyle(sheets);
// 将人员所在部门列宽加宽
......@@ -1053,7 +1081,6 @@ public class StatisticsServiceImpl implements StatisticsService {
sheet.addMergedRegion(cellRangeAddress);
setBorderStyle(BorderStyle.THIN, cellRangeAddress, sheet);
// 写入项目的总合计工时
HSSFRow row1 = sheet.getRow(1);
this.writeWorkTimeToExcel(projectStatisticsByMonth, row, row1);
......@@ -1297,7 +1324,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 月份匹配,写入工时
for (ProjectStatisticsByMonth.StatisticsDateAndWorkTime statisticsDateAndWorkTime : statisticsDateAndWorkTimes) {
for (int j = 3; j < 16; j++) {
if (statisticsDateAndWorkTime.getDate().equals(lastRow.getCell(j).getStringCellValue()) && statisticsDateAndWorkTime.getTotalTime() != null) {
if (lastRow.getCell(j) != null && statisticsDateAndWorkTime.getDate().equals(lastRow.getCell(j).getStringCellValue()) && statisticsDateAndWorkTime.getTotalTime() != null) {
row.createCell(j).setCellValue(Double.valueOf(statisticsDateAndWorkTime.getTotalTime().stripTrailingZeros().toPlainString()));
}
}
......
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