|
@@ -244,6 +244,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
|
List<ProviderInfo> providerInfoList = providerInfoMapper.selectList(new QueryWrapper<ProviderInfo>().eq("company_id", companyId));
|
|
|
List<ProviderCategory> providerCategoryList = providerCategoryMapper.selectList(new QueryWrapper<ProviderCategory>().eq("company_id", companyId));
|
|
|
+ List<ProjectMain> projectMainList = projectMainMapper.selectList(new QueryWrapper<ProjectMain>().eq("company_id", companyId));
|
|
|
List<ProjectVO> list = new ArrayList<>();
|
|
|
for (Project project : projectList) {
|
|
|
ProjectVO projectVO = new ProjectVO();
|
|
@@ -255,6 +256,10 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
projectVO.setInchargerName(incharger.getName());
|
|
|
projectVO.setInchargerPhone(incharger.getPhone());
|
|
|
}
|
|
|
+ Optional<ProjectMain> projectMain = projectMainList.stream().filter(pm -> pm.getId().equals(project.getProjectMainId())).findFirst();
|
|
|
+ if(projectMain.isPresent()){
|
|
|
+ projectVO.setProjectMainName(projectMain.get().getName());
|
|
|
+ }
|
|
|
List<Map<String,Object>> mapList=new ArrayList<>();
|
|
|
if(!StringUtils.isEmpty(project.getProviderIds())){
|
|
|
String[] providerIdString = project.getProviderIds().split(",");
|
|
@@ -718,6 +723,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String endDate = "2021-01-31";
|
|
|
}
|
|
|
|
|
|
+ private List<Integer> getBranchDepartment(Integer departmentId, List<Department> departmentList) {
|
|
|
+ List<Integer> list = new ArrayList<>();
|
|
|
+ list.add(departmentId);
|
|
|
+ //搜到子部门进行添加
|
|
|
+ for (Department department : departmentList) {
|
|
|
+ if (departmentId.equals(department.getSuperiorId())) {
|
|
|
+ list.addAll(getBranchDepartment(department.getDepartmentId(), departmentList));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
//获取查询者所在公司每个项目的工时成本
|
|
|
@Override
|
|
|
public HttpRespMsg getTimeCost(String startDate, String endDate, String userId, HttpServletRequest request) {
|
|
@@ -729,6 +746,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
//当前用户管理部门
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",companyId));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看全公司");
|
|
|
List<SysRichFunction> functionDpartList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门");
|
|
@@ -737,8 +755,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDpartList.size()>0){
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
- deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
@@ -849,6 +872,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
httpRespMsg.data = resultMap;
|
|
|
}
|
|
|
} catch (NullPointerException e) {
|
|
|
+ e.printStackTrace();
|
|
|
httpRespMsg.setError("验证失败");
|
|
|
return httpRespMsg;
|
|
|
}
|
|
@@ -1384,12 +1408,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getProjectTask(Integer pageIndex, Integer pageSize, Integer projectId, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg getProjectTask(Integer pageIndex, Integer pageSize, Integer projectId, HttpServletRequest request,Integer taskType) {
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
|
Integer companyId = user.getCompanyId();
|
|
|
- int total = taskMapper.getProjectTaskCount(companyId, projectId);
|
|
|
+ int total = taskMapper.getProjectTaskCount(companyId, projectId,taskType);
|
|
|
int pageStart = (pageIndex -1) * pageSize;
|
|
|
- List projectTask = taskMapper.getProjectTask(companyId, pageStart, pageSize, projectId);
|
|
|
+ List projectTask = taskMapper.getProjectTask(companyId, pageStart, pageSize, projectId,taskType);
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
map.put("records", projectTask);
|
|
@@ -1399,7 +1423,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg exportProjectTask(HttpServletRequest request) {
|
|
|
+ public HttpRespMsg exportProjectTask(HttpServletRequest request,Integer taskType) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
@@ -1407,7 +1431,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
QueryWrapper<Project> queryWrapper = new QueryWrapper<Project>().eq("company_id", companyId);
|
|
|
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
- List<Map> projectList = taskMapper.getProjectTask(companyId, null, null, null);
|
|
|
+ List<Map> projectList = taskMapper.getProjectTask(companyId, null, null, null,taskType);
|
|
|
List<ProjectVO> list = new ArrayList<>();
|
|
|
String[] statusNames = {"进行中","已完成","已撤销"};
|
|
|
String[] typeList = {"任务","里程碑","风险"};
|
|
@@ -2089,12 +2113,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司加班情况");
|
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门加班情况");
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDeptList.size()>0){
|
|
|
- deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
- deptIds.add(user.getDepartmentId());
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
@@ -2124,11 +2153,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司加班情况");
|
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门加班情况");
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDeptList.size()>0){
|
|
|
- deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
@@ -2460,39 +2495,68 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
continue;
|
|
|
}
|
|
|
//项目编号 项目名称 参与人 负责人 级别 开始日期 截止日期 合同金额
|
|
|
- HSSFCell codeCell = row.getCell(0);
|
|
|
- HSSFCell categoryCell = row.getCell(1);
|
|
|
- HSSFCell isPublicCell = row.getCell(2);
|
|
|
- HSSFCell nameCell = row.getCell(3);
|
|
|
HSSFCell subNameCell=null;
|
|
|
HSSFCell mainNameCell=null;
|
|
|
- if(timeType.getMainProjectState()==1){
|
|
|
- mainNameCell = row.getCell(4);
|
|
|
- }else {
|
|
|
- subNameCell = row.getCell(4);
|
|
|
- }
|
|
|
- HSSFCell participatorCell = row.getCell(5);
|
|
|
- HSSFCell inchargerCell = row.getCell(6);
|
|
|
- HSSFCell levelCell = row.getCell(7);
|
|
|
+ HSSFCell codeCell=null;
|
|
|
+ HSSFCell isPublicCell=null;
|
|
|
+ HSSFCell nameCell=null;
|
|
|
+ HSSFCell participatorCell=null;
|
|
|
+ HSSFCell inchargerCell=null;
|
|
|
+ HSSFCell levelCell=null;
|
|
|
HSSFCell customerCell=null;
|
|
|
+ HSSFCell startDateCell=null;
|
|
|
+ HSSFCell endDateCell=null;
|
|
|
+ HSSFCell amountCell=null;
|
|
|
+ HSSFCell categoryCell=null;
|
|
|
int i=0;
|
|
|
int k=0;
|
|
|
- if(company.getPackageCustomer()==1){
|
|
|
- customerCell=row.getCell(8);
|
|
|
- i++;
|
|
|
- }
|
|
|
- if(company.getPackageProvider()==1){
|
|
|
- for (int j = 0; j < providerCategoryList.size(); j++) {
|
|
|
- if(company.getPackageProvider()==1){
|
|
|
- k++;
|
|
|
+ if(timeType.getMainProjectState()==1){
|
|
|
+ mainNameCell = row.getCell(0);
|
|
|
+ codeCell = row.getCell(1);
|
|
|
+ isPublicCell = row.getCell(2);
|
|
|
+ nameCell = row.getCell(3);
|
|
|
+ participatorCell = row.getCell(4);
|
|
|
+ inchargerCell = row.getCell(5);
|
|
|
+ levelCell = row.getCell(6);
|
|
|
+ if(company.getPackageCustomer()==1){
|
|
|
+ customerCell=row.getCell(7);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ if(company.getPackageProvider()==1){
|
|
|
+ for (int j = 0; j < providerCategoryList.size(); j++) {
|
|
|
+ if(company.getPackageProvider()==1){
|
|
|
+ k++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ startDateCell = row.getCell(7+i+k);
|
|
|
+ endDateCell = row.getCell(8+i+k);
|
|
|
+ amountCell = row.getCell(9+i+k);
|
|
|
+ }else {
|
|
|
+ codeCell = row.getCell(0);
|
|
|
+ categoryCell = row.getCell(1);
|
|
|
+ isPublicCell = row.getCell(2);
|
|
|
+ nameCell = row.getCell(3);
|
|
|
+ subNameCell = row.getCell(4);
|
|
|
+ participatorCell = row.getCell(5);
|
|
|
+ inchargerCell = row.getCell(6);
|
|
|
+ levelCell = row.getCell(7);
|
|
|
+ customerCell=null;
|
|
|
+ if(company.getPackageCustomer()==1){
|
|
|
+ customerCell=row.getCell(8);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ if(company.getPackageProvider()==1){
|
|
|
+ for (int j = 0; j < providerCategoryList.size(); j++) {
|
|
|
+ if(company.getPackageProvider()==1){
|
|
|
+ k++;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ startDateCell = row.getCell(8+i+k);
|
|
|
+ endDateCell = row.getCell(9+i+k);
|
|
|
+ amountCell = row.getCell(10+i+k);
|
|
|
}
|
|
|
- HSSFCell startDateCell = row.getCell(8+i+k);
|
|
|
- HSSFCell endDateCell = row.getCell(9+i+k);
|
|
|
- HSSFCell amountCell = row.getCell(10+i+k);
|
|
|
-
|
|
|
-
|
|
|
if (codeCell != null)codeCell.setCellType(CellType.STRING);
|
|
|
if (nameCell != null)nameCell.setCellType(CellType.STRING);
|
|
|
if (categoryCell != null)categoryCell.setCellType(CellType.STRING);
|
|
@@ -2527,7 +2591,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//检查项目是否存在
|
|
|
List<ProjectCategory> projectCategoryList = projectCategoryMapper.selectList(new QueryWrapper<ProjectCategory>().eq("company_id", user.getCompanyId()));
|
|
|
if (categoryCell != null && !StringUtils.isEmpty(categoryCell.getStringCellValue())) {
|
|
|
- Optional<ProjectCategory> category = projectCategoryList.stream().filter(pc -> pc.getName().equals(categoryCell.getStringCellValue())).findFirst();
|
|
|
+ HSSFCell finalCategoryCell = categoryCell;
|
|
|
+ Optional<ProjectCategory> category = projectCategoryList.stream().filter(pc -> pc.getName().equals(finalCategoryCell.getStringCellValue())).findFirst();
|
|
|
if(!category.isPresent()){
|
|
|
throw new Exception("项目分类["+categoryCell.getStringCellValue()+"]不存在");
|
|
|
}
|
|
@@ -2593,8 +2658,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for (int j = 0; j < providerCategoryList.size(); j++) {
|
|
|
String nameSb = "";
|
|
|
String idSb = "";
|
|
|
- providerCell=row.getCell(8+i);
|
|
|
- HSSFCell cell = row.getCell(10);
|
|
|
+ if(timeType.getMainProjectState()==1){
|
|
|
+ providerCell=row.getCell(7+i);
|
|
|
+ HSSFCell cell = row.getCell(9);
|
|
|
+ }else {
|
|
|
+ providerCell=row.getCell(8+i);
|
|
|
+ HSSFCell cell = row.getCell(10);
|
|
|
+ }
|
|
|
System.out.println("当前分类:"+providerCategoryList.get(j).getProviderCategoryName()+", categoryId="+providerCategoryList.get(j).getId());
|
|
|
String categoryName = providerCategoryList.get(j).getProviderCategoryName();
|
|
|
Integer categoryId = providerCategoryList.get(j).getId();
|
|
@@ -2865,12 +2935,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ if(company.getPackageCustomer()==1){
|
|
|
+ rowData.add(projectVO.getCustomerName());
|
|
|
+ }
|
|
|
if (company.getPackageProject() == 1) {
|
|
|
Integer level = projectVO.getLevel();
|
|
|
if (level == null) {
|
|
|
level = 1;
|
|
|
}
|
|
|
- rowData.add(projectVO.getCustomerName());
|
|
|
rowData.add(levelArray[level-1]);
|
|
|
rowData.add(df.format((Double)projectVO.getContractAmount()));
|
|
|
}
|
|
@@ -3074,12 +3146,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司加班情况");
|
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门加班情况");
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDeptList.size()>0){
|
|
|
- deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
- deptIds.add(user.getDepartmentId());
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
@@ -3462,6 +3540,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
//当前用户管理部门
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",companyId));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id", companyId));
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看全公司");
|
|
|
List<SysRichFunction> functionDpartList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门");
|
|
@@ -3470,8 +3549,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDpartList.size()>0){
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
- deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
@@ -3746,12 +3830,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司工时分配");
|
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门工时分配");
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDeptList.size()>0){
|
|
|
- deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
-
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
@@ -3782,12 +3871,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "全公司工时分配");
|
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(user.getRoleId(), "负责部门工时分配");
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",user.getCompanyId()));
|
|
|
List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", user.getId()).eq("company_id",user.getCompanyId()));
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDeptList.size()>0){
|
|
|
- deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
- deptIds.add(user.getDepartmentId());
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ List<Integer> collect = departmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
@@ -3831,11 +3925,18 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "全公司工时分配");
|
|
|
List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "负责部门工时分配");
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",targetUser.getCompanyId()));
|
|
|
List<Department> userDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id",targetUser.getCompanyId()));
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDeptList.size()>0){
|
|
|
- deptIds = userDepartmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ List<Integer> collect = userDepartmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
+
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
@@ -3931,9 +4032,6 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- System.out.println(user.getName());
|
|
|
- System.out.println(days);
|
|
|
- System.out.println(num);
|
|
|
BigDecimal bigDecimal=new BigDecimal(num);
|
|
|
BigDecimal divide;
|
|
|
if(days!=0){
|
|
@@ -4058,31 +4156,84 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
@Override
|
|
|
public HttpRespMsg getUserWorkingTimeStatic(String startDate, String endDate, Integer pageIndex, Integer pageSize, HttpServletRequest request,String userId,Integer departmentId) {
|
|
|
+ HttpRespMsg httpRespMsg =new HttpRespMsg();
|
|
|
+ DecimalFormat dft = new DecimalFormat("0%");
|
|
|
User targetUser = userMapper.selectById(request.getHeader("token"));
|
|
|
- List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看全部人员工时统计");
|
|
|
- List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看负责部门人员工时统计");
|
|
|
+ List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "全公司工时统计");
|
|
|
+ List<SysRichFunction> functionDeptList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "负责部门工时统计");
|
|
|
List<Integer> deptIds=null;
|
|
|
+ List<Department> allDepartmentList=departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id",targetUser.getCompanyId()));
|
|
|
List<Department> userDepartmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("manager_id", targetUser.getId()).eq("company_id",targetUser.getCompanyId()));
|
|
|
//判断查看权限
|
|
|
if(functionAllList.size()==0){
|
|
|
if(functionDeptList.size()>0){
|
|
|
- deptIds = userDepartmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ List<Integer> collect = userDepartmentList.stream().distinct().map(dm -> dm.getDepartmentId()).collect(Collectors.toList());
|
|
|
+ for (Integer integer : collect) {
|
|
|
+ List<Integer> branchDepartment = getBranchDepartment(integer, allDepartmentList);
|
|
|
+ deptIds.addAll(branchDepartment);
|
|
|
+ }
|
|
|
}else {
|
|
|
deptIds=new ArrayList<>();
|
|
|
deptIds.add(-1);
|
|
|
}
|
|
|
}
|
|
|
long total;
|
|
|
- List<Map<String,Object>> resultList=projectMapper.getUserWorkingTimeStatic(startDate,endDate,pageIndex,pageSize,userId,departmentId,deptIds);
|
|
|
+ List<Map<String,Object>> resultList;
|
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
|
- total=projectMapper.findCountWithUserWorkingTime(startDate,endDate,pageIndex,pageSize,userId,departmentId,deptIds);
|
|
|
+ Integer size=pageSize;
|
|
|
+ Integer start=(pageIndex-1)*size;
|
|
|
+ resultList=projectMapper.getUserWorkingTimeStatic(targetUser.getCompanyId(),startDate,endDate,start,size,userId,departmentId,deptIds);
|
|
|
+ total=projectMapper.findCountWithUserWorkingTime(targetUser.getCompanyId(),startDate,endDate,start,size,userId,departmentId,deptIds);
|
|
|
}else{
|
|
|
- total=projectMapper.findCountWithUserWorkingTime(startDate,endDate,null,null,userId,departmentId,deptIds);
|
|
|
+ resultList=projectMapper.getUserWorkingTimeStatic(targetUser.getCompanyId(),startDate,endDate,null,null,userId,departmentId,deptIds);
|
|
|
+ total=projectMapper.findCountWithUserWorkingTime(targetUser.getCompanyId(),startDate,endDate,null,null,userId,departmentId,deptIds);
|
|
|
+ }
|
|
|
+ for (Map<String, Object> map : resultList) {
|
|
|
+ BigDecimal phBigDecimal =new BigDecimal(String.valueOf(map.get("planHours")==null?0:map.get("planHours")));
|
|
|
+ BigDecimal wtBigDecimal =new BigDecimal(String.valueOf(map.get("workingTime")==null?0:map.get("workingTime")));
|
|
|
+ if(phBigDecimal.compareTo(BigDecimal.ZERO)==0||wtBigDecimal.compareTo(BigDecimal.ZERO)==0){
|
|
|
+ map.put("proportion",dft.format(0));
|
|
|
+ }else{
|
|
|
+ BigDecimal divide = wtBigDecimal.divide(phBigDecimal, 2, BigDecimal.ROUND_HALF_UP);
|
|
|
+ map.put("proportion",dft.format(divide));
|
|
|
+ }
|
|
|
}
|
|
|
Map<String,Object> map=new HashMap<>();
|
|
|
map.put("result",resultList);
|
|
|
map.put("total",total);
|
|
|
- return null;
|
|
|
+ httpRespMsg.data=map;
|
|
|
+ return httpRespMsg;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg exportUserWorkingTimeStatic(String startDate, String endDate, HttpServletRequest request, String userId, Integer departmentId) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ HttpRespMsg httpRespMsg = getUserWorkingTimeStatic(startDate, endDate, null, null, request, userId, departmentId);
|
|
|
+ Map<String,Object> data = (Map<String, Object>) httpRespMsg.data;
|
|
|
+ List<Map<String,Object>> resultList= (List<Map<String, Object>>) data.get("result");
|
|
|
+ List<List<String>> dataList=new ArrayList<>();
|
|
|
+ List<String> titleList=new ArrayList<>();
|
|
|
+ titleList.add("姓名");
|
|
|
+ titleList.add("部门");
|
|
|
+ titleList.add("计划工时");
|
|
|
+ titleList.add("实际工时");
|
|
|
+ titleList.add("实际用时占比");
|
|
|
+ dataList.add(titleList);
|
|
|
+ for (Map<String, Object> map : resultList) {
|
|
|
+ List<String> item=new ArrayList<>();
|
|
|
+ item.add((String) map.get("name"));
|
|
|
+ item.add((String) map.get("departmentName")==null?"":(String) map.get("departmentName"));
|
|
|
+ item.add(String.valueOf(map.get("planHours")).equals("null")?"":String.valueOf(map.get("planHours")));
|
|
|
+ item.add(String.valueOf(map.get("workingTime")).equals("null")?"":String.valueOf(map.get("workingTime")));
|
|
|
+ item.add(String.valueOf(map.get("proportion")).equals("null")?"":String.valueOf(map.get("proportion")));
|
|
|
+ dataList.add(item);
|
|
|
+ }
|
|
|
+ //生成excel文件导出
|
|
|
+ String fileName = "人员工时统计_"+System.currentTimeMillis();
|
|
|
+ String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
|
|
|
+ msg.data = resp;
|
|
|
+ return msg;
|
|
|
}
|
|
|
|
|
|
|