|
@@ -1,17 +1,19 @@
|
|
|
package com.gyee.power.fitting.service.custom.ratedpower;
|
|
|
|
|
|
+import com.gyee.power.fitting.common.spring.InitialRunner;
|
|
|
+import com.gyee.power.fitting.common.util.DateUtil;
|
|
|
import com.gyee.power.fitting.common.util.FileUtil;
|
|
|
-import com.gyee.power.fitting.model.Powerfittinganalysis;
|
|
|
+import com.gyee.power.fitting.model.*;
|
|
|
import com.gyee.power.fitting.model.custom.PowerPointData;
|
|
|
-import com.gyee.power.fitting.service.PowerfittinganalysisService;
|
|
|
+import com.gyee.power.fitting.service.ProEconPowerFittingAnalySisService;
|
|
|
import lombok.val;
|
|
|
+import org.apache.commons.collections4.list.TreeList;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* 额定功率分析
|
|
@@ -21,25 +23,39 @@ import java.util.Map;
|
|
|
public class RatedPowerService {
|
|
|
|
|
|
@Resource
|
|
|
- private PowerfittinganalysisService powerService;
|
|
|
+ private ProEconPowerFittingAnalySisService powerService;
|
|
|
|
|
|
public Object ratePowerAnalysis(String ids) {
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
- List<Powerfittinganalysis> list = powerService.selectListByIds(ids);
|
|
|
- if (list == null || list.size() == 0)
|
|
|
+ Map<String, ProEconEquipmentmodel> eqMap = InitialRunner.equipmentNewMap;
|
|
|
+ Map<String, ProBasicEquipment> wtMap = InitialRunner.wtNewMap;
|
|
|
+ List<ProEconPowerFittingAnalySis> list = powerService.listByIds(Arrays.asList(ids.split(",")));
|
|
|
+ if (list.size() == 0) {
|
|
|
return result;
|
|
|
+ }
|
|
|
|
|
|
List<PowerPointData> all = new ArrayList<>();
|
|
|
- Map<String, Double> map = new HashMap<>();
|
|
|
- for (Powerfittinganalysis obj : list){
|
|
|
- List<PowerPointData> ls = csvParse(obj);
|
|
|
- all.addAll(ls);
|
|
|
- map.put(obj.getWindturbine(), ls.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble());
|
|
|
+ TreeList<Object> lst = new TreeList<>();
|
|
|
+ for (ProEconPowerFittingAnalySis obj : list){
|
|
|
+ String[] spid = obj.getProcessid().split(",");
|
|
|
+ for (String id : spid){
|
|
|
+ TreeMap<String, Object> mp = new TreeMap<>();
|
|
|
+ ProEconPowerFittingAnalySis item = powerService.getById(id);
|
|
|
+ List<PowerPointData> ls = csvParse(item);
|
|
|
+ all.addAll(ls);
|
|
|
+ double avg = ls.size() > 0 ? ls.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble() : 0;
|
|
|
+ mp.put("wt", InitialRunner.wtNewMap.get(item.getWindturbineId()).getNemCode());
|
|
|
+ mp.put("avg", new BigDecimal(avg).setScale(0, RoundingMode.CEILING).doubleValue());
|
|
|
+ mp.put("count", ls.size());
|
|
|
+ lst.add(mp);
|
|
|
+ }
|
|
|
}
|
|
|
- double avgData = all.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble();
|
|
|
+ double avg = all.size() > 0 ? all.stream().mapToDouble(PowerPointData::getPower).average().getAsDouble() : 0;
|
|
|
+ double avgData = new BigDecimal(avg).setScale(0, RoundingMode.CEILING).doubleValue();
|
|
|
|
|
|
result.put("avg", avgData);
|
|
|
- result.put("data", map);
|
|
|
+ result.put("data", lst);
|
|
|
+ result.put("power", eqMap.get(wtMap.get(list.get(0).getWindturbineId()).getModelId()).getPowerProduction());
|
|
|
|
|
|
return result;
|
|
|
}
|
|
@@ -49,14 +65,16 @@ public class RatedPowerService {
|
|
|
* @param obj
|
|
|
* @return
|
|
|
*/
|
|
|
- private List<PowerPointData> csvParse(Powerfittinganalysis obj){
|
|
|
+ private List<PowerPointData> csvParse(ProEconPowerFittingAnalySis obj){
|
|
|
List<PowerPointData> list = new ArrayList<>();
|
|
|
val content = FileUtil.readFile(obj.getPath(), true);
|
|
|
for (int i = 1; i < content.size(); i++){
|
|
|
String[] split = content.get(i).split(",");
|
|
|
PowerPointData data = new PowerPointData(split, false);
|
|
|
- if (data.getSpeed() >= 12.0)
|
|
|
+ if (data.getSpeed() >= 12.0){
|
|
|
+ data.setTime(DateUtil.format(data.getTime(), DateUtil.DATE_PATTERN));
|
|
|
list.add(data);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
return list;
|