|
@@ -755,7 +755,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
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);
|
|
@@ -768,7 +770,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
double remainDouble = pEstimatedWorkDouble - rWorkTimeDouble;
|
|
|
estimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
|
|
|
double proportion = (remainDouble / pEstimatedWorkDouble)*100;
|
|
|
- estimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion)+"%");
|
|
|
+ estimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
|
|
|
}
|
|
|
lastList.add(estimatedWorkVO);
|
|
|
}
|
|
@@ -794,7 +796,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
double remainDouble = gEstimatedWorkDouble - grWorkTimeDouble;
|
|
|
groupEstimatedWorkVO.setRemainWorkTime(String.format("%.2f", remainDouble));
|
|
|
double proportion = (remainDouble / gEstimatedWorkDouble)*100;
|
|
|
- groupEstimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion)+"%");
|
|
|
+ groupEstimatedWorkVO.setRemainWorkTimeProportion(String.format("%.2f", proportion));
|
|
|
}
|
|
|
|
|
|
groupEstimatedWorkVO.setWorkTime(grWorkTime);
|
|
@@ -836,13 +838,33 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
.collect(Collectors.toList());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ if (type==0){
|
|
|
+ lastList.stream().
|
|
|
+ filter(l -> Double.parseDouble(l.getRemainWorkTimeProportion()) < projectWarningPercent)
|
|
|
+ .forEach(s->s.setIsRed(true));
|
|
|
+ }else {
|
|
|
+ lastList.stream().
|
|
|
+ filter(l -> 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+pageIndex);
|
|
|
+ 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);
|
|
@@ -850,6 +872,203 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportProjectEstimatedWorkNew(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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
+ CompanyDingding dingding = companyDingdingMapper.selectOne(new LambdaQueryWrapper<CompanyDingding>().eq(CompanyDingding::getCompanyId, user.getCompanyId()));
|
|
|
+ //导出项目
|
|
|
+ if (type==0){
|
|
|
+ List<String> headList = new ArrayList<String>();
|
|
|
+ headList.add("项目名称");
|
|
|
+ headList.add("项目预估工时");
|
|
|
+ headList.add("项目实际工时");
|
|
|
+ headList.add("项目剩余工时");
|
|
|
+ headList.add("剩余工时占比(%)");
|
|
|
+
|
|
|
+ List<List<String>> allList = new ArrayList<>();
|
|
|
+ allList.add(headList);
|
|
|
+
|
|
|
+ if (!lastList.isEmpty()){
|
|
|
+ for (int i = 0; i < lastList.size(); i++) {
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getProjectName())?"":lastList.get(i).getProjectName());
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getEstimatedWorkTime())?"":lastList.get(i).getEstimatedWorkTime());
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getWorkTime())?"":lastList.get(i).getWorkTime());
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTime())?"":lastList.get(i).getRemainWorkTime());
|
|
|
+ if (!StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())&&lastList.get(i).getRemainWorkTimeProportion().equals("\\")){
|
|
|
+ list.add("\\");
|
|
|
+ }else {
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())?"":lastList.get(i).getRemainWorkTimeProportion()+"%");
|
|
|
+ }
|
|
|
+
|
|
|
+ allList.add(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,dingding,"预估工时表",allList,path);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ httpRespMsg.setError(e.getMessage());
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //导出分组
|
|
|
+ else {
|
|
|
+ List<String> headList = new ArrayList<String>();
|
|
|
+ headList.add("项目名称");
|
|
|
+ headList.add("分组名称");
|
|
|
+ headList.add("分组预估工时");
|
|
|
+ headList.add("分组实际工时");
|
|
|
+ headList.add("分组剩余工时");
|
|
|
+ headList.add("剩余工时占比(%)");
|
|
|
+
|
|
|
+ List<List<String>> allList = new ArrayList<>();
|
|
|
+ allList.add(headList);
|
|
|
+
|
|
|
+ if (!lastList.isEmpty()){
|
|
|
+ for (int i = 0; i < lastList.size(); i++) {
|
|
|
+ ArrayList<String> list = new ArrayList<>();
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getProjectName())?"":lastList.get(i).getProjectName());
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getGroupName())?"":lastList.get(i).getGroupName());
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getEstimatedWorkTime())?"":lastList.get(i).getEstimatedWorkTime());
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getWorkTime())?"":lastList.get(i).getWorkTime());
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTime())?"":lastList.get(i).getRemainWorkTime());
|
|
|
+ if (!StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())&&lastList.get(i).getRemainWorkTimeProportion().equals("\\")){
|
|
|
+ list.add("\\");
|
|
|
+ }else {
|
|
|
+ list.add(StringUtils.isEmpty(lastList.get(i).getRemainWorkTimeProportion())?"":lastList.get(i).getRemainWorkTimeProportion()+"%");
|
|
|
+ }
|
|
|
+ allList.add(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,dingding,"预估工时表",allList,path);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ httpRespMsg.setError(e.getMessage());
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public HttpRespMsg getProjectEstimatedWork(Integer pageIndex, Integer pageSize, Integer projectId, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
//通过公司id获取该公司所有的项目列表
|