|
@@ -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 {
|
|
|
|
|
|
// 读取golden数据库的时间间隔
|
|
|
- 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();
|
|
|
-// Tempscatterpoint item = tempscatterpointService.getOne(station, wtId, time);
|
|
|
-//
|
|
|
-// if (item != null){
|
|
|
-// // 缓存有数据直接读取
|
|
|
-// scatter = JSONObject.parseObject(item.getScatter(), new TypeReference<List<List<Double>>>() {});
|
|
|
-// actual = JSONObject.parseObject(item.getLineactual(), new TypeReference<List<List<Double>>>() {});
|
|
|
-// optimal = JSONObject.parseObject(item.getLineoptimal(), new TypeReference<List<List<Double>>>() {});
|
|
|
-// } else{
|
|
|
- // 缓存没数据,先查golden,在缓存
|
|
|
- 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 {
|
|
|
+ // 缓存没数据,先查golden,在缓存
|
|
|
+ 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<List<Long>> listStatus = goldenService.getConnectData(status.getId(), startTime, endTime);
|
|
|
+ //// if (listStatus.size() > 0){
|
|
|
+ //// for (int i = 0; i< listStatus.size(); i++){
|
|
|
+ //// for (List<Long> ls : listStatus){
|
|
|
+ //// List<TsDoubleData> listPower = remoteServiceBuilder.ShardingService().getHistorySnapAI(power.getId(), ls.get(0), ls.get(1), interval);
|
|
|
+ //// List<TsDoubleData> listSpeed = remoteServiceBuilder.ShardingService().getHistorySnapAI(speed.getId(), ls.get(0), ls.get(1), 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);
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- //新风机的拟合数据插入缓存
|
|
|
-// Tempscatterpoint temp = new Tempscatterpoint();
|
|
|
-// temp.setStation(station);
|
|
|
-// temp.setWindturbineid(wtId);
|
|
|
-// temp.setTime(time);
|
|
|
-// temp.setScatter(JSON.toJSONString(scatter));
|
|
|
-// temp.setLineactual(JSON.toJSONString(actual));
|
|
|
-// temp.setLineoptimal(JSON.toJSONString(optimal));
|
|
|
-// tempscatterpointService.insertItem(temp);
|
|
|
-// }
|
|
|
-
|
|
|
- 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);
|
|
|
+
|
|
|
+ //新风机的拟合数据插入缓存
|
|
|
+// Powercurvefitting temp = new Powercurvefitting();
|
|
|
+// temp.setStation(station);
|
|
|
+// temp.setWindturbineid(wtId);
|
|
|
+// temp.setTime(time);
|
|
|
+// System.out.println("===" + Base64Util.encode(scatter.toString()).length());
|
|
|
+// temp.setScatter(Base64Util.encode(scatter.toString()));
|
|
|
+// temp.setLineactual(Base64Util.encode(actual.toString()));
|
|
|
+// temp.setLineoptimal(Base64Util.encode(optimal.toString()));
|
|
|
+// temp.setRemark("1");
|
|
|
+// temp.setCategory("1");
|
|
|
+// powercurvefittingService.insertItem(temp);
|
|
|
+
|
|
|
+ } 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());
|
|
|
+ }
|
|
|
}
|