| | |
| | | import org.sxkj.fw.record.entity.FwDroneFlightRecordEntity; |
| | | import org.sxkj.fw.record.excel.FwDroneAlarmRecordExcel; |
| | | import org.sxkj.fw.record.excel.FwDroneFlightRecordExcel; |
| | | import org.sxkj.fw.record.param.FwDroneFlightRecordExportParam; |
| | | import org.sxkj.fw.record.service.IFwDroneFlightRecordService; |
| | | import org.sxkj.fw.record.vo.FwDroneFlightRecordVO; |
| | | import org.sxkj.fw.record.wrapper.FwDroneFlightRecordWrapper; |
| | |
| | | import javax.validation.Valid; |
| | | import java.io.FileOutputStream; |
| | | import java.io.IOException; |
| | | import java.net.URLEncoder; |
| | | import java.nio.charset.StandardCharsets; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | |
| | | return R.data(FwDroneFlightRecordWrapper.build().entityVO(detail)); |
| | | } |
| | | /** |
| | | * 无人机飞行记录表 分页 |
| | | */ |
| | | // @GetMapping("/list") |
| | | // @ApiOperationSupport(order = 2) |
| | | // @ApiOperation(value = "分页", notes = "传入fwDroneFlightRecord") |
| | | // public R<IPage<FwDroneFlightRecordVO>> list(@ApiIgnore @RequestParam Map<String, Object> fwDroneFlightRecord, Query query) { |
| | | // IPage<FwDroneFlightRecordEntity> pages = fwDroneFlightRecordService.page(Condition.getPage(query), Condition.getQueryWrapper(fwDroneFlightRecord, FwDroneFlightRecordEntity.class)); |
| | | // return R.data(FwDroneFlightRecordWrapper.build().pageVO(pages)); |
| | | // } |
| | | |
| | | /** |
| | | * 无人机飞行记录表 自定义分页 |
| | | */ |
| | | @GetMapping("/page") |
| | |
| | | IPage<FwDroneFlightRecordVO> pages = fwDroneFlightRecordService.selectFwDroneFlightRecordPage(Condition.getPage(query), fwDroneFlightRecord); |
| | | return R.data(pages); |
| | | } |
| | | |
| | | /** |
| | | * 无人机飞行记录表 新增 |
| | | */ |
| | | // @PostMapping("/save") |
| | | // @ApiOperationSupport(order = 4) |
| | | // @ApiOperation(value = "新增", notes = "传入fwDroneFlightRecord") |
| | | // public R save(@Valid @RequestBody FwDroneFlightRecordDTO fwDroneFlightRecord) { |
| | | // FwDroneFlightRecordEntity entity = Objects.requireNonNull(BeanUtil.copy(fwDroneFlightRecord, FwDroneFlightRecordEntity.class)); |
| | | // return R.status(fwDroneFlightRecordService.save(entity)); |
| | | // } |
| | | |
| | | /** |
| | | * 无人机飞行记录表 修改 |
| | | */ |
| | | // @PostMapping("/update") |
| | | // @ApiOperationSupport(order = 5) |
| | | // @ApiOperation(value = "修改", notes = "传入fwDroneFlightRecord") |
| | | // public R update(@Valid @RequestBody FwDroneFlightRecordEntity fwDroneFlightRecord) { |
| | | // return R.status(fwDroneFlightRecordService.updateById(fwDroneFlightRecord)); |
| | | // } |
| | | |
| | | /** |
| | | * 无人机飞行记录表 新增或修改 |
| | |
| | | @GetMapping("/export-fwDroneFlightRecord") |
| | | @ApiOperationSupport(order = 9) |
| | | @ApiOperation(value = "导出数据", notes = "传入fwDroneFlightRecord") |
| | | public void exportFwDroneFlightRecord(@ApiIgnore @RequestParam Map<String, Object> fwDroneFlightRecord, BladeUser bladeUser, HttpServletResponse response) { |
| | | QueryWrapper<FwDroneFlightRecordEntity> queryWrapper = Condition.getQueryWrapper(fwDroneFlightRecord, FwDroneFlightRecordEntity.class); |
| | | //if (!AuthUtil.isAdministrator()) { |
| | | // queryWrapper.lambda().eq(FwDroneFlightRecord::getTenantId, bladeUser.getTenantId()); |
| | | //} |
| | | queryWrapper.lambda().eq(FwDroneFlightRecordEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED); |
| | | List<FwDroneFlightRecordExcel> list = fwDroneFlightRecordService.exportFwDroneFlightRecord(queryWrapper); |
| | | ExcelUtil.export(response, "无人机飞行记录表数据" + DateUtil.time(), "无人机飞行记录表数据表", list, FwDroneFlightRecordExcel.class); |
| | | public void exportFwDroneFlightRecord(FwDroneFlightRecordExportParam fwDroneFlightRecord, HttpServletResponse response) throws IOException { |
| | | Map<String,List<FwDroneFlightRecordExcel>> list = fwDroneFlightRecordService.exportFwDroneFlightRecord(fwDroneFlightRecord); |
| | | exportMultipleSheets(response, "无人机飞行记录表数据" + DateUtil.time(), list, FwDroneFlightRecordExcel.class); |
| | | } |
| | | |
| | | // ... existing code ... |
| | | |
| | | /** |
| | | * 导出多个sheet到Excel文件 |
| | | * @param response HTTP响应对象 |
| | | * @param fileName 文件名 |
| | | * @param sheetDataMap 包含sheet名称和对应数据列表的映射 |
| | | * @param clazz 数据类型对应的类 |
| | | */ |
| | | public static <T> void exportMultipleSheets(HttpServletResponse response, String fileName, |
| | | java.util.Map<String, List<T>> sheetDataMap, Class<T> clazz) throws IOException { |
| | | try { |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding(StandardCharsets.UTF_8.name()); |
| | | fileName = URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | |
| | | ExcelWriter excelWriter = null; |
| | | try { |
| | | excelWriter = EasyExcel.write(response.getOutputStream(), clazz).build(); |
| | | int sheetIndex = 0; |
| | | for (java.util.Map.Entry<String, List<T>> entry : sheetDataMap.entrySet()) { |
| | | String sheetName = entry.getKey(); |
| | | List<T> dataList = entry.getValue(); |
| | | if (dataList != null && !dataList.isEmpty()) { |
| | | com.alibaba.excel.write.metadata.WriteSheet writeSheet = EasyExcel.writerSheet(sheetIndex++, sheetName).build(); |
| | | excelWriter.write(dataList, writeSheet); |
| | | } |
| | | } |
| | | } finally { |
| | | if (excelWriter != null) { |
| | | excelWriter.finish(); |
| | | } |
| | | } |
| | | } catch (Throwable $ex) { |
| | | throw $ex; |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | } |