123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- package com.gyee.power.fitting.controller.gf;
- import com.alibaba.fastjson.JSONObject;
- import com.gyee.power.fitting.common.config.R;
- import com.gyee.power.fitting.common.config.ResultMsg;
- import com.gyee.power.fitting.common.config.StringUtils;
- import com.gyee.power.fitting.common.result.JsonResult;
- import com.gyee.power.fitting.common.result.ResultCode;
- import com.gyee.power.fitting.common.spring.InitialRunner;
- import com.gyee.power.fitting.model.ProBasicEquipment;
- 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.ProBasicEquipmentService;
- import com.gyee.power.fitting.service.impl.NewIvPvCurveFittingService;
- import io.swagger.annotations.ApiOperation;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletResponse;
- import java.util.*;
- import java.util.stream.Collectors;
- @RestController
- @CrossOrigin
- @RequestMapping("/photovol")
- public class NewPhotovoltaicController {
- @Resource
- private NewIvPvCurveFittingService curveFittingService;
- @Resource
- private ProBasicEquipmentService equipmentService;
- @GetMapping("/filelist")
- private JSONObject getFileList(
- @RequestParam(value = "station", required = true) String station,
- @RequestParam(value = "inverters", required = true) List<String> inverters,
- @RequestParam(value = "startdate", required = true) long startdate,
- @RequestParam(value = "enddate", required = true) 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/powertimefile")
- private JSONObject powerTimeFile(@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);
- Map<String, List<PhotovoltaicInfo>> infos = curveFittingService.calculatAnalysis(fileList);
- List<TableTitle> collect = curveFittingService.getTheoryTitel();
- Map<String, Object> table = new HashMap<>();
- Set<String> keys = infos.keySet();
- for (String key : keys) {
- for (ProBasicEquipment c : InitialRunner.newgfwtList) {
- if (key.equals(c.getId())) {
- table.put("name", c.getName());
- }
- }
- }
- table.put("title", collect);
- table.put("data", infos);
- return JsonResult.successData(ResultCode.SUCCESS, table);
- }
- @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(@RequestParam("station") String station,
- @RequestParam("inverters") List<String> inverters,
- @RequestParam("startdate") long startdate,
- @RequestParam("enddate") long enddate) {
- // List<String> strings = jsonObj2List(null);
- // if (strings.size() > 450) return JsonResult.error(ResultCode.PARAM_NOT_VALID);
- List<String> fileList = curveFittingService.getFileList(station, inverters, startdate, enddate, false);
- List<PhotovoltaicInfo> infos = curveFittingService.calculatFitting(fileList);
- 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);
- }
- @GetMapping(value = "/wtByWplist")
- @ApiOperation(value = "风机列表", notes = "风机列表")
- public R wtByWplist(@RequestParam(value = "wpids", required = true) String wpids) {
- List<ProBasicEquipment> resultList = curveFittingService.wtByWplist(wpids);
- if (StringUtils.isNotNull(resultList)) {
- return R.data(ResultMsg.ok(resultList));
- } else {
- return R.error(ResultMsg.error());
- }
- }
- }
|