|
@@ -17,7 +17,6 @@ import com.gyee.power.fitting.model.custom.PowerPointData;
|
|
|
import com.gyee.power.fitting.model.custom.TableTitle;
|
|
|
import com.gyee.power.fitting.model.custom.TsDoubleData;
|
|
|
import com.gyee.power.fitting.service.PowerfittinganalysisService;
|
|
|
-import com.gyee.power.fitting.service.PowerlossinfoService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -36,165 +35,10 @@ public class FiveLossService {
|
|
|
|
|
|
@Resource
|
|
|
private PowerfittinganalysisService analysisService;
|
|
|
- @Resource
|
|
|
- private PowerlossinfoService lossInfoService;
|
|
|
+
|
|
|
@Resource
|
|
|
private RemoteServiceBuilder remoteService;
|
|
|
|
|
|
- /**
|
|
|
- * 五项损失查询
|
|
|
- *
|
|
|
- * @param station 场站
|
|
|
- * @param project 期次
|
|
|
- * @param line 线路
|
|
|
- * @param type 1:场站 2:期次 3:线路
|
|
|
- * @return
|
|
|
- */
|
|
|
- public Map<String, Object> fiveLoss(String station, List<String> project, List<String> line, Date st, Date et, String type) {
|
|
|
- Map<String, Object> promise = new HashMap<>();
|
|
|
- Map<String, String> stationMap = InitialRunner.stationMap;
|
|
|
- Map<String, Windturbine> wtMap = InitialRunner.wtMap;
|
|
|
- Map<String, Project> pMap = InitialRunner.projectMap;
|
|
|
- Map<String, Line> lMap = InitialRunner.lineMap;
|
|
|
-
|
|
|
- List<Powerlossinfo> list = lossInfoService.selectList(station, project, line, st, et);
|
|
|
- if (list == null || list.size() == 0)
|
|
|
- return promise;
|
|
|
-
|
|
|
- Map<String, List<Powerlossinfo>> collect = null;
|
|
|
- if (type.equals("1"))
|
|
|
- collect = list.stream().collect(Collectors.groupingBy(Powerlossinfo::getStationid));
|
|
|
- else if (type.equals("2"))
|
|
|
- collect = list.stream().collect(Collectors.groupingBy(Powerlossinfo::getProjectid));
|
|
|
- else if (type.equals("3"))
|
|
|
- collect = list.stream().collect(Collectors.groupingBy(Powerlossinfo::getLineid));
|
|
|
- else if (line.size() > 0)
|
|
|
- collect = list.stream().collect(Collectors.groupingBy(Powerlossinfo::getLineid));
|
|
|
- else if (project.size() > 0)
|
|
|
- collect = list.stream().collect(Collectors.groupingBy(Powerlossinfo::getProjectid));
|
|
|
- else
|
|
|
- collect = list.stream().collect(Collectors.groupingBy(Powerlossinfo::getWindturbineid));
|
|
|
-
|
|
|
- List<FjjxbVo> result = collect.entrySet()
|
|
|
- .stream()
|
|
|
- .map(entry -> {
|
|
|
- String key = entry.getKey();
|
|
|
- List<Powerlossinfo> value = entry.getValue();
|
|
|
- FjjxbVo vo = new FjjxbVo().toData(value);
|
|
|
- vo.setId(key);
|
|
|
- if (type.equals("1"))
|
|
|
- vo.setName(stationMap.get(key));
|
|
|
- else if (type.equals("2"))
|
|
|
- vo.setName(pMap.get(key).getName());
|
|
|
- else if (type.equals("3"))
|
|
|
- vo.setName(lMap.get(key).getName());
|
|
|
- else if (line.size() > 0)
|
|
|
- vo.setName(lMap.get(key).getName());
|
|
|
- else if (project.size() > 0)
|
|
|
- vo.setName(pMap.get(key).getName());
|
|
|
- else
|
|
|
- vo.setName(wtMap.get(key).getName());
|
|
|
- return vo;
|
|
|
- }).sorted(Comparator.comparing(FjjxbVo::getId)).collect(Collectors.toList());
|
|
|
-
|
|
|
- /** 添加标题 **/
|
|
|
- List<FixedVo> fxList = AnnotationTool.getFixedVoList(FjjxbVo.class);
|
|
|
- List<TableTitle> lt = fxList.stream().map(d -> new TableTitle(d.getName(), d.getDes())).collect(Collectors.toList());
|
|
|
-
|
|
|
- promise.put("title", lt);
|
|
|
- promise.put("data", result);
|
|
|
-
|
|
|
- return promise;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- /** 根据已缓存的文件计算损失电量
|
|
|
- * 明细状态
|
|
|
- * 0-待机 1-手动停机 2-正常发电 3-缺陷降出力 4-限电降出力 5-限电停机 6-故障停机
|
|
|
- * 7-场内受累停机 8-检修停机 9-场内受累检修 10-电网受累 11-环境受累 12-风机离线
|
|
|
- */
|
|
|
- @Async
|
|
|
- @Transactional
|
|
|
- public void fiveLossCal() {
|
|
|
- log.info("======风机绩效榜计算开始.............");
|
|
|
- Map<String, Windturbine> wtmap = InitialRunner.wtMap;
|
|
|
- Map<String, Map<Double, Double>> zsglmap = InitialRunner.zsllglMap;
|
|
|
-
|
|
|
- List<Powerfittinganalysis> analyses = analysisService.selectListByIsCal(Constants.DATA_PREPARE, 0);
|
|
|
- if (analyses.size() == 0){
|
|
|
- log.info("======风机榜效帮计算结束,Powerfittinganalysis数据为空.............");
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- for (Powerfittinganalysis p : analyses) {
|
|
|
- List<Powerlossinfo> result = new ArrayList<>();
|
|
|
- Windturbine wt = wtmap.get(p.getWindturbine());
|
|
|
- List<String> content = FileUtil.readFile(p.getPath(), true);
|
|
|
- if (content.size() == 0){
|
|
|
- log.info("======风机榜效帮计算结束,文件内容为空.............");
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- log.info("======风机绩效榜计算:" + p.getWindturbine());
|
|
|
- content.remove(0); //去掉标题栏
|
|
|
- int count = 86400 / p.getInterp(); //一天86400s 一天的条数
|
|
|
- List<List<String>> coll = CollectUtil.groupListByQty(content, count);
|
|
|
- coll.forEach(ls -> {
|
|
|
- double rfdl = 0; //日发电量
|
|
|
- double gzssdl = 0;//故障损失电量
|
|
|
- double jhjxssdl = 0;//计划检修损失电量
|
|
|
- double fjhjxssdl = 0;//非计划检修电量
|
|
|
- double xdssdl = 0;//限电损失电量
|
|
|
- double slssdl = 0;//受累损失电量
|
|
|
- double xnssdl = 0;//性能损失电量
|
|
|
-
|
|
|
- List<PowerPointData> pdl = ls.stream().map(mp -> new PowerPointData(mp.split(","), false)).collect(Collectors.toList());
|
|
|
- double zcfd = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 2); //正常发电
|
|
|
- xdssdl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 5); //限电损失电量
|
|
|
- double qxjcl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 3); //缺陷降出力损失电量
|
|
|
- double xdjcl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 4); //限电降出力损失电量
|
|
|
- double cnsltj = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 7); //场内受累停机损失电量
|
|
|
- double cnsljx = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 9); //场内受累检修损失电量
|
|
|
- double dwsl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 10); //电网受累损失电量
|
|
|
- double hjsl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 11); //环境受累损失电量
|
|
|
-
|
|
|
- gzssdl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 6);
|
|
|
- jhjxssdl = generalLoss(pdl, zsglmap.get(p.getWindturbine()), p.getInterp(), 8);
|
|
|
- fjhjxssdl = gzssdl;
|
|
|
- xdssdl = xdssdl + xdjcl;
|
|
|
- slssdl = cnsltj + dwsl + hjsl + cnsljx + cnsljx;
|
|
|
- xnssdl = qxjcl + zcfd;
|
|
|
- rfdl = pdl.get(pdl.size() - 1).getDl();
|
|
|
- double llgdl = rfdl + gzssdl + jhjxssdl + fjhjxssdl + xdssdl + slssdl + xnssdl;
|
|
|
-
|
|
|
- Powerlossinfo loss = new Powerlossinfo();
|
|
|
- loss.setLineid(wt.getLineid());
|
|
|
- loss.setProjectid(wt.getProjectid());
|
|
|
- loss.setRecorddate(DateUtil.parseStrtoDate(pdl.get(0).getTime(), DateUtil.DATE_PATTERN));
|
|
|
- loss.setStationid(wt.getWindpowerstationid());
|
|
|
- loss.setWindturbineid(wt.getId());
|
|
|
- loss.setGenecapacity(rfdl);
|
|
|
- loss.setTherogenecapacity(llgdl);
|
|
|
- loss.setDayjhjxssdl(jhjxssdl);
|
|
|
- loss.setDayfjhjxssdl(fjhjxssdl);
|
|
|
- loss.setDaygzssdl(gzssdl);
|
|
|
- loss.setDayxdssdl(xdssdl);
|
|
|
- loss.setDayxnssdl(xnssdl);
|
|
|
- loss.setDayslssdl(slssdl);
|
|
|
- loss.setSpeed(pdl.stream().mapToDouble(PowerPointData::getSpeed).average().getAsDouble());
|
|
|
- result.add(loss);
|
|
|
- });
|
|
|
-
|
|
|
- //保存之前删除已有的五损数据
|
|
|
- lossInfoService.deleteBatch(wt.getId(), result.stream().map(m -> m.getRecorddate()).collect(Collectors.toList()));
|
|
|
- lossInfoService.insertBatch(result);
|
|
|
- }
|
|
|
- //更新已经计算过的文件数据
|
|
|
- analyses.forEach((entity) -> entity.setIscal(1));
|
|
|
- analysisService.updateBatchById(analyses);
|
|
|
- log.info("======风机榜效帮计算结束.............");
|
|
|
- }
|
|
|
-
|
|
|
|
|
|
/**
|
|
|
* 损失电量计算 eg: 1.5MW 一小时发电:1500kWh 一分钟发电:1500/60 == 25kW
|
|
@@ -239,116 +83,6 @@ public class FiveLossService {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 通过线上实时计算五损数据
|
|
|
- * @param st 开始时间
|
|
|
- * @param et 结束时间
|
|
|
- * @param interval 等间隔时间
|
|
|
- */
|
|
|
- @Async
|
|
|
- @Transactional
|
|
|
- public void fiveLossCalByLine(long st, long et, int interval){
|
|
|
- List<Windpowerstation> wpList = InitialRunner.wpList;
|
|
|
- Map<String, Windturbine> wtmap = InitialRunner.wtMap;
|
|
|
- Map<String, List<Windturbinetestingpointai2>> pointMap = InitialRunner.pointMap;
|
|
|
- Map<String, List<Modelpowerdetails>> modelmap = InitialRunner.modelPowerDetailMap;
|
|
|
-
|
|
|
- List<Powerlossinfo> result = new ArrayList<>();
|
|
|
- pointMap.forEach((k, v) -> {
|
|
|
- Windturbine wt = wtmap.get(k);
|
|
|
- String speed = v.stream().filter(f -> f.getUniformcode().equals(Constants.CODE_POINT_SPEED)).findFirst().get().getId();
|
|
|
- String power = v.stream().filter(f -> f.getUniformcode().equals(Constants.CODE_POINT_POWER)).findFirst().get().getId();
|
|
|
- String fdl = v.stream().filter(f -> f.getUniformcode().equals(Constants.CODE_POINT_RFDL)).findFirst().get().getId();
|
|
|
- String status = v.stream().filter(f -> f.getUniformcode().equals(Constants.CODE_POINT_MXZT)).findFirst().get().getId();
|
|
|
-
|
|
|
- List<TsDoubleData> speedLS = remoteService.adapter().getHistorySnap(speed, st, et, interval);
|
|
|
- List<TsDoubleData> powerLS = remoteService.adapter().getHistorySnap(power, st, et, interval);
|
|
|
- JSONObject rfdlObj = remoteService.adapter().getHistorySection(fdl, et);
|
|
|
- List<TsDoubleData> statusLS = remoteService.adapter().getHistorySnap(status, st, et, interval);
|
|
|
-
|
|
|
- double rfdl = 0; //日发电量
|
|
|
- double gzssdl = 0;//故障损失电量
|
|
|
- double jhjxssdl = 0;//计划检修损失电量
|
|
|
- double fjhjxssdl = 0;//非计划检修电量
|
|
|
- double xdssdl = 0;//限电损失电量
|
|
|
- double slssdl = 0;//受累损失电量
|
|
|
- double xnssdl = 0;//性能损失电量
|
|
|
-
|
|
|
- double zcfd = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 2); //正常发电
|
|
|
- xdssdl = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 5); //限电损失电量
|
|
|
- double qxjcl = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()),interval, 3); //缺陷降出力损失电量
|
|
|
- double xdjcl = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 4); //限电降出力损失电量
|
|
|
- double cnsltj = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 7); //场内受累停机损失电量
|
|
|
- double cnsljx = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 9); //场内受累检修损失电量
|
|
|
- double dwsl = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 10); //电网受累损失电量
|
|
|
- double hjsl = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 11); //环境受累损失电量
|
|
|
-
|
|
|
- gzssdl = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 6);
|
|
|
- jhjxssdl = generalLossLine(statusLS, speedLS, powerLS, modelmap.get(wt.getModelid()), interval, 8);
|
|
|
- fjhjxssdl = gzssdl;
|
|
|
- xdssdl = xdssdl + xdjcl;
|
|
|
- slssdl = cnsltj + dwsl + hjsl + cnsljx + cnsljx;
|
|
|
- xnssdl = qxjcl + zcfd;
|
|
|
- rfdl = rfdlObj.getJSONObject(fdl).getDoubleValue("doubleValue");
|
|
|
-
|
|
|
- double llgdl = rfdl + gzssdl + jhjxssdl + fjhjxssdl + xdssdl + slssdl + xnssdl;
|
|
|
-
|
|
|
- Powerlossinfo loss = new Powerlossinfo();
|
|
|
- loss.setLineid(wt.getLineid());
|
|
|
- loss.setProjectid(wt.getProjectid());
|
|
|
- loss.setRecorddate(DateUtil.parseStrtoDate(DateUtil.format(st, DateUtil.DATE_PATTERN), DateUtil.DATE_PATTERN));
|
|
|
- loss.setStationid(wt.getWindpowerstationid());
|
|
|
- loss.setWindturbineid(wt.getId());
|
|
|
- loss.setGenecapacity(rfdl);
|
|
|
- loss.setTherogenecapacity(llgdl);
|
|
|
- loss.setDayjhjxssdl(jhjxssdl);
|
|
|
- loss.setDayfjhjxssdl(fjhjxssdl);
|
|
|
- loss.setDaygzssdl(gzssdl);
|
|
|
- loss.setDayxdssdl(xdssdl);
|
|
|
- loss.setDayxnssdl(xnssdl);
|
|
|
- loss.setDayslssdl(slssdl);
|
|
|
- loss.setSpeed(speedLS.stream().mapToDouble(TsDoubleData::getDoubleValue).average().getAsDouble());
|
|
|
- result.add(loss);
|
|
|
-
|
|
|
- //保存之前删除已有的五损数据
|
|
|
- lossInfoService.deleteByWtIdAndDate(wt.getId(), loss.getRecorddate());
|
|
|
- });
|
|
|
-
|
|
|
- lossInfoService.insertBatch(result);
|
|
|
- }
|
|
|
-
|
|
|
- private double generalLossLine(List<TsDoubleData> ztmxData, List<TsDoubleData> speedData, List<TsDoubleData> powerData, List<Modelpowerdetails> zsglData, int interval, double status) {
|
|
|
- double ssdl = 0.0;
|
|
|
- List<Modelpowerdetails> theoryData = zsglData.stream().filter(f -> f.getTheorypower() > 0).collect(Collectors.toList());
|
|
|
- if (ztmxData.size() == powerData.size()){
|
|
|
- if (status == 2.0 || status == 3.0 || status == 4.0 || status == 9.0 || status == 10.0 || status == 11.0) {
|
|
|
- for (int i = 0; i < ztmxData.size(); i++) {
|
|
|
- for (int j = 0; j < theoryData.size(); j++) {
|
|
|
- if (String.format("%.2f", speedData.get(i).getDoubleValue()).equals(String.format("%.2f", theoryData.get(j).getSpeed()))) {
|
|
|
- double zsgl = theoryData.get(j).getTheorypower();
|
|
|
- double power = powerData.get(i).getDoubleValue();
|
|
|
- double temp = (zsgl - power) > 0 ? zsgl - power : 0;
|
|
|
- ssdl = ssdl + (temp / 60) * (interval / 60);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- for (int i = 0; i < ztmxData.size(); i++) {
|
|
|
- for (int j = 0; j < theoryData.size(); j++) {
|
|
|
- if (String.format("%.2f", speedData.get(i).getDoubleValue()).equals(String.format("%.2f", theoryData.get(j).getSpeed()))) {
|
|
|
- double zsgl = theoryData.get(j).getTheorypower();
|
|
|
- ssdl = ssdl + (zsgl / 60) * (interval / 60);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- return ssdl > 0 ? ssdl : 0;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 使用文件,通过自诉案功率计算五损数据
|
|
|
* @param ids 准备的数据ID
|
|
|
*/
|