PmDemandServiceImpl.java 210 KB

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