zrj
2024-08-20 8b7b86f12fab51fe21b5575f4ffd524fbeaf412b
src/main/java/com/dji/sample/patches/controller/PatchesController.java
@@ -6,6 +6,7 @@
import com.dji.sample.common.util.MinioUrlUtils;
import com.dji.sample.media.model.MediaFileEntity;
import com.dji.sample.media.service.impl.FileServiceImpl;
import com.dji.sample.patches.constant.FileSufConstant;
import com.dji.sample.patches.model.Param.PatchesParam;
import com.dji.sample.patches.model.entity.LotInfo;
import com.dji.sample.patches.service.GetPatchesService;
@@ -178,7 +179,7 @@
//            timerUtil.mytask5();
//            timerUtil.mytask6();
//            timerUtil.mytask7();
            timerUtil.GtdbOperation();
        } catch (Exception e) {
            throw new RuntimeException("db存储发送出现异常" + e);
        }
@@ -255,6 +256,10 @@
                                 @RequestParam double airportLat,
                                 @RequestParam double airportLon,
                                 HttpServletRequest request) throws Exception {
        // 检查格式是否正确
        if(!checkFileType(file.getOriginalFilename())){
            throw new RuntimeException("文件格式异常");
        }
        CustomClaim customClaim = (CustomClaim) request.getAttribute(TOKEN_CLAIM);
        String creator = customClaim.getUsername();
        MultipartFile multipartFile = shpToDataSourceService.insertGeo(file, workspaceId, waylineName, airportLat, airportLon, creator);
@@ -272,10 +277,27 @@
        return ResponseResult.success(infoMap);
    }
    /**
     * 检查文件格式是否正确
     * @param originalFilename
     * @return
     */
    private boolean checkFileType(String originalFilename) {
        if (originalFilename.endsWith(FileSufConstant.FILE_SUFFIX_ZIP) ||
                originalFilename.endsWith(FileSufConstant.FILE_SUFFIX_KML) ||
                originalFilename.endsWith(FileSufConstant.FILE_SUFFIX_KMZ)
        ){
            return true;
        }
        // 返回
        return false;
    }
    @GetMapping("/getExcel")
    public ResponseEntity<byte[]> exportExcel(@RequestParam String workspaceId) {
        List<LotInfo> lotInfos = getPatchesService.listLotinfo(workspaceId);
    public ResponseEntity<byte[]> exportExcel(@RequestParam String ids) {
//        List<LotInfo> lotInfos = getPatchesService.listLotinfo(workspaceId);
        try {
            List<LotInfo> lotInfos = getPatchesService.getLotInfosByIDs(ids);
            ByteArrayInputStream excelStream = ExcelUtil.exportLotInfoToExcel(lotInfos);
            byte[] excelData = excelStream.readAllBytes();
            excelStream.close();
@@ -288,7 +310,7 @@
            return new ResponseEntity<>(excelData, headers, HttpStatus.OK);
        } catch (IOException e) {
            e.printStackTrace();
            return new ResponseEntity<>(("Failed to generate Excel file.").getBytes(), HttpStatus.INTERNAL_SERVER_ERROR);
            return new ResponseEntity<>(("生成excel失败.").getBytes(), HttpStatus.INTERNAL_SERVER_ERROR);
        }
    }
}