|
@@ -2,6 +2,8 @@ package com.gyee.frame.controller.file;
|
|
|
|
|
|
import com.gyee.frame.common.conf.AjaxStatus;
|
|
import com.gyee.frame.common.conf.AjaxStatus;
|
|
import com.gyee.frame.common.domain.AjaxResult;
|
|
import com.gyee.frame.common.domain.AjaxResult;
|
|
|
|
+import com.gyee.frame.common.file.FileZip;
|
|
|
|
+import com.gyee.frame.model.config.FilePathConfig;
|
|
import com.gyee.frame.model.excel.LoadrateHourly;
|
|
import com.gyee.frame.model.excel.LoadrateHourly;
|
|
import com.gyee.frame.service.export.LoadrateHourlyService;
|
|
import com.gyee.frame.service.export.LoadrateHourlyService;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
@@ -10,8 +12,11 @@ import org.springframework.web.bind.annotation.RequestParam;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
import java.io.File;
|
|
import java.io.File;
|
|
|
|
+import java.util.Collection;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
@RequestMapping("/loadrate")
|
|
@RequestMapping("/loadrate")
|
|
@@ -34,13 +39,24 @@ public class LoadrateHourlyController {
|
|
return AjaxResult.successData(AjaxStatus.success.code,loadrateHourlies);
|
|
return AjaxResult.successData(AjaxStatus.success.code,loadrateHourlies);
|
|
}
|
|
}
|
|
@GetMapping("/down")
|
|
@GetMapping("/down")
|
|
- public AjaxResult getDownInfo(@RequestParam(value = "stationid",required = false) String stationid,
|
|
|
|
|
|
+ public AjaxResult getDownInfo(HttpServletResponse response,
|
|
|
|
+ @RequestParam(value = "stationid",required = false) String stationid,
|
|
@RequestParam("date") String date,
|
|
@RequestParam("date") String date,
|
|
- @RequestParam("time") String time){
|
|
|
|
- File file = loadrateHourlyService.getPath(date, time);
|
|
|
|
- if(file.exists()){
|
|
|
|
- return AjaxResult.successData(AjaxStatus.success.code,file.getPath());
|
|
|
|
|
|
+ @RequestParam(value = "time",required = false) String time){
|
|
|
|
+
|
|
|
|
+ if(time!=null){
|
|
|
|
+ File path = loadrateHourlyService.getPath(date, time);
|
|
|
|
+ if(!path.exists()) return AjaxResult.error("文件不存在!");
|
|
|
|
+ FileZip.download(path.getPath(),response);
|
|
|
|
+ return AjaxResult.success();
|
|
|
|
+ }else{
|
|
|
|
+ String s = FilePathConfig.getDataPath() + "\\光伏逆变器负荷率利用小时计算\\" + date.replaceAll("-", "") + ".zip";
|
|
|
|
+ File zipfile = new File(s);
|
|
|
|
+ List<File> values = loadrateHourlyService.getAllPath(date).entrySet().stream().map(kv -> kv.getValue()).collect(Collectors.toList());
|
|
|
|
+ if(values.size()<=0) return AjaxResult.error("文件不存在!");
|
|
|
|
+ String s1 = FileZip.zipFiles(values, zipfile);
|
|
|
|
+ FileZip.download(s1,response);
|
|
|
|
+ return AjaxResult.success();
|
|
}
|
|
}
|
|
- return AjaxResult.error("文件不存在!");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|