|
@@ -284,8 +284,7 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
public HttpRespMsg getUserStatistics(Integer departmentId, HttpServletRequest request) {
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
try {
|
|
|
-// Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
- Integer companyId = 6;
|
|
|
+ Integer companyId = userMapper.selectById(request.getHeader("Token")).getCompanyId();
|
|
|
//首先校验有无权限
|
|
|
if (departmentMapper.selectCount(new QueryWrapper<Department>()
|
|
|
.eq("department_id", departmentId)
|
|
@@ -293,28 +292,36 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
List<Map<String, Object>> list = departmentMapper
|
|
|
.getCostByUser(getBranchDepartment(departmentId, companyId));
|
|
|
Map<String, List<Map<String, Object>>> tempMap = new HashMap<>();
|
|
|
+ Double totalCostMoney = (double) 0;
|
|
|
for (Map<String, Object> map : list) {
|
|
|
if (tempMap.containsKey(map.get("user"))) {
|
|
|
//这个名字已经装进数组中了
|
|
|
List<Map<String, Object>> tempList = tempMap.get(map.get("user"));
|
|
|
- Map<String, Object> finalMap = new HashMap<>();
|
|
|
- finalMap.put("project", map.get("project"));
|
|
|
- finalMap.put("money", map.getOrDefault("money", 0));
|
|
|
- finalMap.put("time", map.getOrDefault("time", 0));
|
|
|
- tempList.add(finalMap);
|
|
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("project", map.get("project"));
|
|
|
+ Double money = (Double) map.getOrDefault("money", 0);
|
|
|
+ Double time = (Double) map.getOrDefault("time", 0);
|
|
|
+ totalCostMoney += money;
|
|
|
+ dataMap.put("money", money);
|
|
|
+ dataMap.put("time", time);
|
|
|
+ tempList.add(dataMap);
|
|
|
} else {
|
|
|
//这个名字尚未装进数组中
|
|
|
List<Map<String, Object>> tempList = new ArrayList<>();
|
|
|
if (map.containsKey("project")) {
|
|
|
Map<String, Object> dataMap = new HashMap<>();
|
|
|
dataMap.put("project", map.get("project"));
|
|
|
- dataMap.put("money", map.getOrDefault("money", 0));
|
|
|
- dataMap.put("time", map.getOrDefault("time", 0));
|
|
|
+ Double money = (Double) map.getOrDefault("money", 0);
|
|
|
+ Double time = (Double) map.getOrDefault("time", 0);
|
|
|
+ totalCostMoney += money;
|
|
|
+ dataMap.put("money", money);
|
|
|
+ dataMap.put("time", time);
|
|
|
tempList.add(dataMap);
|
|
|
}
|
|
|
tempMap.put((String) map.get("user"), tempList);
|
|
|
}
|
|
|
}
|
|
|
+ Map<String, Object> finalMap = new HashMap<>();
|
|
|
List<Map<String, Object>> finalList = new ArrayList<>();
|
|
|
for (String key : tempMap.keySet()) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
@@ -322,7 +329,9 @@ public class DepartmentServiceImpl extends ServiceImpl<DepartmentMapper, Departm
|
|
|
map.put("project", tempMap.get(key));
|
|
|
finalList.add(map);
|
|
|
}
|
|
|
- httpRespMsg.data = finalList;
|
|
|
+ finalMap.put("totalCostMoney", totalCostMoney);
|
|
|
+ finalMap.put("list", finalList);
|
|
|
+ httpRespMsg.data = finalMap;
|
|
|
} else {
|
|
|
httpRespMsg.setError("部门不存在或无查看权限");
|
|
|
}
|