吉安感知网项目-后端
linwei
2026-01-22 4dd58784ace4cb295b62a0be91ed8297cf96288f
飞行记录导出
7 files modified
2 files added
223 ■■■■■ changed files
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/controller/FwDroneFlightRecordController.java 87 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/controller/FwDroneFlightRecordDetailController.java 47 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/excel/FwDroneFlightRecordExcel.java 6 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneFlightRecordMapper.java 5 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneFlightRecordMapper.xml 3 ●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/param/FwDroneFlightRecordExportParam.java 12 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/service/IFwDroneFlightRecordService.java 6 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/service/impl/FwDroneFlightRecordServiceImpl.java 16 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/vo/FwDroneFlightRecordExportVO.java 41 ●●●●● patch | view | raw | blame | history
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/controller/FwDroneFlightRecordController.java
@@ -41,6 +41,7 @@
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;
@@ -50,6 +51,8 @@
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;
@@ -79,17 +82,6 @@
        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")
@@ -99,27 +91,6 @@
        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));
    // }
    /**
     * 无人机飞行记录表 新增或修改
@@ -149,14 +120,50 @@
    @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;
        }
    }
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/controller/FwDroneFlightRecordDetailController.java
@@ -74,16 +74,7 @@
        FwDroneFlightRecordDetailEntity detail = fwDroneFlightRecordDetailService.getOne(Condition.getQueryWrapper(fwDroneFlightRecordDetail));
        return R.data(FwDroneFlightRecordDetailWrapper.build().entityVO(detail));
    }
    /**
     * 无人机飞行记录详情表 分页
     */
    // @GetMapping("/list")
    // @ApiOperationSupport(order = 2)
    // @ApiOperation(value = "分页", notes = "传入fwDroneFlightRecordDetail")
    // public R<IPage<FwDroneFlightRecordDetailVO>> list(@ApiIgnore @RequestParam Map<String, Object> fwDroneFlightRecordDetail, Query query) {
    //     IPage<FwDroneFlightRecordDetailEntity> pages = fwDroneFlightRecordDetailService.page(Condition.getPage(query), Condition.getQueryWrapper(fwDroneFlightRecordDetail, FwDroneFlightRecordDetailEntity.class));
    //     return R.data(FwDroneFlightRecordDetailWrapper.build().pageVO(pages));
    // }
    /**
     * 无人机飞行记录详情表 自定义分页
@@ -96,25 +87,6 @@
        return R.data(pages);
    }
    /**
     * 无人机飞行记录详情表 新增
     */
    // @PostMapping("/save")
    // @ApiOperationSupport(order = 4)
    // @ApiOperation(value = "新增", notes = "传入fwDroneFlightRecordDetail")
    // public R save(@Valid @RequestBody FwDroneFlightRecordDetailEntity fwDroneFlightRecordDetail) {
    //     return R.status(fwDroneFlightRecordDetailService.save(fwDroneFlightRecordDetail));
    // }
    /**
     * 无人机飞行记录详情表 修改
     */
    // @PostMapping("/update")
    // @ApiOperationSupport(order = 5)
    // @ApiOperation(value = "修改", notes = "传入fwDroneFlightRecordDetail")
    // public R update(@Valid @RequestBody FwDroneFlightRecordDetailEntity fwDroneFlightRecordDetail) {
    //     return R.status(fwDroneFlightRecordDetailService.updateById(fwDroneFlightRecordDetail));
    // }
    /**
     * 无人机飞行记录详情表 新增或修改
@@ -138,21 +110,6 @@
    }
    /**
     * 导出数据
     */
    @GetMapping("/export-fwDroneFlightRecordDetail")
    @ApiOperationSupport(order = 9)
    @Ignore
    @ApiOperation(value = "导出数据", notes = "传入fwDroneFlightRecordDetail")
    public void exportFwDroneFlightRecordDetail(@ApiIgnore @RequestParam Map<String, Object> fwDroneFlightRecordDetail, BladeUser bladeUser, HttpServletResponse response) {
        QueryWrapper<FwDroneFlightRecordDetailEntity> queryWrapper = Condition.getQueryWrapper(fwDroneFlightRecordDetail, FwDroneFlightRecordDetailEntity.class);
        //if (!AuthUtil.isAdministrator()) {
        //    queryWrapper.lambda().eq(FwDroneFlightRecordDetail::getTenantId, bladeUser.getTenantId());
        //}
        queryWrapper.lambda().eq(FwDroneFlightRecordDetailEntity::getIsDeleted, BladeConstant.DB_NOT_DELETED);
        List<FwDroneFlightRecordDetailExcel> list = fwDroneFlightRecordDetailService.exportFwDroneFlightRecordDetail(queryWrapper);
        ExcelUtil.export(response, "无人机飞行记录详情表数据" + DateUtil.time(), "无人机飞行记录详情表数据表", list, FwDroneFlightRecordDetailExcel.class);
    }
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/excel/FwDroneFlightRecordExcel.java
@@ -17,6 +17,7 @@
package org.sxkj.fw.record.excel;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
@@ -42,6 +43,9 @@
    private static final long serialVersionUID = 1L;
    @ExcelIgnore
    private Long id;
    @ColumnWidth(20)
    @ExcelProperty("无人机名称")
    private String droneName;
