|
@@ -14409,12 +14409,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg groupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr) {
|
|
|
+ public HttpRespMsg groupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr,Integer pageIndex,Integer pageSize) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
List<Department> departments = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, user.getCompanyId()));
|
|
|
NumberFormat percentFormat = NumberFormat.getPercentInstance();
|
|
|
percentFormat.setMaximumFractionDigits(2);
|
|
|
+ Integer start=null;
|
|
|
+ Integer size=null;
|
|
|
+ if(pageIndex!=null&&pageSize!=null){
|
|
|
+ size=pageSize;
|
|
|
+ start=(pageIndex-1)*size;
|
|
|
+ }
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
List<String> groupNameList=new ArrayList<>();
|
|
|
List<Integer> projectIdList=new ArrayList<>();
|
|
@@ -14432,6 +14438,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
boolean incharger = sysFunctionService.hasPriviledge(user.getRoleId(), "负责部门分组耗用进度表");
|
|
|
List<Department> allDeptList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, companyId));
|
|
|
List<Map<String,Object>> resultList;
|
|
|
+ Integer total;
|
|
|
//是否具有查看全部数据的权限
|
|
|
//针对依斯呗 指定部门
|
|
|
List<Integer> regularDeptIds=new ArrayList<>();
|
|
@@ -14451,7 +14458,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(!viewAll){
|
|
|
if(!incharger){
|
|
|
//只能查看本人的数据
|
|
|
- resultList=projectMapper.groupExpendProcessListForUser(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList);
|
|
|
+ resultList=projectMapper.groupExpendProcessListForUser(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList,start,size);
|
|
|
+ total=projectMapper.groupExpendProcessListForUserCount(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList);
|
|
|
}else {
|
|
|
List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().select(Department::getDepartmentId).eq(Department::getManagerId, user.getId()));
|
|
|
List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
|
|
@@ -14465,16 +14473,152 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<Integer> branchDepartment = getBranchDepartment(integer, allDeptList);
|
|
|
deptIds.addAll(branchDepartment);
|
|
|
}
|
|
|
- resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList);
|
|
|
+ resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
|
|
|
+ total=projectMapper.groupExpendProcessListForUserCount(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList);
|
|
|
}
|
|
|
}else {
|
|
|
- resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList);
|
|
|
+ resultList=projectMapper.groupExpendProcessListForUser(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
|
|
|
+ total=projectMapper.groupExpendProcessListForUserCount(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList);
|
|
|
}
|
|
|
resultList.forEach(r->{
|
|
|
Optional<Department> department = departments.stream().filter(d -> d.getDepartmentId().equals(Integer.valueOf(String.valueOf(r.get("departmentId"))))).findFirst();
|
|
|
r.put("departmentName",departmentService.getSupDepartment(department.get(),departments));
|
|
|
});
|
|
|
- msg.setData(resultList);
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
+ map.put("record",resultList);
|
|
|
+ map.put("total",total);
|
|
|
+ msg.setData(map);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg groupExpendProcessListForProject(String startDate, String endDate, String projectIds, String groupNames, String deptIdStr,Integer pageIndex,Integer pageSize) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ List<Department> departments = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, user.getCompanyId()));
|
|
|
+ NumberFormat percentFormat = NumberFormat.getPercentInstance();
|
|
|
+ percentFormat.setMaximumFractionDigits(2);
|
|
|
+ Integer start=null;
|
|
|
+ Integer size=null;
|
|
|
+ if(pageIndex!=null&&pageSize!=null){
|
|
|
+ size=pageSize;
|
|
|
+ start=(pageIndex-1)*size;
|
|
|
+ }
|
|
|
+ Integer companyId = user.getCompanyId();
|
|
|
+ List<String> groupNameList=new ArrayList<>();
|
|
|
+ List<Integer> projectIdList=new ArrayList<>();
|
|
|
+ List<Integer> deptIdList=new ArrayList<>();
|
|
|
+ if(!StringUtils.isEmpty(groupNames)){
|
|
|
+ groupNameList = Arrays.asList(groupNames.split(","));
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(projectIds)){
|
|
|
+ projectIdList=Arrays.asList(projectIds.split(",")).stream().map(i->Integer.valueOf(i)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if(!StringUtils.isEmpty(deptIdStr)){
|
|
|
+ deptIdList=Arrays.asList(deptIdStr.split(",")).stream().map(i->Integer.valueOf(i)).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ boolean viewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "全部分组耗用进度表");
|
|
|
+ boolean incharger = sysFunctionService.hasPriviledge(user.getRoleId(), "负责部门分组耗用进度表");
|
|
|
+ List<Department> allDeptList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, companyId));
|
|
|
+ List<Map<String,Object>> resultList;
|
|
|
+ Integer total;
|
|
|
+ //是否具有查看全部数据的权限
|
|
|
+ //针对依斯呗 指定部门
|
|
|
+ List<Integer> regularDeptIds=new ArrayList<>();
|
|
|
+ if(user.getCompanyId()==3092){
|
|
|
+ List<String> nameString=new ArrayList<>();
|
|
|
+ nameString.add("4");
|
|
|
+ nameString.add("46");
|
|
|
+ nameString.add("45");
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getCompanyId, user.getCompanyId()).in(Department::getDepartmentName, nameString));
|
|
|
+ List<Integer> theCollect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ theCollect.add(-1);
|
|
|
+ for (Integer integer : theCollect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDeptList);
|
|
|
+ regularDeptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!viewAll){
|
|
|
+ if(!incharger){
|
|
|
+ //只能查看本人的数据
|
|
|
+ resultList=projectMapper.groupExpendProcessListForProject(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList,start,size);
|
|
|
+ total=projectMapper.groupExpendProcessListForProjectCount(user.getId(),companyId,startDate,endDate,null,null,projectIdList,groupNameList,deptIdList);
|
|
|
+ }else {
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new LambdaQueryWrapper<Department>().select(Department::getDepartmentId).eq(Department::getManagerId, user.getId()));
|
|
|
+ List<DepartmentOtherManager> departmentOtherManagerList = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("other_manager_id", user.getId()));
|
|
|
+ List<Integer> deptIds=new ArrayList<>();
|
|
|
+ List<Integer> theCollect = departmentList.stream().map(dm -> dm.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ theCollect.add(-1);
|
|
|
+ List<Integer> otherCollect = departmentOtherManagerList.stream().map(dom -> dom.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ otherCollect.add(-1);
|
|
|
+ theCollect.addAll(otherCollect);
|
|
|
+ for (Integer integer : theCollect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDeptList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+ resultList=projectMapper.groupExpendProcessListForProject(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
|
|
|
+ total=projectMapper.groupExpendProcessListForProjectCount(null,companyId,startDate,endDate,deptIdList,regularDeptIds,projectIdList,groupNameList,deptIdList);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ resultList=projectMapper.groupExpendProcessListForProject(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList,start,size);
|
|
|
+ total=projectMapper.groupExpendProcessListForProjectCount(null,companyId,startDate,endDate,null,regularDeptIds,projectIdList,groupNameList,deptIdList);
|
|
|
+ }
|
|
|
+ //计算占比
|
|
|
+ double workTime = resultList.stream().mapToDouble(r -> Double.valueOf(String.valueOf(r.get("workTime")))).sum();
|
|
|
+ resultList.forEach(r->{
|
|
|
+ BigDecimal time = new BigDecimal(String.valueOf(r.get("workTime")));
|
|
|
+ time=time.divide(new BigDecimal(workTime),4,RoundingMode.HALF_UP);
|
|
|
+ time=time.multiply(new BigDecimal(100));
|
|
|
+// String format = percentFormat.format(time.doubleValue());
|
|
|
+ r.put("percent",time.doubleValue()+"%");
|
|
|
+ });
|
|
|
+ Map<String,Object> map=new HashMap<>();
|
|
|
+ map.put("record",resultList);
|
|
|
+ map.put("total",total);
|
|
|
+ msg.setData(map);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportGroupExpendProcessListForUser(String startDate, String endDate, String projectIds, String groupNames,String titleStr, String deptIdStr) {
|
|
|
+ User user = userMapper.selectById(request.getHeader("token"));
|
|
|
+ WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, user.getCompanyId()));
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ titleList.add("所属部门");
|
|
|
+ titleList.add("工号");
|
|
|
+ titleList.add("员工");
|
|
|
+ if(!StringUtils.isEmpty(titleStr)){
|
|
|
+ List<String> strings = Arrays.asList(titleStr.split(","));
|
|
|
+ titleList.addAll(strings);
|
|
|
+ }
|
|
|
+ dataList.add(titleList);
|
|
|
+ HttpRespMsg msg = groupExpendProcessListForUser(startDate, endDate, projectIds, groupNames, deptIdStr, null, null);
|
|
|
+ Map<String, Object> data = (Map<String, Object>) msg.data;
|
|
|
+ List<Map<String, Object>> mapList = (List<Map<String, Object>>) data.get("record");
|
|
|
+ for (Map<String, Object> map : mapList) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ item.add("$departmentName="+String.valueOf(map.get("departmentName"))+"$");
|
|
|
+ }else {
|
|
|
+ item.add(String.valueOf(map.get("departmentName")));
|
|
|
+ }
|
|
|
+ item.add(String.valueOf(map.get("jobNumber")));
|
|
|
+ if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
+ item.add("$userName="+String.valueOf(map.get("userName"))+"$");
|
|
|
+ }else {
|
|
|
+ item.add(String.valueOf(map.get("userName")));
|
|
|
+ }
|
|
|
+ for (String s : titleList) {
|
|
|
+ item.add(String.valueOf(map.get(s)));
|
|
|
+ }
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ return excelExportService.exportGeneralExcelByTitleAndList(wxCorpInfo,null,"人员分组耗用表",dataList,path);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
return msg;
|
|
|
}
|
|
|
}
|