|
@@ -8103,37 +8103,46 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
//查看全部
|
|
|
resultList=reportMapper.getUserWorkTimeByCategory(categoryId,userId,user.getCompanyId(),null,deptId,startDate,endDate);
|
|
|
}
|
|
|
- List<String> userIdList = resultList.stream().map(m -> String.valueOf(m.get("userId"))).distinct().collect(Collectors.toList());
|
|
|
- Map<String, List<Map<String, Object>>> listMap = resultList.stream().collect(Collectors.groupingBy(r -> String.valueOf(r.get("userId"))));
|
|
|
+
|
|
|
+ List<String> projectIdList = resultList.stream().map(m -> String.valueOf(m.get("projectId"))).distinct().collect(Collectors.toList());
|
|
|
+
|
|
|
+ Map<String, List<Map<String, Object>>> listMapGroupByProject = resultList.stream().collect(Collectors.groupingBy(r -> String.valueOf(r.get("projectId"))));
|
|
|
List<Map<String,Object>> lastList=new ArrayList<>();
|
|
|
- for (String targetUserId : userIdList) {
|
|
|
- Optional<Map<String, Object>> first = resultList.stream().filter(r -> String.valueOf(r.get("userId")).equals(targetUserId)).findFirst();
|
|
|
- if(first.isPresent()){
|
|
|
- Map<String, Object> map = first.get();
|
|
|
- Map<String,Object> item=new HashMap<>();
|
|
|
- item.put("userId",String.valueOf(map.get("userId")));
|
|
|
- item.put("categoryName",String.valueOf(map.get("categoryName")));
|
|
|
- item.put("deptName",String.valueOf(map.get("deptName")));
|
|
|
- item.put("userName",String.valueOf(map.get("userName")));
|
|
|
- item.put("deptId",String.valueOf(map.get("deptId")));
|
|
|
- item.put("targetWorkingTime",String.valueOf(map.get("targetWorkingTime")));
|
|
|
- item.put("allWorkingTime",String.valueOf(map.get("allWorkingTime")));
|
|
|
- item.put("plate1",map.get("plate1")==null?"":String.valueOf(map.get("plate1")));
|
|
|
- item.put("plate2",map.get("plate2")==null?"":String.valueOf(map.get("plate2")));
|
|
|
- item.put("plate3",map.get("plate3")==null?"":String.valueOf(map.get("plate3")));
|
|
|
- item.put("plate4",map.get("plate4")==null?"":String.valueOf(map.get("plate4")));
|
|
|
- item.put("plate5",map.get("plate5")==null?"":String.valueOf(map.get("plate5")));
|
|
|
- if(map.get("corpWxUserId")!=null){
|
|
|
- item.put("corpWxUserId",String.valueOf(map.get("corpWxUserId")));
|
|
|
- }
|
|
|
- if(map.get("corpWxDeptId")!=null){
|
|
|
- item.put("corpWxDeptId",String.valueOf(map.get("corpWxDeptId")));
|
|
|
- }
|
|
|
- List<Map<String, Object>> mapList = listMap.get(targetUserId);
|
|
|
- item.put("dataList",mapList);
|
|
|
- lastList.add(item);
|
|
|
+ for (String targetProjectId : projectIdList) {
|
|
|
+ List<Map<String, Object>> maps = listMapGroupByProject.get(targetProjectId);
|
|
|
+ Optional<Map<String, Object>> first = resultList.stream().filter(r -> String.valueOf(r.get("projectId")).equals(targetProjectId)).findFirst();
|
|
|
+ Map<String, List<Map<String, Object>>> listMapGroupByUser = maps.stream().collect(Collectors.groupingBy(r -> String.valueOf(r.get("userId"))));
|
|
|
+ List<String> userIdList = maps.stream().map(m -> String.valueOf(m.get("userId"))).distinct().collect(Collectors.toList());
|
|
|
+ for (String targetUserId : userIdList) {
|
|
|
+ if(first.isPresent()){
|
|
|
+ Map<String, Object> map = first.get();
|
|
|
+ Map<String,Object> item=new HashMap<>();
|
|
|
+ item.put("userId",String.valueOf(map.get("userId")));
|
|
|
+ item.put("projectCode",String.valueOf(map.get("projectCode")));
|
|
|
+ item.put("deptName",String.valueOf(map.get("deptName")));
|
|
|
+ item.put("userName",String.valueOf(map.get("userName")));
|
|
|
+ item.put("deptId",String.valueOf(map.get("deptId")));
|
|
|
+ item.put("targetWorkingTime",String.valueOf(map.get("targetWorkingTime")));
|
|
|
+ item.put("allWorkingTime",String.valueOf(map.get("allWorkingTime")));
|
|
|
+ item.put("plate1",map.get("plate1")==null?"":String.valueOf(map.get("plate1")));
|
|
|
+ item.put("plate2",map.get("plate2")==null?"":String.valueOf(map.get("plate2")));
|
|
|
+ item.put("plate3",map.get("plate3")==null?"":String.valueOf(map.get("plate3")));
|
|
|
+ item.put("plate4",map.get("plate4")==null?"":String.valueOf(map.get("plate4")));
|
|
|
+ item.put("plate5",map.get("plate5")==null?"":String.valueOf(map.get("plate5")));
|
|
|
+ if(map.get("corpWxUserId")!=null){
|
|
|
+ item.put("corpWxUserId",String.valueOf(map.get("corpWxUserId")));
|
|
|
+ }
|
|
|
+ if(map.get("corpWxDeptId")!=null){
|
|
|
+ item.put("corpWxDeptId",String.valueOf(map.get("corpWxDeptId")));
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> mapList = listMapGroupByUser.get(targetUserId);
|
|
|
+ item.put("dataList",mapList);
|
|
|
+ lastList.add(item);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
if(start!=null&&size!=null){
|
|
|
if(lastList.size()<size){
|
|
|
size=lastList.size();
|
|
@@ -8156,6 +8165,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
public HttpRespMsg exportUserWorkTimeByCategory(Integer categoryId, Integer deptId, String userId, String startDate, String endDate) {
|
|
|
HttpRespMsg msg = getUserWorkTimeByCategory(categoryId, deptId, userId, startDate, endDate, null, null);
|
|
|
Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
|
|
|
+
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", companyId));
|
|
|
DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
List<LocalDate> dates = getDays(LocalDate.parse(startDate, dtf), LocalDate.parse(endDate, dtf));
|
|
@@ -8163,7 +8173,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
Map<String,Object> data = (Map<String, Object>) msg.getData();
|
|
|
List<List<String>> dataList=new ArrayList<>();
|
|
|
List<String> titleList=new ArrayList<>();
|
|
|
- titleList.add("生产项目号");
|
|
|
+ if(categoryId!=null){
|
|
|
+ ProjectCategory projectCategory = projectCategoryMapper.selectById(categoryId);
|
|
|
+ titleList.add(projectCategory.getName()+"项目号");
|
|
|
+ }else {
|
|
|
+ titleList.add("未分配");
|
|
|
+ }
|
|
|
titleList.add("姓名");
|
|
|
titleList.add("部门");
|
|
|
List<Map<String,Object>> headerList= (List<Map<String, Object>>) data.get("header");
|
|
@@ -8172,7 +8187,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
titleList.add(String.valueOf(custom.get("titleName")));
|
|
|
}
|
|
|
titleList.add("总工时");
|
|
|
- titleList.add("生产工时");
|
|
|
+ if(categoryId!=null){
|
|
|
+ ProjectCategory projectCategory = projectCategoryMapper.selectById(categoryId);
|
|
|
+ titleList.add(projectCategory.getName()+"工时");
|
|
|
+ }else {
|
|
|
+ titleList.add("未分配工时");
|
|
|
+ }
|
|
|
for (Map<String, Object> header : headerList) {
|
|
|
titleList.add(String.valueOf(header.get("titleName")));
|
|
|
}
|
|
@@ -8180,7 +8200,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
|
|
|
List<Map<String,Object>> records = (List<Map<String, Object>>) data.get("record");
|
|
|
for (Map<String, Object> record : records) {
|
|
|
List<String> item=new ArrayList<>();
|
|
|
- item.add(String.valueOf(record.get("categoryName")));
|
|
|
+ item.add(String.valueOf(record.get("projectCode")));
|
|
|
if(wxCorpInfo!=null&&wxCorpInfo.getSaasSyncContact()==1){
|
|
|
item.add("$userName="+String.valueOf(record.get("corpWxUserId"))+"$");
|
|
|
item.add("$departmentName="+String.valueOf(record.get("corpWxDeptId"))+"$");
|