|
|
@@ -937,160 +937,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
- /*@Override
|
|
|
- public HttpRespMsg getProjectEstimatedWorkNew(Integer pageIndex, Integer pageSize, Integer projectId, Integer type,Integer isWarn, HttpServletRequest request) {
|
|
|
- HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
- //通过公司id获取该公司所有的项目列表
|
|
|
- User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
- Integer companyId = user.getCompanyId();
|
|
|
- EstimateTimeSetting estimateTimeSetting = estimateTimeSettingMapper.selectOne(new QueryWrapper<EstimateTimeSetting>().eq("company_id", companyId));
|
|
|
- //该公司下的allday
|
|
|
- float allday=timeTypeMapper.selectOne(new QueryWrapper<TimeType>()
|
|
|
- .eq("company_id",companyId)).getAllday();
|
|
|
- //根据公司的id搜索该公司有哪些项目 20231108之前完成的不统计,状态为进行中/已完成
|
|
|
- List<Project> records = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId).in("status", 1, 2)
|
|
|
- .and(wrapper -> wrapper.isNull("finish_date").or()
|
|
|
- .ge("finish_date", "2023-11-08")).eq(projectId != null, "id", projectId));
|
|
|
-
|
|
|
- List<Integer> collectIds = records.stream().map(Project::getId).collect(Collectors.toList());
|
|
|
-
|
|
|
- //根据查询道德project列表查询总的reporeList
|
|
|
- List<Report> reportList = reportMapper.selectList(new QueryWrapper<Report>()
|
|
|
- .in("project_id", collectIds));
|
|
|
- //根据查询道德project列表查询总的task_groupList
|
|
|
- List<TaskGroup> taskGroups = taskGroupMapper.selectList(new QueryWrapper<TaskGroup>()
|
|
|
- .in("project_id", collectIds));
|
|
|
-
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
- List<GroupEstimatedWorkVO> lastList=new ArrayList<>();
|
|
|
- for (Project project : records) {
|
|
|
-
|
|
|
- List<TaskGroup> taskGroupCollect = taskGroups.stream().filter(t -> t.getProjectId().equals(project.getId())).collect(Collectors.toList());
|
|
|
-
|
|
|
- //0代表按项目查看
|
|
|
- if (type==0){
|
|
|
- GroupEstimatedWorkVO estimatedWorkVO = new GroupEstimatedWorkVO();
|
|
|
- Double reallWorkTime = reportList.stream().filter(r -> r.getProjectId() .equals( project.getId())&&r.getWorkingTime()!=null)
|
|
|
- .mapToDouble(Report::getWorkingTime).sum();
|
|
|
- String rWorkTime=reallWorkTime==null ? "0":df.format(reallWorkTime);
|
|
|
- estimatedWorkVO.setProjectId(project.getId());
|
|
|
- estimatedWorkVO.setProjectName(project.getProjectName());
|
|
|
- estimatedWorkVO.setProjectCode(project.getProjectCode());
|
|
|
- estimatedWorkVO.setWorkTime(rWorkTime);
|
|
|
- String pEstimatedWork=project.getManDay()==null? "0": (project.getManDay()*allday+"");
|
|
|
- estimatedWorkVO.setEstimatedWorkTime(pEstimatedWork);
|
|
|
- if (project.getManDay()==null){
|
|
|
- estimatedWorkVO.setRemainWorkTime("\\");
|
|
|
- estimatedWorkVO.setRemainWorkTimeProportion("\\");
|
|
|
- }else{
|
|
|
- double rWorkTimeDouble = Double.parseDouble(rWorkTime);
|
|
|
- double pEstimatedWorkDouble = Double.parseDouble(pEstimatedWork);
|
|
|
- double remainDouble = pEstimatedWorkDouble - rWorkTimeDouble;
|
|
|
- estimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
|
|
|
- double proportion = (remainDouble / pEstimatedWorkDouble)*100;
|
|
|
- estimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
|
|
|
- }
|
|
|
- lastList.add(estimatedWorkVO);
|
|
|
- }
|
|
|
- else {
|
|
|
- if (taskGroupCollect.size()>0){
|
|
|
- List<Integer> groupIds = taskGroupCollect.stream().map(TaskGroup::getId).collect(Collectors.toList());
|
|
|
- List<Report> getByProjectAndGroup = reportMapper.selectList(new QueryWrapper<Report>()
|
|
|
- .eq("project_id", project.getId())
|
|
|
- .in("group_id", groupIds));
|
|
|
- for (TaskGroup taskGroup : taskGroupCollect) {
|
|
|
- Double gReallWorkTime = getByProjectAndGroup.stream().filter(r -> r.getGroupId().equals( taskGroup.getId()))
|
|
|
- .mapToDouble(r->r.getWorkingTime()).sum();
|
|
|
- GroupEstimatedWorkVO groupEstimatedWorkVO = new GroupEstimatedWorkVO();
|
|
|
- String grWorkTime=gReallWorkTime==null ? "0":gReallWorkTime+"";
|
|
|
- String gEstimatedWork=taskGroup.getManDay()==null ? 0*allday+"": taskGroup.getManDay()*allday+"";
|
|
|
-
|
|
|
- if (taskGroup.getManDay()==null){
|
|
|
- groupEstimatedWorkVO.setRemainWorkTime("\\");
|
|
|
- groupEstimatedWorkVO.setRemainWorkTimeProportion("\\");
|
|
|
- }else{
|
|
|
- double grWorkTimeDouble = Double.parseDouble(grWorkTime);
|
|
|
- double gEstimatedWorkDouble = Double.parseDouble(gEstimatedWork);
|
|
|
- double remainDouble = gEstimatedWorkDouble - grWorkTimeDouble;
|
|
|
- groupEstimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
|
|
|
- double proportion = (remainDouble / gEstimatedWorkDouble)*100;
|
|
|
- groupEstimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
|
|
|
- }
|
|
|
-
|
|
|
- groupEstimatedWorkVO.setWorkTime(grWorkTime);
|
|
|
- groupEstimatedWorkVO.setEstimatedWorkTime(gEstimatedWork);
|
|
|
- groupEstimatedWorkVO.setId(taskGroup.getId());
|
|
|
- groupEstimatedWorkVO.setGroupName(taskGroup.getName());
|
|
|
- groupEstimatedWorkVO.setProjectId(project.getId());
|
|
|
- groupEstimatedWorkVO.setProjectName(project.getProjectName());
|
|
|
-
|
|
|
- lastList.add(groupEstimatedWorkVO);
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- GroupEstimatedWorkVO groupEstimatedWorkVO = new GroupEstimatedWorkVO();
|
|
|
- groupEstimatedWorkVO.setWorkTime("");
|
|
|
- groupEstimatedWorkVO.setEstimatedWorkTime("");
|
|
|
- groupEstimatedWorkVO.setId(null);
|
|
|
- groupEstimatedWorkVO.setGroupName("");
|
|
|
- groupEstimatedWorkVO.setProjectId(project.getId());
|
|
|
- groupEstimatedWorkVO.setProjectName(project.getProjectName());
|
|
|
- groupEstimatedWorkVO.setRemainWorkTime("\\");
|
|
|
- groupEstimatedWorkVO.setRemainWorkTimeProportion("\\");
|
|
|
- lastList.add(groupEstimatedWorkVO);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- Integer projectWarningPercent = estimateTimeSetting.getProjectWarningPercent();
|
|
|
- Integer groupWarningPercent = estimateTimeSetting.getGroupWarningPercent();
|
|
|
- if (isWarn!=null){
|
|
|
- lastList = lastList.stream().
|
|
|
- filter(l -> !StringUtils.isEmpty(l.getRemainWorkTimeProportion()) && !l.getRemainWorkTimeProportion().equals("\\")).collect(Collectors.toList());
|
|
|
- if (type==0){
|
|
|
- lastList = lastList.stream().
|
|
|
- filter(l -> Double.parseDouble(l.getRemainWorkTimeProportion()) < projectWarningPercent)
|
|
|
- .collect(Collectors.toList());
|
|
|
- }else {
|
|
|
- lastList = lastList.stream().
|
|
|
- filter(l -> Double.parseDouble(l.getRemainWorkTimeProportion()) < groupWarningPercent)
|
|
|
- .collect(Collectors.toList());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- if (type==0){
|
|
|
- lastList.stream().
|
|
|
- filter(l -> !StringUtils.isEmpty(l.getRemainWorkTimeProportion()) && !l.getRemainWorkTimeProportion().equals("\\")&&Double.parseDouble(l.getRemainWorkTimeProportion()) < projectWarningPercent)
|
|
|
- .forEach(s->s.setIsRed(true));
|
|
|
- }else {
|
|
|
- lastList.stream().
|
|
|
- filter(l -> !StringUtils.isEmpty(l.getRemainWorkTimeProportion()) && !l.getRemainWorkTimeProportion().equals("\\")&&Double.parseDouble(l.getRemainWorkTimeProportion()) < groupWarningPercent)
|
|
|
- .forEach(s->s.setIsRed(true));
|
|
|
- }
|
|
|
-
|
|
|
- Integer size=(pageIndex-1)*pageSize;
|
|
|
- List<GroupEstimatedWorkVO> subList = new ArrayList<>();
|
|
|
- if (lastList.size()>size+pageSize){
|
|
|
- subList=lastList.subList(size,size+pageSize);
|
|
|
- }else {
|
|
|
- subList=lastList.subList(size,lastList.size());
|
|
|
- }
|
|
|
- if (!subList.isEmpty()){
|
|
|
- subList.forEach(s->{
|
|
|
- if (!StringUtils.isEmpty(s.getRemainWorkTimeProportion())&&s.getRemainWorkTimeProportion().equals("\\")){
|
|
|
- s.setRemainWorkTimeProportion("\\");
|
|
|
- }else {
|
|
|
- s.setRemainWorkTimeProportion(s.getRemainWorkTimeProportion()+"%");
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- Map<String,Object> resultMap=new HashMap<>();
|
|
|
- resultMap.put("total",lastList.size());
|
|
|
- resultMap.put("records",subList);
|
|
|
- httpRespMsg.data=resultMap;
|
|
|
- return httpRespMsg;
|
|
|
- }*/
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public HttpRespMsg getProjectEstimatedWorkNew(Integer pageIndex, Integer pageSize, Integer projectId, Integer type,Integer isWarn, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
@@ -9161,7 +9007,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<List<String>> exportList = new ArrayList<>();
|
|
|
//String[] titles = {"项目编号", "项目名称", "当前总预算","当前剩余预算","总剩余预算","已发生总工时成本"};
|
|
|
String[] titles = {MessageUtils.message("entry.projectId"), MessageUtils.message("entry.projectName"), MessageUtils.message("entry.totalBudget"),MessageUtils.message("entry.curRemBud"),MessageUtils.message("entry.totalRemBud"),MessageUtils.message("entry.totalLaborCostIncurred")};
|
|
|
- ArrayList<String> headList = Lists.list(titles);
|
|
|
+ ArrayList<String> headList = new ArrayList<>(Arrays.asList(titles));
|
|
|
//列,根据定义的工时预警类型的成本项来
|
|
|
List<ProjectBasecostSetting> settingList = projectBasecostSettingMapper.selectList(new QueryWrapper<ProjectBasecostSetting>().eq("company_id", companyId).eq("alarm_type", 1));
|
|
|
for (ProjectBasecostSetting setting : settingList) {
|
|
|
@@ -17288,26 +17134,78 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
* 按部门汇总统计工时成本数据(分页)
|
|
|
*/
|
|
|
@Override
|
|
|
- public HttpRespMsg getTimeCostForTableByDept(Integer pageIndex, Integer pageSize, String startDate, String endDate, Integer projectId, Integer departmentId, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg getTimeCostForTableByDept(String startDate, String endDate, Integer projectId, Integer departmentId, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
Integer companyId = targetUser.getCompanyId();
|
|
|
|
|
|
- // 计算分页参数
|
|
|
- int start = (pageIndex - 1) * pageSize;
|
|
|
-
|
|
|
+ List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
// 查询数据(分页)
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCostForTableByDept(companyId, startDate, endDate, projectId, departmentId, start, pageSize);
|
|
|
-
|
|
|
- // 查询总数
|
|
|
- long total = projectMapper.getTimeCostForTableByDeptCount(companyId, startDate, endDate, projectId, departmentId);
|
|
|
-
|
|
|
- Map<String, Object> resultMap = new HashMap<>();
|
|
|
- resultMap.put("records", list);
|
|
|
- resultMap.put("total", total);
|
|
|
-
|
|
|
- httpRespMsg.data = resultMap;
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCostForTableByDept(companyId, startDate, endDate, projectId, departmentId);
|
|
|
+ List<Integer> deptIds = new ArrayList<>();
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ //取上一级部门
|
|
|
+ Integer deptId = (Integer) map.get("deptId");
|
|
|
+ deptIds.add(deptId);
|
|
|
+ }
|
|
|
+ List<Department> superDeptList = new ArrayList<>();
|
|
|
+ for (Integer id : deptIds) {
|
|
|
+ Department curDept = allDeptList.stream().filter(department -> department.getDepartmentId().equals(id)).findFirst().orElse(null);
|
|
|
+ if (curDept != null) {
|
|
|
+ if (curDept.getSuperiorId() != null && curDept.getSuperiorId() != 0) {
|
|
|
+ //加入到父级部门
|
|
|
+ superDeptList.add(allDeptList.stream().filter(su->su.getDepartmentId().equals(curDept.getSuperiorId())).findFirst().orElse(null));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //去重
|
|
|
+ superDeptList = superDeptList.stream().distinct().collect(Collectors.toList());
|
|
|
+ List<Map<String, Object>> sumList = new ArrayList<>();
|
|
|
+ //计算每个父部门的合计工时
|
|
|
+ for (Department superDept : superDeptList) {
|
|
|
+ //计算合计工时
|
|
|
+ double sum = 0.0;
|
|
|
+ BigDecimal cost = new BigDecimal(0);
|
|
|
+ List<Map<String, Object>> childList = new ArrayList<>();
|
|
|
+ for (Map<String, Object> map : list) {
|
|
|
+ Integer deptId = (Integer) map.get("deptId");
|
|
|
+ if (deptId.equals(superDept.getDepartmentId())) {
|
|
|
+ sum += (Double)map.get("workingTime");
|
|
|
+ cost = cost.add((BigDecimal) map.get("cost"));
|
|
|
+ childList.add(map);
|
|
|
+ } else {
|
|
|
+ //取父部门
|
|
|
+ Department curDept = allDeptList.stream().filter(department -> department.getDepartmentId().equals(deptId)).findFirst().orElse(null);
|
|
|
+ if (curDept != null && curDept.getSuperiorId() != null && curDept.getSuperiorId() != 0) {
|
|
|
+ if (curDept.getSuperiorId().equals(superDept.getDepartmentId())) {
|
|
|
+ sum += (Double)map.get("workingTime");
|
|
|
+ cost = cost.add((BigDecimal) map.get("cost"));
|
|
|
+ childList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<String, Object> superMap = new HashMap<>();
|
|
|
+ superMap.put("deptId", superDept.getDepartmentId());
|
|
|
+ superMap.put("departmentName", superDept.getDepartmentName());
|
|
|
+ superMap.put("workingTime", sum);
|
|
|
+ superMap.put("cost", cost);
|
|
|
+ superMap.put("isSum", true);
|
|
|
+ superMap.put("childList", childList);
|
|
|
+ sumList.add(superMap);
|
|
|
+ }
|
|
|
+ //以sumList为基准,重新排列list
|
|
|
+ List<Map<String, Object>> newList = new ArrayList<>();
|
|
|
+ for (Map<String, Object> superMap : sumList) {
|
|
|
+ newList.add(superMap);
|
|
|
+ List<Map<String, Object>> childList = (List<Map<String, Object>>) superMap.get("childList");
|
|
|
+ for (Map<String, Object> child : childList) {
|
|
|
+ newList.add(child);
|
|
|
+ }
|
|
|
+ superMap.remove("childList");
|
|
|
+ }
|
|
|
+ httpRespMsg.data = newList;
|
|
|
} catch (NullPointerException e) {
|
|
|
e.printStackTrace();
|
|
|
httpRespMsg.setError(MessageUtils.message("access.verificationError"));
|
|
|
@@ -17333,13 +17231,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
// 获取企业微信和钉钉配置
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
- CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, companyId));
|
|
|
-
|
|
|
- // 获取所有部门信息用于转译
|
|
|
- List<Department> allDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
|
|
|
-
|
|
|
+ HttpRespMsg httpRespMsg = getTimeCostForTableByDept(startDate, endDate, projectId, departmentId, request);
|
|
|
// 查询所有数据(不分页)
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCostForTableByDept(companyId, startDate, endDate, projectId, departmentId, null, null);
|
|
|
+ List<Map<String, Object>> list = (List<Map<String, Object>>)httpRespMsg.getData();
|
|
|
|
|
|
// 构建Excel表头
|
|
|
List<String> headers = new ArrayList<>();
|
|
|
@@ -17358,40 +17252,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if("未分配".equals(item.get("departmentName"))) {
|
|
|
row.add("未分配");
|
|
|
} else {
|
|
|
- // 查找部门对象进行转译
|
|
|
- Department dept = null;
|
|
|
- if(item.get("deptId") != null) {
|
|
|
- Integer deptId = Integer.valueOf(item.get("deptId").toString());
|
|
|
- dept = allDepartmentList.stream()
|
|
|
- .filter(d -> d.getDepartmentId().equals(deptId))
|
|
|
- .findFirst().orElse(null);
|
|
|
- }
|
|
|
- if(dept != null) {
|
|
|
- row.add(departmentService.exportWxDepartment(dept, allDepartmentList));
|
|
|
- } else {
|
|
|
- row.add(item.get("departmentName") != null ? item.get("departmentName").toString() : "");
|
|
|
- }
|
|
|
- }
|
|
|
- } else if(dingding != null && dingding.getContactNeedTranslate() == 1) {
|
|
|
- if("未分配".equals(item.get("departmentName"))) {
|
|
|
- row.add("未分配");
|
|
|
- } else {
|
|
|
- // 查找部门对象进行转译
|
|
|
- Department dept = null;
|
|
|
- if(item.get("deptId") != null) {
|
|
|
- Integer deptId = Integer.valueOf(item.get("deptId").toString());
|
|
|
- dept = allDepartmentList.stream()
|
|
|
- .filter(d -> d.getDepartmentId().equals(deptId))
|
|
|
- .findFirst().orElse(null);
|
|
|
- }
|
|
|
- if(dept != null) {
|
|
|
- row.add(departmentService.exportDdDepartment(dept, allDepartmentList));
|
|
|
- } else {
|
|
|
- row.add(item.get("departmentName") != null ? item.get("departmentName").toString() : "");
|
|
|
- }
|
|
|
+ String deptName = item.get("departmentName") != null ? "$departmentName="+item.get("departmentName").toString() + "$": "";
|
|
|
+ row.add(deptName + (item.get("isSum") != null && item.get("isSum").equals(true) ? "(合计)" : ""));
|
|
|
}
|
|
|
} else {
|
|
|
- row.add(item.get("departmentName") != null ? item.get("departmentName").toString() : "");
|
|
|
+ String deptName = item.get("departmentName") != null ? item.get("departmentName").toString(): "";
|
|
|
+ row.add(deptName + (item.get("isSum") != null && item.get("isSum").equals(true) ? "(合计)" : ""));
|
|
|
}
|
|
|
row.add(item.get("workingTime") != null ? item.get("workingTime").toString() : "0");
|
|
|
row.add(item.get("cost") != null ? item.get("cost").toString() : "0");
|
|
|
@@ -17400,7 +17266,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
// 生成Excel文件
|
|
|
String fileName = "按部门汇总工时成本统计_" + System.currentTimeMillis();
|
|
|
- return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, dingding, fileName, dataList, path);
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo, null, fileName, dataList, path);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
msg.setError(e.getMessage());
|