吉安感知网项目-后端
linwei
2026-01-19 077cedddebbfae2d740e259e9e16b0eb363f3a02
drone-ops/drone-resource/src/main/java/org/sxkj/resource/controller/AttachController.java
@@ -80,32 +80,6 @@
      return R.data(detail);
   }
   @GetMapping("/test")
   public R test(@RequestParam(required = true) Date startTime, @RequestParam(required = true) Date endTime) {
      CacheUtil.clear(RESOURCE_CACHE);
      attachClient.processingYesterdayVideo(startTime, endTime);
      return R.success("成功");
   }
   @GetMapping("/getlotInfoList")
   public ResponseResult getlotInfoList(@ApiParam Long lotInfoId) {
      return ResponseResult.success(attachService.getlotInfoList(lotInfoId));
   }
   /**
    * 分页 附件表
    */
   @GetMapping("/list")
   @ApiOperationSupport(order = 2)
   @ApiOperation(value = "附件分页", notes = "传入attach")
   public R<IPage<Attach>> list(Attach attach, Query query) {
      List<String> wayLineJobIds = attach.getWayLineJobIds();
      QueryWrapper<Attach> queryWrapper1 = Condition.getQueryWrapper(attach);
      QueryWrapper<Attach> queryWrapper = queryWrapper1.in(!CollectionUtils.isEmpty(wayLineJobIds), "wayline_job_id", wayLineJobIds);
      IPage<Attach> pages = attachService.page(Condition.getPage(query), queryWrapper);
      return R.data(pages);
   }
   /**
    * 自定义分页 附件表
    */
