DataPrepareController.java 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.gyee.power.fitting.controller.fj;
  2. import com.alibaba.fastjson.JSONObject;
  3. import com.gyee.power.fitting.common.result.JsonResult;
  4. import com.gyee.power.fitting.common.result.ResultCode;
  5. import com.gyee.power.fitting.common.util.FileUtil;
  6. import com.gyee.power.fitting.model.ProEconPowerFittingAnalySis;
  7. import com.gyee.power.fitting.service.ProEconPowerFittingAnalySisService;
  8. import com.gyee.power.fitting.service.custom.curve.DataPrepareService;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.web.bind.annotation.*;
  11. import javax.servlet.http.HttpServletRequest;
  12. import javax.servlet.http.HttpServletResponse;
  13. import java.util.*;
  14. /**
  15. * 功率曲线拟合 数据准备
  16. */
  17. @RestController
  18. @CrossOrigin
  19. @RequestMapping("/power/prepare")
  20. public class DataPrepareController {
  21. @Autowired
  22. private DataPrepareService prepareService;
  23. @Autowired
  24. private ProEconPowerFittingAnalySisService powerService;
  25. @Autowired
  26. private HttpServletRequest request;
  27. /**
  28. * 数据准备 golden-file
  29. * @param station
  30. * @param wtIds
  31. * @param st
  32. * @param et
  33. * @param interval
  34. * @return
  35. */
  36. @GetMapping("data")
  37. public JSONObject dataPrepare(String station, String wtIds, Long st,
  38. Long et, Integer interval){
  39. if (station.isEmpty() || wtIds.isEmpty())
  40. return JsonResult.error(ResultCode.PARAM_NOT_COMPLETE);
  41. String[] points = wtIds.split(",");
  42. prepareService.dataPrepare(station, Arrays.asList(points), st, et, interval);
  43. return JsonResult.error(ResultCode.SUCCESS_DATA_PREPARE);
  44. }
  45. /** 文件 tree
  46. * @return
  47. */
  48. @GetMapping("tree")
  49. public JSONObject dataPrepareTree(){
  50. List<Object> result = prepareService.dataPrepareTree(request);
  51. return JsonResult.successData(ResultCode.SUCCESS, result);
  52. }
  53. /**
  54. * file 文件数据展示前500行
  55. * @param id
  56. * @return
  57. */
  58. @GetMapping("show")
  59. public JSONObject dataPrepareShow(String id){
  60. Map<String, Object> result = prepareService.dataPrepareShow(id);
  61. return JsonResult.successData(ResultCode.SUCCESS, result);
  62. }
  63. /**
  64. * file 下载
  65. * @return
  66. */
  67. @GetMapping("download")
  68. public void dataPrepareDownload(HttpServletResponse response, @RequestParam(value = "id", required = false) String id){
  69. ProEconPowerFittingAnalySis obj = powerService.selectItemById(id);
  70. FileUtil.download(obj.getPath(), response);
  71. }
  72. }