|
@@ -1,18 +1,23 @@
|
|
|
package com.gyee.impala.service.custom;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.gyee.impala.common.constant.Constants;
|
|
|
import com.gyee.impala.common.exception.CustomException;
|
|
|
import com.gyee.impala.common.feign.RemoteServiceBuilder;
|
|
|
import com.gyee.impala.common.result.ResultCode;
|
|
|
+import com.gyee.impala.common.util.Base64Util;
|
|
|
import com.gyee.impala.common.util.DateUtil;
|
|
|
-import com.gyee.impala.model.custom.TsPointData;
|
|
|
+import com.gyee.impala.model.custom.TsDoubleData;
|
|
|
+import com.gyee.impala.model.master.Powercurvefitting;
|
|
|
import com.gyee.impala.model.master.Windturbinepoint;
|
|
|
import com.gyee.impala.model.slave.Windturbinecurvefittingmonth;
|
|
|
-import com.gyee.impala.service.master.TempscatterpointService;
|
|
|
+import com.gyee.impala.model.slave.Windturbinetestingpointai2;
|
|
|
+import com.gyee.impala.service.master.PowercurvefittingService;
|
|
|
import com.gyee.impala.service.master.WindturbinepointService;
|
|
|
import com.gyee.impala.service.slave.WindturbinecurvefittingmonthService;
|
|
|
-import com.gyee.impala.service.slave.WindturbinewindyawService;
|
|
|
+import com.gyee.impala.service.slave.Windturbinetestingpointai2Service;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -29,16 +34,20 @@ import java.util.*;
|
|
|
public class AnalyseScatterService {
|
|
|
|
|
|
|
|
|
- private final int interval = 150;
|
|
|
+ private final int interval = 1200;
|
|
|
|
|
|
@Autowired
|
|
|
private WindturbinepointService windturbinepointService;
|
|
|
@Autowired
|
|
|
- private TempscatterpointService tempscatterpointService;
|
|
|
+ private Windturbinetestingpointai2Service windturbinetestingpointai2Service;
|
|
|
+ @Autowired
|
|
|
+ private PowercurvefittingService powercurvefittingService;
|
|
|
@Autowired
|
|
|
private WindturbinecurvefittingmonthService windturbinecurvefittingmonthService;
|
|
|
@Autowired
|
|
|
private RemoteServiceBuilder remoteServiceBuilder;
|
|
|
+ @Autowired
|
|
|
+ private GoldenService goldenService;
|
|
|
|
|
|
|
|
|
|
|
@@ -56,94 +65,124 @@ public class AnalyseScatterService {
|
|
|
List<List<Double>> optimal = new ArrayList<>();
|
|
|
|
|
|
Calendar cal = Calendar.getInstance();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- cal.setTime(DateUtil.dateTime(DateUtil.YYYY_MM, time));
|
|
|
- int year = cal.get(Calendar.YEAR);
|
|
|
- int month = cal.get(Calendar.MONTH);
|
|
|
-
|
|
|
- time = year + "-" + StringUtils.leftPad(String.valueOf(month + 1), 2, "0");
|
|
|
-
|
|
|
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
- long startTime = cal.getTime().getTime();
|
|
|
- cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
- long endTime = cal.getTime().getTime();
|
|
|
-
|
|
|
- try{
|
|
|
-
|
|
|
- Windturbinepoint power = windturbinepointService.getListByWtIdAndUniformCode(wtId, Constants.POINT_POWER);
|
|
|
- Windturbinepoint speed = windturbinepointService.getListByWtIdAndUniformCode(wtId, Constants.POINT_SPEED);
|
|
|
- List<TsPointData> listPower = remoteServiceBuilder.ShardingService().getHistorySnap(power.getPoint(), startTime, endTime, interval);
|
|
|
- List<TsPointData> listSpeed = remoteServiceBuilder.ShardingService().getHistorySnap(speed.getPoint(), startTime, endTime, interval);
|
|
|
-
|
|
|
-
|
|
|
- DecimalFormat dcmFmt = new DecimalFormat("0.00");
|
|
|
- if (!listPower.isEmpty() && !listSpeed.isEmpty()) {
|
|
|
- for (int i = 0; i < listPower.size(); i++) {
|
|
|
- List<Double> ds = new ArrayList<>();
|
|
|
-
|
|
|
- double f = listSpeed.get(i).getDoubleValue();
|
|
|
- ds.add(Double.valueOf(dcmFmt.format(f)));
|
|
|
- f = listPower.get(i).getDoubleValue();
|
|
|
- ds.add(Double.valueOf(dcmFmt.format(f)));
|
|
|
- ds.add((double) listPower.get(i).getTs());
|
|
|
- scatter.add(ds);
|
|
|
+ Powercurvefitting item = powercurvefittingService.getOne(station, wtId, time);
|
|
|
+
|
|
|
+ if (item != null) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ cal.setTime(DateUtil.dateTime(DateUtil.YYYY_MM, time));
|
|
|
+ int year = cal.get(Calendar.YEAR);
|
|
|
+ int month = cal.get(Calendar.MONTH);
|
|
|
+
|
|
|
+ time = year + "-" + StringUtils.leftPad(String.valueOf(month + 1), 2, "0");
|
|
|
+
|
|
|
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMinimum(Calendar.DAY_OF_MONTH));
|
|
|
+ long startTime = cal.getTime().getTime();
|
|
|
+ cal.set(Calendar.DAY_OF_MONTH, cal.getActualMaximum(Calendar.DAY_OF_MONTH));
|
|
|
+ long endTime = cal.getTime().getTime();
|
|
|
+
|
|
|
+ try{
|
|
|
+
|
|
|
+ Windturbinetestingpointai2 power = windturbinetestingpointai2Service.getItemByStationAndCode(station, wtId, Constants.POINT_POWER);
|
|
|
+ Windturbinetestingpointai2 speed = windturbinetestingpointai2Service.getItemByStationAndCode(station, wtId, Constants.POINT_SPEED);
|
|
|
+ Windturbinetestingpointai2 status = windturbinetestingpointai2Service.getItemByStationAndCode(station, wtId, Constants.FJZT);
|
|
|
+
|
|
|
+ List<TsDoubleData> listPower = remoteServiceBuilder.ShardingService().getHistorySnapAI(power.getId(), startTime, endTime, interval);
|
|
|
+ List<TsDoubleData> listSpeed = remoteServiceBuilder.ShardingService().getHistorySnapAI(speed.getId(), startTime, endTime, interval);
|
|
|
+
|
|
|
+
|
|
|
+ DecimalFormat dcmFmt = new DecimalFormat("0.00");
|
|
|
+ if (!listPower.isEmpty() && !listSpeed.isEmpty()) {
|
|
|
+ for (int j = 0; j < listPower.size(); j++) {
|
|
|
+ List<Double> ds = new ArrayList<>();
|
|
|
+
|
|
|
+ double f = listSpeed.get(j).getDoubleValue();
|
|
|
+ ds.add(Double.valueOf(dcmFmt.format(f)));
|
|
|
+ f = listPower.get(j).getDoubleValue() < 0 ? 0 : listPower.get(j).getDoubleValue();
|
|
|
+ ds.add(Double.valueOf(dcmFmt.format(f)));
|
|
|
+ scatter.add(ds);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- List<Windturbinecurvefittingmonth> curve = windturbinecurvefittingmonthService.getListByWtIdAndYearAndMonth(wtId, String.valueOf(year), String.valueOf(month));
|
|
|
- for (Windturbinecurvefittingmonth wc : curve) {
|
|
|
- List<Double> ap = new ArrayList<>();
|
|
|
- List<Double> op = new ArrayList<>();
|
|
|
- int c = wc.getSpeed().intValue();
|
|
|
-
|
|
|
- if (c == wc.getSpeed()) {
|
|
|
- ap.add(wc.getSpeed());
|
|
|
- ap.add(wc.getActualpower());
|
|
|
- op.add(wc.getSpeed());
|
|
|
- op.add(wc.getOptimalpower());
|
|
|
- actual.add(ap);
|
|
|
- optimal.add(op);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<Windturbinecurvefittingmonth> curve = windturbinecurvefittingmonthService.getListByWtIdAndYearAndMonth(wtId, String.valueOf(year), String.valueOf(month));
|
|
|
+ for (Windturbinecurvefittingmonth wc : curve) {
|
|
|
+ List<Double> ap = new ArrayList<>();
|
|
|
+ List<Double> op = new ArrayList<>();
|
|
|
+ int c = wc.getSpeed().intValue();
|
|
|
+
|
|
|
+ if (c == wc.getSpeed()) {
|
|
|
+ ap.add(wc.getSpeed());
|
|
|
+ ap.add(wc.getActualpower());
|
|
|
+ op.add(wc.getSpeed());
|
|
|
+ op.add(wc.getOptimalpower());
|
|
|
+ actual.add(ap);
|
|
|
+ optimal.add(op);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- result.put("scatter", scatter);
|
|
|
- result.put("lineactual", actual);
|
|
|
- result.put("lineoptimal", optimal);
|
|
|
-
|
|
|
- return result;
|
|
|
- } catch (CustomException e) {
|
|
|
- log.error(e.getMessage());
|
|
|
- throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ } catch (CustomException e) {
|
|
|
+ log.error(e.getMessage());
|
|
|
+ throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ result.put("scatter", scatter);
|
|
|
+ result.put("lineactual", actual);
|
|
|
+ result.put("lineoptimal", optimal);
|
|
|
+
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
|
|
|
public void getTotalRangeCal(String wtId, long startTime, long endTime) {
|
|
|
try{
|
|
|
|
|
|
- Windturbinepoint direct = windturbinepointService.getListByWtIdAndUniformCode(wtId, Constants.POINT_WIND_DIRECT);
|
|
|
- Windturbinepoint angle = windturbinepointService.getListByWtIdAndUniformCode(wtId, Constants.POINT_WIND_ANGLE);
|
|
|
- List<TsPointData> listDirect = remoteServiceBuilder.ShardingService().getHistorySnap(direct.getPoint(), startTime, endTime, interval);
|
|
|
- List<TsPointData> listAngle = remoteServiceBuilder.ShardingService().getHistorySnap(angle.getPoint(), startTime, endTime, interval);
|
|
|
+ Windturbinepoint direct = windturbinepointService.getItemByWtIdAndUniformCode(wtId, Constants.POINT_WIND_DIRECT);
|
|
|
+ Windturbinepoint angle = windturbinepointService.getItemByWtIdAndUniformCode(wtId, Constants.POINT_WIND_ANGLE);
|
|
|
+ List<TsDoubleData> listDirect = remoteServiceBuilder.ShardingService().getHistorySnapAI(direct.getPoint(), startTime, endTime, interval);
|
|
|
+ List<TsDoubleData> listAngle = remoteServiceBuilder.ShardingService().getHistorySnapAI(angle.getPoint(), startTime, endTime, interval);
|
|
|
|
|
|
|
|
|
} catch (CustomException e) {
|
|
@@ -151,4 +190,13 @@ public class AnalyseScatterService {
|
|
|
throw new CustomException(ResultCode.ERROR_DATA);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ public static void main(String[] args){
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ for(int i = 0; i < 200000; i++)
|
|
|
+ sb.append("A");
|
|
|
+
|
|
|
+ System.out.println(sb.toString().length());
|
|
|
+ }
|
|
|
}
|