| | |
| | | import com.ycl.entity.equipment.EquipmentBayonet; |
| | | import com.ycl.service.dict.IDataDictionaryService; |
| | | import com.ycl.service.equipment.IEquipmentBayonetService; |
| | | import com.ycl.utils.EasyExcelUtils; |
| | | import com.ycl.vo.equipment.EquipmentBayonetVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | @GetMapping("/export") |
| | | @ApiOperation("导出") |
| | | @SneakyThrows |
| | | @LogSave(operationType = "卡口管理", contain = "删除卡口") |
| | | @LogSave(operationType = "卡口管理", contain = "导出卡口") |
| | | public void export(HttpServletResponse response, |
| | | @RequestParam(required = false) Integer size, |
| | | @RequestParam(required = false) Integer current, |
| | |
| | | Page<EquipmentBayonet> equipmentBayonetPage = new Page<>(); |
| | | equipmentBayonetPage.setCurrent(current); |
| | | equipmentBayonetPage.setSize(size); |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")) + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), EquipmentBayonetVO.class) |
| | | .sheet("数据") |
| | | .doWrite(iEquipmentBayonetService |
| | | .page(equipmentBayonetPage, new LambdaQueryWrapper<EquipmentBayonet>() |
| | | .like(StringUtils.isNotBlank(bayonetName), EquipmentBayonet::getBayonetName, bayonetName)) |
| | | .getRecords() |
| | | .stream() |
| | | .map(item -> { |
| | | EquipmentBayonetVO equipmentBayonetVO = new EquipmentBayonetVO(); |
| | | BeanUtils.copyProperties(item, equipmentBayonetVO); |
| | | equipmentBayonetVO.setFrontEndType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getFrontEndType())).getName()); |
| | | equipmentBayonetVO.setInOutCityType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getInOutCityType())).getName()); |
| | | return equipmentBayonetVO; |
| | | }).collect(Collectors.toList())); |
| | | EasyExcelUtils.export(response,"数据",EquipmentBayonetVO.class,iEquipmentBayonetService |
| | | .page(equipmentBayonetPage, new LambdaQueryWrapper<EquipmentBayonet>() |
| | | .like(StringUtils.isNotBlank(bayonetName), EquipmentBayonet::getBayonetName, bayonetName)) |
| | | .getRecords() |
| | | .stream() |
| | | .map(item -> { |
| | | EquipmentBayonetVO equipmentBayonetVO = new EquipmentBayonetVO(); |
| | | BeanUtils.copyProperties(item, equipmentBayonetVO); |
| | | equipmentBayonetVO.setFrontEndType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getFrontEndType())).getName()); |
| | | equipmentBayonetVO.setInOutCityType(iDataDictionaryService.getOne(new LambdaQueryWrapper<DataDictionary>().eq(DataDictionary::getId, item.getInOutCityType())).getName()); |
| | | return equipmentBayonetVO; |
| | | }).collect(Collectors.toList())); |
| | | } |
| | | |
| | | } |
| | | } |