SpecificService.java 175 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545
  1. package com.gyee.runeconomy.service.specific;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.gyee.common.model.StringUtils;
  4. import com.gyee.common.util.DateUtils;
  5. import com.gyee.common.util.DoubleUtils;
  6. import com.gyee.common.util.SortUtils;
  7. import com.gyee.common.vo.specific.SpecificCenterVo;
  8. import com.gyee.common.vo.specific.SpecificTarget;
  9. import com.gyee.common.vo.specific.SpecificTargetVo;
  10. import com.gyee.common.vo.specific.SpecificTopVo;
  11. import com.gyee.runeconomy.init.CacheContext;
  12. import com.gyee.runeconomy.model.auto.*;
  13. import com.gyee.runeconomy.service.TokenService;
  14. import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay1Service;
  15. import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay4Service;
  16. import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay5Service;
  17. import com.gyee.runeconomy.service.auto.IProEconPowerstationInfoDay7Service;
  18. import com.gyee.runeconomy.service.bmk.BenchmarkingService;
  19. import org.springframework.stereotype.Service;
  20. import org.springframework.web.context.request.RequestContextHolder;
  21. import org.springframework.web.context.request.ServletRequestAttributes;
  22. import javax.annotation.Resource;
  23. import javax.servlet.http.HttpServletRequest;
  24. import java.text.ParseException;
  25. import java.util.*;
  26. import java.util.stream.Collectors;
  27. /*
  28. @author 谢生杰
  29. @date 2022/11/23-21:38
  30. 专题分析
  31. */
  32. @Service
  33. public class SpecificService {
  34. @Resource
  35. private IProEconPowerstationInfoDay1Service proEconPowerstationInfoDay1Service;
  36. @Resource
  37. private IProEconPowerstationInfoDay4Service proEconPowerstationInfoDay4Service;
  38. @Resource
  39. private IProEconPowerstationInfoDay5Service proEconPowerstationInfoDay5Service;
  40. @Resource
  41. private IProEconPowerstationInfoDay7Service proEconPowerstationInfoDay7Service;
  42. @Resource
  43. private BenchmarkingService benchmarkingService;
  44. @Resource
  45. private TokenService tokenService;
  46. /**
  47. * 获取专题分析上面部分
  48. *
  49. * @param yearmonth
  50. * @return
  51. * @throws ParseException
  52. */
  53. public List<SpecificTopVo> maintoplist(String companys, String type, String yearmonth) throws ParseException {
  54. List<SpecificTopVo> resultList = new ArrayList<>();
  55. Date date = DateUtils.parseDate(yearmonth + "-01");
  56. Calendar c = Calendar.getInstance();
  57. c.setTime(date);
  58. Integer year = c.get(Calendar.YEAR);
  59. Integer month = c.get(Calendar.MONTH) + 1;
  60. SpecificTopVo dqvo = new SpecificTopVo();
  61. dqvo.setType("本期");
  62. setDySpecificinfodays(companys, type, yearmonth, dqvo);
  63. setDnSpecificinfodays(companys, type, yearmonth, dqvo);
  64. resultList.add(dqvo);
  65. SpecificTopVo tqvo = new SpecificTopVo();
  66. tqvo.setType("同期");
  67. setTySpecificinfodays(companys, type, yearmonth, tqvo);
  68. setTnSpecificinfodays(companys, type, yearmonth, tqvo);
  69. resultList.add(tqvo);
  70. SpecificTopVo bjvo = new SpecificTopVo();
  71. bjvo.setType("比较");
  72. setBjVo(dqvo, tqvo, bjvo);
  73. resultList.add(bjvo);
  74. return resultList;
  75. }
  76. /**
  77. * 比较当前,同期值,给比较值赋值
  78. *
  79. * @param dqvo
  80. * @param tqvo
  81. * @param bjvo
  82. */
  83. private void setBjVo(SpecificTopVo dqvo, SpecificTopVo tqvo, SpecificTopVo bjvo) {
  84. bjvo.setYfnlyl(dqvo.getYfnlyl() >= tqvo.getYfnlyl() ? 1.0 : 2.0);
  85. bjvo.setYwhssl(dqvo.getYwhssl() >= tqvo.getYwhssl() ? 1.0 : 2.0);
  86. bjvo.setYgzssl(dqvo.getYgzssl() >= tqvo.getYgzssl() ? 1.0 : 2.0);
  87. bjvo.setYxdssl(dqvo.getYxdssl() >= tqvo.getYxdssl() ? 1.0 : 2.0);
  88. bjvo.setYxnssl(dqvo.getYxnssl() >= tqvo.getYxnssl() ? 1.0 : 2.0);
  89. bjvo.setYslssl(dqvo.getYslssl() >= tqvo.getYslssl() ? 1.0 : 2.0);
  90. bjvo.setNfnlyl(dqvo.getNfnlyl() >= tqvo.getNfnlyl() ? 1.0 : 2.0);
  91. bjvo.setNwhssl(dqvo.getNwhssl() >= tqvo.getNwhssl() ? 1.0 : 2.0);
  92. bjvo.setNgzssl(dqvo.getNgzssl() >= tqvo.getNgzssl() ? 1.0 : 2.0);
  93. bjvo.setNxdssl(dqvo.getNxdssl() >= tqvo.getNxdssl() ? 1.0 : 2.0);
  94. bjvo.setNxnssl(dqvo.getNxnssl() >= tqvo.getNxnssl() ? 1.0 : 2.0);
  95. bjvo.setNslssl(dqvo.getNslssl() >= tqvo.getNslssl() ? 1.0 : 2.0);
  96. }
  97. /**
  98. * 获取当月专题分析上面数据
  99. *
  100. * @param companys
  101. * @param type
  102. * @param yearmonth
  103. * @return
  104. */
  105. private void setDySpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  106. QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  107. qw.select("sum(rllfdl) as yllfdl,sum(rfdl) as yfdl,sum(rgzssdl) as ygzssdl,sum(rcnslgzssdl) as ycnslgzssdl,sum(rjxssdl) as yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) as yqxjclssdl,sum(rsdtjssdl) as ysdtjssdl,sum(rxnssdl) as yxnssdl,sum(rxdtjssdl) as yxdtjssdl,sum(rxdjclssdl) as yxdjclssdl,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl");
  108. qw.eq("foreign_key_id", companys + type);
  109. qw.eq("to_char(record_date,'yyyy-MM')", yearmonth);
  110. qw.groupBy("to_char(record_date,'yyyy-MM')");
  111. List<ProEconPowerstationInfoDay1> monthList = proEconPowerstationInfoDay1Service.list(qw);
  112. if (StringUtils.isNotEmpty(monthList)) {
  113. Optional<ProEconPowerstationInfoDay1> monthFirst = monthList.stream().findFirst();
  114. if (monthFirst.isPresent()) {
  115. ProEconPowerstationInfoDay1 monthSpecific = monthFirst.get();
  116. dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getYllfdl().doubleValue() / 10000, 2));
  117. dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getYfdl().doubleValue() / 10000, 2));
  118. dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getYjxssdl().doubleValue() / 10000 + monthSpecific.getYcnsljxssdl().doubleValue() / 10000, 2));
  119. dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getYgzssdl().doubleValue() / 10000 + monthSpecific.getYcnslgzssdl().doubleValue() / 10000, 2));
  120. dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYxdjclssdl().doubleValue() / 10000, 2));
  121. dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getYdjssdl().doubleValue() / 10000 + monthSpecific.getYqxjclssdl().doubleValue() / 10000 + monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYsdtjssdl().doubleValue() / 10000, 2));
  122. dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getYcwsldwssdl().doubleValue() / 10000 + monthSpecific.getYcwsltqssdl().doubleValue() / 10000, 2));
  123. if (dqvo.getYllfdl() != 0) {
  124. dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl() / dqvo.getYllfdl() * 100, 2));
  125. dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl() / dqvo.getYllfdl() * 100, 2));
  126. dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl() / dqvo.getYllfdl() * 100, 2));
  127. dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl() / dqvo.getYllfdl() * 100, 2));
  128. dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl() / dqvo.getYllfdl() * 100, 2));
  129. dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl() / dqvo.getYllfdl() * 100, 2));
  130. } else {
  131. dqvo.setYfnlyl(0.0);
  132. dqvo.setYwhssl(0.0);
  133. dqvo.setYgzssl(0.0);
  134. dqvo.setYxdssl(0.0);
  135. dqvo.setYxnssl(0.0);
  136. dqvo.setYslssl(0.0);
  137. }
  138. }
  139. } else {
  140. dqvo.setYllfdl(0.0);
  141. dqvo.setYsjfdl(0.0);
  142. dqvo.setYwhssdl(0.0);
  143. dqvo.setYgzssdl(0.0);
  144. dqvo.setYxdssdl(0.0);
  145. dqvo.setYxnssdl(0.0);
  146. dqvo.setYslssdl(0.0);
  147. dqvo.setYfnlyl(0.0);
  148. dqvo.setYwhssl(0.0);
  149. dqvo.setYgzssl(0.0);
  150. dqvo.setYxdssl(0.0);
  151. dqvo.setYxnssl(0.0);
  152. dqvo.setYslssl(0.0);
  153. }
  154. }
  155. /**
  156. * 获取月同期专题分析上面数据
  157. *
  158. * @param companys
  159. * @param type
  160. * @return
  161. */
  162. private void setTySpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  163. String yearString = yearmonth.split("-")[0];
  164. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  165. String yearMonth = year + "-" + yearmonth.split("-")[1];
  166. QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  167. qw.select("sum(rllfdl) as yllfdl,sum(rfdl) as yfdl,sum(rgzssdl) as ygzssdl,sum(rcnslgzssdl) as ycnslgzssdl,sum(rjxssdl) as yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) as yqxjclssdl,sum(rsdtjssdl) as ysdtjssdl,sum(rxnssdl) as yxnssdl,sum(rxdtjssdl) as yxdtjssdl,sum(rxdjclssdl) as yxdjclssdl,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl");
  168. qw.eq("foreign_key_id", companys + type);
  169. qw.eq("to_char(record_date,'yyyy-MM')", yearMonth);
  170. qw.groupBy("to_char(record_date,'yyyy-MM')");
  171. List<ProEconPowerstationInfoDay1> monthList = proEconPowerstationInfoDay1Service.list(qw);
  172. Optional<ProEconPowerstationInfoDay1> monthFirst = monthList.stream().findFirst();
  173. if (monthFirst.isPresent()) {
  174. ProEconPowerstationInfoDay1 monthSpecific = monthFirst.get();
  175. dqvo.setYllfdl(DoubleUtils.getRoundingNum(monthSpecific.getYllfdl().doubleValue() / 10000, 2));
  176. dqvo.setYsjfdl(DoubleUtils.getRoundingNum(monthSpecific.getYfdl().doubleValue() / 10000, 2));
  177. dqvo.setYwhssdl(DoubleUtils.getRoundingNum(monthSpecific.getYjxssdl().doubleValue() / 10000 + monthSpecific.getYcnsljxssdl().doubleValue() / 10000, 2));
  178. dqvo.setYgzssdl(DoubleUtils.getRoundingNum(monthSpecific.getYgzssdl().doubleValue() / 10000 + monthSpecific.getYcnslgzssdl().doubleValue() / 10000, 2));
  179. dqvo.setYxdssdl(DoubleUtils.getRoundingNum(monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYxdjclssdl().doubleValue() / 10000, 2));
  180. dqvo.setYxnssdl(DoubleUtils.getRoundingNum(monthSpecific.getYdjssdl().doubleValue() / 10000 + monthSpecific.getYqxjclssdl().doubleValue() / 10000 + monthSpecific.getYxnssdl().doubleValue() / 10000 + monthSpecific.getYsdtjssdl().doubleValue() / 10000, 2));
  181. dqvo.setYslssdl(DoubleUtils.getRoundingNum(monthSpecific.getYcwsldwssdl().doubleValue() / 10000 + monthSpecific.getYcwsltqssdl().doubleValue() / 10000, 2));
  182. if (dqvo.getYllfdl() != 0) {
  183. dqvo.setYfnlyl(DoubleUtils.getRoundingNum(dqvo.getYsjfdl() / dqvo.getYllfdl() * 100, 2));
  184. dqvo.setYwhssl(DoubleUtils.getRoundingNum(dqvo.getYwhssdl() / dqvo.getYllfdl() * 100, 2));
  185. dqvo.setYgzssl(DoubleUtils.getRoundingNum(dqvo.getYgzssdl() / dqvo.getYllfdl() * 100, 2));
  186. dqvo.setYxdssl(DoubleUtils.getRoundingNum(dqvo.getYxdssdl() / dqvo.getYllfdl() * 100, 2));
  187. dqvo.setYxnssl(DoubleUtils.getRoundingNum(dqvo.getYxnssdl() / dqvo.getYllfdl() * 100, 2));
  188. dqvo.setYslssl(DoubleUtils.getRoundingNum(dqvo.getYslssdl() / dqvo.getYllfdl() * 100, 2));
  189. } else {
  190. dqvo.setYfnlyl(0.0);
  191. dqvo.setYwhssl(0.0);
  192. dqvo.setYgzssl(0.0);
  193. dqvo.setYxdssl(0.0);
  194. dqvo.setYxnssl(0.0);
  195. dqvo.setYslssl(0.0);
  196. }
  197. } else {
  198. dqvo.setYllfdl(0.0);
  199. dqvo.setYsjfdl(0.0);
  200. dqvo.setYwhssdl(0.0);
  201. dqvo.setYgzssdl(0.0);
  202. dqvo.setYxdssdl(0.0);
  203. dqvo.setYxnssdl(0.0);
  204. dqvo.setYslssdl(0.0);
  205. dqvo.setYfnlyl(0.0);
  206. dqvo.setYwhssl(0.0);
  207. dqvo.setYgzssl(0.0);
  208. dqvo.setYxdssl(0.0);
  209. dqvo.setYxnssl(0.0);
  210. dqvo.setYslssl(0.0);
  211. }
  212. }
  213. /**
  214. * 获取当年专题分析上面数据
  215. *
  216. * @param companys
  217. * @param type
  218. * @param yearmonth
  219. * @param dqvo
  220. */
  221. private void setDnSpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) {
  222. QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  223. qw.select("sum(rllfdl) as nllfdl,sum(rfdl) as nfdl,sum(rgzssdl) as ngzssdl,sum(rcnslgzssdl) as ncnslgzssdl,sum(rjxssdl) as njxssdl,sum(rcnsljxssdl) ncnsljxssdl,sum(rdjssdl) ndjssdl,sum(rqxjclssdl) as nqxjclssdl,sum(rsdtjssdl) as nsdtjssdl,sum(rxnssdl) as nxnssdl,sum(rxdtjssdl) as nxdtjssdl,sum(rxdjclssdl) as nxdjclssdl,sum(rcwsldwssdl) ncwsldwssdl,sum(rcwsltqssdl) ncwsltqssdl");
  224. qw.eq("foreign_key_id", companys + type);
  225. qw.eq("to_char(record_date,'yyyy')", yearmonth.split("-")[0]);
  226. qw.groupBy("to_char(record_date,'yyyy')");
  227. List<ProEconPowerstationInfoDay1> yearList = proEconPowerstationInfoDay1Service.list(qw);
  228. if (StringUtils.isNotEmpty(yearList)) {
  229. Optional<ProEconPowerstationInfoDay1> yearFirsts = yearList.stream().findFirst();
  230. if (yearFirsts.isPresent()) {
  231. ProEconPowerstationInfoDay1 yearSpecific = yearFirsts.get();
  232. dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getNllfdl().doubleValue() / 10000, 2));
  233. dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getNfdl().doubleValue() / 10000, 2));
  234. dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getNjxssdl().doubleValue() / 10000 + yearSpecific.getNcnsljxssdl().doubleValue() / 10000, 2));
  235. dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getNgzssdl().doubleValue() / 10000 + yearSpecific.getNcnslgzssdl().doubleValue() / 10000, 2));
  236. dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNxdjclssdl().doubleValue() / 10000, 2));
  237. dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getNdjssdl().doubleValue() / 10000 + yearSpecific.getNqxjclssdl().doubleValue() / 10000 + yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNsdtjssdl().doubleValue() / 10000, 2));
  238. dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getNcwsldwssdl().doubleValue() / 10000 + yearSpecific.getNcwsltqssdl().doubleValue() / 10000, 2));
  239. if (dqvo.getYllfdl() != 0) {
  240. dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
  241. dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
  242. dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
  243. dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
  244. dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
  245. dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
  246. } else {
  247. dqvo.setNfnlyl(0.0);
  248. dqvo.setNwhssl(0.0);
  249. dqvo.setNgzssl(0.0);
  250. dqvo.setNxdssl(0.0);
  251. dqvo.setNxnssl(0.0);
  252. dqvo.setNslssl(0.0);
  253. }
  254. }
  255. } else {
  256. dqvo.setNllfdl(0.0);
  257. dqvo.setNsjfdl(0.0);
  258. dqvo.setNwhssdl(0.0);
  259. dqvo.setNgzssdl(0.0);
  260. dqvo.setNxdssdl(0.0);
  261. dqvo.setNxnssdl(0.0);
  262. dqvo.setNslssdl(0.0);
  263. dqvo.setNfnlyl(0.0);
  264. dqvo.setNwhssl(0.0);
  265. dqvo.setNgzssl(0.0);
  266. dqvo.setNxdssl(0.0);
  267. dqvo.setNxnssl(0.0);
  268. dqvo.setNslssl(0.0);
  269. }
  270. }
  271. /**
  272. * 获取年同期专题分析上面数据
  273. *
  274. * @param companys
  275. * @param dqvo
  276. */
  277. private void setTnSpecificinfodays(String companys, String type, String yearmonth, SpecificTopVo dqvo) throws ParseException {
  278. String yearString = yearmonth.split("-")[0];
  279. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  280. QueryWrapper<ProEconPowerstationInfoDay1> qw = new QueryWrapper<>();
  281. qw.select("sum(rllfdl) as nllfdl,sum(rfdl) as nfdl,sum(rgzssdl) as ngzssdl,sum(rcnslgzssdl) as ncnslgzssdl,sum(rjxssdl) as njxssdl,sum(rcnsljxssdl) ncnsljxssdl,sum(rdjssdl) ndjssdl,sum(rqxjclssdl) as nqxjclssdl,sum(rsdtjssdl) as nsdtjssdl,sum(rxnssdl) as nxnssdl,sum(rxdtjssdl) as nxdtjssdl,sum(rxdjclssdl) as nxdjclssdl,sum(rcwsldwssdl) ncwsldwssdl,sum(rcwsltqssdl) ncwsltqssdl");
  282. qw.eq("foreign_key_id", companys + type);
  283. qw.eq("to_char(record_date,'yyyy')", year);
  284. qw.groupBy("to_char(record_date,'yyyy')");
  285. List<ProEconPowerstationInfoDay1> yearList = proEconPowerstationInfoDay1Service.list(qw);
  286. Optional<ProEconPowerstationInfoDay1> yearFirsts = yearList.stream().findFirst();
  287. if (yearFirsts.isPresent()) {
  288. ProEconPowerstationInfoDay1 yearSpecific = yearFirsts.get();
  289. dqvo.setNllfdl(DoubleUtils.getRoundingNum(yearSpecific.getNllfdl().doubleValue() / 10000, 2));
  290. dqvo.setNsjfdl(DoubleUtils.getRoundingNum(yearSpecific.getNfdl().doubleValue() / 10000, 2));
  291. dqvo.setNwhssdl(DoubleUtils.getRoundingNum(yearSpecific.getNjxssdl().doubleValue() / 10000 + yearSpecific.getNcnsljxssdl().doubleValue() / 10000, 2));
  292. dqvo.setNgzssdl(DoubleUtils.getRoundingNum(yearSpecific.getNgzssdl().doubleValue() / 10000 + yearSpecific.getNcnslgzssdl().doubleValue() / 10000, 2));
  293. dqvo.setNxdssdl(DoubleUtils.getRoundingNum(yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNxdjclssdl().doubleValue() / 10000, 2));
  294. dqvo.setNxnssdl(DoubleUtils.getRoundingNum(yearSpecific.getNdjssdl().doubleValue() / 10000 + yearSpecific.getNqxjclssdl().doubleValue() / 10000 + yearSpecific.getNxnssdl().doubleValue() / 10000 + yearSpecific.getNsdtjssdl().doubleValue() / 10000, 2));
  295. dqvo.setNslssdl(DoubleUtils.getRoundingNum(yearSpecific.getNcwsldwssdl().doubleValue() / 10000 + yearSpecific.getNcwsltqssdl().doubleValue() / 10000, 2));
  296. if (dqvo.getYllfdl() != 0) {
  297. dqvo.setNfnlyl(DoubleUtils.getRoundingNum(dqvo.getNsjfdl() / dqvo.getNllfdl() * 100, 2));
  298. dqvo.setNwhssl(DoubleUtils.getRoundingNum(dqvo.getNwhssdl() / dqvo.getNllfdl() * 100, 2));
  299. dqvo.setNgzssl(DoubleUtils.getRoundingNum(dqvo.getNgzssdl() / dqvo.getNllfdl() * 100, 2));
  300. dqvo.setNxdssl(DoubleUtils.getRoundingNum(dqvo.getNxdssdl() / dqvo.getNllfdl() * 100, 2));
  301. dqvo.setNxnssl(DoubleUtils.getRoundingNum(dqvo.getNxnssdl() / dqvo.getNllfdl() * 100, 2));
  302. dqvo.setNslssl(DoubleUtils.getRoundingNum(dqvo.getNslssdl() / dqvo.getNllfdl() * 100, 2));
  303. } else {
  304. dqvo.setNfnlyl(0.0);
  305. dqvo.setNwhssl(0.0);
  306. dqvo.setNgzssl(0.0);
  307. dqvo.setNxdssl(0.0);
  308. dqvo.setNxnssl(0.0);
  309. dqvo.setNslssl(0.0);
  310. }
  311. } else {
  312. dqvo.setNllfdl(0.0);
  313. dqvo.setNsjfdl(0.0);
  314. dqvo.setNwhssdl(0.0);
  315. dqvo.setNgzssdl(0.0);
  316. dqvo.setNxdssdl(0.0);
  317. dqvo.setNxnssdl(0.0);
  318. dqvo.setNslssdl(0.0);
  319. dqvo.setNfnlyl(0.0);
  320. dqvo.setNwhssl(0.0);
  321. dqvo.setNgzssl(0.0);
  322. dqvo.setNxdssl(0.0);
  323. dqvo.setNxnssl(0.0);
  324. dqvo.setNslssl(0.0);
  325. }
  326. }
  327. /**
  328. * 获取专题分析中间部分
  329. *
  330. * @param yearmonth
  331. * @return
  332. */
  333. public Map<String, List<SpecificCenterVo>> maincenterlist(String companys, String type, String yearmonth) throws ParseException {
  334. Map<String, ProBasicPowerstation> wpmap = CacheContext.wpmap;
  335. Date date = DateUtils.parseDate(yearmonth + "-01");
  336. Calendar c = Calendar.getInstance();
  337. c.setTime(date);
  338. int year = c.get(Calendar.YEAR);
  339. int month = c.get(Calendar.MONTH) + 1;
  340. //定义左边部分的结果list
  341. List<SpecificCenterVo> monthresultList = new ArrayList<>();
  342. //设置当月数据
  343. setCenterDyInfo(companys, type, yearmonth, monthresultList);
  344. //设置同期数据
  345. setCenterYtqInfo(companys, type, yearmonth, monthresultList);
  346. //设置比较数据
  347. monthresultList.stream().forEach(i -> {
  348. i.setMtbfCompare(null == i.getTqmtbf() ? 2 : (i.getMtbf() > i.getTqmtbf() ? 1 : 2));
  349. i.setMttrCompare(null == i.getTqmttr() ? 2 : (i.getMttr() > i.getTqmttr() ? 1 : 2));
  350. i.setFwjslCompare(null == i.getTqfwjsl() ? 2 : (i.getFwjsl() > i.getTqfwjsl() ? 1 : 2));
  351. i.setZtzhlCompare(null == i.getTqztzhl() ? 2 : (i.getZtzhl() > i.getTqztzhl() ? 1 : 2));
  352. i.setXqjslCompare(null == i.getTqxqjsl() ? 2 : (i.getXqjsl() > i.getTqxqjsl() ? 1 : 2));
  353. });
  354. //定义右边部分的结果list
  355. List<SpecificCenterVo> yearresultList = new ArrayList<>();
  356. //设置当年数据
  357. setCenterDnInfo(companys, type, yearmonth, yearresultList);
  358. //设置同期数据
  359. setCenterNtqInfo(companys, type, yearmonth, yearresultList);
  360. //设置比较数据
  361. yearresultList.stream().forEach(i -> {
  362. i.setMtbfCompare(null == i.getTqmtbf() ? 2 : (i.getMtbf() > i.getTqmtbf() ? 1 : 2));
  363. i.setMttrCompare(null == i.getTqmttr() ? 2 : (i.getMttr() > i.getTqmttr() ? 1 : 2));
  364. i.setFwjslCompare(null == i.getTqfwjsl() ? 2 : (i.getFwjsl() > i.getTqfwjsl() ? 1 : 2));
  365. i.setZtzhlCompare(null == i.getTqztzhl() ? 2 : (i.getZtzhl() > i.getTqztzhl() ? 1 : 2));
  366. i.setXqjslCompare(null == i.getTqxqjsl() ? 2 : (i.getXqjsl() > i.getTqxqjsl() ? 1 : 2));
  367. });
  368. //封装最终返回结果
  369. monthresultList.stream().forEach(i -> {
  370. i.setOrdernum(wpmap.get(i.getWpid()).getOrderNum());
  371. i.setWpid(wpmap.get(i.getWpid()).getAname());
  372. });
  373. yearresultList.stream().forEach(i -> {
  374. i.setOrdernum(wpmap.get(i.getWpid()).getOrderNum());
  375. i.setWpid(wpmap.get(i.getWpid()).getAname());
  376. });
  377. SortUtils.sort(monthresultList, "ordernum", SortUtils.ASC);
  378. SortUtils.sort(yearresultList, "ordernum", SortUtils.ASC);
  379. Map<String, List<SpecificCenterVo>> resultMap = new HashMap<>();
  380. resultMap.put("当月", monthresultList);
  381. resultMap.put("当年", yearresultList);
  382. return resultMap;
  383. }
  384. /**
  385. * 设置月同期mtbf,mttr,复位及时率,状态转换率,消缺及时率
  386. *
  387. * @param companys
  388. * @param type
  389. * @param yearmonth
  390. * @param monthresultList
  391. */
  392. private void setCenterYtqInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> monthresultList) {
  393. // HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  394. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  395. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  396. String yearString = yearmonth.split("-")[0];
  397. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  398. String yearMonth = year + "-" + yearmonth.split("-")[1];
  399. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  400. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  401. qw.select("foreign_key_id,sum(rmtbf) ymtbf,sum(rmttr) ymttr,avg(rfwjsl) yfwjsl,avg(rztzhjsl) yztzhjsl,avg(rgzxqjsl) ygzxqjsl");
  402. qw1.select("foreign_key_id,avg(rxtxlpr) yxtxlpr,avg(rlsl) ylsl,avg(rnbqzhxl) ynbqzhxl");
  403. qw.eq("location", "wp");
  404. qw1.eq("location", "wp");
  405. if (type.endsWith("-1")) {
  406. qw.like("foreign_key_id", "_FDC_");
  407. qw1.like("foreign_key_id", "_FDC_");
  408. } else if (type.endsWith("-2")) {
  409. qw.like("foreign_key_id", "_GDC_");
  410. qw1.like("foreign_key_id", "_GDC_");
  411. }
  412. if (companys.endsWith("ZGS")) {
  413. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  414. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  415. }
  416. qw.eq("to_char(record_date,'yyyy-MM')", yearMonth);
  417. qw1.eq("to_char(record_date,'yyyy-MM')", yearMonth);
  418. qw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  419. qw1.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  420. List<ProEconPowerstationInfoDay4> tqList = proEconPowerstationInfoDay4Service.list(qw);
  421. List<ProEconPowerstationInfoDay7> tq1List = proEconPowerstationInfoDay7Service.list(qw1);
  422. if (StringUtils.isNotEmpty(tqList)) {
  423. tqList.stream().forEach(i -> {
  424. Optional<SpecificCenterVo> optionMonth = monthresultList.stream().filter(j -> j.getWpid().equals(i.getForeignKeyId())).findFirst();
  425. SpecificCenterVo leftVo = optionMonth.get();
  426. if (optionMonth.isPresent()) {
  427. leftVo.setTqmtbf(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(), 2));
  428. leftVo.setTqmttr(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(), 2));
  429. if (type.equals("-1")) {
  430. leftVo.setTqfwjsl(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(), 2));
  431. leftVo.setTqztzhl(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(), 2));
  432. leftVo.setTqxqjsl(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(), 2));
  433. } else if (type.equals("-2")) {
  434. Optional<ProEconPowerstationInfoDay7> first = tq1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  435. if (first.isPresent()) {
  436. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  437. leftVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYxtxlpr().doubleValue(), 2));
  438. leftVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYlsl().doubleValue(), 2));
  439. leftVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYnbqzhxl().doubleValue(), 2));
  440. } else {
  441. leftVo.setFwjsl(0.0);
  442. leftVo.setZtzhl(0.0);
  443. leftVo.setXqjsl(0.0);
  444. }
  445. }
  446. } else {
  447. leftVo.setTqmtbf(0.0);
  448. leftVo.setTqmttr(0.0);
  449. leftVo.setTqfwjsl(0.0);
  450. leftVo.setTqztzhl(0.0);
  451. leftVo.setTqxqjsl(0.0);
  452. }
  453. });
  454. } else {
  455. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  456. wpls.stream().forEach(wp -> {
  457. Optional<SpecificCenterVo> optionMonth = monthresultList.stream().filter(j -> j.getWpid().equals(wp.getId())).findFirst();
  458. if (optionMonth.isPresent()) {
  459. SpecificCenterVo leftVo = optionMonth.get();
  460. leftVo.setTqmtbf(0.0);
  461. leftVo.setTqmttr(0.0);
  462. leftVo.setTqfwjsl(0.0);
  463. leftVo.setTqztzhl(0.0);
  464. leftVo.setTqxqjsl(0.0);
  465. }
  466. });
  467. }
  468. }
  469. /**
  470. * 设置年同期mtbf,mttr,复位及时率,状态转换率,消缺及时率
  471. *
  472. * @param companys
  473. * @param yearresultList
  474. */
  475. private void setCenterNtqInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> yearresultList) throws ParseException {
  476. HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  477. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  478. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  479. String yearString = yearmonth.split("-")[0];
  480. String year = String.valueOf(Integer.parseInt(yearString) - 1);
  481. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  482. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  483. qw.select("foreign_key_id,sum(rmtbf) nmtbf,sum(rmttr) nmttr,avg(rfwjsl) nfwjsl,avg(rztzhjsl) nztzhjsl,avg(rgzxqjsl) ngzxqjsl");
  484. qw1.select("foreign_key_id,avg(rxtxlpr) nxtxlpr,avg(rlsl) nlsl,avg(rnbqzhxl) nnbqzhxl");
  485. qw.eq("location", "wp");
  486. qw1.eq("location", "wp");
  487. if (type.endsWith("-1")) {
  488. qw.like("foreign_key_id", "_FDC_");
  489. qw1.like("foreign_key_id", "_FDC_");
  490. } else if (type.endsWith("-2")) {
  491. qw.like("foreign_key_id", "_GDC_");
  492. qw1.like("foreign_key_id", "_GDC_");
  493. }
  494. if (companys.endsWith("ZGS")) {
  495. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  496. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  497. }
  498. qw.eq("to_char(record_date,'yyyy')", year);
  499. qw1.eq("to_char(record_date,'yyyy')", year);
  500. qw.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  501. qw1.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  502. List<ProEconPowerstationInfoDay4> tqList = proEconPowerstationInfoDay4Service.list(qw);
  503. List<ProEconPowerstationInfoDay7> tq1List = proEconPowerstationInfoDay7Service.list(qw1);
  504. if (StringUtils.isNotEmpty(tqList)) {
  505. tqList.stream().forEach(i -> {
  506. Optional<SpecificCenterVo> optionYear = yearresultList.stream().filter(j -> j.getWpid().equals(i.getWindpowerstationId())).findFirst();
  507. if (optionYear.isPresent()) {
  508. SpecificCenterVo rightVo = optionYear.get();
  509. rightVo.setTqmtbf(DoubleUtils.keepPrecision(i.getNmtbf().doubleValue(), 2));
  510. rightVo.setTqmttr(DoubleUtils.keepPrecision(i.getNmttr().doubleValue(), 2));
  511. if (type.equals("-1")) {
  512. rightVo.setTqfwjsl(DoubleUtils.keepPrecision(i.getNfwjsl().doubleValue(), 2));
  513. rightVo.setTqztzhl(DoubleUtils.keepPrecision(i.getNztzhjsl().doubleValue(), 2));
  514. rightVo.setTqxqjsl(DoubleUtils.keepPrecision(i.getNgzxqjsl().doubleValue(), 2));
  515. } else if (type.equals("-2")) {
  516. Optional<ProEconPowerstationInfoDay7> first = tq1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  517. if (first.isPresent()) {
  518. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  519. rightVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNxtxlpr().doubleValue(), 2));
  520. rightVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNlsl().doubleValue(), 2));
  521. rightVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNnbqzhxl().doubleValue(), 2));
  522. } else {
  523. rightVo.setFwjsl(0.0);
  524. rightVo.setZtzhl(0.0);
  525. rightVo.setXqjsl(0.0);
  526. }
  527. }
  528. }
  529. });
  530. } else {
  531. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  532. wpls.stream().forEach(wp -> {
  533. Optional<SpecificCenterVo> optionMonth = yearresultList.stream().filter(j -> j.getWpid().equals(wp.getId())).findFirst();
  534. if (optionMonth.isPresent()) {
  535. SpecificCenterVo leftVo = optionMonth.get();
  536. leftVo.setTqmtbf(0.0);
  537. leftVo.setTqmttr(0.0);
  538. leftVo.setTqfwjsl(0.0);
  539. leftVo.setTqztzhl(0.0);
  540. leftVo.setTqxqjsl(0.0);
  541. }
  542. });
  543. }
  544. }
  545. /**
  546. * 设置当月mtbf,mttr,复位及时率,状态转换率,消缺及时率
  547. *
  548. * @param companys
  549. * @param type
  550. * @param monthresultList
  551. */
  552. private void setCenterDyInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> monthresultList) {
  553. HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  554. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  555. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  556. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  557. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  558. qw.select("foreign_key_id,sum(rmtbf) ymtbf,sum(rmttr) ymttr,avg(rfwjsl) yfwjsl,avg(rztzhjsl) yztzhjsl,avg(rgzxqjsl) ygzxqjsl");
  559. qw1.select("foreign_key_id,avg(rxtxlpr) yxtxlpr,avg(rlsl) ylsl,avg(rnbqzhxl) ynbqzhxl");
  560. qw.eq("location", "wp");
  561. qw1.eq("location", "wp");
  562. if (type.endsWith("-1")) {
  563. qw.like("foreign_key_id", "_FDC_");
  564. qw1.like("foreign_key_id", "_FDC_");
  565. } else if (type.endsWith("-2")) {
  566. qw.like("foreign_key_id", "_GDC_");
  567. qw1.like("foreign_key_id", "_GDC_");
  568. }
  569. if (companys.endsWith("ZGS")) {
  570. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  571. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  572. }
  573. qw.eq("to_char(record_date,'yyyy-MM')", yearmonth);
  574. qw1.eq("to_char(record_date,'yyyy-MM')", yearmonth);
  575. qw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  576. qw1.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  577. List<ProEconPowerstationInfoDay4> dyList = proEconPowerstationInfoDay4Service.list(qw);
  578. List<ProEconPowerstationInfoDay7> dy1List = proEconPowerstationInfoDay7Service.list(qw1);
  579. if (StringUtils.isNotEmpty(dyList)) {
  580. dyList.stream().forEach(i -> {
  581. SpecificCenterVo leftVo = new SpecificCenterVo();
  582. leftVo.setWpid(i.getForeignKeyId());
  583. leftVo.setMtbf(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(), 2));
  584. leftVo.setMttr(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(), 2));
  585. if (type.equals("-1")) {
  586. leftVo.setFwjsl(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(), 2));
  587. leftVo.setZtzhl(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(), 2));
  588. leftVo.setXqjsl(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(), 2));
  589. } else if (type.equals("-2")) {
  590. Optional<ProEconPowerstationInfoDay7> first = dy1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  591. if (first.isPresent()) {
  592. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  593. leftVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYxtxlpr().doubleValue(), 2));
  594. leftVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYlsl().doubleValue(), 2));
  595. leftVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getYnbqzhxl().doubleValue(), 2));
  596. } else {
  597. leftVo.setFwjsl(0.0);
  598. leftVo.setZtzhl(0.0);
  599. leftVo.setXqjsl(0.0);
  600. }
  601. }
  602. monthresultList.add(leftVo);
  603. });
  604. } else {
  605. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  606. wpls.stream().forEach(i -> {
  607. SpecificCenterVo leftVo = new SpecificCenterVo();
  608. leftVo.setWpid(i.getId());
  609. leftVo.setMtbf(0.0);
  610. leftVo.setMttr(0.0);
  611. leftVo.setFwjsl(0.0);
  612. leftVo.setZtzhl(0.0);
  613. leftVo.setXqjsl(0.0);
  614. monthresultList.add(leftVo);
  615. });
  616. }
  617. }
  618. /**
  619. * 设置当年mtbf,mttr,复位及时率,状态转换率,消缺及时率
  620. *
  621. * @param companys
  622. * @param yearresultList
  623. */
  624. private void setCenterDnInfo(String companys, String type, String yearmonth, List<SpecificCenterVo> yearresultList) {
  625. HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  626. // List<ProBasicPowerstation> wplsToken = tokenService.getWpls(request);
  627. List<ProBasicPowerstation> wplsToken = CacheContext.wpls;
  628. QueryWrapper<ProEconPowerstationInfoDay4> qw = new QueryWrapper<>();
  629. QueryWrapper<ProEconPowerstationInfoDay7> qw1 = new QueryWrapper<>();
  630. qw.select("foreign_key_id,sum(rmtbf) nmtbf,sum(rmttr) nmttr,avg(rfwjsl) nfwjsl,avg(rztzhjsl) nztzhjsl,avg(rgzxqjsl) ngzxqjsl");
  631. qw1.select("foreign_key_id,avg(rxtxlpr) nxtxlpr,avg(rlsl) nlsl,avg(rnbqzhxl) nnbqzhxl");
  632. qw.eq("location", "wp");
  633. qw1.eq("location", "wp");
  634. if (type.endsWith("-1")) {
  635. qw.like("foreign_key_id", "_FDC_");
  636. qw1.like("foreign_key_id", "_FDC_");
  637. } else if (type.endsWith("-2")) {
  638. qw.like("foreign_key_id", "_GDC_");
  639. qw1.like("foreign_key_id", "_GDC_");
  640. }
  641. if (companys.endsWith("ZGS")) {
  642. qw.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  643. qw1.in("foreign_key_id", wplsToken.stream().filter(wp -> wp.getCompanyId().equals(companys)).map(wp -> wp.getId()).collect(Collectors.toList()));
  644. }
  645. qw.eq("to_char(record_date,'yyyy')", yearmonth.split("-")[0]);
  646. qw1.eq("to_char(record_date,'yyyy')", yearmonth.split("-")[0]);
  647. qw.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  648. qw1.groupBy("to_char(record_date,'yyyy'),foreign_key_id");
  649. List<ProEconPowerstationInfoDay4> dyList = proEconPowerstationInfoDay4Service.list(qw);
  650. List<ProEconPowerstationInfoDay7> dy1List = proEconPowerstationInfoDay7Service.list(qw1);
  651. if (StringUtils.isNotEmpty(dyList)) {
  652. dyList.stream().forEach(i -> {
  653. SpecificCenterVo rightVo = new SpecificCenterVo();
  654. rightVo.setWpid(i.getForeignKeyId());
  655. rightVo.setMtbf(DoubleUtils.keepPrecision(i.getNmtbf().doubleValue(), 2));
  656. rightVo.setMttr(DoubleUtils.keepPrecision(i.getNmttr().doubleValue(), 2));
  657. if (type.equals("-1")) {
  658. rightVo.setFwjsl(DoubleUtils.keepPrecision(i.getNfwjsl().doubleValue(), 2));
  659. rightVo.setZtzhl(DoubleUtils.keepPrecision(i.getNztzhjsl().doubleValue(), 2));
  660. rightVo.setXqjsl(DoubleUtils.keepPrecision(i.getNgzxqjsl().doubleValue(), 2));
  661. } else if (type.equals("-2")) {
  662. Optional<ProEconPowerstationInfoDay7> first = dy1List.stream().filter(d -> d.getForeignKeyId().equals(i.getForeignKeyId())).findFirst();
  663. if (first.isPresent()) {
  664. ProEconPowerstationInfoDay7 proEconPowerstationInfoDay7 = first.get();
  665. rightVo.setFwjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNxtxlpr().doubleValue(), 2));
  666. rightVo.setZtzhl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNlsl().doubleValue(), 2));
  667. rightVo.setXqjsl(DoubleUtils.keepPrecision(proEconPowerstationInfoDay7.getNnbqzhxl().doubleValue(), 2));
  668. } else {
  669. rightVo.setFwjsl(0.0);
  670. rightVo.setZtzhl(0.0);
  671. rightVo.setXqjsl(0.0);
  672. }
  673. }
  674. yearresultList.add(rightVo);
  675. });
  676. } else {
  677. List<ProBasicPowerstation> wpls = benchmarkingService.wpByCplist(companys, type);
  678. wpls.stream().forEach(i -> {
  679. SpecificCenterVo rightVo = new SpecificCenterVo();
  680. rightVo.setWpid(i.getId());
  681. rightVo.setMtbf(0.0);
  682. rightVo.setMttr(0.0);
  683. rightVo.setFwjsl(0.0);
  684. rightVo.setZtzhl(0.0);
  685. rightVo.setXqjsl(0.0);
  686. yearresultList.add(rightVo);
  687. });
  688. }
  689. }
  690. /**
  691. * 获取风能利用率
  692. *
  693. * @param companys
  694. * @param type
  695. * @param year
  696. * @return
  697. */
  698. public List<SpecificTarget> fnlylList(String companys, String type, String year) {
  699. //获取年份所有当月的数据
  700. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  701. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  702. currentqw.eq("location", "wp");
  703. currentqw.eq("to_char(record_date,'yyyy')", year);
  704. if (type.equals("-1")) {
  705. currentqw.like("foreign_key_id", "_FDC_");
  706. } else {
  707. currentqw.like("foreign_key_id", "_GDC_");
  708. }
  709. if (companys.endsWith("ZGS")) {
  710. currentqw.eq("company_id", companys);
  711. } else {
  712. currentqw.eq("region_id", companys);
  713. }
  714. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  715. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  716. currentqw.clear();
  717. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  718. currentqw.eq("foreign_key_id", companys + type);
  719. currentqw.eq("to_char(record_date,'yyyy')", year);
  720. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  721. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  722. int subYear = Integer.parseInt(year) - 1;
  723. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  724. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  725. sameperiodqw.eq("location", "wp");
  726. if (type.equals("-1")) {
  727. currentqw.like("foreign_key_id", "_FDC_");
  728. } else {
  729. currentqw.like("foreign_key_id", "_GDC_");
  730. }
  731. if (companys.endsWith("ZGS")) {
  732. currentqw.eq("company_id", companys);
  733. } else {
  734. currentqw.eq("region_id", companys);
  735. }
  736. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  737. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  738. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  739. sameperiodqw.clear();
  740. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdl) yfdl,sum(rllfdl) yllfdl");
  741. sameperiodqw.eq("foreign_key_id", companys + type);
  742. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  743. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  744. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  745. //合并当月与同期数据为返回结果
  746. List<SpecificTargetVo> resultList = new ArrayList<>();
  747. currentList.stream().forEach(i -> {
  748. SpecificTargetVo vo = new SpecificTargetVo();
  749. String wpid = i.getForeignKeyId();
  750. vo.setWpid(wpid);
  751. if (wpid.contains("_ZGS")) {
  752. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  753. } else if (wpid.contains("_RGN")) {
  754. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  755. } else {
  756. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  757. }
  758. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  759. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  760. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? i.getYfdl().doubleValue() / i.getYllfdl().doubleValue() * 100 : 0, 2));
  761. resultList.add(vo);
  762. });
  763. resultList.stream().forEach(i -> {
  764. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  765. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  766. .findFirst();
  767. if (optional.isPresent()) {
  768. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  769. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? tqinfoday.getYfdl().doubleValue() / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  770. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  771. } else {
  772. i.setSameperiod(0.0);
  773. i.setCompare(0);
  774. }
  775. });
  776. List<SpecificTarget> resultendList = new ArrayList<>();
  777. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  778. resultList.stream().forEach(i -> {
  779. if (map.containsKey(i.getWpid())) {
  780. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  781. if (!integerListMap.containsKey(i.getMonth())) {
  782. map.get(i.getWpid()).put(i.getMonth(), i);
  783. } else {
  784. }
  785. } else {
  786. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  787. tempMap.put(i.getMonth(), i);
  788. map.put(i.getWpid(), tempMap);
  789. }
  790. });
  791. Set<String> wpids = map.keySet();
  792. if (StringUtils.isNotNull(wpids)) {
  793. wpids.stream().forEach(wpid -> {
  794. SpecificTarget vo = new SpecificTarget();
  795. vo.setWpid(wpid);
  796. int orderNum = 100;
  797. if (wpid.contains("_ZGS")) {
  798. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  799. } else if (wpid.contains("_RGN")) {
  800. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  801. } else {
  802. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  803. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  804. }
  805. vo.setOrderNum(orderNum);
  806. List<SpecificTargetVo> tempList = new ArrayList<>();
  807. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  808. for (int x = 1; x <= 12; x++) {
  809. if (listMap.containsKey(x)) {
  810. tempList.add(listMap.get(x));
  811. } else {
  812. SpecificTargetVo vo1 = new SpecificTargetVo();
  813. vo1.setWpid(wpid);
  814. if (wpid.contains("_ZGS")) {
  815. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  816. } else if (wpid.contains("_RGN")) {
  817. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  818. } else {
  819. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  820. }
  821. vo1.setYear(Integer.parseInt(year));
  822. vo1.setMonth(x);
  823. tempList.add(vo1);
  824. }
  825. }
  826. vo.setTargetList(tempList);
  827. resultendList.add(vo);
  828. });
  829. }
  830. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  831. return resultendList;
  832. }
  833. public List<SpecificTarget> fdlList(String companys, String type, String year) {
  834. //获取年份所有当月的数据
  835. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  836. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  837. currentqw.eq("location", "wp");
  838. currentqw.eq("to_char(record_date,'yyyy')", year);
  839. if (type.equals("-1")) {
  840. currentqw.like("foreign_key_id", "_FDC_");
  841. } else {
  842. currentqw.like("foreign_key_id", "_GDC_");
  843. }
  844. if (companys.endsWith("ZGS")) {
  845. currentqw.eq("company_id", companys);
  846. } else {
  847. currentqw.eq("region_id", companys);
  848. }
  849. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  850. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  851. currentqw.clear();
  852. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  853. currentqw.eq("foreign_key_id", companys + type);
  854. currentqw.eq("to_char(record_date,'yyyy')", year);
  855. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  856. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  857. int subYear = Integer.parseInt(year) - 1;
  858. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  859. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  860. sameperiodqw.eq("location", "wp");
  861. if (type.equals("-1")) {
  862. currentqw.like("foreign_key_id", "_FDC_");
  863. } else {
  864. currentqw.like("foreign_key_id", "_GDC_");
  865. }
  866. if (companys.endsWith("ZGS")) {
  867. currentqw.eq("company_id", companys);
  868. } else {
  869. currentqw.eq("region_id", companys);
  870. }
  871. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  872. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  873. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  874. sameperiodqw.clear();
  875. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  876. sameperiodqw.eq("foreign_key_id", companys + type);
  877. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  878. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  879. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  880. //合并当月与同期数据为返回结果
  881. List<SpecificTargetVo> resultList = new ArrayList<>();
  882. currentList.stream().forEach(i -> {
  883. SpecificTargetVo vo = new SpecificTargetVo();
  884. String wpid = i.getForeignKeyId();
  885. vo.setWpid(wpid);
  886. if (wpid.contains("_ZGS")) {
  887. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  888. } else if (wpid.contains("_RGN")) {
  889. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  890. } else {
  891. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  892. }
  893. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  894. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  895. vo.setCurrent(DoubleUtils.keepPrecision(i.getYfdldb().doubleValue() / 10000, 2));
  896. resultList.add(vo);
  897. });
  898. resultList.stream().forEach(i -> {
  899. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  900. .filter(j -> i.getWpid().equals(j.getForeignKeyId())
  901. && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  902. .findFirst();
  903. if (optional.isPresent()) {
  904. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  905. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYfdldb().doubleValue() / 10000, 2));
  906. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  907. } else {
  908. i.setSameperiod(0.0);
  909. i.setCompare(0);
  910. }
  911. });
  912. List<SpecificTarget> resultendList = new ArrayList<>();
  913. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  914. resultList.stream().forEach(i -> {
  915. if (map.containsKey(i.getWpid())) {
  916. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  917. if (!integerListMap.containsKey(i.getMonth())) {
  918. map.get(i.getWpid()).put(i.getMonth(), i);
  919. } else {
  920. }
  921. } else {
  922. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  923. tempMap.put(i.getMonth(), i);
  924. map.put(i.getWpid(), tempMap);
  925. }
  926. });
  927. Set<String> wpids = map.keySet();
  928. if (StringUtils.isNotNull(wpids)) {
  929. wpids.stream().forEach(wpid -> {
  930. SpecificTarget vo = new SpecificTarget();
  931. vo.setWpid(wpid);
  932. int orderNum = 100;
  933. if (wpid.contains("_ZGS")) {
  934. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  935. } else if (wpid.contains("_RGN")) {
  936. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  937. } else {
  938. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  939. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  940. }
  941. vo.setOrderNum(orderNum);
  942. List<SpecificTargetVo> tempList = new ArrayList<>();
  943. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  944. for (int x = 1; x <= 12; x++) {
  945. if (listMap.containsKey(x)) {
  946. tempList.add(listMap.get(x));
  947. } else {
  948. SpecificTargetVo vo1 = new SpecificTargetVo();
  949. vo1.setWpid(wpid);
  950. if (wpid.contains("_ZGS")) {
  951. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  952. } else if (wpid.contains("_RGN")) {
  953. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  954. } else {
  955. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  956. }
  957. vo1.setYear(Integer.parseInt(year));
  958. vo1.setMonth(x);
  959. tempList.add(vo1);
  960. }
  961. }
  962. vo.setTargetList(tempList);
  963. resultendList.add(vo);
  964. });
  965. }
  966. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  967. return resultendList;
  968. }
  969. public List<SpecificTarget> zhcydlList(String companys, String type, String year) {
  970. //获取年份所有当月的数据
  971. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  972. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  973. currentqw.eq("location", "wp");
  974. currentqw.eq("to_char(record_date,'yyyy')", year);
  975. if (type.equals("-1")) {
  976. currentqw.like("foreign_key_id", "_FDC_");
  977. } else {
  978. currentqw.like("foreign_key_id", "_GDC_");
  979. }
  980. if (companys.endsWith("ZGS")) {
  981. currentqw.eq("company_id", companys);
  982. } else {
  983. currentqw.eq("region_id", companys);
  984. }
  985. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  986. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  987. currentqw.clear();
  988. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  989. currentqw.eq("foreign_key_id", companys + type);
  990. currentqw.eq("to_char(record_date,'yyyy')", year);
  991. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  992. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  993. int subYear = Integer.parseInt(year) - 1;
  994. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  995. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  996. sameperiodqw.eq("location", "wp");
  997. if (type.equals("-1")) {
  998. currentqw.like("foreign_key_id", "_FDC_");
  999. } else {
  1000. currentqw.like("foreign_key_id", "_GDC_");
  1001. }
  1002. if (companys.endsWith("ZGS")) {
  1003. currentqw.eq("company_id", companys);
  1004. } else {
  1005. currentqw.eq("region_id", companys);
  1006. }
  1007. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1008. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1009. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  1010. sameperiodqw.clear();
  1011. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rzhcydldb) yzhcydldb");
  1012. sameperiodqw.eq("foreign_key_id", companys + type);
  1013. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1014. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1015. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  1016. //合并当月与同期数据为返回结果
  1017. List<SpecificTargetVo> resultList = new ArrayList<>();
  1018. currentList.stream().forEach(i -> {
  1019. SpecificTargetVo vo = new SpecificTargetVo();
  1020. String wpid = i.getForeignKeyId();
  1021. vo.setWpid(wpid);
  1022. if (wpid.contains("_ZGS")) {
  1023. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1024. } else if (wpid.contains("_RGN")) {
  1025. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1026. } else {
  1027. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1028. }
  1029. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1030. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1031. vo.setCurrent(DoubleUtils.keepPrecision(i.getYzhcydldb().doubleValue() / 10000, 2));
  1032. resultList.add(vo);
  1033. });
  1034. resultList.stream().forEach(i -> {
  1035. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  1036. // .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  1037. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  1038. .findFirst();
  1039. if (optional.isPresent()) {
  1040. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  1041. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYzhcydldb().doubleValue() / 10000, 2));
  1042. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1043. } else {
  1044. i.setSameperiod(0.0);
  1045. i.setCompare(0);
  1046. }
  1047. });
  1048. List<SpecificTarget> resultendList = new ArrayList<>();
  1049. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1050. resultList.stream().forEach(i -> {
  1051. if (map.containsKey(i.getWpid())) {
  1052. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1053. if (!integerListMap.containsKey(i.getMonth())) {
  1054. map.get(i.getWpid()).put(i.getMonth(), i);
  1055. } else {
  1056. }
  1057. } else {
  1058. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1059. tempMap.put(i.getMonth(), i);
  1060. map.put(i.getWpid(), tempMap);
  1061. }
  1062. });
  1063. Set<String> wpids = map.keySet();
  1064. if (StringUtils.isNotNull(wpids)) {
  1065. wpids.stream().forEach(wpid -> {
  1066. SpecificTarget vo = new SpecificTarget();
  1067. vo.setWpid(wpid);
  1068. int orderNum = 100;
  1069. if (wpid.contains("_ZGS")) {
  1070. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1071. } else if (wpid.contains("_RGN")) {
  1072. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1073. } else {
  1074. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1075. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1076. }
  1077. vo.setOrderNum(orderNum);
  1078. List<SpecificTargetVo> tempList = new ArrayList<>();
  1079. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1080. for (int x = 1; x <= 12; x++) {
  1081. if (listMap.containsKey(x)) {
  1082. tempList.add(listMap.get(x));
  1083. } else {
  1084. SpecificTargetVo vo1 = new SpecificTargetVo();
  1085. vo1.setWpid(wpid);
  1086. if (wpid.contains("_ZGS")) {
  1087. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1088. } else if (wpid.contains("_RGN")) {
  1089. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1090. } else {
  1091. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1092. }
  1093. vo1.setYear(Integer.parseInt(year));
  1094. vo1.setMonth(x);
  1095. tempList.add(vo1);
  1096. }
  1097. }
  1098. vo.setTargetList(tempList);
  1099. resultendList.add(vo);
  1100. });
  1101. }
  1102. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1103. return resultendList;
  1104. }
  1105. public List<SpecificTarget> gwdlList(String companys, String type, String year) {
  1106. //获取年份所有当月的数据
  1107. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  1108. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1109. currentqw.eq("location", "wp");
  1110. currentqw.eq("to_char(record_date,'yyyy')", year);
  1111. if (type.equals("-1")) {
  1112. currentqw.like("foreign_key_id", "_FDC_");
  1113. } else {
  1114. currentqw.like("foreign_key_id", "_GDC_");
  1115. }
  1116. if (companys.endsWith("ZGS")) {
  1117. currentqw.eq("company_id", companys);
  1118. } else {
  1119. currentqw.eq("region_id", companys);
  1120. }
  1121. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1122. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  1123. currentqw.clear();
  1124. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1125. currentqw.eq("foreign_key_id", companys + type);
  1126. currentqw.eq("to_char(record_date,'yyyy')", year);
  1127. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1128. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  1129. int subYear = Integer.parseInt(year) - 1;
  1130. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  1131. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1132. sameperiodqw.eq("location", "wp");
  1133. if (type.equals("-1")) {
  1134. currentqw.like("foreign_key_id", "_FDC_");
  1135. } else {
  1136. currentqw.like("foreign_key_id", "_GDC_");
  1137. }
  1138. if (companys.endsWith("ZGS")) {
  1139. currentqw.eq("company_id", companys);
  1140. } else {
  1141. currentqw.eq("region_id", companys);
  1142. }
  1143. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1144. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1145. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  1146. sameperiodqw.clear();
  1147. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgwgwdldb) ygwgwdldb");
  1148. sameperiodqw.eq("foreign_key_id", companys + type);
  1149. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1150. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1151. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  1152. //合并当月与同期数据为返回结果
  1153. List<SpecificTargetVo> resultList = new ArrayList<>();
  1154. currentList.stream().forEach(i -> {
  1155. SpecificTargetVo vo = new SpecificTargetVo();
  1156. String wpid = i.getForeignKeyId();
  1157. vo.setWpid(wpid);
  1158. if (wpid.contains("_ZGS")) {
  1159. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1160. } else if (wpid.contains("_RGN")) {
  1161. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1162. } else {
  1163. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1164. }
  1165. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1166. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1167. vo.setCurrent(DoubleUtils.keepPrecision(i.getYgwgwdldb().doubleValue() / 10000, 2));
  1168. resultList.add(vo);
  1169. });
  1170. resultList.stream().forEach(i -> {
  1171. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  1172. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  1173. .findFirst();
  1174. if (optional.isPresent()) {
  1175. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  1176. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYgwgwdldb().doubleValue() / 10000, 2));
  1177. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1178. } else {
  1179. i.setSameperiod(0.0);
  1180. i.setCompare(0);
  1181. }
  1182. });
  1183. List<SpecificTarget> resultendList = new ArrayList<>();
  1184. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1185. resultList.stream().forEach(i -> {
  1186. if (map.containsKey(i.getWpid())) {
  1187. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1188. if (!integerListMap.containsKey(i.getMonth())) {
  1189. map.get(i.getWpid()).put(i.getMonth(), i);
  1190. } else {
  1191. }
  1192. } else {
  1193. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1194. tempMap.put(i.getMonth(), i);
  1195. map.put(i.getWpid(), tempMap);
  1196. }
  1197. });
  1198. Set<String> wpids = map.keySet();
  1199. if (StringUtils.isNotNull(wpids)) {
  1200. wpids.stream().forEach(wpid -> {
  1201. SpecificTarget vo = new SpecificTarget();
  1202. vo.setWpid(wpid);
  1203. int orderNum = 100;
  1204. if (wpid.contains("_ZGS")) {
  1205. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1206. } else if (wpid.contains("_RGN")) {
  1207. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1208. } else {
  1209. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1210. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1211. }
  1212. vo.setOrderNum(orderNum);
  1213. List<SpecificTargetVo> tempList = new ArrayList<>();
  1214. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1215. for (int x = 1; x <= 12; x++) {
  1216. if (listMap.containsKey(x)) {
  1217. tempList.add(listMap.get(x));
  1218. } else {
  1219. SpecificTargetVo vo1 = new SpecificTargetVo();
  1220. vo1.setWpid(wpid);
  1221. if (wpid.contains("_ZGS")) {
  1222. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1223. } else if (wpid.contains("_RGN")) {
  1224. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1225. } else {
  1226. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1227. }
  1228. vo1.setYear(Integer.parseInt(year));
  1229. vo1.setMonth(x);
  1230. tempList.add(vo1);
  1231. }
  1232. }
  1233. vo.setTargetList(tempList);
  1234. resultendList.add(vo);
  1235. });
  1236. }
  1237. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1238. return resultendList;
  1239. }
  1240. public List<SpecificTarget> swdlList(String companys, String type, String year) {
  1241. //获取年份所有当月的数据
  1242. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  1243. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  1244. currentqw.eq("location", "wp");
  1245. currentqw.eq("to_char(record_date,'yyyy')", year);
  1246. if (type.equals("-1")) {
  1247. currentqw.like("foreign_key_id", "_FDC_");
  1248. } else {
  1249. currentqw.like("foreign_key_id", "_GDC_");
  1250. }
  1251. if (companys.endsWith("ZGS")) {
  1252. currentqw.eq("company_id", companys);
  1253. } else {
  1254. currentqw.eq("region_id", companys);
  1255. }
  1256. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1257. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  1258. currentqw.clear();
  1259. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  1260. currentqw.eq("foreign_key_id", companys + type);
  1261. currentqw.eq("to_char(record_date,'yyyy')", year);
  1262. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1263. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  1264. int subYear = Integer.parseInt(year) - 1;
  1265. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  1266. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  1267. sameperiodqw.eq("location", "wp");
  1268. if (type.equals("-1")) {
  1269. currentqw.like("foreign_key_id", "_FDC_");
  1270. } else {
  1271. currentqw.like("foreign_key_id", "_GDC_");
  1272. }
  1273. if (companys.endsWith("ZGS")) {
  1274. currentqw.eq("company_id", companys);
  1275. } else {
  1276. currentqw.eq("region_id", companys);
  1277. }
  1278. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1279. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1280. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  1281. sameperiodqw.clear();
  1282. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rswdldb) yswdldb");
  1283. sameperiodqw.eq("foreign_key_id", companys + type);
  1284. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1285. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1286. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  1287. //合并当月与同期数据为返回结果
  1288. List<SpecificTargetVo> resultList = new ArrayList<>();
  1289. currentList.stream().forEach(i -> {
  1290. SpecificTargetVo vo = new SpecificTargetVo();
  1291. String wpid = i.getForeignKeyId();
  1292. vo.setWpid(wpid);
  1293. if (wpid.contains("_ZGS")) {
  1294. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1295. } else if (wpid.contains("_RGN")) {
  1296. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1297. } else {
  1298. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1299. }
  1300. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1301. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1302. vo.setCurrent(DoubleUtils.keepPrecision(i.getYswdldb().doubleValue() / 10000, 2));
  1303. resultList.add(vo);
  1304. });
  1305. resultList.stream().forEach(i -> {
  1306. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  1307. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  1308. .findFirst();
  1309. if (optional.isPresent()) {
  1310. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  1311. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYswdldb().doubleValue() / 10000, 2));
  1312. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1313. } else {
  1314. i.setSameperiod(0.0);
  1315. i.setCompare(0);
  1316. }
  1317. });
  1318. List<SpecificTarget> resultendList = new ArrayList<>();
  1319. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1320. resultList.stream().forEach(i -> {
  1321. if (map.containsKey(i.getWpid())) {
  1322. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1323. if (!integerListMap.containsKey(i.getMonth())) {
  1324. map.get(i.getWpid()).put(i.getMonth(), i);
  1325. } else {
  1326. }
  1327. } else {
  1328. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1329. tempMap.put(i.getMonth(), i);
  1330. map.put(i.getWpid(), tempMap);
  1331. }
  1332. });
  1333. Set<String> wpids = map.keySet();
  1334. if (StringUtils.isNotNull(wpids)) {
  1335. wpids.stream().forEach(wpid -> {
  1336. SpecificTarget vo = new SpecificTarget();
  1337. vo.setWpid(wpid);
  1338. int orderNum = 100;
  1339. if (wpid.contains("_ZGS")) {
  1340. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1341. } else if (wpid.contains("_RGN")) {
  1342. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1343. } else {
  1344. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1345. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1346. }
  1347. vo.setOrderNum(orderNum);
  1348. List<SpecificTargetVo> tempList = new ArrayList<>();
  1349. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1350. for (int x = 1; x <= 12; x++) {
  1351. if (listMap.containsKey(x)) {
  1352. tempList.add(listMap.get(x));
  1353. } else {
  1354. SpecificTargetVo vo1 = new SpecificTargetVo();
  1355. vo1.setWpid(wpid);
  1356. if (wpid.contains("_ZGS")) {
  1357. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1358. } else if (wpid.contains("_RGN")) {
  1359. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1360. } else {
  1361. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1362. }
  1363. vo1.setYear(Integer.parseInt(year));
  1364. vo1.setMonth(x);
  1365. tempList.add(vo1);
  1366. }
  1367. }
  1368. vo.setTargetList(tempList);
  1369. resultendList.add(vo);
  1370. });
  1371. }
  1372. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1373. return resultendList;
  1374. }
  1375. public List<SpecificTarget> lyxsList(String companys, String type, String year) {
  1376. //获取年份所有当月的数据
  1377. QueryWrapper<ProEconPowerstationInfoDay5> currentqw = new QueryWrapper<>();
  1378. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1379. currentqw.eq("location", "wp");
  1380. currentqw.eq("to_char(record_date,'yyyy')", year);
  1381. if (type.equals("-1")) {
  1382. currentqw.like("foreign_key_id", "_FDC_");
  1383. } else {
  1384. currentqw.like("foreign_key_id", "_GDC_");
  1385. }
  1386. if (companys.endsWith("ZGS")) {
  1387. currentqw.eq("company_id", companys);
  1388. } else {
  1389. currentqw.eq("region_id", companys);
  1390. }
  1391. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1392. List<ProEconPowerstationInfoDay5> currentList = proEconPowerstationInfoDay5Service.list(currentqw);
  1393. currentqw.clear();
  1394. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1395. currentqw.eq("foreign_key_id", companys + type);
  1396. currentqw.eq("to_char(record_date,'yyyy')", year);
  1397. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1398. currentList.addAll(proEconPowerstationInfoDay5Service.list(currentqw));
  1399. int subYear = Integer.parseInt(year) - 1;
  1400. QueryWrapper<ProEconPowerstationInfoDay5> sameperiodqw = new QueryWrapper<>();
  1401. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1402. sameperiodqw.eq("location", "wp");
  1403. if (type.equals("-1")) {
  1404. currentqw.like("foreign_key_id", "_FDC_");
  1405. } else {
  1406. currentqw.like("foreign_key_id", "_GDC_");
  1407. }
  1408. if (companys.endsWith("ZGS")) {
  1409. currentqw.eq("company_id", companys);
  1410. } else {
  1411. currentqw.eq("region_id", companys);
  1412. }
  1413. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1414. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1415. List<ProEconPowerstationInfoDay5> sameperiodList = proEconPowerstationInfoDay5Service.list(sameperiodqw);
  1416. sameperiodqw.clear();
  1417. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rfdldb) yfdldb");
  1418. sameperiodqw.eq("foreign_key_id", companys + type);
  1419. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1420. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1421. sameperiodList.addAll(proEconPowerstationInfoDay5Service.list(sameperiodqw));
  1422. //合并当月与同期数据为返回结果
  1423. List<SpecificTargetVo> resultList = new ArrayList<>();
  1424. currentList.stream().forEach(i -> {
  1425. SpecificTargetVo vo = new SpecificTargetVo();
  1426. String wpid = i.getForeignKeyId();
  1427. List<ProBasicPowerstation> rl = CacheContext.wpls.stream().filter(wp -> wpid.equals(wp.getId())).collect(Collectors.toList());
  1428. List<ProBasicCompany> gsrl = CacheContext.cpls.stream().filter(wp -> wpid.contains(wp.getId())).collect(Collectors.toList());
  1429. double capacity = 1;
  1430. if (!rl.isEmpty() && rl.size()>0) {
  1431. capacity = (rl.get(0).getJrCapacity() / 10000) + (rl.get(0).getJrwindCapacity() / 10000);
  1432. }else {
  1433. capacity = (gsrl.get(0).getJrCapacity() / 10000) + (gsrl.get(0).getJrwindCapacity() / 10000);
  1434. }
  1435. vo.setWpid(wpid);
  1436. if (wpid.contains("_ZGS")) {
  1437. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1438. } else if (wpid.contains("_RGN")) {
  1439. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1440. } else {
  1441. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1442. }
  1443. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1444. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1445. vo.setCurrent(DoubleUtils.keepPrecision((i.getYfdldb().doubleValue() / 10000) / capacity, 2));
  1446. resultList.add(vo);
  1447. });
  1448. resultList.stream().forEach(i -> {
  1449. Optional<ProEconPowerstationInfoDay5> optional = sameperiodList.stream()
  1450. .filter(j -> i.getWpid().equals(j.getForeignKeyId())
  1451. && i.getMonth().equals(DateUtils.getMonthFromDate(j.getRecordDate())))
  1452. .findFirst();
  1453. List<ProBasicPowerstation> rl = CacheContext.wpls.stream().filter(wp -> i.getWpid().equals(wp.getId())).collect(Collectors.toList());
  1454. List<ProBasicCompany> gsrl = CacheContext.cpls.stream().filter(wp -> i.getWpid().contains(wp.getId())).collect(Collectors.toList());
  1455. double capacity = 1;
  1456. if (!rl.isEmpty() && rl.size()>0) {
  1457. capacity = (rl.get(0).getJrCapacity() / 10000) + (rl.get(0).getJrwindCapacity() / 10000);
  1458. }else {
  1459. capacity = (gsrl.get(0).getJrCapacity() / 10000) + (gsrl.get(0).getJrwindCapacity() / 10000);
  1460. }
  1461. if (optional.isPresent()) {
  1462. ProEconPowerstationInfoDay5 tqinfoday = optional.get();
  1463. i.setSameperiod(DoubleUtils.keepPrecision(((tqinfoday.getYfdldb().doubleValue() / 10000)) / capacity , 2));
  1464. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1465. } else {
  1466. i.setSameperiod(0.0);
  1467. i.setCompare(0);
  1468. }
  1469. });
  1470. List<SpecificTarget> resultendList = new ArrayList<>();
  1471. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1472. resultList.stream().forEach(i -> {
  1473. if (map.containsKey(i.getWpid())) {
  1474. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1475. if (!integerListMap.containsKey(i.getMonth())) {
  1476. map.get(i.getWpid()).put(i.getMonth(), i);
  1477. } else {
  1478. }
  1479. } else {
  1480. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1481. tempMap.put(i.getMonth(), i);
  1482. map.put(i.getWpid(), tempMap);
  1483. }
  1484. });
  1485. Set<String> wpids = map.keySet();
  1486. if (StringUtils.isNotNull(wpids)) {
  1487. wpids.stream().forEach(wpid -> {
  1488. SpecificTarget vo = new SpecificTarget();
  1489. vo.setWpid(wpid);
  1490. int orderNum = 100;
  1491. if (wpid.contains("_ZGS")) {
  1492. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1493. } else if (wpid.contains("_RGN")) {
  1494. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1495. } else {
  1496. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1497. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1498. }
  1499. vo.setOrderNum(orderNum);
  1500. List<SpecificTargetVo> tempList = new ArrayList<>();
  1501. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1502. for (int x = 1; x <= 12; x++) {
  1503. if (listMap.containsKey(x)) {
  1504. tempList.add(listMap.get(x));
  1505. } else {
  1506. SpecificTargetVo vo1 = new SpecificTargetVo();
  1507. vo1.setWpid(wpid);
  1508. if (wpid.contains("_ZGS")) {
  1509. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1510. } else if (wpid.contains("_RGN")) {
  1511. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1512. } else {
  1513. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1514. }
  1515. vo1.setYear(Integer.parseInt(year));
  1516. vo1.setMonth(x);
  1517. tempList.add(vo1);
  1518. }
  1519. }
  1520. vo.setTargetList(tempList);
  1521. resultendList.add(vo);
  1522. });
  1523. }
  1524. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1525. return resultendList;
  1526. }
  1527. public List<SpecificTarget> gzsslList(String companys, String type, String year) {
  1528. //获取年份所有当月的数据
  1529. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  1530. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  1531. currentqw.eq("location", "wp");
  1532. currentqw.eq("to_char(record_date,'yyyy')", year);
  1533. if (type.equals("-1")) {
  1534. currentqw.like("foreign_key_id", "_FDC_");
  1535. } else {
  1536. currentqw.like("foreign_key_id", "_GDC_");
  1537. }
  1538. if (companys.endsWith("ZGS")) {
  1539. currentqw.eq("company_id", companys);
  1540. } else {
  1541. currentqw.eq("region_id", companys);
  1542. }
  1543. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1544. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  1545. currentqw.clear();
  1546. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  1547. currentqw.eq("foreign_key_id", companys + type);
  1548. currentqw.eq("to_char(record_date,'yyyy')", year);
  1549. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1550. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  1551. int subYear = Integer.parseInt(year) - 1;
  1552. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  1553. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  1554. sameperiodqw.eq("location", "wp");
  1555. if (type.equals("-1")) {
  1556. currentqw.like("foreign_key_id", "_FDC_");
  1557. } else {
  1558. currentqw.like("foreign_key_id", "_GDC_");
  1559. }
  1560. if (companys.endsWith("ZGS")) {
  1561. currentqw.eq("company_id", companys);
  1562. } else {
  1563. currentqw.eq("region_id", companys);
  1564. }
  1565. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1566. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1567. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  1568. sameperiodqw.clear();
  1569. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rgzssdl) ygzssdl,sum(rcnslgzssdl) ycnslgzssdl,sum(rllfdl) yllfdl");
  1570. sameperiodqw.eq("foreign_key_id", companys + type);
  1571. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1572. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1573. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  1574. //合并当月与同期数据为返回结果
  1575. List<SpecificTargetVo> resultList = new ArrayList<>();
  1576. currentList.stream().forEach(i -> {
  1577. SpecificTargetVo vo = new SpecificTargetVo();
  1578. String wpid = i.getForeignKeyId();
  1579. vo.setWpid(wpid);
  1580. if (wpid.contains("_ZGS")) {
  1581. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1582. } else if (wpid.contains("_RGN")) {
  1583. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1584. } else {
  1585. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1586. }
  1587. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1588. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1589. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYgzssdl().doubleValue() + i.getYcnslgzssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  1590. resultList.add(vo);
  1591. });
  1592. resultList.stream().forEach(i -> {
  1593. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  1594. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  1595. .findFirst();
  1596. if (optional.isPresent()) {
  1597. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  1598. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYgzssdl().doubleValue() + tqinfoday.getYcnslgzssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  1599. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1600. } else {
  1601. i.setSameperiod(0.0);
  1602. i.setCompare(0);
  1603. }
  1604. });
  1605. List<SpecificTarget> resultendList = new ArrayList<>();
  1606. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1607. resultList.stream().forEach(i -> {
  1608. if (map.containsKey(i.getWpid())) {
  1609. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1610. if (!integerListMap.containsKey(i.getMonth())) {
  1611. map.get(i.getWpid()).put(i.getMonth(), i);
  1612. } else {
  1613. }
  1614. } else {
  1615. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1616. tempMap.put(i.getMonth(), i);
  1617. map.put(i.getWpid(), tempMap);
  1618. }
  1619. });
  1620. Set<String> wpids = map.keySet();
  1621. if (StringUtils.isNotNull(wpids)) {
  1622. wpids.stream().forEach(wpid -> {
  1623. SpecificTarget vo = new SpecificTarget();
  1624. vo.setWpid(wpid);
  1625. int orderNum = 100;
  1626. if (wpid.contains("_ZGS")) {
  1627. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1628. } else if (wpid.contains("_RGN")) {
  1629. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1630. } else {
  1631. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1632. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1633. }
  1634. vo.setOrderNum(orderNum);
  1635. List<SpecificTargetVo> tempList = new ArrayList<>();
  1636. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1637. for (int x = 1; x <= 12; x++) {
  1638. if (listMap.containsKey(x)) {
  1639. tempList.add(listMap.get(x));
  1640. } else {
  1641. SpecificTargetVo vo1 = new SpecificTargetVo();
  1642. vo1.setWpid(wpid);
  1643. if (wpid.contains("_ZGS")) {
  1644. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1645. } else if (wpid.contains("_RGN")) {
  1646. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1647. } else {
  1648. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1649. }
  1650. vo1.setYear(Integer.parseInt(year));
  1651. vo1.setMonth(x);
  1652. tempList.add(vo1);
  1653. }
  1654. }
  1655. vo.setTargetList(tempList);
  1656. resultendList.add(vo);
  1657. });
  1658. }
  1659. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1660. return resultendList;
  1661. }
  1662. public List<SpecificTarget> whsslList(String companys, String type, String year) {
  1663. //获取年份所有当月的数据
  1664. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  1665. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  1666. currentqw.eq("location", "wp");
  1667. currentqw.eq("to_char(record_date,'yyyy')", year);
  1668. if (type.equals("-1")) {
  1669. currentqw.like("foreign_key_id", "_FDC_");
  1670. } else {
  1671. currentqw.like("foreign_key_id", "_GDC_");
  1672. }
  1673. if (companys.endsWith("ZGS")) {
  1674. currentqw.eq("company_id", companys);
  1675. } else {
  1676. currentqw.eq("region_id", companys);
  1677. }
  1678. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1679. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  1680. currentqw.clear();
  1681. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  1682. currentqw.eq("foreign_key_id", companys + type);
  1683. currentqw.eq("to_char(record_date,'yyyy')", year);
  1684. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1685. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  1686. int subYear = Integer.parseInt(year) - 1;
  1687. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  1688. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  1689. sameperiodqw.eq("location", "wp");
  1690. if (type.equals("-1")) {
  1691. currentqw.like("foreign_key_id", "_FDC_");
  1692. } else {
  1693. currentqw.like("foreign_key_id", "_GDC_");
  1694. }
  1695. if (companys.endsWith("ZGS")) {
  1696. currentqw.eq("company_id", companys);
  1697. } else {
  1698. currentqw.eq("region_id", companys);
  1699. }
  1700. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1701. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1702. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  1703. sameperiodqw.clear();
  1704. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rjxssdl) yjxssdl,sum(rcnsljxssdl) ycnsljxssdl,sum(rllfdl) yllfdl");
  1705. sameperiodqw.eq("foreign_key_id", companys + type);
  1706. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1707. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1708. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  1709. //合并当月与同期数据为返回结果
  1710. List<SpecificTargetVo> resultList = new ArrayList<>();
  1711. currentList.stream().forEach(i -> {
  1712. SpecificTargetVo vo = new SpecificTargetVo();
  1713. String wpid = i.getForeignKeyId();
  1714. vo.setWpid(wpid);
  1715. if (wpid.contains("_ZGS")) {
  1716. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1717. } else if (wpid.contains("_RGN")) {
  1718. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1719. } else {
  1720. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1721. }
  1722. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1723. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1724. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYjxssdl().doubleValue() + i.getYcnsljxssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  1725. resultList.add(vo);
  1726. });
  1727. resultList.stream().forEach(i -> {
  1728. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  1729. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  1730. .findFirst();
  1731. if (optional.isPresent()) {
  1732. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  1733. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYjxssdl().doubleValue() + tqinfoday.getYcnsljxssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  1734. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1735. } else {
  1736. i.setSameperiod(0.0);
  1737. i.setCompare(0);
  1738. }
  1739. });
  1740. List<SpecificTarget> resultendList = new ArrayList<>();
  1741. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1742. resultList.stream().forEach(i -> {
  1743. if (map.containsKey(i.getWpid())) {
  1744. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1745. if (!integerListMap.containsKey(i.getMonth())) {
  1746. map.get(i.getWpid()).put(i.getMonth(), i);
  1747. } else {
  1748. }
  1749. } else {
  1750. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1751. tempMap.put(i.getMonth(), i);
  1752. map.put(i.getWpid(), tempMap);
  1753. }
  1754. });
  1755. Set<String> wpids = map.keySet();
  1756. if (StringUtils.isNotNull(wpids)) {
  1757. wpids.stream().forEach(wpid -> {
  1758. SpecificTarget vo = new SpecificTarget();
  1759. vo.setWpid(wpid);
  1760. int orderNum = 100;
  1761. if (wpid.contains("_ZGS")) {
  1762. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1763. } else if (wpid.contains("_RGN")) {
  1764. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1765. } else {
  1766. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1767. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1768. }
  1769. vo.setOrderNum(orderNum);
  1770. List<SpecificTargetVo> tempList = new ArrayList<>();
  1771. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1772. for (int x = 1; x <= 12; x++) {
  1773. if (listMap.containsKey(x)) {
  1774. tempList.add(listMap.get(x));
  1775. } else {
  1776. SpecificTargetVo vo1 = new SpecificTargetVo();
  1777. vo1.setWpid(wpid);
  1778. if (wpid.contains("_ZGS")) {
  1779. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1780. } else if (wpid.contains("_RGN")) {
  1781. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1782. } else {
  1783. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1784. }
  1785. vo1.setYear(Integer.parseInt(year));
  1786. vo1.setMonth(x);
  1787. tempList.add(vo1);
  1788. }
  1789. }
  1790. vo.setTargetList(tempList);
  1791. resultendList.add(vo);
  1792. });
  1793. }
  1794. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1795. return resultendList;
  1796. }
  1797. public List<SpecificTarget> xdsslList(String companys, String type, String year) {
  1798. //获取年份所有当月的数据
  1799. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  1800. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  1801. currentqw.eq("location", "wp");
  1802. currentqw.eq("to_char(record_date,'yyyy')", year);
  1803. if (type.equals("-1")) {
  1804. currentqw.like("foreign_key_id", "_FDC_");
  1805. } else {
  1806. currentqw.like("foreign_key_id", "_GDC_");
  1807. }
  1808. if (companys.endsWith("ZGS")) {
  1809. currentqw.eq("company_id", companys);
  1810. } else {
  1811. currentqw.eq("region_id", companys);
  1812. }
  1813. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1814. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  1815. currentqw.clear();
  1816. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  1817. currentqw.eq("foreign_key_id", companys + type);
  1818. currentqw.eq("to_char(record_date,'yyyy')", year);
  1819. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1820. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  1821. int subYear = Integer.parseInt(year) - 1;
  1822. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  1823. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  1824. sameperiodqw.eq("location", "wp");
  1825. if (type.equals("-1")) {
  1826. currentqw.like("foreign_key_id", "_FDC_");
  1827. } else {
  1828. currentqw.like("foreign_key_id", "_GDC_");
  1829. }
  1830. if (companys.endsWith("ZGS")) {
  1831. currentqw.eq("company_id", companys);
  1832. } else {
  1833. currentqw.eq("region_id", companys);
  1834. }
  1835. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1836. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1837. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  1838. sameperiodqw.clear();
  1839. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rxdtjssdl) yxdtjssdl,sum(rxdjclssdl) yxdjclssdl,sum(rllfdl) yllfdl");
  1840. sameperiodqw.eq("foreign_key_id", companys + type);
  1841. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1842. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1843. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  1844. //合并当月与同期数据为返回结果
  1845. List<SpecificTargetVo> resultList = new ArrayList<>();
  1846. currentList.stream().forEach(i -> {
  1847. SpecificTargetVo vo = new SpecificTargetVo();
  1848. String wpid = i.getForeignKeyId();
  1849. vo.setWpid(wpid);
  1850. if (wpid.contains("_ZGS")) {
  1851. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1852. } else if (wpid.contains("_RGN")) {
  1853. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1854. } else {
  1855. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1856. }
  1857. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1858. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1859. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYxdjclssdl().doubleValue() + i.getYxdtjssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  1860. resultList.add(vo);
  1861. });
  1862. resultList.stream().forEach(i -> {
  1863. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  1864. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  1865. .findFirst();
  1866. if (optional.isPresent()) {
  1867. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  1868. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYxdjclssdl().doubleValue() + tqinfoday.getYxdtjssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  1869. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  1870. } else {
  1871. i.setSameperiod(0.0);
  1872. i.setCompare(0);
  1873. }
  1874. });
  1875. List<SpecificTarget> resultendList = new ArrayList<>();
  1876. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  1877. resultList.stream().forEach(i -> {
  1878. if (map.containsKey(i.getWpid())) {
  1879. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  1880. if (!integerListMap.containsKey(i.getMonth())) {
  1881. map.get(i.getWpid()).put(i.getMonth(), i);
  1882. } else {
  1883. }
  1884. } else {
  1885. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  1886. tempMap.put(i.getMonth(), i);
  1887. map.put(i.getWpid(), tempMap);
  1888. }
  1889. });
  1890. Set<String> wpids = map.keySet();
  1891. if (StringUtils.isNotNull(wpids)) {
  1892. wpids.stream().forEach(wpid -> {
  1893. SpecificTarget vo = new SpecificTarget();
  1894. vo.setWpid(wpid);
  1895. int orderNum = 100;
  1896. if (wpid.contains("_ZGS")) {
  1897. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1898. } else if (wpid.contains("_RGN")) {
  1899. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1900. } else {
  1901. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1902. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  1903. }
  1904. vo.setOrderNum(orderNum);
  1905. List<SpecificTargetVo> tempList = new ArrayList<>();
  1906. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  1907. for (int x = 1; x <= 12; x++) {
  1908. if (listMap.containsKey(x)) {
  1909. tempList.add(listMap.get(x));
  1910. } else {
  1911. SpecificTargetVo vo1 = new SpecificTargetVo();
  1912. vo1.setWpid(wpid);
  1913. if (wpid.contains("_ZGS")) {
  1914. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  1915. } else if (wpid.contains("_RGN")) {
  1916. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  1917. } else {
  1918. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1919. }
  1920. vo1.setYear(Integer.parseInt(year));
  1921. vo1.setMonth(x);
  1922. tempList.add(vo1);
  1923. }
  1924. }
  1925. vo.setTargetList(tempList);
  1926. resultendList.add(vo);
  1927. });
  1928. }
  1929. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  1930. return resultendList;
  1931. }
  1932. public List<SpecificTarget> xnsslList(String companys, String type, String year) {
  1933. //获取年份所有当月的数据
  1934. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  1935. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  1936. currentqw.eq("location", "wp");
  1937. currentqw.eq("to_char(record_date,'yyyy')", year);
  1938. if (type.equals("-1")) {
  1939. currentqw.like("foreign_key_id", "_FDC_");
  1940. } else {
  1941. currentqw.like("foreign_key_id", "_GDC_");
  1942. }
  1943. if (companys.endsWith("ZGS")) {
  1944. currentqw.eq("company_id", companys);
  1945. } else {
  1946. currentqw.eq("region_id", companys);
  1947. }
  1948. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1949. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  1950. currentqw.clear();
  1951. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  1952. currentqw.eq("foreign_key_id", companys + type);
  1953. currentqw.eq("to_char(record_date,'yyyy')", year);
  1954. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1955. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  1956. int subYear = Integer.parseInt(year) - 1;
  1957. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  1958. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  1959. sameperiodqw.eq("location", "wp");
  1960. if (type.equals("-1")) {
  1961. currentqw.like("foreign_key_id", "_FDC_");
  1962. } else {
  1963. currentqw.like("foreign_key_id", "_GDC_");
  1964. }
  1965. if (companys.endsWith("ZGS")) {
  1966. currentqw.eq("company_id", companys);
  1967. } else {
  1968. currentqw.eq("region_id", companys);
  1969. }
  1970. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1971. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1972. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  1973. sameperiodqw.clear();
  1974. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rdjssdl) ydjssdl,sum(rqxjclssdl) yqxjclssdl,sum(rsdtjssdl) ysdtjssdl,sum(rxnssdl) yxnssdl,sum(rllfdl) yllfdl");
  1975. sameperiodqw.eq("foreign_key_id", companys + type);
  1976. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  1977. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  1978. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  1979. //合并当月与同期数据为返回结果
  1980. List<SpecificTargetVo> resultList = new ArrayList<>();
  1981. currentList.stream().forEach(i -> {
  1982. SpecificTargetVo vo = new SpecificTargetVo();
  1983. String wpid = i.getForeignKeyId();
  1984. vo.setWpid(wpid);
  1985. if (wpid.contains("_ZGS")) {
  1986. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  1987. } else if (wpid.contains("_RGN")) {
  1988. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  1989. } else {
  1990. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  1991. }
  1992. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  1993. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  1994. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYdjssdl().doubleValue() + i.getYqxjclssdl().doubleValue() + i.getYsdtjssdl().doubleValue() + i.getYxnssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  1995. resultList.add(vo);
  1996. });
  1997. resultList.stream().forEach(i -> {
  1998. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  1999. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2000. .findFirst();
  2001. if (optional.isPresent()) {
  2002. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  2003. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYdjssdl().doubleValue() + tqinfoday.getYqxjclssdl().doubleValue() + tqinfoday.getYsdtjssdl().doubleValue() + tqinfoday.getYxnssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  2004. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2005. } else {
  2006. i.setSameperiod(0.0);
  2007. i.setCompare(0);
  2008. }
  2009. });
  2010. List<SpecificTarget> resultendList = new ArrayList<>();
  2011. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2012. resultList.stream().forEach(i -> {
  2013. if (map.containsKey(i.getWpid())) {
  2014. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2015. if (!integerListMap.containsKey(i.getMonth())) {
  2016. map.get(i.getWpid()).put(i.getMonth(), i);
  2017. } else {
  2018. }
  2019. } else {
  2020. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2021. tempMap.put(i.getMonth(), i);
  2022. map.put(i.getWpid(), tempMap);
  2023. }
  2024. });
  2025. Set<String> wpids = map.keySet();
  2026. if (StringUtils.isNotNull(wpids)) {
  2027. wpids.stream().forEach(wpid -> {
  2028. SpecificTarget vo = new SpecificTarget();
  2029. vo.setWpid(wpid);
  2030. int orderNum = 100;
  2031. if (wpid.contains("_ZGS")) {
  2032. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2033. } else if (wpid.contains("_RGN")) {
  2034. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2035. } else {
  2036. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2037. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2038. }
  2039. vo.setOrderNum(orderNum);
  2040. List<SpecificTargetVo> tempList = new ArrayList<>();
  2041. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2042. for (int x = 1; x <= 12; x++) {
  2043. if (listMap.containsKey(x)) {
  2044. tempList.add(listMap.get(x));
  2045. } else {
  2046. SpecificTargetVo vo1 = new SpecificTargetVo();
  2047. vo1.setWpid(wpid);
  2048. if (wpid.contains("_ZGS")) {
  2049. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2050. } else if (wpid.contains("_RGN")) {
  2051. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2052. } else {
  2053. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2054. }
  2055. vo1.setYear(Integer.parseInt(year));
  2056. vo1.setMonth(x);
  2057. tempList.add(vo1);
  2058. }
  2059. }
  2060. vo.setTargetList(tempList);
  2061. resultendList.add(vo);
  2062. });
  2063. }
  2064. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2065. return resultendList;
  2066. }
  2067. public List<SpecificTarget> slsslList(String companys, String type, String year) {
  2068. //获取年份所有当月的数据
  2069. QueryWrapper<ProEconPowerstationInfoDay1> currentqw = new QueryWrapper<>();
  2070. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  2071. currentqw.eq("location", "wp");
  2072. currentqw.eq("to_char(record_date,'yyyy')", year);
  2073. if (type.equals("-1")) {
  2074. currentqw.like("foreign_key_id", "_FDC_");
  2075. } else {
  2076. currentqw.like("foreign_key_id", "_GDC_");
  2077. }
  2078. if (companys.endsWith("ZGS")) {
  2079. currentqw.eq("company_id", companys);
  2080. } else {
  2081. currentqw.eq("region_id", companys);
  2082. }
  2083. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2084. List<ProEconPowerstationInfoDay1> currentList = proEconPowerstationInfoDay1Service.list(currentqw);
  2085. currentqw.clear();
  2086. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  2087. currentqw.eq("foreign_key_id", companys + type);
  2088. currentqw.eq("to_char(record_date,'yyyy')", year);
  2089. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2090. currentList.addAll(proEconPowerstationInfoDay1Service.list(currentqw));
  2091. int subYear = Integer.parseInt(year) - 1;
  2092. QueryWrapper<ProEconPowerstationInfoDay1> sameperiodqw = new QueryWrapper<>();
  2093. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  2094. sameperiodqw.eq("location", "wp");
  2095. if (type.equals("-1")) {
  2096. currentqw.like("foreign_key_id", "_FDC_");
  2097. } else {
  2098. currentqw.like("foreign_key_id", "_GDC_");
  2099. }
  2100. if (companys.endsWith("ZGS")) {
  2101. currentqw.eq("company_id", companys);
  2102. } else {
  2103. currentqw.eq("region_id", companys);
  2104. }
  2105. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2106. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2107. List<ProEconPowerstationInfoDay1> sameperiodList = proEconPowerstationInfoDay1Service.list(sameperiodqw);
  2108. sameperiodqw.clear();
  2109. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rcwsldwssdl) ycwsldwssdl,sum(rcwsltqssdl) ycwsltqssdl,sum(rllfdl) yllfdl");
  2110. sameperiodqw.eq("foreign_key_id", companys + type);
  2111. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2112. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2113. sameperiodList.addAll(proEconPowerstationInfoDay1Service.list(sameperiodqw));
  2114. //合并当月与同期数据为返回结果
  2115. List<SpecificTargetVo> resultList = new ArrayList<>();
  2116. currentList.stream().forEach(i -> {
  2117. SpecificTargetVo vo = new SpecificTargetVo();
  2118. String wpid = i.getForeignKeyId();
  2119. vo.setWpid(wpid);
  2120. if (wpid.contains("_ZGS")) {
  2121. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2122. } else if (wpid.contains("_RGN")) {
  2123. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2124. } else {
  2125. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2126. }
  2127. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2128. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2129. vo.setCurrent(DoubleUtils.keepPrecision(i.getYllfdl().doubleValue() != 0 ? (i.getYcwsldwssdl().doubleValue() + i.getYcwsltqssdl().doubleValue()) / i.getYllfdl().doubleValue() * 100 : 0, 2));
  2130. resultList.add(vo);
  2131. });
  2132. resultList.stream().forEach(i -> {
  2133. Optional<ProEconPowerstationInfoDay1> optional = sameperiodList.stream()
  2134. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2135. .findFirst();
  2136. if (optional.isPresent()) {
  2137. ProEconPowerstationInfoDay1 tqinfoday = optional.get();
  2138. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYllfdl().doubleValue() != 0 ? (tqinfoday.getYcwsldwssdl().doubleValue() + tqinfoday.getYcwsltqssdl().doubleValue()) / tqinfoday.getYllfdl().doubleValue() * 100 : 0, 2));
  2139. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2140. } else {
  2141. i.setSameperiod(0.0);
  2142. i.setCompare(0);
  2143. }
  2144. });
  2145. List<SpecificTarget> resultendList = new ArrayList<>();
  2146. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2147. resultList.stream().forEach(i -> {
  2148. if (map.containsKey(i.getWpid())) {
  2149. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2150. if (!integerListMap.containsKey(i.getMonth())) {
  2151. map.get(i.getWpid()).put(i.getMonth(), i);
  2152. } else {
  2153. }
  2154. } else {
  2155. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2156. tempMap.put(i.getMonth(), i);
  2157. map.put(i.getWpid(), tempMap);
  2158. }
  2159. });
  2160. Set<String> wpids = map.keySet();
  2161. if (StringUtils.isNotNull(wpids)) {
  2162. wpids.stream().forEach(wpid -> {
  2163. SpecificTarget vo = new SpecificTarget();
  2164. vo.setWpid(wpid);
  2165. int orderNum = 100;
  2166. if (wpid.contains("_ZGS")) {
  2167. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2168. } else if (wpid.contains("_RGN")) {
  2169. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2170. } else {
  2171. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2172. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2173. }
  2174. vo.setOrderNum(orderNum);
  2175. List<SpecificTargetVo> tempList = new ArrayList<>();
  2176. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2177. for (int x = 1; x <= 12; x++) {
  2178. if (listMap.containsKey(x)) {
  2179. tempList.add(listMap.get(x));
  2180. } else {
  2181. SpecificTargetVo vo1 = new SpecificTargetVo();
  2182. vo1.setWpid(wpid);
  2183. if (wpid.contains("_ZGS")) {
  2184. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2185. } else if (wpid.contains("_RGN")) {
  2186. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2187. } else {
  2188. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2189. }
  2190. vo1.setYear(Integer.parseInt(year));
  2191. vo1.setMonth(x);
  2192. tempList.add(vo1);
  2193. }
  2194. }
  2195. vo.setTargetList(tempList);
  2196. resultendList.add(vo);
  2197. });
  2198. }
  2199. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2200. return resultendList;
  2201. }
  2202. public List<SpecificTarget> fwjslList(String companys, String type, String year) {
  2203. //获取年份所有当月的数据
  2204. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  2205. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  2206. currentqw.eq("location", "wp");
  2207. currentqw.eq("to_char(record_date,'yyyy')", year);
  2208. if (type.equals("-1")) {
  2209. currentqw.like("foreign_key_id", "_FDC_");
  2210. } else {
  2211. currentqw.like("foreign_key_id", "_GDC_");
  2212. }
  2213. if (companys.endsWith("ZGS")) {
  2214. currentqw.eq("company_id", companys);
  2215. } else {
  2216. currentqw.eq("region_id", companys);
  2217. }
  2218. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2219. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  2220. currentqw.clear();
  2221. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  2222. currentqw.eq("foreign_key_id", companys + type);
  2223. currentqw.eq("to_char(record_date,'yyyy')", year);
  2224. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2225. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  2226. int subYear = Integer.parseInt(year) - 1;
  2227. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  2228. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  2229. sameperiodqw.eq("location", "wp");
  2230. if (type.equals("-1")) {
  2231. currentqw.like("foreign_key_id", "_FDC_");
  2232. } else {
  2233. currentqw.like("foreign_key_id", "_GDC_");
  2234. }
  2235. if (companys.endsWith("ZGS")) {
  2236. currentqw.eq("company_id", companys);
  2237. } else {
  2238. currentqw.eq("region_id", companys);
  2239. }
  2240. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2241. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2242. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  2243. sameperiodqw.clear();
  2244. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yfwjsl) yfwjsl");
  2245. sameperiodqw.eq("foreign_key_id", companys + type);
  2246. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2247. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2248. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  2249. //合并当月与同期数据为返回结果
  2250. List<SpecificTargetVo> resultList = new ArrayList<>();
  2251. currentList.stream().forEach(i -> {
  2252. SpecificTargetVo vo = new SpecificTargetVo();
  2253. String wpid = i.getForeignKeyId();
  2254. vo.setWpid(wpid);
  2255. if (wpid.contains("_ZGS")) {
  2256. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2257. } else if (wpid.contains("_RGN")) {
  2258. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2259. } else {
  2260. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2261. }
  2262. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2263. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2264. vo.setCurrent(DoubleUtils.keepPrecision(i.getYfwjsl().doubleValue(), 2));
  2265. resultList.add(vo);
  2266. });
  2267. resultList.stream().forEach(i -> {
  2268. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  2269. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2270. .findFirst();
  2271. if (optional.isPresent()) {
  2272. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  2273. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYfwjsl().doubleValue(), 2));
  2274. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2275. } else {
  2276. i.setSameperiod(0.0);
  2277. i.setCompare(0);
  2278. }
  2279. });
  2280. List<SpecificTarget> resultendList = new ArrayList<>();
  2281. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2282. resultList.stream().forEach(i -> {
  2283. if (map.containsKey(i.getWpid())) {
  2284. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2285. if (!integerListMap.containsKey(i.getMonth())) {
  2286. map.get(i.getWpid()).put(i.getMonth(), i);
  2287. } else {
  2288. }
  2289. } else {
  2290. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2291. tempMap.put(i.getMonth(), i);
  2292. map.put(i.getWpid(), tempMap);
  2293. }
  2294. });
  2295. Set<String> wpids = map.keySet();
  2296. if (StringUtils.isNotNull(wpids)) {
  2297. wpids.stream().forEach(wpid -> {
  2298. SpecificTarget vo = new SpecificTarget();
  2299. vo.setWpid(wpid);
  2300. int orderNum = 100;
  2301. if (wpid.contains("_ZGS")) {
  2302. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2303. } else if (wpid.contains("_RGN")) {
  2304. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2305. } else {
  2306. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2307. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2308. }
  2309. vo.setOrderNum(orderNum);
  2310. List<SpecificTargetVo> tempList = new ArrayList<>();
  2311. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2312. for (int x = 1; x <= 12; x++) {
  2313. if (listMap.containsKey(x)) {
  2314. tempList.add(listMap.get(x));
  2315. } else {
  2316. SpecificTargetVo vo1 = new SpecificTargetVo();
  2317. vo1.setWpid(wpid);
  2318. if (wpid.contains("_ZGS")) {
  2319. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2320. } else if (wpid.contains("_RGN")) {
  2321. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2322. } else {
  2323. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2324. }
  2325. vo1.setYear(Integer.parseInt(year));
  2326. vo1.setMonth(x);
  2327. tempList.add(vo1);
  2328. }
  2329. }
  2330. vo.setTargetList(tempList);
  2331. resultendList.add(vo);
  2332. });
  2333. }
  2334. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2335. return resultendList;
  2336. }
  2337. public List<SpecificTarget> ztzhlList(String companys, String type, String year) {
  2338. //获取年份所有当月的数据
  2339. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  2340. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  2341. currentqw.eq("location", "wp");
  2342. currentqw.eq("to_char(record_date,'yyyy')", year);
  2343. if (type.equals("-1")) {
  2344. currentqw.like("foreign_key_id", "_FDC_");
  2345. } else {
  2346. currentqw.like("foreign_key_id", "_GDC_");
  2347. }
  2348. if (companys.endsWith("ZGS")) {
  2349. currentqw.eq("company_id", companys);
  2350. } else {
  2351. currentqw.eq("region_id", companys);
  2352. }
  2353. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2354. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  2355. currentqw.clear();
  2356. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  2357. currentqw.eq("foreign_key_id", companys + type);
  2358. currentqw.eq("to_char(record_date,'yyyy')", year);
  2359. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2360. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  2361. int subYear = Integer.parseInt(year) - 1;
  2362. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  2363. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  2364. sameperiodqw.eq("location", "wp");
  2365. if (type.equals("-1")) {
  2366. currentqw.like("foreign_key_id", "_FDC_");
  2367. } else {
  2368. currentqw.like("foreign_key_id", "_GDC_");
  2369. }
  2370. if (companys.endsWith("ZGS")) {
  2371. currentqw.eq("company_id", companys);
  2372. } else {
  2373. currentqw.eq("region_id", companys);
  2374. }
  2375. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2376. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2377. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  2378. sameperiodqw.clear();
  2379. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yztzhjsl) yztzhjsl");
  2380. sameperiodqw.eq("foreign_key_id", companys + type);
  2381. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2382. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2383. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  2384. //合并当月与同期数据为返回结果
  2385. List<SpecificTargetVo> resultList = new ArrayList<>();
  2386. currentList.stream().forEach(i -> {
  2387. SpecificTargetVo vo = new SpecificTargetVo();
  2388. String wpid = i.getForeignKeyId();
  2389. vo.setWpid(wpid);
  2390. if (wpid.contains("_ZGS")) {
  2391. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2392. } else if (wpid.contains("_RGN")) {
  2393. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2394. } else {
  2395. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2396. }
  2397. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2398. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2399. vo.setCurrent(DoubleUtils.keepPrecision(i.getYztzhjsl().doubleValue(), 2));
  2400. resultList.add(vo);
  2401. });
  2402. resultList.stream().forEach(i -> {
  2403. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  2404. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2405. .findFirst();
  2406. if (optional.isPresent()) {
  2407. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  2408. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYztzhjsl().doubleValue(), 2));
  2409. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2410. } else {
  2411. i.setSameperiod(0.0);
  2412. i.setCompare(0);
  2413. }
  2414. });
  2415. List<SpecificTarget> resultendList = new ArrayList<>();
  2416. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2417. resultList.stream().forEach(i -> {
  2418. if (map.containsKey(i.getWpid())) {
  2419. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2420. if (!integerListMap.containsKey(i.getMonth())) {
  2421. map.get(i.getWpid()).put(i.getMonth(), i);
  2422. } else {
  2423. }
  2424. } else {
  2425. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2426. tempMap.put(i.getMonth(), i);
  2427. map.put(i.getWpid(), tempMap);
  2428. }
  2429. });
  2430. Set<String> wpids = map.keySet();
  2431. if (StringUtils.isNotNull(wpids)) {
  2432. wpids.stream().forEach(wpid -> {
  2433. SpecificTarget vo = new SpecificTarget();
  2434. vo.setWpid(wpid);
  2435. int orderNum = 100;
  2436. if (wpid.contains("_ZGS")) {
  2437. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2438. } else if (wpid.contains("_RGN")) {
  2439. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2440. } else {
  2441. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2442. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2443. }
  2444. vo.setOrderNum(orderNum);
  2445. List<SpecificTargetVo> tempList = new ArrayList<>();
  2446. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2447. for (int x = 1; x <= 12; x++) {
  2448. if (listMap.containsKey(x)) {
  2449. tempList.add(listMap.get(x));
  2450. } else {
  2451. SpecificTargetVo vo1 = new SpecificTargetVo();
  2452. vo1.setWpid(wpid);
  2453. if (wpid.contains("_ZGS")) {
  2454. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2455. } else if (wpid.contains("_RGN")) {
  2456. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2457. } else {
  2458. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2459. }
  2460. vo1.setYear(Integer.parseInt(year));
  2461. vo1.setMonth(x);
  2462. tempList.add(vo1);
  2463. }
  2464. }
  2465. vo.setTargetList(tempList);
  2466. resultendList.add(vo);
  2467. });
  2468. }
  2469. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2470. return resultendList;
  2471. }
  2472. public List<SpecificTarget> xqjslList(String companys, String type, String year) {
  2473. //获取年份所有当月的数据
  2474. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  2475. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  2476. currentqw.eq("location", "wp");
  2477. currentqw.eq("to_char(record_date,'yyyy')", year);
  2478. if (type.equals("-1")) {
  2479. currentqw.like("foreign_key_id", "_FDC_");
  2480. } else {
  2481. currentqw.like("foreign_key_id", "_GDC_");
  2482. }
  2483. if (companys.endsWith("ZGS")) {
  2484. currentqw.eq("company_id", companys);
  2485. } else {
  2486. currentqw.eq("region_id", companys);
  2487. }
  2488. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2489. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  2490. currentqw.clear();
  2491. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  2492. currentqw.eq("foreign_key_id", companys + type);
  2493. currentqw.eq("to_char(record_date,'yyyy')", year);
  2494. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2495. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  2496. int subYear = Integer.parseInt(year) - 1;
  2497. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  2498. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  2499. sameperiodqw.eq("location", "wp");
  2500. if (type.equals("-1")) {
  2501. currentqw.like("foreign_key_id", "_FDC_");
  2502. } else {
  2503. currentqw.like("foreign_key_id", "_GDC_");
  2504. }
  2505. if (companys.endsWith("ZGS")) {
  2506. currentqw.eq("company_id", companys);
  2507. } else {
  2508. currentqw.eq("region_id", companys);
  2509. }
  2510. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2511. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2512. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  2513. sameperiodqw.clear();
  2514. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ygzxqjsl) ygzxqjsl");
  2515. sameperiodqw.eq("foreign_key_id", companys + type);
  2516. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2517. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2518. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  2519. //合并当月与同期数据为返回结果
  2520. List<SpecificTargetVo> resultList = new ArrayList<>();
  2521. currentList.stream().forEach(i -> {
  2522. SpecificTargetVo vo = new SpecificTargetVo();
  2523. String wpid = i.getForeignKeyId();
  2524. vo.setWpid(wpid);
  2525. if (wpid.contains("_ZGS")) {
  2526. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2527. } else if (wpid.contains("_RGN")) {
  2528. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2529. } else {
  2530. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2531. }
  2532. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2533. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2534. vo.setCurrent(DoubleUtils.keepPrecision(i.getYgzxqjsl().doubleValue(), 2));
  2535. resultList.add(vo);
  2536. });
  2537. resultList.stream().forEach(i -> {
  2538. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  2539. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2540. .findFirst();
  2541. if (optional.isPresent()) {
  2542. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  2543. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYgzxqjsl().doubleValue(), 2));
  2544. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2545. } else {
  2546. i.setSameperiod(0.0);
  2547. i.setCompare(0);
  2548. }
  2549. });
  2550. List<SpecificTarget> resultendList = new ArrayList<>();
  2551. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2552. resultList.stream().forEach(i -> {
  2553. if (map.containsKey(i.getWpid())) {
  2554. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2555. if (!integerListMap.containsKey(i.getMonth())) {
  2556. map.get(i.getWpid()).put(i.getMonth(), i);
  2557. } else {
  2558. }
  2559. } else {
  2560. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2561. tempMap.put(i.getMonth(), i);
  2562. map.put(i.getWpid(), tempMap);
  2563. }
  2564. });
  2565. Set<String> wpids = map.keySet();
  2566. if (StringUtils.isNotNull(wpids)) {
  2567. wpids.stream().forEach(wpid -> {
  2568. SpecificTarget vo = new SpecificTarget();
  2569. vo.setWpid(wpid);
  2570. int orderNum = 100;
  2571. if (wpid.contains("_ZGS")) {
  2572. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2573. } else if (wpid.contains("_RGN")) {
  2574. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2575. } else {
  2576. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2577. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2578. }
  2579. vo.setOrderNum(orderNum);
  2580. List<SpecificTargetVo> tempList = new ArrayList<>();
  2581. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2582. for (int x = 1; x <= 12; x++) {
  2583. if (listMap.containsKey(x)) {
  2584. tempList.add(listMap.get(x));
  2585. } else {
  2586. SpecificTargetVo vo1 = new SpecificTargetVo();
  2587. vo1.setWpid(wpid);
  2588. if (wpid.contains("_ZGS")) {
  2589. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2590. } else if (wpid.contains("_RGN")) {
  2591. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2592. } else {
  2593. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2594. }
  2595. vo1.setYear(Integer.parseInt(year));
  2596. vo1.setMonth(x);
  2597. tempList.add(vo1);
  2598. }
  2599. }
  2600. vo.setTargetList(tempList);
  2601. resultendList.add(vo);
  2602. });
  2603. }
  2604. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2605. return resultendList;
  2606. }
  2607. public List<SpecificTarget> mtbfList(String companys, String type, String year) {
  2608. //获取年份所有当月的数据
  2609. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  2610. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  2611. currentqw.eq("location", "wp");
  2612. currentqw.eq("to_char(record_date,'yyyy')", year);
  2613. if (type.equals("-1")) {
  2614. currentqw.like("foreign_key_id", "_FDC_");
  2615. } else {
  2616. currentqw.like("foreign_key_id", "_GDC_");
  2617. }
  2618. if (companys.endsWith("ZGS")) {
  2619. currentqw.eq("company_id", companys);
  2620. } else {
  2621. currentqw.eq("region_id", companys);
  2622. }
  2623. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2624. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  2625. currentqw.clear();
  2626. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  2627. currentqw.eq("foreign_key_id", companys + type);
  2628. currentqw.eq("to_char(record_date,'yyyy')", year);
  2629. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2630. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  2631. int subYear = Integer.parseInt(year) - 1;
  2632. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  2633. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  2634. sameperiodqw.eq("location", "wp");
  2635. if (type.equals("-1")) {
  2636. currentqw.like("foreign_key_id", "_FDC_");
  2637. } else {
  2638. currentqw.like("foreign_key_id", "_GDC_");
  2639. }
  2640. if (companys.endsWith("ZGS")) {
  2641. currentqw.eq("company_id", companys);
  2642. } else {
  2643. currentqw.eq("region_id", companys);
  2644. }
  2645. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2646. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2647. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  2648. sameperiodqw.clear();
  2649. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmtbf) ymtbf");
  2650. sameperiodqw.eq("foreign_key_id", companys + type);
  2651. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2652. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2653. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  2654. //合并当月与同期数据为返回结果
  2655. List<SpecificTargetVo> resultList = new ArrayList<>();
  2656. currentList.stream().forEach(i -> {
  2657. SpecificTargetVo vo = new SpecificTargetVo();
  2658. String wpid = i.getForeignKeyId();
  2659. vo.setWpid(wpid);
  2660. if (wpid.contains("_ZGS")) {
  2661. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2662. } else if (wpid.contains("_RGN")) {
  2663. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2664. } else {
  2665. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2666. }
  2667. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2668. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2669. vo.setCurrent(DoubleUtils.keepPrecision(i.getYmtbf().doubleValue(), 2));
  2670. resultList.add(vo);
  2671. });
  2672. resultList.stream().forEach(i -> {
  2673. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  2674. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2675. .findFirst();
  2676. if (optional.isPresent()) {
  2677. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  2678. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYmtbf().doubleValue(), 2));
  2679. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2680. } else {
  2681. i.setSameperiod(0.0);
  2682. i.setCompare(0);
  2683. }
  2684. });
  2685. List<SpecificTarget> resultendList = new ArrayList<>();
  2686. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2687. resultList.stream().forEach(i -> {
  2688. if (map.containsKey(i.getWpid())) {
  2689. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2690. if (!integerListMap.containsKey(i.getMonth())) {
  2691. map.get(i.getWpid()).put(i.getMonth(), i);
  2692. } else {
  2693. }
  2694. } else {
  2695. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2696. tempMap.put(i.getMonth(), i);
  2697. map.put(i.getWpid(), tempMap);
  2698. }
  2699. });
  2700. Set<String> wpids = map.keySet();
  2701. if (StringUtils.isNotNull(wpids)) {
  2702. wpids.stream().forEach(wpid -> {
  2703. SpecificTarget vo = new SpecificTarget();
  2704. vo.setWpid(wpid);
  2705. int orderNum = 100;
  2706. if (wpid.contains("_ZGS")) {
  2707. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2708. } else if (wpid.contains("_RGN")) {
  2709. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2710. } else {
  2711. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2712. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2713. }
  2714. vo.setOrderNum(orderNum);
  2715. List<SpecificTargetVo> tempList = new ArrayList<>();
  2716. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2717. for (int x = 1; x <= 12; x++) {
  2718. if (listMap.containsKey(x)) {
  2719. tempList.add(listMap.get(x));
  2720. } else {
  2721. SpecificTargetVo vo1 = new SpecificTargetVo();
  2722. vo1.setWpid(wpid);
  2723. if (wpid.contains("_ZGS")) {
  2724. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2725. } else if (wpid.contains("_RGN")) {
  2726. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2727. } else {
  2728. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2729. }
  2730. vo1.setYear(Integer.parseInt(year));
  2731. vo1.setMonth(x);
  2732. tempList.add(vo1);
  2733. }
  2734. }
  2735. vo.setTargetList(tempList);
  2736. resultendList.add(vo);
  2737. });
  2738. }
  2739. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2740. return resultendList;
  2741. }
  2742. public List<SpecificTarget> mttrList(String companys, String type, String year) {
  2743. //获取年份所有当月的数据
  2744. QueryWrapper<ProEconPowerstationInfoDay4> currentqw = new QueryWrapper<>();
  2745. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  2746. currentqw.eq("location", "wp");
  2747. currentqw.eq("to_char(record_date,'yyyy')", year);
  2748. if (type.equals("-1")) {
  2749. currentqw.like("foreign_key_id", "_FDC_");
  2750. } else {
  2751. currentqw.like("foreign_key_id", "_GDC_");
  2752. }
  2753. if (companys.endsWith("ZGS")) {
  2754. currentqw.eq("company_id", companys);
  2755. } else {
  2756. currentqw.eq("region_id", companys);
  2757. }
  2758. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2759. List<ProEconPowerstationInfoDay4> currentList = proEconPowerstationInfoDay4Service.list(currentqw);
  2760. currentqw.clear();
  2761. currentqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  2762. currentqw.eq("foreign_key_id", companys + type);
  2763. currentqw.eq("to_char(record_date,'yyyy')", year);
  2764. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2765. currentList.addAll(proEconPowerstationInfoDay4Service.list(currentqw));
  2766. int subYear = Integer.parseInt(year) - 1;
  2767. QueryWrapper<ProEconPowerstationInfoDay4> sameperiodqw = new QueryWrapper<>();
  2768. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  2769. sameperiodqw.eq("location", "wp");
  2770. if (type.equals("-1")) {
  2771. currentqw.like("foreign_key_id", "_FDC_");
  2772. } else {
  2773. currentqw.like("foreign_key_id", "_GDC_");
  2774. }
  2775. if (companys.endsWith("ZGS")) {
  2776. currentqw.eq("company_id", companys);
  2777. } else {
  2778. currentqw.eq("region_id", companys);
  2779. }
  2780. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2781. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2782. List<ProEconPowerstationInfoDay4> sameperiodList = proEconPowerstationInfoDay4Service.list(sameperiodqw);
  2783. sameperiodqw.clear();
  2784. sameperiodqw.select("foreign_key_id,max(record_date) record_date,sum(rmttr) ymttr");
  2785. sameperiodqw.eq("foreign_key_id", companys + type);
  2786. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2787. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2788. sameperiodList.addAll(proEconPowerstationInfoDay4Service.list(sameperiodqw));
  2789. //合并当月与同期数据为返回结果
  2790. List<SpecificTargetVo> resultList = new ArrayList<>();
  2791. currentList.stream().forEach(i -> {
  2792. SpecificTargetVo vo = new SpecificTargetVo();
  2793. String wpid = i.getForeignKeyId();
  2794. vo.setWpid(wpid);
  2795. if (wpid.contains("_ZGS")) {
  2796. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2797. } else if (wpid.contains("_RGN")) {
  2798. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2799. } else {
  2800. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2801. }
  2802. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2803. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2804. vo.setCurrent(DoubleUtils.keepPrecision(i.getYmttr().doubleValue(), 2));
  2805. resultList.add(vo);
  2806. });
  2807. resultList.stream().forEach(i -> {
  2808. Optional<ProEconPowerstationInfoDay4> optional = sameperiodList.stream()
  2809. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2810. .findFirst();
  2811. if (optional.isPresent()) {
  2812. ProEconPowerstationInfoDay4 tqinfoday = optional.get();
  2813. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYmttr().doubleValue(), 2));
  2814. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2815. } else {
  2816. i.setSameperiod(0.0);
  2817. i.setCompare(0);
  2818. }
  2819. });
  2820. List<SpecificTarget> resultendList = new ArrayList<>();
  2821. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2822. resultList.stream().forEach(i -> {
  2823. if (map.containsKey(i.getWpid())) {
  2824. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2825. if (!integerListMap.containsKey(i.getMonth())) {
  2826. map.get(i.getWpid()).put(i.getMonth(), i);
  2827. } else {
  2828. }
  2829. } else {
  2830. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2831. tempMap.put(i.getMonth(), i);
  2832. map.put(i.getWpid(), tempMap);
  2833. }
  2834. });
  2835. Set<String> wpids = map.keySet();
  2836. if (StringUtils.isNotNull(wpids)) {
  2837. wpids.stream().forEach(wpid -> {
  2838. SpecificTarget vo = new SpecificTarget();
  2839. vo.setWpid(wpid);
  2840. int orderNum = 100;
  2841. if (wpid.contains("_ZGS")) {
  2842. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2843. } else if (wpid.contains("_RGN")) {
  2844. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2845. } else {
  2846. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2847. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2848. }
  2849. vo.setOrderNum(orderNum);
  2850. List<SpecificTargetVo> tempList = new ArrayList<>();
  2851. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2852. for (int x = 1; x <= 12; x++) {
  2853. if (listMap.containsKey(x)) {
  2854. tempList.add(listMap.get(x));
  2855. } else {
  2856. SpecificTargetVo vo1 = new SpecificTargetVo();
  2857. vo1.setWpid(wpid);
  2858. if (wpid.contains("_ZGS")) {
  2859. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2860. } else if (wpid.contains("_RGN")) {
  2861. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2862. } else {
  2863. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2864. }
  2865. vo1.setYear(Integer.parseInt(year));
  2866. vo1.setMonth(x);
  2867. tempList.add(vo1);
  2868. }
  2869. }
  2870. vo.setTargetList(tempList);
  2871. resultendList.add(vo);
  2872. });
  2873. }
  2874. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  2875. return resultendList;
  2876. }
  2877. public List<SpecificTarget> xtxlList(String companys, String type, String year) {
  2878. //获取年份所有当月的数据
  2879. QueryWrapper<ProEconPowerstationInfoDay7> currentqw = new QueryWrapper<>();
  2880. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  2881. currentqw.eq("location", "wp");
  2882. currentqw.eq("to_char(record_date,'yyyy')", year);
  2883. if (type.equals("-1")) {
  2884. currentqw.like("foreign_key_id", "_FDC_");
  2885. } else {
  2886. currentqw.like("foreign_key_id", "_GDC_");
  2887. }
  2888. if (companys.endsWith("ZGS")) {
  2889. currentqw.eq("company_id", companys);
  2890. } else {
  2891. currentqw.eq("region_id", companys);
  2892. }
  2893. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2894. List<ProEconPowerstationInfoDay7> currentList = proEconPowerstationInfoDay7Service.list(currentqw);
  2895. currentqw.clear();
  2896. currentqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  2897. currentqw.eq("foreign_key_id", companys + type);
  2898. currentqw.eq("to_char(record_date,'yyyy')", year);
  2899. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2900. currentList.addAll(proEconPowerstationInfoDay7Service.list(currentqw));
  2901. int subYear = Integer.parseInt(year) - 1;
  2902. QueryWrapper<ProEconPowerstationInfoDay7> sameperiodqw = new QueryWrapper<>();
  2903. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  2904. sameperiodqw.eq("location", "wp");
  2905. if (type.equals("-1")) {
  2906. currentqw.like("foreign_key_id", "_FDC_");
  2907. } else {
  2908. currentqw.like("foreign_key_id", "_GDC_");
  2909. }
  2910. if (companys.endsWith("ZGS")) {
  2911. currentqw.eq("company_id", companys);
  2912. } else {
  2913. currentqw.eq("region_id", companys);
  2914. }
  2915. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2916. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2917. List<ProEconPowerstationInfoDay7> sameperiodList = proEconPowerstationInfoDay7Service.list(sameperiodqw);
  2918. sameperiodqw.clear();
  2919. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(yxtxlpr) yxtxlpr");
  2920. sameperiodqw.eq("foreign_key_id", companys + type);
  2921. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  2922. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  2923. sameperiodList.addAll(proEconPowerstationInfoDay7Service.list(sameperiodqw));
  2924. //合并当月与同期数据为返回结果
  2925. List<SpecificTargetVo> resultList = new ArrayList<>();
  2926. currentList.stream().forEach(i -> {
  2927. SpecificTargetVo vo = new SpecificTargetVo();
  2928. String wpid = i.getForeignKeyId();
  2929. vo.setWpid(wpid);
  2930. if (wpid.contains("_ZGS")) {
  2931. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2932. } else if (wpid.contains("_RGN")) {
  2933. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2934. } else {
  2935. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2936. }
  2937. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  2938. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  2939. vo.setCurrent(DoubleUtils.keepPrecision(i.getYxtxlpr().doubleValue(), 2));
  2940. resultList.add(vo);
  2941. });
  2942. resultList.stream().forEach(i -> {
  2943. Optional<ProEconPowerstationInfoDay7> optional = sameperiodList.stream()
  2944. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  2945. .findFirst();
  2946. if (optional.isPresent()) {
  2947. ProEconPowerstationInfoDay7 tqinfoday = optional.get();
  2948. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYxtxlpr().doubleValue(), 2));
  2949. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  2950. } else {
  2951. i.setSameperiod(0.0);
  2952. i.setCompare(0);
  2953. }
  2954. });
  2955. List<SpecificTarget> resultendList = new ArrayList<>();
  2956. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  2957. resultList.stream().forEach(i -> {
  2958. if (map.containsKey(i.getWpid())) {
  2959. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  2960. if (!integerListMap.containsKey(i.getMonth())) {
  2961. map.get(i.getWpid()).put(i.getMonth(), i);
  2962. } else {
  2963. }
  2964. } else {
  2965. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  2966. tempMap.put(i.getMonth(), i);
  2967. map.put(i.getWpid(), tempMap);
  2968. }
  2969. });
  2970. Set<String> wpids = map.keySet();
  2971. if (StringUtils.isNotNull(wpids)) {
  2972. wpids.stream().forEach(wpid -> {
  2973. SpecificTarget vo = new SpecificTarget();
  2974. vo.setWpid(wpid);
  2975. int orderNum = 100;
  2976. if (wpid.contains("_ZGS")) {
  2977. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  2978. } else if (wpid.contains("_RGN")) {
  2979. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  2980. } else {
  2981. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2982. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  2983. }
  2984. vo.setOrderNum(orderNum);
  2985. List<SpecificTargetVo> tempList = new ArrayList<>();
  2986. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  2987. for (int x = 1; x <= 12; x++) {
  2988. if (listMap.containsKey(x)) {
  2989. tempList.add(listMap.get(x));
  2990. } else {
  2991. SpecificTargetVo vo1 = new SpecificTargetVo();
  2992. vo1.setWpid(wpid);
  2993. if (wpid.contains("_ZGS")) {
  2994. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  2995. } else if (wpid.contains("_RGN")) {
  2996. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  2997. } else {
  2998. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  2999. }
  3000. vo1.setYear(Integer.parseInt(year));
  3001. vo1.setMonth(x);
  3002. tempList.add(vo1);
  3003. }
  3004. }
  3005. vo.setTargetList(tempList);
  3006. resultendList.add(vo);
  3007. });
  3008. }
  3009. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3010. return resultendList;
  3011. }
  3012. public List<SpecificTarget> lslList(String companys, String type, String year) {
  3013. //获取年份所有当月的数据
  3014. QueryWrapper<ProEconPowerstationInfoDay7> currentqw = new QueryWrapper<>();
  3015. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  3016. currentqw.eq("location", "wp");
  3017. currentqw.eq("to_char(record_date,'yyyy')", year);
  3018. if (type.equals("-1")) {
  3019. currentqw.like("foreign_key_id", "_FDC_");
  3020. } else {
  3021. currentqw.like("foreign_key_id", "_GDC_");
  3022. }
  3023. if (companys.endsWith("ZGS")) {
  3024. currentqw.eq("company_id", companys);
  3025. } else {
  3026. currentqw.eq("region_id", companys);
  3027. }
  3028. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3029. List<ProEconPowerstationInfoDay7> currentList = proEconPowerstationInfoDay7Service.list(currentqw);
  3030. currentqw.clear();
  3031. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  3032. currentqw.eq("foreign_key_id", companys + type);
  3033. currentqw.eq("to_char(record_date,'yyyy')", year);
  3034. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3035. currentList.addAll(proEconPowerstationInfoDay7Service.list(currentqw));
  3036. int subYear = Integer.parseInt(year) - 1;
  3037. QueryWrapper<ProEconPowerstationInfoDay7> sameperiodqw = new QueryWrapper<>();
  3038. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  3039. sameperiodqw.eq("location", "wp");
  3040. if (type.equals("-1")) {
  3041. currentqw.like("foreign_key_id", "_FDC_");
  3042. } else {
  3043. currentqw.like("foreign_key_id", "_GDC_");
  3044. }
  3045. if (companys.endsWith("ZGS")) {
  3046. currentqw.eq("company_id", companys);
  3047. } else {
  3048. currentqw.eq("region_id", companys);
  3049. }
  3050. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3051. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3052. List<ProEconPowerstationInfoDay7> sameperiodList = proEconPowerstationInfoDay7Service.list(sameperiodqw);
  3053. sameperiodqw.clear();
  3054. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ylsl) ylsl");
  3055. sameperiodqw.eq("foreign_key_id", companys + type);
  3056. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3057. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3058. sameperiodList.addAll(proEconPowerstationInfoDay7Service.list(sameperiodqw));
  3059. //合并当月与同期数据为返回结果
  3060. List<SpecificTargetVo> resultList = new ArrayList<>();
  3061. currentList.stream().forEach(i -> {
  3062. SpecificTargetVo vo = new SpecificTargetVo();
  3063. String wpid = i.getForeignKeyId();
  3064. vo.setWpid(wpid);
  3065. if (wpid.contains("_ZGS")) {
  3066. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3067. } else if (wpid.contains("_RGN")) {
  3068. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3069. } else {
  3070. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3071. }
  3072. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  3073. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  3074. vo.setCurrent(DoubleUtils.keepPrecision(i.getYlsl().doubleValue(), 2));
  3075. resultList.add(vo);
  3076. });
  3077. resultList.stream().forEach(i -> {
  3078. Optional<ProEconPowerstationInfoDay7> optional = sameperiodList.stream()
  3079. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  3080. .findFirst();
  3081. if (optional.isPresent()) {
  3082. ProEconPowerstationInfoDay7 tqinfoday = optional.get();
  3083. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYxtxlpr().doubleValue(), 2));
  3084. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3085. } else {
  3086. i.setSameperiod(0.0);
  3087. i.setCompare(0);
  3088. }
  3089. });
  3090. List<SpecificTarget> resultendList = new ArrayList<>();
  3091. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3092. resultList.stream().forEach(i -> {
  3093. if (map.containsKey(i.getWpid())) {
  3094. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3095. if (!integerListMap.containsKey(i.getMonth())) {
  3096. map.get(i.getWpid()).put(i.getMonth(), i);
  3097. } else {
  3098. }
  3099. } else {
  3100. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3101. tempMap.put(i.getMonth(), i);
  3102. map.put(i.getWpid(), tempMap);
  3103. }
  3104. });
  3105. Set<String> wpids = map.keySet();
  3106. if (StringUtils.isNotNull(wpids)) {
  3107. wpids.stream().forEach(wpid -> {
  3108. SpecificTarget vo = new SpecificTarget();
  3109. vo.setWpid(wpid);
  3110. int orderNum = 100;
  3111. if (wpid.contains("_ZGS")) {
  3112. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3113. } else if (wpid.contains("_RGN")) {
  3114. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3115. } else {
  3116. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3117. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3118. }
  3119. vo.setOrderNum(orderNum);
  3120. List<SpecificTargetVo> tempList = new ArrayList<>();
  3121. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3122. for (int x = 1; x <= 12; x++) {
  3123. if (listMap.containsKey(x)) {
  3124. tempList.add(listMap.get(x));
  3125. } else {
  3126. SpecificTargetVo vo1 = new SpecificTargetVo();
  3127. vo1.setWpid(wpid);
  3128. if (wpid.contains("_ZGS")) {
  3129. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3130. } else if (wpid.contains("_RGN")) {
  3131. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3132. } else {
  3133. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3134. }
  3135. vo1.setYear(Integer.parseInt(year));
  3136. vo1.setMonth(x);
  3137. tempList.add(vo1);
  3138. }
  3139. }
  3140. vo.setTargetList(tempList);
  3141. resultendList.add(vo);
  3142. });
  3143. }
  3144. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3145. return resultendList;
  3146. }
  3147. public List<SpecificTarget> zhxlList(String companys, String type, String year) {
  3148. //获取年份所有当月的数据
  3149. QueryWrapper<ProEconPowerstationInfoDay7> currentqw = new QueryWrapper<>();
  3150. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  3151. currentqw.eq("location", "wp");
  3152. currentqw.eq("to_char(record_date,'yyyy')", year);
  3153. if (type.equals("-1")) {
  3154. currentqw.like("foreign_key_id", "_FDC_");
  3155. } else {
  3156. currentqw.like("foreign_key_id", "_GDC_");
  3157. }
  3158. if (companys.endsWith("ZGS")) {
  3159. currentqw.eq("company_id", companys);
  3160. } else {
  3161. currentqw.eq("region_id", companys);
  3162. }
  3163. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3164. List<ProEconPowerstationInfoDay7> currentList = proEconPowerstationInfoDay7Service.list(currentqw);
  3165. currentqw.clear();
  3166. currentqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  3167. currentqw.eq("foreign_key_id", companys + type);
  3168. currentqw.eq("to_char(record_date,'yyyy')", year);
  3169. currentqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3170. currentList.addAll(proEconPowerstationInfoDay7Service.list(currentqw));
  3171. int subYear = Integer.parseInt(year) - 1;
  3172. QueryWrapper<ProEconPowerstationInfoDay7> sameperiodqw = new QueryWrapper<>();
  3173. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  3174. sameperiodqw.eq("location", "wp");
  3175. if (type.equals("-1")) {
  3176. currentqw.like("foreign_key_id", "_FDC_");
  3177. } else {
  3178. currentqw.like("foreign_key_id", "_GDC_");
  3179. }
  3180. if (companys.endsWith("ZGS")) {
  3181. currentqw.eq("company_id", companys);
  3182. } else {
  3183. currentqw.eq("region_id", companys);
  3184. }
  3185. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3186. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3187. List<ProEconPowerstationInfoDay7> sameperiodList = proEconPowerstationInfoDay7Service.list(sameperiodqw);
  3188. sameperiodqw.clear();
  3189. sameperiodqw.select("foreign_key_id,max(record_date) record_date,avg(ynbqzhxl) ynbqzhxl");
  3190. sameperiodqw.eq("foreign_key_id", companys + type);
  3191. sameperiodqw.eq("to_char(record_date,'yyyy')", String.valueOf(subYear));
  3192. sameperiodqw.groupBy("to_char(record_date,'yyyy-MM'),foreign_key_id");
  3193. sameperiodList.addAll(proEconPowerstationInfoDay7Service.list(sameperiodqw));
  3194. //合并当月与同期数据为返回结果
  3195. List<SpecificTargetVo> resultList = new ArrayList<>();
  3196. currentList.stream().forEach(i -> {
  3197. SpecificTargetVo vo = new SpecificTargetVo();
  3198. String wpid = i.getForeignKeyId();
  3199. vo.setWpid(wpid);
  3200. if (wpid.contains("_ZGS")) {
  3201. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3202. } else if (wpid.contains("_RGN")) {
  3203. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3204. } else {
  3205. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3206. }
  3207. vo.setYear(DateUtils.getYear(i.getRecordDate()));
  3208. vo.setMonth(DateUtils.getMonth(i.getRecordDate()));
  3209. vo.setCurrent(DoubleUtils.keepPrecision(i.getYnbqzhxl().doubleValue(), 2));
  3210. resultList.add(vo);
  3211. });
  3212. resultList.stream().forEach(i -> {
  3213. Optional<ProEconPowerstationInfoDay7> optional = sameperiodList.stream()
  3214. .filter(j -> j.getForeignKeyId().equals(i.getWpid()) && String.valueOf(DateUtils.getMonth(j.getRecordDate())).equals(i.getMonth()))
  3215. .findFirst();
  3216. if (optional.isPresent()) {
  3217. ProEconPowerstationInfoDay7 tqinfoday = optional.get();
  3218. i.setSameperiod(DoubleUtils.keepPrecision(tqinfoday.getYxtxlpr().doubleValue(), 2));
  3219. i.setCompare(i.getCurrent().compareTo(i.getSameperiod()));
  3220. } else {
  3221. i.setSameperiod(0.0);
  3222. i.setCompare(0);
  3223. }
  3224. });
  3225. List<SpecificTarget> resultendList = new ArrayList<>();
  3226. Map<String, Map<Integer, SpecificTargetVo>> map = new HashMap<>();
  3227. resultList.stream().forEach(i -> {
  3228. if (map.containsKey(i.getWpid())) {
  3229. Map<Integer, SpecificTargetVo> integerListMap = map.get(i.getWpid());
  3230. if (!integerListMap.containsKey(i.getMonth())) {
  3231. map.get(i.getWpid()).put(i.getMonth(), i);
  3232. } else {
  3233. }
  3234. } else {
  3235. Map<Integer, SpecificTargetVo> tempMap = new HashMap<>();
  3236. tempMap.put(i.getMonth(), i);
  3237. map.put(i.getWpid(), tempMap);
  3238. }
  3239. });
  3240. Set<String> wpids = map.keySet();
  3241. if (StringUtils.isNotNull(wpids)) {
  3242. wpids.stream().forEach(wpid -> {
  3243. SpecificTarget vo = new SpecificTarget();
  3244. vo.setWpid(wpid);
  3245. int orderNum = 100;
  3246. if (wpid.contains("_ZGS")) {
  3247. vo.setWpname(CacheContext.cpmap.get(companys).getAname());
  3248. } else if (wpid.contains("_RGN")) {
  3249. vo.setWpname(CacheContext.rgmap.get(companys).getAname());
  3250. } else {
  3251. vo.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3252. orderNum = CacheContext.wpmap.get(wpid).getOrderNum();
  3253. }
  3254. vo.setOrderNum(orderNum);
  3255. List<SpecificTargetVo> tempList = new ArrayList<>();
  3256. Map<Integer, SpecificTargetVo> listMap = map.get(wpid);
  3257. for (int x = 1; x <= 12; x++) {
  3258. if (listMap.containsKey(x)) {
  3259. tempList.add(listMap.get(x));
  3260. } else {
  3261. SpecificTargetVo vo1 = new SpecificTargetVo();
  3262. vo1.setWpid(wpid);
  3263. if (wpid.contains("_ZGS")) {
  3264. vo1.setWpname(CacheContext.cpmap.get(companys).getAname());
  3265. } else if (wpid.contains("_RGN")) {
  3266. vo1.setWpname(CacheContext.rgmap.get(companys).getAname());
  3267. } else {
  3268. vo1.setWpname(CacheContext.wpmap.get(wpid).getAname());
  3269. }
  3270. vo1.setYear(Integer.parseInt(year));
  3271. vo1.setMonth(x);
  3272. tempList.add(vo1);
  3273. }
  3274. }
  3275. vo.setTargetList(tempList);
  3276. resultendList.add(vo);
  3277. });
  3278. }
  3279. SortUtils.sort(resultendList, "orderNum", SortUtils.ASC);
  3280. return resultendList;
  3281. }
  3282. }