|
@@ -7631,7 +7631,7 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
//部门参与项目情况表
|
|
|
@Override
|
|
|
- public HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String startDate,String endDate, Integer departmentId, HttpServletRequest request){
|
|
|
+ public HttpRespMsg deptPartInProjects(Integer pageIndex, Integer pageSize, String month, Integer departmentId, HttpServletRequest request){
|
|
|
HttpRespMsg httpRespMsg = new HttpRespMsg();
|
|
|
User user = userMapper.selectById(request.getHeader("token"));
|
|
|
List<SysRichFunction> functionAllList = sysFunctionMapper.getRoleFunctions(user.getRoleId(),"全部部门参与项目情况表");
|
|
@@ -7665,6 +7665,11 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
if(departmentId!=null){
|
|
|
branchDepartment = getBranchDepartment(departmentId, allDepartmentList);
|
|
|
}
|
|
|
+ String startDate = null;
|
|
|
+ String endDate = null;
|
|
|
+ LocalDate time = LocalDate.parse(month, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ startDate = time.with(TemporalAdjusters.firstDayOfMonth()).toString();
|
|
|
+ endDate = time.with(TemporalAdjusters.lastDayOfMonth()).toString();
|
|
|
//分页查询数据
|
|
|
if(pageIndex!=null&&pageSize!=null){
|
|
|
Integer size=pageSize;
|
|
@@ -7678,13 +7683,14 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
total = maps.size();
|
|
|
}
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
- System.err.println(resultList.toString());
|
|
|
if (resultList.size() > 0){
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate localStartDate = LocalDate.parse(startDate, dateTimeFormatter);
|
|
|
+ LocalDate localEndDate = LocalDate.parse(endDate, dateTimeFormatter);
|
|
|
for (Map<String, Object> stringObjectMap : resultList) {
|
|
|
Department department = departmentMapper.selectById(stringObjectMap.get("deptId").toString());
|
|
|
- if ("0".equals(stringObjectMap.get("deptId").toString())){
|
|
|
- stringObjectMap.put("deptName","未分配");
|
|
|
- }else if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact()==1 && department != null){
|
|
|
+ List<Map<String,Object>> businessTrips = null;
|
|
|
+ if (wxCorpInfo!=null && wxCorpInfo.getSaasSyncContact()==1 && department != null){
|
|
|
stringObjectMap.put("deptName",getWxDepartment(department));
|
|
|
}else {
|
|
|
stringObjectMap.put("deptName",getSupDepartment(department));
|
|
@@ -7694,14 +7700,42 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
stringObjectMap.put("centerCount",stringObjectMap.get("centerCount")==null?0:stringObjectMap.get("centerCount"));
|
|
|
stringObjectMap.put("peopleCount",stringObjectMap.get("peopleCount")==null?0:stringObjectMap.get("peopleCount"));
|
|
|
if (StringUtils.isEmpty(startDate) && StringUtils.isEmpty(endDate)){
|
|
|
- List<Map<String,Object>> businessTrips = businessTripMapper.selectBusiness(null, null,stringObjectMap.get("deptId").toString());
|
|
|
+ businessTrips = businessTripMapper.selectBusiness(null, null,stringObjectMap.get("deptId").toString());
|
|
|
Integer dayCount = businessTrips.stream().collect(Collectors.summingInt((b) -> (int)b.get("dayCount")));
|
|
|
stringObjectMap.put("tripCount",dayCount==null?0:dayCount);
|
|
|
- }else{
|
|
|
- List<Map<String,Object>> businessTrips = businessTripMapper.selectBusiness(startDate,endDate,stringObjectMap.get("deptId").toString());
|
|
|
+ }else {
|
|
|
+ businessTrips = businessTripMapper.selectBusiness(startDate,endDate,stringObjectMap.get("deptId").toString());
|
|
|
for (Map<String, Object> businessTrip : businessTrips) {
|
|
|
-
|
|
|
+ String tripStartS = businessTrip.get("startDate").toString();
|
|
|
+ String tripEndS = businessTrip.get("endDate").toString();
|
|
|
+ LocalDate tripStart = LocalDate.parse(tripStartS, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ LocalDate tripEnd = LocalDate.parse(tripEndS, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
|
|
|
+ //若出差开始时间不在本月内
|
|
|
+ if(tripStart.isBefore(localStartDate)){
|
|
|
+ long day = localStartDate.toEpochDay() - tripStart.toEpochDay();
|
|
|
+ int dayCount = Integer.parseInt(businessTrip.get("dayCount").toString());
|
|
|
+ businessTrip.put("dayCount",dayCount-day);
|
|
|
+ }
|
|
|
+ //若出差结束时间不在本月内
|
|
|
+ if (tripEnd.isAfter(localEndDate)){
|
|
|
+ long day = tripEnd.toEpochDay() - localEndDate.toEpochDay();
|
|
|
+ int dayCount = Integer.parseInt(businessTrip.get("dayCount").toString());
|
|
|
+ businessTrip.put("dayCount",dayCount-day);
|
|
|
+ }
|
|
|
+ System.err.println(stringObjectMap.get("deptId"));
|
|
|
+ System.err.print(tripStart);
|
|
|
+ System.err.println(tripEnd);
|
|
|
+ System.err.println(businessTrip.get("dayCount"));
|
|
|
}
|
|
|
+ Integer dayCount = businessTrips.stream().collect(Collectors.summingInt((b) -> Integer.parseInt(b.get("dayCount").toString())));
|
|
|
+ stringObjectMap.put("tripCount",dayCount==null?0:dayCount);
|
|
|
+ }
|
|
|
+ Long peopleCount = null;
|
|
|
+ if (businessTrips!=null && businessTrips.size()!=0){
|
|
|
+ peopleCount = businessTrips.stream().map((b) -> b.get("userId")).distinct().count();
|
|
|
+ stringObjectMap.put("tripPeopleCount",peopleCount);
|
|
|
+ }else {
|
|
|
+ stringObjectMap.put("tripPeopleCount",0);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -7714,31 +7748,40 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
|
|
|
|
//导出员工月度工时表
|
|
|
@Override
|
|
|
- public HttpRespMsg exportDeptPartInProjects(String startDate,String endDate, Integer departmentId, HttpServletRequest request){
|
|
|
+ public HttpRespMsg exportDeptPartInProjects(String month, Integer departmentId, HttpServletRequest request){
|
|
|
HttpRespMsg msg=new HttpRespMsg();
|
|
|
String token = request.getHeader("token");
|
|
|
User user = userMapper.selectById(token);
|
|
|
WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new QueryWrapper<WxCorpInfo>().eq("company_id", user.getCompanyId()));
|
|
|
- HttpRespMsg httpRespMsg = deptPartInProjects(null, null, startDate, endDate, departmentId, request);
|
|
|
+ HttpRespMsg httpRespMsg = deptPartInProjects(null, null, month, departmentId, request);
|
|
|
Map<String, Object> data = (Map<String, Object>) (Map<String, Object>) httpRespMsg.data;
|
|
|
List<Map<String, Object>> resultList = (List<Map<String, Object>>) data.get("resultList");
|
|
|
List<String> titleList=new ArrayList<>();
|
|
|
List<List<String>> dataList = new ArrayList<>();
|
|
|
// titleList.add("部门名称");
|
|
|
+// titleList.add("部门人数");
|
|
|
// titleList.add("参与的项目的数量");
|
|
|
+// titleList.add("参与的研究中心的数量");
|
|
|
// titleList.add("参与人次");
|
|
|
// titleList.add("出差的天数");
|
|
|
+// titleList.add("出差的人次");
|
|
|
titleList.add(MessageUtils.message("excel.deptName"));
|
|
|
+ titleList.add(MessageUtils.message("excel.deptHeadCount"));
|
|
|
titleList.add(MessageUtils.message("excel.joinProCount"));
|
|
|
+ titleList.add(MessageUtils.message("excel.joinCenterCount"));
|
|
|
titleList.add(MessageUtils.message("excel.joinPeopleCount"));
|
|
|
titleList.add(MessageUtils.message("excel.tripDays"));
|
|
|
+ titleList.add(MessageUtils.message("excel.tripPeopleCount"));
|
|
|
dataList.add(titleList);
|
|
|
for (Map<String, Object> map : resultList) {
|
|
|
List<String> item=new ArrayList<>();
|
|
|
item.add(map.get("deptName").toString());
|
|
|
+ item.add(map.get("deptHeadCount").toString());
|
|
|
item.add(map.get("projectCount").toString());
|
|
|
+ item.add(map.get("centerCount").toString());
|
|
|
item.add(map.get("peopleCount").toString());
|
|
|
item.add(map.get("tripCount").toString());
|
|
|
+ item.add(map.get("tripPeopleCount").toString());
|
|
|
dataList.add(item);
|
|
|
}
|
|
|
//生成excel文件导出
|