|
@@ -2750,11 +2750,130 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
allList.add(sumRow);
|
|
allList.add(sumRow);
|
|
//生成excel文件导出
|
|
//生成excel文件导出
|
|
String fileName = "加班统计报表_"+System.currentTimeMillis();
|
|
String fileName = "加班统计报表_"+System.currentTimeMillis();
|
|
- String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , allList, path);
|
|
|
|
|
|
+
|
|
|
|
+ //按照项目统计
|
|
|
|
+ List<List<String>> groupByProjectList = new ArrayList<>();
|
|
|
|
+ headList = new ArrayList<String>();
|
|
|
|
+ headList.add("序号");
|
|
|
|
+ headList.add("项目编号");
|
|
|
|
+ headList.add("项目名称");;
|
|
|
|
+ headList.add("工作时长(h)");
|
|
|
|
+ headList.add("加班工时(h)");
|
|
|
|
+ if (hasViewSalary) {
|
|
|
|
+ headList.add("加班成本(元)");
|
|
|
|
+ }
|
|
|
|
+ groupByProjectList.add(headList);
|
|
|
|
+ List<Map<String, Object>> byProjectList = new ArrayList<>();
|
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
|
+ Integer curProId = (Integer) map.get("projectId");
|
|
|
|
+ Optional<Map<String, Object>> find = byProjectList.stream().filter(pro -> pro.get("projectId").equals(curProId)).findFirst();
|
|
|
|
+ if (find.isPresent()) {
|
|
|
|
+ //项目已存储,叠加工时数据
|
|
|
|
+ Map oldItem = find.get();
|
|
|
|
+ double workingTime = ((Double)map.get("workingTime"));
|
|
|
|
+ double overtimeHours = ((Double)map.get("overtimeHours"));
|
|
|
|
+ BigDecimal cost = (BigDecimal)map.get("cost");
|
|
|
|
+ oldItem.put("workingTime", (Double)oldItem.get("workingTime") + workingTime);
|
|
|
|
+ oldItem.put("overtimeHours", (Double)oldItem.get("overtimeHours") + overtimeHours);
|
|
|
|
+ oldItem.put("cost", ((BigDecimal)oldItem.get("cost")).add(cost));
|
|
|
|
+ } else {
|
|
|
|
+ Map<String, Object> itemMap = new HashMap<>();
|
|
|
|
+ itemMap.putAll(map);
|
|
|
|
+ byProjectList.add(itemMap);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ seq = 1;
|
|
|
|
+ for (Map<String, Object> map : byProjectList) {
|
|
|
|
+ List<String> rowData = new ArrayList<String>();
|
|
|
|
+ rowData.add(""+seq);
|
|
|
|
+ rowData.add((String)map.get("projectCode"));
|
|
|
|
+ rowData.add((String)map.get("projectName"));
|
|
|
|
+ rowData.add(((Double)map.get("workingTime")).toString());
|
|
|
|
+ rowData.add(((Double)map.get("overtimeHours")).toString());
|
|
|
|
+ if (hasViewSalary) {
|
|
|
|
+ rowData.add(((BigDecimal)map.get("cost")).toString());
|
|
|
|
+ }
|
|
|
|
+ groupByProjectList.add(rowData);
|
|
|
|
+ seq++;
|
|
|
|
+ }
|
|
|
|
+ //合计
|
|
|
|
+ List<String> sumRowProject = new ArrayList<String>();
|
|
|
|
+ sumRowProject.add("合计");
|
|
|
|
+ sumRowProject.add("");
|
|
|
|
+ sumRowProject.add("");
|
|
|
|
+ sumRowProject.add(""+df.format(totalWorkTime));
|
|
|
|
+ sumRowProject.add(""+df.format(totalCostTime));
|
|
|
|
+ if (hasViewSalary) {
|
|
|
|
+ sumRowProject.add(total);
|
|
|
|
+ }
|
|
|
|
+ groupByProjectList.add(sumRowProject);
|
|
|
|
+ //按照人员统计
|
|
|
|
+ List<List<String>> groupByMembList = new ArrayList<>();
|
|
|
|
+ headList = new ArrayList<String>();
|
|
|
|
+ headList.add("序号");
|
|
|
|
+ headList.add("姓名");
|
|
|
|
+ headList.add("工作时长(h)");
|
|
|
|
+ headList.add("加班工时(h)");
|
|
|
|
+ if (hasViewSalary) {
|
|
|
|
+ headList.add("加班成本(元)");
|
|
|
|
+ }
|
|
|
|
+ groupByMembList.add(headList);
|
|
|
|
+ List<Map<String, Object>> byMembList = new ArrayList<>();
|
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
|
+ String curUserId = (String) map.get("userId");
|
|
|
|
+ Optional<Map<String, Object>> find = byMembList.stream().filter(memb -> memb.get("userId").equals(curUserId)).findFirst();
|
|
|
|
+ if (find.isPresent()) {
|
|
|
|
+ //人员已存储,叠加工时数据
|
|
|
|
+ Map oldItem = find.get();
|
|
|
|
+ double workingTime = ((Double)map.get("workingTime"));
|
|
|
|
+ double overtimeHours = ((Double)map.get("overtimeHours"));
|
|
|
|
+ BigDecimal cost = (BigDecimal)map.get("cost");
|
|
|
|
+ oldItem.put("workingTime", (Double)oldItem.get("workingTime") + workingTime);
|
|
|
|
+ oldItem.put("overtimeHours", (Double)oldItem.get("overtimeHours") + overtimeHours);
|
|
|
|
+ oldItem.put("cost", ((BigDecimal)oldItem.get("cost")).add(cost));
|
|
|
|
+ } else {
|
|
|
|
+ Map<String, Object> itemMap = new HashMap<>();
|
|
|
|
+ itemMap.putAll(map);
|
|
|
|
+ byMembList.add(map);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ seq = 1;
|
|
|
|
+ for (Map<String, Object> map : byMembList) {
|
|
|
|
+ List<String> rowData = new ArrayList<String>();
|
|
|
|
+ rowData.add(""+seq);
|
|
|
|
+ rowData.add((String)map.get("username"));
|
|
|
|
+ rowData.add(((Double)map.get("workingTime")).toString());
|
|
|
|
+ rowData.add(((Double)map.get("overtimeHours")).toString());
|
|
|
|
+ if (hasViewSalary) {
|
|
|
|
+ rowData.add(((BigDecimal)map.get("cost")).toString());
|
|
|
|
+ }
|
|
|
|
+ groupByMembList.add(rowData);
|
|
|
|
+ seq++;
|
|
|
|
+ }
|
|
|
|
+ //合计
|
|
|
|
+ List<String> sumRowMemb = new ArrayList<String>();
|
|
|
|
+ sumRowMemb.add("合计");
|
|
|
|
+ sumRowMemb.add("");
|
|
|
|
+ sumRowMemb.add(""+df.format(totalWorkTime));
|
|
|
|
+ sumRowMemb.add(""+df.format(totalCostTime));
|
|
|
|
+ if (hasViewSalary) {
|
|
|
|
+ sumRowMemb.add(total);
|
|
|
|
+ }
|
|
|
|
+ groupByMembList.add(sumRowMemb);
|
|
|
|
+ List[] totalList = new ArrayList[3];
|
|
|
|
+ totalList[0] = allList;
|
|
|
|
+ totalList[1] = groupByProjectList;
|
|
|
|
+ totalList[2] = groupByMembList;
|
|
|
|
+ String[] sheetNames = new String[3];
|
|
|
|
+ sheetNames[0] = "加班情况明细表";
|
|
|
|
+ sheetNames[1] = "按项目统计";
|
|
|
|
+ sheetNames[2] = "按人员统计";
|
|
|
|
+ String resp = ExcelUtil.exportMultiSheetGeneralExcelByTitleAndList(fileName , totalList, path, sheetNames);
|
|
|
|
|
|
httpRespMsg.data = resp;
|
|
httpRespMsg.data = resp;
|
|
} catch (NullPointerException e) {
|
|
} catch (NullPointerException e) {
|
|
- httpRespMsg.setError("验证失败");
|
|
|
|
|
|
+ httpRespMsg.setError("验证失败"+e.getMessage());
|
|
|
|
+ e.printStackTrace();
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
}
|
|
}
|
|
return httpRespMsg;
|
|
return httpRespMsg;
|
|
@@ -2993,7 +3112,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
if (participationList.size() > 0) {
|
|
if (participationList.size() > 0) {
|
|
//批量保存
|
|
//批量保存
|
|
List<Participation> finalOldPartList = oldPartList;
|
|
List<Participation> finalOldPartList = oldPartList;
|
|
- List<Participation> addPartList = participationList.stream().filter(newP-> finalOldPartList.stream().anyMatch(oldP->oldP.getUserId().equals(newP.getUserId()))).collect(Collectors.toList());
|
|
|
|
|
|
+ List<Participation> addPartList = participationList.stream().filter(newP-> !finalOldPartList.stream().anyMatch(oldP->oldP.getUserId().equals(newP.getUserId()))).collect(Collectors.toList());
|
|
if (addPartList.size() > 0) {
|
|
if (addPartList.size() > 0) {
|
|
participationService.saveBatch(addPartList);
|
|
participationService.saveBatch(addPartList);
|
|
}
|
|
}
|