|
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.io.File;
|
|
|
import java.util.*;
|
|
|
|
|
|
@RestController
|
|
@@ -29,6 +30,7 @@ public class GoldenController {
|
|
|
@Autowired
|
|
|
FileUtils fileUtils;
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 查询所有的场站
|
|
|
*
|
|
@@ -71,63 +73,20 @@ public class GoldenController {
|
|
|
/**
|
|
|
* 通过模板导出所有风机数据
|
|
|
*
|
|
|
- * @param id 模板ID
|
|
|
- * @param startTs 开始时间
|
|
|
- * @param endTs 结束时间
|
|
|
- * @param interval 时间间隔
|
|
|
+ * @param startTs 开始时间
|
|
|
+ * @param endTs 结束时间
|
|
|
* @return
|
|
|
*/
|
|
|
@GetMapping("/history/all")
|
|
|
public AjaxResult getHistoryAll(
|
|
|
@RequestParam(value = "station") String station,
|
|
|
- @RequestParam(value = "templateId") Integer id,
|
|
|
@RequestParam(value = "startTs") Long startTs,
|
|
|
- @RequestParam(value = "endTs") Long endTs,
|
|
|
- @RequestParam(value = "interval", required = false) Optional<Integer> interval) {
|
|
|
+ @RequestParam(value = "endTs") Long endTs) {
|
|
|
|
|
|
- int val = interval.isPresent() ? interval.get() : 1800;
|
|
|
- Map<String, List<Object>> map = goldenService.getHistoryDataAll(station, id, startTs, endTs, val);
|
|
|
- return AjaxResult.successData(AjaxStatus.success.code, map);
|
|
|
+ boolean tag = goldenService.getHistoryDataAll(station, startTs, endTs);
|
|
|
+ return AjaxResult.successData(AjaxStatus.success.code, tag);
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// * @param request
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @GetMapping("/downloadFile")
|
|
|
-// public ResponseEntity<Resource> downloadFile(HttpServletRequest request,
|
|
|
-// @RequestParam(value = "station") String station,
|
|
|
-// @RequestParam(value = "templateId") String templateId,
|
|
|
-// @RequestParam(value = "month") String month,
|
|
|
-// @RequestParam(value = "interval") int interval) throws Exception {
|
|
|
-//
|
|
|
-// String path = fileUtils.getFilePath(station, templateId, month, interval);
|
|
|
-// if ("1".equals(templateId)){
|
|
|
-// ZipUtils.toZip(fileUtils.getFilePathNoEx(path), path, true);
|
|
|
-// }
|
|
|
-// // Load file as Resource
|
|
|
-// Resource resource = fileUtils.loadFileAsResource(path);
|
|
|
-//
|
|
|
-// // Try to determine file's content type
|
|
|
-// String contentType = null;
|
|
|
-// try {
|
|
|
-// contentType = request.getServletContext().getMimeType(resource.getFile().getAbsolutePath());
|
|
|
-// } catch (IOException ex) {
|
|
|
-//
|
|
|
-// }
|
|
|
-//
|
|
|
-// // Fallback to the default content type if type could not be determined
|
|
|
-// if (contentType == null) {
|
|
|
-// contentType = "application/octet-stream";
|
|
|
-// }
|
|
|
-//
|
|
|
-// return ResponseEntity.ok()
|
|
|
-// .contentType(MediaType.parseMediaType(contentType))
|
|
|
-// .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + resource.getFilename() + "\"")
|
|
|
-// .body(resource);
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* @param request
|
|
@@ -135,24 +94,29 @@ public class GoldenController {
|
|
|
*/
|
|
|
@GetMapping("/downloadFile")
|
|
|
public AjaxResult downloadFile(HttpServletRequest request,
|
|
|
- @RequestParam(value = "station") String station,
|
|
|
- @RequestParam(value = "templateId") String templateId,
|
|
|
- @RequestParam(value = "month") String month,
|
|
|
- @RequestParam(value = "interval") int interval) throws Exception {
|
|
|
- String path = fileUtils.getFilePath(station, templateId, month, interval);
|
|
|
- if ("1".equals(templateId)){
|
|
|
- ZipUtils.toZip(fileUtils.getFilePathNoEx(path), path, true);
|
|
|
+ @RequestParam(value = "station") String[] stations,
|
|
|
+ @RequestParam(value = "templateId") String templateId,
|
|
|
+ @RequestParam(value = "month") String[] month,
|
|
|
+ @RequestParam(value = "interval") int[] interval) throws Exception {
|
|
|
+
|
|
|
+ String zipName = "";
|
|
|
+ List<File> srcFiles = new ArrayList<>();
|
|
|
+ for (int i = 0; i < stations.length; i++) {
|
|
|
+ String path = fileUtils.getFilePath(stations[i], templateId, month[i], interval[i]);
|
|
|
+ if ("1".equals(templateId)) {
|
|
|
+ ZipUtils.toZip(fileUtils.getFilePathNoEx(path), path, true);
|
|
|
+ zipName = month[0] + "_单机数据.zip";
|
|
|
+ } else {
|
|
|
+ zipName = month[0] + "_测风塔数据.zip";
|
|
|
+ }
|
|
|
+ srcFiles.add(new File(path));
|
|
|
}
|
|
|
+ ZipUtils.toZip(srcFiles, fileUtils.getFilePath2("path", month[0], interval[0]), zipName);
|
|
|
Map map = new HashMap();
|
|
|
- map.put("path",fileUtils.getFilePath2(station, templateId, month, interval));
|
|
|
-
|
|
|
- if ("1".equals(templateId)) {
|
|
|
- map.put("name",station+".zip");
|
|
|
- } else if ("2".equals(templateId)) {
|
|
|
- map.put("name",station+".xls");
|
|
|
- }
|
|
|
+ map.put("path", fileUtils.getFilePath2("url", month[0], interval[0]));
|
|
|
+ map.put("name", zipName);
|
|
|
|
|
|
- AjaxResult result = AjaxResult.successData(200,map);
|
|
|
+ AjaxResult result = AjaxResult.successData(200, map);
|
|
|
return result;
|
|
|
}
|
|
|
|