|
@@ -254,6 +254,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String auditUserIds,
|
|
|
Integer category,
|
|
|
String projectDesc,
|
|
|
+ Integer projectMainId,
|
|
|
HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("Token"));
|
|
@@ -308,6 +309,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
.setAssociateDegreeNames(associateDegreeNames)
|
|
|
.setCustomerId(customerId)
|
|
|
.setProjectDesc(projectDesc)
|
|
|
+ .setProjectMainId(projectMainId)
|
|
|
.setTaskGpIncharge(taskGpIncharge);
|
|
|
if (category != null) {
|
|
|
ProjectCategory projectCategory = projectCategoryMapper.selectById(category);
|
|
@@ -375,6 +377,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
.setAssociateDegreeNames(associateDegreeNames)
|
|
|
.setCustomerId(customerId)
|
|
|
.setProjectDesc(projectDesc)
|
|
|
+ .setProjectMainId(projectMainId)
|
|
|
.setTaskGpIncharge(taskGpIncharge);
|
|
|
if (category != null) {
|
|
|
ProjectCategory projectCategory = projectCategoryMapper.selectById(category);
|
|
@@ -646,13 +649,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
//根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
|
|
|
- Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId =targetUser.getCompanyId();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
-
|
|
|
+ //当前用户所属部门 或者 管理部门
|
|
|
+ List<Integer> deptIds=null;
|
|
|
+ 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(), "查看负责部门");
|
|
|
+ List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
+ List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
+ //判断查看权限
|
|
|
+ if(functionAllList.size()==0){
|
|
|
+ if(functionDpartList.size()>0){
|
|
|
+ if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
+ deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ deptIds.add(targetUser.getDepartmentId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ deptIds.add(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
if (timeType.getFixMonthcost() == 1) {
|
|
|
//每月固定月薪的方式计算,平摊到各个项目中
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null,deptIds);
|
|
|
//检查财务表中是否已经导入成本
|
|
|
List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
@@ -710,10 +732,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
resultMap.put("costList", retList);
|
|
|
resultMap.put("totalMoneyCost", totalMoneyCost);
|
|
|
+ if(functionCostList.size()==0){
|
|
|
+ resultMap.put("totalCostMoney",null);
|
|
|
+ list.forEach(li->{
|
|
|
+ li.put("costMoney",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(functionTimeList.size()==0){
|
|
|
+ retList.forEach(li->{
|
|
|
+ li.put("cost",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
httpRespMsg.data = resultMap;
|
|
|
|
|
|
} else {
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, null, userId,deptIds);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (!map.containsKey("cost")) {
|
|
@@ -728,14 +761,24 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
resultMap.put("costList", list);
|
|
|
resultMap.put("totalMoneyCost", totalMoneyCost);
|
|
|
+ if(functionCostList.size()==0){
|
|
|
+ resultMap.put("totalCostMoney",null);
|
|
|
+ list.forEach(li->{
|
|
|
+ li.put("costMoney",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(functionTimeList.size()==0){
|
|
|
+ list.forEach(li->{
|
|
|
+ li.put("cost",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
httpRespMsg.data = resultMap;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
} catch (NullPointerException e) {
|
|
|
httpRespMsg.setError("验证失败");
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
+
|
|
|
return httpRespMsg;
|
|
|
}
|
|
|
|
|
@@ -744,9 +787,29 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
public HttpRespMsg exportTimeCost(String startDate, String endDate,Integer projectId, String userId, Boolean projectSum,Integer type, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
- Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId =targetUser.getCompanyId();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId);
|
|
|
+ //当前用户所属部门 或者 管理部门
|
|
|
+ List<Integer> deptIds=null;
|
|
|
+ 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(), "查看负责部门");
|
|
|
+ List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
+ List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
+ //判断查看权限
|
|
|
+ if(functionAllList.size()==0){
|
|
|
+ if(functionDpartList.size()>0){
|
|
|
+ if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
+ deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ deptIds.add(targetUser.getDepartmentId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ deptIds.add(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCost(companyId, startDate, endDate, projectId, userId,deptIds);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
List<List<String>> allList=null ;
|
|
|
List<String> sumRow = null;
|
|
@@ -757,8 +820,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
headList.add("项目分类");
|
|
|
headList.add("人员");
|
|
|
headList.add("部门");
|
|
|
- headList.add("工时(h)");
|
|
|
- headList.add("成本(元)");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ headList.add("工时(h)");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ headList.add("成本(元)");
|
|
|
+ }
|
|
|
allList=new ArrayList<>();
|
|
|
allList.add(headList);
|
|
|
double totalCostTime = 0;
|
|
@@ -778,8 +845,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
rowData.add((String)map.get("categoryName"));
|
|
|
rowData.add("");
|
|
|
rowData.add("");
|
|
|
- rowData.add(((Double)map.get("cost")).toString());
|
|
|
- rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ rowData.add(((Double)map.get("cost")).toString());
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ }
|
|
|
if (projectSum != null && projectSum == true) {
|
|
|
allList.add(rowData);
|
|
|
}
|
|
@@ -800,11 +871,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
membRowData.add("");
|
|
|
membRowData.add("");
|
|
|
}
|
|
|
-
|
|
|
membRowData.add((String)membMap.get("name"));
|
|
|
membRowData.add((String)membMap.get("departmentName"));
|
|
|
- membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
- membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add(((Double)membMap.get("cost")).toString());
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ membRowData.add(((BigDecimal)membMap.get("costMoney")).toString());
|
|
|
+ }
|
|
|
allList.add(membRowData);
|
|
|
}
|
|
|
}
|
|
@@ -815,8 +889,12 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
sumRow.add("");
|
|
|
sumRow.add("");
|
|
|
sumRow.add("");
|
|
|
- sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
- sumRow.add(totalMoneyCost.toString());
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ sumRow.add(totalMoneyCost.toString());
|
|
|
+ }
|
|
|
allList.add(sumRow);
|
|
|
}else{
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
@@ -825,15 +903,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<String> headList = new ArrayList<String>();
|
|
|
headList.add("人员");
|
|
|
projectNames.forEach(pn->{
|
|
|
- headList.add(String.valueOf(pn)+"/工时");
|
|
|
- headList.add(String.valueOf(pn)+"/成本");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ headList.add(String.valueOf(pn)+"/工时");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ headList.add(String.valueOf(pn)+"/成本");
|
|
|
+ }
|
|
|
});
|
|
|
- headList.add("合计/工时");
|
|
|
- headList.add("合计/成本");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ headList.add("合计/工时");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ headList.add("合计/成本");
|
|
|
+ }
|
|
|
allList=new ArrayList<>();
|
|
|
allList.add(headList);
|
|
|
//统计当前所有项目所有人的时间成本投入
|
|
|
- List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByProject(companyId,startDate, endDate, projectId,userId);
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByProject(companyId,startDate, endDate, projectId,userId,deptIds);
|
|
|
for (User user : userList) {
|
|
|
BigDecimal moneyCost = BigDecimal.valueOf(0);
|
|
|
double costTime = 0;
|
|
@@ -843,17 +929,29 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for(Object i:projectIds){
|
|
|
List<Map<String, Object>> resultList = mapList.stream().filter(mp -> mp.get("projectId").equals(i)).collect(Collectors.toList());
|
|
|
if(resultList.size()>0){
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("cost")));
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add(String.valueOf(resultList.get(0).get("cost")));
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
|
|
|
+ }
|
|
|
costTime += (Double)resultList.get(0).get("cost");
|
|
|
moneyCost = moneyCost.add((BigDecimal)resultList.get(0).get("costMoney"));
|
|
|
}else{
|
|
|
- membRowData.add("");
|
|
|
- membRowData.add("");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add("");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ membRowData.add("");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
- membRowData.add(moneyCost.toString());
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ membRowData.add(moneyCost.toString());
|
|
|
+ }
|
|
|
if(mapList.size()>0){
|
|
|
allList.add(membRowData);
|
|
|
}
|
|
@@ -1882,11 +1980,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate, HttpServletRequest request) {
|
|
|
+ public HttpRespMsg getOvertimeList(String userId, Integer projectId, String startDate, String endDate, HttpServletRequest request,Integer departmentId) {
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
- List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,departmentId);
|
|
|
boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
|
|
|
if (!hasViewSalary) {
|
|
|
//去掉权限
|
|
@@ -1907,7 +2005,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
|
|
|
- List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null);
|
|
|
boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
List<String> headList = new ArrayList<String>();
|
|
@@ -2495,7 +2593,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
- List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getOvertimeDetail(userId, user.getCompanyId(), startDate, endDate, projectId,null);
|
|
|
boolean hasViewSalary = sysFunctionService.hasPriviledge(user.getRoleId(), "查看加班成本");
|
|
|
if (!hasViewSalary) {
|
|
|
//去掉权限
|
|
@@ -2844,13 +2942,32 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
//根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
|
|
|
- Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId =targetUser.getCompanyId();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
-
|
|
|
+ //当前用户所属部门 或者 管理部门
|
|
|
+ List<Integer> deptIds=null;
|
|
|
+ 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(), "查看负责部门");
|
|
|
+ List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
+ List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
+ //判断查看权限
|
|
|
+ if(functionAllList.size()==0){
|
|
|
+ if(functionDpartList.size()>0){
|
|
|
+ if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
+ deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ deptIds.add(targetUser.getDepartmentId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ deptIds.add(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
TimeType timeType = timeTypeMapper.selectById(companyId);
|
|
|
if (timeType.getFixMonthcost() == 1) {
|
|
|
//每月固定月薪的方式计算,平摊到各个项目中
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCostReport(companyId, startDate+"-01", endDate+"-31", null,deptIds);
|
|
|
//检查财务表中是否已经导入成本
|
|
|
List<Finance> financeList = financeMapper.selectList(new QueryWrapper<Finance>().eq("ymonth", startDate).eq("company_id", companyId));
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
@@ -2908,10 +3025,21 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
resultMap.put("costList", retList);
|
|
|
resultMap.put("totalMoneyCost", totalMoneyCost);
|
|
|
+ if(functionCostList.size()==0){
|
|
|
+ resultMap.put("totalCostMoney",null);
|
|
|
+ retList.forEach(li->{
|
|
|
+ li.put("costMoney",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(functionTimeList.size()==0){
|
|
|
+ retList.forEach(li->{
|
|
|
+ li.put("cost",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
httpRespMsg.data = resultMap;
|
|
|
|
|
|
} else {
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, null, userId);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, null, userId,deptIds);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (!map.containsKey("cost")) {
|
|
@@ -2926,6 +3054,17 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
resultMap.put("costList", list);
|
|
|
resultMap.put("totalMoneyCost", totalMoneyCost);
|
|
|
+ if(functionCostList.size()==0){
|
|
|
+ resultMap.put("totalCostMoney",null);
|
|
|
+ list.forEach(li->{
|
|
|
+ li.put("costMoney",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ if(functionTimeList.size()==0){
|
|
|
+ list.forEach(li->{
|
|
|
+ li.put("cost",null);
|
|
|
+ });
|
|
|
+ }
|
|
|
httpRespMsg.data = resultMap;
|
|
|
}
|
|
|
|
|
@@ -2941,17 +3080,42 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
public HttpRespMsg exportTimeCostByCategory(String startDate, String endDate, Integer projectCategoryId, String userId, Boolean projectSum, Integer type, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
- Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
+ //根据系统配置的员工成本计算方式,按固定时薪还是固定月薪,分情况计算。
|
|
|
+ User targetUser = userMapper.selectById(request.getHeader("Token"));
|
|
|
+ Integer companyId =targetUser.getCompanyId();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
- List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, projectCategoryId, userId);
|
|
|
+ //当前用户所属部门 或者 管理部门
|
|
|
+ List<Integer> deptIds=null;
|
|
|
+ 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(), "查看负责部门");
|
|
|
+ List<SysRichFunction> functionTimeList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看工时统计");
|
|
|
+ List<SysRichFunction> functionCostList = sysFunctionMapper.getRoleFunctions(targetUser.getRoleId(), "查看成本统计");
|
|
|
+ //判断查看权限
|
|
|
+ if(functionAllList.size()==0){
|
|
|
+ if(functionDpartList.size()>0){
|
|
|
+ if(functionTimeList.size()>0||functionCostList.size()>0){
|
|
|
+ deptIds = departmentList.stream().map(dp -> dp.getDepartmentId()).distinct().collect(Collectors.toList());
|
|
|
+ deptIds.add(targetUser.getDepartmentId());
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ deptIds=new ArrayList<>();
|
|
|
+ deptIds.add(-1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> list = projectMapper.getTimeCostByCategory(companyId, startDate, endDate, projectCategoryId, userId,deptIds);
|
|
|
BigDecimal totalMoneyCost = BigDecimal.valueOf(0);
|
|
|
List<List<String>> allList=null ;
|
|
|
List<String> sumRow = null;
|
|
|
if(type==0){
|
|
|
List<String> headList = new ArrayList<String>();
|
|
|
headList.add("项目分类");
|
|
|
- headList.add("工时(h)");
|
|
|
- headList.add("成本(元)");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ headList.add("工时(h)");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ headList.add("成本(元)");
|
|
|
+ }
|
|
|
allList=new ArrayList<>();
|
|
|
allList.add(headList);
|
|
|
double totalCostTime = 0;
|
|
@@ -2967,15 +3131,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
totalCostTime += (Double)map.get("cost");
|
|
|
List<String> rowData = new ArrayList<String>();
|
|
|
rowData.add((String)map.get("categoryName"));
|
|
|
- rowData.add(((Double)map.get("cost")).toString());
|
|
|
- rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ rowData.add(((Double)map.get("cost")).toString());
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ rowData.add(((BigDecimal)map.get("costMoney")).toString());
|
|
|
+ }
|
|
|
allList.add(rowData);
|
|
|
}
|
|
|
//合计
|
|
|
sumRow=new ArrayList<>();
|
|
|
sumRow.add("合计");
|
|
|
- sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
- sumRow.add(totalMoneyCost.toString());
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ sumRow.add(""+new BigDecimal(totalCostTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ sumRow.add(totalMoneyCost.toString());
|
|
|
+ }
|
|
|
allList.add(sumRow);
|
|
|
}else{
|
|
|
List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
|
|
@@ -2984,15 +3156,23 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
List<String> headList = new ArrayList<String>();
|
|
|
headList.add("人员");
|
|
|
projectCategoryNameS.forEach(pc->{
|
|
|
- headList.add(String.valueOf(pc)+"/工时");
|
|
|
- headList.add(String.valueOf(pc)+"/成本");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ headList.add(String.valueOf(pc)+"/工时");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ headList.add(String.valueOf(pc)+"/成本");
|
|
|
+ }
|
|
|
});
|
|
|
- headList.add("工时/合计");
|
|
|
- headList.add("成本/合计");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ headList.add("工时/合计");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ headList.add("成本/合计");
|
|
|
+ }
|
|
|
allList=new ArrayList<>();
|
|
|
allList.add(headList);
|
|
|
//统计当前所有项目所有人的时间成本投入
|
|
|
- List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByCategory(companyId,startDate,endDate, projectCategoryId,userId);
|
|
|
+ List<Map<String, Object>> membList = projectMapper.getProjectCostGroupByCategory(companyId,startDate,endDate, projectCategoryId,userId,deptIds);
|
|
|
for (User user : userList) {
|
|
|
BigDecimal moneyCost = BigDecimal.valueOf(0);
|
|
|
double costTime = 0;
|
|
@@ -3002,17 +3182,29 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
for(Object i:projectCategorys){
|
|
|
List<Map<String, Object>> resultList = mapList.stream().filter(mp -> mp.get("category").equals(i)).collect(Collectors.toList());
|
|
|
if(resultList.size()>0){
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("cost")));
|
|
|
- membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add(String.valueOf(resultList.get(0).get("cost")));
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ membRowData.add(String.valueOf(resultList.get(0).get("costMoney")));
|
|
|
+ }
|
|
|
costTime += (Double)resultList.get(0).get("cost");
|
|
|
moneyCost = moneyCost.add((BigDecimal)resultList.get(0).get("costMoney"));
|
|
|
}else{
|
|
|
- membRowData.add("");
|
|
|
- membRowData.add("");
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add("");
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ membRowData.add("");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
- membRowData.add(moneyCost.toString());
|
|
|
+ if(functionTimeList.size()>0){
|
|
|
+ membRowData.add(""+new BigDecimal(costTime).setScale(1, BigDecimal.ROUND_HALF_UP));
|
|
|
+ }
|
|
|
+ if(functionCostList.size()>0){
|
|
|
+ membRowData.add(moneyCost.toString());
|
|
|
+ }
|
|
|
if(mapList.size()>0){
|
|
|
allList.add(membRowData);
|
|
|
}
|
|
@@ -3031,14 +3223,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate, Integer pageIndex, Integer pageSize,HttpServletRequest request) {
|
|
|
+ public HttpRespMsg getUserWorkingTimeList(String userId, Integer projectId, String startDate, String endDate, Integer pageIndex, Integer pageSize,HttpServletRequest request,Integer departmentId) {
|
|
|
//1.获取分页结果
|
|
|
Integer size=pageSize;//查询条数
|
|
|
Integer start =(pageIndex-1)*size;//limit开始
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
- List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,start,size,departmentId);
|
|
|
long total=projectMapper.findCountWithUser(userId, user.getCompanyId(), startDate, endDate, projectId,null,null);
|
|
|
list.forEach(li->{
|
|
|
double isPublic = (double) li.get("isPublic");
|
|
@@ -3060,7 +3252,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
|
String token = request.getHeader("TOKEN");
|
|
|
User user = userMapper.selectById(token);
|
|
|
- List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null);
|
|
|
+ List<Map<String, Object>> list = projectMapper.getUserWorkingTimeList(userId, user.getCompanyId(), startDate, endDate, projectId,null,null,null);
|
|
|
String[] string={"人员","普通项目工时","公共项目工时","总工时","公共项目工时占比"};
|
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
|
dataList.add(Arrays.asList(string));
|
|
@@ -3199,10 +3391,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg getWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId, Integer departmentId,Integer projectId,Integer pageIndex,Integer pageSize,String startDate,String endDate) {
|
|
|
+ public HttpRespMsg getWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId,Integer pageIndex,Integer pageSize,String startDate,String endDate) {
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
- List<Map<String,Object>> list;
|
|
|
Integer size;
|
|
|
Integer start;
|
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
@@ -3212,14 +3403,8 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
size=null;
|
|
|
start=null;
|
|
|
}
|
|
|
- long total;
|
|
|
- if(stateKey==0){
|
|
|
- list=projectMapper.getWaitingReviewListByDepartment(user.getCompanyId(),userId,departmentId,start,size,startDate,endDate);
|
|
|
- total=projectMapper.findCountWithDepartment(user.getCompanyId(),userId,departmentId,null,null,startDate,endDate);
|
|
|
- }else {
|
|
|
- list=projectMapper.getWaitingReviewListByProject(user.getCompanyId(),userId,projectId,start,size,startDate,endDate);
|
|
|
- total=projectMapper.findCountWithProject(user.getCompanyId(),userId,projectId,null,null,startDate,endDate);
|
|
|
- }
|
|
|
+ List<Map<String,Object>> list=projectMapper.getWaitingReviewList(user.getCompanyId(),userId,start,size,startDate,endDate);
|
|
|
+ long total=projectMapper.findCount(user.getCompanyId(),userId,null,null,startDate,endDate);
|
|
|
HashMap map=new HashMap();
|
|
|
map.put("total",total);
|
|
|
map.put("result",list);
|
|
@@ -3228,38 +3413,51 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public HttpRespMsg exportWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId, Integer departmentId, Integer projectId,String startDate,String endDate) {
|
|
|
- HttpRespMsg msg = getWaitingReviewList(request, stateKey, userId, departmentId, projectId, null, null,startDate,endDate);
|
|
|
+ public HttpRespMsg exportWaitingReviewList(HttpServletRequest request, Integer stateKey, String userId,String startDate,String endDate) {
|
|
|
+ HttpRespMsg msg = getWaitingReviewList(request, stateKey, userId, null, null,startDate,endDate);
|
|
|
HashMap resultmap= (HashMap) msg.data;
|
|
|
List<Map<String,Object>> list= (List<Map<String, Object>>) resultmap.get("result");
|
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
|
- String[] s;
|
|
|
- String fileName;
|
|
|
- if(stateKey==0){
|
|
|
- s= new String[]{"人员", "部门", "待审核数量"};
|
|
|
- fileName = "人员部门待审核统计_"+System.currentTimeMillis();
|
|
|
- }else {
|
|
|
- s= new String[]{"人员", "项目", "待审核数量"};
|
|
|
- fileName = "人员项目待审核统计_"+System.currentTimeMillis();
|
|
|
- }
|
|
|
+ String[] s={"人员", "待审核数量"};
|
|
|
dataList.add(Arrays.asList(s));
|
|
|
for (Map<String, Object> map : list) {
|
|
|
List<String> item=new ArrayList<>();
|
|
|
item.add(String.valueOf(map.get("userName")));
|
|
|
- if(stateKey==0){
|
|
|
- item.add(String.valueOf(map.get("departmentName")));
|
|
|
- }else {
|
|
|
- item.add(String.valueOf(map.get("projectName")));
|
|
|
- }
|
|
|
item.add(String.valueOf(map.get("num")));
|
|
|
dataList.add(item);
|
|
|
}
|
|
|
//生成excel文件导出
|
|
|
+ String fileName = "人员待审核统计_"+System.currentTimeMillis();
|
|
|
String resp = ExcelUtil.exportGeneralExcelByTitleAndList(fileName , dataList, path);
|
|
|
msg.data = resp;
|
|
|
return msg;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public HttpRespMsg batchSetParticipation(HttpServletRequest request,Integer[] projectIdArray,String[] userIds) {
|
|
|
+ HttpRespMsg msg=new HttpRespMsg();
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+ List<Integer> ids = Arrays.asList(projectIdArray);
|
|
|
+ List<String> userIdList = (List<String>) Arrays.asList(userIds);
|
|
|
+ List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().eq("company_id", companyId).in("id", ids));
|
|
|
+ List<Participation> list=new ArrayList<>();
|
|
|
+ for (Project project : projectList) {
|
|
|
+ List<Participation> participationList = participationMapper.selectList(new QueryWrapper<Participation>().eq("project_id", project.getId()));
|
|
|
+ for (String s : userIdList) {
|
|
|
+ boolean anyMatch = participationList.stream().anyMatch(pt -> pt.getUserId().equals(s));
|
|
|
+ if(anyMatch){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Participation participation=new Participation();
|
|
|
+ participation.setProjectId(project.getId());
|
|
|
+ participation.setUserId(s);
|
|
|
+ list.add(participation);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ participationService.saveBatch(list);
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
private List<Department> getSubDepts(Department dp, List<Department> list) {
|
|
|
List<Department> collect = list.stream().filter(l -> dp.getDepartmentId().equals(l.getSuperiorId())).collect(Collectors.toList());
|