PmDemandServiceImpl.java 244 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619
  1. package com.ozs.pm.service.impl;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  4. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  5. import com.baomidou.mybatisplus.core.metadata.IPage;
  6. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  7. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  8. import com.ozs.base.domain.BaseAgency;
  9. import com.ozs.base.domain.BaseExpert;
  10. import com.ozs.base.domain.BaseNotice;
  11. import com.ozs.base.domain.BaseNoticeType;
  12. import com.ozs.base.domain.BaseUnitInformation;
  13. import com.ozs.base.domain.vo.BaseExpertVo;
  14. import com.ozs.base.mapper.BaseExpertMapper;
  15. import com.ozs.base.service.BaseAgencyService;
  16. import com.ozs.base.service.BaseExpertService;
  17. import com.ozs.base.service.BaseNoticeService;
  18. import com.ozs.base.service.BaseNoticeTypeService;
  19. import com.ozs.common.constant.Constants;
  20. import com.ozs.common.core.domain.AjaxResult;
  21. import com.ozs.common.core.domain.entity.SysDept;
  22. import com.ozs.common.core.domain.entity.SysDictData;
  23. import com.ozs.common.core.domain.entity.SysRole;
  24. import com.ozs.common.core.domain.entity.SysUser;
  25. import com.ozs.common.core.domain.model.LoginUser;
  26. import com.ozs.common.enums.BidWinningStatus;
  27. import com.ozs.common.enums.ExpertType;
  28. import com.ozs.common.enums.IsExcess;
  29. import com.ozs.common.enums.NameListType;
  30. import com.ozs.common.enums.PlanPurchaseMode;
  31. import com.ozs.common.enums.PmProjectStatus;
  32. import com.ozs.common.enums.ProcurementMethodSuggest;
  33. import com.ozs.common.enums.ProjectAttribute;
  34. import com.ozs.common.enums.ProjectTypes;
  35. import com.ozs.common.enums.SysFileRefEnum;
  36. import com.ozs.common.enums.WarnStatus;
  37. import com.ozs.common.utils.DateUtils;
  38. import com.ozs.common.utils.RandomUtil;
  39. import com.ozs.common.utils.SecurityUtils;
  40. import com.ozs.common.utils.StringUtils;
  41. import com.ozs.common.utils.bean.BeanUtils;
  42. import com.ozs.home.domain.vo.HomeToDoQueryResVo;
  43. import com.ozs.plan.doman.PlanYears;
  44. import com.ozs.plan.doman.ProvisionalPlan;
  45. import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
  46. import com.ozs.plan.mapper.ProvisionalPlanMapper;
  47. import com.ozs.plan.service.PlanYearsService;
  48. import com.ozs.pm.doman.PmAuditDeptRef;
  49. import com.ozs.pm.doman.PmBidFailure;
  50. import com.ozs.pm.doman.PmBidOpening;
  51. import com.ozs.pm.doman.PmBidWinning;
  52. import com.ozs.pm.doman.PmBidWinningOpeningRef;
  53. import com.ozs.pm.doman.PmBookBuilding;
  54. import com.ozs.pm.doman.PmCallQuestion;
  55. import com.ozs.pm.doman.PmContractInfo;
  56. import com.ozs.pm.doman.PmDemand;
  57. import com.ozs.pm.doman.PmDemandExpertRef;
  58. import com.ozs.pm.doman.PmExpertFeedback;
  59. import com.ozs.pm.doman.PmProcurementDocumentsReview;
  60. import com.ozs.pm.doman.PmProjectConstruction;
  61. import com.ozs.pm.doman.PmReleaseAnnouncement;
  62. import com.ozs.pm.doman.vo.requestVo.PmBaseExpertExtractReqVo;
  63. import com.ozs.pm.doman.vo.requestVo.PmBaseExpertFillReqVo;
  64. import com.ozs.pm.doman.vo.requestVo.PmBidFailureReqVo;
  65. import com.ozs.pm.doman.vo.requestVo.PmBidOpeningFillReqVo;
  66. import com.ozs.pm.doman.vo.requestVo.PmBidWinningReqVo;
  67. import com.ozs.pm.doman.vo.requestVo.PmBookBuildingReqVo;
  68. import com.ozs.pm.doman.vo.requestVo.PmContractInfoReqVo;
  69. import com.ozs.pm.doman.vo.requestVo.PmDemandReqVo;
  70. import com.ozs.pm.doman.vo.requestVo.PmProjectConstructionReqVo;
  71. import com.ozs.pm.doman.vo.requestVo.PmReleaseAnnouncementReqVo;
  72. import com.ozs.pm.doman.vo.responseVo.PmBaseExpertResVo;
  73. import com.ozs.pm.doman.vo.responseVo.PmBidFailureResVo;
  74. import com.ozs.pm.doman.vo.responseVo.PmBidOpeningResVo;
  75. import com.ozs.pm.doman.vo.responseVo.PmBidWinningResVo;
  76. import com.ozs.pm.doman.vo.responseVo.PmBookBuildingResVo;
  77. import com.ozs.pm.doman.vo.responseVo.PmCallQuestionResVo;
  78. import com.ozs.pm.doman.vo.responseVo.PmContractInfoResVo;
  79. import com.ozs.pm.doman.vo.responseVo.PmDemandResVo;
  80. import com.ozs.pm.doman.vo.responseVo.PmExpertFeedbackResVo;
  81. import com.ozs.pm.doman.vo.responseVo.PmProcurementDocumentsReviewResVo;
  82. import com.ozs.pm.doman.vo.responseVo.PmProjectConstructionResVo;
  83. import com.ozs.pm.doman.vo.responseVo.PmPurchaseExecutionResVo;
  84. import com.ozs.pm.doman.vo.responseVo.PmReleaseAnnouncementResVo;
  85. import com.ozs.pm.doman.vo.responseVo.StatisticalChartsResVo;
  86. import com.ozs.pm.mapper.PmDemandMapper;
  87. import com.ozs.pm.service.IPmDemandService;
  88. import com.ozs.pm.service.PmAuditDeptRefService;
  89. import com.ozs.pm.service.PmBidFailureService;
  90. import com.ozs.pm.service.PmBidOpeningService;
  91. import com.ozs.pm.service.PmBidWinningOpeningRefService;
  92. import com.ozs.pm.service.PmBidWinningService;
  93. import com.ozs.pm.service.PmBookBuildingService;
  94. import com.ozs.pm.service.PmCallQuestionHisService;
  95. import com.ozs.pm.service.PmCallQuestionService;
  96. import com.ozs.pm.service.PmContractInfoService;
  97. import com.ozs.pm.service.PmDemandExpertRefService;
  98. import com.ozs.pm.service.PmExpertFeedbackService;
  99. import com.ozs.pm.service.PmProcurementDocumentsReviewService;
  100. import com.ozs.pm.service.PmProjectConstructionService;
  101. import com.ozs.pm.service.PmReleaseAnnouncementService;
  102. import com.ozs.system.domain.SysFileInfo;
  103. import com.ozs.system.domain.SysFileRef;
  104. import com.ozs.system.domain.vo.SysRegionVO;
  105. import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
  106. import com.ozs.system.mapper.SysDeptMapper;
  107. import com.ozs.system.mapper.SysFileRefMapper;
  108. import com.ozs.system.mapper.SysRoleMapper;
  109. import com.ozs.system.service.ISysDeptService;
  110. import com.ozs.system.service.ISysDictDataService;
  111. import com.ozs.system.service.ISysDictTypeService;
  112. import com.ozs.system.service.ISysRegionService;
  113. import com.ozs.system.service.ISysUserService;
  114. import com.ozs.system.service.SysFileRefService;
  115. import com.ozs.system.service.SysFileService;
  116. import lombok.extern.slf4j.Slf4j;
  117. import org.springframework.beans.factory.annotation.Autowired;
  118. import org.springframework.stereotype.Service;
  119. import org.springframework.transaction.annotation.Transactional;
  120. import org.springframework.util.ObjectUtils;
  121. import java.math.BigDecimal;
  122. import java.text.DecimalFormat;
  123. import java.text.ParseException;
  124. import java.util.ArrayList;
  125. import java.util.Arrays;
  126. import java.util.Calendar;
  127. import java.util.Date;
  128. import java.util.HashMap;
  129. import java.util.HashSet;
  130. import java.util.LinkedHashMap;
  131. import java.util.LinkedList;
  132. import java.util.List;
  133. import java.util.Map;
  134. import java.util.Set;
  135. import java.util.stream.Collectors;
  136. /**
  137. * 采购需求Service业务层处理
  138. *
  139. * @author ruoyi
  140. * @date 2023-01-16
  141. */
  142. @Service
  143. @Slf4j
  144. public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> implements IPmDemandService {
  145. @Autowired
  146. private PmDemandMapper pmDemandMapper;
  147. @Autowired
  148. private ISysDeptService deptService;
  149. @Autowired
  150. private SysRoleMapper sysRoleMapper;
  151. @Autowired
  152. private ISysDictDataService dictDataService;
  153. @Autowired
  154. private ISysDictTypeService dictTypeService;
  155. @Autowired
  156. private SysFileService fileService;
  157. @Autowired
  158. private SysFileRefService sysFileRefService;
  159. @Autowired
  160. private PmReleaseAnnouncementService pmReleaseAnnouncementService;
  161. @Autowired
  162. private BaseExpertService baseExpertService;
  163. @Autowired
  164. private PmDemandExpertRefService pmDemandExpertRefService;
  165. @Autowired
  166. private PmBidOpeningService pmBidOpeningService;
  167. @Autowired
  168. private SysFileRefMapper sysFileRefMapper;
  169. @Autowired
  170. private PmBookBuildingService pmBookBuildingService;
  171. @Autowired
  172. private PmCallQuestionService pmCallQuestionService;
  173. @Autowired
  174. private PmBidWinningService pmBidWinningService;
  175. @Autowired
  176. private ISysDictTypeService iSysDictTypeService;
  177. @Autowired
  178. private PmBidFailureService pmBidFailureService;
  179. @Autowired
  180. private PmBidWinningOpeningRefService pmBidWinningOpeningRefService;
  181. @Autowired
  182. private PmContractInfoService pmContractInfoService;
  183. @Autowired
  184. private BaseAgencyService baseAgencyService;
  185. @Autowired
  186. private PmProjectConstructionService pmProjectConstructionService;
  187. @Autowired
  188. private BaseNoticeTypeService baseNoticeTypeService;
  189. @Autowired
  190. private BaseNoticeService baseNoticeService;
  191. @Autowired
  192. private PlanYearsService planYearsService;
  193. @Autowired
  194. private ISysRegionService iSysRegionService;
  195. @Autowired
  196. private ISysUserService userService;
  197. @Autowired
  198. private SysDeptMapper deptMapper;
  199. @Autowired
  200. private BaseExpertMapper baseExpertMapper;
  201. @Autowired
  202. private PmAuditDeptRefService pmAuditDeptRefService;
  203. @Autowired
  204. private ProvisionalPlanMapper provisionalPlanMapper;
  205. @Autowired
  206. private PmExpertFeedbackService pmExpertFeedbackService;
  207. @Autowired
  208. private PmProcurementDocumentsReviewService pmProcurementDocumentsReviewService;
  209. @Autowired
  210. private PmCallQuestionHisService questionHisService;
  211. /**
  212. * 查询采购需求
  213. *
  214. * @param demandId 采购需求主键
  215. * @return 采购需求
  216. */
  217. @Override
  218. public PmDemandResVo selectPmDemandByDemandId(Long demandId, String detailType) {
  219. PmDemand pmDemand = this.getById(demandId);
  220. if (pmDemand != null) {
  221. PmDemandResVo vo = new PmDemandResVo();
  222. vo.setProjectName(pmDemand.getProjectName());
  223. vo.setDemandId(demandId);
  224. if ("1".equals(detailType)) { //项目计划
  225. BeanUtils.copyProperties(pmDemand, vo);
  226. //project_type,evaluation 从原来计划里取
  227. ProvisionalPlan provisionalPlan = provisionalPlanMapper.seletById(pmDemand.getPlanId());
  228. if (provisionalPlan != null) {
  229. vo.setProjectType(provisionalPlan.getProjectType());
  230. vo.setEvaluation(provisionalPlan.getEvaluation().doubleValue());
  231. }
  232. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(vo.getPurchaseDeptId()).get("sysDept");
  233. if (sysDeptResponseVo != null) {
  234. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  235. }
  236. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  237. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  238. vo.setPurchaseServicesName(purchaseServicesName);
  239. }
  240. //采购需求附件
  241. List<SysFileInfo> demandFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND.getType());
  242. if (!ObjectUtils.isEmpty(demandFileInfos)) {
  243. vo.setDemandFileInfos(demandFileInfos);
  244. }
  245. //项目类型
  246. String projectTypeName = dictDataService.selectDictLabel("sys_project_type", vo.getProjectType());
  247. if (StringUtils.isNotEmpty(projectTypeName)) {
  248. vo.setProjectTypeName(projectTypeName);
  249. }
  250. //是否为超限额计划
  251. for (IsExcess value : IsExcess.values()) {
  252. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  253. vo.setIsExcessName(value.getInfo());
  254. break;
  255. }
  256. }
  257. //采购方式
  258. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  259. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  260. vo.setPurchaseModeName(value.getInfo());
  261. break;
  262. }
  263. }
  264. //项目属性
  265. for (ProjectAttribute value : ProjectAttribute.values()) {
  266. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  267. vo.setProjectAttrName(value.getInfo());
  268. break;
  269. }
  270. }
  271. //预警状态
  272. for (WarnStatus value : WarnStatus.values()) {
  273. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  274. vo.setWarnStatusName(value.getInfo());
  275. break;
  276. }
  277. }
  278. //项目状态
  279. for (PmProjectStatus value : PmProjectStatus.values()) {
  280. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  281. vo.setProjectStatusName(value.getInfo());
  282. break;
  283. }
  284. }
  285. } else if ("2".equals(detailType)) { //需求建档
  286. //采购需求审核文件
  287. List<SysFileInfo> auditFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  288. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  289. vo.setAuditFileInfos(auditFileInfos);
  290. }
  291. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  292. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  293. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  294. if (pmBookBuilding != null) {
  295. PmBookBuildingResVo responseVo = new PmBookBuildingResVo();
  296. BeanUtils.copyProperties(pmBookBuilding, responseVo);
  297. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  298. if (!ObjectUtils.isEmpty(fileInfos)) {
  299. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  300. fileInfos.addAll(auditFileInfos);
  301. }
  302. responseVo.setFileInfos(fileInfos);
  303. }
  304. vo.setPmBookBuildingResVo(responseVo);
  305. }
  306. } else if ("3".equals(detailType)) { //任务下达
  307. vo.setTaskReleaseTime(pmDemand.getTaskReleaseTime());
  308. //任务下达文件
  309. List<SysFileInfo> taskReleaseFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType());
  310. if (!ObjectUtils.isEmpty(taskReleaseFileInfos)) {
  311. vo.setTaskReleaseFileInfos(taskReleaseFileInfos);
  312. }
  313. } else if ("4".equals(detailType)) { //中标信息
  314. setPmPurchaseExecutionResVo(vo, pmDemand);
  315. } else if ("5".equals(detailType)) { //合同信息
  316. setPmPurchaseExecutionResVo(vo, pmDemand);
  317. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  318. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  319. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  320. if (pmContractInfo != null) {
  321. PmContractInfoResVo pmContractInfoResVo = new PmContractInfoResVo();
  322. BeanUtils.copyProperties(pmContractInfo, pmContractInfoResVo);
  323. //合同信息文件
  324. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  325. if (!ObjectUtils.isEmpty(fileInfos)) {
  326. pmContractInfoResVo.setFileInfos(fileInfos);
  327. }
  328. vo.setPmContractInfoResVo(pmContractInfoResVo);
  329. }
  330. } else if ("6".equals(detailType)) { //建设情况
  331. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  332. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  333. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  334. if (pmProjectConstruction != null) {
  335. PmProjectConstructionResVo pmProjectConstructionResVo = new PmProjectConstructionResVo();
  336. BeanUtils.copyProperties(pmProjectConstruction, pmProjectConstructionResVo);
  337. //建设情况文件
  338. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  339. if (!ObjectUtils.isEmpty(fileInfos)) {
  340. pmProjectConstructionResVo.setFileInfos(fileInfos);
  341. }
  342. vo.setPmProjectConstructionResVo(pmProjectConstructionResVo);
  343. }
  344. }
  345. return vo;
  346. } else {
  347. return null;
  348. }
  349. }
  350. private void setPmPurchaseExecutionResVo(PmDemandResVo vo, PmDemand pmDemand) {
  351. Long demandId = pmDemand.getDemandId();
  352. PmPurchaseExecutionResVo pmPurchaseExecutionResVo = new PmPurchaseExecutionResVo();
  353. //代理商信息
  354. BaseAgency baseAgency = this.baseAgencyService.getById(pmDemand.getAgencyId());
  355. List<SysDictData> dictData = dictTypeService.selectDictDataByType(Constants.SYS_COMPANY_NATURE);
  356. for (SysDictData data : dictData) {
  357. if (data.getDictValue().equals(baseAgency.getCompanyNature())) {
  358. baseAgency.setCompanyNatureName(data.getDictLabel());
  359. break;
  360. }
  361. }
  362. List<SysDictData> dictDataT = dictTypeService.selectDictDataByType(Constants.SYS_PROJECT_TYPE);
  363. for (SysDictData data : dictDataT) {
  364. if (data.getDictValue().equals(baseAgency.getCompanyType() + "")) {
  365. baseAgency.setCompanyTypeName(data.getDictLabel());
  366. break;
  367. }
  368. }
  369. pmPurchaseExecutionResVo.setBaseAgency(baseAgency);
  370. vo.setPurchaseTaskDocumentNumber(pmDemand.getPurchaseTaskDocumentNumber());
  371. //专家意见反馈
  372. LambdaQueryWrapper<PmExpertFeedback> pmExpertFeedbackLambdaQueryWrapper = new LambdaQueryWrapper<>();
  373. pmExpertFeedbackLambdaQueryWrapper.eq(PmExpertFeedback::getDemandId, demandId);
  374. PmExpertFeedback pmExpertFeedback = pmExpertFeedbackService.getOne(pmExpertFeedbackLambdaQueryWrapper);
  375. if (!ObjectUtils.isEmpty(pmExpertFeedback)) {
  376. PmExpertFeedbackResVo pmExpertFeedbackResVo = new PmExpertFeedbackResVo();
  377. BeanUtils.copyProperties(pmExpertFeedback, pmExpertFeedbackResVo);
  378. List<SysFileInfo> fileInfos = getSysFileInfoList(pmExpertFeedbackResVo.getId(), SysFileRefEnum.PM_EXPERT_FEEDBACK.getType());
  379. if (!ObjectUtils.isEmpty(fileInfos)) {
  380. pmExpertFeedbackResVo.setFileInfos(fileInfos);
  381. }
  382. pmPurchaseExecutionResVo.setPmExpertFeedbackResVo(pmExpertFeedbackResVo);
  383. }
  384. //采购文件编制审核
  385. LambdaQueryWrapper<PmProcurementDocumentsReview> pmProcurementDocumentsReviewLambdaQueryWrapper = new LambdaQueryWrapper<>();
  386. pmProcurementDocumentsReviewLambdaQueryWrapper.eq(PmProcurementDocumentsReview::getDemandId, demandId);
  387. PmProcurementDocumentsReview pmProcurementDocumentsReview = pmProcurementDocumentsReviewService.getOne(pmProcurementDocumentsReviewLambdaQueryWrapper);
  388. if (!ObjectUtils.isEmpty(pmProcurementDocumentsReview)) {
  389. PmProcurementDocumentsReviewResVo pmProcurementDocumentsReviewResVo = new PmProcurementDocumentsReviewResVo();
  390. BeanUtils.copyProperties(pmProcurementDocumentsReview, pmProcurementDocumentsReviewResVo);
  391. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProcurementDocumentsReviewResVo.getId(), SysFileRefEnum.PM_BID_FILE.getType());
  392. if (!ObjectUtils.isEmpty(fileInfos)) {
  393. pmProcurementDocumentsReviewResVo.setFileInfos(fileInfos);
  394. }
  395. pmPurchaseExecutionResVo.setPmProcurementDocumentsReviewResVo(pmProcurementDocumentsReviewResVo);
  396. }
  397. //采购公告列表
  398. LambdaQueryWrapper<PmReleaseAnnouncement> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  399. lambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId).orderByDesc(PmReleaseAnnouncement::getReleaseTime);
  400. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = this.pmReleaseAnnouncementService.list(lambdaQueryWrapper);
  401. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  402. List<PmReleaseAnnouncementResVo> pmReleaseAnnouncementResVoList = new ArrayList<>();
  403. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  404. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  405. PmReleaseAnnouncementResVo pmReleaseAnnouncementResVo = new PmReleaseAnnouncementResVo();
  406. BeanUtils.copyProperties(pmReleaseAnnouncement, pmReleaseAnnouncementResVo);
  407. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncementResVo.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  408. if (!ObjectUtils.isEmpty(fileInfos)) {
  409. fileInfosAll.addAll(fileInfos);
  410. }
  411. pmReleaseAnnouncementResVoList.add(pmReleaseAnnouncementResVo);
  412. }
  413. pmPurchaseExecutionResVo.setPmReleaseAnnouncementFileInfos(fileInfosAll);
  414. pmPurchaseExecutionResVo.setPmReleaseAnnouncementResVoList(pmReleaseAnnouncementResVoList);
  415. }
  416. //标前质疑投诉
  417. LambdaQueryWrapper<PmCallQuestion> pmCallQuestionLambdaQueryWrapper = new LambdaQueryWrapper<>();
  418. pmCallQuestionLambdaQueryWrapper.eq(PmCallQuestion::getDemandId, demandId)
  419. .eq(PmCallQuestion::getType, '0').orderByDesc(PmCallQuestion::getCallQuestionTime);
  420. List<PmCallQuestion> pmCallQuestionList = pmCallQuestionService.list(pmCallQuestionLambdaQueryWrapper);
  421. if (!ObjectUtils.isEmpty(pmCallQuestionList)) {
  422. List<PmCallQuestionResVo> pmCallQuestionResVoList = new ArrayList<>();
  423. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  424. for (PmCallQuestion pmCallQuestion : pmCallQuestionList) {
  425. PmCallQuestionResVo pmCallQuestionResVo = new PmCallQuestionResVo();
  426. BeanUtils.copyProperties(pmCallQuestion, pmCallQuestionResVo);
  427. List<SysFileInfo> fileInfos = getSysFileInfoList(pmCallQuestionResVo.getId(), SysFileRefEnum.PM_PRE_BID_CALL_QUESTION.getType());
  428. if (!ObjectUtils.isEmpty(fileInfos)) {
  429. fileInfosAll.addAll(fileInfos);
  430. }
  431. pmCallQuestionResVoList.add(pmCallQuestionResVo);
  432. }
  433. pmPurchaseExecutionResVo.setPmCallQuestionPreResVoList(pmCallQuestionResVoList);
  434. pmPurchaseExecutionResVo.setPmCallQuestionPreFileInfos(fileInfosAll);
  435. }
  436. //专家信息列表
  437. List<PmBaseExpertResVo> pmBaseExpertResVoList = this.pmDemandExpertRefService.getPmBaseExpertResVoList(demandId);
  438. pmPurchaseExecutionResVo.setPmBaseExpertResVoList(pmBaseExpertResVoList);
  439. //开标信息列表
  440. List<PmBidOpeningResVo> pmBidOpeningResVoList = this.pmBidOpeningService.getPmBidOpeningResVoList(demandId);
  441. pmPurchaseExecutionResVo.setPmBidOpeningResVoList(pmBidOpeningResVoList);
  442. //评标结果公告列表
  443. LambdaQueryWrapper<PmBidWinning> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
  444. lambdaQueryWrapper1.eq(PmBidWinning::getDemandId, demandId)
  445. .ne(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode()).orderByDesc(PmBidWinning::getBidAnnouncementTime);
  446. List<PmBidWinning> pmBidWinningList = this.pmBidWinningService.list(lambdaQueryWrapper1);
  447. if (!ObjectUtils.isEmpty(pmBidWinningList)) {
  448. List<PmBidWinningResVo> pmBidWinningResVoList = new ArrayList<>();
  449. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  450. for (PmBidWinning pmBidWinning : pmBidWinningList) {
  451. PmBidWinningResVo pmBidWinningResVo = new PmBidWinningResVo();
  452. BeanUtils.copyProperties(pmBidWinning, pmBidWinningResVo);
  453. pmBidWinningResVoList.add(pmBidWinningResVo);
  454. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinningResVo.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  455. if (!ObjectUtils.isEmpty(fileInfos)) {
  456. fileInfosAll.addAll(fileInfos);
  457. }
  458. }
  459. pmPurchaseExecutionResVo.setPmBidWinningResVoList(pmBidWinningResVoList);
  460. pmPurchaseExecutionResVo.setPmBidWinningFileInfos(fileInfosAll);
  461. }
  462. //标后质疑
  463. LambdaQueryWrapper<PmCallQuestion> pmCallQuestionLambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  464. pmCallQuestionLambdaQueryWrapper2.eq(PmCallQuestion::getDemandId, demandId)
  465. .eq(PmCallQuestion::getType, '1').orderByDesc(PmCallQuestion::getCallQuestionTime);
  466. List<PmCallQuestion> pmCallQuestionList2 = pmCallQuestionService.list(pmCallQuestionLambdaQueryWrapper2);
  467. if (!ObjectUtils.isEmpty(pmCallQuestionList2)) {
  468. List<PmCallQuestionResVo> pmCallQuestionResVoList = new ArrayList<>();
  469. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  470. for (PmCallQuestion pmCallQuestion : pmCallQuestionList2) {
  471. PmCallQuestionResVo pmCallQuestionResVo = new PmCallQuestionResVo();
  472. BeanUtils.copyProperties(pmCallQuestion, pmCallQuestionResVo);
  473. List<SysFileInfo> fileInfos = getSysFileInfoList(pmCallQuestionResVo.getId(), SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  474. if (!ObjectUtils.isEmpty(fileInfos)) {
  475. fileInfosAll.addAll(fileInfos);
  476. }
  477. pmCallQuestionResVoList.add(pmCallQuestionResVo);
  478. }
  479. pmPurchaseExecutionResVo.setPmCallQuestionPostResVoList(pmCallQuestionResVoList);
  480. pmPurchaseExecutionResVo.setPmCallRequestPostFileInfos(fileInfosAll);
  481. }
  482. //流标情况
  483. LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  484. lambdaQueryWrapper2.eq(PmBidFailure::getDemandId, demandId).orderByDesc(PmBidFailure::getBidFailureTime);
  485. List<PmBidFailure> pmBidFailureList = this.pmBidFailureService.list(lambdaQueryWrapper2);
  486. if (!ObjectUtils.isEmpty(pmBidFailureList)) {
  487. List<PmBidFailureResVo> pmBidFailureResVoList = new ArrayList<>();
  488. List<PmCallQuestionResVo> pmCallQuestionBidFailureResVoList = new ArrayList<>();
  489. List<SysFileInfo> pmBidFailureFileInfos = new ArrayList<>();
  490. List<SysFileInfo> pmCallRequestBidFailureFileInfos = new ArrayList<>();
  491. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  492. PmBidFailureResVo pmBidFailureResVo = new PmBidFailureResVo();
  493. BeanUtils.copyProperties(pmBidFailure, pmBidFailureResVo);
  494. pmBidFailureResVoList.add(pmBidFailureResVo);
  495. //流标文件
  496. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  497. if (!ObjectUtils.isEmpty(fileInfos)) {
  498. pmBidFailureFileInfos.addAll(fileInfos);
  499. }
  500. if ("1".equals(pmBidFailure.getCallQuestion())) { //有质疑
  501. PmCallQuestionResVo pmCallQuestionResVo = new PmCallQuestionResVo();
  502. pmCallQuestionResVo.setCallQuestion(pmBidFailure.getCallQuestion());
  503. pmCallQuestionResVo.setCallQuestionTime(pmBidFailure.getCallQuestionTime());
  504. pmCallQuestionBidFailureResVoList.add(pmCallQuestionResVo);
  505. //流废标质疑文件
  506. List<SysFileInfo> fileInfos2 = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_CALL_QUESTION.getType());
  507. if (!ObjectUtils.isEmpty(fileInfos2)) {
  508. pmCallRequestBidFailureFileInfos.addAll(fileInfos2);
  509. }
  510. }
  511. }
  512. pmPurchaseExecutionResVo.setPmBidFailureResVoList(pmBidFailureResVoList);
  513. pmPurchaseExecutionResVo.setPmBidFailureFileInfos(pmBidFailureFileInfos);
  514. //流废标处置
  515. pmPurchaseExecutionResVo.setPmCallQuestionBidFailureResVoList(pmCallQuestionBidFailureResVoList);
  516. pmPurchaseExecutionResVo.setPmCallRequestBidFailureFileInfos(pmCallRequestBidFailureFileInfos);
  517. }
  518. //中标通知书
  519. List<SysFileInfo> pmBidWinningNotificationFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  520. pmPurchaseExecutionResVo.setFileInfos(pmBidWinningNotificationFileInfos);
  521. vo.setUpAcceptanceTime(pmDemand.getUpAcceptanceTime());
  522. vo.setPmPurchaseExecutionResVo(pmPurchaseExecutionResVo);
  523. }
  524. /**
  525. * 查询采购需求列表
  526. *
  527. * @param pmDemandReqVo
  528. * @return 采购需求
  529. */
  530. @Override
  531. public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
  532. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  533. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  534. List<PmAuditDeptRef> list = new ArrayList<>();
  535. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  536. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  537. l.eq(PmAuditDeptRef::getRefType, "2");
  538. list = pmAuditDeptRefService.list(l);
  539. if (!pmDemandReqVo.getIsAdmin()) {
  540. if (2 == reqType) {
  541. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toSet()));
  542. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  543. } else if (3 == reqType) {
  544. //采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  545. if (!ObjectUtils.isEmpty(list)) {
  546. // 如果有上级单位存在,本单位不处理
  547. SysDept sysDept = deptMapper.selectDeptById(sysUser.getDeptId());
  548. //本单位所有参与审核的项目id
  549. Set<Long> refList = new HashSet<>();
  550. for (PmAuditDeptRef deptRef : list) {
  551. refList.add(deptRef.getRefId());
  552. }
  553. //上级参与审核的项目
  554. List<Long> refListf = new ArrayList<>();
  555. List<PmAuditDeptRef> listf = new ArrayList<>();
  556. if (sysDept.getParentId() != 0) {
  557. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  558. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  559. lf.eq(PmAuditDeptRef::getRefType, "2");
  560. listf = pmAuditDeptRefService.list(lf);
  561. //上级参与审核的项目id
  562. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  563. }
  564. //取集合差集,只处理差集中的数据
  565. if (!ObjectUtils.isEmpty(refListf)) {
  566. refList.removeAll(refListf);
  567. }
  568. //为空就返回空
  569. if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  570. lw.in(PmDemand::getDemandId, -1);
  571. } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  572. lw.in(PmDemand::getDemandId, refList);
  573. }
  574. }
  575. } else {
  576. lw.eq(PmDemand::getCreateBy, SecurityUtils.getUserId());
  577. //lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  578. }
  579. }
  580. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  581. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  582. }
  583. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  584. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  585. }
  586. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus())) {
  587. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  588. }
  589. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus())) {
  590. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  591. }
  592. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess())) {
  593. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  594. }
  595. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  596. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  597. }
  598. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  599. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  600. }
  601. if (reqType == 2) { //任务下达列表
  602. lw.apply("(project_status >=8 )");
  603. } else if (reqType == 3) { //采购执行列表
  604. lw.apply("(project_status >=9 )");
  605. } else if (reqType == 4) { //合同信息列表
  606. lw.apply("(project_status >=19 )");
  607. } else if (reqType == 5) { //项目建设列表
  608. lw.apply("(project_status >=20 )");
  609. }
  610. lw.last(" order by project_status, plan_demand_sub_time");
  611. IPage<PmDemand> pageRes = this.page(new Page<>(pmDemandReqVo.getPageNum(), pmDemandReqVo.getPageSize()), lw);
  612. IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
  613. if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
  614. List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
  615. for (PmDemandResVo vo : pmDemandResVos) {
  616. if (2 == reqType) {
  617. // 根据项目id 和 部门id 和 参数类型 获取 部门级别
  618. List<PmAuditDeptRef> collect = list.stream()
  619. .filter(o -> o.getRefId().equals(vo.getDemandId()))
  620. .collect(Collectors.toList());
  621. if (!ObjectUtils.isEmpty(collect)) {
  622. String deptLevel = collect.get(0).getDeptLevel();
  623. // 根据项目id 和 参数类型 获取 所有审核数据
  624. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  625. ll.eq(PmAuditDeptRef::getRefId, vo.getDemandId());
  626. ll.eq(PmAuditDeptRef::getRefType, "2");
  627. List<PmAuditDeptRef> listl = pmAuditDeptRefService.list(l);
  628. // 判断当前用户是否有审核权限
  629. boolean flay = true;
  630. List<PmAuditDeptRef> collect1 = listl.stream()
  631. .filter(pmAuditDeptRef -> pmAuditDeptRef.getRefId().equals(vo.getDemandId()))
  632. .collect(Collectors.toList());
  633. for (PmAuditDeptRef pmAuditDeptRef : collect1) {
  634. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  635. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  636. flay = false;
  637. } else if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0
  638. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
  639. flay = false;
  640. }
  641. }
  642. vo.setFlay(flay);
  643. }
  644. }
  645. LambdaQueryWrapper<PmExpertFeedback> pmExpertFeedbackLambdaQueryWrapper = new LambdaQueryWrapper<>();
  646. pmExpertFeedbackLambdaQueryWrapper.eq(PmExpertFeedback::getDemandId, vo.getDemandId());
  647. PmExpertFeedback pmExpertFeedback = this.pmExpertFeedbackService.getOne(pmExpertFeedbackLambdaQueryWrapper);
  648. if (pmExpertFeedback != null) {
  649. vo.setProjectNumber(pmExpertFeedback.getProjectNumber());
  650. vo.setDocumentReviewTime(pmExpertFeedback.getDocumentReviewTime());
  651. }
  652. LambdaQueryWrapper<PmProcurementDocumentsReview> pmProcurementDocumentsReviewLambdaQueryWrapper = new LambdaQueryWrapper<>();
  653. pmProcurementDocumentsReviewLambdaQueryWrapper.eq(PmProcurementDocumentsReview::getDemandId, vo.getDemandId());
  654. PmProcurementDocumentsReview pmProcurementDocumentsReview = this.pmProcurementDocumentsReviewService.getOne(pmProcurementDocumentsReviewLambdaQueryWrapper);
  655. if (pmProcurementDocumentsReview != null) {
  656. vo.setProcurementOfficeApprovalTime(pmProcurementDocumentsReview.getProcurementOfficeApprovalTime());
  657. }
  658. if (Integer.parseInt(vo.getProjectStatus()) > 12 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  659. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  660. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, vo.getDemandId())
  661. .orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  662. .last(" limit 1");
  663. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(pmReleaseAnnouncementLambdaQueryWrapper);
  664. if (pmReleaseAnnouncement != null) {
  665. vo.setAnnouncementReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  666. vo.setTenderOpenTime(pmReleaseAnnouncement.getTenderOpenTime());
  667. }
  668. }
  669. if (Integer.parseInt(vo.getProjectStatus()) > 15 && Integer.parseInt(vo.getProjectStatus()) != 16 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  670. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  671. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, vo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode())
  672. .orderByDesc(PmBidWinning::getBidAnnouncementTime)
  673. .last(" limit 1");
  674. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(pmBidWinningLambdaQueryWrapper);
  675. if (pmBidWinning != null) {
  676. vo.setBidAnnouncementTime(pmBidWinning.getBidAnnouncementTime());
  677. }
  678. }
  679. }
  680. results.setRecords(pmDemandResVos);
  681. }
  682. return results;
  683. }
  684. /**
  685. * 查询采购需求列表
  686. *
  687. * @param pmDemandReqVo
  688. * @return 采购需求
  689. */
  690. @Override
  691. public List<PmDemandResVo> selectPmDemandListDe(PmDemandReqVo pmDemandReqVo) {
  692. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  693. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  694. List<PmAuditDeptRef> list = new ArrayList<>();
  695. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  696. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  697. l.eq(PmAuditDeptRef::getRefType, "2");
  698. list = pmAuditDeptRefService.list(l);
  699. if (!pmDemandReqVo.getIsAdmin()) {
  700. if (!ObjectUtils.isEmpty(list)) {
  701. //lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  702. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toSet()));
  703. }
  704. }
  705. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  706. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  707. }
  708. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  709. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  710. }
  711. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus())) {
  712. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  713. }
  714. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus())) {
  715. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  716. }
  717. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess())) {
  718. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  719. }
  720. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  721. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  722. }
  723. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  724. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  725. }
  726. lw.apply("(project_status >=6 )");
  727. lw.last(" order by project_status, plan_demand_sub_time");
  728. List<PmDemand> demandList = pmDemandMapper.selectList(lw);
  729. List<PmDemandResVo> pmDemandResVosTwo = new LinkedList<>();
  730. if (!ObjectUtils.isEmpty(demandList)) {
  731. List<PmDemandResVo> pmDemandResVos = demandChangeTo(demandList);
  732. for (PmDemandResVo vo : pmDemandResVos) {
  733. // 根据项目id 和 部门id 和 参数类型 获取 部门级别
  734. //list是该部门参与审核的项目
  735. List<PmAuditDeptRef> collect = list.stream()
  736. .filter(o -> o.getRefId().equals(vo.getDemandId()))
  737. .collect(Collectors.toList());
  738. if (!ObjectUtils.isEmpty(collect)) {
  739. //部门在这个项目的审核等级**
  740. String deptLevel = collect.get(0).getDeptLevel();
  741. // 根据项目id 和 参数类型 获取 该项目的所有审核数据
  742. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  743. ll.eq(PmAuditDeptRef::getRefId, vo.getDemandId());
  744. ll.eq(PmAuditDeptRef::getRefType, "2");
  745. List<PmAuditDeptRef> listl = pmAuditDeptRefService.list(ll);
  746. // 判断当前用户是否可以进行审核
  747. boolean flay = true;
  748. //是否为本单位已审核过的数据
  749. boolean fg = false;
  750. for (PmAuditDeptRef pmAuditDeptRef : listl) {
  751. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) < 0 && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
  752. //下级单位已审核,轮到本单位审核
  753. fg = true;
  754. } else if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0 && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
  755. //本单位已审核
  756. flay = false;
  757. fg = true;
  758. } else if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0 && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  759. //本单位未进行审核
  760. fg = true;
  761. }
  762. }
  763. vo.setFlay(flay);
  764. if (flay == true || vo.getPurchaseDeptId().equals(SecurityUtils.getDeptId()) || fg == true) {
  765. LambdaQueryWrapper<PmExpertFeedback> pmExpertFeedbackLambdaQueryWrapper = new LambdaQueryWrapper<>();
  766. pmExpertFeedbackLambdaQueryWrapper.eq(PmExpertFeedback::getDemandId, vo.getDemandId());
  767. PmExpertFeedback pmExpertFeedback = this.pmExpertFeedbackService.getOne(pmExpertFeedbackLambdaQueryWrapper);
  768. if (pmExpertFeedback != null) {
  769. vo.setProjectNumber(pmExpertFeedback.getProjectNumber());
  770. vo.setDocumentReviewTime(pmExpertFeedback.getDocumentReviewTime());
  771. }
  772. LambdaQueryWrapper<PmProcurementDocumentsReview> pmProcurementDocumentsReviewLambdaQueryWrapper = new LambdaQueryWrapper<>();
  773. pmProcurementDocumentsReviewLambdaQueryWrapper.eq(PmProcurementDocumentsReview::getDemandId, vo.getDemandId());
  774. PmProcurementDocumentsReview pmProcurementDocumentsReview = this.pmProcurementDocumentsReviewService.getOne(pmProcurementDocumentsReviewLambdaQueryWrapper);
  775. if (pmProcurementDocumentsReview != null) {
  776. vo.setProcurementOfficeApprovalTime(pmProcurementDocumentsReview.getProcurementOfficeApprovalTime());
  777. }
  778. if (Integer.parseInt(vo.getProjectStatus()) > 12 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  779. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  780. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, vo.getDemandId())
  781. .orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  782. .last(" limit 1");
  783. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(pmReleaseAnnouncementLambdaQueryWrapper);
  784. if (pmReleaseAnnouncement != null) {
  785. vo.setAnnouncementReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  786. vo.setTenderOpenTime(pmReleaseAnnouncement.getTenderOpenTime());
  787. }
  788. }
  789. if (Integer.parseInt(vo.getProjectStatus()) > 15 && Integer.parseInt(vo.getProjectStatus()) != 16 && Integer.parseInt(vo.getProjectStatus()) != 18) {
  790. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  791. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, vo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode())
  792. .orderByDesc(PmBidWinning::getBidAnnouncementTime)
  793. .last(" limit 1");
  794. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(pmBidWinningLambdaQueryWrapper);
  795. if (pmBidWinning != null) {
  796. vo.setBidAnnouncementTime(pmBidWinning.getBidAnnouncementTime());
  797. }
  798. }
  799. pmDemandResVosTwo.add(vo);
  800. }
  801. }
  802. }
  803. }
  804. return pmDemandResVosTwo;
  805. }
  806. /**
  807. * 需求建档
  808. *
  809. * @param vo 采购需求
  810. * @return 结果
  811. */
  812. @Override
  813. @Transactional(rollbackFor = Exception.class)
  814. public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
  815. PmDemand pmDemand = this.getById(vo.getDemandId());
  816. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  817. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, vo.getDemandId());
  818. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  819. if (pmBookBuilding != null) {
  820. vo.setId(pmBookBuilding.getId());
  821. BeanUtils.copyProperties(vo, pmBookBuilding);
  822. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  823. pmBookBuilding.setUpdateTime(new Date());
  824. } else {
  825. pmBookBuilding = new PmBookBuilding();
  826. BeanUtils.copyProperties(vo, pmBookBuilding);
  827. pmBookBuilding.setCreateBy(vo.getUpdateBy());
  828. pmBookBuilding.setCreateTime(new Date());
  829. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  830. pmBookBuilding.setUpdateTime(pmBookBuilding.getCreateTime());
  831. }
  832. if (pmBookBuildingService.saveOrUpdate(pmBookBuilding)) {
  833. List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
  834. uploadFile(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType(), sysFileRefs, vo.getUpdateBy());
  835. PmDemand pmDemandUpdate = new PmDemand();
  836. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  837. pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  838. pmDemandUpdate.setEvaluation(vo.getBudgetAmount());
  839. pmDemandUpdate.setProjectType(vo.getProjectType());
  840. pmDemandUpdate.setPurchaseMode(vo.getPurchaseMode());
  841. pmDemandUpdate.setUpdateBy(vo.getUpdateBy());
  842. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  843. return this.updateById(pmDemandUpdate);
  844. } else {
  845. return false;
  846. }
  847. }
  848. private List<SysFileInfo> getSysFileInfoList(Long redId, Integer type) {
  849. HashMap<String, Object> map = new HashMap<>();
  850. map.put("red_id", redId);
  851. map.put("type", type);
  852. List<SysFileRef> fileRefs = sysFileRefService.listByMap(map);
  853. if (!ObjectUtils.isEmpty(fileRefs)) {
  854. List<SysFileInfo> fileInfos = new ArrayList<>();
  855. for (SysFileRef ref : fileRefs) {
  856. SysFileInfo fileInfo = fileService.getById(ref.getFileId());
  857. fileInfos.add(fileInfo);
  858. }
  859. return fileInfos;
  860. } else {
  861. return null;
  862. }
  863. }
  864. /**
  865. * 提交采购需求
  866. *
  867. * @param pmDemandReqVo
  868. * @return 结果
  869. */
  870. @Override
  871. @Transactional(rollbackFor = Exception.class)
  872. public boolean commit(PmDemandReqVo pmDemandReqVo) {
  873. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  874. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  875. Long deptId = sysUser.getDeptId();
  876. pmAuditDeptRefService.insertPmAuditDeptRefs(pmDemandReqVo.getDemandId()
  877. , "2"
  878. , deptId
  879. , BigDecimal.valueOf(pmDemand.getEvaluation())
  880. , sysUser.getUserId()
  881. , pmDemand.getProjectType());
  882. PmDemand pmDemandUpdate = new PmDemand();
  883. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  884. pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  885. pmDemandUpdate.setRealDemandCommitTime(DateUtils.getNowDate());
  886. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  887. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  888. List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
  889. int setting2 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划完成时间")).collect(Collectors.toList()).get(0).getDictValue());
  890. log.info("******** setting2 == " + setting2);
  891. //采购完成时间:根据数据阈值中设置的采购完成时间进行判断,进行预警
  892. int diff2 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanPurchaseFinishTime(), DateUtils.parseDate(DateUtils.getDate()));
  893. if (ObjectUtils.isEmpty(pmDemand.getRealPurchaseFinishTime()) && diff2 > 0 && diff2 <= setting2) {
  894. log.info("******** 采购完成预警: " + pmDemand.getProjectName());
  895. pmDemandUpdate.setWarnStatus(WarnStatus.PURCHASE_FINISH_WARNING.getCode());
  896. } else if (ObjectUtils.isEmpty(pmDemand.getRealPurchaseFinishTime()) && pmDemand.getPlanPurchaseFinishTime().getTime() < System.currentTimeMillis()) {
  897. log.info("******** 采购完成逾期: " + pmDemand.getProjectName());
  898. pmDemandUpdate.setWarnStatus(WarnStatus.PURCHASE_FINISH_EX.getCode());
  899. this.updateById(pmDemandUpdate);
  900. } else {
  901. pmDemandUpdate.setWarnStatus(WarnStatus.NORMAL.getCode());
  902. }
  903. return this.updateById(pmDemandUpdate);
  904. }
  905. /**
  906. * 查看流程图
  907. *
  908. * @param demandId 采购需求主键
  909. * @return 采购需求
  910. */
  911. @Override
  912. public Object viewFlowChart(Long demandId) {
  913. PmDemand pmDemand = this.getById(demandId);
  914. String projectStatus = String.valueOf(pmDemand.getProjectStatus());
  915. String moduleName = null;
  916. if (PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(projectStatus)
  917. || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(projectStatus)
  918. || PmProjectStatus.WASTE_BID_RETURN.getCode().equals(projectStatus)) {
  919. moduleName = "需求填制";
  920. } else if (PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(projectStatus)) {
  921. moduleName = "需求提交";
  922. } else if (PmProjectStatus.DEMAND_WAIT_AUDIT.getCode().equals(projectStatus)) {
  923. moduleName = "需求审核";
  924. } else if (PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(projectStatus)) {
  925. moduleName = "任务下达";
  926. } else if (PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode().equals(projectStatus)) {
  927. moduleName = "选取代理";
  928. } else if (PmProjectStatus.EXPERT_FEEDBACK.getCode().equals(projectStatus)) {
  929. moduleName = "上传意见反馈单";
  930. } else if (PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode().equals(projectStatus)) {
  931. moduleName = "上传招标文件审批表";
  932. } else if (PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  933. moduleName = "采购公告发布";
  934. } else if (PmProjectStatus.PRE_BID_QUERY.getCode().equals(projectStatus)) {
  935. moduleName = "标前质疑投诉";
  936. } else if (PmProjectStatus.WAIT_OPEN_BID.getCode().equals(projectStatus)) {
  937. moduleName = "填写专家信息,开评标";
  938. } else if (PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode().equals(projectStatus) || PmProjectStatus.WASTE_BID_HANDLE.getCode().equals(projectStatus)) {
  939. moduleName = "评标结果公告";
  940. } else if (PmProjectStatus.POST_BID_QUERY.getCode().equals(projectStatus)) {
  941. moduleName = "质疑处理,上传中标通知书";
  942. } else if (PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(projectStatus)) {
  943. moduleName = "合同填制";
  944. } else if (PmProjectStatus.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) {
  945. moduleName = "建设文档填制";
  946. } else if (PmProjectStatus.COMPLETION_CONSTRUCTION.getCode().equals(projectStatus)) {
  947. moduleName = "项目归档";
  948. }
  949. return moduleName;
  950. }
  951. /**
  952. * 审核采购需求通过
  953. *
  954. * @param pmDemandReqVo
  955. * @return 结果
  956. */
  957. @Override
  958. @Transactional(rollbackFor = Exception.class)
  959. public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
  960. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  961. PmDemand pmDemandUpdate = new PmDemand();
  962. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  963. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  964. Long deptId = sysUser.getDeptId();
  965. SysDept sysDept = deptMapper.selectDeptById(deptId);
  966. String[] ancestors = sysDept.getAncestors().split(",");
  967. String deptLevel = null;
  968. if (ancestors.length == 2) { //C级
  969. deptLevel = "C";
  970. } else if (ancestors.length == 3) { //B级
  971. deptLevel = "B";
  972. } else if (ancestors.length == 4) { //A级
  973. deptLevel = "A";
  974. }
  975. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  976. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  977. lw.eq(PmAuditDeptRef::getRefType, "2");
  978. List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
  979. boolean flay = true;
  980. if (!ObjectUtils.isEmpty(list)) {
  981. for (PmAuditDeptRef pmAuditDeptRef : list) {
  982. // 判断 deptLevel 是否还有更高的 且是 待审核的数据
  983. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  984. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  985. flay = false;
  986. }
  987. // 更新当前 deptLevel 级别的审核状态
  988. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0) {
  989. pmAuditDeptRef.setStatus(1);
  990. pmAuditDeptRefService.updateById(pmAuditDeptRef);
  991. }
  992. }
  993. }
  994. if (flay) {
  995. pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  996. }
  997. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  998. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  999. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  1000. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  1001. pmDemandUpdate.setAuditTime(DateUtils.getNowDate());
  1002. return this.updateById(pmDemandUpdate);
  1003. }
  1004. /**
  1005. * 审核采购需求退回
  1006. *
  1007. * @param pmDemandReqVo
  1008. * @return 结果
  1009. */
  1010. @Override
  1011. @Transactional(rollbackFor = Exception.class)
  1012. public boolean reviewReturn(PmDemandReqVo pmDemandReqVo) {
  1013. UpdateWrapper<PmDemand> updateWrapper = new UpdateWrapper<>();
  1014. updateWrapper.lambda().eq(PmDemand::getDemandId, pmDemandReqVo.getDemandId())
  1015. .set(PmDemand::getProjectStatus, PmProjectStatus.DEMAND_AUDIT_RETURN.getCode())
  1016. .set(PmDemand::getAdjustReason, pmDemandReqVo.getRefuseReason())
  1017. .set(PmDemand::getRealDemandCommitTime, null)
  1018. .set(PmDemand::getUpdateBy, pmDemandReqVo.getUpdateBy())
  1019. .set(PmDemand::getUpdateTime, DateUtils.getNowDate())
  1020. .set(PmDemand::getAuditTime, DateUtils.getNowDate());
  1021. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  1022. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  1023. lw.eq(PmAuditDeptRef::getRefType, "2");
  1024. pmAuditDeptRefService.remove(lw);
  1025. return this.update(updateWrapper);
  1026. }
  1027. /**
  1028. * 下达任务
  1029. *
  1030. * @param pmDemandReqVo
  1031. * @return 结果
  1032. */
  1033. @Override
  1034. @Transactional(rollbackFor = Exception.class)
  1035. public boolean releaseTask(PmDemandReqVo pmDemandReqVo) {
  1036. PmDemand pmDemand = new PmDemand();
  1037. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  1038. pmDemand.setTaskReleaseTime(pmDemandReqVo.getTaskReleaseTime());
  1039. pmDemand.setProjectStatus(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1040. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  1041. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  1042. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  1043. pmDemand.setUpdateTime(DateUtils.getNowDate());
  1044. pmDemand.setAuditTime(DateUtils.getNowDate());
  1045. return this.updateById(pmDemand);
  1046. }
  1047. @Override
  1048. @Transactional(rollbackFor = Exception.class)
  1049. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy, boolean delOld) {
  1050. if (!ObjectUtils.isEmpty(sysFileRefs)) {
  1051. // 删关联
  1052. LambdaQueryWrapper<SysFileRef> lw = new LambdaQueryWrapper<>();
  1053. lw.eq(SysFileRef::getRedId, redId);
  1054. lw.eq(SysFileRef::getType, fileType);
  1055. sysFileRefMapper.delete(lw);
  1056. //添加新的
  1057. for (SysFileRef ref : sysFileRefs) {
  1058. if (ref.getFileId() == null) {
  1059. continue;
  1060. }
  1061. ref.setRedId(redId);
  1062. ref.setType(fileType);
  1063. ref.setCreated(upateBy);
  1064. ref.setCreateTime(new Date());
  1065. ref.setUpdated(upateBy);
  1066. ref.setUpdateTime(ref.getCreateTime());
  1067. sysFileRefService.save(ref);
  1068. }
  1069. return true;
  1070. } else {
  1071. return false;
  1072. }
  1073. }
  1074. @Override
  1075. @Transactional(rollbackFor = Exception.class)
  1076. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy) {
  1077. return uploadFile(redId, fileType, sysFileRefs, upateBy, false);
  1078. }
  1079. @Override
  1080. @Transactional(rollbackFor = Exception.class)
  1081. public boolean insertPmReleaseAnnouncement(PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) throws Exception {
  1082. PmDemand pmDemand = this.getById(pmReleaseAnnouncementReqVo.getDemandId());
  1083. if (ObjectUtils.isEmpty(pmDemand)) {
  1084. throw new Exception("参数错误");
  1085. }
  1086. if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
  1087. throw new Exception("上传附件不能为空");
  1088. }
  1089. PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
  1090. BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
  1091. if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
  1092. uploadFile(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType(), pmReleaseAnnouncementReqVo.getSysFileRefs(), pmReleaseAnnouncementReqVo.getUpdateBy());
  1093. PmDemand pmDemandUpdate = new PmDemand();
  1094. pmDemandUpdate.setDemandId(pmReleaseAnnouncementReqVo.getDemandId());
  1095. pmDemandUpdate.setProjectStatus(PmProjectStatus.PRE_BID_QUERY.getCode());
  1096. pmDemandUpdate.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  1097. pmDemandUpdate.setUpdateBy(pmReleaseAnnouncementReqVo.getUpdateBy());
  1098. if (this.updateById(pmDemandUpdate)) {
  1099. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1100. BaseNotice baseNotice = new BaseNotice();
  1101. baseNotice.setName(pmDemand.getProjectName());
  1102. baseNotice.setTitle(pmDemand.getProjectName() + "招标公告");
  1103. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1104. lambdaQueryWrapper.eq(BaseNoticeType::getName, "招标公告");
  1105. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1106. if (baseNoticeType == null) {
  1107. throw new Exception("招标公告 公告类型不存在");
  1108. }
  1109. baseNotice.setDemandId(pmDemand.getDemandId());
  1110. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1111. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1112. baseNotice.setType(baseNoticeType.getId());
  1113. baseNotice.setReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  1114. baseNotice.setCreated(pmReleaseAnnouncementReqVo.getCreateBy());
  1115. baseNotice.setCreateTime(pmReleaseAnnouncementReqVo.getCreateTime());
  1116. baseNotice.setUpdated(pmReleaseAnnouncementReqVo.getUpdateBy());
  1117. baseNotice.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  1118. return this.baseNoticeService.saveOrUpdate(baseNotice);
  1119. } else {
  1120. return false;
  1121. }
  1122. } else {
  1123. return false;
  1124. }
  1125. }
  1126. @Override
  1127. @Transactional(rollbackFor = Exception.class)
  1128. public boolean insertExpertBatch(PmBaseExpertFillReqVo pmBaseExpertFillReqVo) throws Exception {
  1129. PmDemand pmDemand = this.getById(pmBaseExpertFillReqVo.getDemandId());
  1130. if (ObjectUtils.isEmpty(pmDemand)) {
  1131. throw new Exception("参数错误");
  1132. }
  1133. List<BaseExpert> baseExpertList = pmBaseExpertFillReqVo.getBaseExpertList();
  1134. if (ObjectUtils.isEmpty(baseExpertList)) {
  1135. throw new Exception("参数错误");
  1136. }
  1137. Date now = new Date();
  1138. for (BaseExpert baseExpert : baseExpertList) {
  1139. if (NameListType.BLACK.getCode().equals(baseExpert.getStatus())) {
  1140. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")属于黑名单");
  1141. } else {
  1142. if (ObjectUtils.isEmpty(baseExpert.getStatus())) {
  1143. baseExpert.setStatus(NameListType.WHITE.getCode());
  1144. }
  1145. }
  1146. if (ObjectUtils.isEmpty(baseExpert.getCreated())) {
  1147. baseExpert.setCreated(pmBaseExpertFillReqVo.getCreateBy());
  1148. baseExpert.setCreateTime(now);
  1149. }
  1150. if (ObjectUtils.isEmpty(baseExpert.getUpdated())) {
  1151. baseExpert.setUpdated(pmBaseExpertFillReqVo.getUpdateBy());
  1152. baseExpert.setUpdateTime(now);
  1153. }
  1154. if (ObjectUtils.isEmpty(baseExpert.getId())) {
  1155. LambdaQueryWrapper<BaseExpert> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1156. lambdaQueryWrapper.eq(BaseExpert::getIdNumber, baseExpert.getIdNumber());
  1157. BaseExpert baseExpert1 = baseExpertService.getOne(lambdaQueryWrapper);
  1158. if (!ObjectUtils.isEmpty(baseExpert1)) {
  1159. baseExpert.setId(baseExpert1.getId());
  1160. }
  1161. }
  1162. if (baseExpertService.saveOrUpdate(baseExpert)) {
  1163. LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1164. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  1165. .eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  1166. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertFillReqVo.getAccessTime());
  1167. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(pmDemandExpertRefLambdaQueryWrapper);
  1168. if (pmDemandExpertRef == null) {
  1169. pmDemandExpertRef = new PmDemandExpertRef();
  1170. pmDemandExpertRef.setCreateBy(pmBaseExpertFillReqVo.getCreateBy());
  1171. pmDemandExpertRef.setCreateTime(now);
  1172. }
  1173. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  1174. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  1175. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertFillReqVo.getAccessTime()));
  1176. pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
  1177. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  1178. pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
  1179. //专家单位
  1180. if (StringUtils.isNotNull(baseExpert.getUnitInformation())) {
  1181. List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(baseExpert.getUnitInformation());
  1182. if (baseUnitInformationList.size() <= 0) {
  1183. BaseUnitInformation baseUnitInformation = new BaseUnitInformation();
  1184. baseUnitInformation.setUnitName(baseExpert.getUnitInformation());
  1185. baseUnitInformation.setCreated(baseExpert.getExpertName());
  1186. baseUnitInformation.setCreateTime(new Date());
  1187. Integer i = baseExpertMapper.insertBaseUnitInformation(baseUnitInformation);
  1188. }
  1189. }
  1190. }
  1191. }
  1192. PmDemand pmDemandUpdate = new PmDemand();
  1193. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1194. pmDemandUpdate.setHasExpert("1");
  1195. this.updateById(pmDemandUpdate);
  1196. return true;
  1197. }
  1198. @Override
  1199. @Transactional(rollbackFor = Exception.class)
  1200. public boolean extractExpertBatch(PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) throws Exception {
  1201. PmDemand pmDemand = this.getById(pmBaseExpertExtractReqVo.getDemandId());
  1202. if (ObjectUtils.isEmpty(pmDemand)) {
  1203. throw new Exception("参数错误");
  1204. }
  1205. String professional = pmBaseExpertExtractReqVo.getProfessional();
  1206. if (ObjectUtils.isEmpty(professional)) {
  1207. throw new Exception("必须选择专家专业");
  1208. }
  1209. String localArea = pmBaseExpertExtractReqVo.getLocalArea();
  1210. if (ObjectUtils.isEmpty(localArea)) {
  1211. throw new Exception("必须选择地域");
  1212. }
  1213. if (!StringUtils.isNumeric(localArea)) {
  1214. throw new Exception("地域必须传数字代码");
  1215. }
  1216. Integer technicalExpertNumber = pmBaseExpertExtractReqVo.getTechnicalExpertNumber();
  1217. if (technicalExpertNumber == null) {
  1218. technicalExpertNumber = 0;
  1219. }
  1220. Integer economicExpertNumber = pmBaseExpertExtractReqVo.getEconomicExpertNumber();
  1221. if (economicExpertNumber == null) {
  1222. economicExpertNumber = 0;
  1223. }
  1224. Integer legalAffairsExpertNumber = pmBaseExpertExtractReqVo.getLegalAffairsExpertNumber();
  1225. if (legalAffairsExpertNumber == null) {
  1226. legalAffairsExpertNumber = 0;
  1227. }
  1228. Integer spareExpertNumber = pmBaseExpertExtractReqVo.getSpareExpertNumber();
  1229. if (spareExpertNumber == null) {
  1230. spareExpertNumber = 0;
  1231. }
  1232. if (technicalExpertNumber + economicExpertNumber + legalAffairsExpertNumber + spareExpertNumber == 0) {
  1233. throw new Exception("必须至少填写一个数量");
  1234. }
  1235. String needAvoidUnit = pmBaseExpertExtractReqVo.getNeedAvoidUnit();
  1236. List<String> needAvoidUnitList = null;
  1237. if (!ObjectUtils.isEmpty(needAvoidUnit)) {
  1238. String[] arr = needAvoidUnit.split(",");
  1239. needAvoidUnitList = Arrays.asList(arr);
  1240. }
  1241. List<String> sysRegionCodeList = new ArrayList<>();
  1242. if (!ObjectUtils.isEmpty(localArea)) {
  1243. sysRegionCodeList.add(localArea);
  1244. //找到该地域code对应的子列表
  1245. List<SysRegionVO> sysRegionVOList = iSysRegionService.findChildDivisions(localArea);
  1246. if (!ObjectUtils.isEmpty(sysRegionVOList)) {
  1247. for (SysRegionVO vo : sysRegionVOList) {
  1248. sysRegionCodeList.add(vo.getCode());
  1249. }
  1250. }
  1251. }
  1252. //从专家库中查询符合项目类型的以及是白名单的全部列表
  1253. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
  1254. lw.eq(BaseExpert::getStatus, NameListType.WHITE.getCode())
  1255. .notIn(!ObjectUtils.isEmpty(needAvoidUnitList), BaseExpert::getUnitInformation, needAvoidUnitList)
  1256. .in(!ObjectUtils.isEmpty(sysRegionCodeList), BaseExpert::getLocalArea, sysRegionCodeList); //地域
  1257. List<BaseExpert> baseExpertList = baseExpertService.list(lw);
  1258. if (ObjectUtils.isEmpty(baseExpertList)) {
  1259. throw new Exception("没抽取到符合条件的专家");
  1260. }
  1261. //从列表中挑出来各个类型的子列表
  1262. List<BaseExpert> technicalExpertList = new ArrayList<>();
  1263. List<BaseExpert> economicExpertList = new ArrayList<>();
  1264. List<BaseExpert> legalAffairsExpertList = new ArrayList<>();
  1265. List<BaseExpert> spareExpertList = new ArrayList<>();
  1266. String[] arr = professional.split(",");
  1267. List<String> professionalList = Arrays.asList(arr);
  1268. for (BaseExpert baseExpert : baseExpertList) {
  1269. //专业类型判断
  1270. String majorType = baseExpert.getMajorType();
  1271. if (!ObjectUtils.isEmpty(majorType)) {
  1272. String[] arr2 = majorType.split(",");
  1273. List<String> majorTypeList = Arrays.asList(arr2);
  1274. if (!hasIntersection(professionalList, majorTypeList)) { //不符合专业类型
  1275. continue;
  1276. }
  1277. }
  1278. //备用专家
  1279. if (spareExpertNumber > 0) { //都加进去
  1280. spareExpertList.add(baseExpert);
  1281. }
  1282. if (technicalExpertNumber > 0) {
  1283. if (baseExpert.getExpertType().contains(ExpertType.TECHNICAL_EXPERT.getCode())) {
  1284. technicalExpertList.add(baseExpert);
  1285. continue;
  1286. }
  1287. }
  1288. if (economicExpertNumber > 0) {
  1289. if (baseExpert.getExpertType().contains(ExpertType.ECONOMIC_EXPERT.getCode())) {
  1290. economicExpertList.add(baseExpert);
  1291. continue;
  1292. }
  1293. }
  1294. if (legalAffairsExpertNumber > 0) {
  1295. if (baseExpert.getExpertType().contains(ExpertType.LEGALAFFAIRS_EXPERT.getCode())) {
  1296. legalAffairsExpertList.add(baseExpert);
  1297. continue;
  1298. }
  1299. }
  1300. }
  1301. //从子列表中随机抽取符合数据量的
  1302. List<BaseExpert> alltExpertList = new ArrayList<>();
  1303. if (technicalExpertNumber > 0 && technicalExpertList.size() < technicalExpertNumber) {
  1304. throw new Exception("抽取到符合条件的技术专家数量不够");
  1305. }
  1306. if (!ObjectUtils.isEmpty(technicalExpertList)) {
  1307. alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
  1308. }
  1309. if (economicExpertNumber > 0 && economicExpertList.size() < economicExpertNumber) {
  1310. throw new Exception("抽取到符合条件的经济专家数量不够");
  1311. }
  1312. if (!ObjectUtils.isEmpty(economicExpertList)) {
  1313. alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
  1314. }
  1315. if (legalAffairsExpertNumber > 0 && legalAffairsExpertList.size() < legalAffairsExpertNumber) {
  1316. throw new Exception("抽取到符合条件的法务专家数量不够");
  1317. }
  1318. if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
  1319. alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
  1320. }
  1321. List<BaseExpert> spareExpertListNew = new ArrayList<>();
  1322. if (!ObjectUtils.isEmpty(spareExpertList)) {
  1323. //获取全部IDlist
  1324. List<Integer> allExpertIdList = new ArrayList<>();
  1325. if (!ObjectUtils.isEmpty(alltExpertList)) {
  1326. for (BaseExpert baseExpert : alltExpertList) {
  1327. allExpertIdList.add(baseExpert.getId());
  1328. }
  1329. }
  1330. //遍历全部IDlist
  1331. if (!ObjectUtils.isEmpty(allExpertIdList)) { //去重
  1332. for (BaseExpert baseExpert : spareExpertList) {
  1333. if (!allExpertIdList.contains(baseExpert.getId())) {
  1334. spareExpertListNew.add(baseExpert);
  1335. }
  1336. }
  1337. } else {
  1338. spareExpertListNew = spareExpertList;
  1339. }
  1340. if (!ObjectUtils.isEmpty(spareExpertListNew)) {
  1341. alltExpertList.addAll(RandomUtil.getRandomList(spareExpertListNew, spareExpertNumber));
  1342. }
  1343. }
  1344. if (spareExpertNumber > 0 && spareExpertListNew.size() < spareExpertNumber) {
  1345. throw new Exception("抽取到符合条件的备用专家数量不够");
  1346. }
  1347. if (ObjectUtils.isEmpty(alltExpertList)) {
  1348. throw new Exception("没抽取到符合条件的专家");
  1349. } else {
  1350. List<PmDemandExpertRef> pmDemandExpertRefList = new ArrayList<>();
  1351. for (BaseExpert baseExpert : alltExpertList) {
  1352. LambdaQueryWrapper<PmDemandExpertRef> baseExpertLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1353. baseExpertLambdaQueryWrapper.eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  1354. .eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  1355. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertExtractReqVo.getAccessTime());
  1356. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(baseExpertLambdaQueryWrapper);
  1357. if (pmDemandExpertRef == null) {
  1358. pmDemandExpertRef = new PmDemandExpertRef();
  1359. pmDemandExpertRef.setCreateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1360. pmDemandExpertRef.setCreateTime(new Date());
  1361. }
  1362. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  1363. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  1364. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertExtractReqVo.getAccessTime()));
  1365. pmDemandExpertRef.setUpdateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1366. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  1367. pmDemandExpertRefList.add(pmDemandExpertRef);
  1368. }
  1369. PmDemand pmDemandUpdate = new PmDemand();
  1370. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1371. pmDemandUpdate.setHasExpert("1");
  1372. this.updateById(pmDemandUpdate);
  1373. return pmDemandExpertRefService.saveOrUpdateBatch(pmDemandExpertRefList);
  1374. }
  1375. }
  1376. //二个列表是否有交集
  1377. private boolean hasIntersection(List<String> professionalList, List<String> majorTypeList) {
  1378. for (String professiona : professionalList) {
  1379. for (String majorType : majorTypeList) {
  1380. if (professiona.equals(majorType)) {
  1381. return true;
  1382. }
  1383. }
  1384. }
  1385. return false;
  1386. }
  1387. @Override
  1388. @Transactional(rollbackFor = Exception.class)
  1389. public boolean insertBidOpeningBatch(PmBidOpeningFillReqVo pmBidOpeningFillReqVo) throws Exception {
  1390. PmDemand pmDemand = this.getById(pmBidOpeningFillReqVo.getDemandId());
  1391. if (ObjectUtils.isEmpty(pmDemand)) {
  1392. throw new Exception("参数错误");
  1393. }
  1394. //从发布公告里获取开标时间
  1395. LambdaQueryWrapper<PmReleaseAnnouncement> lw = new LambdaQueryWrapper<>();
  1396. lw.eq(PmReleaseAnnouncement::getDemandId, pmDemand.getDemandId()).orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  1397. .last(" limit 1 ");
  1398. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(lw);
  1399. if (pmReleaseAnnouncement == null) {
  1400. throw new Exception("发布公告不存在");
  1401. }
  1402. Date tenderOpenTime = pmReleaseAnnouncement.getTenderOpenTime();
  1403. Date now = new Date();
  1404. List<PmBidOpening> pmBidOpeningList = pmBidOpeningFillReqVo.getPmBidOpeningList();
  1405. for (PmBidOpening pmBidOpening : pmBidOpeningList) {
  1406. if (ObjectUtils.isEmpty(pmBidOpening.getBidderName())) {
  1407. throw new Exception("投标人名称不能为空");
  1408. }
  1409. if (ObjectUtils.isEmpty(pmBidOpening.getScore())) {
  1410. throw new Exception("分数不能为空");
  1411. }
  1412. pmBidOpening.setOpenBidTime(tenderOpenTime);
  1413. pmBidOpening.setDemandId(pmBidOpeningFillReqVo.getDemandId());
  1414. pmBidOpening.setCreateBy(pmBidOpeningFillReqVo.getCreateBy());
  1415. pmBidOpening.setCreateTime(now);
  1416. pmBidOpening.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1417. pmBidOpening.setUpdateTime(now);
  1418. }
  1419. if (pmBidOpeningService.saveOrUpdateBatch(pmBidOpeningList)) {
  1420. PmDemand pmDemandUpdate = new PmDemand();
  1421. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1422. pmDemandUpdate.setProjectStatus(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1423. pmDemandUpdate.setUpdateTime(now);
  1424. pmDemandUpdate.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1425. return this.updateById(pmDemandUpdate);
  1426. } else {
  1427. return false;
  1428. }
  1429. }
  1430. /**
  1431. * 预中标
  1432. *
  1433. * @param pmBidWinningReqVo
  1434. * @return
  1435. * @throws Exception
  1436. */
  1437. @Override
  1438. @Transactional(rollbackFor = Exception.class)
  1439. public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1440. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1441. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount()) && ObjectUtils.isEmpty(pmBidWinningReqVo.getRemarks())) {
  1442. throw new Exception("中标金额或备注必须填写一个");
  1443. }
  1444. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1445. throw new Exception("中标单位信息列表不能为空");
  1446. }
  1447. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1448. throw new Exception("上传附件不能为空");
  1449. }
  1450. PmBidWinning pmBidWinning = new PmBidWinning();
  1451. BeanUtils.copyProperties(pmBidWinningReqVo, pmBidWinning);
  1452. //修改老的中标信息状态
  1453. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getId())) { //属于新增
  1454. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1455. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId())
  1456. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1457. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  1458. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1459. for (PmBidWinning item : pmBidWinninglist) {
  1460. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1461. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1462. .eq(PmBidWinning::getId, item.getId());
  1463. pmBidWinningService.update(updateWrapper1);
  1464. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1465. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1466. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1467. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1468. pmBidWinningOpeningRefService.update(updateWrapper2);
  1469. }
  1470. }
  1471. }
  1472. if (pmBidWinningService.saveOrUpdate(pmBidWinning)) {
  1473. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1474. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1475. LambdaQueryWrapper<PmBidWinningOpeningRef> pmBidWinningOpeningRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1476. pmBidWinningOpeningRefLambdaQueryWrapper.eq(PmBidWinningOpeningRef::getOpeningId, pmBidOpeningId)
  1477. .eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId());
  1478. PmBidWinningOpeningRef pmBidWinningOpeningRef = pmBidWinningOpeningRefService.getOne(pmBidWinningOpeningRefLambdaQueryWrapper);
  1479. if (pmBidWinningOpeningRef == null) {
  1480. pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1481. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1482. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1483. }
  1484. pmBidWinningOpeningRef.setDemandId(pmBidWinning.getDemandId());
  1485. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1486. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1487. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1488. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1489. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1490. }
  1491. if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
  1492. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
  1493. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1494. PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
  1495. BaseNotice baseNotice = new BaseNotice();
  1496. baseNotice.setName(pmDemand.getProjectName());
  1497. baseNotice.setTitle(pmDemand.getProjectName() + "预中标公告");
  1498. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1499. lambdaQueryWrapper.eq(BaseNoticeType::getName, "预中标公告");
  1500. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1501. if (baseNoticeType == null) {
  1502. throw new Exception("预中标公告 公告类型不存在");
  1503. }
  1504. baseNotice.setDemandId(pmDemand.getDemandId());
  1505. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1506. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1507. baseNotice.setType(baseNoticeType.getId());
  1508. baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
  1509. baseNotice.setCreated(pmBidWinningReqVo.getCreateBy());
  1510. baseNotice.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1511. baseNotice.setUpdated(pmBidWinningReqVo.getUpdateBy());
  1512. baseNotice.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1513. this.baseNoticeService.saveOrUpdate(baseNotice);
  1514. PmDemand pmDemandUpdate = new PmDemand();
  1515. pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
  1516. pmDemandUpdate.setProjectStatus(PmProjectStatus.POST_BID_QUERY.getCode());
  1517. pmDemandUpdate.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1518. pmDemandUpdate.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1519. return this.updateById(pmDemandUpdate);
  1520. } else {
  1521. return false;
  1522. }
  1523. } else {
  1524. return false;
  1525. }
  1526. }
  1527. @Override
  1528. @Transactional(rollbackFor = Exception.class)
  1529. public boolean updatePmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1530. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1531. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1532. throw new Exception("中标单位信息列表不能为空");
  1533. }
  1534. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1535. throw new Exception("中标金额不能为空");
  1536. }
  1537. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1538. throw new Exception("上传附件不能为空");
  1539. }
  1540. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1541. lw.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1542. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1543. if (ObjectUtils.isEmpty(pmBidWinninglist)) {
  1544. throw new Exception("原中标信息不存在");
  1545. }
  1546. //修改老的状态
  1547. for (PmBidWinning item : pmBidWinninglist) {
  1548. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1549. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1550. .eq(PmBidWinning::getId, item.getId());
  1551. pmBidWinningService.update(updateWrapper1);
  1552. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1553. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1554. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1555. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1556. pmBidWinningOpeningRefService.update(updateWrapper2);
  1557. }
  1558. //新增
  1559. PmBidWinning pmBidWinning = new PmBidWinning();
  1560. BeanUtils.copyProperties(pmBidWinninglist.get(0), pmBidWinning);
  1561. pmBidWinning.setId(null);
  1562. pmBidWinning.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
  1563. pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
  1564. pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1565. pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1566. if (pmBidWinningService.save(pmBidWinning)) {
  1567. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1568. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1569. PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1570. pmBidWinningOpeningRef.setDemandId(pmBidWinning.getDemandId());
  1571. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1572. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1573. pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
  1574. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1575. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1576. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1577. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1578. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1579. }
  1580. LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1581. sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType, SysFileRefEnum.PM_BID_WINNING_FILE.getType())
  1582. .eq(SysFileRef::getRedId, pmBidWinninglist.get(0));
  1583. List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
  1584. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
  1585. return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
  1586. } else {
  1587. return false;
  1588. }
  1589. }
  1590. /**
  1591. * 流标
  1592. *
  1593. * @param pmBidFailureReqVo
  1594. * @return
  1595. * @throws Exception
  1596. */
  1597. @Override
  1598. @Transactional(rollbackFor = Exception.class)
  1599. public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
  1600. PmBidFailure pmBidFailure = new PmBidFailure();
  1601. BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
  1602. if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
  1603. //把中标信息修改状态
  1604. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1605. lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1606. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1607. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1608. for (PmBidWinning item : pmBidWinninglist) {
  1609. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1610. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1611. .eq(PmBidWinning::getId, item.getId());
  1612. pmBidWinningService.update(updateWrapper1);
  1613. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1614. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1615. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1616. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1617. pmBidWinningOpeningRefService.update(updateWrapper2);
  1618. }
  1619. }
  1620. uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
  1621. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1622. PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
  1623. BaseNotice baseNotice = new BaseNotice();
  1624. baseNotice.setName(pmDemand.getProjectName());
  1625. baseNotice.setTitle(pmDemand.getProjectName() + "流废标公告");
  1626. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1627. lambdaQueryWrapper.eq(BaseNoticeType::getName, "流废标公告");
  1628. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1629. if (baseNoticeType == null) {
  1630. throw new Exception("流废标公告 公告类型不存在");
  1631. }
  1632. baseNotice.setDemandId(pmDemand.getDemandId());
  1633. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1634. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1635. baseNotice.setType(baseNoticeType.getId());
  1636. baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
  1637. baseNotice.setCreated(pmBidFailureReqVo.getCreateBy());
  1638. baseNotice.setCreateTime(pmBidFailureReqVo.getCreateTime());
  1639. baseNotice.setUpdated(pmBidFailureReqVo.getUpdateBy());
  1640. baseNotice.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1641. this.baseNoticeService.saveOrUpdate(baseNotice);
  1642. PmDemand pmDemandUpdate = new PmDemand();
  1643. pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
  1644. pmDemandUpdate.setProjectStatus(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1645. pmDemandUpdate.setHasExpert("0");
  1646. pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1647. pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
  1648. return this.updateById(pmDemandUpdate);
  1649. } else {
  1650. return false;
  1651. }
  1652. }
  1653. @Override
  1654. @Transactional(rollbackFor = Exception.class)
  1655. public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
  1656. Long demandId = pmContractInfoReqVo.getDemandId();
  1657. if (ObjectUtils.isEmpty(demandId)) {
  1658. throw new Exception("采购需求ID不能为空");
  1659. }
  1660. PmDemand pmDemand = this.getById(demandId);
  1661. if (ObjectUtils.isEmpty(pmDemand)) {
  1662. throw new Exception("采购需求ID错误");
  1663. }
  1664. List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
  1665. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1666. throw new Exception("上传附件不能为空");
  1667. }
  1668. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1669. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  1670. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  1671. if (pmContractInfo != null) {
  1672. pmContractInfoReqVo.setId(pmContractInfo.getId());
  1673. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1674. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1675. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1676. } else {
  1677. pmContractInfo = new PmContractInfo();
  1678. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1679. pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
  1680. pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
  1681. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1682. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1683. }
  1684. if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
  1685. this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
  1686. PmDemand pmDemandUpdate = new PmDemand();
  1687. pmDemandUpdate.setDemandId(demandId);
  1688. pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1689. pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1690. pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1691. return this.updateById(pmDemandUpdate);
  1692. } else {
  1693. return false;
  1694. }
  1695. }
  1696. @Override
  1697. @Transactional(rollbackFor = Exception.class)
  1698. public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
  1699. Long demandId = pmProjectConstructionReqVo.getDemandId();
  1700. if (ObjectUtils.isEmpty(demandId)) {
  1701. throw new Exception("采购需求ID不能为空");
  1702. }
  1703. PmDemand pmDemand = this.getById(demandId);
  1704. if (ObjectUtils.isEmpty(pmDemand)) {
  1705. throw new Exception("采购需求ID错误");
  1706. }
  1707. List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
  1708. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1709. throw new Exception("上传附件不能为空");
  1710. }
  1711. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1712. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  1713. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  1714. if (pmProjectConstruction != null) {
  1715. pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
  1716. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1717. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1718. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1719. } else {
  1720. pmProjectConstruction = new PmProjectConstruction();
  1721. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1722. pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
  1723. pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
  1724. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1725. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1726. }
  1727. if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
  1728. this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
  1729. PmDemand pmDemandUpdate = new PmDemand();
  1730. pmDemandUpdate.setDemandId(demandId);
  1731. pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1732. pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
  1733. pmDemandUpdate.setWarnStatus(WarnStatus.NORMAL.getCode());
  1734. pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1735. pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1736. return this.updateById(pmDemandUpdate);
  1737. } else {
  1738. return false;
  1739. }
  1740. }
  1741. /**
  1742. * 更新需求预警状态
  1743. *
  1744. * @param demnadId
  1745. * @return
  1746. */
  1747. @Override
  1748. @Transactional(rollbackFor = Exception.class)
  1749. public void updateDemandWarnStatus(Long demnadId) {
  1750. PmDemand pmDemand = this.getById(demnadId);
  1751. List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
  1752. int setting1 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划提报时间")).collect(Collectors.toList()).get(0).getDictValue());
  1753. log.info("******** setting1 == " + setting1);
  1754. //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
  1755. int diff1 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanDemandSubTime(), DateUtils.parseDate(DateUtils.getDate()));
  1756. if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && diff1 > 0 && diff1 <= setting1) {
  1757. PmDemand pmDemandUpdate = new PmDemand();
  1758. pmDemandUpdate.setDemandId(demnadId);
  1759. pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_WARNING.getCode());
  1760. this.updateById(pmDemandUpdate);
  1761. } else if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && pmDemand.getPlanDemandSubTime().getTime() < System.currentTimeMillis()) {
  1762. PmDemand pmDemandUpdate = new PmDemand();
  1763. pmDemandUpdate.setDemandId(demnadId);
  1764. pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_EX.getCode());
  1765. this.updateById(pmDemandUpdate);
  1766. }
  1767. }
  1768. /**
  1769. * 通过需求ID列表 查询采购执行列表 sunhh
  1770. *
  1771. * @param demandIdList
  1772. * @return
  1773. */
  1774. @Override
  1775. public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
  1776. return this.baseMapper.selectByDemandIdList(demandIdList);
  1777. }
  1778. /**
  1779. * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
  1780. *
  1781. * @param baseExpertVo
  1782. * @return
  1783. */
  1784. @Override
  1785. public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
  1786. return pmDemandMapper.selectExtractionExpert(baseExpertVo);
  1787. }
  1788. @Override
  1789. public List<PmDemand> demandWaitCommit() {
  1790. List<PmDemand> byStatus = getListByStatus(PmProjectStatus.DEMAND_WAIT_FILL.getCode());
  1791. byStatus.addAll(getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  1792. return (byStatus);
  1793. }
  1794. @Override
  1795. public List<PmDemand> contractWaitFilled() {
  1796. List<PmDemand> byStatus = getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  1797. return (byStatus);
  1798. }
  1799. @Override
  1800. public List<PmDemand> projectWaitFinish() {
  1801. List<PmDemand> byStatus = getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1802. return (byStatus);
  1803. }
  1804. @Override
  1805. public List<PmDemand> demandWaitExamine() {
  1806. return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  1807. }
  1808. @Override
  1809. public List<PmDemand> taskWaitRelease() {
  1810. return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  1811. }
  1812. @Override
  1813. public List<PmDemandResVo> purchaseDemandDocking() {
  1814. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1815. return listToVoList(byStatus);
  1816. }
  1817. @Override
  1818. public List<PmDemandResVo> expertFeedback() {
  1819. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  1820. return listToVoList(byStatus);
  1821. }
  1822. @Override
  1823. public List<PmDemandResVo> procurementDocumentsReview() {
  1824. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  1825. return listToVoList(byStatus);
  1826. }
  1827. @Override
  1828. public List<PmDemandResVo> procurementAnnouncement() {
  1829. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  1830. return listToVoList(byStatus);
  1831. }
  1832. @Override
  1833. public List<PmDemandResVo> preBidQuery() {
  1834. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.PRE_BID_QUERY.getCode());
  1835. return listToVoList(byStatus);
  1836. }
  1837. @Override
  1838. public List<PmDemandResVo> waitOpenBid() {
  1839. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1840. return listToVoList(byStatus);
  1841. }
  1842. @Override
  1843. public List<PmDemandResVo> bidResultAnnouncement() {
  1844. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1845. return listToVoList(byStatus);
  1846. }
  1847. @Override
  1848. public List<PmDemandResVo> wasteBidHandle() {
  1849. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1850. return listToVoList(byStatus);
  1851. }
  1852. @Override
  1853. public List<PmDemandResVo> postBidQuery() {
  1854. List<PmDemand> byStatus = getListByStatusCGB(PmProjectStatus.POST_BID_QUERY.getCode());
  1855. return listToVoList(byStatus);
  1856. }
  1857. @Override
  1858. public AjaxResult procurementOfficeWillManipulateTotal() {
  1859. List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
  1860. // 采购需求对接,专家意见反馈,采购文件编制审核,采购公告发布,标前质疑投诉,待开标,评标结果公告,流废标处置,标后质疑
  1861. List<PmDemandResVo> demandRes = new ArrayList<>();
  1862. List<String> projectStatus = new ArrayList<>();
  1863. projectStatus.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1864. projectStatus.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  1865. projectStatus.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  1866. projectStatus.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  1867. projectStatus.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  1868. projectStatus.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1869. projectStatus.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1870. projectStatus.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1871. projectStatus.add(PmProjectStatus.POST_BID_QUERY.getCode());
  1872. demandRes = listToVoList(getListByStatusTotalCGB(projectStatus));
  1873. //计划数据--发函催告
  1874. List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
  1875. //转为首页table展示数据
  1876. if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
  1877. for (PmDemandResVo demandResVo : demandRes) {
  1878. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1879. home.setEvaluation(BigDecimal.valueOf(demandResVo.getEvaluation()));
  1880. BeanUtils.copyProperties(demandResVo, home);
  1881. homeRes.add(home);
  1882. }
  1883. }
  1884. if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
  1885. for (PlanQuarterResponseVo planVo : planRes) {
  1886. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1887. BeanUtils.copyProperties(planVo, home);
  1888. homeRes.add(home);
  1889. }
  1890. }
  1891. return AjaxResult.success(homeRes);
  1892. }
  1893. @Override
  1894. public AjaxResult procurementOfficeWillManipulateTotalNum() {
  1895. List<StatisticalChartsResVo> result = new ArrayList<>();
  1896. // 采购需求对接,专家意见反馈,采购文件编制审核,采购公告发布,标前质疑投诉,待开标,评标结果公告,流废标处置,标后质疑
  1897. Integer numByStatus = getNumByStatusCGB(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  1898. StatisticalChartsResVo chartsResVo = new StatisticalChartsResVo();
  1899. chartsResVo.setNum(numByStatus);
  1900. chartsResVo.setColumnName("采购需求对接");
  1901. result.add(chartsResVo);
  1902. Integer numByStatus1 = getNumByStatusCGB(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  1903. StatisticalChartsResVo chartsResVo1 = new StatisticalChartsResVo();
  1904. chartsResVo1.setColumnName("专家意见反馈");
  1905. chartsResVo1.setNum(numByStatus1);
  1906. result.add(chartsResVo1);
  1907. Integer numByStatus2 = getNumByStatusCGB(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  1908. StatisticalChartsResVo chartsResVo2 = new StatisticalChartsResVo();
  1909. chartsResVo2.setColumnName("采购文件编制审核");
  1910. chartsResVo2.setNum(numByStatus2);
  1911. result.add(chartsResVo2);
  1912. Integer numByStatus3 = getNumByStatusCGB(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  1913. StatisticalChartsResVo chartsResVo3 = new StatisticalChartsResVo();
  1914. chartsResVo3.setColumnName("采购公告发布");
  1915. chartsResVo3.setNum(numByStatus3);
  1916. result.add(chartsResVo3);
  1917. Integer numByStatus4 = getNumByStatusCGB(PmProjectStatus.PRE_BID_QUERY.getCode());
  1918. StatisticalChartsResVo chartsResVo4 = new StatisticalChartsResVo();
  1919. chartsResVo4.setColumnName("标前质疑投诉");
  1920. chartsResVo4.setNum(numByStatus4);
  1921. result.add(chartsResVo4);
  1922. Integer numByStatus5 = getNumByStatusCGB(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1923. StatisticalChartsResVo chartsResVo5 = new StatisticalChartsResVo();
  1924. chartsResVo5.setColumnName("待开标");
  1925. chartsResVo5.setNum(numByStatus5);
  1926. result.add(chartsResVo5);
  1927. Integer numByStatus6 = getNumByStatusCGB(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  1928. StatisticalChartsResVo chartsResVo6 = new StatisticalChartsResVo();
  1929. chartsResVo6.setColumnName("评标结果公告");
  1930. chartsResVo6.setNum(numByStatus6);
  1931. result.add(chartsResVo6);
  1932. Integer numByStatus7 = getNumByStatusCGB(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  1933. StatisticalChartsResVo chartsResVo7 = new StatisticalChartsResVo();
  1934. chartsResVo7.setColumnName("流废标处置");
  1935. chartsResVo7.setNum(numByStatus7);
  1936. result.add(chartsResVo7);
  1937. Integer numByStatus8 = getNumByStatusCGB(PmProjectStatus.POST_BID_QUERY.getCode());
  1938. StatisticalChartsResVo chartsResVo8 = new StatisticalChartsResVo();
  1939. chartsResVo8.setColumnName("标后质疑");
  1940. chartsResVo8.setNum(numByStatus8);
  1941. result.add(chartsResVo8);
  1942. //计划数据--发函催告
  1943. Integer letterNum = planYearsService.willSendLetterNum();
  1944. StatisticalChartsResVo chartsResVo9 = new StatisticalChartsResVo();
  1945. chartsResVo9.setColumnName("发函催告");
  1946. chartsResVo9.setNum(letterNum);
  1947. result.add(chartsResVo9);
  1948. StatisticalChartsResVo chartsResVoT = new StatisticalChartsResVo();
  1949. chartsResVoT.setColumnName("全部");
  1950. chartsResVoT.setNum(willTotal(result));
  1951. result.add(chartsResVoT);
  1952. return AjaxResult.success(result);
  1953. }
  1954. public Integer willTotal(List<StatisticalChartsResVo> result) {
  1955. Integer re = 0;
  1956. if (!ObjectUtils.isEmpty(result)) {
  1957. for (StatisticalChartsResVo resVo : result) {
  1958. re += resVo.getNum();
  1959. }
  1960. }
  1961. return re;
  1962. }
  1963. /**
  1964. * 统计分析-采购项目信息统计
  1965. *
  1966. * @param pmDemandReqVo
  1967. * @return
  1968. */
  1969. @Override
  1970. public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
  1971. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  1972. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  1973. Map<String, Integer> mapReturn = new HashMap<>();
  1974. // 查询项目总数量
  1975. Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
  1976. // 查询已完成项目数量,预算(合同)金额数量
  1977. Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
  1978. // 查询新创建项目数量,预算金额数量
  1979. Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
  1980. // 查询去年完成项目数量,预算(合同)金额数量
  1981. Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
  1982. mapReturn.putAll(mapCount);
  1983. mapReturn.putAll(mapYWC);
  1984. mapReturn.putAll(mapXCJ);
  1985. mapReturn.putAll(mapQNWC);
  1986. return mapReturn;
  1987. }
  1988. @Override
  1989. public List<StatisticalChartsResVo> countByProjectAttr(PmDemandReqVo pmDemandReqVo) {
  1990. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  1991. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  1992. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  1993. } else {
  1994. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  1995. }
  1996. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1997. //直接获取每个属性的数量
  1998. //重点采购项目
  1999. pmDemandReqVo.setProjectAttr(ProjectAttribute.emergency.getCode());
  2000. StatisticalChartsResVo vo1 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2001. vo1.setColumnName("重点采购项目");
  2002. resVos.add(vo1);
  2003. //重大规划任务项目
  2004. pmDemandReqVo.setProjectAttr(ProjectAttribute.majorPlan.getCode());
  2005. StatisticalChartsResVo vo2 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2006. vo2.setColumnName("重大规划任务项目");
  2007. resVos.add(vo2);
  2008. //规划任务项目
  2009. pmDemandReqVo.setProjectAttr(ProjectAttribute.plan.getCode());
  2010. StatisticalChartsResVo vo3 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2011. vo3.setColumnName("规划任务项目");
  2012. resVos.add(vo3);
  2013. //一般采购项目
  2014. pmDemandReqVo.setProjectAttr(ProjectAttribute.commonly.getCode());
  2015. StatisticalChartsResVo vo4 = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  2016. vo4.setColumnName("一般采购项目");
  2017. resVos.add(vo4);
  2018. return resVos;
  2019. }
  2020. @Override
  2021. public List<StatisticalChartsResVo> countByTaskAttr(PmDemandReqVo pmDemandReqVo) {
  2022. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2023. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2024. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2025. } else {
  2026. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2027. }
  2028. //状态为“任务待下达”以后的数据
  2029. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2030. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2031. //重点采购项目
  2032. pmDemandReqVo.setProjectAttr(ProjectAttribute.emergency.getCode());
  2033. StatisticalChartsResVo vo1 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2034. vo1.setColumnName("重点采购项目");
  2035. resVos.add(vo1);
  2036. //重大规划任务项目
  2037. pmDemandReqVo.setProjectAttr(ProjectAttribute.majorPlan.getCode());
  2038. StatisticalChartsResVo vo2 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2039. vo2.setColumnName("重大规划任务项目");
  2040. resVos.add(vo2);
  2041. //规划任务项目
  2042. pmDemandReqVo.setProjectAttr(ProjectAttribute.plan.getCode());
  2043. StatisticalChartsResVo vo3 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2044. vo3.setColumnName("规划任务项目");
  2045. resVos.add(vo3);
  2046. //一般采购项目
  2047. pmDemandReqVo.setProjectAttr(ProjectAttribute.commonly.getCode());
  2048. StatisticalChartsResVo vo4 = pmDemandMapper.countByTaskAttr(pmDemandReqVo);
  2049. vo4.setColumnName("一般采购项目");
  2050. resVos.add(vo4);
  2051. return resVos;
  2052. }
  2053. @Override
  2054. public List<StatisticalChartsResVo> countByPurchaseMode(PmDemandReqVo pmDemandReqVo) {
  2055. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2056. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2057. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2058. } else {
  2059. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2060. }
  2061. //状态为“任务待下达”以后的数据
  2062. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2063. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2064. //公开招标
  2065. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.OPEN_BIDDING.getCode());
  2066. StatisticalChartsResVo chartsR = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2067. chartsR.setColumnName("公开招标");
  2068. resVos.add(chartsR);
  2069. //邀请招标
  2070. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.SELECTED_BIDDING.getCode());
  2071. StatisticalChartsResVo chartsR1 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2072. chartsR1.setColumnName("邀请招标");
  2073. resVos.add(chartsR1);
  2074. //竞争性谈判
  2075. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.COMPETITIVE_NEGOTIATION.getCode());
  2076. StatisticalChartsResVo chartsR2 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2077. chartsR2.setColumnName("竞争性谈判");
  2078. resVos.add(chartsR2);
  2079. //询价
  2080. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.ENQUIRY.getCode());
  2081. StatisticalChartsResVo chartsR3 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2082. chartsR3.setColumnName("询价");
  2083. resVos.add(chartsR3);
  2084. //单一来源
  2085. pmDemandReqVo.setPurchaseMode(ProcurementMethodSuggest.SINGLE_SOURCE.getCode());
  2086. StatisticalChartsResVo chartsR4 = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  2087. chartsR4.setColumnName("单一来源");
  2088. resVos.add(chartsR4);
  2089. return resVos;
  2090. }
  2091. @Override
  2092. public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
  2093. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2094. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2095. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2096. } else {
  2097. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2098. }
  2099. //状态为“任务待下达”以后的数据
  2100. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2101. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2102. //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
  2103. pmDemandReqVo.setEvaluation(100);
  2104. StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(pmDemandReqVo);
  2105. resVo.setColumnName("100万以下采购任务");
  2106. resVos.add(resVo);
  2107. pmDemandReqVo.setEvaluation(100);
  2108. pmDemandReqVo.setEvaluationEnd(500);
  2109. StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2110. resVo1.setColumnName("100至500万元采购任务");
  2111. resVos.add(resVo1);
  2112. pmDemandReqVo.setEvaluation(500);
  2113. pmDemandReqVo.setEvaluationEnd(1000);
  2114. StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2115. resVo2.setColumnName("500至1000万元采购任务");
  2116. resVos.add(resVo2);
  2117. pmDemandReqVo.setEvaluation(1000);
  2118. pmDemandReqVo.setEvaluationEnd(5000);
  2119. StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2120. resVo3.setColumnName("1000至5000万元采购任务");
  2121. resVos.add(resVo3);
  2122. pmDemandReqVo.setEvaluation(5000);
  2123. pmDemandReqVo.setEvaluationEnd(10000);
  2124. StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  2125. resVo4.setColumnName("5000至1亿元采购任务");
  2126. resVos.add(resVo4);
  2127. pmDemandReqVo.setEvaluation(10000);
  2128. StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(pmDemandReqVo);
  2129. resVo5.setColumnName("1亿元及以上采购任务");
  2130. resVos.add(resVo5);
  2131. return resVos;
  2132. }
  2133. @Override
  2134. public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
  2135. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2136. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2137. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2138. } else {
  2139. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2140. }
  2141. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2142. //执行滞后采购项目:本年度所有的逾期项目数
  2143. //预算金额:本年度所有逾期项目累加的预算金额
  2144. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedThisYear(pmDemandReqVo);
  2145. resVo.setColumnName("本年度执行滞后任务");
  2146. resVo.setColumnNamePlus("任务新增数量");
  2147. resVos.add(resVo);
  2148. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedThisQua(pmDemandReqVo);
  2149. resVo2.setColumnName("本季度执行滞后任务");
  2150. resVo2.setColumnNamePlus("任务新增数量");
  2151. resVos.add(resVo2);
  2152. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedThisMonth(pmDemandReqVo);
  2153. resVo3.setColumnName("本月执行滞后任务");
  2154. resVo3.setColumnNamePlus("任务新增数量");
  2155. resVos.add(resVo3);
  2156. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjectExceedAllNum(pmDemandReqVo);
  2157. resVo4.setColumnName("累计执行滞后采购任务");
  2158. resVo4.setColumnNamePlus("采购任务数量");
  2159. resVos.add(resVo4);
  2160. //执行停滞采购任务数量--退回的采购任务数量
  2161. List<String> tzrw = new ArrayList<>();
  2162. tzrw.add(PmProjectStatus.DEMAND_AUDIT_RETURN.getCode());
  2163. pmDemandReqVo.setProjectStatusList(tzrw);
  2164. Map<String, Object> map = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2165. StatisticalChartsResVo resVo5 = new StatisticalChartsResVo();
  2166. resVo5.setColumnName("执行停滞");
  2167. resVo5.setColumnNamePlus("采购任务数量");
  2168. resVo5.setNum(Math.toIntExact((Long) map.get("countNumber")));
  2169. resVo5.setEvaluationTotal((BigDecimal) map.get("evaluationTotal"));
  2170. resVos.add(resVo5);
  2171. return AjaxResult.success(resVos);
  2172. }
  2173. /**
  2174. * 统计不同时间维度的逾期项目
  2175. *
  2176. * @return
  2177. */
  2178. @Override
  2179. public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
  2180. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2181. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2182. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  2183. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear(pmDemandReqVo);
  2184. if (pmDemandReqVo.getTimeType().equals("1")) {
  2185. resMap.put("年", byYear);
  2186. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  2187. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  2188. for (StatisticalChartsResVo chartsResVo : byYear) {
  2189. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  2190. for (int i = 1; i <= 4; i++) {
  2191. pmDemandReqVo.setQuarter(i);
  2192. StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(pmDemandReqVo);
  2193. if (ObjectUtils.isEmpty(quarter)) {
  2194. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  2195. quarter = vo;
  2196. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  2197. }
  2198. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  2199. byQuarter.add(quarter);
  2200. }
  2201. }
  2202. resMap.put("季度", byQuarter);
  2203. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  2204. List<StatisticalChartsResVo> byMonth = new LinkedList<>();
  2205. for (StatisticalChartsResVo chartsResVo : byYear) {
  2206. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  2207. for (int i = 1; i <= 12; i++) {
  2208. pmDemandReqVo.setMonth(i);
  2209. StatisticalChartsResVo month = pmDemandMapper.countProjectExceedMonth(pmDemandReqVo);
  2210. if (ObjectUtils.isEmpty(month)) {
  2211. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  2212. month = vo;
  2213. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  2214. }
  2215. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  2216. byMonth.add(month);
  2217. }
  2218. }
  2219. resMap.put("月", byMonth);
  2220. }
  2221. return AjaxResult.success(resMap);
  2222. }
  2223. @Override
  2224. public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
  2225. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2226. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2227. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  2228. //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
  2229. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear(pmDemandReqVo);
  2230. if (pmDemandReqVo.getTimeType().equals("1")) {
  2231. resMap.put("年", byYear);
  2232. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  2233. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  2234. for (StatisticalChartsResVo chartsResVo : byYear) {
  2235. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  2236. for (int i = 1; i <= 4; i++) {
  2237. pmDemandReqVo.setQuarter(i);
  2238. StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(pmDemandReqVo);
  2239. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  2240. byQuarter.add(quarter);
  2241. }
  2242. }
  2243. resMap.put("季度", byQuarter);
  2244. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  2245. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth(pmDemandReqVo);
  2246. resMap.put("月", byMonth);
  2247. }
  2248. return AjaxResult.success(resMap);
  2249. }
  2250. @Override
  2251. public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
  2252. //阶段包括:采购需求对接,专家意见反馈,采购文件编制审核,采购公告发布,标前质疑投诉,待开标,评标结果公告,流废标处置,标后质疑
  2253. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2254. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2255. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2256. } else {
  2257. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2258. }
  2259. List<StatisticalChartsResVo> everyStatusNum = new ArrayList<>();
  2260. //项目进行到各个阶段的数量
  2261. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode()));
  2262. StatisticalChartsResVo everyStatusNum9 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2263. everyStatusNum9.setColumnName(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getInfo());
  2264. everyStatusNum.add(everyStatusNum9);
  2265. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.EXPERT_FEEDBACK.getCode()));
  2266. StatisticalChartsResVo everyStatusNum10 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2267. everyStatusNum10.setColumnName(PmProjectStatus.EXPERT_FEEDBACK.getInfo());
  2268. everyStatusNum.add(everyStatusNum10);
  2269. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode()));
  2270. StatisticalChartsResVo everyStatusNum11 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2271. everyStatusNum11.setColumnName(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getInfo());
  2272. everyStatusNum.add(everyStatusNum11);
  2273. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode()));
  2274. StatisticalChartsResVo everyStatusNum12 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2275. everyStatusNum12.setColumnName(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getInfo());
  2276. everyStatusNum.add(everyStatusNum12);
  2277. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.PRE_BID_QUERY.getCode()));
  2278. StatisticalChartsResVo everyStatusNum13 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2279. everyStatusNum13.setColumnName(PmProjectStatus.PRE_BID_QUERY.getInfo());
  2280. everyStatusNum.add(everyStatusNum13);
  2281. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.WAIT_OPEN_BID.getCode()));
  2282. StatisticalChartsResVo everyStatusNum14 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2283. everyStatusNum14.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
  2284. everyStatusNum.add(everyStatusNum14);
  2285. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode()));
  2286. StatisticalChartsResVo everyStatusNum15 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2287. everyStatusNum15.setColumnName(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getInfo());
  2288. everyStatusNum.add(everyStatusNum15);
  2289. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.WASTE_BID_HANDLE.getCode()));
  2290. StatisticalChartsResVo everyStatusNum16 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2291. everyStatusNum16.setColumnName(PmProjectStatus.WASTE_BID_HANDLE.getInfo());
  2292. everyStatusNum.add(everyStatusNum16);
  2293. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.POST_BID_QUERY.getCode()));
  2294. StatisticalChartsResVo everyStatusNum17 = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  2295. everyStatusNum17.setColumnName(PmProjectStatus.POST_BID_QUERY.getInfo());
  2296. everyStatusNum.add(everyStatusNum17);
  2297. return AjaxResult.success(everyStatusNum);
  2298. }
  2299. @Override
  2300. public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
  2301. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2302. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2303. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2304. } else {
  2305. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2306. }
  2307. //所有滞后
  2308. List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll(pmDemandReqVo);
  2309. Date now = new Date();
  2310. //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
  2311. HashMap<String, Integer> map = new LinkedHashMap<>();
  2312. map.put("滞后1个月以内的采购任务", 0);
  2313. map.put("滞后1至3个月采购任务", 0);
  2314. map.put("滞后3至6个月采购任务", 0);
  2315. map.put("滞后6个月至1年采购任务", 0);
  2316. map.put("滞后1年以上采购任务", 0);
  2317. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  2318. for (PmDemand demand : demandList) {
  2319. //滞后时间
  2320. Long exTime = 0L;
  2321. if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
  2322. exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
  2323. } else {
  2324. exTime = now.getTime() - demand.getPlanPurchaseFinishTime().getTime();
  2325. }
  2326. if (exTime < Long.valueOf("2592000000")) {
  2327. map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
  2328. }
  2329. if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
  2330. map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
  2331. }
  2332. if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
  2333. map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
  2334. }
  2335. if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
  2336. map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
  2337. }
  2338. if (exTime > Long.valueOf("31104000000")) {
  2339. map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
  2340. }
  2341. }
  2342. }
  2343. return AjaxResult.success(map);
  2344. }
  2345. @Override
  2346. public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
  2347. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2348. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2349. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2350. } else {
  2351. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2352. }
  2353. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2354. //本月度新提报重大规划采购任务数量
  2355. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2356. StatisticalChartsResVo resVo = pmDemandMapper.majorProjectByStatusThisMonthSub(pmDemandReqVo);
  2357. resVo.setColumnName("本月度新提报");
  2358. resVo.setColumnNamePlus("重大规划采购任务数量");
  2359. resVos.add(resVo);
  2360. //本季度新提报重大规划采购任务数量
  2361. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2362. StatisticalChartsResVo resVo2 = pmDemandMapper.majorProjectByStatusThisQuaSub(pmDemandReqVo);
  2363. resVo2.setColumnName("本季度新提报");
  2364. resVo2.setColumnNamePlus("重大规划采购任务数量");
  2365. resVos.add(resVo2);
  2366. //本年度新提报重大规划采购任务数量
  2367. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2368. StatisticalChartsResVo resVo3 = pmDemandMapper.majorProjectByStatusThisYearSub(pmDemandReqVo);
  2369. resVo3.setColumnName("本年度新提报");
  2370. resVo3.setColumnNamePlus("重大规划采购任务数量");
  2371. resVos.add(resVo3);
  2372. //本月度完成重大规划采购任务数量
  2373. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2374. StatisticalChartsResVo resVo4 = pmDemandMapper.majorProjectByStatusThisMonthFi(pmDemandReqVo);
  2375. resVo4.setColumnName("本月度完成");
  2376. resVo4.setColumnNamePlus("重大规划采购任务数量");
  2377. resVos.add(resVo4);
  2378. //本季度完成重大规划采购任务数量
  2379. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2380. StatisticalChartsResVo resVo5 = pmDemandMapper.majorProjectByStatusThisQuaFi(pmDemandReqVo);
  2381. resVo5.setColumnName("本季度完成");
  2382. resVo5.setColumnNamePlus("重大规划采购任务数量");
  2383. resVos.add(resVo5);
  2384. //本年度完成重大规划采购任务数量
  2385. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2386. StatisticalChartsResVo resVo6 = pmDemandMapper.majorProjectByStatusThisYearFi(pmDemandReqVo);
  2387. resVo6.setColumnName("本年度完成");
  2388. resVo6.setColumnNamePlus("重大规划采购任务数量");
  2389. resVos.add(resVo6);
  2390. //上年度结转和本年度新提报重大规划采购任务累计项目数量
  2391. List<String> yearLastZ = new ArrayList<>();
  2392. yearLastZ.add(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  2393. yearLastZ.add(PmProjectStatus.DEMAND_AUDIT_RETURN.getCode());
  2394. yearLastZ.add(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  2395. yearLastZ.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  2396. yearLastZ.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  2397. yearLastZ.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  2398. yearLastZ.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  2399. yearLastZ.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  2400. yearLastZ.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  2401. yearLastZ.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  2402. yearLastZ.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  2403. yearLastZ.add(PmProjectStatus.POST_BID_QUERY.getCode());
  2404. yearLastZ.add(PmProjectStatus.WASTE_BID_RETURN.getCode());
  2405. pmDemandReqVo.setProjectStatusList(yearLastZ);
  2406. StatisticalChartsResVo resVo7 = pmDemandMapper.majorProjectByStatusLastYear(pmDemandReqVo);
  2407. if (ObjectUtils.isEmpty(resVo7)) {
  2408. resVo7 = new StatisticalChartsResVo();
  2409. resVo7.setNum(0);
  2410. resVo7.setEvaluationTotal(BigDecimal.ZERO);
  2411. resVo7.setEvaluationContractTotal(BigDecimal.ZERO);
  2412. }
  2413. resVo7.setNum(resVo7.getNum() + resVo3.getNum());
  2414. resVo7.setEvaluationTotal(resVo7.getEvaluationTotal().add(resVo3.getEvaluationTotal()));
  2415. resVo7.setColumnName("上年度结转和本年度新提报");
  2416. resVo7.setColumnNamePlus("重大规划采购任务累计数量");
  2417. resVos.add(resVo7);
  2418. //今年以来累计完成数量
  2419. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2420. StatisticalChartsResVo resVo8 = pmDemandMapper.majorProjectByStatusToThisYear(pmDemandReqVo);
  2421. resVo8.setColumnName("今年以来累计");
  2422. resVo8.setColumnNamePlus("累计完成数量");
  2423. resVos.add(resVo8);
  2424. //正常推进周期内的重大规划采购任务数量
  2425. StatisticalChartsResVo resVo9 = pmDemandMapper.majorProjectByStatusWei(pmDemandReqVo);
  2426. resVo9.setColumnName("正常推进周期内");
  2427. resVo9.setColumnNamePlus("重大规划采购任务数量");
  2428. resVos.add(resVo9);
  2429. //执行滞后的重大规划采购任务数量
  2430. StatisticalChartsResVo resVo10 = pmDemandMapper.majorProjectByStatusChao(pmDemandReqVo);
  2431. resVo10.setColumnName("执行滞后");
  2432. resVo10.setColumnNamePlus("重大规划采购任务数量");
  2433. resVos.add(resVo10);
  2434. return AjaxResult.success(resVos);
  2435. }
  2436. @Override
  2437. public AjaxResult countMajorProjectCGB(PmDemandReqVo pmDemandReqVo) {
  2438. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2439. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2440. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2441. } else {
  2442. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2443. }
  2444. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2445. //本月度新受领重大规划采购任务数量
  2446. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2447. StatisticalChartsResVo resVo = pmDemandMapper.majorProjectByStatusThisMonthNew(pmDemandReqVo);
  2448. resVo.setColumnName("本月度新受领");
  2449. resVo.setColumnNamePlus("重大规划采购任务数量");
  2450. resVos.add(resVo);
  2451. //本季度新受领重大规划采购任务数量
  2452. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2453. StatisticalChartsResVo resVo2 = pmDemandMapper.majorProjectByStatusThisQuaNew(pmDemandReqVo);
  2454. resVo2.setColumnName("本季度新受领");
  2455. resVo2.setColumnNamePlus("重大规划采购任务数量");
  2456. resVos.add(resVo2);
  2457. //本年度新受领重大规划采购任务数量
  2458. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.TASK_WAIT_RELEASE.getCode()));
  2459. StatisticalChartsResVo resVo3 = pmDemandMapper.majorProjectByStatusThisYearNew(pmDemandReqVo);
  2460. resVo3.setColumnName("本年度新受领");
  2461. resVo3.setColumnNamePlus("重大规划采购任务数量");
  2462. resVos.add(resVo3);
  2463. //上年度结转重大规划采购任务累计项目数量
  2464. List<String> yearLastZ = new ArrayList<>();
  2465. yearLastZ.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  2466. yearLastZ.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  2467. yearLastZ.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  2468. yearLastZ.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  2469. yearLastZ.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  2470. yearLastZ.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  2471. yearLastZ.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  2472. yearLastZ.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  2473. yearLastZ.add(PmProjectStatus.POST_BID_QUERY.getCode());
  2474. yearLastZ.add(PmProjectStatus.WASTE_BID_RETURN.getCode());
  2475. pmDemandReqVo.setProjectStatusList(yearLastZ);
  2476. StatisticalChartsResVo resVo7 = pmDemandMapper.majorProjectByStatusLastYear(pmDemandReqVo);
  2477. if (ObjectUtils.isEmpty(resVo7)) {
  2478. resVo7 = new StatisticalChartsResVo();
  2479. resVo7.setNum(0);
  2480. resVo7.setEvaluationTotal(BigDecimal.ZERO);
  2481. resVo7.setEvaluationContractTotal(BigDecimal.ZERO);
  2482. }
  2483. resVo7.setColumnName("上年度结转和本年度新提报");
  2484. resVo7.setColumnNamePlus("累计项目数量");
  2485. //上年度结转和本月度新受领重大规划采购任务累计项目数量预算金额
  2486. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2487. StatisticalChartsResVo resVo4 = pmDemandMapper.majorProjectByStatusThisMonthFiCGB(pmDemandReqVo);
  2488. if (ObjectUtils.isEmpty(resVo4)) {
  2489. resVo4 = new StatisticalChartsResVo();
  2490. resVo4.setNum(0);
  2491. resVo4.setEvaluationTotal(BigDecimal.ZERO);
  2492. resVo4.setEvaluationContractTotal(BigDecimal.ZERO);
  2493. }
  2494. resVo4.setNum(resVo4.getNum() + resVo7.getNum());
  2495. resVo4.setEvaluationTotal(resVo4.getEvaluationTotal().add(resVo7.getEvaluationTotal()));
  2496. resVo4.setColumnName("上年度结转和本月度新受领");
  2497. resVo4.setColumnNamePlus("累计项目数量");
  2498. resVos.add(resVo4);
  2499. //上年度结转和本季度新受领重大规划采购任务累计项目数量预算金额
  2500. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2501. StatisticalChartsResVo resVo5 = pmDemandMapper.majorProjectByStatusThisQuaFiCGB(pmDemandReqVo);
  2502. if (ObjectUtils.isEmpty(resVo5)) {
  2503. resVo5 = new StatisticalChartsResVo();
  2504. resVo5.setNum(0);
  2505. resVo5.setEvaluationTotal(BigDecimal.ZERO);
  2506. resVo5.setEvaluationContractTotal(BigDecimal.ZERO);
  2507. }
  2508. resVo5.setNum(resVo5.getNum() + resVo7.getNum());
  2509. resVo5.setEvaluationTotal(resVo5.getEvaluationTotal().add(resVo7.getEvaluationTotal()));
  2510. resVo5.setColumnName("上年度结转和本季度新受领");
  2511. resVo5.setColumnNamePlus("累计项目数量");
  2512. resVos.add(resVo5);
  2513. //上年度结转和本年度新受领重大规划采购任务累计项目数量预算金额
  2514. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode()));
  2515. StatisticalChartsResVo resVo6 = pmDemandMapper.majorProjectByStatusThisYearFiCGB(pmDemandReqVo);
  2516. if (ObjectUtils.isEmpty(resVo6)) {
  2517. resVo6 = new StatisticalChartsResVo();
  2518. resVo6.setNum(0);
  2519. resVo6.setEvaluationTotal(BigDecimal.ZERO);
  2520. resVo6.setEvaluationContractTotal(BigDecimal.ZERO);
  2521. }
  2522. resVo6.setNum(resVo6.getNum() + resVo7.getNum());
  2523. resVo6.setEvaluationTotal(resVo6.getEvaluationTotal().add(resVo7.getEvaluationTotal()));
  2524. resVo6.setColumnName("上年度结转和本年度新受领");
  2525. resVo6.setColumnNamePlus("累计项目数量");
  2526. resVos.add(resVo6);
  2527. //本月度完成重大规划采购任务数量
  2528. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2529. StatisticalChartsResVo resVoA = pmDemandMapper.majorProjectByStatusThisMonthFi(pmDemandReqVo);
  2530. resVoA.setColumnName("本月度完成");
  2531. resVoA.setColumnNamePlus("重大规划采购任务数量");
  2532. resVos.add(resVoA);
  2533. //本季度完成重大规划采购任务数量
  2534. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2535. StatisticalChartsResVo resVoB = pmDemandMapper.majorProjectByStatusThisQuaFi(pmDemandReqVo);
  2536. resVoB.setColumnName("本季度完成");
  2537. resVoB.setColumnNamePlus("重大规划采购任务数量");
  2538. resVos.add(resVoB);
  2539. //本年度完成重大规划采购任务数量
  2540. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2541. StatisticalChartsResVo resVoC = pmDemandMapper.majorProjectByStatusThisYearFi(pmDemandReqVo);
  2542. resVoC.setColumnName("本年度完成");
  2543. resVoC.setColumnNamePlus("重大规划采购任务数量");
  2544. resVos.add(resVoC);
  2545. //今年以来累计完成数量
  2546. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.CONTRACT_WAIT_FILL.getCode()));
  2547. StatisticalChartsResVo resVo8 = pmDemandMapper.majorProjectByStatusToThisYear(pmDemandReqVo);
  2548. resVo8.setColumnName("今年以来累计");
  2549. resVo8.setColumnNamePlus("累计完成数量");
  2550. resVos.add(resVo8);
  2551. //正常推进周期内的重大规划采购任务数量
  2552. StatisticalChartsResVo resVo9 = pmDemandMapper.majorProjectByStatusWei(pmDemandReqVo);
  2553. resVo9.setColumnName("正常推进周期内");
  2554. resVo9.setColumnNamePlus("重大规划采购任务数量");
  2555. resVos.add(resVo9);
  2556. //执行滞后的重大规划采购任务数量
  2557. StatisticalChartsResVo resVo10 = pmDemandMapper.majorProjectByStatusChao(pmDemandReqVo);
  2558. resVo10.setColumnName("执行滞后");
  2559. resVo10.setColumnNamePlus("重大规划采购任务数量");
  2560. resVos.add(resVo10);
  2561. return AjaxResult.success(resVos);
  2562. }
  2563. /**
  2564. * 通过计划ID查询项目数据
  2565. *
  2566. * @param planId
  2567. * @return
  2568. */
  2569. @Override
  2570. public PmDemand selectByPlanId(Long planId) {
  2571. return pmDemandMapper.selectByPlanId(planId);
  2572. }
  2573. /**
  2574. * 项目执行进度统计
  2575. * 1、正常推进项目数量:指未完成并且没有逾期的项目
  2576. * 预算金额:指未完成并且没有逾期的项目累加的预算金额
  2577. * 2、未完成采购任务:“合同待填制”状态之前的项目
  2578. * 预算金额:“合同待填制”状态之前的项目累加的预算金额
  2579. *
  2580. * @param pmDemandReqVo
  2581. * @return
  2582. */
  2583. @Override
  2584. public List<StatisticalChartsResVo> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
  2585. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  2586. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2587. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2588. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2589. } else {
  2590. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2591. }
  2592. //今年以来累计完成采购任务数量 预算金额(万元) 合同金额(万元)
  2593. StatisticalChartsResVo tThisYear = pmDemandMapper.selectFInishAll(pmDemandReqVo);
  2594. tThisYear.setColumnName("累计完成采购任务数量");
  2595. resVos.add(tThisYear);
  2596. // 正常推进项目数量、预算金额
  2597. StatisticalChartsResVo mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
  2598. mapNormalPropulsion.setColumnName("正常推进项目数量");
  2599. resVos.add(mapNormalPropulsion);
  2600. // 未完成采购任务,预算金额
  2601. StatisticalChartsResVo mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
  2602. mapIncomplete.setColumnName("未完成采购任务");
  2603. resVos.add(mapIncomplete);
  2604. return resVos;
  2605. }
  2606. /**
  2607. * 已完成项目数量统计
  2608. *
  2609. * @param pmDemandReqVo
  2610. * @return
  2611. */
  2612. @Override
  2613. public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
  2614. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2615. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2616. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  2617. // 统计时间类型 1:年度,2:季度,3:月份
  2618. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2619. // 查询数据库中最小的年份
  2620. int minYear = pmDemandMapper.selectMinYear();
  2621. // 获取当前年份
  2622. Calendar calendar = Calendar.getInstance();
  2623. int year = calendar.get(Calendar.YEAR);
  2624. // 获取统计数据
  2625. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
  2626. mapReturn.addAll(listMap);
  2627. for (int i = minYear; i <= year; i++) {
  2628. boolean isYear = false;
  2629. for (Map<String, Integer> map : listMap) {
  2630. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2631. isYear = true;
  2632. }
  2633. }
  2634. if (!isYear) {
  2635. Map<String, Integer> map1 = new HashMap<>();
  2636. map1.put("yy", i);
  2637. map1.put("evaluation", 0);
  2638. map1.put("contractAmount", 0);
  2639. map1.put("countNum", 0);
  2640. mapReturn.add(map1);
  2641. }
  2642. }
  2643. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2644. // 当前年份季度统计
  2645. // 获取统计数据
  2646. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
  2647. mapReturn.addAll(listMap);
  2648. for (int i = 1; i <= 4; i++) {
  2649. boolean isYear = false;
  2650. for (Map<String, Integer> map : listMap) {
  2651. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2652. isYear = true;
  2653. }
  2654. }
  2655. if (!isYear) {
  2656. Map<String, Integer> map1 = new HashMap<>();
  2657. map1.put("yy", i);
  2658. map1.put("evaluation", 0);
  2659. map1.put("contractAmount", 0);
  2660. map1.put("countNum", 0);
  2661. mapReturn.add(map1);
  2662. }
  2663. }
  2664. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2665. // 当前年份月份统计
  2666. // 获取统计数据
  2667. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
  2668. mapReturn.addAll(listMap);
  2669. for (int i = 1; i <= 12; i++) {
  2670. boolean isYear = false;
  2671. for (Map<String, Integer> map : listMap) {
  2672. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2673. isYear = true;
  2674. }
  2675. }
  2676. if (!isYear) {
  2677. Map<String, Integer> map1 = new HashMap<>();
  2678. map1.put("yy", i);
  2679. map1.put("evaluation", 0);
  2680. map1.put("contractAmount", 0);
  2681. map1.put("countNum", 0);
  2682. mapReturn.add(map1);
  2683. }
  2684. }
  2685. }
  2686. return mapReturn;
  2687. }
  2688. /**
  2689. * 已完成采购任务数量统计
  2690. *
  2691. * @param pmDemandReqVo
  2692. * @return
  2693. */
  2694. @Override
  2695. public List<Map<String, Integer>> purchaseTaskFinish(PmDemandReqVo pmDemandReqVo) {
  2696. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2697. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2698. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2699. } else {
  2700. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2701. }
  2702. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  2703. // 统计时间类型 1:年度,2:季度,3:月份
  2704. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2705. // 查询数据库中最小的年份
  2706. int minYear = pmDemandMapper.selectMinYear();
  2707. // 获取当前年份
  2708. Calendar calendar = Calendar.getInstance();
  2709. int year = calendar.get(Calendar.YEAR);
  2710. // 获取统计数据
  2711. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishYear(pmDemandReqVo);
  2712. //mapReturn.addAll(listMap);
  2713. for (int i = minYear; i <= year; i++) {
  2714. boolean isYear = false;
  2715. for (Map<String, Integer> map : listMap) {
  2716. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2717. isYear = true;
  2718. map.put("yy", i);
  2719. mapReturn.add(map);
  2720. }
  2721. }
  2722. if (!isYear) {
  2723. Map<String, Integer> map1 = new HashMap<>();
  2724. map1.put("yy", i);
  2725. map1.put("evaluation", 0);
  2726. map1.put("contractAmount", 0);
  2727. map1.put("countNum", 0);
  2728. mapReturn.add(map1);
  2729. }
  2730. }
  2731. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2732. // 当前年份季度统计
  2733. // 获取统计数据
  2734. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishQuarter(pmDemandReqVo);
  2735. //mapReturn.addAll(listMap);
  2736. for (int i = 1; i <= 4; i++) {
  2737. boolean isYear = false;
  2738. for (Map<String, Integer> map : listMap) {
  2739. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2740. isYear = true;
  2741. map.put("yy", i);
  2742. mapReturn.add(map);
  2743. }
  2744. }
  2745. if (!isYear) {
  2746. Map<String, Integer> map1 = new HashMap<>();
  2747. map1.put("yy", i);
  2748. map1.put("evaluation", 0);
  2749. map1.put("contractAmount", 0);
  2750. map1.put("countNum", 0);
  2751. mapReturn.add(map1);
  2752. }
  2753. }
  2754. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2755. // 当前年份月份统计
  2756. // 获取统计数据
  2757. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishMonth(pmDemandReqVo);
  2758. //mapReturn.addAll(listMap);
  2759. for (int i = 1; i <= 12; i++) {
  2760. boolean isYear = false;
  2761. for (Map<String, Integer> map : listMap) {
  2762. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2763. isYear = true;
  2764. map.put("yy", i);
  2765. map.put("countNum", 0);
  2766. mapReturn.add(map);
  2767. }
  2768. }
  2769. if (!isYear) {
  2770. Map<String, Integer> map1 = new HashMap<>();
  2771. map1.put("yy", i);
  2772. map1.put("evaluation", 0);
  2773. map1.put("contractAmount", 0);
  2774. map1.put("countNum", 0);
  2775. mapReturn.add(map1);
  2776. }
  2777. }
  2778. }
  2779. return mapReturn;
  2780. }
  2781. /**
  2782. * 项目数量分析---------年度的同比和环比不展示-----------
  2783. *
  2784. * @param pmDemandReqVo
  2785. * @return
  2786. */
  2787. @Override
  2788. public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
  2789. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  2790. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  2791. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  2792. } else {
  2793. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  2794. }
  2795. List<Map<String, String>> mapReturn = new ArrayList<>();
  2796. // 统计时间类型 1:年度,2:季度,3:月份
  2797. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2798. // 查询数据库中最小的年份
  2799. int minYear = pmDemandMapper.selectMinYear();
  2800. // 获取当前年份
  2801. Calendar calendar = Calendar.getInstance();
  2802. int year = calendar.get(Calendar.YEAR);
  2803. // 获取统计数据
  2804. // 获取项目统计
  2805. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
  2806. mapReturn.addAll(listMap);
  2807. for (int i = minYear; i <= year; i++) {
  2808. boolean isYear = false;
  2809. for (Map<String, String> map : listMap) {
  2810. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2811. isYear = true;
  2812. }
  2813. }
  2814. if (!isYear) {
  2815. Map<String, String> map1 = new HashMap<>();
  2816. map1.put("yy", i + "");
  2817. map1.put("countNum", 0 + "");
  2818. map1.put("evaluationSum", 0 + "");
  2819. mapReturn.add(map1);
  2820. }
  2821. }
  2822. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2823. // 当前年份季度统计
  2824. // 获取统计数据
  2825. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
  2826. List<Map<String, String>> mapList = new ArrayList<>();
  2827. mapList.addAll(listMap);
  2828. for (int i = 1; i <= 4; i++) {
  2829. boolean isYear = false;
  2830. for (Map<String, String> map : listMap) {
  2831. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2832. isYear = true;
  2833. }
  2834. }
  2835. if (!isYear) {
  2836. Map<String, String> map1 = new HashMap<>();
  2837. map1.put("yy", i + "");
  2838. map1.put("countNum", 0 + "");
  2839. map1.put("evaluationSum", 0 + "");
  2840. mapList.add(map1);
  2841. }
  2842. }
  2843. Map<String, String> map1 = new HashMap<>();
  2844. Map<String, String> map2 = new HashMap<>();
  2845. Map<String, String> map3 = new HashMap<>();
  2846. Map<String, String> map4 = new HashMap<>();
  2847. for (Map<String, String> map : mapList) {
  2848. String yy = String.valueOf(map.get("yy"));
  2849. if ("1".equals(yy)) {
  2850. map1.putAll(map);
  2851. } else if ("2".equals(yy)) {
  2852. map2.putAll(map);
  2853. } else if ("3".equals(yy)) {
  2854. map3.putAll(map);
  2855. } else if ("4".equals(yy)) {
  2856. map4.putAll(map);
  2857. }
  2858. }
  2859. String countNum1 = String.valueOf(map1.get("countNum"));
  2860. String countNum2 = String.valueOf(map2.get("countNum"));
  2861. String countNum3 = String.valueOf(map3.get("countNum"));
  2862. String countNum4 = String.valueOf(map4.get("countNum"));
  2863. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  2864. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  2865. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  2866. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  2867. // 查询上一年四季度数据
  2868. List<Map<String, String>> listMapOldYear = pmDemandMapper.purchaseProjectNumberAnalysisOldYearQuarter(pmDemandReqVo);
  2869. List<Map<String, String>> mapListOld = new ArrayList<>();
  2870. mapListOld.addAll(listMapOldYear);
  2871. for (int i = 1; i <= 4; i++) {
  2872. boolean isYear = false;
  2873. for (Map<String, String> map : listMapOldYear) {
  2874. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2875. isYear = true;
  2876. }
  2877. }
  2878. if (!isYear) {
  2879. Map<String, String> map11 = new HashMap<>();
  2880. map11.put("yy", i + "");
  2881. map11.put("countNum", 0 + "");
  2882. map11.put("evaluationSum", 0 + "");
  2883. mapListOld.add(map11);
  2884. }
  2885. }
  2886. Map<String, String> mapOld1 = new HashMap<>();
  2887. Map<String, String> mapOld2 = new HashMap<>();
  2888. Map<String, String> mapOld3 = new HashMap<>();
  2889. Map<String, String> mapOld4 = new HashMap<>();
  2890. for (Map<String, String> mapOld : mapListOld) {
  2891. String yy = String.valueOf(mapOld.get("yy"));
  2892. if ("1".equals(yy)) {
  2893. mapOld1.putAll(mapOld);
  2894. } else if ("2".equals(yy)) {
  2895. mapOld2.putAll(mapOld);
  2896. } else if ("3".equals(yy)) {
  2897. mapOld3.putAll(mapOld);
  2898. } else if ("4".equals(yy)) {
  2899. mapOld4.putAll(mapOld);
  2900. }
  2901. }
  2902. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  2903. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  2904. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  2905. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  2906. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  2907. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  2908. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  2909. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  2910. BigDecimal countNum11 = new BigDecimal(countNum1);
  2911. BigDecimal countNum22 = new BigDecimal(countNum2);
  2912. BigDecimal countNum33 = new BigDecimal(countNum3);
  2913. BigDecimal countNum44 = new BigDecimal(countNum4);
  2914. BigDecimal countNumOld11 = new BigDecimal(countNumOld1);
  2915. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  2916. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  2917. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  2918. BigDecimal evaluationSum11 = new BigDecimal(evaluationSum1);
  2919. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  2920. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  2921. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  2922. BigDecimal evaluationSumOld11 = new BigDecimal(evaluationSumOld1);
  2923. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  2924. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  2925. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  2926. // 项目数量环比 对比
  2927. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  2928. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  2929. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  2930. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  2931. if (!"0".equals(countNumOld4)) {
  2932. monthonmonthNum1 = (countNum11.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2933. }
  2934. if (!"0".equals(countNum1)) {
  2935. monthonmonthNum2 = (countNum22.subtract(countNum11)).divide(countNum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2936. }
  2937. if (!"0".equals(countNum2)) {
  2938. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2939. }
  2940. if (!"0".equals(countNum3)) {
  2941. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2942. }
  2943. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  2944. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  2945. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  2946. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  2947. // 项目数量同比 对比
  2948. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  2949. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  2950. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  2951. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  2952. if (!"0".equals(countNumOld1)) {
  2953. yearonyearNum1 = (countNum11.subtract(countNumOld11)).divide(countNumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2954. }
  2955. if (!"0".equals(countNumOld2)) {
  2956. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2957. }
  2958. if (!"0".equals(countNumOld3)) {
  2959. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2960. }
  2961. if (!"0".equals(countNumOld4)) {
  2962. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2963. }
  2964. map1.put("yearonyearNum", yearonyearNum1.toString());
  2965. map2.put("yearonyearNum", yearonyearNum2.toString());
  2966. map3.put("yearonyearNum", yearonyearNum3.toString());
  2967. map4.put("yearonyearNum", yearonyearNum4.toString());
  2968. // 预算金额环比 对比
  2969. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  2970. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  2971. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  2972. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  2973. if (!"0".equals(evaluationSumOld4)) {
  2974. monthonmonthAmount1 = (evaluationSum11.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2975. }
  2976. if (!"0".equals(evaluationSum1)) {
  2977. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum11)).divide(evaluationSum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2978. }
  2979. if (!"0".equals(evaluationSum2)) {
  2980. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2981. }
  2982. if (!"0".equals(evaluationSum3)) {
  2983. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2984. }
  2985. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  2986. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  2987. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  2988. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  2989. // 预算金额同比比 对比
  2990. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  2991. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  2992. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  2993. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  2994. if (!"0".equals(evaluationSumOld1)) {
  2995. yearonyearAmount1 = (evaluationSum11.subtract(evaluationSumOld11)).divide(evaluationSumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2996. }
  2997. if (!"0".equals(evaluationSumOld2)) {
  2998. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2999. }
  3000. if (!"0".equals(evaluationSumOld3)) {
  3001. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3002. }
  3003. if (!"0".equals(evaluationSumOld4)) {
  3004. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3005. }
  3006. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  3007. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  3008. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  3009. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  3010. // 存入集合
  3011. mapReturn.add(map1);
  3012. mapReturn.add(map2);
  3013. mapReturn.add(map3);
  3014. mapReturn.add(map4);
  3015. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  3016. // 当前年份月份统计
  3017. // 获取统计数据
  3018. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
  3019. List<Map<String, String>> mapList = new ArrayList<>();
  3020. mapList.addAll(listMap);
  3021. for (int i = 1; i <= 12; i++) {
  3022. boolean isYear = false;
  3023. for (Map<String, String> map : listMap) {
  3024. String yy = String.valueOf(map.get("yy"));
  3025. String yyNew = yy.replaceAll("^0*", "");
  3026. if (i == Integer.valueOf(yyNew)) {
  3027. isYear = true;
  3028. }
  3029. }
  3030. if (!isYear) {
  3031. Map<String, String> map1 = new HashMap<>();
  3032. String yy = String.format("%02d", i);
  3033. map1.put("yy", yy);
  3034. map1.put("countNum", 0 + "");
  3035. map1.put("evaluationSum", 0 + "");
  3036. mapList.add(map1);
  3037. }
  3038. }
  3039. Map<String, String> map1 = new HashMap<>();
  3040. Map<String, String> map2 = new HashMap<>();
  3041. Map<String, String> map3 = new HashMap<>();
  3042. Map<String, String> map4 = new HashMap<>();
  3043. Map<String, String> map5 = new HashMap<>();
  3044. Map<String, String> map6 = new HashMap<>();
  3045. Map<String, String> map7 = new HashMap<>();
  3046. Map<String, String> map8 = new HashMap<>();
  3047. Map<String, String> map9 = new HashMap<>();
  3048. Map<String, String> map10 = new HashMap<>();
  3049. Map<String, String> map11 = new HashMap<>();
  3050. Map<String, String> map12 = new HashMap<>();
  3051. for (Map<String, String> map : mapList) {
  3052. String yy = String.valueOf(map.get("yy"));
  3053. if ("01".equals(yy)) {
  3054. map1.putAll(map);
  3055. } else if ("02".equals(yy)) {
  3056. map2.putAll(map);
  3057. } else if ("03".equals(yy)) {
  3058. map3.putAll(map);
  3059. } else if ("04".equals(yy)) {
  3060. map4.putAll(map);
  3061. } else if ("05".equals(yy)) {
  3062. map5.putAll(map);
  3063. } else if ("06".equals(yy)) {
  3064. map6.putAll(map);
  3065. } else if ("07".equals(yy)) {
  3066. map7.putAll(map);
  3067. } else if ("08".equals(yy)) {
  3068. map8.putAll(map);
  3069. } else if ("09".equals(yy)) {
  3070. map9.putAll(map);
  3071. } else if ("10".equals(yy)) {
  3072. map10.putAll(map);
  3073. } else if ("11".equals(yy)) {
  3074. map11.putAll(map);
  3075. } else if ("12".equals(yy)) {
  3076. map12.putAll(map);
  3077. }
  3078. }
  3079. String countNum1 = String.valueOf(map1.get("countNum"));
  3080. String countNum2 = String.valueOf(map2.get("countNum"));
  3081. String countNum3 = String.valueOf(map3.get("countNum"));
  3082. String countNum4 = String.valueOf(map4.get("countNum"));
  3083. String countNum5 = String.valueOf(map5.get("countNum"));
  3084. String countNum6 = String.valueOf(map6.get("countNum"));
  3085. String countNum7 = String.valueOf(map7.get("countNum"));
  3086. String countNum8 = String.valueOf(map8.get("countNum"));
  3087. String countNum9 = String.valueOf(map9.get("countNum"));
  3088. String countNum10 = String.valueOf(map10.get("countNum"));
  3089. String countNum11 = String.valueOf(map11.get("countNum"));
  3090. String countNum12 = String.valueOf(map12.get("countNum"));
  3091. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  3092. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  3093. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  3094. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  3095. String evaluationSum5 = String.valueOf(map5.get("evaluationSum"));
  3096. String evaluationSum6 = String.valueOf(map6.get("evaluationSum"));
  3097. String evaluationSum7 = String.valueOf(map7.get("evaluationSum"));
  3098. String evaluationSum8 = String.valueOf(map8.get("evaluationSum"));
  3099. String evaluationSum9 = String.valueOf(map9.get("evaluationSum"));
  3100. String evaluationSum10 = String.valueOf(map10.get("evaluationSum"));
  3101. String evaluationSum11 = String.valueOf(map11.get("evaluationSum"));
  3102. String evaluationSum12 = String.valueOf(map12.get("evaluationSum"));
  3103. // 查询上一年月份数据
  3104. List<Map<String, String>> listMapOldMonth = pmDemandMapper.purchaseProjectNumberAnalysisOldYearMonth(pmDemandReqVo);
  3105. List<Map<String, String>> mapListOld = new ArrayList<>();
  3106. mapListOld.addAll(listMapOldMonth);
  3107. for (int i = 1; i <= 12; i++) {
  3108. boolean isYear = false;
  3109. for (Map<String, String> map : listMapOldMonth) {
  3110. String yy = String.valueOf(map.get("yy"));
  3111. String yyNew = yy.replaceAll("^0*", "");
  3112. if (i == Integer.valueOf(yyNew)) {
  3113. isYear = true;
  3114. }
  3115. }
  3116. if (!isYear) {
  3117. Map<String, String> map111 = new HashMap<>();
  3118. String yy = String.format("%02d", i);
  3119. map111.put("yy", yy);
  3120. map111.put("countNum", 0 + "");
  3121. map111.put("evaluationSum", 0 + "");
  3122. mapListOld.add(map111);
  3123. }
  3124. }
  3125. Map<String, String> mapOld1 = new HashMap<>();
  3126. Map<String, String> mapOld2 = new HashMap<>();
  3127. Map<String, String> mapOld3 = new HashMap<>();
  3128. Map<String, String> mapOld4 = new HashMap<>();
  3129. Map<String, String> mapOld5 = new HashMap<>();
  3130. Map<String, String> mapOld6 = new HashMap<>();
  3131. Map<String, String> mapOld7 = new HashMap<>();
  3132. Map<String, String> mapOld8 = new HashMap<>();
  3133. Map<String, String> mapOld9 = new HashMap<>();
  3134. Map<String, String> mapOld10 = new HashMap<>();
  3135. Map<String, String> mapOld11 = new HashMap<>();
  3136. Map<String, String> mapOld12 = new HashMap<>();
  3137. for (Map<String, String> mapOld : mapListOld) {
  3138. String yy = String.valueOf(mapOld.get("yy"));
  3139. if ("01".equals(yy)) {
  3140. mapOld1.putAll(mapOld);
  3141. } else if ("02".equals(yy)) {
  3142. mapOld2.putAll(mapOld);
  3143. } else if ("03".equals(yy)) {
  3144. mapOld3.putAll(mapOld);
  3145. } else if ("04".equals(yy)) {
  3146. mapOld4.putAll(mapOld);
  3147. } else if ("05".equals(yy)) {
  3148. mapOld5.putAll(mapOld);
  3149. } else if ("06".equals(yy)) {
  3150. mapOld6.putAll(mapOld);
  3151. } else if ("07".equals(yy)) {
  3152. mapOld7.putAll(mapOld);
  3153. } else if ("08".equals(yy)) {
  3154. mapOld8.putAll(mapOld);
  3155. } else if ("09".equals(yy)) {
  3156. mapOld9.putAll(mapOld);
  3157. } else if ("10".equals(yy)) {
  3158. mapOld10.putAll(mapOld);
  3159. } else if ("11".equals(yy)) {
  3160. mapOld11.putAll(mapOld);
  3161. } else if ("12".equals(yy)) {
  3162. mapOld12.putAll(mapOld);
  3163. }
  3164. }
  3165. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  3166. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  3167. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  3168. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  3169. String countNumOld5 = String.valueOf(mapOld5.get("countNum"));
  3170. String countNumOld6 = String.valueOf(mapOld6.get("countNum"));
  3171. String countNumOld7 = String.valueOf(mapOld7.get("countNum"));
  3172. String countNumOld8 = String.valueOf(mapOld8.get("countNum"));
  3173. String countNumOld9 = String.valueOf(mapOld9.get("countNum"));
  3174. String countNumOld10 = String.valueOf(mapOld10.get("countNum"));
  3175. String countNumOld11 = String.valueOf(mapOld11.get("countNum"));
  3176. String countNumOld12 = String.valueOf(mapOld12.get("countNum"));
  3177. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  3178. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  3179. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  3180. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  3181. String evaluationSumOld5 = String.valueOf(mapOld5.get("evaluationSum"));
  3182. String evaluationSumOld6 = String.valueOf(mapOld6.get("evaluationSum"));
  3183. String evaluationSumOld7 = String.valueOf(mapOld7.get("evaluationSum"));
  3184. String evaluationSumOld8 = String.valueOf(mapOld8.get("evaluationSum"));
  3185. String evaluationSumOld9 = String.valueOf(mapOld9.get("evaluationSum"));
  3186. String evaluationSumOld10 = String.valueOf(mapOld10.get("evaluationSum"));
  3187. String evaluationSumOld11 = String.valueOf(mapOld11.get("evaluationSum"));
  3188. String evaluationSumOld12 = String.valueOf(mapOld12.get("evaluationSum"));
  3189. BigDecimal countNum111 = new BigDecimal(countNum1);
  3190. BigDecimal countNum22 = new BigDecimal(countNum2);
  3191. BigDecimal countNum33 = new BigDecimal(countNum3);
  3192. BigDecimal countNum44 = new BigDecimal(countNum4);
  3193. BigDecimal countNum55 = new BigDecimal(countNum5);
  3194. BigDecimal countNum66 = new BigDecimal(countNum6);
  3195. BigDecimal countNum77 = new BigDecimal(countNum7);
  3196. BigDecimal countNum88 = new BigDecimal(countNum8);
  3197. BigDecimal countNum99 = new BigDecimal(countNum9);
  3198. BigDecimal countNum1010 = new BigDecimal(countNum10);
  3199. BigDecimal countNum1111 = new BigDecimal(countNum11);
  3200. BigDecimal countNum1212 = new BigDecimal(countNum12);
  3201. BigDecimal countNumOld111 = new BigDecimal(countNumOld1);
  3202. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  3203. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  3204. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  3205. BigDecimal countNumOld55 = new BigDecimal(countNumOld5);
  3206. BigDecimal countNumOld66 = new BigDecimal(countNumOld6);
  3207. BigDecimal countNumOld77 = new BigDecimal(countNumOld7);
  3208. BigDecimal countNumOld88 = new BigDecimal(countNumOld8);
  3209. BigDecimal countNumOld99 = new BigDecimal(countNumOld9);
  3210. BigDecimal countNumOld1010 = new BigDecimal(countNumOld10);
  3211. BigDecimal countNumOld1111 = new BigDecimal(countNumOld11);
  3212. BigDecimal countNumOld1212 = new BigDecimal(countNumOld12);
  3213. BigDecimal evaluationSum111 = new BigDecimal(evaluationSum1);
  3214. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  3215. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  3216. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  3217. BigDecimal evaluationSum55 = new BigDecimal(evaluationSum5);
  3218. BigDecimal evaluationSum66 = new BigDecimal(evaluationSum6);
  3219. BigDecimal evaluationSum77 = new BigDecimal(evaluationSum7);
  3220. BigDecimal evaluationSum88 = new BigDecimal(evaluationSum8);
  3221. BigDecimal evaluationSum99 = new BigDecimal(evaluationSum9);
  3222. BigDecimal evaluationSum1010 = new BigDecimal(evaluationSum10);
  3223. BigDecimal evaluationSum1111 = new BigDecimal(evaluationSum11);
  3224. BigDecimal evaluationSum1212 = new BigDecimal(evaluationSum12);
  3225. BigDecimal evaluationSumOld111 = new BigDecimal(evaluationSumOld1);
  3226. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  3227. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  3228. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  3229. BigDecimal evaluationSumOld55 = new BigDecimal(evaluationSumOld5);
  3230. BigDecimal evaluationSumOld66 = new BigDecimal(evaluationSumOld6);
  3231. BigDecimal evaluationSumOld77 = new BigDecimal(evaluationSumOld7);
  3232. BigDecimal evaluationSumOld88 = new BigDecimal(evaluationSumOld8);
  3233. BigDecimal evaluationSumOld99 = new BigDecimal(evaluationSumOld9);
  3234. BigDecimal evaluationSumOld1010 = new BigDecimal(evaluationSumOld10);
  3235. BigDecimal evaluationSumOld1111 = new BigDecimal(evaluationSumOld11);
  3236. BigDecimal evaluationSumOld1212 = new BigDecimal(evaluationSumOld12);
  3237. // 项目数量环比 对比
  3238. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  3239. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  3240. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  3241. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  3242. BigDecimal monthonmonthNum5 = new BigDecimal(0.00);
  3243. BigDecimal monthonmonthNum6 = new BigDecimal(0.00);
  3244. BigDecimal monthonmonthNum7 = new BigDecimal(0.00);
  3245. BigDecimal monthonmonthNum8 = new BigDecimal(0.00);
  3246. BigDecimal monthonmonthNum9 = new BigDecimal(0.00);
  3247. BigDecimal monthonmonthNum10 = new BigDecimal(0.00);
  3248. BigDecimal monthonmonthNum11 = new BigDecimal(0.00);
  3249. BigDecimal monthonmonthNum12 = new BigDecimal(0.00);
  3250. if (!"0".equals(countNumOld12)) {
  3251. monthonmonthNum1 = (countNum111.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3252. }
  3253. if (!"0".equals(countNum1)) {
  3254. monthonmonthNum2 = (countNum22.subtract(countNum111)).divide(countNum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3255. }
  3256. if (!"0".equals(countNum2)) {
  3257. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3258. }
  3259. if (!"0".equals(countNum3)) {
  3260. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3261. }
  3262. if (!"0".equals(countNum4)) {
  3263. monthonmonthNum5 = (countNum55.subtract(countNum44)).divide(countNum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3264. }
  3265. if (!"0".equals(countNum5)) {
  3266. monthonmonthNum6 = (countNum66.subtract(countNum55)).divide(countNum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3267. }
  3268. if (!"0".equals(countNum6)) {
  3269. monthonmonthNum7 = (countNum77.subtract(countNum66)).divide(countNum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3270. }
  3271. if (!"0".equals(countNum7)) {
  3272. monthonmonthNum8 = (countNum88.subtract(countNum77)).divide(countNum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3273. }
  3274. if (!"0".equals(countNum8)) {
  3275. monthonmonthNum9 = (countNum99.subtract(countNum88)).divide(countNum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3276. }
  3277. if (!"0".equals(countNum9)) {
  3278. monthonmonthNum10 = (countNum1010.subtract(countNum99)).divide(countNum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3279. }
  3280. if (!"0".equals(countNum10)) {
  3281. monthonmonthNum11 = (countNum1111.subtract(countNum1010)).divide(countNum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3282. }
  3283. if (!"0".equals(countNum11)) {
  3284. monthonmonthNum12 = (countNum1212.subtract(countNum1111)).divide(countNum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3285. }
  3286. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  3287. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  3288. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  3289. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  3290. map5.put("monthonmonthNum", monthonmonthNum5.toString());
  3291. map6.put("monthonmonthNum", monthonmonthNum6.toString());
  3292. map7.put("monthonmonthNum", monthonmonthNum7.toString());
  3293. map8.put("monthonmonthNum", monthonmonthNum8.toString());
  3294. map9.put("monthonmonthNum", monthonmonthNum9.toString());
  3295. map10.put("monthonmonthNum", monthonmonthNum10.toString());
  3296. map11.put("monthonmonthNum", monthonmonthNum11.toString());
  3297. map12.put("monthonmonthNum", monthonmonthNum12.toString());
  3298. // 项目数量同比 对比
  3299. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  3300. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  3301. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  3302. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  3303. BigDecimal yearonyearNum5 = new BigDecimal(0.00);
  3304. BigDecimal yearonyearNum6 = new BigDecimal(0.00);
  3305. BigDecimal yearonyearNum7 = new BigDecimal(0.00);
  3306. BigDecimal yearonyearNum8 = new BigDecimal(0.00);
  3307. BigDecimal yearonyearNum9 = new BigDecimal(0.00);
  3308. BigDecimal yearonyearNum10 = new BigDecimal(0.00);
  3309. BigDecimal yearonyearNum11 = new BigDecimal(0.00);
  3310. BigDecimal yearonyearNum12 = new BigDecimal(0.00);
  3311. if (!"0".equals(countNumOld1)) {
  3312. yearonyearNum1 = (countNum111.subtract(countNumOld111)).divide(countNumOld111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3313. }
  3314. if (!"0".equals(countNumOld2)) {
  3315. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3316. }
  3317. if (!"0".equals(countNumOld3)) {
  3318. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3319. }
  3320. if (!"0".equals(countNumOld4)) {
  3321. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3322. }
  3323. if (!"0".equals(countNumOld5)) {
  3324. yearonyearNum5 = (countNum55.subtract(countNumOld55)).divide(countNumOld55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3325. }
  3326. if (!"0".equals(countNumOld6)) {
  3327. yearonyearNum6 = (countNum66.subtract(countNumOld66)).divide(countNumOld66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3328. }
  3329. if (!"0".equals(countNumOld7)) {
  3330. yearonyearNum7 = (countNum77.subtract(countNumOld77)).divide(countNumOld77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3331. }
  3332. if (!"0".equals(countNumOld8)) {
  3333. yearonyearNum8 = (countNum88.subtract(countNumOld88)).divide(countNumOld88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3334. }
  3335. if (!"0".equals(countNumOld9)) {
  3336. yearonyearNum9 = (countNum99.subtract(countNumOld99)).divide(countNumOld99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3337. }
  3338. if (!"0".equals(countNumOld10)) {
  3339. yearonyearNum10 = (countNum1010.subtract(countNumOld1010)).divide(countNumOld1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3340. }
  3341. if (!"0".equals(countNumOld11)) {
  3342. yearonyearNum11 = (countNum1111.subtract(countNumOld1111)).divide(countNumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3343. }
  3344. if (!"0".equals(countNumOld12)) {
  3345. yearonyearNum12 = (countNum1212.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3346. }
  3347. map1.put("yearonyearNum", yearonyearNum1.toString());
  3348. map2.put("yearonyearNum", yearonyearNum2.toString());
  3349. map3.put("yearonyearNum", yearonyearNum3.toString());
  3350. map4.put("yearonyearNum", yearonyearNum4.toString());
  3351. map5.put("yearonyearNum", yearonyearNum5.toString());
  3352. map6.put("yearonyearNum", yearonyearNum6.toString());
  3353. map7.put("yearonyearNum", yearonyearNum7.toString());
  3354. map8.put("yearonyearNum", yearonyearNum8.toString());
  3355. map9.put("yearonyearNum", yearonyearNum9.toString());
  3356. map10.put("yearonyearNum", yearonyearNum10.toString());
  3357. map11.put("yearonyearNum", yearonyearNum11.toString());
  3358. map12.put("yearonyearNum", yearonyearNum12.toString());
  3359. // 预算金额环比 对比
  3360. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  3361. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  3362. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  3363. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  3364. BigDecimal monthonmonthAmount5 = new BigDecimal(0.00);
  3365. BigDecimal monthonmonthAmount6 = new BigDecimal(0.00);
  3366. BigDecimal monthonmonthAmount7 = new BigDecimal(0.00);
  3367. BigDecimal monthonmonthAmount8 = new BigDecimal(0.00);
  3368. BigDecimal monthonmonthAmount9 = new BigDecimal(0.00);
  3369. BigDecimal monthonmonthAmount10 = new BigDecimal(0.00);
  3370. BigDecimal monthonmonthAmount11 = new BigDecimal(0.00);
  3371. BigDecimal monthonmonthAmount12 = new BigDecimal(0.00);
  3372. if (!"0".equals(evaluationSumOld12)) {
  3373. monthonmonthAmount1 = (evaluationSum111.subtract(evaluationSumOld1212)).divide(evaluationSumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3374. }
  3375. if (!"0".equals(evaluationSum1)) {
  3376. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum111)).divide(evaluationSum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3377. }
  3378. if (!"0".equals(evaluationSum2)) {
  3379. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3380. }
  3381. if (!"0".equals(evaluationSum3)) {
  3382. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3383. }
  3384. if (!"0".equals(evaluationSum4)) {
  3385. monthonmonthAmount5 = (evaluationSum55.subtract(evaluationSum44)).divide(evaluationSum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3386. }
  3387. if (!"0".equals(evaluationSum5)) {
  3388. monthonmonthAmount6 = (evaluationSum66.subtract(evaluationSum55)).divide(evaluationSum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3389. }
  3390. if (!"0".equals(evaluationSum6)) {
  3391. monthonmonthAmount7 = (evaluationSum77.subtract(evaluationSum66)).divide(evaluationSum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3392. }
  3393. if (!"0".equals(evaluationSum7)) {
  3394. monthonmonthAmount8 = (evaluationSum88.subtract(evaluationSum77)).divide(evaluationSum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3395. }
  3396. if (!"0".equals(evaluationSum8)) {
  3397. monthonmonthAmount9 = (evaluationSum99.subtract(evaluationSum88)).divide(evaluationSum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3398. }
  3399. if (!"0".equals(evaluationSum9)) {
  3400. monthonmonthAmount10 = (evaluationSum1010.subtract(evaluationSum99)).divide(evaluationSum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3401. }
  3402. if (!"0".equals(evaluationSum10)) {
  3403. monthonmonthAmount11 = (evaluationSum1111.subtract(evaluationSum1010)).divide(evaluationSum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3404. }
  3405. if (!"0".equals(evaluationSum11)) {
  3406. monthonmonthAmount12 = (evaluationSum1212.subtract(evaluationSum1111)).divide(evaluationSum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3407. }
  3408. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  3409. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  3410. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  3411. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  3412. map5.put("monthonmonthAmount", monthonmonthAmount5.toString());
  3413. map6.put("monthonmonthAmount", monthonmonthAmount6.toString());
  3414. map7.put("monthonmonthAmount", monthonmonthAmount7.toString());
  3415. map8.put("monthonmonthAmount", monthonmonthAmount8.toString());
  3416. map9.put("monthonmonthAmount", monthonmonthAmount9.toString());
  3417. map10.put("monthonmonthAmount", monthonmonthAmount10.toString());
  3418. map11.put("monthonmonthAmount", monthonmonthAmount11.toString());
  3419. map12.put("monthonmonthAmount", monthonmonthAmount12.toString());
  3420. // 预算金额同比比 对比
  3421. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  3422. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  3423. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  3424. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  3425. BigDecimal yearonyearAmount5 = new BigDecimal(0.00);
  3426. BigDecimal yearonyearAmount6 = new BigDecimal(0.00);
  3427. BigDecimal yearonyearAmount7 = new BigDecimal(0.00);
  3428. BigDecimal yearonyearAmount8 = new BigDecimal(0.00);
  3429. BigDecimal yearonyearAmount9 = new BigDecimal(0.00);
  3430. BigDecimal yearonyearAmount10 = new BigDecimal(0.00);
  3431. BigDecimal yearonyearAmount11 = new BigDecimal(0.00);
  3432. BigDecimal yearonyearAmount12 = new BigDecimal(0.00);
  3433. if (!"0".equals(evaluationSumOld1)) {
  3434. yearonyearAmount1 = (evaluationSum111.subtract(evaluationSumOld111)).divide(evaluationSumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3435. }
  3436. if (!"0".equals(evaluationSumOld2)) {
  3437. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3438. }
  3439. if (!"0".equals(evaluationSumOld3)) {
  3440. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3441. }
  3442. if (!"0".equals(evaluationSumOld4)) {
  3443. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3444. }
  3445. if (!"0".equals(evaluationSumOld5)) {
  3446. yearonyearAmount5 = (evaluationSum55.subtract(evaluationSumOld55)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3447. }
  3448. if (!"0".equals(evaluationSumOld6)) {
  3449. yearonyearAmount6 = (evaluationSum66.subtract(evaluationSumOld66)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3450. }
  3451. if (!"0".equals(evaluationSumOld7)) {
  3452. yearonyearAmount7 = (evaluationSum77.subtract(evaluationSumOld77)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3453. }
  3454. if (!"0".equals(evaluationSumOld8)) {
  3455. yearonyearAmount8 = (evaluationSum88.subtract(evaluationSumOld88)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3456. }
  3457. if (!"0".equals(evaluationSumOld9)) {
  3458. yearonyearAmount9 = (evaluationSum99.subtract(evaluationSumOld99)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3459. }
  3460. if (!"0".equals(evaluationSumOld10)) {
  3461. yearonyearAmount10 = (evaluationSum1010.subtract(evaluationSumOld1010)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3462. }
  3463. if (!"0".equals(evaluationSumOld11)) {
  3464. yearonyearAmount11 = (evaluationSum1111.subtract(evaluationSumOld1111)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3465. }
  3466. if (!"0".equals(evaluationSumOld12)) {
  3467. yearonyearAmount12 = (evaluationSum1212.subtract(evaluationSumOld1212)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  3468. }
  3469. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  3470. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  3471. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  3472. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  3473. map5.put("yearonyearAmount", yearonyearAmount5.toString());
  3474. map6.put("yearonyearAmount", yearonyearAmount6.toString());
  3475. map7.put("yearonyearAmount", yearonyearAmount7.toString());
  3476. map8.put("yearonyearAmount", yearonyearAmount8.toString());
  3477. map9.put("yearonyearAmount", yearonyearAmount9.toString());
  3478. map10.put("yearonyearAmount", yearonyearAmount10.toString());
  3479. map11.put("yearonyearAmount", yearonyearAmount11.toString());
  3480. map12.put("yearonyearAmount", yearonyearAmount12.toString());
  3481. // 存入集合
  3482. mapReturn.add(map1);
  3483. mapReturn.add(map2);
  3484. mapReturn.add(map3);
  3485. mapReturn.add(map4);
  3486. mapReturn.add(map5);
  3487. mapReturn.add(map6);
  3488. mapReturn.add(map7);
  3489. mapReturn.add(map8);
  3490. mapReturn.add(map9);
  3491. mapReturn.add(map10);
  3492. mapReturn.add(map11);
  3493. mapReturn.add(map12);
  3494. }
  3495. return mapReturn;
  3496. }
  3497. @Override
  3498. public List<StatisticalChartsResVo> demandSubCount(PmDemandReqVo pmDemandReqVo) {
  3499. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3500. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3501. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3502. } else {
  3503. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3504. }
  3505. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3506. //本级和所属采购单位新提报采购需求数量--本年度中本级及下级审核的“需求待提交”之后状态的数据
  3507. StatisticalChartsResVo selectSTS = pmDemandMapper.selectSTS(pmDemandReqVo);
  3508. selectSTS.setColumnName("本级和所属采购单位新提报");
  3509. selectSTS.setColumnNamePlus("采购需求数量");
  3510. resVos.add(selectSTS);
  3511. //上年度结转和本年度提报的采购需求累计数量
  3512. //1.上年度结转:上年度“需求待提交”之后,“合同待填制”之前状态的数据
  3513. //2.本年度提报:指本年度“需求待提交”之后状态的数据
  3514. StatisticalChartsResVo lastYear = pmDemandMapper.selectSTSLastYear(pmDemandReqVo);
  3515. StatisticalChartsResVo thisYear = pmDemandMapper.selectSTSThisYear(pmDemandReqVo);
  3516. if (ObjectUtils.isEmpty(lastYear.getNum())) {
  3517. lastYear = new StatisticalChartsResVo();
  3518. lastYear.setNum(0);
  3519. lastYear.setEvaluationTotal(BigDecimal.ZERO);
  3520. lastYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3521. }
  3522. if (ObjectUtils.isEmpty(thisYear.getNum())) {
  3523. thisYear = new StatisticalChartsResVo();
  3524. thisYear.setNum(0);
  3525. thisYear.setEvaluationTotal(BigDecimal.ZERO);
  3526. thisYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3527. }
  3528. lastYear.setNum(lastYear.getNum() + thisYear.getNum());
  3529. lastYear.setEvaluationTotal(lastYear.getEvaluationTotal().add(thisYear.getEvaluationTotal()));
  3530. lastYear.setColumnName("上年度结转和本年度提报");
  3531. lastYear.setColumnNamePlus("采购需求累计数量");
  3532. resVos.add(lastYear);
  3533. //未按季度采购明细计划提报或调整延迟的数量--超过计划需求提报时间的项目
  3534. StatisticalChartsResVo meiJiDu = pmDemandMapper.selectmeiJiDu(pmDemandReqVo);
  3535. meiJiDu.setColumnName("未按季度采购明细计划提报或调整延迟");
  3536. meiJiDu.setColumnNamePlus("采购需求数量");
  3537. resVos.add(meiJiDu);
  3538. return resVos;
  3539. }
  3540. @Override
  3541. public List<StatisticalChartsResVo> countByProjectType(PmDemandReqVo pmDemandReqVo) {
  3542. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3543. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3544. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3545. } else {
  3546. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3547. }
  3548. List<StatisticalChartsResVo> resultList = new ArrayList<>();
  3549. //项目类型情况统计--根据项目类型:物资类、服务类、工程类、装备类统计项目数量及预算金额
  3550. pmDemandReqVo.setProjectType(ProjectTypes.EQUIPMENTTYPE.getCode());
  3551. StatisticalChartsResVo res1 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3552. res1.setColumnName(ProjectTypes.EQUIPMENTTYPE.getInfo());
  3553. resultList.add(res1);
  3554. pmDemandReqVo.setProjectType(ProjectTypes.MATERIALTYPE.getCode());
  3555. StatisticalChartsResVo res2 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3556. res2.setColumnName(ProjectTypes.MATERIALTYPE.getInfo());
  3557. resultList.add(res2);
  3558. pmDemandReqVo.setProjectType(ProjectTypes.SERVICESTYPE.getCode());
  3559. StatisticalChartsResVo res3 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3560. res3.setColumnName(ProjectTypes.SERVICESTYPE.getInfo());
  3561. resultList.add(res3);
  3562. pmDemandReqVo.setProjectType(ProjectTypes.PLANTOEXAMINETYPE.getCode());
  3563. StatisticalChartsResVo res4 = pmDemandMapper.selectByProjectType(pmDemandReqVo);
  3564. res4.setColumnName(ProjectTypes.PLANTOEXAMINETYPE.getInfo());
  3565. resultList.add(res4);
  3566. return resultList;
  3567. }
  3568. @Override
  3569. public List<StatisticalChartsResVo> countByPurchaseChange(PmDemandReqVo pmDemandReqVo) {
  3570. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3571. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3572. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3573. } else {
  3574. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3575. }
  3576. List<StatisticalChartsResVo> byChange = new ArrayList<>();
  3577. //本月相关采购机构完成采购任务--状态为“标后质疑”后的数据
  3578. StatisticalChartsResVo thisMonth = pmDemandMapper.selectCGThisMonth(pmDemandReqVo);
  3579. thisMonth.setColumnName("本月相关采购机构");
  3580. thisMonth.setColumnNamePlus("完成采购任务数量");
  3581. byChange.add(thisMonth);
  3582. //本季度相关采购机构完成采购任务--状态为“标后质疑”后的数据
  3583. StatisticalChartsResVo thisQua = pmDemandMapper.selectCGThisQua(pmDemandReqVo);
  3584. thisQua.setColumnName("本季度相关采购机构");
  3585. thisQua.setColumnNamePlus("完成采购任务数量");
  3586. byChange.add(thisQua);
  3587. //上年度结转和本年度提报的采购需求中累计已完成的采购任务
  3588. //上年度结转:上年度“标后质疑”之后,“合同待填制”之前状态的数据
  3589. //本年度提报:状态为“标后质疑”后的数据
  3590. StatisticalChartsResVo zLastYear = pmDemandMapper.selectZJLastYear(pmDemandReqVo);
  3591. StatisticalChartsResVo tThisYear = pmDemandMapper.selectTBThisYear(pmDemandReqVo);
  3592. if (ObjectUtils.isEmpty(zLastYear.getNum())) {
  3593. zLastYear = new StatisticalChartsResVo();
  3594. zLastYear.setNum(0);
  3595. zLastYear.setEvaluationTotal(BigDecimal.ZERO);
  3596. zLastYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3597. }
  3598. if (ObjectUtils.isEmpty(tThisYear.getNum())) {
  3599. tThisYear = new StatisticalChartsResVo();
  3600. tThisYear.setNum(0);
  3601. tThisYear.setEvaluationTotal(BigDecimal.ZERO);
  3602. tThisYear.setEvaluationContractTotal(BigDecimal.ZERO);
  3603. }
  3604. //tThisYear.setNum(ObjectUtils.isEmpty(tThisYear.getNum()) ? 0 : tThisYear.getNum() + (ObjectUtils.isEmpty(zLastYear.getNum()) ? 0 : zLastYear.getNum()));
  3605. //tThisYear.setEvaluationTotal((ObjectUtils.isEmpty(tThisYear.getEvaluationTotal()) ? BigDecimal.ZERO : tThisYear.getEvaluationTotal()).add((ObjectUtils.isEmpty(zLastYear.getEvaluationTotal()) ? BigDecimal.ZERO : zLastYear.getEvaluationTotal())));
  3606. //tThisYear.setEvaluationContractTotal((ObjectUtils.isEmpty(tThisYear.getEvaluationContractTotal()) ? BigDecimal.ZERO : tThisYear.getEvaluationContractTotal()).add(ObjectUtils.isEmpty(zLastYear.getEvaluationContractTotal()) ? BigDecimal.ZERO : zLastYear.getEvaluationContractTotal()));
  3607. tThisYear.setColumnName("上年度结转和本年度提报的采购需求");
  3608. tThisYear.setColumnNamePlus("累计完成采购任务数量");
  3609. byChange.add(tThisYear);
  3610. //正常推进周期内的采购任务--本年度项目未超过计划完成采购时间的数据
  3611. StatisticalChartsResVo cThisYear = pmDemandMapper.selectCCThisYear(pmDemandReqVo);
  3612. cThisYear.setColumnName("正常推进周期内");
  3613. cThisYear.setColumnNamePlus("采购任务数量");
  3614. byChange.add(cThisYear);
  3615. return byChange;
  3616. }
  3617. @Override
  3618. public AjaxResult exceedReason(PmDemandReqVo pmDemandReqVo) {
  3619. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3620. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3621. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3622. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3623. } else {
  3624. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3625. }
  3626. //统计超过计划完成采购时间的项目中,处在各阶段的数据包括以下内容:
  3627. //1、需求编制对接数量/涉及金额:状态为“采购需求对接”的数量及预算金额
  3628. List<String> xqdj = new ArrayList<>();
  3629. xqdj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3630. pmDemandReqVo.setProjectStatusList(xqdj);
  3631. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3632. resVo.setColumnName("需求编制对接数量");
  3633. resVos.add(resVo);
  3634. //2、采购文件编制审核数量/涉及金额:状态为“采购文件编制审核“的数量及预算金额
  3635. List<String> wjsh = new ArrayList<>();
  3636. wjsh.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3637. pmDemandReqVo.setProjectStatusList(wjsh);
  3638. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3639. resVo2.setColumnName("采购文件编制审核数量");
  3640. resVos.add(resVo2);
  3641. //3、质疑、投诉、复议、信访举报数量/涉及金额:按钮”质疑投诉”进行质疑过的项目及预算金额
  3642. List<Long> demandIdAll = questionHisService.selectDemandIdAll();
  3643. pmDemandReqVo.setDemandIdAll(demandIdAll);
  3644. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3645. resVo3.setColumnName("质疑、投诉、复议、信访举报数量");
  3646. resVos.add(resVo3);
  3647. //4、流标废标数量/涉及金额:状态为“流废标处置”的项目及预算金额
  3648. List<String> fblb = new ArrayList<>();
  3649. fblb.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  3650. pmDemandReqVo.setProjectStatusList(fblb);
  3651. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3652. resVo4.setColumnName("流标废标数量");
  3653. resVos.add(resVo4);
  3654. //5、其他原因项目数量/涉及金额:统计“专家意见反馈”、“采购公告发布”、”待开标“、”评标结果公告“、“标后质疑”状态的数据
  3655. List<String> qtyy = new ArrayList<>();
  3656. qtyy.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  3657. qtyy.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  3658. qtyy.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3659. qtyy.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  3660. qtyy.add(PmProjectStatus.POST_BID_QUERY.getCode());
  3661. pmDemandReqVo.setProjectStatusList(qtyy);
  3662. StatisticalChartsResVo resVo5 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3663. resVo5.setColumnName("其他原因项目数量");
  3664. resVos.add(resVo5);
  3665. return AjaxResult.success(resVos);
  3666. }
  3667. @Override
  3668. public AjaxResult exceedReasonZj(PmDemandReqVo pmDemandReqVo) {
  3669. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3670. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3671. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3672. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3673. } else {
  3674. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3675. }
  3676. //统计超过计划完成采购时间的项目中,处在各阶段的数据包括以下内容:
  3677. //1、需求编制对接数量/涉及金额:状态为“采购需求对接”的数量及预算金额
  3678. List<String> xqdj = new ArrayList<>();
  3679. xqdj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3680. pmDemandReqVo.setProjectStatusList(xqdj);
  3681. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3682. resVo.setColumnName("需求编制对接数量");
  3683. resVos.add(resVo);
  3684. //2、采购文件编制审核数量/涉及金额:状态为“采购文件编制审核“的数量及预算金额
  3685. List<String> wjsh = new ArrayList<>();
  3686. wjsh.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3687. pmDemandReqVo.setProjectStatusList(wjsh);
  3688. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3689. resVo2.setColumnName("采购文件编制审核数量");
  3690. resVos.add(resVo2);
  3691. //3、质疑、投诉、复议、信访举报数量/涉及金额:按钮”质疑投诉”进行质疑过的项目及预算金额
  3692. List<Long> demandIdAll = questionHisService.selectDemandIdAll();
  3693. pmDemandReqVo.setDemandIdAll(demandIdAll);
  3694. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3695. resVo3.setColumnName("质疑、投诉、复议、信访举报数量");
  3696. resVos.add(resVo3);
  3697. //5、其他原因项目数量/涉及金额:统计“专家意见反馈”、“采购公告发布”、”待开标“、”评标结果公告“、“标后质疑”状态的数据
  3698. List<String> qtyy = new ArrayList<>();
  3699. qtyy.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  3700. qtyy.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  3701. qtyy.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3702. qtyy.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  3703. qtyy.add(PmProjectStatus.POST_BID_QUERY.getCode());
  3704. pmDemandReqVo.setProjectStatusList(qtyy);
  3705. StatisticalChartsResVo resVo5 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3706. resVo5.setColumnName("其他原因项目数量");
  3707. resVos.add(resVo5);
  3708. return AjaxResult.success(resVos);
  3709. }
  3710. @Override
  3711. public AjaxResult exceedLink(PmDemandReqVo pmDemandReqVo) {
  3712. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3713. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3714. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3715. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3716. } else {
  3717. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3718. }
  3719. //滞留环节
  3720. //超过计划完成采购时间的各状态数量及占比统计,包括:采购需求对接、采购文件编制审核、标签质疑投诉、待开标、流废标处置、标后质疑
  3721. //1、 状态为“采购需求对接”的数量及预算金额
  3722. List<String> xqdj = new ArrayList<>();
  3723. xqdj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3724. pmDemandReqVo.setProjectStatusList(xqdj);
  3725. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3726. resVo.setColumnName("采购需求对接");
  3727. resVos.add(resVo);
  3728. //2、 状态为“采购文件编制审核“的数量及预算金额
  3729. List<String> wjsh = new ArrayList<>();
  3730. wjsh.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3731. pmDemandReqVo.setProjectStatusList(wjsh);
  3732. StatisticalChartsResVo resVo2 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3733. resVo2.setColumnName("采购文件编制审核");
  3734. resVos.add(resVo2);
  3735. //3.标前质疑
  3736. List<String> bqzy = new ArrayList<>();
  3737. bqzy.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  3738. pmDemandReqVo.setProjectStatusList(bqzy);
  3739. StatisticalChartsResVo resVo3 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3740. resVo3.setColumnName("标前质疑投诉");
  3741. resVos.add(resVo3);
  3742. //4、 待开标
  3743. List<String> dkb = new ArrayList<>();
  3744. dkb.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3745. pmDemandReqVo.setProjectStatusList(dkb);
  3746. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3747. resVo4.setColumnName("待开标");
  3748. resVos.add(resVo4);
  3749. //5、 流废标处置
  3750. List<String> lfb = new ArrayList<>();
  3751. lfb.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  3752. pmDemandReqVo.setProjectStatusList(lfb);
  3753. StatisticalChartsResVo resVo5 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3754. resVo5.setColumnName("流废标处置");
  3755. resVos.add(resVo5);
  3756. //6、 标后质疑
  3757. List<String> bhzy = new ArrayList<>();
  3758. bhzy.add(PmProjectStatus.POST_BID_QUERY.getCode());
  3759. pmDemandReqVo.setProjectStatusList(bhzy);
  3760. StatisticalChartsResVo resVo6 = pmDemandMapper.countProjectExceedAndStatus(pmDemandReqVo);
  3761. resVo6.setColumnName("标后质疑");
  3762. resVos.add(resVo6);
  3763. return AjaxResult.success(resVos);
  3764. }
  3765. @Override
  3766. public AjaxResult countPurTask(PmDemandReqVo pmDemandReqVo) {
  3767. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  3768. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3769. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3770. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3771. } else {
  3772. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3773. }
  3774. //1、所属采购服务站数量
  3775. //查询现有的采购服务站
  3776. SysDictData dictData = new SysDictData();
  3777. dictData.setDictType("purchase_services");
  3778. List<SysDictData> servicesData = dictDataService.selectDictDataList(dictData);
  3779. StatisticalChartsResVo resVo = new StatisticalChartsResVo();
  3780. resVo.setColumnName("所属采购服务站数量");
  3781. resVo.setNum(servicesData.size());
  3782. resVos.add(resVo);
  3783. //2、所属采购机构--根据招标代理机构管理中的白名单数据显示
  3784. StatisticalChartsResVo resVo2 = pmDemandMapper.countBaseAgencyWithWhite();
  3785. resVo2.setColumnName("所属采购机构");
  3786. resVos.add(resVo2);
  3787. //3、新受领集中采购数量--状态为“任务待下达”之后的数据
  3788. StatisticalChartsResVo resVo3 = pmDemandMapper.JZCGnum(pmDemandReqVo);
  3789. resVo3.setColumnName("新受领集中采购数量");
  3790. resVos.add(resVo3);
  3791. //4、上年度结转任务数量 上年度“任务待下达”之后,“合同待填制”之前的状态的数据
  3792. List<String> snzj = new ArrayList<>();
  3793. snzj.add(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  3794. snzj.add(PmProjectStatus.PURCHASE_DEMAND_DOCKING.getCode());
  3795. snzj.add(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  3796. snzj.add(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  3797. snzj.add(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  3798. snzj.add(PmProjectStatus.PRE_BID_QUERY.getCode());
  3799. snzj.add(PmProjectStatus.WAIT_OPEN_BID.getCode());
  3800. snzj.add(PmProjectStatus.BID_RESULT_ANNOUNCEMENT.getCode());
  3801. snzj.add(PmProjectStatus.WASTE_BID_HANDLE.getCode());
  3802. pmDemandReqVo.setProjectStatusList(snzj);
  3803. StatisticalChartsResVo resVo4 = pmDemandMapper.countProjecReaAndStatus(pmDemandReqVo);
  3804. resVo4.setColumnName("上年度结转任务数量");
  3805. resVos.add(resVo4);
  3806. return AjaxResult.success(resVos);
  3807. }
  3808. @Override
  3809. public AjaxResult countMajorProjectNumCGB(PmDemandReqVo pmDemandReqVo) {
  3810. //新增执行滞后采购任务数量分析 所有的超过计划完成采购时间的数据
  3811. //是-1就是查询自己及子孙级以下,否则只查询指定部门
  3812. if (pmDemandReqVo.getPurchaseDeptId().equals(-1)) {
  3813. pmDemandReqVo.setDeptList(isQueryAll(pmDemandReqVo.getPurchaseDeptId()));
  3814. } else {
  3815. pmDemandReqVo.setDemandIdAll(isQueryZD(pmDemandReqVo.getPurchaseDeptId()));
  3816. }
  3817. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  3818. // 查询数据库中最小的年份
  3819. int minYear = pmDemandMapper.selectMinYear();
  3820. // 获取当前年份
  3821. Calendar calendar = Calendar.getInstance();
  3822. int thisYear = calendar.get(Calendar.YEAR);
  3823. List<StatisticalChartsResVo> resVos = new LinkedList<>();
  3824. for (int i = minYear; i <= thisYear; i++) {
  3825. pmDemandReqVo.setYear(i);
  3826. StatisticalChartsResVo byYear = pmDemandMapper.countProjectACT_Year(pmDemandReqVo);
  3827. resVos.add(byYear);
  3828. }
  3829. if (pmDemandReqVo.getTimeType().equals("1")) {
  3830. resMap.put("年", resVos);
  3831. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  3832. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  3833. for (StatisticalChartsResVo chartsResVo : resVos) {
  3834. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  3835. for (int i = 1; i <= 4; i++) {
  3836. pmDemandReqVo.setQuarter(i);
  3837. StatisticalChartsResVo quarter = pmDemandMapper.countProjectACT_Qua(pmDemandReqVo);
  3838. if (ObjectUtils.isEmpty(quarter)) {
  3839. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  3840. quarter = vo;
  3841. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  3842. }
  3843. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  3844. byQuarter.add(quarter);
  3845. }
  3846. }
  3847. resMap.put("季度", byQuarter);
  3848. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  3849. List<StatisticalChartsResVo> byMonth = new LinkedList<>();
  3850. for (StatisticalChartsResVo chartsResVo : resVos) {
  3851. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  3852. for (int i = 1; i <= 12; i++) {
  3853. pmDemandReqVo.setMonth(i);
  3854. StatisticalChartsResVo month = pmDemandMapper.countProjectACT_Mon(pmDemandReqVo);
  3855. if (ObjectUtils.isEmpty(month)) {
  3856. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "", 0, BigDecimal.valueOf(0), BigDecimal.valueOf(0));
  3857. month = vo;
  3858. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  3859. }
  3860. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  3861. byMonth.add(month);
  3862. }
  3863. }
  3864. resMap.put("月", byMonth);
  3865. }
  3866. return AjaxResult.success(resMap);
  3867. }
  3868. //查询不同状态下的项目数据
  3869. public List<PmDemand> getListByStatus(String projectStatus) {
  3870. LoginUser user = SecurityUtils.getLoginUser();
  3871. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3872. // 通过用户ID查询角色
  3873. List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(user.getUserId());
  3874. //需求单位只能查看和操作个人数据
  3875. List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals("demand_unit")).collect(Collectors.toList());
  3876. if (!ObjectUtils.isEmpty(sysRoleList)) {
  3877. lw.eq(PmDemand::getCreateBy, user.getUserId());
  3878. } else if (!projectStatus.equals("5") && !projectStatus.equals("4")) {
  3879. //需求待提交时不用查审核
  3880. List<PmAuditDeptRef> list = new ArrayList<>();
  3881. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3882. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  3883. l.eq(PmAuditDeptRef::getRefType, "2");
  3884. list = pmAuditDeptRefService.list(l);
  3885. if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  3886. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  3887. }
  3888. }
  3889. lw.in(PmDemand::getProjectStatus, projectStatus);
  3890. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  3891. lw.last(" order by project_status, plan_demand_sub_time");
  3892. return this.baseMapper.selectList(lw);
  3893. }
  3894. /**
  3895. * 查询不同状态下的项目数据(采购办)
  3896. * 采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  3897. *
  3898. * @param projectStatus
  3899. * @return
  3900. */
  3901. public List<PmDemand> getListByStatusCGB(String projectStatus) {
  3902. //登录用户的部门
  3903. Long deptId = SecurityUtils.getDeptId();
  3904. SysDept sysDept = deptMapper.selectDeptById(deptId);
  3905. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3906. List<PmAuditDeptRef> list = new ArrayList<>();
  3907. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3908. l.eq(PmAuditDeptRef::getDeptId, deptId);
  3909. l.eq(PmAuditDeptRef::getRefType, "2");
  3910. list = pmAuditDeptRefService.list(l);
  3911. //本单位所有参与审核的项目id
  3912. List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3913. //上级参与审核的项目
  3914. List<Long> refListf = new ArrayList<>();
  3915. List<PmAuditDeptRef> listf = new ArrayList<>();
  3916. if (sysDept.getParentId() != 0) {
  3917. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  3918. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  3919. lf.eq(PmAuditDeptRef::getRefType, "2");
  3920. listf = pmAuditDeptRefService.list(lf);
  3921. //上级参与审核的项目id
  3922. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3923. }
  3924. //取集合差集,只处理差集中的数据
  3925. if (!ObjectUtils.isEmpty(refListf)) {
  3926. refList.removeAll(refListf);
  3927. }
  3928. lw.in(PmDemand::getProjectStatus, projectStatus);
  3929. lw.last(" order by project_status, plan_demand_sub_time");
  3930. return this.baseMapper.selectList(lw);
  3931. }
  3932. /**
  3933. * 查询不同状态下的项目数据
  3934. * 待办事项--全部
  3935. *
  3936. * @param projectStatus
  3937. * @return
  3938. */
  3939. public List<PmDemand> getListByStatusTotal(List<String> projectStatus) {
  3940. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3941. List<PmAuditDeptRef> list = new ArrayList<>();
  3942. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3943. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  3944. l.eq(PmAuditDeptRef::getRefType, "2");
  3945. list = pmAuditDeptRefService.list(l);
  3946. if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  3947. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  3948. }
  3949. lw.in(PmDemand::getProjectStatus, projectStatus);
  3950. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  3951. lw.last(" order by project_status, plan_demand_sub_time");
  3952. return this.baseMapper.selectList(lw);
  3953. }
  3954. /**
  3955. * 查询不同状态下的项目数据(采购办)
  3956. * 采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  3957. * 待办事项--全部
  3958. *
  3959. * @param projectStatus
  3960. * @return
  3961. */
  3962. public List<PmDemand> getListByStatusTotalCGB(List<String> projectStatus) {
  3963. //登录用户的部门
  3964. Long deptId = SecurityUtils.getDeptId();
  3965. SysDept sysDept = deptMapper.selectDeptById(deptId);
  3966. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  3967. List<PmAuditDeptRef> list = new ArrayList<>();
  3968. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  3969. l.eq(PmAuditDeptRef::getDeptId, deptId);
  3970. l.eq(PmAuditDeptRef::getRefType, "2");
  3971. list = pmAuditDeptRefService.list(l);
  3972. //本单位所有参与审核的项目id
  3973. List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3974. //上级参与审核的项目
  3975. List<Long> refListf = new ArrayList<>();
  3976. List<PmAuditDeptRef> listf = new ArrayList<>();
  3977. if (sysDept.getParentId() != 0) {
  3978. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  3979. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  3980. lf.eq(PmAuditDeptRef::getRefType, "2");
  3981. listf = pmAuditDeptRefService.list(lf);
  3982. //上级参与审核的项目id
  3983. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  3984. }
  3985. //取集合差集,只处理差集中的数据
  3986. if (!ObjectUtils.isEmpty(refListf)) {
  3987. refList.removeAll(refListf);
  3988. }
  3989. //为空就返回空
  3990. if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  3991. lw.in(PmDemand::getDemandId, -1);
  3992. } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  3993. lw.in(PmDemand::getDemandId, refList);
  3994. }
  3995. lw.in(PmDemand::getProjectStatus, projectStatus);
  3996. lw.last(" order by project_status, plan_demand_sub_time");
  3997. return this.baseMapper.selectList(lw);
  3998. }
  3999. //数据转换
  4000. @Override
  4001. public List<PmDemandResVo> listToVoList(List<PmDemand> demandList) {
  4002. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  4003. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  4004. pmDemandResponseVoList = demandChangeTo(demandList);
  4005. }
  4006. return pmDemandResponseVoList;
  4007. }
  4008. //查询不同状态下的项目数据的数量
  4009. @Override
  4010. public Integer getNumByStatus(String projectStatus) {
  4011. LoginUser user = SecurityUtils.getLoginUser();
  4012. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  4013. // 通过用户ID查询角色
  4014. List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(user.getUserId());
  4015. //需求单位只能查看和操作个人数据
  4016. List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals("demand_unit")).collect(Collectors.toList());
  4017. if (!ObjectUtils.isEmpty(sysRoleList)) {
  4018. lw.eq(PmDemand::getCreateBy, user.getUserId());
  4019. } else if (!projectStatus.equals("5") && !projectStatus.equals("4")) {
  4020. ///需求待提交时不用查审核
  4021. List<PmAuditDeptRef> list = new ArrayList<>();
  4022. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  4023. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  4024. l.eq(PmAuditDeptRef::getRefType, "2");
  4025. list = pmAuditDeptRefService.list(l);
  4026. if (!ObjectUtils.isEmpty(list) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  4027. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  4028. }
  4029. }
  4030. lw.eq(PmDemand::getProjectStatus, projectStatus);
  4031. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  4032. lw.last(" order by project_status, plan_demand_sub_time");
  4033. Long count = this.baseMapper.selectCount(lw);
  4034. return Math.toIntExact(count);
  4035. }
  4036. /**
  4037. * 查询不同状态下的项目数据的数量(采购办首页)
  4038. * 采购执行管理中,本单位超额项目交给上级处理,本单位不处理。
  4039. */
  4040. @Override
  4041. public Integer getNumByStatusCGB(String projectStatus) {
  4042. //登录用户的部门
  4043. Long deptId = SecurityUtils.getDeptId();
  4044. SysDept sysDept = deptMapper.selectDeptById(deptId);
  4045. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  4046. List<PmAuditDeptRef> list = new ArrayList<>();
  4047. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  4048. l.eq(PmAuditDeptRef::getDeptId, deptId);
  4049. l.eq(PmAuditDeptRef::getRefType, "2");
  4050. list = pmAuditDeptRefService.list(l);
  4051. //本单位所有参与审核的项目id
  4052. List<Long> refList = list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  4053. //上级参与审核的项目
  4054. List<Long> refListf = new ArrayList<>();
  4055. List<PmAuditDeptRef> listf = new ArrayList<>();
  4056. if (sysDept.getParentId() != 0) {
  4057. LambdaQueryWrapper<PmAuditDeptRef> lf = new LambdaQueryWrapper<>();
  4058. lf.eq(PmAuditDeptRef::getDeptId, sysDept.getParentId());
  4059. lf.eq(PmAuditDeptRef::getRefType, "2");
  4060. listf = pmAuditDeptRefService.list(lf);
  4061. //上级参与审核的项目id
  4062. refListf = listf.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList());
  4063. }
  4064. //取集合差集,只处理差集中的数据
  4065. if (!ObjectUtils.isEmpty(refListf)) {
  4066. refList.removeAll(refListf);
  4067. }
  4068. //为空就返回空
  4069. if (ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  4070. lw.in(PmDemand::getDemandId, -1);
  4071. } else if (!ObjectUtils.isEmpty(refList) && !SysUser.isAdmin(SecurityUtils.getUserId())) {
  4072. lw.in(PmDemand::getDemandId, refList);
  4073. }
  4074. lw.eq(PmDemand::getProjectStatus, projectStatus);
  4075. lw.last(" order by project_status, plan_demand_sub_time");
  4076. Long count = this.baseMapper.selectCount(lw);
  4077. return Math.toIntExact(count);
  4078. }
  4079. //字段转换and赋值
  4080. public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
  4081. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  4082. //获取字典数据
  4083. HashMap<String, HashMap<String, String>> planEnums = dictTypeService.getAboutEnums();
  4084. //项目属性
  4085. HashMap<String, String> projectAttributes = planEnums.get("projectAttributes");
  4086. //提前或延后*天进行提醒
  4087. List<SysDictData> alertTime = dictTypeService.selectDictDataByType("alert_time_setting");
  4088. HashMap<String, String> alertTimeMap = new LinkedHashMap<>();
  4089. //根据时间类别设定的提醒时间
  4090. for (SysDictData dictData : alertTime) {
  4091. // 字段名称----阈值
  4092. alertTimeMap.put(dictData.getDictLabel(), dictData.getDictValue());
  4093. }
  4094. for (PmDemand pmDemand1 : pmDemandList) {
  4095. PmDemandResVo vo = new PmDemandResVo();
  4096. BeanUtils.copyProperties(pmDemand1, vo);
  4097. if (vo.getPurchaseDeptId() != null) {
  4098. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  4099. if (deptMap != null) {
  4100. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  4101. if (sysDeptResponseVo != null) {
  4102. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  4103. }
  4104. }
  4105. }
  4106. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  4107. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  4108. vo.setPurchaseServicesName(purchaseServicesName);
  4109. }
  4110. //项目类型
  4111. for (ProjectTypes value : ProjectTypes.values()) {
  4112. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  4113. vo.setProjectTypeName(value.getInfo());
  4114. break;
  4115. }
  4116. }
  4117. //是否为超限额计划
  4118. for (IsExcess value : IsExcess.values()) {
  4119. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  4120. vo.setIsExcessName(value.getInfo());
  4121. break;
  4122. }
  4123. }
  4124. //采购方式
  4125. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  4126. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  4127. vo.setPurchaseModeName(value.getInfo());
  4128. break;
  4129. }
  4130. }
  4131. //项目属性为value拼接
  4132. if (!ObjectUtils.isEmpty(vo.getProjectAttr())) {
  4133. if (vo.getProjectAttr().length() > 1) {
  4134. StringBuilder builder = new StringBuilder();
  4135. String[] split = vo.getProjectAttr().split(",");
  4136. for (String s : split) {
  4137. for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
  4138. if (s.equals(entry.getValue())) {
  4139. if (!vo.getProjectAttr().endsWith(s)) {
  4140. builder.append(entry.getKey() + ",");
  4141. } else {
  4142. builder.append(entry.getKey());
  4143. }
  4144. break;
  4145. }
  4146. }
  4147. }
  4148. vo.setProjectAttrName(builder.toString());
  4149. } else {
  4150. for (Map.Entry<String, String> entry : projectAttributes.entrySet()) {
  4151. if (vo.getProjectAttr().equals(entry.getValue())) {
  4152. vo.setProjectAttrName(entry.getKey());
  4153. break;
  4154. }
  4155. }
  4156. }
  4157. }
  4158. //预警状态
  4159. for (WarnStatus value : WarnStatus.values()) {
  4160. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  4161. vo.setWarnStatusName(value.getInfo());
  4162. break;
  4163. }
  4164. }
  4165. //项目状态
  4166. for (PmProjectStatus value : PmProjectStatus.values()) {
  4167. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  4168. vo.setProjectStatusName(value.getInfo());
  4169. break;
  4170. }
  4171. }
  4172. try {
  4173. vo.setTipsMessage(pmDemandGetTips(vo, alertTimeMap));
  4174. if (vo.getTipsMessage().contains("超过")) {
  4175. vo.setIsExceedProject("1");
  4176. if (ObjectUtils.isEmpty(pmDemand1.getDelayReason())) {
  4177. //没有原因就可以填写滞后原因
  4178. vo.setIsWriteExceed("1");
  4179. }
  4180. }
  4181. } catch (ParseException e) {
  4182. e.printStackTrace();
  4183. }
  4184. pmDemandResponseVoList.add(vo);
  4185. }
  4186. return pmDemandResponseVoList;
  4187. }
  4188. /**
  4189. * 根据年度计划提报时间的阈值进行提示
  4190. *
  4191. * @return
  4192. */
  4193. public String pmDemandGetTips(PmDemandResVo vo, HashMap<String, String> alertTimeMap) throws ParseException {
  4194. //首页待办事项--计划完成采购时间提醒
  4195. if (ObjectUtils.isEmpty(vo.getRealDemandCommitTime())) {
  4196. int alertDay2 = Integer.parseInt(alertTimeMap.get("计划提报时间"));
  4197. Integer alertTime = 1000 * 60 * 60 * 24 * alertDay2;
  4198. double surplusTwo = vo.getPlanDemandSubTime().getTime() - System.currentTimeMillis();
  4199. //少于设定阈值便提醒
  4200. if (surplusTwo < alertTime) {
  4201. //剩余天数(向上取整)
  4202. int i = (int) Math.ceil(surplusTwo / 1000 / 60 / 60 / 24);
  4203. if (i > 0) {
  4204. return "距离计划提报时间不足" + i + "天";
  4205. } else {
  4206. return "已超过计划提报时间" + Math.abs(i) + "天";
  4207. }
  4208. }
  4209. }
  4210. //首页待办事项--计划完成采购时间提醒
  4211. if (ObjectUtils.isEmpty(vo.getRealPurchaseFinishTime())) {
  4212. int alertDay2 = Integer.parseInt(alertTimeMap.get("计划完成时间"));
  4213. Integer alertTime = 1000 * 60 * 60 * 24 * alertDay2;
  4214. double surplusTwo = vo.getPlanPurchaseFinishTime().getTime() - System.currentTimeMillis();
  4215. //少于设定阈值便提醒
  4216. if (surplusTwo < alertTime) {
  4217. //剩余天数(向上取整)
  4218. int i = (int) Math.ceil(surplusTwo / 1000 / 60 / 60 / 24);
  4219. if (i > 0) {
  4220. return "距离计划完成采购时间不足" + i + "天";
  4221. } else {
  4222. return "已超过计划完成采购时间" + Math.abs(i) + "天";
  4223. }
  4224. }
  4225. }
  4226. //首页待办事项--计划交付时间提醒
  4227. if (ObjectUtils.isEmpty(vo.getRealDeliverTime())) {
  4228. Date deliverTime = vo.getPlanDeliverTime();
  4229. int alertDay = Integer.parseInt(alertTimeMap.get("计划交付(实施)时间"));
  4230. Integer remindTine = 1000 * 60 * 60 * 24 * alertDay;
  4231. double surplus = deliverTime.getTime() - System.currentTimeMillis();
  4232. if (surplus < remindTine) {
  4233. //剩余天数(向上取整)
  4234. int i = (int) Math.ceil(surplus / 1000 / 60 / 60 / 24);
  4235. if (i > 0) {
  4236. return "距离计划交付时间不足" + i + "天";
  4237. } else {
  4238. return "已超过计划交付时间" + Math.abs(i) + "天";
  4239. }
  4240. }
  4241. }
  4242. return "";
  4243. }
  4244. /**
  4245. * 计算百分比:使用java.text.DecimalFormat实现
  4246. *
  4247. * @param x
  4248. * @param y
  4249. * @return
  4250. */
  4251. public static String getPercent(int x, int y) {
  4252. double d1 = x * 1.0;
  4253. double d2 = y * 1.0;
  4254. // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
  4255. DecimalFormat decimalFormat = new DecimalFormat("##.00%");
  4256. return decimalFormat.format(d1 / d2);
  4257. }
  4258. //查询本单位及本级一下全部
  4259. public List<Long> isQueryAll(Integer queryAll) {
  4260. List<Long> deptList = new ArrayList<>();
  4261. Long deptId = SecurityUtils.getDeptId();
  4262. //查询全部
  4263. if (queryAll.equals(-1)) {
  4264. //获取到子孙级部门id
  4265. if (deptService.hasChildByDeptId(SecurityUtils.getDeptId())) {
  4266. List<Long> children = deptService.getDeptChildren(deptId);
  4267. System.err.println(children.size());
  4268. deptList.addAll(children);
  4269. }
  4270. deptList.add(deptId);
  4271. }
  4272. return deptList;
  4273. }
  4274. //查询本单位还是本单位及子孙级----要查询子单位的超额数据
  4275. @Override
  4276. public List<Long> isQueryZD(Integer queryZd) {
  4277. //指定部门--以及子单位的超额数据
  4278. List<Long> demandId = new ArrayList<>();
  4279. //先获取本部门的项目
  4280. LambdaQueryWrapper<PmDemand> ld = new LambdaQueryWrapper<>();
  4281. ld.eq(PmDemand::getPurchaseDeptId, queryZd);
  4282. //本部门的项目
  4283. List<PmDemand> deList = pmDemandMapper.selectList(ld);
  4284. for (PmDemand demand : deList) {
  4285. demandId.add(demand.getDemandId());
  4286. }
  4287. if (deptService.hasChildByDeptId(Long.valueOf(queryZd))) {
  4288. //获取子级部门d
  4289. List<Long> childByDeptId = deptService.getChildIdByDeptId(Long.valueOf(queryZd));
  4290. //取出所有可以进行统计的项目id
  4291. for (Long cid : childByDeptId) {
  4292. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  4293. ll.eq(PmAuditDeptRef::getDeptId, cid);
  4294. ll.eq(PmAuditDeptRef::getRefType, "2");
  4295. //子部门参加审核的项目
  4296. List<PmAuditDeptRef> refList = pmAuditDeptRefService.list(ll);
  4297. //同一个数据有上级参与说明是超额
  4298. for (PmAuditDeptRef ref : refList) {
  4299. //获取上级并查询是否参与审核
  4300. SysDept dept = deptService.selectByCid(ref.getDeptId());
  4301. //是否参与审核
  4302. LambdaQueryWrapper<PmAuditDeptRef> pp = new LambdaQueryWrapper<>();
  4303. ll.eq(PmAuditDeptRef::getDeptId, dept.getDeptId());
  4304. ll.eq(PmAuditDeptRef::getRefId, ref.getRefId());
  4305. //取出父级部门参加审核的项目(超额项目)
  4306. List<PmAuditDeptRef> refListP = pmAuditDeptRefService.list(pp);
  4307. if (!ObjectUtils.isEmpty(refListP)) {
  4308. demandId.add(ref.getRefId());
  4309. }
  4310. }
  4311. }
  4312. }
  4313. return demandId;
  4314. }
  4315. }