PmDemandServiceImpl.java 227 KB

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