| | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | auxiliaryOutputWorkingHoursDto.setDateTime(null); |
| | | auxiliaryOutputWorkingHoursDto.setWeek(null); |
| | | Map<String, Object> map = new HashMap<>(); |
| | | List<Integer> ids = null; |
| | | List<Integer> ids = new ArrayList<>(); |
| | | map.put("head", PrintChina.printChina(AuxiliaryOutputWorkingHoursDto.class)); |
| | | //判断组长,组员,管理员权限 |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectAuxiliaryOutputWorkingHours"); |
| | |
| | | //查询组长下的组员 |
| | | List<User> users = userMapper.selectList(Wrappers.<User>lambdaQuery().like(User::getDepartLimsId, user.getDepartLimsId())); |
| | | if (ObjectUtils.isNotEmpty(users)) { |
| | | ids = users.stream().map(User::getId).distinct().collect(Collectors.toList()); |
| | | ids.addAll(users.stream().map(User::getId).distinct().collect(Collectors.toList())); |
| | | } |
| | | } |
| | | if (ObjectUtils.isNotEmpty(dates)) { |
| | | if (ObjectUtils.isNotEmpty(dates) && ObjectUtils.isNotEmpty(week)){ |
| | | String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | if (ObjectUtils.isNotEmpty(week)){ |
| | | String[] weeks = week.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | map.put("body", auxiliaryOutputWorkingHoursMapper.selectAuxiliaryOutputWorkingHours(page, |
| | | QueryWrappers.queryWrappers(auxiliaryOutputWorkingHoursDto) |
| | | .ge("date_time", split[0]).le("date_time", split[1] + " 23:59:59") |
| | | .ge("week", weeks[0]).le("week", weeks[1] ), ids)); |
| | | } |
| | | map.put("body", auxiliaryOutputWorkingHoursMapper.selectAuxiliaryOutputWorkingHours(page, QueryWrappers.queryWrappers(auxiliaryOutputWorkingHoursDto).ge("date_time", split[0]).le("date_time", split[1] + " 23:59:59"), ids)); |
| | | } else { |
| | | String[] weeks = week.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | map.put("body", auxiliaryOutputWorkingHoursMapper.selectAuxiliaryOutputWorkingHours(page, |
| | | QueryWrappers.queryWrappers(auxiliaryOutputWorkingHoursDto) |
| | | .ge("date_time", split[0]).le("date_time", split[1] + " 23:59:59") |
| | | .ge("week", weeks[0]).le("week", weeks[1]), ids)); |
| | | }else if(ObjectUtils.isNotEmpty(dates) && ObjectUtils.isEmpty(week)){ |
| | | String[] split = dates.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | map.put("body", auxiliaryOutputWorkingHoursMapper.selectAuxiliaryOutputWorkingHours(page, |
| | | QueryWrappers.queryWrappers(auxiliaryOutputWorkingHoursDto) |
| | | .ge("date_time", split[0]).le("date_time", split[1] + " 23:59:59"), ids)); |
| | | }else if (ObjectUtils.isEmpty(dates) && ObjectUtils.isNotEmpty(week)){ |
| | | String[] weeks = week.replaceAll("\\[", "").replaceAll("]", "").replaceAll("\"", "").split(","); |
| | | map.put("body", auxiliaryOutputWorkingHoursMapper.selectAuxiliaryOutputWorkingHours(page, |
| | | QueryWrappers.queryWrappers(auxiliaryOutputWorkingHoursDto) |
| | | .ge("week", weeks[0]).le("week", weeks[1]), ids)); |
| | | }else { |
| | | map.put("body", auxiliaryOutputWorkingHoursMapper.selectAuxiliaryOutputWorkingHours(page, QueryWrappers.queryWrappers(auxiliaryOutputWorkingHoursDto), ids)); |
| | | } |
| | | return map; |
| | |
| | | //导出 |
| | | @Override |
| | | public void exportWorkingHours(HttpServletResponse response) throws IOException { |
| | | List<AuxiliaryOutputWorkingHoursDto> auxiliaryOutputWorkingHoursDtos = null; |
| | | List<AuxiliaryWorkingHoursDayDto> auxiliaryWorkingHoursDayDtos = null; |
| | | List<Integer> ids = null; |
| | | List<AuxiliaryOutputWorkingHoursDto> auxiliaryOutputWorkingHoursDtos = new ArrayList<>(); |
| | | List<AuxiliaryWorkingHoursDayDto> auxiliaryWorkingHoursDayDtos = new ArrayList<>(); |
| | | List<Integer> ids = new ArrayList<>(); |
| | | //判断是组长还是组员还是管理员 |
| | | Map<String, Integer> map1 = getLook.selectPowerByMethodAndUserId("selectAuxiliaryOutputWorkingHours"); |
| | | User user = userMapper.selectById(map1.get("userId")); |
| | |
| | | |
| | | //查询辅助工时 |
| | | auxiliaryWorkingHoursDayDtos = auxiliaryWorkingHoursDayMapper.selectDataByUser(ids); |
| | | // if (auxiliaryWorkingHoursDayDtos == null || auxiliaryWorkingHoursDayDtos.size() == 0) { |
| | | // throw new RuntimeException("暂无数据"); |
| | | // } |
| | | //查询统计工时 |
| | | auxiliaryOutputWorkingHoursDtos = auxiliaryOutputWorkingHoursMapper.selectDataByUser(ids); |
| | | // if (auxiliaryOutputWorkingHoursDtos == null || auxiliaryOutputWorkingHoursDtos.size() == 0) { |
| | | // throw new RuntimeException("暂无数据"); |
| | | // } |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("UTF-8"); |
| | | // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系 |
| | | String fileName = URLEncoder.encode("工时管理导出", "UTF-8"); |
| | | String fileName = URLEncoder.encode("日工时管理导出", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | try { |
| | | // 新建ExcelWriter |