PmDemandServiceImpl.java 203 KB

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