PmDemandServiceImpl.java 212 KB

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