|
@@ -1,167 +1,166 @@
|
|
|
-//package com.gyee.power.fitting.controller.gf;
|
|
|
-//
|
|
|
-//import com.alibaba.fastjson.JSONObject;
|
|
|
-//import com.gyee.power.fitting.common.result.JsonResult;
|
|
|
-//import com.gyee.power.fitting.common.result.ResultCode;
|
|
|
-//import com.gyee.power.fitting.model.anno.AnnotationTool;
|
|
|
-//import com.gyee.power.fitting.model.anno.FixedVo;
|
|
|
-//import com.gyee.power.fitting.model.custom.FjjxbVo;
|
|
|
-//import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
|
|
|
-//import com.gyee.power.fitting.model.custom.TableTitle;
|
|
|
-//import com.gyee.power.fitting.service.impl.IvPvCurveFittingService;
|
|
|
-//import com.gyee.power.fitting.service.impl.NewIvPvCurveFittingService;
|
|
|
-//import org.springframework.web.bind.annotation.*;
|
|
|
-//
|
|
|
-//import javax.annotation.Resource;
|
|
|
-//import javax.servlet.http.HttpServletResponse;
|
|
|
-//import java.util.*;
|
|
|
-//import java.util.stream.Collectors;
|
|
|
-//
|
|
|
-//@RestController("/photovol")
|
|
|
-//public class PhotovoltaicController {
|
|
|
-//
|
|
|
-// @Resource
|
|
|
-// private AnnotationTool annotationTool;
|
|
|
-// @Resource
|
|
|
-// private NewIvPvCurveFittingService curveFittingService;
|
|
|
-//
|
|
|
-// @GetMapping("/filelist")
|
|
|
-// private JSONObject getFileList(@RequestParam("station") String station,
|
|
|
-// @RequestParam("inverters") List<String> inverters,
|
|
|
-// @RequestParam("startdate") long startdate,
|
|
|
-// @RequestParam("enddate") long enddate) {
|
|
|
-// List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, false);
|
|
|
-// if (fileList == null) {
|
|
|
-// try {
|
|
|
-// curveFittingService.getDatas2File(station, startdate, enddate);
|
|
|
-// curveFittingService.standardPointCalculate2();
|
|
|
-// } catch (Exception e) {
|
|
|
-// return JsonResult.error(ResultCode.ERROR_FILE_NO);
|
|
|
-// }
|
|
|
-//
|
|
|
-// fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, true);
|
|
|
-// }
|
|
|
-// //Map<String, Object> table = curveFittingService.getTable(fileList.get(0));
|
|
|
-// //table.put("filelist", fileList);
|
|
|
-//
|
|
|
-// List<Object> fileLists = curveFittingService.str2FileList(fileList);
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, fileLists);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @GetMapping("/allfilelist")
|
|
|
-// private JSONObject getFileList() {
|
|
|
-// List<String> fileList = curveFittingService.getAllFileList();
|
|
|
-// List<Object> objects = curveFittingService.str2FileList(fileList);
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, objects);
|
|
|
-// }
|
|
|
-//
|
|
|
-// /**
|
|
|
-// * 单文件表格显示
|
|
|
-// *
|
|
|
-// * @param filename
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @GetMapping("/datas")
|
|
|
-// private JSONObject getDatas(@RequestParam("filename") String filename) {
|
|
|
-// Map<String, Object> table = curveFittingService.getTable(filename);
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, table);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //功率-时间曲线,根据条件,暂时不用
|
|
|
-// @GetMapping("/analysis/powertime")
|
|
|
-// private JSONObject powerTimeAnalysis(@RequestParam("station") String station,
|
|
|
-// @RequestParam("inverters") List<String> inverters,
|
|
|
-// @RequestParam("startdate") long startdate,
|
|
|
-// @RequestParam("enddate") long enddate) {
|
|
|
-// List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, true);
|
|
|
-// Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
|
|
|
-//
|
|
|
-// List<FixedVo> fixedVos = annotationTool.getFixedVoList(PhotovoltaicInfo.class);
|
|
|
-// String[] ss = {"station", "datetime", "T", "S", "actualP"};
|
|
|
-// List<String> strings = Arrays.asList(ss);
|
|
|
-// List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
|
|
|
-// collect = collect.stream().filter(c -> strings.contains(c.getKey())).collect(Collectors.toList());
|
|
|
-// TableTitle title = new TableTitle();
|
|
|
-// title.setKey("ideaP");
|
|
|
-// title.setDes("理论功率");
|
|
|
-// collect.add(title);
|
|
|
-//
|
|
|
-// Map<String, Object> table = new HashMap<>();
|
|
|
-// table.put("title", collect);
|
|
|
-// table.put("data", infos);
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, table);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //功率-时间曲线,根据文件
|
|
|
-// @GetMapping("/analysis/powertimefile")
|
|
|
-// private JSONObject powerTimeFile(@RequestParam("filelist") List<String> fileList) {
|
|
|
-// Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
|
|
|
-//
|
|
|
-// List<TableTitle> collect = curveFittingService.getTheoryTitel();
|
|
|
-//
|
|
|
-// Map<String, Object> table = new HashMap<>();
|
|
|
-// table.put("title", collect);
|
|
|
-// table.put("data", infos);
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, table);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @GetMapping("/test")
|
|
|
-// private void test() {
|
|
|
-// curveFittingService.standardPointCalculate2();
|
|
|
-// }
|
|
|
-//
|
|
|
-// @GetMapping("/gfjxb")
|
|
|
-// public JSONObject gfjxb(@RequestParam("startdate") long startdate,
|
|
|
-// @RequestParam("enddate") long enddate) {
|
|
|
-// List<FjjxbVo> voList = curveFittingService.getPhotovoltaicPerformanceList(startdate, enddate);
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, voList);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //功率-光照-温度曲线
|
|
|
-// @PostMapping("/analysis/powerbeam")
|
|
|
-// private JSONObject powerBeamTemperature(@RequestBody JSONObject filename) {
|
|
|
-// List<String> strings = jsonObj2List(filename);
|
|
|
-// if (strings.size() > 450) return JsonResult.error(ResultCode.PARAM_NOT_VALID);
|
|
|
-// List<PhotovoltaicInfo> infos = curveFittingService.calculatFitting(strings);
|
|
|
-// List<double[]> b = curveFittingService.oneFileFitting(infos);
|
|
|
-// infos = infos.stream().filter(i -> i.getS() > 1).sorted(Comparator.comparing(PhotovoltaicInfo::getS)).collect(Collectors.toList());
|
|
|
-//
|
|
|
-// List<double[]> a = new ArrayList<>();
|
|
|
-// for (PhotovoltaicInfo pi : infos) {
|
|
|
-//
|
|
|
-// double[] scatter = new double[3];
|
|
|
-//
|
|
|
-// scatter[0] = pi.getS();
|
|
|
-// scatter[1] = pi.getActualP();
|
|
|
-// scatter[2] = pi.getT();
|
|
|
-//
|
|
|
-// a.add(scatter);
|
|
|
-// }
|
|
|
-//
|
|
|
-// HashMap<String, Object> map = new HashMap<>();
|
|
|
-// map.put("scatter", a);
|
|
|
-// map.put("curve", b);
|
|
|
-//
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, map);
|
|
|
-// }
|
|
|
-//
|
|
|
-// //文件删除
|
|
|
-// @DeleteMapping("/delete/files")
|
|
|
-// private JSONObject deleteFiles(@RequestBody JSONObject filename) {
|
|
|
-// List<String> strings = jsonObj2List(filename);
|
|
|
-// int i = curveFittingService.deleteFiles(strings);
|
|
|
-// return JsonResult.successData(ResultCode.SUCCESS, "共删除" + i + "个文件,删除失败" + (strings.size() - i) + "个!");
|
|
|
-// }
|
|
|
-//
|
|
|
-// private List<String> jsonObj2List(JSONObject filename) {
|
|
|
-// String fn = filename.getString("filename");
|
|
|
-// String[] split = fn.split(",");
|
|
|
-// return Arrays.asList(split);
|
|
|
-// }
|
|
|
-//
|
|
|
-// @GetMapping("/export/files")
|
|
|
-// private void exportFiles(HttpServletResponse response, @RequestParam("filename") String filename) {
|
|
|
-// String[] split = filename.split(",");
|
|
|
-// curveFittingService.downFiles(Arrays.asList(split), response);
|
|
|
-// }
|
|
|
-//}
|
|
|
+package com.gyee.power.fitting.controller.gf;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.gyee.power.fitting.common.result.JsonResult;
|
|
|
+import com.gyee.power.fitting.common.result.ResultCode;
|
|
|
+import com.gyee.power.fitting.model.anno.AnnotationTool;
|
|
|
+import com.gyee.power.fitting.model.anno.FixedVo;
|
|
|
+import com.gyee.power.fitting.model.custom.FjjxbVo;
|
|
|
+import com.gyee.power.fitting.model.custom.PhotovoltaicInfo;
|
|
|
+import com.gyee.power.fitting.model.custom.TableTitle;
|
|
|
+import com.gyee.power.fitting.service.impl.IvPvCurveFittingService;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/new/photovol")
|
|
|
+public class PhotovoltaicController {
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IvPvCurveFittingService curveFittingService;
|
|
|
+
|
|
|
+ @GetMapping("/filelist")
|
|
|
+ private JSONObject getFileList(@RequestParam("station") String station,
|
|
|
+ @RequestParam("inverters") List<String> inverters,
|
|
|
+ @RequestParam("startdate") long startdate,
|
|
|
+ @RequestParam("enddate") long enddate) {
|
|
|
+ List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, false);
|
|
|
+ if (fileList == null) {
|
|
|
+ try {
|
|
|
+ curveFittingService.getDatas2File(station, startdate, enddate);
|
|
|
+ curveFittingService.standardPointCalculate2();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return JsonResult.error(ResultCode.ERROR_FILE_NO);
|
|
|
+ }
|
|
|
+
|
|
|
+ fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, true);
|
|
|
+ }
|
|
|
+ //Map<String, Object> table = curveFittingService.getTable(fileList.get(0));
|
|
|
+ //table.put("filelist", fileList);
|
|
|
+
|
|
|
+ List<Object> fileLists = curveFittingService.str2FileList(fileList);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, fileLists);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/allfilelist")
|
|
|
+ private JSONObject getFileList() {
|
|
|
+ List<String> fileList = curveFittingService.getAllFileList();
|
|
|
+ List<Object> objects = curveFittingService.str2FileList(fileList);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, objects);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 单文件表格显示
|
|
|
+ *
|
|
|
+ * @param filename
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/datas")
|
|
|
+ private JSONObject getDatas(@RequestParam("filename") String filename) {
|
|
|
+ Map<String, Object> table = curveFittingService.getTable(filename);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, table);
|
|
|
+ }
|
|
|
+
|
|
|
+ //功率-时间曲线,根据条件,暂时不用
|
|
|
+ @GetMapping("/analysis/powertime")
|
|
|
+ private JSONObject powerTimeAnalysis(@RequestParam("station") String station,
|
|
|
+ @RequestParam("inverters") List<String> inverters,
|
|
|
+ @RequestParam("startdate") long startdate,
|
|
|
+ @RequestParam("enddate") long enddate) {
|
|
|
+ List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, true);
|
|
|
+ Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
|
|
|
+
|
|
|
+ List<FixedVo> fixedVos = AnnotationTool.getFixedVoList(PhotovoltaicInfo.class);
|
|
|
+ String[] ss = {"station", "datetime", "T", "S", "actualP"};
|
|
|
+ List<String> strings = Arrays.asList(ss);
|
|
|
+ List<TableTitle> collect = fixedVos.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
|
|
|
+ collect = collect.stream().filter(c -> strings.contains(c.getKey())).collect(Collectors.toList());
|
|
|
+ TableTitle title = new TableTitle();
|
|
|
+ title.setKey("ideaP");
|
|
|
+ title.setDes("理论功率");
|
|
|
+ collect.add(title);
|
|
|
+
|
|
|
+ Map<String, Object> table = new HashMap<>();
|
|
|
+ table.put("title", collect);
|
|
|
+ table.put("data", infos);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, table);
|
|
|
+ }
|
|
|
+
|
|
|
+ //功率-时间曲线,根据文件
|
|
|
+ @GetMapping("/analysis/powertimefile")
|
|
|
+ private JSONObject powerTimeFile(@RequestParam("filelist") List<String> fileList) {
|
|
|
+ Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
|
|
|
+
|
|
|
+ List<TableTitle> collect = curveFittingService.getTheoryTitel();
|
|
|
+
|
|
|
+ Map<String, Object> table = new HashMap<>();
|
|
|
+ table.put("title", collect);
|
|
|
+ table.put("data", infos);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, table);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/test")
|
|
|
+ private void test() {
|
|
|
+ curveFittingService.standardPointCalculate2();
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/gfjxb")
|
|
|
+ public JSONObject gfjxb(@RequestParam("startdate") long startdate,
|
|
|
+ @RequestParam("enddate") long enddate) {
|
|
|
+ List<FjjxbVo> voList = curveFittingService.getPhotovoltaicPerformanceList(startdate, enddate);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, voList);
|
|
|
+ }
|
|
|
+
|
|
|
+ //功率-光照-温度曲线
|
|
|
+ @PostMapping("/analysis/powerbeam")
|
|
|
+ private JSONObject powerBeamTemperature(@RequestBody JSONObject filename) {
|
|
|
+ List<String> strings = jsonObj2List(filename);
|
|
|
+ if (strings.size() > 450) return JsonResult.error(ResultCode.PARAM_NOT_VALID);
|
|
|
+ List<PhotovoltaicInfo> infos = curveFittingService.calculatFitting(strings);
|
|
|
+ List<double[]> b = curveFittingService.oneFileFitting(infos);
|
|
|
+ infos = infos.stream().filter(i -> i.getS() > 1).sorted(Comparator.comparing(PhotovoltaicInfo::getS)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<double[]> a = new ArrayList<>();
|
|
|
+ for (PhotovoltaicInfo pi : infos) {
|
|
|
+
|
|
|
+ double[] scatter = new double[3];
|
|
|
+
|
|
|
+ scatter[0] = pi.getS();
|
|
|
+ scatter[1] = pi.getActualP();
|
|
|
+ scatter[2] = pi.getT();
|
|
|
+
|
|
|
+ a.add(scatter);
|
|
|
+ }
|
|
|
+
|
|
|
+ HashMap<String, Object> map = new HashMap<>();
|
|
|
+ map.put("scatter", a);
|
|
|
+ map.put("curve", b);
|
|
|
+
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, map);
|
|
|
+ }
|
|
|
+
|
|
|
+ //文件删除
|
|
|
+ @DeleteMapping("/delete/files")
|
|
|
+ private JSONObject deleteFiles(@RequestBody JSONObject filename) {
|
|
|
+ List<String> strings = jsonObj2List(filename);
|
|
|
+ int i = curveFittingService.deleteFiles(strings);
|
|
|
+ return JsonResult.successData(ResultCode.SUCCESS, "共删除" + i + "个文件,删除失败" + (strings.size() - i) + "个!");
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<String> jsonObj2List(JSONObject filename) {
|
|
|
+ String fn = filename.getString("filename");
|
|
|
+ String[] split = fn.split(",");
|
|
|
+ return Arrays.asList(split);
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/export/files")
|
|
|
+ private void exportFiles(HttpServletResponse response, @RequestParam("filename") String filename) {
|
|
|
+ String[] split = filename.split(",");
|
|
|
+ curveFittingService.downFiles(Arrays.asList(split), response);
|
|
|
+ }
|
|
|
+}
|