SceneController.java 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. package com.fdkankan.project.tieta.controller;
  2. import cn.hutool.core.img.ImgUtil;
  3. import cn.hutool.core.io.FileUtil;
  4. import cn.hutool.http.HttpUtil;
  5. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  6. import com.fdkankan.project.tieta.bean.ResultData;
  7. import com.fdkankan.project.tieta.entity.FullphotoFileindex;
  8. import com.fdkankan.project.tieta.entity.Scene;
  9. import com.fdkankan.project.tieta.service.FullphotoFileindexService;
  10. import com.fdkankan.project.tieta.service.SceneService;
  11. import com.fdkankan.project.tieta.utils.CreateObjUtil;
  12. import org.springframework.beans.factory.annotation.Autowired;
  13. import org.springframework.web.bind.annotation.GetMapping;
  14. import org.springframework.web.bind.annotation.RequestMapping;
  15. import org.springframework.web.bind.annotation.RestController;
  16. import java.io.File;
  17. import java.util.List;
  18. /**
  19. * <p>
  20. * 前端控制器
  21. * </p>
  22. *
  23. * @author dsx
  24. * @since 2024-06-25
  25. */
  26. @RestController
  27. @RequestMapping("/scene")
  28. public class SceneController {
  29. @Autowired
  30. private SceneService sceneService;
  31. @GetMapping("/test")
  32. public ResultData test(){
  33. return ResultData.ok(sceneService.list());
  34. }
  35. @GetMapping("/add")
  36. public ResultData add(){
  37. Scene scene = new Scene();
  38. scene.setNum("sdfsdfdhfgjghjrr胜多负少的");
  39. sceneService.save(scene);
  40. return ResultData.ok();
  41. }
  42. @Autowired
  43. private FullphotoFileindexService fullphotoFileindexService;
  44. @GetMapping("/test2")
  45. public ResultData test2(String stationCode, String roomEntityID) throws Exception {
  46. String path = "D:\\test\\tieta\\" + stationCode + "_" + roomEntityID + "\\";
  47. List<FullphotoFileindex> list = fullphotoFileindexService.list(new LambdaQueryWrapper<FullphotoFileindex>().eq(FullphotoFileindex::getStationCode, stationCode).eq(FullphotoFileindex::getEntityId, roomEntityID));
  48. list.stream().forEach(v->{
  49. String localPath = path + v.getFileName();
  50. HttpUtil.downloadFile(v.getFileUrl(), localPath);
  51. if(v.getFileName().endsWith("jpg")){
  52. String highPath = path + "pan\\high\\" + v.getFileName();
  53. FileUtil.mkParentDirs(highPath);
  54. String lowPath = path + "pan\\low\\" + v.getFileName();
  55. FileUtil.mkParentDirs(lowPath);
  56. ImgUtil.scale(new File(localPath),new File(highPath), 0.5f);
  57. ImgUtil.scale(new File(localPath),new File(lowPath), 0.0625f);
  58. }
  59. });
  60. CreateObjUtil.convertTxtToVisionmodeldata(path + "vision.txt", path + "vision.modeldata");
  61. return ResultData.ok();
  62. }
  63. }