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

完善工时统计

parent be48dd2a
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
<result column="modify_time" property="modifyTime"/> <result column="modify_time" property="modifyTime"/>
<result column="business_id" property="businessId"/> <result column="business_id" property="businessId"/>
<result column="business_name" property="businessName"/> <result column="business_name" property="businessName"/>
<result column="conclusion_time" property="conclusionTime"/>
</resultMap> </resultMap>
<!-- 通用查询结果列 --> <!-- 通用查询结果列 -->
...@@ -132,14 +133,13 @@ ...@@ -132,14 +133,13 @@
from from
<include refid="table"/> <include refid="table"/>
<where> <where>
<if test="ids != null"> <if test="ids != null">
AND id IN AND id IN
<foreach collection="ids" item="id" separator="," open="(" close=")"> <foreach collection="ids" item="id" separator="," open="(" close=")">
#{id} #{id}
</foreach> </foreach>
</if> </if>
<if test="null !=isConclusion"> <if test="null != isConclusion">
AND is_conclusion = #{isConclusion} AND is_conclusion = #{isConclusion}
</if> </if>
</where> </where>
......
...@@ -342,6 +342,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -342,6 +342,7 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 获取查询结果中的类型 // 获取查询结果中的类型
assert workTimeAndCostCollects != null;
List<Integer> typeList = workTimeAndCostCollects.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList()); List<Integer> typeList = workTimeAndCostCollects.stream().map(WorkTimeAndCostCollect::getType).collect(Collectors.toList());
if (typeList.size() < workTypes.size()) { if (typeList.size() < workTypes.size()) {
int j; int j;
...@@ -396,8 +397,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -396,8 +397,7 @@ public class StatisticsServiceImpl implements StatisticsService {
PageInfo dayWorkTimeOfMonth = this.getDayWorkTimeOfMonth(param); PageInfo dayWorkTimeOfMonth = this.getDayWorkTimeOfMonth(param);
// 返回一个“暂无数据”的Excel // 返回一个“暂无数据”的Excel
if (CollectionUtil.isEmpty(dayWorkTimeOfMonth.getList())) { if (CollectionUtil.isEmpty(dayWorkTimeOfMonth.getList())) {
HSSFWorkbook sheets = this.creatEmptyHSSFWorkbook(); return this.creatEmptyHSSFWorkbook();
return sheets;
} }
Date date = DateUtil.convertStrToDate(param.getYear() + "-" + param.getMonth(), "yyyy-MM"); Date date = DateUtil.convertStrToDate(param.getYear() + "-" + param.getMonth(), "yyyy-MM");
// 传参的时间当月总天数 // 传参的时间当月总天数
...@@ -484,7 +484,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -484,7 +484,7 @@ public class StatisticsServiceImpl implements StatisticsService {
for (int j = 0; j < list.size(); j++) { for (int j = 0; j < list.size(); j++) {
HSSFRow row = sheet.getRow(j + 1); HSSFRow row = sheet.getRow(j + 1);
for (int r = 0; r < dayCount; r++) { for (int r = 0; r < dayCount; r++) {
HSSFCell cell = null; HSSFCell cell;
if (row.getCell(r + 3) == null) { if (row.getCell(r + 3) == null) {
cell = row.createCell(r + 3); cell = row.createCell(r + 3);
} else { } else {
...@@ -511,7 +511,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -511,7 +511,7 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 将字符串中的1到9的数字相加 // 将字符串中的1到9的数字相加
Integer getNumberOfString(String value) { private Integer getNumberOfString(String value) {
value = value.trim(); value = value.trim();
if (StringUtil.isEmpty(value)) { if (StringUtil.isEmpty(value)) {
return null; return null;
...@@ -545,7 +545,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -545,7 +545,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 不是中心级不能选择部门,只能查看自己部门的信息 // 不是中心级不能选择部门,只能查看自己部门的信息
if (!rank.contains(LevelRankEnum.CENTRAL_LEVEL.getRank()) && deptId != user.getDeptId()) { if (!rank.contains(LevelRankEnum.CENTRAL_LEVEL.getRank()) && !deptId.equals(user.getDeptId())) {
throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY); throw new BaseCustomException(BASE_RESP_CODE_ENUM.NO_AUTHORITY);
} }
...@@ -759,8 +759,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -759,8 +759,7 @@ public class StatisticsServiceImpl implements StatisticsService {
log.info("StatisticsServiceImpl[]exportUserStatistics[]param{}" + userId + deptId + startDate + endDate); log.info("StatisticsServiceImpl[]exportUserStatistics[]param{}" + userId + deptId + startDate + endDate);
List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsReport = this.getUserWorkTimeStatisticsReport(userId, deptId, startDate, endDate); List<UserWorkTimeStatisticsByProject> userWorkTimeStatisticsReport = this.getUserWorkTimeStatisticsReport(userId, deptId, startDate, endDate);
if (CollectionUtil.isEmpty(userWorkTimeStatisticsReport)) { if (CollectionUtil.isEmpty(userWorkTimeStatisticsReport)) {
HSSFWorkbook sheets = this.creatEmptyHSSFWorkbook(); return this.creatEmptyHSSFWorkbook();
return sheets;
} }
// 部门信息 // 部门信息
WorkDept dept = workDeptMapper.getById(deptId); WorkDept dept = workDeptMapper.getById(deptId);
...@@ -891,27 +890,27 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -891,27 +890,27 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 合并单元格,第一行 // 合并单元格,第一行
CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 0, 0, row1_lastCellNum + 1); CellRangeAddress cellRangeAddress = new CellRangeAddress(0, 0, 0, row1_lastCellNum);
sheet1.addMergedRegion(cellRangeAddress); sheet1.addMergedRegion(cellRangeAddress);
setBorderStyle(BorderStyle.THIN, cellRangeAddress, sheet1); setBorderStyle(cellRangeAddress, sheet1);
// 序号 // 序号
CellRangeAddress cellRangeAddress1 = new CellRangeAddress(1, 2, 0, 0); CellRangeAddress cellRangeAddress1 = new CellRangeAddress(1, 2, 0, 0);
sheet1.addMergedRegion(cellRangeAddress1); sheet1.addMergedRegion(cellRangeAddress1);
setBorderStyle(BorderStyle.THIN, cellRangeAddress1, sheet1); setBorderStyle(cellRangeAddress1, sheet1);
// 人员 // 人员
CellRangeAddress cellRangeAddress2 = new CellRangeAddress(1, 2, 1, 1); CellRangeAddress cellRangeAddress2 = new CellRangeAddress(1, 2, 1, 1);
sheet1.addMergedRegion(cellRangeAddress2); sheet1.addMergedRegion(cellRangeAddress2);
setBorderStyle(BorderStyle.THIN, cellRangeAddress2, sheet1); setBorderStyle(cellRangeAddress2, sheet1);
// 项目名后的合计 // 项目名后的合计
short lastCellNum1 = row_1.getLastCellNum(); short lastCellNum1 = row_1.getLastCellNum();
CellRangeAddress cellRangeAddress6 = new CellRangeAddress(1, 2, lastCellNum1 - 1, lastCellNum1 - 1); CellRangeAddress cellRangeAddress6 = new CellRangeAddress(1, 2, lastCellNum1 - 1, lastCellNum1 - 1);
sheet1.addMergedRegion(cellRangeAddress6); sheet1.addMergedRegion(cellRangeAddress6);
setBorderStyle(BorderStyle.THIN, cellRangeAddress6, sheet1); setBorderStyle(cellRangeAddress6, sheet1);
// 合计行 // 合计行
CellRangeAddress cellRangeAddress3 = new CellRangeAddress(userWorkTimeStatisticsReport.size() + 1, userWorkTimeStatisticsReport.size() + 1, 0, 1); CellRangeAddress cellRangeAddress3 = new CellRangeAddress(userWorkTimeStatisticsReport.size() + 1, userWorkTimeStatisticsReport.size() + 1, 0, 1);
sheet1.addMergedRegion(cellRangeAddress3); sheet1.addMergedRegion(cellRangeAddress3);
setBorderStyle(BorderStyle.THIN, cellRangeAddress3, sheet1); setBorderStyle(cellRangeAddress3, sheet1);
// 项目行和总计行,正常工时和加班工时表头列数 // 项目行和总计行,正常工时和加班工时表头列数
short lastCellNum = row_2.getLastCellNum(); short lastCellNum = row_2.getLastCellNum();
for (int i = 0; i < lastCellNum / 2; i++) { for (int i = 0; i < lastCellNum / 2; i++) {
...@@ -921,11 +920,11 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -921,11 +920,11 @@ public class StatisticsServiceImpl implements StatisticsService {
// 总计行 // 总计行
CellRangeAddress cellRangeAddress4 = new CellRangeAddress(userWorkTimeStatisticsReport.size() + 2, userWorkTimeStatisticsReport.size() + 2, i * 2, i * 2 + 1); CellRangeAddress cellRangeAddress4 = new CellRangeAddress(userWorkTimeStatisticsReport.size() + 2, userWorkTimeStatisticsReport.size() + 2, i * 2, i * 2 + 1);
sheet1.addMergedRegion(cellRangeAddress4); sheet1.addMergedRegion(cellRangeAddress4);
setBorderStyle(BorderStyle.THIN, cellRangeAddress4, sheet1); setBorderStyle(cellRangeAddress4, sheet1);
if (i > 0) { if (i > 0) {
CellRangeAddress cellRangeAddress5 = new CellRangeAddress(1, 1, i * 2, i * 2 + 1); CellRangeAddress cellRangeAddress5 = new CellRangeAddress(1, 1, i * 2, i * 2 + 1);
sheet1.addMergedRegion(cellRangeAddress5); sheet1.addMergedRegion(cellRangeAddress5);
setBorderStyle(BorderStyle.THIN, cellRangeAddress5, sheet1); setBorderStyle(cellRangeAddress5, sheet1);
} }
} }
// 样式 // 样式
...@@ -954,7 +953,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -954,7 +953,7 @@ public class StatisticsServiceImpl implements StatisticsService {
public HSSFWorkbook exportProjectStatistics(Integer userId, Integer year, String projectIds) { public HSSFWorkbook exportProjectStatistics(Integer userId, Integer year, String projectIds) {
log.info("StatisticsServiceImpl[]exportProjectStatistics[]param{}" + userId + year + projectIds); log.info("StatisticsServiceImpl[]exportProjectStatistics[]param{}" + userId + year + projectIds);
// 将项目主键解析出来 // 将项目主键解析出来
List<Integer> projectIdList = Arrays.asList(projectIds.split(",")).stream().map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList()); List<Integer> projectIdList = Arrays.stream(projectIds.split(",")).map(s -> Integer.parseInt(s.trim())).collect(Collectors.toList());
// year为空,为今年 // year为空,为今年
if (year == null) { if (year == null) {
year = DateUtil.getYear(new Date()); year = DateUtil.getYear(new Date());
...@@ -974,22 +973,34 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -974,22 +973,34 @@ public class StatisticsServiceImpl implements StatisticsService {
// 个人对于项目的贡献 // 个人对于项目的贡献
map.replace("isAll", true); map.replace("isAll", true);
List<ProjectStatisticsByMonth> projectStatisticsByMonths2 = workProjectTimeCostMapper.selectListStatistics(map); List<ProjectStatisticsByMonth> projectStatisticsByMonths2 = workProjectTimeCostMapper.selectListStatistics(map);
// 所有部门
List<WorkDept> depts = workDeptMapper.getDeptByCondition(null);
// 补齐未查找到数据的项目 // 补齐未查找到数据的项目
List<Integer> projectCollect = projectStatisticsByMonths.stream().map(ProjectStatisticsByMonth::getProjectId).collect(Collectors.toList()); List<Integer> projectCollect = projectStatisticsByMonths.stream().map(ProjectStatisticsByMonth::getProjectId).collect(Collectors.toList());
projectIdList.removeAll(projectCollect); projectIdList.removeAll(projectCollect);
if (CollectionUtil.isNotEmpty(projectIdList)) {
List<WorkProject> projectsByIds = workProjectMapper.getProjectsByIds(projectIdList, null); List<WorkProject> projectsByIds = workProjectMapper.getProjectsByIds(projectIdList, null);
for (WorkProject projectsById : projectsByIds) { for (WorkProject projectsById : projectsByIds) {
String deptName = "";
for (WorkDept dept : depts) {
if (dept.getId() == projectsById.getDeptId()) {
deptName = dept.getDeptName();
}
}
ProjectStatisticsByMonth projectStatisticsByMonth = new ProjectStatisticsByMonth(); ProjectStatisticsByMonth projectStatisticsByMonth = new ProjectStatisticsByMonth();
projectStatisticsByMonth.setProjectId(projectsById.getId()); projectStatisticsByMonth.setProjectId(projectsById.getId());
projectStatisticsByMonth.setProjectName(projectsById.getProjectName()); projectStatisticsByMonth.setProjectName(projectsById.getProjectName());
projectStatisticsByMonth.setDeptName(deptName);
projectStatisticsByMonth.setStatisticsDateAndWorkTimes(new ArrayList<>()); projectStatisticsByMonth.setStatisticsDateAndWorkTimes(new ArrayList<>());
projectStatisticsByMonths.add(projectStatisticsByMonth); projectStatisticsByMonths.add(projectStatisticsByMonth);
} }
}
// 如果没有项目统计数据,返回Excel显示暂无数据 // 如果没有项目统计数据,返回Excel显示暂无数据
if (CollectionUtil.isEmpty(projectStatisticsByMonths)) { if (CollectionUtil.isEmpty(projectStatisticsByMonths)) {
HSSFWorkbook sheets = creatEmptyHSSFWorkbook(); return creatEmptyHSSFWorkbook();
return sheets;
} }
// 计算项目合计 // 计算项目合计
this.addProjectStatisticsTotalTime(projectStatisticsByMonths, "合计"); this.addProjectStatisticsTotalTime(projectStatisticsByMonths, "合计");
...@@ -1002,6 +1013,8 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1002,6 +1013,8 @@ public class StatisticsServiceImpl implements StatisticsService {
this.conversionDateFormat(projectStatisticsByMonths1, yearMonthList, null, true); this.conversionDateFormat(projectStatisticsByMonths1, yearMonthList, null, true);
this.conversionDateFormat(projectStatisticsByMonths2, yearMonthList, null, false); this.conversionDateFormat(projectStatisticsByMonths2, yearMonthList, null, false);
HSSFWorkbook sheets = new HSSFWorkbook(); HSSFWorkbook sheets = new HSSFWorkbook();
for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) { for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) {
// 项目名作为sheet名 // 项目名作为sheet名
...@@ -1009,11 +1022,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1009,11 +1022,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// sheet名不能存在“/” // sheet名不能存在“/”
String s = projectName.replaceAll("/", "_"); String s = projectName.replaceAll("/", "_");
HSSFSheet sheet = sheets.createSheet(s); HSSFSheet sheet = sheets.createSheet(s);
// 项目无部门下的数据,改sheet页为空白
if (!collect1.contains(projectStatisticsByMonth.getProjectId())) {
sheet.createRow(0).createCell(0).setCellValue("暂无数据");
continue;
}
// 普通样式 // 普通样式
HSSFCellStyle ordinaryCellStyle = this.createOrdinaryCellStyle(sheets); HSSFCellStyle ordinaryCellStyle = this.createOrdinaryCellStyle(sheets);
// 将人员所在部门列宽加宽 // 将人员所在部门列宽加宽
...@@ -1026,7 +1035,13 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1026,7 +1035,13 @@ public class StatisticsServiceImpl implements StatisticsService {
// 合并第一行的前五个单元格 // 合并第一行的前五个单元格
CellRangeAddress cellRangeAddress2 = new CellRangeAddress(0, 0, 0, 15); CellRangeAddress cellRangeAddress2 = new CellRangeAddress(0, 0, 0, 15);
sheet.addMergedRegion(cellRangeAddress2); sheet.addMergedRegion(cellRangeAddress2);
setBorderStyle(BorderStyle.THIN, cellRangeAddress2, sheet); setBorderStyle(cellRangeAddress2, sheet);
// 项目无部门下的数据,改sheet页为空白
if (!collect1.contains(projectStatisticsByMonth.getProjectId())) {
sheet.createRow(1).createCell(0).setCellValue("暂无数据");
continue;
}
// 人员所在部门、序号,一个部门重复一次 // 人员所在部门、序号,一个部门重复一次
for (ProjectStatisticsByMonth statisticsByMonth : projectStatisticsByMonths1) { for (ProjectStatisticsByMonth statisticsByMonth : projectStatisticsByMonths1) {
...@@ -1068,7 +1083,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1068,7 +1083,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 合并合计单元格 // 合并合计单元格
CellRangeAddress cellRangeAddress1 = new CellRangeAddress(lastRowNum1 + 1, lastRowNum1 + 1, 0, 2); CellRangeAddress cellRangeAddress1 = new CellRangeAddress(lastRowNum1 + 1, lastRowNum1 + 1, 0, 2);
sheet.addMergedRegion(cellRangeAddress1); sheet.addMergedRegion(cellRangeAddress1);
setBorderStyle(BorderStyle.THIN, cellRangeAddress1, sheet); setBorderStyle(cellRangeAddress1, sheet);
// 写入部门的工时 // 写入部门的工时
this.writeWorkTimeToExcel(statisticsByMonth, row_total, row_last); this.writeWorkTimeToExcel(statisticsByMonth, row_total, row_last);
} }
...@@ -1079,7 +1094,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1079,7 +1094,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 合并单元格 // 合并单元格
CellRangeAddress cellRangeAddress = new CellRangeAddress(lastRowNum1 + 1, lastRowNum1 + 1, 0, 2); CellRangeAddress cellRangeAddress = new CellRangeAddress(lastRowNum1 + 1, lastRowNum1 + 1, 0, 2);
sheet.addMergedRegion(cellRangeAddress); sheet.addMergedRegion(cellRangeAddress);
setBorderStyle(BorderStyle.THIN, cellRangeAddress, sheet); setBorderStyle(cellRangeAddress, sheet);
// 写入项目的总合计工时 // 写入项目的总合计工时
HSSFRow row1 = sheet.getRow(1); HSSFRow row1 = sheet.getRow(1);
...@@ -1157,14 +1172,14 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1157,14 +1172,14 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
//获取用户某月已填报的日期,如果一天中只有被驳回则不为已填报 //获取用户某月已填报的日期,如果一天中只有被驳回则不为已填报
public List<Date> currentMonthFilledDays(Integer userId, Date date) { private List<Date> currentMonthFilledDays(Integer userId, Date date) {
log.info("StatisticsServiceImpl[]currentMonthFilledDays[]input.method"); log.info("StatisticsServiceImpl[]currentMonthFilledDays[]input.method");
List<Date> currentMonthFilledDays = workTimeOrderMapper.getDaysByDateAndStatus(userId, date); List<Date> currentMonthFilledDays = workTimeOrderMapper.getDaysByDateAndStatus(userId, date);
return currentMonthFilledDays; return currentMonthFilledDays;
} }
// 设置单元格基本样式 // 设置单元格基本样式
HSSFCellStyle createOrdinaryCellStyle(HSSFWorkbook sheets) { private HSSFCellStyle createOrdinaryCellStyle(HSSFWorkbook sheets) {
HSSFCellStyle cellStyle = sheets.createCellStyle(); HSSFCellStyle cellStyle = sheets.createCellStyle();
// cellStyle.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); // cellStyle.setFillBackgroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex());
cellStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex()); cellStyle.setFillForegroundColor(HSSFColor.HSSFColorPredefined.WHITE.getIndex());
...@@ -1192,7 +1207,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1192,7 +1207,7 @@ public class StatisticsServiceImpl implements StatisticsService {
// 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月 // 部门主键不为空时,日期格式只有某月。为空时,日期格式为某年统计的第一个月为某年某月,其余为某月
public void conversionDateFormat(List<ProjectStatisticsByMonth> projectStatisticsByMonths, List<String> yearMonthList, Integer projectId, boolean isTotal) { private void conversionDateFormat(List<ProjectStatisticsByMonth> projectStatisticsByMonths, List<String> yearMonthList, Integer projectId, boolean isTotal) {
for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) { for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) {
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth.getStatisticsDateAndWorkTimes(); List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth.getStatisticsDateAndWorkTimes();
for (int i = 0; i < yearMonthList.size(); i++) { for (int i = 0; i < yearMonthList.size(); i++) {
...@@ -1235,17 +1250,16 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1235,17 +1250,16 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 获取用户权限 // 获取用户权限
public List<String> getUserAuthority(List<UserRoleLevelDto> roleUserLevel) { private List<String> getUserAuthority(List<UserRoleLevelDto> roleUserLevel) {
if (CollectionUtil.isEmpty(roleUserLevel)) { if (CollectionUtil.isEmpty(roleUserLevel)) {
return null; return null;
} }
// 获取权限名 // 获取权限名
List<String> collect = roleUserLevel.stream().map(UserRoleLevelDto::getLevelName).collect(Collectors.toList()); return roleUserLevel.stream().map(UserRoleLevelDto::getLevelName).collect(Collectors.toList());
return collect;
} }
// 获取用户当前权限对应的级别 // 获取用户当前权限对应的级别
public List<Integer> getUserRank(List<UserRoleLevelDto> workLevels, String levelName) { private List<Integer> getUserRank(List<UserRoleLevelDto> workLevels, String levelName) {
List<Integer> rank = new ArrayList<>(); List<Integer> rank = new ArrayList<>();
if (CollectionUtil.isEmpty(workLevels)) { if (CollectionUtil.isEmpty(workLevels)) {
return rank; return rank;
...@@ -1259,7 +1273,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1259,7 +1273,7 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 获取开始时间到结束时间这个时间段的所有年月集合 // 获取开始时间到结束时间这个时间段的所有年月集合
List<String> getYearMonthList(String startDate, String endDate) { private List<String> getYearMonthList(String startDate, String endDate) {
String pattern = "yyyy年M月"; String pattern = "yyyy年M月";
SimpleDateFormat sdf = new SimpleDateFormat(pattern); SimpleDateFormat sdf = new SimpleDateFormat(pattern);
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
...@@ -1277,22 +1291,21 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1277,22 +1291,21 @@ public class StatisticsServiceImpl implements StatisticsService {
return list; return list;
} }
public String simpleDateToYearMonthDay(String simple) { private String simpleDateToYearMonthDay(String simple) {
String date1 = simple.replaceFirst("-", "年"); String date1 = simple.replaceFirst("-", "年");
String date2 = date1.replaceFirst("-", "月"); String date2 = date1.replaceFirst("-", "月");
String date3 = date2 + "日"; return date2 + "日";
return date3;
} }
//合并单元格后添加边框 //合并单元格后添加边框
public static void setBorderStyle(BorderStyle borderStyle, CellRangeAddress region, HSSFSheet sheet) { private static void setBorderStyle(CellRangeAddress region, HSSFSheet sheet) {
RegionUtil.setBorderBottom(borderStyle, region, sheet); //下边框 RegionUtil.setBorderBottom(BorderStyle.THIN, region, sheet); //下边框
RegionUtil.setBorderLeft(borderStyle, region, sheet); //左边框 RegionUtil.setBorderLeft(BorderStyle.THIN, region, sheet); //左边框
RegionUtil.setBorderRight(borderStyle, region, sheet); //右边框 RegionUtil.setBorderRight(BorderStyle.THIN, region, sheet); //右边框
RegionUtil.setBorderTop(borderStyle, region, sheet); //上边框 RegionUtil.setBorderTop(BorderStyle.THIN, region, sheet); //上边框
} }
public void addProjectStatisticsTotalTime(List<ProjectStatisticsByMonth> projectStatisticsByMonths, String statisticsName) { private void addProjectStatisticsTotalTime(List<ProjectStatisticsByMonth> projectStatisticsByMonths, String statisticsName) {
for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) { for (ProjectStatisticsByMonth projectStatisticsByMonth : projectStatisticsByMonths) {
// 一条统计的 // 一条统计的
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth.getStatisticsDateAndWorkTimes(); List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth.getStatisticsDateAndWorkTimes();
...@@ -1318,7 +1331,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1318,7 +1331,7 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 写入对应时间的工时 // 写入对应时间的工时
public void writeWorkTimeToExcel(ProjectStatisticsByMonth projectStatisticsByMonth1, HSSFRow row, HSSFRow lastRow) { private void writeWorkTimeToExcel(ProjectStatisticsByMonth projectStatisticsByMonth1, HSSFRow row, HSSFRow lastRow) {
// 一个人的统计月份与工时 // 一个人的统计月份与工时
List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth1.getStatisticsDateAndWorkTimes(); List<ProjectStatisticsByMonth.StatisticsDateAndWorkTime> statisticsDateAndWorkTimes = projectStatisticsByMonth1.getStatisticsDateAndWorkTimes();
// 月份匹配,写入工时 // 月份匹配,写入工时
...@@ -1331,7 +1344,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1331,7 +1344,7 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
} }
public void closeSheets(HSSFWorkbook sheets) { private void closeSheets(HSSFWorkbook sheets) {
try { try {
sheets.close(); sheets.close();
} catch (IOException e) { } catch (IOException e) {
...@@ -1340,7 +1353,7 @@ public class StatisticsServiceImpl implements StatisticsService { ...@@ -1340,7 +1353,7 @@ public class StatisticsServiceImpl implements StatisticsService {
} }
// 返回一个空的Excel // 返回一个空的Excel
public HSSFWorkbook creatEmptyHSSFWorkbook() { private HSSFWorkbook creatEmptyHSSFWorkbook() {
HSSFWorkbook sheets = new HSSFWorkbook(); HSSFWorkbook sheets = new HSSFWorkbook();
HSSFSheet sheet = sheets.createSheet(); HSSFSheet sheet = sheets.createSheet();
sheet.createRow(0).createCell(0).setCellValue("暂无数据"); sheet.createRow(0).createCell(0).setCellValue("暂无数据");
......
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