|
@@ -0,0 +1,138 @@
|
|
|
+package com.gyee.runeconomy.service;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
+import com.gyee.common.util.DateUtils;
|
|
|
+import com.gyee.common.util.DoubleUtils;
|
|
|
+import com.gyee.common.util.SortUtils;
|
|
|
+import com.gyee.common.vo.curve.CurveVo;
|
|
|
+import com.gyee.runeconomy.init.CacheContext;
|
|
|
+import com.gyee.runeconomy.model.auto.*;
|
|
|
+import com.gyee.runeconomy.service.auto.IProEconWtCurveFittingMonthService;
|
|
|
+import com.gyee.runeconomy.service.auto.IProEconWtCurveFittingService;
|
|
|
+import com.gyee.runeconomy.service.auto.IProEconWtCurveFittingYearService;
|
|
|
+import com.gyee.runeconomy.util.redis.RedisService;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class PerformanceCurvefittingService {
|
|
|
+
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RedisService redisService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProEconWtCurveFittingService proEconWtCurveFittingService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProEconWtCurveFittingMonthService proEconWtCurveFittingMonthService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IProEconWtCurveFittingYearService proEconWtCurveFittingYearService;
|
|
|
+
|
|
|
+
|
|
|
+ public Map<String, List<CurveVo>> curvefitting(String windpowerstationIds, String type,String dateType) {
|
|
|
+ Map<String, List<CurveVo>> resultMap = new HashMap<>();
|
|
|
+ Map<String, ProBasicEquipment> wtmap = CacheContext.wtmap;
|
|
|
+
|
|
|
+ String zbzgl = redisService.get("ZBZGL");
|
|
|
+ Map<String, Map<Double, Double>> zbzglMap = JSONObject.parseObject(zbzgl, new TypeReference<Map<String, Map<Double, Double>>>() {
|
|
|
+ });
|
|
|
+ Map<String,Map<Double,Double>> zzsglMap = getWtCurveFitting(windpowerstationIds,dateType);
|
|
|
+ if (type.equals("0")){
|
|
|
+ List<CurveVo> tempList = new ArrayList<>();
|
|
|
+ if (zzsglMap.containsKey(windpowerstationIds)){
|
|
|
+ Map<Double, Double> zsglmap = zzsglMap.get(windpowerstationIds);
|
|
|
+ Map<Double, Double> bzglmap = zbzglMap.get(wtmap.get(windpowerstationIds).getModelId());
|
|
|
+ Set<Double> speeds = zsglmap.keySet();
|
|
|
+ speeds.stream().forEach(speed->{
|
|
|
+ CurveVo vo = new CurveVo();
|
|
|
+ vo.setWtid(windpowerstationIds);
|
|
|
+ vo.setSpeed(speed);
|
|
|
+ vo.setTheorypower(DoubleUtils.keepPrecision(zsglmap.get(speed),2));
|
|
|
+ vo.setEnsurepower(DoubleUtils.keepPrecision(bzglmap.containsKey(speed)?bzglmap.get(speed):zsglmap.get(speed),2));
|
|
|
+ tempList.add(vo);
|
|
|
+ });
|
|
|
+ SortUtils.sort(tempList,"speed",SortUtils.ASC);
|
|
|
+ resultMap.put(windpowerstationIds,tempList);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String[] wts = windpowerstationIds.split(",");
|
|
|
+ Arrays.stream(wts).forEach(wt->{
|
|
|
+ List<CurveVo> tempList = new ArrayList<>();
|
|
|
+ if(zzsglMap.get(wt) == null || zzsglMap.size() == 0)
|
|
|
+ return;
|
|
|
+ Map<Double, Double> zsglmap = zzsglMap.get(wt);
|
|
|
+ Set<Double> speeds = zsglmap.keySet();
|
|
|
+ speeds.stream().forEach(speed->{
|
|
|
+ CurveVo vo = new CurveVo();
|
|
|
+ vo.setWtid(wt);
|
|
|
+ vo.setSpeed(speed);
|
|
|
+ vo.setTheorypower(DoubleUtils.keepPrecision(zsglmap.get(speed),2));
|
|
|
+ tempList.add(vo);
|
|
|
+ });
|
|
|
+ SortUtils.sort(tempList,"speed",SortUtils.ASC);
|
|
|
+ resultMap.put(wt,tempList);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取风机拟合曲线
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private Map<String, Map<Double, Double>> getWtCurveFitting(String powerstationIds, String dateType) {
|
|
|
+
|
|
|
+ String[] wts = powerstationIds.split(",");
|
|
|
+ Map<String, Map<Double, Double>> zzsglMap = new HashMap<>();
|
|
|
+ String strdate = DateUtils.toDate1(new Date());
|
|
|
+ Date date = DateUtils.parseDate(strdate);
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+
|
|
|
+ int year = calendar.get(Calendar.YEAR);
|
|
|
+ int month = calendar.get(Calendar.MONTH) + 1;
|
|
|
+ Arrays.stream(wts).forEach(wt -> {
|
|
|
+ Map<Double, Double> doubleMap = new HashMap<>();
|
|
|
+ switch (dateType) {
|
|
|
+
|
|
|
+ case "1":
|
|
|
+ List<ProEconWtCurveFitting> daylist = proEconWtCurveFittingService.getProEconWtCurveFittingList(wt,date);
|
|
|
+
|
|
|
+ daylist.stream().forEach(w -> {
|
|
|
+ doubleMap.put(w.getSpeed(), w.getActualPower());
|
|
|
+ });
|
|
|
+ zzsglMap.put(wt, doubleMap);
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ List<ProEconWtCurveFittingMonth> monthlist = proEconWtCurveFittingMonthService.getProEconWtCurveFittingMonthList(wt,String.valueOf(month),String.valueOf(year));
|
|
|
+
|
|
|
+ monthlist.stream().forEach(w -> {
|
|
|
+ doubleMap.put(w.getSpeed(), w.getActualPower());
|
|
|
+ });
|
|
|
+ zzsglMap.put(wt, doubleMap);
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ List<ProEconWtCurveFittingYear> yearslist = proEconWtCurveFittingYearService.getProEconWtCurveFittingYearList(wt,String.valueOf(year));
|
|
|
+
|
|
|
+ yearslist.stream().forEach(w -> {
|
|
|
+ doubleMap.put(w.getSpeed(), w.getActualPower());
|
|
|
+ });
|
|
|
+ zzsglMap.put(wt, doubleMap);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ return zzsglMap;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|