@@ -55,7 +59,7 @@
    private Date alarmTime;
    @ColumnWidth(20)
    @ExcelProperty("触发原因/类型")
    @ExcelProperty("触发原因")
    private String triggerType;
    @ColumnWidth(20)
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneFlightRecordMapper.java
@@ -18,6 +18,7 @@
import org.sxkj.fw.record.dto.FwDroneFlightRecordDTO;
import org.sxkj.fw.record.entity.FwDroneFlightRecordEntity;
import org.sxkj.fw.record.param.FwDroneFlightRecordExportParam;
import org.sxkj.fw.record.vo.FwDroneFlightRecordVO;
import org.sxkj.fw.record.excel.FwDroneFlightRecordExcel;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
@@ -47,9 +48,9 @@
    /**
     * 获取导出数据
     *
     * @param queryWrapper
     * @param fwDroneFlightRecord
     * @return
     */
    List<FwDroneFlightRecordExcel> exportFwDroneFlightRecord(@Param("ew") Wrapper<FwDroneFlightRecordEntity> queryWrapper);
    List<FwDroneFlightRecordExcel> exportFwDroneFlightRecord(FwDroneFlightRecordExportParam fwDroneFlightRecord);
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/mapper/FwDroneFlightRecordMapper.xml
@@ -61,7 +61,8 @@
    <select id="exportFwDroneFlightRecord" resultType="org.sxkj.fw.record.excel.FwDroneFlightRecordExcel">
        SELECT dfr.drone_name,
        SELECT dfr.id,
               dfr.drone_name,
               dfr.serial_no,
               dfr.alarm_time,
               dfr.area_name,
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/param/FwDroneFlightRecordExportParam.java
New file
@@ -0,0 +1,12 @@
package org.sxkj.fw.record.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class FwDroneFlightRecordExportParam {
    @ApiModelProperty("主键id,逗号分隔")
    private List<Long> ids;
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/service/IFwDroneFlightRecordService.java
@@ -19,11 +19,13 @@
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import org.sxkj.fw.record.dto.FwDroneFlightRecordDTO;
import org.sxkj.fw.record.entity.FwDroneFlightRecordEntity;
import org.sxkj.fw.record.param.FwDroneFlightRecordExportParam;
import org.sxkj.fw.record.vo.FwDroneFlightRecordVO;
import org.sxkj.fw.record.excel.FwDroneFlightRecordExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseService;
import java.util.List;
import java.util.Map;
/**
 * 无人机飞行记录表 服务类
@@ -45,9 +47,9 @@
    /**
     * 导出数据
     *
     * @param queryWrapper
     * @param fwDroneFlightRecord
     * @return
     */
    List<FwDroneFlightRecordExcel> exportFwDroneFlightRecord(Wrapper<FwDroneFlightRecordEntity> queryWrapper);
    Map<String,List<FwDroneFlightRecordExcel>> exportFwDroneFlightRecord(FwDroneFlightRecordExportParam fwDroneFlightRecord);
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/service/impl/FwDroneFlightRecordServiceImpl.java
@@ -18,6 +18,7 @@
import org.sxkj.fw.record.dto.FwDroneFlightRecordDTO;
import org.sxkj.fw.record.entity.FwDroneFlightRecordEntity;
import org.sxkj.fw.record.param.FwDroneFlightRecordExportParam;
import org.sxkj.fw.record.vo.FwDroneFlightRecordVO;
import org.sxkj.fw.record.excel.FwDroneFlightRecordExcel;
import org.sxkj.fw.record.mapper.FwDroneFlightRecordMapper;
@@ -26,7 +27,10 @@
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springblade.core.mp.base.BaseServiceImpl;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
 * 无人机飞行记录表 服务实现类
@@ -44,12 +48,12 @@
    @Override
    public List<FwDroneFlightRecordExcel> exportFwDroneFlightRecord(Wrapper<FwDroneFlightRecordEntity> queryWrapper) {
        List<FwDroneFlightRecordExcel> fwDroneFlightRecordList = baseMapper.exportFwDroneFlightRecord(queryWrapper);
        //fwDroneFlightRecordList.forEach(fwDroneFlightRecord -> {
        //    fwDroneFlightRecord.setTypeName(DictCache.getValue(DictEnum.YES_NO, FwDroneFlightRecord.getType()));
        //});
        return fwDroneFlightRecordList;
    public Map<String, List<FwDroneFlightRecordExcel>> exportFwDroneFlightRecord(FwDroneFlightRecordExportParam fwDroneFlightRecord) {
        List<FwDroneFlightRecordExcel> fwDroneFlightRecordList = baseMapper.exportFwDroneFlightRecord(fwDroneFlightRecord);
        // 按照 无人机名称 和 序列号 组合进行分组,键格式为 "id_serialNo"
        Map<String, List<FwDroneFlightRecordExcel>> groupedMap = fwDroneFlightRecordList.stream()
            .collect(Collectors.groupingBy(item -> item.getDroneName() + "_" + item.getSerialNo()));
        return groupedMap;
    }
}
drone-service/drone-fw/src/main/java/org/sxkj/fw/record/vo/FwDroneFlightRecordExportVO.java
New file
@@ -0,0 +1,41 @@
/*
 *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
 *
 *  Redistribution and use in source and binary forms, with or without
 *  modification, are permitted provided that the following conditions are met:
 *
 *  Redistributions of source code must retain the above copyright notice,
 *  this list of conditions and the following disclaimer.
 *  Redistributions in binary form must reproduce the above copyright
 *  notice, this list of conditions and the following disclaimer in the
 *  documentation and/or other materials provided with the distribution.
 *  Neither the name of the dreamlu.net developer nor the names of its
 *  contributors may be used to endorse or promote products derived from
 *  this software without specific prior written permission.
 *  Author: Chill 庄骞 (smallchill@163.com)
 */
package org.sxkj.fw.record.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.sxkj.fw.record.entity.FwDroneFlightRecordEntity;
import org.sxkj.fw.record.excel.FwDroneFlightRecordExcel;
import java.io.Serializable;
import java.util.List;
/**
 * 无人机飞行记录表 视图实体类
 *
 * @author lw
 * @since 2026-01-08
 */
@Data
public class FwDroneFlightRecordExportVO  implements Serializable {
    private static final long serialVersionUID = 1L;
    private String serialNo;
    private List<FwDroneFlightRecordExcel> fwDroneFlightRecordList;
}