12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964 |
- package com.gyee.generation.service;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
- import com.gyee.common.contant.ContantXk;
- import com.gyee.common.model.PointData;
- import com.gyee.generation.init.CacheContext;
- import com.gyee.generation.model.auto.*;
- import com.gyee.generation.model.vo.*;
- import com.gyee.generation.service.auto.*;
- import com.gyee.generation.util.DateUtils;
- import com.gyee.generation.util.DeviationRateUtil;
- import com.gyee.generation.util.StringUtils;
- import com.gyee.generation.util.realtimesource.IEdosUtil;
- import com.gyee.generation.util.realtimesource.math.LineUtil;
- import com.gyee.generation.util.redis.RedisService;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import javax.annotation.Resource;
- import java.util.*;
- import java.util.stream.Collectors;
- @Service
- public class PowerCurveFittingByTimeService {
- private static final Logger logger = LoggerFactory.getLogger(PowerCurveFittingByTimeService.class);
- @Resource
- private IEdosUtil edosUtil;
- @Value("${curvefitting.dimension}")
- private Integer dimension;
- @Value("${curvefitting.scale}")
- private Double scale;
- @Value("${initialcode}")
- private String initialcode;
- public Map<String, Double> windturbineCapacity;
- @Resource
- private RedisService redisService;
- @Resource
- private IProEconWtCurveFittingMonthService proEconWtCurveFittingMonthService;
- @Resource
- private IProEconWtCurveFittingYearService proEconWtCurveFittingYearService;
- @Resource
- private IProEconWtCurveFittingService proEconWtCurveFittingService;
- @Resource
- private IProEconCurveFittingMainService proEconCurveFittingMainService;
- @Resource
- private IProEconCurveFittingSubService proEconCurveFittingSubService;
- @Resource
- private IProEconCurveFittMonthMainService proEconCurveFittMonthMainService;
- @Resource
- private IProEconCurveFittMonthSubService proEconCurveFittMonthSubService;
- @Resource
- private IProEconWtPowerCurveFittingService proEconWtPowerCurveFittingService;
- @Resource
- private IProEconCurveFittYearSubService proEconCurveFittYearSubService;
- @Resource
- private IProEconCurveFittYearMainService proEconCurveFittYearMainService;
- public void cureFittingDay(Date recordDate,String wpId) throws Exception {
-
- Date end = DateUtils.addDays(DateUtils.truncate(recordDate), -1);
- Calendar c = Calendar.getInstance();
- c.setTime(end);
- Date begin = DateUtils.addDays(end, -6);
- List<ProBasicEquipment> wtls=new ArrayList<>();
- if(StringUtils.notEmp(wpId) && CacheContext.wpwtmap.containsKey(wpId))
- {
- wtls=CacheContext.wpwtmap.get(wpId);
- }else
- {
- wtls=CacheContext.wtls;
- }
- StringBuilder sb=new StringBuilder();
- for(ProBasicEquipment wt:wtls)
- {
- sb.append("'").append(wt.getId()).append("',");
- }
- String wtIds=sb.substring(0,sb.length()-1);
- proEconWtCurveFittingService.deleteProEconWtCurveFittingFByDay(DateUtils.truncate(recordDate),wtIds);
- proEconCurveFittingMainService.deleteProEconCurveFittingMainFByDay(DateUtils.truncate(recordDate),wtIds);
- proEconCurveFittingSubService.deleteProEconCurveFittingSubFByDay(DateUtils.truncate(recordDate),wtIds);
- Map<String, CureFittingVo> windMap = new HashMap<>();
-
- if (windturbineCapacity == null) {
- windturbineCapacity = new HashMap<>();
- Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
- for (ProBasicEquipment windturbine : CacheContext.wtls) {
- if (modelMap.containsKey(windturbine.getModelId())) {
- windturbineCapacity.put(windturbine.getId(), modelMap.get(windturbine.getModelId()).getPowerProduction());
- }
- }
- }
- for (ProBasicEquipment wt : wtls) {
- String windturbineId = wt.getId();
- if(wt.getWindpowerstationId().contains(WpType.GDC.id))
- {
- continue;
- }
- Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
-
- String pointIdGL = null;
-
- String pointIdZT = null;
- String pointIdFS = null;
- if (windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSFS)) {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
- }
- if (windturbinetestingpointnewMap.containsKey(ContantXk.CJ_SSGL)) {
- pointIdGL = windturbinetestingpointnewMap.get(ContantXk.CJ_SSGL).getNemCode();
- }
- if (windturbinetestingpointnewMap.containsKey(ContantXk.MXZT)) {
- pointIdZT = windturbinetestingpointnewMap.get(ContantXk.MXZT).getNemCode();
- }
- CureFittingVo item = new CureFittingVo();
- item.setPointIdFS(pointIdFS);
- item.setPointIdZT(pointIdZT);
- item.setPointIdGL(pointIdGL);
-
- if (CacheContext.wtstandardmap.containsKey(wt.getId())) {
- item.setStandardId(CacheContext.wtstandardmap.get(wt.getId()));
- } else {
- item.setStandardId(wt.getId());
- }
- windMap.put(windturbineId, item);
- }
- for (String key : windMap.keySet()) {
-
- windMap.get(key).setYsjglPoints(new ArrayList<>());
- windMap.get(key).setYzyglPoints(new ArrayList<>());
- windMap.get(key).setRsjglPoints(new ArrayList<>());
- windMap.get(key).setRzyglPoints(new ArrayList<>());
- windMap.get(key).setNsjglPoints(new ArrayList<>());
- windMap.get(key).setNzyglPoints(new ArrayList<>());
- if (windMap.get(key).getPointIdGL() == null || windMap.get(key).getPointIdFS() == null || windMap.get(key).getPointIdZT() == null) {
- logger.info(key);
- continue;
- }
-
- curveFittingBuilder(begin, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(), windMap.get(key).getRsjglPoints(), windMap.get(key).getRzyglPoints(), key);
- List<PointVo> vos = windMap.get(key).getRsjglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
- windMap.get(key).setRsjglPoints(vos);
- vos = windMap.get(key).getRzyglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
- windMap.get(key).setRzyglPoints(vos);
- }
- List<ProEconCurveFittingMain> mainls=new ArrayList<>();
- for (String key : windMap.keySet()) {
- Double modelpower = 1500.0;
- if (windturbineCapacity.containsKey(key)) {
- modelpower = windturbineCapacity.get(key);
- }
-
- List<PointVo> dayLastMonthPoints = new ArrayList<>();
-
- List<PointVo> dayLastYearPoints = new ArrayList<>();
-
- List<PointVo> dayStandardPoints = new ArrayList<>();
-
- List<PointVo> bzglpowerPoints = new ArrayList<>();
- if (CacheContext.wtstandardmap.containsKey(key)) {
- String standardId = CacheContext.wtstandardmap.get(key);
- if (StringUtils.notEmp(standardId)) {
- if (windMap.containsKey(key)) {
- dayStandardPoints = windMap.get(standardId).getRsjglPoints();
- }
- }
- }
- Date d1 = DateUtils.addDays(recordDate, -1);
- Date d2 = DateUtils.addYears(recordDate, -1);
- QueryWrapper<ProEconWtCurveFitting> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("record_date",d1).eq("windturbine_id",key);
- List<ProEconWtCurveFitting> wcfls = proEconWtCurveFittingService.list(queryWrapper)
- .stream()
- .sorted(Comparator.comparing(ProEconWtCurveFitting::getSpeed)).collect(Collectors.toList());
- dayBuildPoints(wcfls, dayLastMonthPoints);
- QueryWrapper<ProEconWtCurveFitting> queryWrapper2 = new QueryWrapper<>();
- queryWrapper2.eq("record_date",d2).eq("windturbine_id",key);
- wcfls = proEconWtCurveFittingService.list(queryWrapper2).stream()
- .sorted(Comparator.comparing(ProEconWtCurveFitting::getSpeed)).collect(Collectors.toList());
-
- dayBuildPoints(wcfls, dayLastMonthPoints);
- if (CacheContext.wtmap.containsKey(key)) {
- String modelid = CacheContext.wtmap.get(key).getModelId();
- if (StringUtils.notEmp(modelid)) {
-
- if (CacheContext.theoreticalPowerMap.containsKey(modelid)) {
- for (Double speed : CacheContext.theoreticalPowerMap.get(modelid).keySet()) {
- PointVo point = new PointVo();
- point.setX(speed);
- point.setY(CacheContext.theoreticalPowerMap.get(modelid).get(speed).getEnsurePower());
- bzglpowerPoints.add(point);
- }
- }
- }
- }
-
- QueryWrapper<ProEconCurveFittingMain> queryWrapper3 = new QueryWrapper<>();
- queryWrapper3.eq("record_date",recordDate).eq("windturbine_id",key);
- Optional<ProEconCurveFittingMain> cfmdayo = proEconCurveFittingMainService.list(queryWrapper3).stream()
- .findFirst();
- ProEconCurveFittingMain cfmday;
- if (cfmdayo.isPresent()) {
- cfmday = cfmdayo.get();
- QueryWrapper<ProEconCurveFittingMain> wrapper = new QueryWrapper<>();
- wrapper.eq("id", cfmday.getId());
- proEconCurveFittingMainService.remove(wrapper);
- }
- cfmday = new ProEconCurveFittingMain();
- cfmday.setWindturbineId(key);
- cfmday.setRecordDate(DateUtils.truncate(recordDate));
-
- cfmday.setDeviationRate1(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), windMap.get(key).getRzyglPoints(), modelpower));
-
- cfmday.setDeviationRate2(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), bzglpowerPoints, modelpower));
-
- cfmday.setDeviationRate3(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRzyglPoints(), bzglpowerPoints, modelpower));
-
- cfmday.setMonthDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), dayLastMonthPoints, modelpower));
-
- cfmday.setYearDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), dayLastYearPoints, modelpower));
-
- cfmday.setStandardDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), dayStandardPoints, modelpower));
- mainls.add(cfmday);
-
-
- List<ProEconCurveFittingSub> subls=new ArrayList<>();
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 3, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 4, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 5, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 6, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 7, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 8, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 9, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 10, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 11, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 12, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- subls.add(pLCBuild(key, recordDate, windMap, modelpower, 13, bzglpowerPoints, dayLastMonthPoints, dayLastYearPoints, dayStandardPoints));
- List<ProEconCurveFittingSub> templs=new ArrayList<>();
- for(ProEconCurveFittingSub vo:subls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconCurveFittingSubService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconCurveFittingSubService.saveBatch(templs);
- }
- insertPoints(recordDate, windMap.get(key).getRsjglPoints(), windMap.get(key).getRzyglPoints(), key);
- logger.info(key);
- }
- List<ProEconCurveFittingMain> templs=new ArrayList<>();
- for(ProEconCurveFittingMain vo:mainls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconCurveFittingMainService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconCurveFittingMainService.saveBatch(templs);
- }
- }
- public void cureFittingMonth(Date recordDate,String type,String wpId) throws Exception {
-
- Date end = DateUtils.addDays(DateUtils.truncate(recordDate), 1);
- Calendar c = Calendar.getInstance();
- c.setTime(recordDate);
- int day_year = c.get(Calendar.YEAR);
- int day_month = c.get(Calendar.MONTH) + 1;
- List<ProBasicEquipment> wtls=new ArrayList<>();
- if(StringUtils.notEmp(wpId) && CacheContext.wpwtmap.containsKey(wpId))
- {
- wtls=CacheContext.wpwtmap.get(wpId);
- }else
- {
- wtls=CacheContext.wtls;
- }
- StringBuilder sb=new StringBuilder();
- for(ProBasicEquipment wt:wtls)
- {
- sb.append("'").append(wt.getId()).append("',");
- }
- String wtIds=sb.substring(0,sb.length()-1);
- proEconWtCurveFittingMonthService.deleteProEconWtCurveFittingFByMonth(String.valueOf(day_year),String.valueOf(day_month),wtIds);
- proEconCurveFittMonthMainService.deleteProEconCurveFittMonthMainFByMonth(String.valueOf(day_year),String.valueOf(day_month), wtIds);
- proEconCurveFittMonthSubService.deleteProEconCurveFittMonthSubFByMonth(String.valueOf(day_year),String.valueOf(day_month),wtIds);
- c.set(Calendar.DAY_OF_MONTH, 1);
- Date begin = DateUtils.truncate(c.getTime());
-
- c.setTime(DateUtils.addMonths(begin, -1));
- int month_year = c.get(Calendar.YEAR);
- int month_month = c.get(Calendar.MONTH) + 1;
-
- c.setTime(DateUtils.addYears(begin, -1));
- int year_year = c.get(Calendar.YEAR);
- int year_month = c.get(Calendar.MONTH) + 1;
- Map<String, CureFittingVo> windMap = new HashMap<>();
- if (windturbineCapacity == null) {
- windturbineCapacity = new HashMap<>();
- Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
- for (ProBasicEquipment windturbine : CacheContext.wtls) {
- if (modelMap.containsKey(windturbine.getModelId())) {
- windturbineCapacity.put(windturbine.getId(), modelMap.get(windturbine.getModelId()).getPowerProduction());
- }
- }
- }
- for (ProBasicEquipment wt : wtls) {
- String windturbineId = wt.getId();
- if(wt.getWindpowerstationId().contains(WpType.GDC.id) )
- {
- continue;
- }
- Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
-
- String pointIdGL = windturbinetestingpointnewMap.get(ContantXk.CJ_SSGL).getNemCode();
-
- String pointIdZT = windturbinetestingpointnewMap.get(ContantXk.MXZT).getNemCode();
- String pointIdFS;
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- if (windturbinetestingpointnewMap.containsKey(ContantXk.FCCFTFS70)) {
- ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.FCCFTFS70);
- if (StringUtils.notEmp(point.getNemCode()) && !point.getNemCode().equals(initialcode)) {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.FCCFTFS70).getNemCode();
- } else {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
- }
- } else {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
- }
- } else {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
- }
- CureFittingVo item = new CureFittingVo();
- item.setPointIdFS(pointIdFS);
- item.setPointIdZT(pointIdZT);
- item.setPointIdGL(pointIdGL);
-
- if (CacheContext.wtstandardmap.containsKey(wt.getId())) {
- item.setStandardId(CacheContext.wtstandardmap.get(wt.getId()));
- } else {
- item.setStandardId(wt.getId());
- }
- windMap.put(windturbineId, item);
- }
- for (String key : windMap.keySet()) {
-
- windMap.get(key).setYsjglPoints(new ArrayList<>());
- windMap.get(key).setYzyglPoints(new ArrayList<>());
- windMap.get(key).setRsjglPoints(new ArrayList<>());
- windMap.get(key).setRzyglPoints(new ArrayList<>());
- windMap.get(key).setNsjglPoints(new ArrayList<>());
- windMap.get(key).setNzyglPoints(new ArrayList<>());
- if (windMap.get(key).getPointIdGL() == null || windMap.get(key).getPointIdFS() == null || windMap.get(key).getPointIdZT() == null) {
- logger.info(key);
- continue;
- }
-
- curveFittingBuilder(begin, end, dimension, scale, windMap.get(key).getPointIdGL(), windMap.get(key).getPointIdFS(), windMap.get(key).getPointIdZT(), windMap.get(key).getYsjglPoints(), windMap.get(key).getYzyglPoints(), key);
- List<PointVo> vos = windMap.get(key).getYsjglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
- windMap.get(key).setYsjglPoints(vos);
- vos = windMap.get(key).getYzyglPoints().stream().filter(it -> it.getX() >= 0 && it.getX() <= 25).sorted(Comparator.comparing(PointVo::getX)).collect(Collectors.toList());
- windMap.get(key).setYzyglPoints(vos);
- logger.info(key+"曲线拟合完成!");
- }
- logger.info("曲线拟合完成!");
- List<ProEconCurveFittMonthMain> mainls=new ArrayList<>();
- for (String key : windMap.keySet()) {
- Double modelpower = 1500.0;
- if (windturbineCapacity.containsKey(key)) {
- modelpower = windturbineCapacity.get(key);
- }
-
- List<PointVo> monthLastMonthPoints = new ArrayList<>();
-
- List<PointVo> monthLastYearPoints = new ArrayList<>();
-
- List<PointVo> monthStandardPoints = new ArrayList<>();
-
- List<PointVo> bzglpowerPoints = new ArrayList<>();
- if (CacheContext.wtstandardmap.containsKey(key)) {
- String standardId = CacheContext.wtstandardmap.get(key);
- if (StringUtils.notEmp(standardId)) {
- if (windMap.containsKey(key)) {
- monthStandardPoints = windMap.get(standardId).getYsjglPoints();
- }
- }
- }
- String stringyear = String.valueOf(day_year);
- String stringmonth = String.valueOf(day_month);
- String stringyear2 = String.valueOf(month_year);
- String stringmonth2 = String.valueOf(month_month);
- String stringyear3 = String.valueOf(year_year);
- String stringmonth3 = String.valueOf(year_month);
- QueryWrapper<ProEconWtCurveFittingMonth> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("year",stringyear2).eq("month",stringmonth2).eq("windturbine_id",key);
- List<ProEconWtCurveFittingMonth> wcfmls = proEconWtCurveFittingMonthService.list(queryWrapper).stream()
- .sorted(Comparator.comparing(ProEconWtCurveFittingMonth::getSpeed)).collect(Collectors.toList());
- monthBuildPoints(wcfmls, monthLastMonthPoints);
- QueryWrapper<ProEconWtCurveFittingMonth> queryWrapper2 = new QueryWrapper<>();
- queryWrapper2.eq("year",stringyear3).eq("month",stringmonth3).eq("windturbine_id",key);
- wcfmls = proEconWtCurveFittingMonthService.list(queryWrapper2).stream()
- .sorted(Comparator.comparing(ProEconWtCurveFittingMonth::getSpeed)).collect(Collectors.toList());
- monthBuildPoints(wcfmls, monthLastYearPoints);
- if (CacheContext.wtmap.containsKey(key)) {
- String modelid = CacheContext.wtmap.get(key).getModelId();
- if (StringUtils.notEmp(modelid)) {
-
- if (CacheContext.theoreticalPowerMap.containsKey(modelid)) {
- for (Double speed : CacheContext.theoreticalPowerMap.get(modelid).keySet()) {
- PointVo point = new PointVo();
- point.setX(speed);
- point.setY(CacheContext.theoreticalPowerMap.get(modelid).get(speed).getEnsurePower());
- bzglpowerPoints.add(point);
- }
- }
- }
- }
- QueryWrapper<ProEconCurveFittMonthMain> queryWrapper3 = new QueryWrapper<>();
- queryWrapper3.eq("year",stringyear).eq("month",stringmonth).eq("windturbine_id",key);
- Optional<ProEconCurveFittMonthMain> cfmmontho = proEconCurveFittMonthMainService.list(queryWrapper3).stream()
- .findFirst();
- ProEconCurveFittMonthMain cfmmonth;
- if (cfmmontho.isPresent()) {
- cfmmonth = cfmmontho.get();
- QueryWrapper<ProEconCurveFittMonthMain> wrapper = new QueryWrapper<>();
- wrapper.eq("id", cfmmonth.getId());
- proEconCurveFittMonthMainService.remove(wrapper);
- }
- cfmmonth = new ProEconCurveFittMonthMain();
- cfmmonth.setWindturbineId(key);
- cfmmonth.setYear(String.valueOf(day_year));
- cfmmonth.setMonth(String.valueOf(day_month));
-
- cfmmonth.setDeviationRate1(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), windMap.get(key).getYzyglPoints(), modelpower));
-
- cfmmonth.setDeviationRate2(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), bzglpowerPoints, modelpower));
-
- cfmmonth.setDeviationRate3(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYzyglPoints(), bzglpowerPoints, modelpower));
-
- cfmmonth.setMonthDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), monthLastMonthPoints, modelpower));
-
- cfmmonth.setYearDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), monthLastYearPoints, modelpower));
-
- cfmmonth.setStandardDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), monthStandardPoints, modelpower));
- mainls.add(cfmmonth);
-
-
- List<ProEconCurveFittMonthSub> subls=new ArrayList<>();
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 3, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 4, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 5, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 6, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 7, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 8, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 9, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 10, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 11, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 12, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- subls.add(pLCBuild(key, stringyear, stringmonth, windMap, modelpower, 13, bzglpowerPoints, monthLastMonthPoints, monthLastYearPoints, monthStandardPoints));
- List<ProEconCurveFittMonthSub> templs=new ArrayList<>();
- for(ProEconCurveFittMonthSub vo:subls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconCurveFittMonthSubService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconCurveFittMonthSubService.saveBatch(templs);
- }
- insertPoints(stringyear, stringmonth, windMap.get(key).getYsjglPoints(), windMap.get(key).getYzyglPoints(), key);
- if(type.equals("1"))
- {
- insertPoints2( windMap.get(key).getYsjglPoints(), windMap.get(key).getYzyglPoints(), key);
- }
- logger.info(key+"月曲线偏差率完成!");
- }
- List<ProEconCurveFittMonthMain> templs=new ArrayList<>();
- for(ProEconCurveFittMonthMain vo:mainls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconCurveFittMonthMainService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconCurveFittMonthMainService.saveBatch(templs);
- }
- logger.info("曲线保存完成!");
- }
- public void cureFittingYear(Date recordDate,String wpId) throws Exception {
-
- Date end = DateUtils.addDays(DateUtils.truncate(recordDate), 1);
- Calendar c = Calendar.getInstance();
- c.setTime(recordDate);
- int day_year = c.get(Calendar.YEAR);
- List<ProBasicEquipment> wtls=new ArrayList<>();
- if(StringUtils.notEmp(wpId) && CacheContext.wpwtmap.containsKey(wpId))
- {
- wtls=CacheContext.wpwtmap.get(wpId);
- }else
- {
- wtls=CacheContext.wtls;
- }
- StringBuilder sb=new StringBuilder();
- for(ProBasicEquipment wt:wtls)
- {
- sb.append("'").append(wt.getId()).append("',");
- }
- String wtIds=sb.substring(0,sb.length()-1);
- proEconWtCurveFittingYearService.deleteProEconWtCurveFittingFByYear(String.valueOf(day_year), wtIds);
- proEconCurveFittYearMainService.deleteProEconCurveFittYearMainFByYear(String.valueOf(day_year), wtIds);
- proEconCurveFittYearSubService.deleteProEconCurveFittYearSubFByYear(String.valueOf(day_year), wtIds);
- c.set(Calendar.DAY_OF_MONTH, 1);
- c.set(Calendar.MONTH, 0);
- Date begin = c.getTime();
-
- c.setTime(DateUtils.addYears(begin, -1));
- int year_year = c.get(Calendar.YEAR);
- Map<String, CureFittingVo> windMap = new HashMap<>();
- if (windturbineCapacity == null) {
- windturbineCapacity = new HashMap<>();
- Map<String, ProEconEquipmentmodel> modelMap = CacheContext.modelMap;
- for (ProBasicEquipment windturbine : CacheContext.wtls) {
- if (modelMap.containsKey(windturbine.getModelId())) {
- windturbineCapacity.put(windturbine.getId(), modelMap.get(windturbine.getModelId()).getPowerProduction());
- }
- }
- }
- for (ProBasicEquipment wt : wtls) {
- String windturbineId = wt.getId();
- if(wt.getWindpowerstationId().contains(WpType.GDC.id))
- {
- continue;
- }
- Map<String, ProBasicEquipmentPoint> windturbinetestingpointnewMap = CacheContext.wtpAimap.get(wt.getId());
-
- String pointIdGL = windturbinetestingpointnewMap.get(ContantXk.CJ_SSGL).getNemCode();
-
- String pointIdZT = windturbinetestingpointnewMap.get(ContantXk.MXZT).getNemCode();
- String pointIdFS;
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- if (windturbinetestingpointnewMap.containsKey(ContantXk.FCCFTFS70)) {
- ProBasicEquipmentPoint point = windturbinetestingpointnewMap.get(ContantXk.FCCFTFS70);
- if (StringUtils.notEmp(point.getNemCode()) && !point.getNemCode().equals(initialcode)) {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.FCCFTFS70).getNemCode();
- } else {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
- }
- } else {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
- }
- } else {
- pointIdFS = windturbinetestingpointnewMap.get(ContantXk.CJ_SSFS).getNemCode();
- }
- CureFittingVo item = new CureFittingVo();
- item.setPointIdFS(pointIdFS);
- item.setPointIdZT(pointIdZT);
- item.setPointIdGL(pointIdGL);
-
- if (CacheContext.wtstandardmap.containsKey(wt.getId())) {
- item.setStandardId(CacheContext.wtstandardmap.get(wt.getId()));
- } else {
- item.setStandardId(wt.getId());
- }
- windMap.put(windturbineId, item);
- }
- for (String key : windMap.keySet()) {
-
- windMap.get(key).setYsjglPoints(new ArrayList<>());
- windMap.get(key).setYzyglPoints(new ArrayList<>());
- windMap.get(key).setRsjglPoints(new ArrayList<>());
- windMap.get(key).setRzyglPoints(new ArrayList<>());
- windMap.get(key).setNsjglPoints(new ArrayList<>());
- windMap.get(key).setNzyglPoints(new ArrayList<>());
-
-
- QueryWrapper<ProEconWtPowerCurveFitting> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("windturbine_id",key);
- List<ProEconWtPowerCurveFitting> wtpowerls= proEconWtPowerCurveFittingService.list(queryWrapper)
- .stream()
- .sorted(Comparator.comparing(ProEconWtPowerCurveFitting::getSpeed)).collect(Collectors.toList());
- List<PointVo> zyglls=new ArrayList<>();
- List<PointVo> sjglls=new ArrayList<>();
- if(!wtpowerls.isEmpty())
- {
- for(ProEconWtPowerCurveFitting wtp:wtpowerls)
- {
- PointVo zyvo=new PointVo();
- zyvo.setX(wtp.getSpeed());
- zyvo.setY(wtp.getOptimalPower());
- zyglls.add(zyvo);
- PointVo sjvo=new PointVo();
- sjvo.setX(wtp.getSpeed());
- sjvo.setY(wtp.getActualPower());
- sjglls.add(sjvo);
- }
- }
- windMap.get(key).setNsjglPoints(sjglls);
- windMap.get(key).setNzyglPoints(zyglls);
- }
- List<ProEconCurveFittYearMain> mainls=new ArrayList<>();
- for (String key : windMap.keySet()) {
- Double modelpower = 1500.0;
- if (windturbineCapacity.containsKey(key)) {
- modelpower = windturbineCapacity.get(key);
- }
-
- List<PointVo> yearLastMonthPoints = new ArrayList<>();
-
- List<PointVo> yearLastYearPoints;
-
- List<PointVo> yearStandardPoints = new ArrayList<>();
-
-
- List<PointVo> bzglpowerPoints = new ArrayList<>();
- if (CacheContext.wtstandardmap.containsKey(key)) {
- String standardId = CacheContext.wtstandardmap.get(key);
- if (StringUtils.notEmp(standardId)) {
- if (windMap.containsKey(key)) {
- yearStandardPoints = windMap.get(standardId).getNsjglPoints();
- }
- }
- }
- String stringyear = String.valueOf(day_year);
- String stringyear3 = String.valueOf(year_year);
-
- QueryWrapper<ProEconWtCurveFittingYear> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("year",stringyear3).eq("windturbine_id",key);
- List<ProEconWtCurveFittingYear> wcfyls = proEconWtCurveFittingYearService.list(queryWrapper).stream()
- .sorted(Comparator.comparing(ProEconWtCurveFittingYear::getSpeed)).collect(Collectors.toList());
-
- yearBuildPoints(wcfyls, yearLastMonthPoints);
- yearLastYearPoints = yearLastMonthPoints;
- if (CacheContext.wtmap.containsKey(key)) {
- String modelid = CacheContext.wtmap.get(key).getModelId();
- if (StringUtils.notEmp(modelid)) {
-
- if (CacheContext.theoreticalPowerMap.containsKey(modelid)) {
- for (Double speed : CacheContext.theoreticalPowerMap.get(modelid).keySet()) {
- PointVo point = new PointVo();
- point.setX(speed);
- point.setY(CacheContext.theoreticalPowerMap.get(modelid).get(speed).getEnsurePower());
- bzglpowerPoints.add(point);
- }
- }
- }
- }
- QueryWrapper<ProEconCurveFittYearMain> queryWrapper2 = new QueryWrapper<>();
- queryWrapper2.eq("year",stringyear).eq("windturbine_id",key);
- Optional<ProEconCurveFittYearMain> cfmyearo = proEconCurveFittYearMainService.list(queryWrapper2)
- .stream()
- .findFirst();
- ProEconCurveFittYearMain cfmyear;
- if (cfmyearo.isPresent()) {
- cfmyear = cfmyearo.get();
- QueryWrapper<ProEconCurveFittMonthMain> wrapper = new QueryWrapper<>();
- wrapper.eq("id", cfmyear.getId());
- proEconCurveFittMonthMainService.remove(wrapper);
- }
- cfmyear = new ProEconCurveFittYearMain();
- cfmyear.setWindturbineId(key);
- cfmyear.setYear(String.valueOf(day_year));
-
- cfmyear.setDeviationRate1(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), windMap.get(key).getNzyglPoints(), modelpower));
-
- cfmyear.setDeviationRate2(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), bzglpowerPoints, modelpower));
-
- cfmyear.setDeviationRate3(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNzyglPoints(), bzglpowerPoints, modelpower));
-
- cfmyear.setMonthDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), yearLastMonthPoints, modelpower));
-
- cfmyear.setYearDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), yearLastYearPoints, modelpower));
-
- cfmyear.setStandardDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), yearStandardPoints, modelpower));
- mainls.add(cfmyear);
-
- List<ProEconCurveFittYearSub> subls=new ArrayList<>();
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 3, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 4, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 5, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 6, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 7, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 8, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 9, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 10, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 11, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 12, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- subls.add(pLCBuild(key, stringyear, windMap, modelpower, 13, bzglpowerPoints, yearLastMonthPoints, yearLastYearPoints, yearStandardPoints));
- List<ProEconCurveFittYearSub> templs=new ArrayList<>();
- for(ProEconCurveFittYearSub vo:subls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconCurveFittYearSubService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconCurveFittYearSubService.saveBatch(templs);
- }
- insertPoints(stringyear, windMap.get(key).getNsjglPoints(), windMap.get(key).getNzyglPoints(), key);
- logger.info(key);
- }
- List<ProEconCurveFittYearMain> templs=new ArrayList<>();
- for(ProEconCurveFittYearMain vo:mainls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconCurveFittYearMainService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconCurveFittYearMainService.saveBatch(templs);
- }
- }
- public ProEconCurveFittingSub pLCBuild(String key, Date current, Map<String, CureFittingVo> windMap, Double modelpower, double speed,
- List<PointVo> bzglpowerPoints, List<PointVo> lastMonthPoints, List<PointVo> lastYearPoints, List<PointVo> lastStandardPoints
- ) {
- QueryWrapper<ProEconCurveFittingSub> queryWrapper2 = new QueryWrapper<>();
- queryWrapper2.eq("record_date",current).eq("speed",speed).eq("windturbine_id",key);
- Optional<ProEconCurveFittingSub> cfmso = proEconCurveFittingSubService.list(queryWrapper2)
- .stream()
- .findFirst();
- ProEconCurveFittingSub cfms;
- if (cfmso.isPresent()) {
- cfms = cfmso.get();
- QueryWrapper<ProEconCurveFittingSub> wrapper = new QueryWrapper<>();
- wrapper.eq("id", cfms.getId());
- proEconCurveFittingSubService.remove(wrapper);
- }
- cfms = new ProEconCurveFittingSub();
- cfms.setWindturbineId(key);
- cfms.setSpeed(speed);
- cfms.setRecordDate(DateUtils.truncate(current));
- cfms.setDeviationRate1(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), windMap.get(key).getRzyglPoints(), modelpower, speed));
-
- cfms.setDeviationRate2(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), bzglpowerPoints, modelpower, speed));
-
- cfms.setDeviationRate3(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRzyglPoints(), bzglpowerPoints, modelpower, speed));
-
- cfms.setMonthDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), lastMonthPoints, modelpower, speed));
-
- cfms.setYearDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), lastYearPoints, modelpower, speed));
-
- cfms.setStandardDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getRsjglPoints(), lastStandardPoints, modelpower, speed));
- return cfms;
-
- }
- public ProEconCurveFittMonthSub pLCBuild(String key, String stringyear, String stringmonth, Map<String, CureFittingVo> windMap, Double modelpower, double speed,
- List<PointVo> bzglpowerPoints, List<PointVo> lastMonthPoints, List<PointVo> lastYearPoints, List<PointVo> lastStandardPoints
- ) {
-
- QueryWrapper<ProEconCurveFittMonthSub> queryWrapper2 = new QueryWrapper<>();
- queryWrapper2.eq("year",stringyear).eq("month",stringmonth).eq("speed",speed).eq("windturbine_id",key);
- Optional<ProEconCurveFittMonthSub> cfmsmontho = proEconCurveFittMonthSubService.list(queryWrapper2).stream()
- .findFirst();
- ProEconCurveFittMonthSub cfmsmonth;
- if (cfmsmontho.isPresent()) {
- cfmsmonth = cfmsmontho.get();
- QueryWrapper<ProEconCurveFittMonthSub> wrapper = new QueryWrapper<>();
- wrapper.eq("id", cfmsmonth.getId());
- proEconCurveFittMonthSubService.remove(wrapper);
- }
- cfmsmonth = new ProEconCurveFittMonthSub();
- cfmsmonth.setWindturbineId(key);
- cfmsmonth.setYear(stringyear);
- cfmsmonth.setMonth(stringmonth);
- cfmsmonth.setSpeed(speed);
-
- cfmsmonth.setDeviationRate1(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), windMap.get(key).getYzyglPoints(), modelpower, speed));
-
- cfmsmonth.setDeviationRate2(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), bzglpowerPoints, modelpower, speed));
-
- cfmsmonth.setDeviationRate3(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYzyglPoints(), bzglpowerPoints, modelpower, speed));
-
- cfmsmonth.setMonthDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), lastMonthPoints, modelpower, speed));
-
- cfmsmonth.setYearDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), lastYearPoints, modelpower, speed));
-
- cfmsmonth.setStandardDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getYsjglPoints(), lastStandardPoints, modelpower, speed));
- return cfmsmonth;
- }
- public ProEconCurveFittYearSub pLCBuild(String key, String stringyear, Map<String, CureFittingVo> windMap, Double modelpower, double speed,
- List<PointVo> bzglpowerPoints, List<PointVo> lastMonthPoints, List<PointVo> lastYearPoints, List<PointVo> lastStandardPoints
- ) {
-
- QueryWrapper<ProEconCurveFittYearSub> queryWrapper = new QueryWrapper<>();
- queryWrapper.eq("year",stringyear).eq("speed",speed).eq("windturbine_id",key);
- Optional<ProEconCurveFittYearSub> cfmsyearo = proEconCurveFittYearSubService.list(queryWrapper).stream()
- .findFirst();
- ProEconCurveFittYearSub cfmsyear;
- if (cfmsyearo.isPresent()) {
- cfmsyear = cfmsyearo.get();
- QueryWrapper<ProEconCurveFittYearSub> wrapper = new QueryWrapper<>();
- wrapper.eq("id", cfmsyear.getId());
- proEconCurveFittYearSubService.remove(wrapper);
- }
- cfmsyear = new ProEconCurveFittYearSub();
- cfmsyear.setWindturbineId(key);
- cfmsyear.setYear(stringyear);
- cfmsyear.setSpeed(speed);
-
-
- cfmsyear.setDeviationRate1(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), windMap.get(key).getNzyglPoints(), modelpower, speed));
-
- cfmsyear.setDeviationRate2(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), bzglpowerPoints, modelpower, speed));
-
- cfmsyear.setDeviationRate3(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNzyglPoints(), bzglpowerPoints, modelpower, speed));
-
- cfmsyear.setMonthDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), lastMonthPoints, modelpower, speed));
-
- cfmsyear.setYearDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), lastYearPoints, modelpower, speed));
-
- cfmsyear.setStandardDeviationRate(DeviationRateUtil.calculateDeviationRate(windMap.get(key).getNsjglPoints(), lastStandardPoints, modelpower, speed));
- return cfmsyear;
- }
- private void insertPoints(Date current, List<PointVo> sjglls, List<PointVo> zyglls, String windturbineId) {
-
- List<ProEconWtCurveFitting> wtcfls=new ArrayList<>();
- if (sjglls.size() == zyglls.size()) {
- for (int i = 0; i < sjglls.size(); i++) {
- ProEconWtCurveFitting item = new ProEconWtCurveFitting();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
- item.setSpeed(StringUtils.round(sjglls.get(i).getX(),2));
- }
- item.setActualPower(StringUtils.round(sjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(zyglls.get(i).getY(),2));
- item.setRecordDate(DateUtils.truncate(current));
- wtcfls.add(item);
-
- }
- }
- } else {
- logger.warn(String.format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, sjglls.size(), zyglls.size()));
- for (int i = 0; i < sjglls.size(); i++) {
- ProEconWtCurveFitting item = new ProEconWtCurveFitting();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
- boolean l = String.valueOf(sjglls.get(i).getX()).contains(".");
- if (l) {
- continue;
- }
- item.setSpeed(StringUtils.round(sjglls.get(i).getX(),2));
- }
- int finalI = i;
- OptionalDouble op = zyglls.stream().filter(x -> Objects.equals(x.getX(), sjglls.get(finalI).getX())).mapToDouble(PointVo::getY).findFirst();
- if (op.isPresent()) {
- item.setOptimalPower(op.getAsDouble());
- } else {
- item.setOptimalPower(0.0);
- }
- item.setActualPower(StringUtils.round(sjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(zyglls.get(i).getY(),2));
- item.setRecordDate(current);
- wtcfls.add(item);
-
- }
- }
-
- }
- List<ProEconWtCurveFitting> templs=new ArrayList<>();
- for(ProEconWtCurveFitting vo:wtcfls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconWtCurveFittingService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconWtCurveFittingService.saveBatch(templs);
- }
- if(!wtcfls.isEmpty())
- {
- redisService.select(9);
- String s = JSONObject.toJSONString(wtcfls);
- redisService.set(CurveType.dayCurve.id+"_"+windturbineId, s);
- }
- }
- private void insertPoints(String year, String month, List<PointVo> sjglls, List<PointVo> zyglls, String windturbineId) {
-
- List<ProEconWtCurveFittingMonth> wtcfls=new ArrayList<>();
- if (sjglls.size() == zyglls.size()) {
- for (int i = 0; i < sjglls.size(); i++) {
- ProEconWtCurveFittingMonth item = new ProEconWtCurveFittingMonth();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
-
- item.setSpeed(StringUtils.round(sjglls.get(i).getX(),2));
- }
- item.setActualPower(StringUtils.round(sjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(zyglls.get(i).getY(),2));
- item.setYear(String.valueOf(year));
- item.setMonth(String.valueOf(month));
- wtcfls.add(item);
-
- }
- }
- } else {
- logger.warn(String.format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, sjglls.size(), zyglls.size()));
- if(!sjglls.isEmpty() && !zyglls.isEmpty() && sjglls.size() == zyglls.size())
- {
- for (int i = 0; i < sjglls.size(); i++) {
- ProEconWtCurveFittingMonth item = new ProEconWtCurveFittingMonth();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
- item.setSpeed(StringUtils.round(sjglls.get(i).getX(),2));
- }
- int finalI = i;
- OptionalDouble op = zyglls.stream().filter(x -> Objects.equals(x.getX(), sjglls.get(finalI).getX())).mapToDouble(PointVo::getY).findFirst();
- if (op.isPresent()) {
- item.setOptimalPower(op.getAsDouble());
- } else {
- item.setOptimalPower(0.0);
- }
- item.setActualPower(StringUtils.round(sjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(zyglls.get(i).getY(),2));
- item.setYear(String.valueOf(year));
- item.setMonth(String.valueOf(month));
- wtcfls.add(item);
-
- }
- }
- }
- }
-
- List<ProEconWtCurveFittingMonth> templs=new ArrayList<>();
- for(ProEconWtCurveFittingMonth vo:wtcfls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconWtCurveFittingMonthService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconWtCurveFittingMonthService.saveBatch(templs);
- }
- if(!wtcfls.isEmpty())
- {
- redisService.select(9);
- String s = JSONObject.toJSONString(wtcfls);
- redisService.set(CurveType.monthCurve.id+"_"+windturbineId, s);
- }
- }
- private void insertPoints(String year, List<PointVo> sjglls, List<PointVo> zyglls, String windturbineId) {
-
- List<ProEconWtCurveFittingYear> wtcfls=new ArrayList<>();
- if (sjglls.size() == zyglls.size()) {
- for (int i = 0; i < sjglls.size(); i++) {
- ProEconWtCurveFittingYear item = new ProEconWtCurveFittingYear();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
- item.setSpeed(StringUtils.round(sjglls.get(i).getX(),2));
- }
- item.setActualPower(StringUtils.round(sjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(zyglls.get(i).getY(),2));
- item.setYear(String.valueOf(year));
- wtcfls.add(item);
-
- }
- }
- } else {
- logger.warn(String.format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, sjglls.size(), zyglls.size()));
- for (int i = 0; i < sjglls.size(); i++) {
- ProEconWtCurveFittingYear item = new ProEconWtCurveFittingYear();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
- item.setSpeed(StringUtils.round(sjglls.get(i).getX(),2));
- }
- int finalI = i;
- OptionalDouble op = zyglls.stream().filter(x -> Objects.equals(x.getX(), sjglls.get(finalI).getX())).mapToDouble(PointVo::getY).findFirst();
- if (op.isPresent()) {
- item.setOptimalPower(op.getAsDouble());
- } else {
- item.setOptimalPower(0.0);
- }
- item.setActualPower(StringUtils.round(sjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(zyglls.get(i).getY(),2));
- item.setYear(String.valueOf(year));
- wtcfls.add(item);
-
- }
- }
- }
-
- List<ProEconWtCurveFittingYear> templs=new ArrayList<>();
- for(ProEconWtCurveFittingYear vo:wtcfls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconWtCurveFittingYearService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconWtCurveFittingYearService.saveBatch(templs);
- }
- if(!wtcfls.isEmpty())
- {
- redisService.select(9);
- String s = JSONObject.toJSONString(wtcfls);
- redisService.set(CurveType.yearCurve.id+"_"+windturbineId, s);
- }
- }
- private void insertPoints2(List<PointVo> monthSjglls, List<PointVo> monthZyglls, String windturbineId) {
- if(!monthSjglls.isEmpty() && !monthZyglls.isEmpty())
- {
- QueryWrapper<ProEconWtPowerCurveFitting> queryWrapper = new QueryWrapper<>();
- if (com.gyee.common.model.StringUtils.isNotEmpty(windturbineId)){
- queryWrapper.eq("windturbine_id",windturbineId);
- }
- List<ProEconWtPowerCurveFitting> ls= proEconWtPowerCurveFittingService.list(queryWrapper);
- List<Long> wtpcfidls = ls.stream().map(ProEconWtPowerCurveFitting::getId).collect(Collectors.toList());
- for (int i = 0; i < wtpcfidls.size(); i++) {
- proEconWtPowerCurveFittingService.removeByIds(wtpcfidls);
- }
- List<ProEconWtPowerCurveFitting> wtcfls=new ArrayList<>();
- if (monthSjglls.size() == monthZyglls.size()) {
- for (int i = 0; i < monthSjglls.size(); i++) {
- ProEconWtPowerCurveFitting item = new ProEconWtPowerCurveFitting();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
-
- item.setSpeed(StringUtils.round(monthSjglls.get(i).getX(),2));
- }
- item.setActualPower(StringUtils.round(monthSjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(monthSjglls.get(i).getY(),2));
- wtcfls.add(item);
-
- }
- }
- } else {
- logger.warn(String.format("下标不一致的风机编号:{0},实际功率:{1},最有功率:{2}", windturbineId, monthSjglls.size(), monthZyglls.size()));
- for (int i = 0; i < monthSjglls.size(); i++) {
- ProEconWtPowerCurveFitting item = new ProEconWtPowerCurveFitting();
- item.setWindturbineId(windturbineId);
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- continue;
-
- } else {
- item.setSpeed(StringUtils.round(monthSjglls.get(i).getX(),2));
- }
- int finalI = i;
- OptionalDouble op = monthZyglls.stream().filter(x -> Objects.equals(x.getX(), monthSjglls.get(finalI).getX())).mapToDouble(PointVo::getY).findFirst();
- if (op.isPresent()) {
- item.setOptimalPower(op.getAsDouble());
- } else {
- item.setOptimalPower(0.0);
- }
- item.setActualPower(StringUtils.round(monthSjglls.get(i).getY(),2));
- item.setOptimalPower(StringUtils.round(monthSjglls.get(i).getY(),2));
- wtcfls.add(item);
-
- }
- }
- }
-
- List<ProEconWtPowerCurveFitting> templs=new ArrayList<>();
- for(ProEconWtPowerCurveFitting vo:wtcfls)
- {
- templs.add(vo);
- if(templs.size()==1000)
- {
- proEconWtPowerCurveFittingService.saveBatch(templs);
- templs=new ArrayList<>();
- }
- }
- if(!templs.isEmpty())
- {
- proEconWtPowerCurveFittingService.saveBatch(templs);
- }
- }
- }
- private void yearBuildPoints(List<ProEconWtCurveFittingYear> data, List<PointVo> points) {
- if (data != null) {
- for (ProEconWtCurveFittingYear datum : data) {
- PointVo point = new PointVo();
- point.setX(datum.getSpeed());
- point.setY(datum.getActualPower());
- points.add(point);
- }
- }
- }
- private void monthBuildPoints(List<ProEconWtCurveFittingMonth> data, List<PointVo> points) {
- if (data != null) {
- for (ProEconWtCurveFittingMonth datum : data) {
- PointVo point = new PointVo();
- point.setX(datum.getSpeed());
- point.setY(datum.getActualPower());
- points.add(point);
- }
- }
- }
- private void dayBuildPoints(List<ProEconWtCurveFitting> data, List<PointVo> points) {
- if (data != null) {
- for (ProEconWtCurveFitting datum : data) {
- PointVo point = new PointVo();
- point.setX(datum.getSpeed());
- point.setY(datum.getActualPower());
- points.add(point);
- }
- }
- }
-
- private boolean filterData(PointData gl, PointData fs, List<PointData> ztls,List<PointData> qfztls,int i, double maxPower,double maxSpeed, String windturbineId) throws Exception {
- if (StringUtils.notEmp(gl)) {
-
- if (gl.getPointValueInDouble() > maxPower || gl.getPointValueInDouble()<0) {
- return false;
- }
- }
- if (StringUtils.notEmp(fs)) {
-
- if (fs.getPointValueInDouble() > maxSpeed || fs.getPointValueInDouble()<0) {
- return false;
- }
- }
-
- if (ztls.get(i).getPointValueInDouble() != 2) {
- return false;
- }
- if(i!=0)
- {
- if (ztls.get(i-1).getPointValueInDouble() != 2) {
- return false;
- }
- }
-
- if (fs.getPointValueInDouble() == 0 && fs.getPointValueInDouble() >= 6 && fs.getPointValueInDouble() < 12.5 && qfztls.get(i).getPointValueInDouble() > 2) {
- return false;
- }else if (fs.getPointValueInDouble() >= 12.5 && qfztls.get(i).getPointValueInDouble() < 1) {
- return false;
- }
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- String modelid = CacheContext.wtmap.get(windturbineId).getModelId();
- if (StringUtils.notEmp(modelid)) {
-
- if (CacheContext.theoreticalPowerMap.containsKey(modelid)) {
- Map<Double,ProBasicModelPowerRd> theoreticalMap= CacheContext.theoreticalPowerMap.get(modelid);
- double speed=StringUtils.round(fs.getPointValueInDouble(),2);
- double power = theoreticalMap.get(speed).getEnsurePower();
- double k = gl.getPointValueInDouble() / power;
- if (gl.getPointValueInDouble() > 0) {
- if (k < 0.95 && maxPower <= power) {
- return false;
- }
- if (k < 0.9 && maxPower > power) {
- return false;
- }
- if (k < 0.85 && speed < 6 && speed > 4) {
- return false;
- }
- if (k < 0.9 && speed <= 4 && speed > 3.5) {
- return false;
- }
- }
- }
- }
- }
- return true;
- }
-
- private void curveFittingBuilder(Date begin, Date end, int dimension, double scale, String pointIdGL, String pointIdFS, String pointIdZT, List<PointVo> sjglPoints, List<PointVo> zyglPoints, String windturbineId) throws Exception {
- double maxPower = windturbineCapacity.get(windturbineId) ;
- double maxSpeed = 25;
- List<PointfVo> sjglnhpoints = new ArrayList<>();
- Map<Double, PointfVo> zyglnhpoints = new HashMap<>();
- Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
- Map<String, ProBasicEquipmentPoint> wtpointmap = wtpAimap.get(windturbineId);
- String qfzt= wtpointmap.get(ContantXk.LSQFZT).getNemCode();
- if (end.after(begin)) {
- if (StringUtils.notEmp(pointIdGL) && StringUtils.notEmp(pointIdFS)) {
- List<PointData> glpointstemp = edosUtil.getHistoryDatasSnap(pointIdGL, begin.getTime() / 1000, end.getTime() / 1000,null,60*10L);
- List<PointData> fspointstemp = edosUtil.getHistoryDatasSnap(pointIdFS, begin.getTime() / 1000, end.getTime() / 1000,null,60*10L);
- List<PointData> ztpointstemp = edosUtil.getHistoryDatasSnap(pointIdZT, begin.getTime() / 1000, end.getTime() / 1000,null,60*10L);
- List<PointData> qfzttemp = edosUtil.getHistoryDatasSnap(qfzt, begin.getTime() / 1000, end.getTime() / 1000,null,60*10L);
- List<PointData> glpoints = new ArrayList<>();
- List<PointData> fspoints = new ArrayList<>();
- List<PointData> ztpoints = new ArrayList<>();
- if (!glpointstemp.isEmpty() && !fspointstemp.isEmpty() && !ztpointstemp.isEmpty() && glpointstemp.size() == fspointstemp.size() && fspointstemp.size() == ztpointstemp.size()) {
- for (int i = 0; i < glpointstemp.size(); i++) {
- if (filterData(glpointstemp.get(i), fspointstemp.get(i), ztpointstemp,qfzttemp,i, maxPower,maxSpeed, windturbineId)) {
- glpoints.add(glpointstemp.get(i));
- fspoints.add(fspointstemp.get(i));
- ztpoints.add(ztpointstemp.get(i));
- }
- }
- }
- if (glpoints.size() != fspoints.size() || glpoints.size() != ztpoints.size()) {
- for (int i = 0; i < fspoints.size(); i++) {
- double x = fspoints.get(i).getPointValueInDouble();
- double y = -1;
- double z = -1;
- int finalI1 = i;
- List<PointData> yArray = glpoints.stream().filter(it -> it.getPointTime().compareTo(fspoints.get(finalI1).getPointTime()) == 0).collect(Collectors.toList());
- if (yArray.size() > 0) {
- y = yArray.get(0).getPointValueInDouble();
- }
- int finalI = i;
- yArray = ztpoints.stream().filter(it -> it.getPointTime().compareTo(fspoints.get(finalI).getPointTime()) == 0).collect(Collectors.toList());
- if (yArray.size() > 0) {
- z = yArray.get(0).getPointValueInDouble();
- }
- Double x1 = StringUtils.round(x, 2);
- Double y1 = y;
- boolean b = true;
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- b = (x >= 0 && y > 0);
- } else {
- if (z == 2) {
- b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
- if (b) {
- if (x > 3 && y <= 0) {
- b = false;
- }
- if (x <= 3 && y > 0) {
- b = false;
- }
- }
- } else {
- b = false;
- }
- }
- }
- if (b) {
- sjglnhpoints.add(new PointfVo(x1, y1));
- if (zyglnhpoints.containsKey(x1)) {
- if (zyglnhpoints.get(x1).getY() < y1) {
- zyglnhpoints.put(x1, new PointfVo(x1, y1));
- }
- } else {
- zyglnhpoints.put(x1, new PointfVo(x1, y1));
- }
- }
- }
- } else {
- for (int i = 0; i < fspoints.size(); i++) {
- double x = fspoints.get(i).getPointValueInDouble();
- double y = glpoints.get(i).getPointValueInDouble();
- double z = ztpoints.get(i).getPointValueInDouble();
- Double x1 = StringUtils.round(x, 2);
- Double y1 = y;
- boolean b = true;
- if (CacheContext.wtmap.containsKey(windturbineId)) {
- ProBasicEquipment wt = CacheContext.wtmap.get(windturbineId);
- if (wt.getWindpowerstationId().contains(WpType.GDC.id)) {
- b = (x >= 0 && y > 0);
- } else {
- if (z == 2) {
- b = (x >= 0 && x <= 30 && y >= 0 && y <= maxPower);
- if (b) {
- if (x > 3 && y <= 0) {
- b = false;
- }
- if (x <= 3 && y > 0) {
- b = false;
- }
- }
- } else {
- b = false;
- }
- }
- }
- if (b) {
- sjglnhpoints.add(new PointfVo(x1, y1));
- if (zyglnhpoints.containsKey(x1)) {
- if (zyglnhpoints.get(x1).getY() < y1) {
- zyglnhpoints.put(x1, new PointfVo(x1, y1));
- }
- } else {
- zyglnhpoints.put(x1, new PointfVo(x1, y1));
- }
- }
- }
- }
- sjglnhpoints.add(new PointfVo(0.0, 0.0));
- sjglnhpoints = sjglnhpoints.stream().filter(it -> it.getX() >= 3).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
- List<PointVo> temp = LineUtil.buildLine(sjglnhpoints.stream().mapToDouble(PointfVo::getX).toArray(), sjglnhpoints.stream().mapToDouble(PointfVo::getY).toArray(), sjglnhpoints.size(), dimension, scale);
- sjglPoints.addAll(temp);
- if (sjglPoints.size() != 0) {
- buildMyPoints(sjglPoints, scale);
- }
- if (!zyglnhpoints.containsKey(0.0))
- {
- zyglnhpoints.put(0.0, new PointfVo(0.0, 0.0));
- }
- List<PointfVo> zygltemp = zyglnhpoints.values().stream().filter(it -> it.getX() >= 3).sorted(Comparator.comparing(PointfVo::getX)).collect(Collectors.toList());
- if (zygltemp.size() != 0) {
- temp = LineUtil.buildLine(zygltemp.stream().mapToDouble(PointfVo::getX).toArray(), zygltemp.stream().mapToDouble(PointfVo::getY).toArray(), zygltemp.size(), dimension, scale);
- }
- zyglPoints.addAll(temp);
- if (zyglPoints.size() != 0) {
- buildMyPoints(zyglPoints, scale);
- }
- }
- }
- }
- private static void buildMyPoints(List<PointVo> sjglPoints, double scale) {
- int coefficient = 1;
- int dec = 0;
- int smax = 25;
- if (scale == 0.01) {
- coefficient = 100;
- dec = 2;
- }
- if (scale == 0.1) {
- coefficient = 10;
- dec = 1;
- }
- smax *= coefficient;
- double min = 0.0;
- double max = 0.0;
- double maxval = 0.0;
- if (sjglPoints.stream().min(Comparator.comparing(PointVo::getX)).isPresent()) {
- min = sjglPoints.stream().min(Comparator.comparing(PointVo::getX)).get().getX() * coefficient;
- }
- if (sjglPoints.stream().max(Comparator.comparing(PointVo::getX)).isPresent()) {
- max = sjglPoints.stream().max(Comparator.comparing(PointVo::getX)).get().getX() * coefficient;
- }
- if (sjglPoints.stream().max(Comparator.comparing(PointVo::getY)).isPresent()) {
- maxval = sjglPoints.stream().max(Comparator.comparing(PointVo::getY)).get().getY();
- }
- for (double i = 0; i < min; i += 1) {
- PointVo point = new PointVo();
- point.setX(StringUtils.round(i / coefficient, dec));
- point.setY(0.0);
- sjglPoints.add(point);
- }
- for (double i = smax; i > max; i -= 1) {
- PointVo point = new PointVo();
- point.setX(StringUtils.round(i / coefficient, dec));
- point.setY(maxval);
- sjglPoints.add(point);
- }
- }
- }
|