PmDemandServiceImpl.java 226 KB

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