@@ -118,83 +92,6 @@
      IPage<AttachVO> pages = attachService.selectAttachPage(Condition.getPage(query), attach);
      AttachVO.settingNickName(pages.getRecords());
      return R.data(pages);
   }
   /**
    * 自定义分页 附件表
    */
   @PostMapping("/aiImagesPage")
   @ApiOperationSupport(order = 3)
   @ApiOperation(value = "自定义分页附件表分页", notes = "ai分页数据")
   public R<IPage<AttachVO>> aiPage(@RequestBody AttachVO attach, Query query) {
      String areaCode = HeaderUtils.getAreaCode();
      attach.setAreaCode(areaCode);
      List<Integer> resultTypes = attach.getResultTypes();
      String wordOrderType = attach.getWordOrderType();
      settingResultType(attach, wordOrderType, resultTypes);
      if (Objects.nonNull(attach.getAiStatus()) && Objects.nonNull(attach.getResultTypes())
         && attach.getResultTypes().contains(Attach.RESULT_TYPE_AI)) {
         attach.setResultTypes(Arrays.asList(Attach.RESULT_TYPE_AI));
      }
      List<String> aiEventMd5s = attachService.findAiEventMd5s(attach.getEventRecordIds());
      attach.setMd5s(aiEventMd5s);
      if (!CollectionUtils.isEmpty(attach.getEventRecordIds())) {
         attach.setResultTypes(Arrays.asList(Attach.RESULT_TYPE_AI, Attach.RESULT_TYPE_IMG));
      }
      IPage page = Condition.getPage(query);
      List<AttachVO> aiAttachImages = attachService.findAiAttachImages(page, attach);
      AttachVO.settingNickName(aiAttachImages);
      page.setRecords(aiAttachImages);
      return R.data(page);
   }
   /**
    * 后台数据中心列表接口
    */
   @PostMapping("/attachmentsPage")
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "后台数据中心列表接口")
   public R<IPage<AttachVO>> attachmentsPage(@RequestBody AttachVO attach, Query query) {
      IPage page = Condition.getPage(query);
      IPage attachPage = attachService.findAttachImages(page, attach);
      return R.data(attachPage);
   }
   private static void settingResultType(AttachVO attach, String wordOrderType, List<Integer> resultTypes) {
      if (!StringUtils.isEmpty(wordOrderType) && !CollectionUtils.isEmpty(resultTypes)) {
         if ("-1".equals(wordOrderType)) {
            attach.setWordOrderType(null);
            if (resultTypes.contains(Attach.RESULT_TYPE_IMG)) {
               resultTypes = Arrays.asList(Attach.RESULT_TYPE_IMG);
            }
         } else {
            if (resultTypes.contains(Attach.RESULT_TYPE_AI)) {
               resultTypes = Arrays.asList(Attach.RESULT_TYPE_AI);
            }
         }
         attach.setResultTypes(resultTypes);
      }
   }
   /**
    * 新增 附件表
    */
   @PostMapping("/save")
   @ApiOperationSupport(order = 4)
   @ApiOperation(value = "新增", notes = "传入attach")
   public R save(@Valid @RequestBody Attach attach) {
      return R.status(attachService.save(attach));
   }
   /**
    * 修改 附件表
    */
   @PostMapping("/update")
   @ApiOperationSupport(order = 5)
   @ApiOperation(value = "修改", notes = "传入attach")
   public R update(@Valid @RequestBody Attach attach) {
      return R.status(attachService.updateById(attach));
   }
   /**
@@ -220,70 +117,161 @@
         .in(Attach::getId, Func.toLongList(ids))));
   }
   // @GetMapping("/test")
   // public R test(@RequestParam(required = true) Date startTime, @RequestParam(required = true) Date endTime) {
   //    CacheUtil.clear(RESOURCE_CACHE);
   //    attachClient.processingYesterdayVideo(startTime, endTime);
   //    return R.success("成功");
   // }
   // @GetMapping("/getlotInfoList")
   // public ResponseResult getlotInfoList(@ApiParam Long lotInfoId) {
   //    return ResponseResult.success(attachService.getlotInfoList(lotInfoId));
   // }
   /**
    * 分页 附件表
    */
   // @GetMapping("/list")
   // @ApiOperationSupport(order = 2)
   // @ApiOperation(value = "附件分页", notes = "传入attach")
   // public R<IPage<Attach>> list(Attach attach, Query query) {
   //    List<String> wayLineJobIds = attach.getWayLineJobIds();
   //    QueryWrapper<Attach> queryWrapper1 = Condition.getQueryWrapper(attach);
   //    QueryWrapper<Attach> queryWrapper = queryWrapper1.in(!CollectionUtils.isEmpty(wayLineJobIds), "wayline_job_id", wayLineJobIds);
   //    queryWrapper.eq("is_deleted", 0);
   //    IPage<Attach> pages = attachService.page(Condition.getPage(query), queryWrapper);
   //    return R.data(pages);
   // }
   /**
    * 自定义分页 附件表
    */
   // @PostMapping("/aiImagesPage")
   // @ApiOperationSupport(order = 3)
   // @ApiOperation(value = "自定义分页附件表分页", notes = "ai分页数据")
   // public R<IPage<AttachVO>> aiPage(@RequestBody AttachVO attach, Query query) {
   //    String areaCode = HeaderUtils.getAreaCode();
   //    attach.setAreaCode(areaCode);
   //    List<Integer> resultTypes = attach.getResultTypes();
   //    String wordOrderType = attach.getWordOrderType();
   //    settingResultType(attach, wordOrderType, resultTypes);
   //    if (Objects.nonNull(attach.getAiStatus()) && Objects.nonNull(attach.getResultTypes())
   //       && attach.getResultTypes().contains(Attach.RESULT_TYPE_AI)) {
   //       attach.setResultTypes(Arrays.asList(Attach.RESULT_TYPE_AI));
   //    }
   //    List<String> aiEventMd5s = attachService.findAiEventMd5s(attach.getEventRecordIds());
   //    attach.setMd5s(aiEventMd5s);
   //    if (!CollectionUtils.isEmpty(attach.getEventRecordIds())) {
   //       attach.setResultTypes(Arrays.asList(Attach.RESULT_TYPE_AI, Attach.RESULT_TYPE_IMG));
   //    }
   //    IPage page = Condition.getPage(query);
   //    List<AttachVO> aiAttachImages = attachService.findAiAttachImages(page, attach);
   //    AttachVO.settingNickName(aiAttachImages);
   //    page.setRecords(aiAttachImages);
   //    return R.data(page);
   // }
   /**
    * 后台数据中心列表接口
    */
   // @PostMapping("/attachmentsPage")
   // @ApiOperationSupport(order = 4)
   // @ApiOperation(value = "后台数据中心列表接口")
   // public R<IPage<AttachVO>> attachmentsPage(@RequestBody AttachVO attach, Query query) {
   //    IPage page = Condition.getPage(query);
   //    IPage attachPage = attachService.findAttachImages(page, attach);
   //    return R.data(attachPage);
   // }
   /**
    * 新增 附件表
    */
   // @PostMapping("/save")
   // @ApiOperationSupport(order = 4)
   // @ApiOperation(value = "新增", notes = "传入attach")
   // public R save(@Valid @RequestBody Attach attach) {
   //    return R.status(attachService.save(attach));
   // }
   /**
    * 修改 附件表
    */
   // @PostMapping("/update")
   // @ApiOperationSupport(order = 5)
   // @ApiOperation(value = "修改", notes = "传入attach")
   // public R update(@Valid @RequestBody Attach attach) {
   //    return R.status(attachService.updateById(attach));
   // }
   /**
    * 删除 附件表及对应的附件信息
    *
    * @param ids
    * @return
    */
   @PostMapping("/removeAttachAndData")
   @ApiOperationSupport(order = 9)
   @ApiOperation(value = "删除", notes = "传入ids")
   @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
   public R removeAttachAndData(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
      return R.status(attachService.removeBatchAndDataByIds(Func.toLongList(ids)));
   }
   // @PostMapping("/removeAttachAndData")
   // @ApiOperationSupport(order = 9)
   // @ApiOperation(value = "删除", notes = "传入ids")
   // @PreAuth(RoleConstant.HAS_ROLE_ADMINISTRATOR)
   // public R removeAttachAndData(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
   //    return R.status(attachService.removeBatchAndDataByIds(Func.toLongList(ids)));
   // }
   @GetMapping("/deptSize")
   @ApiOperationSupport(order = 8)
   @ApiOperation(value = "获取部门文件大小")
   public R<List<DeptAndSizeVo>> getDeptSize(@RequestParam String startTime, @RequestParam String endTime) {
      return R.data(attachService.getDeptAllSize(startTime, endTime));
   }
   // @GetMapping("/deptSize")
   // @ApiOperationSupport(order = 8)
   // @ApiOperation(value = "获取部门文件大小")
   // public R<List<DeptAndSizeVo>> getDeptSize(@RequestParam String startTime, @RequestParam String endTime) {
   //    return R.data(attachService.getDeptAllSize(startTime, endTime));
   // }
   /**
    * 历史正射图片处理
    *
    * @return
    */
   @GetMapping("/hisOrtPicHandler")
   @ApiOperationSupport(order = 9)
   @ApiOperation(value = "历史正射图片处理")
   public R hisOrtPicHandler() {
      return R.data(attachService.hisOrtPicHandler());
   }
   // @GetMapping("/hisOrtPicHandler")
   // @ApiOperationSupport(order = 9)
   // @ApiOperation(value = "历史正射图片处理")
   // public R hisOrtPicHandler() {
   //    return R.data(attachService.hisOrtPicHandler());
   // }
   /**
    * 自动更新附件表md5值
    *
    * @return
    */
   @GetMapping("saveMd5")
   public R saveMd5() {
      attachService.saveMd5();
      return R.success("");
   }
   // @GetMapping("saveMd5")
   // public R saveMd5() {
   //    attachService.saveMd5();
   //    return R.success("");
   // }
   @ApiOperation(value = "地图位置上图片数据", notes = "")
   @PostMapping("/mapAttachs")
   public ResponseResult<TreeVo> mapEvents(@RequestBody AttachQueryParam dto) {
      if (Objects.nonNull(dto.getDateEnum())) {
         TimeRange timeRange = TimeRangeUtils.getTimeRange(dto.getDateEnum());
         dto.setStartDate(timeRange.getStartTime());
         dto.setEndDate(timeRange.getEndTime());
      }
      if (Objects.nonNull(dto.getStartDate())) {
         dto.setStartTime(TimeRangeUtils.getEpochMilli(dto.getStartDate()));
      }
      if (Objects.nonNull(dto.getEndDate())) {
         dto.setEndTime(TimeRangeUtils.getEpochMilli(dto.getEndDate()));
      }
      String areaCode = HeaderUtils.getHeader(CommonConstant.AREA_CODE).orElse(null);
      dto.setAreaCode(!StringUtils.isEmpty(dto.getAreaCode()) ? dto.getAreaCode() : areaCode);
      TreeVo treeVo = attachService.mapAttachEvents(dto);
      return ResponseResult.success(treeVo);
   }
   // @ApiOperation(value = "地图位置上图片数据", notes = "")
   // @PostMapping("/mapAttachs")
   // public ResponseResult<TreeVo> mapEvents(@RequestBody AttachQueryParam dto) {
   //    if (Objects.nonNull(dto.getDateEnum())) {
   //       TimeRange timeRange = TimeRangeUtils.getTimeRange(dto.getDateEnum());
   //       dto.setStartDate(timeRange.getStartTime());
   //       dto.setEndDate(timeRange.getEndTime());
   //    }
   //    if (Objects.nonNull(dto.getStartDate())) {
   //       dto.setStartTime(TimeRangeUtils.getEpochMilli(dto.getStartDate()));
   //    }
   //    if (Objects.nonNull(dto.getEndDate())) {
   //       dto.setEndTime(TimeRangeUtils.getEpochMilli(dto.getEndDate()));
   //    }
   //    String areaCode = HeaderUtils.getHeader(CommonConstant.AREA_CODE).orElse(null);
   //    dto.setAreaCode(!StringUtils.isEmpty(dto.getAreaCode()) ? dto.getAreaCode() : areaCode);
   //    TreeVo treeVo = attachService.mapAttachEvents(dto);
   //    return ResponseResult.success(treeVo);
   // }
   /**
    * 图片分析对比 前后图片对比
@@ -291,33 +279,33 @@
    * @param id 图片id
    * @return
    */
   @GetMapping("contrastiveAnalysis")
   public ResponseResult contrastiveAnalysis(@RequestParam() Long id) {
      List<AnalysisAttachVo> list = attachService.contrastiveAnalysis(id);
      return ResponseResult.success(list);
   }
   // @GetMapping("contrastiveAnalysis")
   // public ResponseResult contrastiveAnalysis(@RequestParam() Long id) {
   //    List<AnalysisAttachVo> list = attachService.contrastiveAnalysis(id);
   //    return ResponseResult.success(list);
   // }
   @ApiOperation(value = "附件详情", notes = "")
   @GetMapping("/getAttachInfo")
   public ResponseResult<AttachInfoVO> getAttachInfo(@ApiParam(value = "附件iD") @RequestParam("id") Long id) throws IOException {
      return ResponseResult.success(attachService.getAttachInfo(id));
   }
   // @ApiOperation(value = "附件详情", notes = "")
   // @GetMapping("/getAttachInfo")
   // public ResponseResult<AttachInfoVO> getAttachInfo(@ApiParam(value = "附件iD") @RequestParam("id") Long id) throws IOException {
   //    return ResponseResult.success(attachService.getAttachInfo(id));
   // }
   @ApiOperation(value = "通过任务id查询附件详情集合", notes = "")
   @GetMapping("/getAttachInfoByJobId")
   public ResponseResult<List<AttachInfoVO>> getAttachInfoByJobId(@ApiParam(value = "任务id") @RequestParam("jobId") String jobId) throws IOException {
      return ResponseResult.success(attachService.getAttachInfoByJobId(jobId));
   }
   // @ApiOperation(value = "通过任务id查询附件详情集合", notes = "")
   // @GetMapping("/getAttachInfoByJobId")
   // public ResponseResult<List<AttachInfoVO>> getAttachInfoByJobId(@ApiParam(value = "任务id") @RequestParam("jobId") String jobId) throws IOException {
   //    return ResponseResult.success(attachService.getAttachInfoByJobId(jobId));
   // }
   @ApiLog("修改文件名称")
   @PostMapping("/updateFileName")
   public ResponseResult updateFileName(@RequestParam Long id, @RequestParam String nickName) {
      if (attachService.updateFileName(id, nickName) > 0) {
         return ResponseResult.success();
      }
      return ResponseResult.error("修改失败");
   }
   // @ApiLog("修改文件名称")
   // @PostMapping("/updateFileName")
   // public ResponseResult updateFileName(@RequestParam Long id, @RequestParam String nickName) {
   //    if (attachService.updateFileName(id, nickName) > 0) {
   //       return ResponseResult.success();
   //    }
   //    return ResponseResult.error("修改失败");
   // }
   /**
@@ -325,39 +313,39 @@
    *
    * @return
    */
   @GetMapping("deletedNotExistsUrl")
   public ResponseResult deletedNotExistsUrl() {
      attachService.deletedNotExistsUrl();
      return ResponseResult.success();
   }
   // @GetMapping("deletedNotExistsUrl")
   // public ResponseResult deletedNotExistsUrl() {
   //    attachService.deletedNotExistsUrl();
   //    return ResponseResult.success();
   // }
   @ApiLog("删除图片视频")
   @DeleteMapping("/deleteMediaFile")
   public ResponseResult deleteMediaFile(@RequestBody List<Long> ids) {
      attachService.deleteMediaFile(ids);
      return ResponseResult.success();
   }
   // @ApiLog("删除图片视频")
   // @DeleteMapping("/deleteMediaFile")
   // public ResponseResult deleteMediaFile(@RequestBody List<Long> ids) {
   //    attachService.deleteMediaFile(ids);
   //    return ResponseResult.success();
   // }
   /**
    * 附件统计
    */
   @ApiOperation(value = "附件统计", notes = "")
   @PostMapping("/attachTypeStatistics")
   public ResponseResult<List<AttachTypeStatisticsVO>> attachTypeStatistics(@RequestBody AttachStatisticsVo attachStatisticsVo) {
      List<AttachTypeStatisticsVO> result = attachService.attachTypeStatistics(attachStatisticsVo);
      return ResponseResult.success(result);
   }
   // @ApiOperation(value = "附件统计", notes = "")
   // @PostMapping("/attachTypeStatistics")
   // public ResponseResult<List<AttachTypeStatisticsVO>> attachTypeStatistics(@RequestBody AttachStatisticsVo attachStatisticsVo) {
   //    List<AttachTypeStatisticsVO> result = attachService.attachTypeStatistics(attachStatisticsVo);
   //    return ResponseResult.success(result);
   // }
   /**
    * 个人中心附件统计
    */
   @ApiOperation(value = "个人中心附件统计", notes = "")
   @PostMapping("/getManageAttachTypeStatistics")
   public ResponseResult<List<LineColumnDateVo>> getManageAttachTypeStatistics(@RequestBody WaylineJobInfoQueryDto dto) {
      WaylineJobInfoQueryParam param = new WaylineJobInfoQueryParam(dto);
      param.setFormatTime(ChartDataVo.getTimeFormatByEnum(param.getDateEnum()));
      List<LineColumnDateVo> result = attachService.getManageAttachTypeStatistics(param);
      return ResponseResult.success(result);
   }
   // @ApiOperation(value = "个人中心附件统计", notes = "")
   // @PostMapping("/getManageAttachTypeStatistics")
   // public ResponseResult<List<LineColumnDateVo>> getManageAttachTypeStatistics(@RequestBody WaylineJobInfoQueryDto dto) {
   //    WaylineJobInfoQueryParam param = new WaylineJobInfoQueryParam(dto);
   //    param.setFormatTime(ChartDataVo.getTimeFormatByEnum(param.getDateEnum()));
   //    List<LineColumnDateVo> result = attachService.getManageAttachTypeStatistics(param);
   //    return ResponseResult.success(result);
   // }
}