|
@@ -4272,18 +4272,45 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
map.put("totalWorkingTime",mapList.stream().mapToDouble(mt->Double.valueOf(String.valueOf(mt.get("working_time")))).sum());
|
|
|
map.put("totalCost",mapList.stream().mapToDouble(mt->Double.valueOf(String.valueOf(mt.get("cost")))).sum());
|
|
|
if(checkStatus!=null && detailStatus==null){
|
|
|
+ DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ DateTimeFormatter dtf1=DateTimeFormatter.ofPattern("yyyyMMdd");
|
|
|
+ List<LocalDate> allDateList = getDays(LocalDate.parse(startDate, dtf), LocalDate.parse(endDate, dtf));
|
|
|
+ List<String> dataStringList=new ArrayList<>();
|
|
|
+ //补全日期列表
|
|
|
+ for (LocalDate localDate : allDateList) {
|
|
|
+ dataStringList.add(localDate.format(dtf1));
|
|
|
+ }
|
|
|
map=new HashMap();
|
|
|
List<String> dateList = mapList.stream().map(m -> String.valueOf(m.get("createDate"))).distinct().collect(Collectors.toList());
|
|
|
+ dateList.addAll(dataStringList.stream().filter(dl->!dateList.contains(dl)).collect(Collectors.toList()));
|
|
|
Map<Object, List<Map<String, Object>>> listMap = mapList.stream().collect(Collectors.groupingBy(m -> m.get("createDate")));
|
|
|
List<Map<String,Object>> resultList=new ArrayList<>();
|
|
|
+ List<User> userList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", user.getCompanyId()));
|
|
|
+ List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", user.getCompanyId()).eq("manager_id", user.getId()));
|
|
|
+ List<DepartmentOtherManager> departmentOtherManagers = departmentOtherManagerMapper.selectList(new QueryWrapper<DepartmentOtherManager>().eq("company_id", user.getCompanyId()).eq("other_manager_id", user.getId()));
|
|
|
+ List<Integer> deptIds = departmentList.stream().map(Department::getDepartmentId).distinct().collect(Collectors.toList());
|
|
|
+ List<Integer> otherDeptIds = departmentOtherManagers.stream().map(DepartmentOtherManager::getDepartmentId).distinct().collect(Collectors.toList());
|
|
|
+ deptIds.addAll(otherDeptIds);
|
|
|
+ List<Integer> targetDeptIds = deptIds.stream().distinct().collect(Collectors.toList());
|
|
|
+ boolean canViewAll = sysFunctionService.hasPriviledge(user.getRoleId(), "查看全部人员工时工价");
|
|
|
for (String s : dateList) {
|
|
|
Map<String,Object> item=new HashMap();
|
|
|
List<Map<String, Object>> list = listMap.get(s);
|
|
|
item.put("createDate",s);
|
|
|
+ //补全的日期无数据的情况 手填填入
|
|
|
+ if(list==null){
|
|
|
+ list=new ArrayList<>();
|
|
|
+ Map<String,Object> ob=new HashMap<>();
|
|
|
+ ob.put("creator_id",user.getId());
|
|
|
+ ob.put("creatorName",user.getName());
|
|
|
+ ob.put("working_time",0);
|
|
|
+ ob.put("cost",0);
|
|
|
+ list.add(ob);
|
|
|
+ }
|
|
|
Map<Object, Map<String, Object>> mapMap = list.stream().collect(Collectors.groupingBy(m -> m.get("creator_id"), Collectors.collectingAndThen(Collectors.toList(), i -> {
|
|
|
Map<String, Object> retMap = new HashMap<>();
|
|
|
- double working_time = i.stream().mapToDouble(mmm -> Double.valueOf(String.valueOf(mmm.get("working_time")))).sum();
|
|
|
- double cost = i.stream().mapToDouble(mmm -> Double.valueOf(String.valueOf(mmm.get("cost")))).sum();
|
|
|
+ double working_time = i.stream().mapToDouble(mmm -> Double.valueOf(String.valueOf(mmm.get("working_time")==null?0:mmm.get("working_time")))).sum();
|
|
|
+ double cost = i.stream().mapToDouble(mmm -> Double.valueOf(String.valueOf(mmm.get("cost")==null?0:mmm.get("cost")))).sum();
|
|
|
retMap.put("working_time", working_time);
|
|
|
retMap.put("creatorName",i.get(0).get("creatorName"));
|
|
|
retMap.put("creatorId",i.get(0).get("creator_id"));
|
|
@@ -4296,6 +4323,19 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
Map<String, Object> nameItem = mapMap.get(id);
|
|
|
theData.add(nameItem);
|
|
|
}
|
|
|
+ if(checkStatus==1){
|
|
|
+ List<User> users = userList.stream().filter(ul -> !theData.stream().anyMatch(td -> td.get("creatorId").equals(ul.getId()))).collect(Collectors.toList());
|
|
|
+ for (User u : users) {
|
|
|
+ if(canViewAll?(targetDeptIds.size()>0):(targetDeptIds.size()>0&&targetDeptIds.contains(u.getDepartmentId()))){
|
|
|
+ Map<String, Object> nameItem =new HashMap<>();
|
|
|
+ nameItem.put("working_time", 0);
|
|
|
+ nameItem.put("creatorName",u.getName());
|
|
|
+ nameItem.put("creatorId",u.getId());
|
|
|
+ nameItem.put("cost", 0);
|
|
|
+ theData.add(nameItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
item.put("subDataList",theData);
|
|
|
item.put("working_time",list.stream().mapToDouble(mt->Double.valueOf(String.valueOf(mt.get("working_time")))).sum());
|
|
|
item.put("cost",list.stream().mapToDouble(mt->Double.valueOf(String.valueOf(mt.get("cost")))).sum());
|