PmDemandServiceImpl.java 162 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166
  1. package com.ozs.pm.service.impl;
  2. import java.lang.invoke.LambdaConversionException;
  3. import java.math.BigDecimal;
  4. import java.text.DecimalFormat;
  5. import java.text.ParseException;
  6. import java.util.*;
  7. import java.util.stream.Collectors;
  8. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  9. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  10. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  11. import com.baomidou.mybatisplus.core.metadata.IPage;
  12. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  13. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  14. import com.ozs.base.domain.*;
  15. import com.ozs.base.domain.vo.BaseExpertVo;
  16. import com.ozs.base.mapper.BaseExpertMapper;
  17. import com.ozs.base.service.*;
  18. import com.ozs.common.core.domain.AjaxResult;
  19. import com.ozs.common.core.domain.entity.*;
  20. import com.ozs.common.enums.*;
  21. import com.ozs.common.utils.DateUtils;
  22. import com.ozs.common.utils.RandomUtil;
  23. import com.ozs.common.utils.SecurityUtils;
  24. import com.ozs.common.utils.StringUtils;
  25. import com.ozs.common.utils.bean.BeanUtils;
  26. import com.ozs.home.domain.vo.HomeToDoQueryResVo;
  27. import com.ozs.plan.doman.vo.responseVo.PlanQuarterResponseVo;
  28. import com.ozs.plan.service.PlanYearsService;
  29. import com.ozs.pm.doman.*;
  30. import com.ozs.pm.doman.vo.requestVo.*;
  31. import com.ozs.pm.doman.vo.responseVo.*;
  32. import com.ozs.pm.mapper.PmDemandMapper;
  33. import com.ozs.pm.service.*;
  34. import com.ozs.system.domain.SysFileInfo;
  35. import com.ozs.system.domain.SysFileRef;
  36. import com.ozs.system.domain.vo.SysRegionVO;
  37. import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
  38. import com.ozs.system.mapper.SysDeptMapper;
  39. import com.ozs.system.mapper.SysRoleMapper;
  40. import com.ozs.system.service.*;
  41. import lombok.extern.slf4j.Slf4j;
  42. import org.springframework.beans.factory.annotation.Autowired;
  43. import org.springframework.stereotype.Service;
  44. import org.springframework.transaction.annotation.Transactional;
  45. import org.springframework.util.CollectionUtils;
  46. import org.springframework.util.ObjectUtils;
  47. /**
  48. * 采购需求Service业务层处理
  49. *
  50. * @author ruoyi
  51. * @date 2023-01-16
  52. */
  53. @Service
  54. @Slf4j
  55. public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> implements IPmDemandService {
  56. @Autowired
  57. private PmDemandMapper pmDemandMapper;
  58. @Autowired
  59. private ISysDeptService deptService;
  60. @Autowired
  61. private ISysDictDataService dictDataService;
  62. @Autowired
  63. private SysFileService fileService;
  64. @Autowired
  65. private SysFileRefService sysFileRefService;
  66. @Autowired
  67. private IPmFlowChartService iPmFlowChartService;
  68. @Autowired
  69. private PmReleaseAnnouncementService pmReleaseAnnouncementService;
  70. @Autowired
  71. private BaseExpertService baseExpertService;
  72. @Autowired
  73. private PmDemandExpertRefService pmDemandExpertRefService;
  74. @Autowired
  75. private PmBidOpeningService pmBidOpeningService;
  76. @Autowired
  77. private PmBookBuildingService pmBookBuildingService;
  78. @Autowired
  79. private PmBidWinningService pmBidWinningService;
  80. @Autowired
  81. private ISysDictTypeService iSysDictTypeService;
  82. @Autowired
  83. private PmBidFailureService pmBidFailureService;
  84. @Autowired
  85. private PmBidWinningOpeningRefService pmBidWinningOpeningRefService;
  86. @Autowired
  87. private PmContractInfoService pmContractInfoService;
  88. @Autowired
  89. private BaseAgencyService baseAgencyService;
  90. @Autowired
  91. private PmProjectConstructionService pmProjectConstructionService;
  92. @Autowired
  93. private BaseNoticeTypeService baseNoticeTypeService;
  94. @Autowired
  95. private BaseNoticeService baseNoticeService;
  96. @Autowired
  97. private PlanYearsService planYearsService;
  98. @Autowired
  99. private ISysRegionService iSysRegionService;
  100. @Autowired
  101. private SysRoleMapper sysRoleMapper;
  102. @Autowired
  103. private ISysUserService userService;
  104. @Autowired
  105. private SysDeptMapper deptMapper;
  106. @Autowired
  107. private BaseExpertMapper baseExpertMapper;
  108. @Autowired
  109. private SysProcurementStandardService sysProcurementStandardService;
  110. @Autowired
  111. private PmAuditDeptRefService pmAuditDeptRefService;
  112. /**
  113. * 查询采购需求
  114. *
  115. * @param demandId 采购需求主键
  116. * @return 采购需求
  117. */
  118. @Override
  119. public PmDemandResVo selectPmDemandByDemandId(Long demandId, String detailType) {
  120. PmDemand pmDemand = this.getById(demandId);
  121. if (pmDemand != null) {
  122. PmDemandResVo vo = new PmDemandResVo();
  123. vo.setProjectName(pmDemand.getProjectName());
  124. vo.setDemandId(demandId);
  125. if ("1".equals(detailType)) { //项目计划
  126. BeanUtils.copyProperties(pmDemand, vo);
  127. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(vo.getPurchaseDeptId()).get("sysDept");
  128. if (sysDeptResponseVo != null) {
  129. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  130. }
  131. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  132. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  133. vo.setPurchaseServicesName(purchaseServicesName);
  134. }
  135. //采购需求附件
  136. List<SysFileInfo> demandFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND.getType());
  137. if (!ObjectUtils.isEmpty(demandFileInfos)) {
  138. List<SysFileInfo> sysFileInfoList = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  139. if (!ObjectUtils.isEmpty(sysFileInfoList)) {
  140. demandFileInfos.addAll(sysFileInfoList);
  141. }
  142. vo.setDemandFileInfos(demandFileInfos);
  143. }
  144. //项目类型
  145. for (ProjectTypes value : ProjectTypes.values()) {
  146. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  147. vo.setProjectTypeName(value.getInfo());
  148. break;
  149. }
  150. }
  151. //是否为超限额计划
  152. for (IsExcess value : IsExcess.values()) {
  153. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  154. vo.setIsExcessName(value.getInfo());
  155. break;
  156. }
  157. }
  158. //采购方式
  159. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  160. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  161. vo.setPurchaseModeName(value.getInfo());
  162. break;
  163. }
  164. }
  165. //项目属性
  166. for (ProjectAttribute value : ProjectAttribute.values()) {
  167. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  168. vo.setProjectAttrName(value.getInfo());
  169. break;
  170. }
  171. }
  172. //预警状态
  173. for (WarnStatus value : WarnStatus.values()) {
  174. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  175. vo.setWarnStatusName(value.getInfo());
  176. break;
  177. }
  178. }
  179. //项目状态
  180. for (PmProjectStatus value : PmProjectStatus.values()) {
  181. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  182. vo.setProjectStatusName(value.getInfo());
  183. break;
  184. }
  185. }
  186. } else if ("2".equals(detailType)) { //需求建档
  187. //采购需求审核文件
  188. List<SysFileInfo> auditFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  189. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  190. vo.setAuditFileInfos(auditFileInfos);
  191. }
  192. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  193. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  194. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  195. if (pmBookBuilding != null) {
  196. PmBookBuildingResVo responseVo = new PmBookBuildingResVo();
  197. BeanUtils.copyProperties(pmBookBuilding, responseVo);
  198. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  199. if (!ObjectUtils.isEmpty(fileInfos)) {
  200. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  201. fileInfos.addAll(auditFileInfos);
  202. }
  203. responseVo.setFileInfos(fileInfos);
  204. }
  205. vo.setPmBookBuildingResVo(responseVo);
  206. }
  207. } else if ("3".equals(detailType)) { //任务下达
  208. //任务下达文件
  209. List<SysFileInfo> taskReleaseFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType());
  210. if (!ObjectUtils.isEmpty(taskReleaseFileInfos)) {
  211. vo.setTaskReleaseFileInfos(taskReleaseFileInfos);
  212. }
  213. } else if ("4".equals(detailType)) { //中标信息
  214. PmPurchaseExecutionResVo pmPurchaseExecutionResVo = new PmPurchaseExecutionResVo();
  215. List<SysFileInfo> fileInfosAll = new ArrayList<>();
  216. //代理商信息
  217. BaseAgency baseAgency = this.baseAgencyService.getById(pmDemand.getAgencyId());
  218. pmPurchaseExecutionResVo.setBaseAgency(baseAgency);
  219. //发布公告列表
  220. LambdaQueryWrapper<PmReleaseAnnouncement> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  221. lambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  222. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = this.pmReleaseAnnouncementService.list(lambdaQueryWrapper);
  223. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  224. List<PmReleaseAnnouncementResVo> pmReleaseAnnouncementResVoList = new ArrayList<>();
  225. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  226. PmReleaseAnnouncementResVo pmReleaseAnnouncementResVo = new PmReleaseAnnouncementResVo();
  227. BeanUtils.copyProperties(pmReleaseAnnouncement, pmReleaseAnnouncementResVo);
  228. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  229. if (!ObjectUtils.isEmpty(fileInfos)) {
  230. fileInfosAll.addAll(fileInfos);
  231. }
  232. pmReleaseAnnouncementResVoList.add(pmReleaseAnnouncementResVo);
  233. }
  234. pmPurchaseExecutionResVo.setPmReleaseAnnouncementResVoList(pmReleaseAnnouncementResVoList);
  235. }
  236. //专家信息列表
  237. List<PmBaseExpertResVo> pmBaseExpertResVoList = this.pmDemandExpertRefService.getPmBaseExpertResVoList(demandId);
  238. pmPurchaseExecutionResVo.setPmBaseExpertResVoList(pmBaseExpertResVoList);
  239. //开标信息列表
  240. List<PmBidOpeningResVo> pmBidOpeningResVoList = this.pmBidOpeningService.getPmBidOpeningResVoList(demandId);
  241. pmPurchaseExecutionResVo.setPmBidOpeningResVoList(pmBidOpeningResVoList);
  242. //中标信息列表
  243. LambdaQueryWrapper<PmBidWinning> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
  244. lambdaQueryWrapper1.eq(PmBidWinning::getDemandId, demandId)
  245. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  246. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(lambdaQueryWrapper1);
  247. if (!ObjectUtils.isEmpty(pmBidWinning)) {
  248. LambdaQueryWrapper<PmBidWinningOpeningRef> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  249. lambdaQueryWrapper2.eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId())
  250. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  251. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = this.pmBidWinningOpeningRefService.list(lambdaQueryWrapper2);
  252. if (!ObjectUtils.isEmpty(pmBidWinningOpeningRefList)) {
  253. List<PmBidWinningResVo> pmBidWinningResVoList = new ArrayList<>();
  254. for (PmBidWinningOpeningRef pmBidWinningOpeningRef : pmBidWinningOpeningRefList) {
  255. PmBidOpening pmBidOpening = this.pmBidOpeningService.getById(pmBidWinningOpeningRef.getOpeningId());
  256. if (pmBidOpening != null) {
  257. PmBidWinningResVo pmBidWinningResVo = new PmBidWinningResVo();
  258. BeanUtils.copyProperties(pmBidWinning, pmBidWinningResVo);
  259. pmBidWinningResVo.setBidWinningName(pmBidOpening.getBidderName());
  260. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  261. if (!ObjectUtils.isEmpty(fileInfos)) {
  262. fileInfosAll.addAll(fileInfos);
  263. }
  264. pmBidWinningResVoList.add(pmBidWinningResVo);
  265. }
  266. }
  267. pmPurchaseExecutionResVo.setPmBidWinningResVoList(pmBidWinningResVoList);
  268. }
  269. }
  270. pmPurchaseExecutionResVo.setCallQuestion(pmDemand.getCallQuestion());
  271. //质疑情况
  272. List<SysFileInfo> callRequestFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  273. if (!ObjectUtils.isEmpty(callRequestFileInfos)) {
  274. pmPurchaseExecutionResVo.setCallRequestFileInfos(callRequestFileInfos);
  275. }
  276. //流标情况
  277. LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  278. lambdaQueryWrapper2.eq(PmBidFailure::getDemandId, demandId).orderByDesc(PmBidFailure::getBidFailureTime);
  279. List<PmBidFailure> pmBidFailureList = this.pmBidFailureService.list(lambdaQueryWrapper2);
  280. if (!ObjectUtils.isEmpty(pmBidFailureList)) {
  281. List<PmBidFailureResVo> pmBidFailureResVoList = new ArrayList<>();
  282. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  283. PmBidFailureResVo pmBidFailureResVo = new PmBidFailureResVo();
  284. BeanUtils.copyProperties(pmBidFailure, pmBidFailureResVo);
  285. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  286. if (!ObjectUtils.isEmpty(fileInfos)) {
  287. fileInfosAll.addAll(fileInfos);
  288. }
  289. pmBidFailureResVoList.add(pmBidFailureResVo);
  290. }
  291. pmPurchaseExecutionResVo.setPmBidFailureResVoList(pmBidFailureResVoList);
  292. }
  293. //中标通知书
  294. List<SysFileInfo> pmBidWinningNotificationFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  295. if (!ObjectUtils.isEmpty(pmBidWinningNotificationFileInfos)) {
  296. fileInfosAll.addAll(pmBidWinningNotificationFileInfos);
  297. }
  298. pmPurchaseExecutionResVo.setFileInfos(fileInfosAll);
  299. vo.setPmPurchaseExecutionResVo(pmPurchaseExecutionResVo);
  300. } else if ("5".equals(detailType)) { //合同信息
  301. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  302. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  303. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  304. if (pmContractInfo != null) {
  305. PmContractInfoResVo pmContractInfoResVo = new PmContractInfoResVo();
  306. BeanUtils.copyProperties(pmContractInfo, pmContractInfoResVo);
  307. //合同信息文件
  308. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  309. if (!ObjectUtils.isEmpty(fileInfos)) {
  310. pmContractInfoResVo.setFileInfos(fileInfos);
  311. }
  312. vo.setPmContractInfoResVo(pmContractInfoResVo);
  313. }
  314. } else if ("6".equals(detailType)) { //建设情况
  315. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  316. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  317. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  318. if (pmProjectConstruction != null) {
  319. PmProjectConstructionResVo pmProjectConstructionResVo = new PmProjectConstructionResVo();
  320. BeanUtils.copyProperties(pmProjectConstruction, pmProjectConstructionResVo);
  321. //建设情况文件
  322. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  323. if (!ObjectUtils.isEmpty(fileInfos)) {
  324. pmProjectConstructionResVo.setFileInfos(fileInfos);
  325. }
  326. vo.setPmProjectConstructionResVo(pmProjectConstructionResVo);
  327. }
  328. }
  329. return vo;
  330. } else {
  331. return null;
  332. }
  333. }
  334. /**
  335. * 查询采购需求列表
  336. *
  337. * @param pmDemandReqVo
  338. * @return 采购需求
  339. */
  340. @Override
  341. public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
  342. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  343. // 4 (合同信息管理)、 0(需求单位管理) 、 5(项目建设管理) 需求单位
  344. // 1(需求需求审核) 、2 (任务下达管理) 采购管理部门
  345. // 3(采购执行管理) 采购办
  346. List<PmAuditDeptRef> list = new ArrayList<>();
  347. LambdaQueryWrapper<PmAuditDeptRef> l = new LambdaQueryWrapper<>();
  348. l.eq(PmAuditDeptRef::getDeptId, SecurityUtils.getDeptId());
  349. l.eq(PmAuditDeptRef::getRefType, "2");
  350. list = pmAuditDeptRefService.list(l);
  351. if (Arrays.asList(1, 2, 3).contains(reqType)) {
  352. if (!ObjectUtils.isEmpty(list) && !SecurityUtils.getUserId().equals(Integer.parseInt("1"))) {
  353. lw.in(PmDemand::getDemandId, list.stream().map(PmAuditDeptRef::getRefId).collect(Collectors.toList()));
  354. }
  355. } else {
  356. lw.eq(PmDemand::getPurchaseDeptId, SecurityUtils.getDeptId());
  357. }
  358. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  359. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  360. }
  361. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  362. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  363. }
  364. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus())) {
  365. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  366. }
  367. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus())) {
  368. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  369. }
  370. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess())) {
  371. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  372. }
  373. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  374. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  375. }
  376. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  377. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  378. }
  379. if (reqType == 1) { //需求审核单位列表
  380. lw.apply("(project_status = 6 or project_status = 8 )");
  381. } else if (reqType == 2) { //任务下达列表
  382. lw.apply("(project_status = 8 or project_status = 9 )");
  383. } else if (reqType == 3) { //采购执行列表
  384. lw.apply("(project_status = 9 or project_status = 10 or project_status = 11 or project_status = 12 or project_status = 13 or project_status = 14 or project_status = 15)");
  385. } else if (reqType == 4) { //合同信息列表
  386. lw.apply("(project_status = 15 or project_status = 16 )");
  387. } else if (reqType == 5) { //项目建设列表
  388. lw.apply("(project_status = 16 or project_status = 17 )");
  389. }
  390. lw.last(" order by project_status, plan_demand_sub_time");
  391. IPage<PmDemand> pageRes = this.page(new Page<>(pmDemandReqVo.getPageNum(), pmDemandReqVo.getPageSize()), lw);
  392. IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
  393. if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
  394. List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
  395. for (PmDemandResVo vo : pmDemandResVos) {
  396. if (Arrays.asList(1, 2, 3).contains(reqType)) {
  397. // 根据项目id 和 部门id 和 参数类型 获取 部门级别
  398. List<PmAuditDeptRef> collect = list.stream()
  399. .filter(o -> o.getRefId().equals(vo.getDemandId()))
  400. .collect(Collectors.toList());
  401. if (!ObjectUtils.isEmpty(collect)) {
  402. String deptLevel = collect.get(0).getDeptLevel();
  403. // 根据项目id 和 参数类型 获取 所有审核数据
  404. LambdaQueryWrapper<PmAuditDeptRef> ll = new LambdaQueryWrapper<>();
  405. ll.eq(PmAuditDeptRef::getRefId, vo.getDemandId());
  406. ll.eq(PmAuditDeptRef::getRefType, "2");
  407. List<PmAuditDeptRef> listl = pmAuditDeptRefService.list(l);
  408. // 判断当前用户是否有审核权限
  409. boolean flay = true;
  410. List<PmAuditDeptRef> collect1 = listl.stream()
  411. .filter(pmAuditDeptRef -> pmAuditDeptRef.getRefId().equals(vo.getDemandId()))
  412. .collect(Collectors.toList());
  413. for (PmAuditDeptRef pmAuditDeptRef : collect1) {
  414. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  415. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  416. flay = false;
  417. } else if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0
  418. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("1"))) {
  419. flay = false;
  420. }
  421. }
  422. vo.setFlay(flay);
  423. }
  424. }
  425. }
  426. results.setRecords(pmDemandResVos);
  427. }
  428. return results;
  429. }
  430. /**
  431. * 需求建档
  432. *
  433. * @param vo 采购需求
  434. * @return 结果
  435. */
  436. @Override
  437. @Transactional(rollbackFor = Exception.class)
  438. public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
  439. PmDemand pmDemand = this.getById(vo.getDemandId());
  440. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  441. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, vo.getDemandId());
  442. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  443. if (pmBookBuilding != null) {
  444. vo.setId(pmBookBuilding.getId());
  445. BeanUtils.copyProperties(vo, pmBookBuilding);
  446. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  447. pmBookBuilding.setUpdateTime(new Date());
  448. } else {
  449. pmBookBuilding = new PmBookBuilding();
  450. BeanUtils.copyProperties(vo, pmBookBuilding);
  451. pmBookBuilding.setCreateBy(vo.getUpdateBy());
  452. pmBookBuilding.setCreateTime(new Date());
  453. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  454. pmBookBuilding.setUpdateTime(pmBookBuilding.getCreateTime());
  455. }
  456. if (pmBookBuildingService.saveOrUpdate(pmBookBuilding)) {
  457. List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
  458. uploadFile(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType(), sysFileRefs, vo.getUpdateBy());
  459. pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  460. pmDemand.setUpdateBy(vo.getUpdateBy());
  461. pmDemand.setUpdateTime(DateUtils.getNowDate());
  462. return this.updateById(pmDemand);
  463. } else {
  464. return false;
  465. }
  466. }
  467. private List<SysFileInfo> getSysFileInfoList(Long redId, Integer type) {
  468. HashMap<String, Object> map = new HashMap<>();
  469. map.put("red_id", redId);
  470. map.put("type", type);
  471. List<SysFileRef> fileRefs = sysFileRefService.listByMap(map);
  472. if (!ObjectUtils.isEmpty(fileRefs)) {
  473. List<SysFileInfo> fileInfos = new ArrayList<>();
  474. for (SysFileRef ref : fileRefs) {
  475. SysFileInfo fileInfo = fileService.getById(ref.getFileId());
  476. fileInfos.add(fileInfo);
  477. }
  478. return fileInfos;
  479. } else {
  480. return null;
  481. }
  482. }
  483. /**
  484. * 查看流程图
  485. *
  486. * @param demandId 采购需求主键
  487. * @return 采购需求
  488. */
  489. @Override
  490. public Object viewFlowChart(Long demandId) {
  491. PmDemand pmDemand = this.getById(demandId);
  492. String projectStatus = String.valueOf(pmDemand.getProjectStatus());
  493. String moduleName = null;
  494. if (PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(projectStatus) || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(projectStatus)) {
  495. moduleName = "需求填制";
  496. } else if (PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(projectStatus)) {
  497. moduleName = "需求提交";
  498. } else if (PmProjectStatus.DEMAND_WAIT_AUDIT.getCode().equals(projectStatus)) {
  499. moduleName = "需求审核";
  500. } else if (PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(projectStatus)) {
  501. moduleName = "任务下达";
  502. } else if (PmProjectStatus.WAIT_SELECT_AGENT.getCode().equals(projectStatus)) {
  503. moduleName = "选取代理";
  504. } else if (PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode().equals(projectStatus)) {
  505. moduleName = "上传招标文件";
  506. } else if (PmProjectStatus.WAIT_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  507. moduleName = "发布公告";
  508. } else if (PmProjectStatus.WAIT_OPEN_BID.getCode().equals(projectStatus)) {
  509. moduleName = "填写专家信息,填写开标信息";
  510. } else if (PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  511. moduleName = "填写中标信息";
  512. } else if (PmProjectStatus.BIDDING_PUBLICITY.getCode().equals(projectStatus)) {
  513. moduleName = "质疑处理,上传中标通知书";
  514. } else if (PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(projectStatus)) {
  515. moduleName = "合同填制";
  516. } else if (PmProjectStatus.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) {
  517. moduleName = "建设文档填制";
  518. } else if (PmProjectStatus.COMPLETION_CONSTRUCTION.getCode().equals(projectStatus)) {
  519. moduleName = "项目归档";
  520. }
  521. return moduleName;
  522. }
  523. @Override
  524. public PmFlowChartResVo getModuleInfo(Long demandId, String moduleName) {
  525. LambdaQueryWrapper<PmFlowChart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  526. lambdaQueryWrapper.eq(PmFlowChart::getModuleName, moduleName);
  527. PmFlowChart pmFlowChart = iPmFlowChartService.getOne(lambdaQueryWrapper);
  528. if (pmFlowChart == null) {
  529. return null;
  530. }
  531. PmFlowChartResVo vo = new PmFlowChartResVo();
  532. BeanUtils.copyProperties(pmFlowChart, vo);
  533. if ("需求填制".equals(moduleName)) {
  534. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND.getType());
  535. if (!ObjectUtils.isEmpty(fileInfos)) {
  536. vo.setFileInfos(fileInfos);
  537. }
  538. } else if ("需求提交".equals(moduleName)) {
  539. LambdaQueryWrapper<PmBookBuilding> pmBookBuildingLambdaQueryWrapper = new LambdaQueryWrapper<>();
  540. pmBookBuildingLambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  541. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(pmBookBuildingLambdaQueryWrapper);
  542. if (pmBookBuilding != null) {
  543. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  544. if (!ObjectUtils.isEmpty(fileInfos)) {
  545. vo.setFileInfos(fileInfos);
  546. }
  547. }
  548. } else if ("需求审核".equals(moduleName)) {
  549. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  550. if (!ObjectUtils.isEmpty(fileInfos)) {
  551. vo.setFileInfos(fileInfos);
  552. }
  553. } else if ("任务下达".equals(moduleName)) {
  554. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_TAST_RELEASE.getType());
  555. if (!ObjectUtils.isEmpty(fileInfos)) {
  556. vo.setFileInfos(fileInfos);
  557. }
  558. } else if ("选取代理".equals(moduleName)) {
  559. //do nothing
  560. } else if ("上传招标文件".equals(moduleName)) {
  561. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_FILE.getType());
  562. if (!ObjectUtils.isEmpty(fileInfos)) {
  563. vo.setFileInfos(fileInfos);
  564. }
  565. } else if ("发布公告".equals(moduleName)) {
  566. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  567. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  568. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = pmReleaseAnnouncementService.list(pmReleaseAnnouncementLambdaQueryWrapper);
  569. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  570. List<SysFileInfo> listAll = new ArrayList<>();
  571. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  572. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  573. if (!ObjectUtils.isEmpty(fileInfos)) {
  574. listAll.addAll(fileInfos);
  575. }
  576. }
  577. if (!ObjectUtils.isEmpty(listAll)) {
  578. vo.setFileInfos(listAll);
  579. }
  580. }
  581. } else if ("填写专家信息".equals(moduleName)) {
  582. //do nothing
  583. } else if ("填写开标信息".equals(moduleName)) {
  584. //do nothing
  585. } else if ("填写中标信息".equals(moduleName)) {
  586. List<SysFileInfo> listAll = new ArrayList<>();
  587. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  588. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, demandId);
  589. List<PmBidWinning> pmBidWinningList = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  590. if (!ObjectUtils.isEmpty(pmBidWinningList)) {
  591. for (PmBidWinning pmBidWinning : pmBidWinningList) {
  592. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  593. if (!ObjectUtils.isEmpty(fileInfos)) {
  594. listAll.addAll(fileInfos);
  595. }
  596. }
  597. }
  598. LambdaQueryWrapper<PmBidFailure> pmBidFailureLambdaQueryWrapper = new LambdaQueryWrapper<>();
  599. pmBidFailureLambdaQueryWrapper.eq(PmBidFailure::getDemandId, demandId);
  600. List<PmBidFailure> pmBidFailureList = pmBidFailureService.list(pmBidFailureLambdaQueryWrapper);
  601. if (!ObjectUtils.isEmpty(pmBidFailureService)) {
  602. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  603. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  604. if (!ObjectUtils.isEmpty(fileInfos)) {
  605. listAll.addAll(fileInfos);
  606. }
  607. }
  608. }
  609. if (!ObjectUtils.isEmpty(listAll)) {
  610. vo.setFileInfos(listAll);
  611. }
  612. } else if ("质疑处理".equals(moduleName)) {
  613. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  614. if (!ObjectUtils.isEmpty(fileInfos)) {
  615. vo.setFileInfos(fileInfos);
  616. }
  617. } else if ("上传中标通知书".equals(moduleName)) {
  618. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  619. if (!ObjectUtils.isEmpty(fileInfos)) {
  620. vo.setFileInfos(fileInfos);
  621. }
  622. } else if ("合同填制".equals(moduleName)) {
  623. LambdaQueryWrapper<PmContractInfo> pmContractInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
  624. pmContractInfoLambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  625. PmContractInfo pmContractInfo = pmContractInfoService.getOne(pmContractInfoLambdaQueryWrapper);
  626. if (pmContractInfo != null) {
  627. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  628. if (!ObjectUtils.isEmpty(fileInfos)) {
  629. vo.setFileInfos(fileInfos);
  630. }
  631. }
  632. } else if ("建设文档填制".equals(moduleName)) {
  633. LambdaQueryWrapper<PmProjectConstruction> pmProjectConstructionLambdaQueryWrapper = new LambdaQueryWrapper<>();
  634. pmProjectConstructionLambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  635. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(pmProjectConstructionLambdaQueryWrapper);
  636. if (pmProjectConstruction != null) {
  637. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  638. if (!ObjectUtils.isEmpty(fileInfos)) {
  639. vo.setFileInfos(fileInfos);
  640. }
  641. }
  642. } else if ("项目归档".equals(moduleName)) {
  643. //do nothing
  644. }
  645. return vo;
  646. }
  647. /**
  648. * 提交采购需求
  649. *
  650. * @param pmDemandReqVo
  651. * @return 结果
  652. */
  653. @Override
  654. @Transactional(rollbackFor = Exception.class)
  655. public boolean commit(PmDemandReqVo pmDemandReqVo) {
  656. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  657. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  658. Long deptId = sysUser.getDeptId();
  659. SysDept sysDept = deptMapper.selectDeptById(deptId);
  660. pmAuditDeptRefService.insertPmAuditDeptRefs(pmDemandReqVo.getDemandId()
  661. , "2"
  662. , deptId
  663. , BigDecimal.valueOf(pmDemand.getEvaluation())
  664. , sysUser.getUserId()
  665. , pmDemand.getProjectType());
  666. PmDemand pmDemandUpdate = new PmDemand();
  667. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  668. pmDemandUpdate.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  669. pmDemandUpdate.setRealDemandCommitTime(DateUtils.getNowDate());
  670. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  671. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  672. return this.updateById(pmDemandUpdate);
  673. }
  674. /**
  675. * 审核采购需求通过
  676. *
  677. * @param pmDemandReqVo
  678. * @return 结果
  679. */
  680. @Override
  681. @Transactional(rollbackFor = Exception.class)
  682. public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
  683. PmDemand pmDemand = this.getById(pmDemandReqVo.getDemandId());
  684. PmDemand pmDemandUpdate = new PmDemand();
  685. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  686. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  687. Long deptId = sysUser.getDeptId();
  688. SysDept sysDept = deptMapper.selectDeptById(deptId);
  689. String[] ancestors = sysDept.getAncestors().split(",");
  690. String deptLevel = null;
  691. if (ancestors.length == 2) { //C级
  692. deptLevel = "C";
  693. } else if (ancestors.length == 3) { //B级
  694. deptLevel = "B";
  695. } else if (ancestors.length == 4) { //A级
  696. deptLevel = "A";
  697. }
  698. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  699. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  700. lw.eq(PmAuditDeptRef::getRefType, "2");
  701. List<PmAuditDeptRef> list = pmAuditDeptRefService.list(lw);
  702. boolean flay = true;
  703. if (!ObjectUtils.isEmpty(list)) {
  704. for (PmAuditDeptRef pmAuditDeptRef : list) {
  705. // 判断 deptLevel 是否还有更高的 且是 待审核的数据
  706. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) > 0
  707. && pmAuditDeptRef.getStatus().equals(Integer.parseInt("0"))) {
  708. flay = false;
  709. }
  710. // 更新当前 deptLevel 级别的审核状态
  711. if (pmAuditDeptRef.getDeptLevel().compareTo(deptLevel) == 0) {
  712. pmAuditDeptRef.setStatus(1);
  713. pmAuditDeptRefService.updateById(pmAuditDeptRef);
  714. }
  715. }
  716. }
  717. if (flay) {
  718. pmDemandUpdate.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  719. }
  720. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  721. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  722. pmDemandUpdate.setUpdateBy(pmDemandReqVo.getUpdateBy());
  723. pmDemandUpdate.setUpdateTime(DateUtils.getNowDate());
  724. pmDemandUpdate.setAuditTime(DateUtils.getNowDate());
  725. return this.updateById(pmDemandUpdate);
  726. }
  727. /**
  728. * 审核采购需求退回
  729. *
  730. * @param pmDemandReqVo
  731. * @return 结果
  732. */
  733. @Override
  734. @Transactional(rollbackFor = Exception.class)
  735. public boolean reviewReturn(PmDemandReqVo pmDemandReqVo) {
  736. UpdateWrapper<PmDemand> updateWrapper = new UpdateWrapper<>();
  737. updateWrapper.lambda().eq(PmDemand::getDemandId, pmDemandReqVo.getDemandId())
  738. .set(PmDemand::getProjectStatus, PmProjectStatus.DEMAND_AUDIT_RETURN.getCode())
  739. .set(PmDemand::getAdjustReason, pmDemandReqVo.getRefuseReason())
  740. .set(PmDemand::getRealDemandCommitTime, null)
  741. .set(PmDemand::getUpdateBy, pmDemandReqVo.getUpdateBy())
  742. .set(PmDemand::getUpdateTime, DateUtils.getNowDate())
  743. .set(PmDemand::getAuditTime, DateUtils.getNowDate());
  744. LambdaQueryWrapper<PmAuditDeptRef> lw = new LambdaQueryWrapper();
  745. lw.eq(PmAuditDeptRef::getRefId, pmDemandReqVo.getDemandId());
  746. lw.eq(PmAuditDeptRef::getRefType, "2");
  747. pmAuditDeptRefService.remove(lw);
  748. return this.update(updateWrapper);
  749. }
  750. /**
  751. * 下达任务
  752. *
  753. * @param pmDemandReqVo
  754. * @return 结果
  755. */
  756. @Override
  757. @Transactional(rollbackFor = Exception.class)
  758. public boolean releaseTask(PmDemandReqVo pmDemandReqVo) {
  759. PmDemand pmDemand = new PmDemand();
  760. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  761. pmDemand.setProjectStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  762. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  763. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  764. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  765. pmDemand.setUpdateTime(DateUtils.getNowDate());
  766. pmDemand.setAuditTime(DateUtils.getNowDate());
  767. return this.updateById(pmDemand);
  768. }
  769. @Override
  770. @Transactional(rollbackFor = Exception.class)
  771. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy) {
  772. if (!ObjectUtils.isEmpty(sysFileRefs)) {
  773. //删除老的
  774. // QueryWrapper<SysFileRef> queryWrapper = new QueryWrapper<>();
  775. // queryWrapper.lambda().eq(SysFileRef::getRedId, redId)
  776. // .eq(SysFileRef::getType, fileType);
  777. // List<SysFileRef> sysFileRefList = sysFileRefService.list(queryWrapper);
  778. // if (!CollectionUtils.isEmpty(sysFileRefList)) {
  779. // sysFileRefService.remove(queryWrapper);
  780. // }
  781. //添加新的
  782. for (SysFileRef ref : sysFileRefs) {
  783. if (ref.getFileId() == null) {
  784. continue;
  785. }
  786. ref.setRedId(redId);
  787. ref.setType(fileType);
  788. ref.setCreated(upateBy);
  789. ref.setCreateTime(new Date());
  790. ref.setUpdated(upateBy);
  791. ref.setUpdateTime(ref.getCreateTime());
  792. sysFileRefService.save(ref);
  793. }
  794. return true;
  795. } else {
  796. return false;
  797. }
  798. }
  799. @Override
  800. @Transactional(rollbackFor = Exception.class)
  801. public boolean insertPmReleaseAnnouncement(PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) throws Exception {
  802. PmDemand pmDemand = this.getById(pmReleaseAnnouncementReqVo.getDemandId());
  803. if (ObjectUtils.isEmpty(pmDemand)) {
  804. throw new Exception("参数错误");
  805. }
  806. if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
  807. throw new Exception("上传附件不能为空");
  808. }
  809. PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
  810. BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
  811. if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
  812. uploadFile(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType(), pmReleaseAnnouncementReqVo.getSysFileRefs(), pmReleaseAnnouncementReqVo.getUpdateBy());
  813. PmDemand pmDemandUpdate = new PmDemand();
  814. pmDemandUpdate.setDemandId(pmReleaseAnnouncementReqVo.getDemandId());
  815. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  816. pmDemandUpdate.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  817. pmDemandUpdate.setUpdateBy(pmReleaseAnnouncementReqVo.getUpdateBy());
  818. if (this.updateById(pmDemandUpdate)) {
  819. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  820. BaseNotice baseNotice = new BaseNotice();
  821. baseNotice.setName(pmDemand.getProjectName());
  822. baseNotice.setTitle(pmDemand.getProjectName() + "招标公告");
  823. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  824. lambdaQueryWrapper.eq(BaseNoticeType::getName, "招标公告");
  825. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  826. if (baseNoticeType == null) {
  827. throw new Exception("招标公告 公告类型不存在");
  828. }
  829. baseNotice.setDemandId(pmDemand.getDemandId());
  830. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  831. baseNotice.setIsExcess(pmDemand.getIsExcess());
  832. baseNotice.setType(baseNoticeType.getId());
  833. baseNotice.setReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  834. baseNotice.setCreated(pmReleaseAnnouncementReqVo.getCreateBy());
  835. baseNotice.setCreateTime(pmReleaseAnnouncementReqVo.getCreateTime());
  836. baseNotice.setUpdated(pmReleaseAnnouncementReqVo.getUpdateBy());
  837. baseNotice.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  838. return this.baseNoticeService.saveOrUpdate(baseNotice);
  839. } else {
  840. return false;
  841. }
  842. } else {
  843. return false;
  844. }
  845. }
  846. @Override
  847. @Transactional(rollbackFor = Exception.class)
  848. public boolean insertExpertBatch(PmBaseExpertFillReqVo pmBaseExpertFillReqVo) throws Exception {
  849. PmDemand pmDemand = this.getById(pmBaseExpertFillReqVo.getDemandId());
  850. if (ObjectUtils.isEmpty(pmDemand)) {
  851. throw new Exception("参数错误");
  852. }
  853. List<BaseExpert> baseExpertList = pmBaseExpertFillReqVo.getBaseExpertList();
  854. if (ObjectUtils.isEmpty(baseExpertList)) {
  855. throw new Exception("参数错误");
  856. }
  857. Date now = new Date();
  858. for (BaseExpert baseExpert : baseExpertList) {
  859. if (NameListType.BLACK.getCode().equals(baseExpert.getStatus())) {
  860. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")属于黑名单");
  861. } else {
  862. if (ObjectUtils.isEmpty(baseExpert.getStatus())) {
  863. baseExpert.setStatus(NameListType.WHITE.getCode());
  864. }
  865. }
  866. if (ObjectUtils.isEmpty(baseExpert.getVarietyPurchase()) || !baseExpert.getVarietyPurchase().contains(pmDemand.getProjectType())) {
  867. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")所属采购品种和项目类型不匹配");
  868. }
  869. if (ObjectUtils.isEmpty(baseExpert.getCreated())) {
  870. baseExpert.setCreated(pmBaseExpertFillReqVo.getCreateBy());
  871. baseExpert.setCreateTime(now);
  872. }
  873. if (ObjectUtils.isEmpty(baseExpert.getUpdated())) {
  874. baseExpert.setUpdated(pmBaseExpertFillReqVo.getUpdateBy());
  875. baseExpert.setUpdateTime(now);
  876. }
  877. if (baseExpertService.saveOrUpdate(baseExpert)) {
  878. LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  879. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  880. .eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  881. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertFillReqVo.getAccessTime());
  882. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(pmDemandExpertRefLambdaQueryWrapper);
  883. if (pmDemandExpertRef == null) {
  884. pmDemandExpertRef = new PmDemandExpertRef();
  885. pmDemandExpertRef.setCreateBy(pmBaseExpertFillReqVo.getCreateBy());
  886. pmDemandExpertRef.setCreateTime(now);
  887. }
  888. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  889. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  890. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertFillReqVo.getAccessTime()));
  891. pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
  892. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  893. pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
  894. //专家单位
  895. if (StringUtils.isNotNull(baseExpert.getUnitInformation())) {
  896. List<BaseUnitInformation> baseUnitInformationList = baseExpertMapper.selectByUnitInformation(baseExpert.getUnitInformation());
  897. if (baseUnitInformationList.size() <= 0) {
  898. BaseUnitInformation baseUnitInformation = new BaseUnitInformation();
  899. baseUnitInformation.setUnitName(baseExpert.getUnitInformation());
  900. baseUnitInformation.setCreated(baseExpert.getExpertName());
  901. baseUnitInformation.setCreateTime(new Date());
  902. Integer i = baseExpertMapper.insertBaseUnitInformation(baseUnitInformation);
  903. }
  904. }
  905. }
  906. }
  907. PmDemand pmDemandUpdate = new PmDemand();
  908. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  909. pmDemandUpdate.setHasExpert("1");
  910. this.updateById(pmDemandUpdate);
  911. return true;
  912. }
  913. @Override
  914. @Transactional(rollbackFor = Exception.class)
  915. public boolean extractExpertBatch(PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) throws Exception {
  916. PmDemand pmDemand = this.getById(pmBaseExpertExtractReqVo.getDemandId());
  917. if (ObjectUtils.isEmpty(pmDemand)) {
  918. throw new Exception("参数错误");
  919. }
  920. String professional = pmBaseExpertExtractReqVo.getProfessional();
  921. if (ObjectUtils.isEmpty(professional)) {
  922. throw new Exception("必须选择专家专业");
  923. }
  924. String localArea = pmBaseExpertExtractReqVo.getLocalArea();
  925. if (ObjectUtils.isEmpty(localArea)) {
  926. throw new Exception("必须选择地域");
  927. }
  928. if (!StringUtils.isNumeric(localArea)) {
  929. throw new Exception("地域必须传数字代码");
  930. }
  931. Integer technicalExpertNumber = pmBaseExpertExtractReqVo.getTechnicalExpertNumber();
  932. if (technicalExpertNumber == null) {
  933. technicalExpertNumber = 0;
  934. }
  935. Integer economicExpertNumber = pmBaseExpertExtractReqVo.getEconomicExpertNumber();
  936. if (economicExpertNumber == null) {
  937. economicExpertNumber = 0;
  938. }
  939. Integer legalAffairsExpertNumber = pmBaseExpertExtractReqVo.getLegalAffairsExpertNumber();
  940. if (legalAffairsExpertNumber == null) {
  941. legalAffairsExpertNumber = 0;
  942. }
  943. Integer spareExpertNumber = pmBaseExpertExtractReqVo.getSpareExpertNumber();
  944. if (spareExpertNumber == null) {
  945. spareExpertNumber = 0;
  946. }
  947. if (technicalExpertNumber + economicExpertNumber + legalAffairsExpertNumber + spareExpertNumber == 0) {
  948. throw new Exception("必须至少填写一个数量");
  949. }
  950. String needAvoidUnit = pmBaseExpertExtractReqVo.getNeedAvoidUnit();
  951. List<String> needAvoidUnitList = null;
  952. if (!ObjectUtils.isEmpty(needAvoidUnit)) {
  953. String[] arr = needAvoidUnit.split(",");
  954. needAvoidUnitList = Arrays.asList(arr);
  955. }
  956. List<String> sysRegionCodeList = new ArrayList<>();
  957. if (!ObjectUtils.isEmpty(localArea)) {
  958. sysRegionCodeList.add(localArea);
  959. //找到该地域code对应的子列表
  960. List<SysRegionVO> sysRegionVOList = iSysRegionService.findChildDivisions(localArea);
  961. if (!ObjectUtils.isEmpty(sysRegionVOList)) {
  962. for (SysRegionVO vo : sysRegionVOList) {
  963. sysRegionCodeList.add(vo.getCode());
  964. }
  965. }
  966. }
  967. //从专家库中查询符合项目类型的以及是白名单的全部列表
  968. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
  969. lw.eq(BaseExpert::getVarietyPurchase, pmDemand.getProjectType())
  970. .eq(BaseExpert::getStatus, NameListType.WHITE.getCode())
  971. .notIn(!ObjectUtils.isEmpty(needAvoidUnitList), BaseExpert::getUnitInformation, needAvoidUnitList)
  972. .in(!ObjectUtils.isEmpty(sysRegionCodeList), BaseExpert::getLocalArea, sysRegionCodeList); //地域
  973. List<BaseExpert> baseExpertList = baseExpertService.list(lw);
  974. if (ObjectUtils.isEmpty(baseExpertList)) {
  975. throw new Exception("没抽取到符合条件的专家");
  976. }
  977. //从列表中挑出来各个类型的子列表
  978. List<BaseExpert> technicalExpertList = new ArrayList<>();
  979. List<BaseExpert> economicExpertList = new ArrayList<>();
  980. List<BaseExpert> legalAffairsExpertList = new ArrayList<>();
  981. List<BaseExpert> spareExpertList = new ArrayList<>();
  982. String[] arr = professional.split(",");
  983. List<String> professionalList = Arrays.asList(arr);
  984. for (BaseExpert baseExpert : baseExpertList) {
  985. //专业类型判断
  986. String majorType = baseExpert.getMajorType();
  987. if (!ObjectUtils.isEmpty(majorType)) {
  988. String[] arr2 = majorType.split(",");
  989. List<String> majorTypeList = Arrays.asList(arr2);
  990. if (!hasIntersection(professionalList, majorTypeList)) { //不符合专业类型
  991. continue;
  992. }
  993. }
  994. //备用专家
  995. if (spareExpertNumber > 0) { //都加进去
  996. spareExpertList.add(baseExpert);
  997. }
  998. if (technicalExpertNumber > 0) {
  999. if (baseExpert.getExpertType().contains(ExpertType.TECHNICAL_EXPERT.getCode())) {
  1000. technicalExpertList.add(baseExpert);
  1001. continue;
  1002. }
  1003. }
  1004. if (economicExpertNumber > 0) {
  1005. if (baseExpert.getExpertType().contains(ExpertType.ECONOMIC_EXPERT.getCode())) {
  1006. economicExpertList.add(baseExpert);
  1007. continue;
  1008. }
  1009. }
  1010. if (legalAffairsExpertNumber > 0) {
  1011. if (baseExpert.getExpertType().contains(ExpertType.LEGALAFFAIRS_EXPERT.getCode())) {
  1012. legalAffairsExpertList.add(baseExpert);
  1013. continue;
  1014. }
  1015. }
  1016. }
  1017. //从子列表中随机抽取符合数据量的
  1018. List<BaseExpert> alltExpertList = new ArrayList<>();
  1019. if(technicalExpertNumber > 0 && technicalExpertList.size() < technicalExpertNumber){
  1020. throw new Exception("抽取到符合条件的技术专家数量不够");
  1021. }
  1022. if (!ObjectUtils.isEmpty(technicalExpertList)) {
  1023. alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
  1024. }
  1025. if(economicExpertNumber > 0 && economicExpertList.size() < economicExpertNumber){
  1026. throw new Exception("抽取到符合条件的经济专家数量不够");
  1027. }
  1028. if (!ObjectUtils.isEmpty(economicExpertList)) {
  1029. alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
  1030. }
  1031. if(legalAffairsExpertNumber > 0 && legalAffairsExpertList.size() < legalAffairsExpertNumber){
  1032. throw new Exception("抽取到符合条件的法务专家数量不够");
  1033. }
  1034. if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
  1035. alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
  1036. }
  1037. List<BaseExpert> spareExpertListNew = new ArrayList<>();
  1038. if (!ObjectUtils.isEmpty(spareExpertList)) {
  1039. //获取全部IDlist
  1040. List<Integer> allExpertIdList = new ArrayList<>();
  1041. if (!ObjectUtils.isEmpty(alltExpertList)) {
  1042. for (BaseExpert baseExpert : alltExpertList) {
  1043. allExpertIdList.add(baseExpert.getId());
  1044. }
  1045. }
  1046. //遍历全部IDlist
  1047. if (!ObjectUtils.isEmpty(allExpertIdList)) { //去重
  1048. for (BaseExpert baseExpert : spareExpertList) {
  1049. if (!allExpertIdList.contains(baseExpert.getId())) {
  1050. spareExpertListNew.add(baseExpert);
  1051. }
  1052. }
  1053. } else {
  1054. spareExpertListNew = spareExpertList;
  1055. }
  1056. if (!ObjectUtils.isEmpty(spareExpertListNew)) {
  1057. alltExpertList.addAll(RandomUtil.getRandomList(spareExpertListNew, spareExpertNumber));
  1058. }
  1059. }
  1060. if(spareExpertNumber > 0 && spareExpertListNew.size() < spareExpertNumber){
  1061. throw new Exception("抽取到符合条件的备用专家数量不够");
  1062. }
  1063. if (ObjectUtils.isEmpty(alltExpertList)) {
  1064. throw new Exception("没抽取到符合条件的专家");
  1065. } else {
  1066. List<PmDemandExpertRef> pmDemandExpertRefList = new ArrayList<>();
  1067. for (BaseExpert baseExpert : alltExpertList) {
  1068. LambdaQueryWrapper<PmDemandExpertRef> baseExpertLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1069. baseExpertLambdaQueryWrapper.eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  1070. .eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  1071. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertExtractReqVo.getAccessTime());
  1072. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(baseExpertLambdaQueryWrapper);
  1073. if (pmDemandExpertRef == null) {
  1074. pmDemandExpertRef = new PmDemandExpertRef();
  1075. pmDemandExpertRef.setCreateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1076. pmDemandExpertRef.setCreateTime(new Date());
  1077. }
  1078. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  1079. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  1080. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertExtractReqVo.getAccessTime()));
  1081. pmDemandExpertRef.setUpdateBy(pmBaseExpertExtractReqVo.getCreateBy());
  1082. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  1083. pmDemandExpertRefList.add(pmDemandExpertRef);
  1084. }
  1085. PmDemand pmDemandUpdate = new PmDemand();
  1086. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1087. pmDemandUpdate.setHasExpert("1");
  1088. this.updateById(pmDemandUpdate);
  1089. return pmDemandExpertRefService.saveOrUpdateBatch(pmDemandExpertRefList);
  1090. }
  1091. }
  1092. //二个列表是否有交集
  1093. private boolean hasIntersection(List<String> professionalList, List<String> majorTypeList) {
  1094. for (String professiona : professionalList) {
  1095. for (String majorType : majorTypeList) {
  1096. if (professiona.equals(majorType)) {
  1097. return true;
  1098. }
  1099. }
  1100. }
  1101. return false;
  1102. }
  1103. @Override
  1104. @Transactional(rollbackFor = Exception.class)
  1105. public boolean insertBidOpeningBatch(PmBidOpeningFillReqVo pmBidOpeningFillReqVo) throws Exception {
  1106. PmDemand pmDemand = this.getById(pmBidOpeningFillReqVo.getDemandId());
  1107. if (ObjectUtils.isEmpty(pmDemand)) {
  1108. throw new Exception("参数错误");
  1109. }
  1110. //从发布公告里获取开标时间
  1111. LambdaQueryWrapper<PmReleaseAnnouncement> lw = new LambdaQueryWrapper<>();
  1112. lw.eq(PmReleaseAnnouncement::getDemandId, pmDemand.getDemandId()).orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  1113. .last(" limit 1 ");
  1114. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(lw);
  1115. if (pmReleaseAnnouncement == null) {
  1116. throw new Exception("发布公告不存在");
  1117. }
  1118. Date tenderOpenTime = pmReleaseAnnouncement.getTenderOpenTime();
  1119. Date now = new Date();
  1120. List<PmBidOpening> pmBidOpeningList = pmBidOpeningFillReqVo.getPmBidOpeningList();
  1121. for (PmBidOpening pmBidOpening : pmBidOpeningList) {
  1122. if (ObjectUtils.isEmpty(pmBidOpening.getBidderName())) {
  1123. throw new Exception("投标人名称不能为空");
  1124. }
  1125. if (ObjectUtils.isEmpty(pmBidOpening.getScore())) {
  1126. throw new Exception("分数不能为空");
  1127. }
  1128. pmBidOpening.setOpenBidTime(tenderOpenTime);
  1129. pmBidOpening.setDemandId(pmBidOpeningFillReqVo.getDemandId());
  1130. pmBidOpening.setCreateBy(pmBidOpeningFillReqVo.getCreateBy());
  1131. pmBidOpening.setCreateTime(now);
  1132. pmBidOpening.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1133. pmBidOpening.setUpdateTime(now);
  1134. }
  1135. if (pmBidOpeningService.saveOrUpdateBatch(pmBidOpeningList)) {
  1136. PmDemand pmDemandUpdate = new PmDemand();
  1137. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  1138. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  1139. pmDemandUpdate.setUpdateTime(now);
  1140. pmDemandUpdate.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  1141. return this.updateById(pmDemandUpdate);
  1142. } else {
  1143. return false;
  1144. }
  1145. }
  1146. /**
  1147. * 填写中标
  1148. *
  1149. * @param pmBidWinningReqVo
  1150. * @return
  1151. * @throws Exception
  1152. */
  1153. @Override
  1154. @Transactional(rollbackFor = Exception.class)
  1155. public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1156. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1157. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1158. throw new Exception("中标金额不能为空");
  1159. }
  1160. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1161. throw new Exception("中标单位信息列表不能为空");
  1162. }
  1163. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1164. throw new Exception("上传附件不能为空");
  1165. }
  1166. PmBidWinning pmBidWinning = new PmBidWinning();
  1167. BeanUtils.copyProperties(pmBidWinningReqVo, pmBidWinning);
  1168. //修改老的中标信息状态
  1169. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getId())) { //属于新增
  1170. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1171. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId())
  1172. .eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1173. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  1174. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1175. for (PmBidWinning item : pmBidWinninglist) {
  1176. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1177. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1178. .eq(PmBidWinning::getId, item.getId());
  1179. pmBidWinningService.update(updateWrapper1);
  1180. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1181. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1182. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1183. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1184. pmBidWinningOpeningRefService.update(updateWrapper2);
  1185. }
  1186. }
  1187. }
  1188. if (pmBidWinningService.saveOrUpdate(pmBidWinning)) {
  1189. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1190. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1191. LambdaQueryWrapper<PmBidWinningOpeningRef> pmBidWinningOpeningRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1192. pmBidWinningOpeningRefLambdaQueryWrapper.eq(PmBidWinningOpeningRef::getOpeningId, pmBidOpeningId)
  1193. .eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId());
  1194. PmBidWinningOpeningRef pmBidWinningOpeningRef = pmBidWinningOpeningRefService.getOne(pmBidWinningOpeningRefLambdaQueryWrapper);
  1195. if (pmBidWinningOpeningRef == null) {
  1196. pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1197. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1198. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1199. }
  1200. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1201. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1202. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1203. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1204. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1205. }
  1206. if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
  1207. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
  1208. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1209. PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
  1210. BaseNotice baseNotice = new BaseNotice();
  1211. baseNotice.setName(pmDemand.getProjectName());
  1212. baseNotice.setTitle(pmDemand.getProjectName() + "中标公告");
  1213. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1214. lambdaQueryWrapper.eq(BaseNoticeType::getName, "中标公告");
  1215. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1216. if (baseNoticeType == null) {
  1217. throw new Exception("中标公告 公告类型不存在");
  1218. }
  1219. baseNotice.setDemandId(pmDemand.getDemandId());
  1220. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1221. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1222. baseNotice.setType(baseNoticeType.getId());
  1223. baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
  1224. baseNotice.setCreated(pmBidWinningReqVo.getCreateBy());
  1225. baseNotice.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1226. baseNotice.setUpdated(pmBidWinningReqVo.getUpdateBy());
  1227. baseNotice.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1228. this.baseNoticeService.saveOrUpdate(baseNotice);
  1229. PmDemand pmDemandUpdate = new PmDemand();
  1230. pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
  1231. pmDemandUpdate.setProjectStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1232. pmDemandUpdate.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1233. pmDemandUpdate.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1234. return this.updateById(pmDemandUpdate);
  1235. } else {
  1236. return false;
  1237. }
  1238. } else {
  1239. return false;
  1240. }
  1241. }
  1242. @Override
  1243. @Transactional(rollbackFor = Exception.class)
  1244. public boolean updatePmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1245. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1246. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1247. throw new Exception("中标单位信息列表不能为空");
  1248. }
  1249. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1250. throw new Exception("中标金额不能为空");
  1251. }
  1252. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1253. throw new Exception("上传附件不能为空");
  1254. }
  1255. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1256. lw.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1257. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1258. if (ObjectUtils.isEmpty(pmBidWinninglist)) {
  1259. throw new Exception("原中标信息不存在");
  1260. }
  1261. //修改老的状态
  1262. for (PmBidWinning item : pmBidWinninglist) {
  1263. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1264. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1265. .eq(PmBidWinning::getId, item.getId());
  1266. pmBidWinningService.update(updateWrapper1);
  1267. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1268. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_REPLACED.getCode())
  1269. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1270. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1271. pmBidWinningOpeningRefService.update(updateWrapper2);
  1272. }
  1273. //新增
  1274. PmBidWinning pmBidWinning = new PmBidWinning();
  1275. BeanUtils.copyProperties(pmBidWinninglist.get(0), pmBidWinning);
  1276. pmBidWinning.setId(null);
  1277. pmBidWinning.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
  1278. pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
  1279. pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1280. pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1281. if (pmBidWinningService.save(pmBidWinning)) {
  1282. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1283. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1284. PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1285. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1286. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1287. pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
  1288. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1289. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1290. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1291. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1292. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1293. }
  1294. LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1295. sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType, SysFileRefEnum.PM_BID_WINNING_FILE.getType())
  1296. .eq(SysFileRef::getRedId, pmBidWinninglist.get(0));
  1297. List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
  1298. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
  1299. return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
  1300. } else {
  1301. return false;
  1302. }
  1303. }
  1304. /**
  1305. * 流标
  1306. *
  1307. * @param pmBidFailureReqVo
  1308. * @return
  1309. * @throws Exception
  1310. */
  1311. @Override
  1312. @Transactional(rollbackFor = Exception.class)
  1313. public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
  1314. PmBidFailure pmBidFailure = new PmBidFailure();
  1315. BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
  1316. if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
  1317. //把中标信息修改状态
  1318. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1319. lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus, BidWinningStatus.NORMAL.getCode());
  1320. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1321. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1322. for (PmBidWinning item : pmBidWinninglist) {
  1323. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1324. updateWrapper1.lambda().set(PmBidWinning::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1325. .eq(PmBidWinning::getId, item.getId());
  1326. pmBidWinningService.update(updateWrapper1);
  1327. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1328. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus, BidWinningStatus.BE_BID_FAILURE.getCode())
  1329. .eq(PmBidWinningOpeningRef::getWinningId, item.getId())
  1330. .eq(PmBidWinningOpeningRef::getStatus, BidWinningStatus.NORMAL.getCode());
  1331. pmBidWinningOpeningRefService.update(updateWrapper2);
  1332. }
  1333. }
  1334. uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
  1335. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1336. PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
  1337. BaseNotice baseNotice = new BaseNotice();
  1338. baseNotice.setName(pmDemand.getProjectName());
  1339. baseNotice.setTitle(pmDemand.getProjectName() + "流标公告");
  1340. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1341. lambdaQueryWrapper.eq(BaseNoticeType::getName, "流标公告");
  1342. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1343. if (baseNoticeType == null) {
  1344. throw new Exception("流标公告 公告类型不存在");
  1345. }
  1346. baseNotice.setDemandId(pmDemand.getDemandId());
  1347. baseNotice.setDeptId(pmDemand.getPurchaseDeptId());
  1348. baseNotice.setIsExcess(pmDemand.getIsExcess());
  1349. baseNotice.setType(baseNoticeType.getId());
  1350. baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
  1351. baseNotice.setCreated(pmBidFailureReqVo.getCreateBy());
  1352. baseNotice.setCreateTime(pmBidFailureReqVo.getCreateTime());
  1353. baseNotice.setUpdated(pmBidFailureReqVo.getUpdateBy());
  1354. baseNotice.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1355. this.baseNoticeService.saveOrUpdate(baseNotice);
  1356. PmDemand pmDemandUpdate = new PmDemand();
  1357. pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
  1358. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1359. pmDemandUpdate.setHasExpert("0");
  1360. pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1361. pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
  1362. return this.updateById(pmDemandUpdate);
  1363. } else {
  1364. return false;
  1365. }
  1366. }
  1367. @Override
  1368. @Transactional(rollbackFor = Exception.class)
  1369. public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
  1370. Long demandId = pmContractInfoReqVo.getDemandId();
  1371. if (ObjectUtils.isEmpty(demandId)) {
  1372. throw new Exception("采购需求ID不能为空");
  1373. }
  1374. PmDemand pmDemand = this.getById(demandId);
  1375. if (ObjectUtils.isEmpty(pmDemand)) {
  1376. throw new Exception("采购需求ID错误");
  1377. }
  1378. List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
  1379. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1380. throw new Exception("上传附件不能为空");
  1381. }
  1382. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1383. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  1384. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  1385. if (pmContractInfo != null) {
  1386. pmContractInfoReqVo.setId(pmContractInfo.getId());
  1387. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1388. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1389. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1390. } else {
  1391. pmContractInfo = new PmContractInfo();
  1392. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1393. pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
  1394. pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
  1395. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1396. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1397. }
  1398. if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
  1399. this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
  1400. PmDemand pmDemandUpdate = new PmDemand();
  1401. pmDemandUpdate.setDemandId(demandId);
  1402. pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1403. pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1404. pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1405. return this.updateById(pmDemandUpdate);
  1406. } else {
  1407. return false;
  1408. }
  1409. }
  1410. @Override
  1411. @Transactional(rollbackFor = Exception.class)
  1412. public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
  1413. Long demandId = pmProjectConstructionReqVo.getDemandId();
  1414. if (ObjectUtils.isEmpty(demandId)) {
  1415. throw new Exception("采购需求ID不能为空");
  1416. }
  1417. PmDemand pmDemand = this.getById(demandId);
  1418. if (ObjectUtils.isEmpty(pmDemand)) {
  1419. throw new Exception("采购需求ID错误");
  1420. }
  1421. List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
  1422. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1423. throw new Exception("上传附件不能为空");
  1424. }
  1425. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1426. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  1427. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  1428. if (pmProjectConstruction != null) {
  1429. pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
  1430. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1431. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1432. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1433. } else {
  1434. pmProjectConstruction = new PmProjectConstruction();
  1435. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1436. pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
  1437. pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
  1438. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1439. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1440. }
  1441. if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
  1442. this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
  1443. PmDemand pmDemandUpdate = new PmDemand();
  1444. pmDemandUpdate.setDemandId(demandId);
  1445. pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1446. pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
  1447. pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1448. pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1449. return this.updateById(pmDemandUpdate);
  1450. } else {
  1451. return false;
  1452. }
  1453. }
  1454. /**
  1455. * 更新需求预警状态
  1456. *
  1457. * @param demnadId
  1458. * @return
  1459. */
  1460. @Override
  1461. @Transactional(rollbackFor = Exception.class)
  1462. public void updateDemandWarnStatus(Long demnadId) {
  1463. PmDemand pmDemand = this.getById(demnadId);
  1464. List<SysDictData> data = iSysDictTypeService.selectDictDataByType("alert_time_setting");
  1465. int setting1 = Integer.parseInt(data.stream().filter(item -> item.getDictLabel().equals("计划提报时间")).collect(Collectors.toList()).get(0).getDictValue());
  1466. log.info("******** setting1 == " + setting1);
  1467. //需求提报时间:根据数据阈值中设置的提报时间进行判断,进行预警
  1468. int diff1 = DateUtils.differentDaysByMillisecond(pmDemand.getPlanDemandSubTime(), DateUtils.parseDate(DateUtils.getDate()));
  1469. if (ObjectUtils.isEmpty(pmDemand.getRealDemandCommitTime()) && diff1 >= setting1) {
  1470. PmDemand pmDemandUpdate = new PmDemand();
  1471. pmDemandUpdate.setDemandId(demnadId);
  1472. pmDemandUpdate.setWarnStatus(WarnStatus.DEMAND_COMMT_WARNING.getCode());
  1473. this.updateById(pmDemandUpdate);
  1474. }
  1475. }
  1476. /**
  1477. * 通过需求ID列表 查询采购执行列表 sunhh
  1478. *
  1479. * @param demandIdList
  1480. * @return
  1481. */
  1482. @Override
  1483. public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
  1484. return this.baseMapper.selectByDemandIdList(demandIdList);
  1485. }
  1486. /**
  1487. * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
  1488. *
  1489. * @param baseExpertVo
  1490. * @return
  1491. */
  1492. @Override
  1493. public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
  1494. return this.baseMapper.selectExtractionExpert(baseExpertVo);
  1495. }
  1496. @Override
  1497. public List<PmDemandResVo> demandWaitCommit() {
  1498. return getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  1499. }
  1500. @Override
  1501. public List<PmDemandResVo> contractWaitFilled() {
  1502. return getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  1503. }
  1504. @Override
  1505. public List<PmDemandResVo> projectWaitFinish() {
  1506. return getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1507. }
  1508. @Override
  1509. public List<PmDemandResVo> demandWaitExamine() {
  1510. return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  1511. }
  1512. @Override
  1513. public List<PmDemandResVo> taskWaitRelease() {
  1514. return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  1515. }
  1516. @Override
  1517. public List<PmDemandResVo> waitSelectAgent() {
  1518. return getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  1519. }
  1520. @Override
  1521. public List<PmDemandResVo> waitUpBidFile() {
  1522. return getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode());
  1523. }
  1524. @Override
  1525. public List<PmDemandResVo> waitAnnouncement() {
  1526. return getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1527. }
  1528. @Override
  1529. public List<PmDemandResVo> waitOpenBid() {
  1530. return getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1531. }
  1532. @Override
  1533. public List<PmDemandResVo> waitBidAnnouncement() {
  1534. return getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  1535. }
  1536. @Override
  1537. public List<PmDemandResVo> biddingPublicity() {
  1538. return getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1539. }
  1540. @Override
  1541. public AjaxResult procurementOfficeWillManipulateTotal() {
  1542. List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
  1543. // 待选取代理, 待上传招标文件, 待发布公告, 待开标, 待发布中标公告, 中标公示中
  1544. List<PmDemandResVo> demandRes = new ArrayList<>();
  1545. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode()));
  1546. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode()));
  1547. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode()));
  1548. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode()));
  1549. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode()));
  1550. demandRes.addAll(getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode()));
  1551. //计划数据--发函催告
  1552. List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
  1553. //转为首页table展示数据
  1554. if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
  1555. for (PmDemandResVo demandResVo : demandRes) {
  1556. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1557. home.setEvaluation(BigDecimal.valueOf(demandResVo.getEvaluation()));
  1558. BeanUtils.copyProperties(demandResVo, home);
  1559. homeRes.add(home);
  1560. }
  1561. }
  1562. if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
  1563. for (PlanQuarterResponseVo planVo : planRes) {
  1564. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1565. BeanUtils.copyProperties(planVo, home);
  1566. homeRes.add(home);
  1567. }
  1568. }
  1569. return AjaxResult.success(homeRes);
  1570. }
  1571. /**
  1572. * 统计分析-采购项目信息统计
  1573. *
  1574. * @param pmDemandReqVo
  1575. * @return
  1576. */
  1577. @Override
  1578. public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
  1579. Map<String, Integer> mapReturn = new HashMap<>();
  1580. // 查询项目总数量
  1581. Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
  1582. // 查询已完成项目数量,预算(合同)金额数量
  1583. Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
  1584. // 查询新创建项目数量,预算金额数量
  1585. Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
  1586. // 查询去年完成项目数量,预算(合同)金额数量
  1587. Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
  1588. mapReturn.putAll(mapCount);
  1589. mapReturn.putAll(mapYWC);
  1590. mapReturn.putAll(mapXCJ);
  1591. mapReturn.putAll(mapQNWC);
  1592. return mapReturn;
  1593. }
  1594. @Override
  1595. public List<StatisticalChartsResVo> countByProjectAttr(PmDemandReqVo pmDemandReqVo) {
  1596. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByProjectAttr(pmDemandReqVo);
  1597. for (StatisticalChartsResVo chartsResVo : resVos) {
  1598. for (PmProjectStatus value : PmProjectStatus.values()) {
  1599. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1600. chartsResVo.setColumnName(value.getInfo());
  1601. break;
  1602. }
  1603. }
  1604. }
  1605. return resVos;
  1606. }
  1607. @Override
  1608. public List<StatisticalChartsResVo> countByPurchaseMode(PmDemandReqVo pmDemandReqVo) {
  1609. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByPurchaseMode(pmDemandReqVo);
  1610. for (StatisticalChartsResVo chartsResVo : resVos) {
  1611. for (ProcurementMethodSuggest value : ProcurementMethodSuggest.values()) {
  1612. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1613. chartsResVo.setColumnName(value.getInfo());
  1614. break;
  1615. }
  1616. }
  1617. }
  1618. return resVos;
  1619. }
  1620. @Override
  1621. public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
  1622. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1623. //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
  1624. pmDemandReqVo.setEvaluation(100);
  1625. StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(pmDemandReqVo);
  1626. resVo.setColumnName("100万以下采购任务");
  1627. resVos.add(resVo);
  1628. pmDemandReqVo.setEvaluation(100);
  1629. pmDemandReqVo.setEvaluationEnd(500);
  1630. StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1631. resVo1.setColumnName("100至500万元采购任务");
  1632. resVos.add(resVo1);
  1633. pmDemandReqVo.setEvaluation(500);
  1634. pmDemandReqVo.setEvaluationEnd(1000);
  1635. StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1636. resVo2.setColumnName("500至1000万元采购任务");
  1637. resVos.add(resVo2);
  1638. pmDemandReqVo.setEvaluation(1000);
  1639. pmDemandReqVo.setEvaluationEnd(5000);
  1640. StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1641. resVo3.setColumnName("1000至5000万元采购任务");
  1642. resVos.add(resVo3);
  1643. pmDemandReqVo.setEvaluation(5000);
  1644. pmDemandReqVo.setEvaluationEnd(10000);
  1645. StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(pmDemandReqVo);
  1646. resVo4.setColumnName("5000至1亿元采购任务");
  1647. resVos.add(resVo4);
  1648. pmDemandReqVo.setEvaluation(10000);
  1649. StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(pmDemandReqVo);
  1650. resVo5.setColumnName("1亿元及以上采购任务");
  1651. resVos.add(resVo5);
  1652. return resVos;
  1653. }
  1654. @Override
  1655. public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
  1656. HashMap<String, String> resMap = new HashMap<>();
  1657. //执行滞后采购项目:本年度所有的逾期项目数
  1658. //预算金额:本年度所有逾期项目累加的预算金额
  1659. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceed(pmDemandReqVo);
  1660. resMap.put("执行滞后采购项目", resVo.getNum());
  1661. resMap.put("预算金额", resVo.getEvaluationTotal());
  1662. //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
  1663. Integer thisYear = pmDemandMapper.countThisYear(pmDemandReqVo);
  1664. resMap.put("滞后项目数量占比", getPercent(Integer.parseInt(resVo.getNum()), thisYear));
  1665. return AjaxResult.success(resMap);
  1666. }
  1667. /**
  1668. * 统计不同时间维度的逾期项目
  1669. *
  1670. * @return
  1671. */
  1672. @Override
  1673. public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
  1674. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1675. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear(pmDemandReqVo);
  1676. if (pmDemandReqVo.getTimeType().equals("1")) {
  1677. resMap.put("年", byYear);
  1678. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1679. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1680. for (StatisticalChartsResVo chartsResVo : byYear) {
  1681. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  1682. for (int i = 1; i <= 4; i++) {
  1683. pmDemandReqVo.setQuarter(i);
  1684. StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(pmDemandReqVo);
  1685. if (ObjectUtils.isEmpty(quarter)) {
  1686. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "0", "0");
  1687. quarter = vo;
  1688. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1689. }
  1690. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1691. byQuarter.add(quarter);
  1692. }
  1693. }
  1694. resMap.put("季度", byQuarter);
  1695. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1696. List<StatisticalChartsResVo> byMonth = new LinkedList<>();
  1697. for (StatisticalChartsResVo chartsResVo : byYear) {
  1698. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  1699. for (int i = 1; i <= 12; i++) {
  1700. pmDemandReqVo.setMonth(i);
  1701. StatisticalChartsResVo month = pmDemandMapper.countProjectExceedMonth(pmDemandReqVo);
  1702. if (ObjectUtils.isEmpty(month)) {
  1703. StatisticalChartsResVo vo = new StatisticalChartsResVo("", "0", "0");
  1704. month = vo;
  1705. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  1706. }
  1707. month.setColumnName(chartsResVo.getColumnName() + "年" + i + "月");
  1708. byMonth.add(month);
  1709. }
  1710. }
  1711. resMap.put("月", byMonth);
  1712. }
  1713. return AjaxResult.success(resMap);
  1714. }
  1715. @Override
  1716. public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
  1717. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1718. //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
  1719. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear();
  1720. if (pmDemandReqVo.getTimeType().equals("1")) {
  1721. resMap.put("年", byYear);
  1722. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1723. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1724. for (StatisticalChartsResVo chartsResVo : byYear) {
  1725. pmDemandReqVo.setYear(Integer.parseInt(chartsResVo.getColumnName()));
  1726. for (int i = 1; i <= 4; i++) {
  1727. pmDemandReqVo.setQuarter(i);
  1728. StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(pmDemandReqVo);
  1729. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1730. byQuarter.add(quarter);
  1731. }
  1732. }
  1733. resMap.put("季度", byQuarter);
  1734. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1735. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth(pmDemandReqVo);
  1736. resMap.put("月", byMonth);
  1737. }
  1738. return AjaxResult.success(resMap);
  1739. }
  1740. @Override
  1741. public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
  1742. //指项目进行到各个阶段的数量
  1743. //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
  1744. List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum(pmDemandReqVo);
  1745. if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
  1746. for (StatisticalChartsResVo vo : everyStatusNum) {
  1747. switch (vo.getColumnName()) {
  1748. case "9":
  1749. vo.setColumnName(PmProjectStatus.WAIT_SELECT_AGENT.getInfo());
  1750. break;
  1751. case "10":
  1752. vo.setColumnName(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getInfo());
  1753. break;
  1754. case "11":
  1755. vo.setColumnName(PmProjectStatus.WAIT_ANNOUNCEMENT.getInfo());
  1756. break;
  1757. case "12":
  1758. vo.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
  1759. break;
  1760. case "13":
  1761. vo.setColumnName(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getInfo());
  1762. break;
  1763. case "14":
  1764. vo.setColumnName(PmProjectStatus.BIDDING_PUBLICITY.getInfo());
  1765. break;
  1766. default: {
  1767. }
  1768. }
  1769. }
  1770. }
  1771. return AjaxResult.success(everyStatusNum);
  1772. }
  1773. @Override
  1774. public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
  1775. //所有滞后
  1776. List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll(pmDemandReqVo);
  1777. //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
  1778. HashMap<String, Integer> map = new LinkedHashMap<>();
  1779. map.put("滞后1个月以内的采购任务", 0);
  1780. map.put("滞后1至3个月采购任务", 0);
  1781. map.put("滞后3至6个月采购任务", 0);
  1782. map.put("滞后6个月至1年采购任务", 0);
  1783. map.put("滞后1年以上采购任务", 0);
  1784. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1785. for (PmDemand demand : demandList) {
  1786. //滞后时间
  1787. Long exTime = null;
  1788. if (!ObjectUtils.isEmpty(demand.getRealDemandCommitTime()) && demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime() > 0) {
  1789. exTime = demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime();
  1790. } else if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
  1791. exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
  1792. } else if (!ObjectUtils.isEmpty(demand.getRealDeliverTime()) && demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime() > 0) {
  1793. exTime = demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime();
  1794. }
  1795. if (exTime < Long.valueOf("2592000000")) {
  1796. map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
  1797. }
  1798. if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
  1799. map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
  1800. }
  1801. if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
  1802. map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
  1803. }
  1804. if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
  1805. map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
  1806. }
  1807. if (exTime > Long.valueOf("31104000000")) {
  1808. map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
  1809. }
  1810. }
  1811. }
  1812. return AjaxResult.success(map);
  1813. }
  1814. @Override
  1815. public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
  1816. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1817. //数量:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目数
  1818. //预算金额:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目累加的预算金额
  1819. StatisticalChartsResVo resVo = new StatisticalChartsResVo();
  1820. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode()));
  1821. resVo = pmDemandMapper.majorProjectByStatus(pmDemandReqVo);
  1822. resVo.setColumnName("今年已完成数量");
  1823. resVos.add(resVo);
  1824. //正常推进项目:指本年度正在进行中的项目属性为“重大规划”的项目数
  1825. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1826. StatisticalChartsResVo resVo1 = new StatisticalChartsResVo();
  1827. pmDemandReqVo.setProjectStatus(Long.valueOf(PmProjectStatus.UNDER_CONSTRUCTION.getCode()));
  1828. resVo1 = pmDemandMapper.majorProjectByStatus(pmDemandReqVo);
  1829. resVo1.setColumnName("正常推进数量");
  1830. resVos.add(resVo1);
  1831. //执行滞后数量:指本年度逾期项目中,项目属性为“重大规划”的项目数
  1832. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1833. StatisticalChartsResVo resVo2 = new StatisticalChartsResVo();
  1834. resVo2 = pmDemandMapper.countMajorProjectExceed(pmDemandReqVo);
  1835. resVo2.setColumnName("执行滞后数量");
  1836. resVos.add(resVo2);
  1837. //上年度重大规划采购任务数量:指上年度项目中,项目属性为“重大规划”的项目数
  1838. //预算金额:指上年度项目中,项目属性为“重大规划”的项目累加的预算(合同)金额
  1839. StatisticalChartsResVo resVo3 = new StatisticalChartsResVo();
  1840. resVo3 = pmDemandMapper.countMajorProjectLastYear(pmDemandReqVo);
  1841. resVo3.setColumnName("上年度重大规划采购任务数量");
  1842. resVos.add(resVo3);
  1843. //resVo2=pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1844. return AjaxResult.success(resVos);
  1845. }
  1846. /**
  1847. * 通过计划ID查询项目数据
  1848. *
  1849. * @param planId
  1850. * @return
  1851. */
  1852. @Override
  1853. public PmDemand selectByPlanId(Long planId) {
  1854. return pmDemandMapper.selectByPlanId(planId);
  1855. }
  1856. /**
  1857. * 项目执行进度统计
  1858. * 1、正常推进项目数量:指未完成并且没有逾期的项目
  1859. * 预算金额:指未完成并且没有逾期的项目累加的预算金额
  1860. * 2、未完成采购任务:“合同待填制”状态之前的项目
  1861. * 预算金额:“合同待填制”状态之前的项目累加的预算金额
  1862. *
  1863. * @param pmDemandReqVo
  1864. * @return
  1865. */
  1866. @Override
  1867. public Map<String, Integer> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
  1868. Map<String, Integer> mapReturn = new HashMap<>();
  1869. // 正常推进项目数量、预算金额
  1870. Map<String, Integer> mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
  1871. // 未完成采购任务,预算金额
  1872. Map<String, Integer> mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
  1873. mapReturn.putAll(mapNormalPropulsion);
  1874. mapReturn.putAll(mapIncomplete);
  1875. return mapReturn;
  1876. }
  1877. /**
  1878. * 已完成项目数量统计
  1879. *
  1880. * @param pmDemandReqVo
  1881. * @return
  1882. */
  1883. @Override
  1884. public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
  1885. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1886. // 统计时间类型 1:年度,2:季度,3:月份
  1887. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1888. // 查询数据库中最小的年份
  1889. int minYear = pmDemandMapper.selectMinYear();
  1890. // 获取当前年份
  1891. Calendar calendar = Calendar.getInstance();
  1892. int year = calendar.get(Calendar.YEAR);
  1893. // 获取统计数据
  1894. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
  1895. mapReturn.addAll(listMap);
  1896. for (int i = minYear; i <= year; i++) {
  1897. boolean isYear = false;
  1898. for (Map<String, Integer> map : listMap) {
  1899. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1900. isYear = true;
  1901. }
  1902. }
  1903. if (!isYear) {
  1904. Map<String, Integer> map1 = new HashMap<>();
  1905. map1.put("yy", i);
  1906. map1.put("evaluation", 0);
  1907. map1.put("contractAmount", 0);
  1908. map1.put("countNum", 0);
  1909. mapReturn.add(map1);
  1910. }
  1911. }
  1912. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1913. // 当前年份季度统计
  1914. // 获取统计数据
  1915. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
  1916. mapReturn.addAll(listMap);
  1917. for (int i = 1; i <= 4; i++) {
  1918. boolean isYear = false;
  1919. for (Map<String, Integer> map : listMap) {
  1920. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1921. isYear = true;
  1922. }
  1923. }
  1924. if (!isYear) {
  1925. Map<String, Integer> map1 = new HashMap<>();
  1926. map1.put("yy", i);
  1927. map1.put("evaluation", 0);
  1928. map1.put("contractAmount", 0);
  1929. map1.put("countNum", 0);
  1930. mapReturn.add(map1);
  1931. }
  1932. }
  1933. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1934. // 当前年份月份统计
  1935. // 获取统计数据
  1936. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
  1937. mapReturn.addAll(listMap);
  1938. for (int i = 1; i <= 12; i++) {
  1939. boolean isYear = false;
  1940. for (Map<String, Integer> map : listMap) {
  1941. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1942. isYear = true;
  1943. }
  1944. }
  1945. if (!isYear) {
  1946. Map<String, Integer> map1 = new HashMap<>();
  1947. map1.put("yy", i);
  1948. map1.put("evaluation", 0);
  1949. map1.put("contractAmount", 0);
  1950. map1.put("countNum", 0);
  1951. mapReturn.add(map1);
  1952. }
  1953. }
  1954. }
  1955. return mapReturn;
  1956. }
  1957. /**
  1958. * 已完成采购任务数量统计
  1959. *
  1960. * @param pmDemandReqVo
  1961. * @return
  1962. */
  1963. @Override
  1964. public List<Map<String, Integer>> purchaseTaskFinish(PmDemandReqVo pmDemandReqVo) {
  1965. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1966. // 统计时间类型 1:年度,2:季度,3:月份
  1967. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1968. // 查询数据库中最小的年份
  1969. int minYear = pmDemandMapper.selectMinYear();
  1970. // 获取当前年份
  1971. Calendar calendar = Calendar.getInstance();
  1972. int year = calendar.get(Calendar.YEAR);
  1973. // 获取统计数据
  1974. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishYear(pmDemandReqVo);
  1975. mapReturn.addAll(listMap);
  1976. for (int i = minYear; i <= year; i++) {
  1977. boolean isYear = false;
  1978. for (Map<String, Integer> map : listMap) {
  1979. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  1980. isYear = true;
  1981. }
  1982. }
  1983. if (!isYear) {
  1984. Map<String, Integer> map1 = new HashMap<>();
  1985. map1.put("yy", i);
  1986. map1.put("evaluation", 0);
  1987. map1.put("contractAmount", 0);
  1988. map1.put("countNum", 0);
  1989. mapReturn.add(map1);
  1990. }
  1991. }
  1992. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1993. // 当前年份季度统计
  1994. // 获取统计数据
  1995. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishQuarter(pmDemandReqVo);
  1996. mapReturn.addAll(listMap);
  1997. for (int i = 1; i <= 4; i++) {
  1998. boolean isYear = false;
  1999. for (Map<String, Integer> map : listMap) {
  2000. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2001. isYear = true;
  2002. }
  2003. }
  2004. if (!isYear) {
  2005. Map<String, Integer> map1 = new HashMap<>();
  2006. map1.put("yy", i);
  2007. map1.put("evaluation", 0);
  2008. map1.put("contractAmount", 0);
  2009. map1.put("countNum", 0);
  2010. mapReturn.add(map1);
  2011. }
  2012. }
  2013. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2014. // 当前年份月份统计
  2015. // 获取统计数据
  2016. List<Map<String, Integer>> listMap = pmDemandMapper.selectPurchaseTaskFinishMonth(pmDemandReqVo);
  2017. mapReturn.addAll(listMap);
  2018. for (int i = 1; i <= 12; i++) {
  2019. boolean isYear = false;
  2020. for (Map<String, Integer> map : listMap) {
  2021. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2022. isYear = true;
  2023. }
  2024. }
  2025. if (!isYear) {
  2026. Map<String, Integer> map1 = new HashMap<>();
  2027. map1.put("yy", i);
  2028. map1.put("evaluation", 0);
  2029. map1.put("contractAmount", 0);
  2030. map1.put("countNum", 0);
  2031. mapReturn.add(map1);
  2032. }
  2033. }
  2034. }
  2035. return mapReturn;
  2036. }
  2037. /**
  2038. * 各阶段项目数量分布
  2039. *
  2040. * @param pmDemandReqVo
  2041. * @return
  2042. */
  2043. @Override
  2044. public List<Map<String, String>> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo) {
  2045. // 项目计划 4之前(包括4)
  2046. List<String> xmjh = new ArrayList<>();
  2047. xmjh.add("4");
  2048. pmDemandReqVo.setProjectStatusList(xmjh);
  2049. Map<String, String> returnMapxmjh = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2050. returnMapxmjh.put("name", "计划管理");
  2051. // 需求建党 4之后(不包括4)
  2052. List<String> xqjd = new ArrayList<>();
  2053. xqjd.add("5");
  2054. xqjd.add("6");
  2055. xqjd.add("7");
  2056. xqjd.add("8");
  2057. pmDemandReqVo.setProjectStatusList(xqjd);
  2058. Map<String, String> returnMapxqjd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2059. returnMapxqjd.put("name", "需求管理");
  2060. // 任务下达 8之后(不包括8)
  2061. List<String> rwxd = new ArrayList<>();
  2062. rwxd.add("9");
  2063. pmDemandReqVo.setProjectStatusList(rwxd);
  2064. Map<String, String> returnMaprwxd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2065. returnMaprwxd.put("name", "任务下达");
  2066. // 采购执行 9之后(不包括9)
  2067. List<String> cgzx = new ArrayList<>();
  2068. cgzx.add("10");
  2069. cgzx.add("11");
  2070. cgzx.add("12");
  2071. cgzx.add("13");
  2072. cgzx.add("14");
  2073. cgzx.add("15");
  2074. pmDemandReqVo.setProjectStatusList(cgzx);
  2075. Map<String, String> returnMapcgzx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2076. returnMapcgzx.put("name", "采购执行");
  2077. // 合同管理 15之后(不包括15)
  2078. List<String> htxx = new ArrayList<>();
  2079. htxx.add("16");
  2080. pmDemandReqVo.setProjectStatusList(htxx);
  2081. Map<String, String> returnMaphtxx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2082. returnMaphtxx.put("name", "合同管理");
  2083. // 项目建设 17
  2084. List<String> xmjs = new ArrayList<>();
  2085. xmjs.add("16");
  2086. pmDemandReqVo.setProjectStatusList(xmjs);
  2087. Map<String, String> returnMapxmjs = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  2088. returnMapxmjs.put("name", "合同管理");
  2089. List<Map<String, String>> returnMap = new ArrayList<>();
  2090. returnMap.add(returnMapxmjh);
  2091. returnMap.add(returnMapxqjd);
  2092. returnMap.add(returnMaprwxd);
  2093. returnMap.add(returnMapcgzx);
  2094. returnMap.add(returnMaphtxx);
  2095. returnMap.add(returnMapxmjs);
  2096. return returnMap;
  2097. }
  2098. /**
  2099. * 项目数量分析---------年度的同比和环比不展示-----------
  2100. *
  2101. * @param pmDemandReqVo
  2102. * @return
  2103. */
  2104. @Override
  2105. public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
  2106. List<Map<String, String>> mapReturn = new ArrayList<>();
  2107. // 统计时间类型 1:年度,2:季度,3:月份
  2108. if ("1".equals(pmDemandReqVo.getTimeType())) {
  2109. // 查询数据库中最小的年份
  2110. int minYear = pmDemandMapper.selectMinYear();
  2111. // 获取当前年份
  2112. Calendar calendar = Calendar.getInstance();
  2113. int year = calendar.get(Calendar.YEAR);
  2114. // 获取统计数据
  2115. // 获取项目统计
  2116. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
  2117. mapReturn.addAll(listMap);
  2118. for (int i = minYear; i <= year; i++) {
  2119. boolean isYear = false;
  2120. for (Map<String, String> map : listMap) {
  2121. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2122. isYear = true;
  2123. }
  2124. }
  2125. if (!isYear) {
  2126. Map<String, String> map1 = new HashMap<>();
  2127. map1.put("yy", i + "");
  2128. map1.put("countNum", 0 + "");
  2129. map1.put("evaluationSum", 0 + "");
  2130. mapReturn.add(map1);
  2131. }
  2132. }
  2133. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  2134. // 当前年份季度统计
  2135. // 获取统计数据
  2136. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
  2137. List<Map<String, String>> mapList = new ArrayList<>();
  2138. mapList.addAll(listMap);
  2139. for (int i = 1; i <= 4; i++) {
  2140. boolean isYear = false;
  2141. for (Map<String, String> map : listMap) {
  2142. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2143. isYear = true;
  2144. }
  2145. }
  2146. if (!isYear) {
  2147. Map<String, String> map1 = new HashMap<>();
  2148. map1.put("yy", i + "");
  2149. map1.put("countNum", 0 + "");
  2150. map1.put("evaluationSum", 0 + "");
  2151. mapList.add(map1);
  2152. }
  2153. }
  2154. Map<String, String> map1 = new HashMap<>();
  2155. Map<String, String> map2 = new HashMap<>();
  2156. Map<String, String> map3 = new HashMap<>();
  2157. Map<String, String> map4 = new HashMap<>();
  2158. for (Map<String, String> map : mapList) {
  2159. String yy = String.valueOf(map.get("yy"));
  2160. if ("1".equals(yy)) {
  2161. map1.putAll(map);
  2162. } else if ("2".equals(yy)) {
  2163. map2.putAll(map);
  2164. } else if ("3".equals(yy)) {
  2165. map3.putAll(map);
  2166. } else if ("4".equals(yy)) {
  2167. map4.putAll(map);
  2168. }
  2169. }
  2170. String countNum1 = String.valueOf(map1.get("countNum"));
  2171. String countNum2 = String.valueOf(map2.get("countNum"));
  2172. String countNum3 = String.valueOf(map3.get("countNum"));
  2173. String countNum4 = String.valueOf(map4.get("countNum"));
  2174. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  2175. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  2176. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  2177. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  2178. // 查询上一年四季度数据
  2179. List<Map<String, String>> listMapOldYear = pmDemandMapper.purchaseProjectNumberAnalysisOldYearQuarter(pmDemandReqVo);
  2180. List<Map<String, String>> mapListOld = new ArrayList<>();
  2181. mapListOld.addAll(listMapOldYear);
  2182. for (int i = 1; i <= 4; i++) {
  2183. boolean isYear = false;
  2184. for (Map<String, String> map : listMapOldYear) {
  2185. if (i == Integer.parseInt(String.valueOf(map.get("yy")))) {
  2186. isYear = true;
  2187. }
  2188. }
  2189. if (!isYear) {
  2190. Map<String, String> map11 = new HashMap<>();
  2191. map11.put("yy", i + "");
  2192. map11.put("countNum", 0 + "");
  2193. map11.put("evaluationSum", 0 + "");
  2194. mapListOld.add(map11);
  2195. }
  2196. }
  2197. Map<String, String> mapOld1 = new HashMap<>();
  2198. Map<String, String> mapOld2 = new HashMap<>();
  2199. Map<String, String> mapOld3 = new HashMap<>();
  2200. Map<String, String> mapOld4 = new HashMap<>();
  2201. for (Map<String, String> mapOld : mapListOld) {
  2202. String yy = String.valueOf(mapOld.get("yy"));
  2203. if ("1".equals(yy)) {
  2204. mapOld1.putAll(mapOld);
  2205. } else if ("2".equals(yy)) {
  2206. mapOld2.putAll(mapOld);
  2207. } else if ("3".equals(yy)) {
  2208. mapOld3.putAll(mapOld);
  2209. } else if ("4".equals(yy)) {
  2210. mapOld4.putAll(mapOld);
  2211. }
  2212. }
  2213. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  2214. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  2215. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  2216. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  2217. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  2218. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  2219. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  2220. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  2221. BigDecimal countNum11 = new BigDecimal(countNum1);
  2222. BigDecimal countNum22 = new BigDecimal(countNum2);
  2223. BigDecimal countNum33 = new BigDecimal(countNum3);
  2224. BigDecimal countNum44 = new BigDecimal(countNum4);
  2225. BigDecimal countNumOld11 = new BigDecimal(countNumOld1);
  2226. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  2227. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  2228. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  2229. BigDecimal evaluationSum11 = new BigDecimal(evaluationSum1);
  2230. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  2231. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  2232. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  2233. BigDecimal evaluationSumOld11 = new BigDecimal(evaluationSumOld1);
  2234. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  2235. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  2236. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  2237. // 项目数量环比 对比
  2238. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  2239. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  2240. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  2241. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  2242. if (!"0".equals(countNumOld4)) {
  2243. monthonmonthNum1 = (countNum11.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2244. }
  2245. if (!"0".equals(countNum1)) {
  2246. monthonmonthNum2 = (countNum22.subtract(countNum11)).divide(countNum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2247. }
  2248. if (!"0".equals(countNum2)) {
  2249. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2250. }
  2251. if (!"0".equals(countNum3)) {
  2252. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2253. }
  2254. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  2255. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  2256. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  2257. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  2258. // 项目数量同比 对比
  2259. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  2260. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  2261. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  2262. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  2263. if (!"0".equals(countNumOld1)) {
  2264. yearonyearNum1 = (countNum11.subtract(countNumOld11)).divide(countNumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2265. }
  2266. if (!"0".equals(countNumOld2)) {
  2267. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2268. }
  2269. if (!"0".equals(countNumOld3)) {
  2270. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2271. }
  2272. if (!"0".equals(countNumOld4)) {
  2273. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2274. }
  2275. map1.put("yearonyearNum", yearonyearNum1.toString());
  2276. map2.put("yearonyearNum", yearonyearNum2.toString());
  2277. map3.put("yearonyearNum", yearonyearNum3.toString());
  2278. map4.put("yearonyearNum", yearonyearNum4.toString());
  2279. // 预算金额环比 对比
  2280. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  2281. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  2282. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  2283. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  2284. if (!"0".equals(evaluationSumOld4)) {
  2285. monthonmonthAmount1 = (evaluationSum11.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2286. }
  2287. if (!"0".equals(evaluationSum1)) {
  2288. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum11)).divide(evaluationSum11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2289. }
  2290. if (!"0".equals(evaluationSum2)) {
  2291. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2292. }
  2293. if (!"0".equals(evaluationSum3)) {
  2294. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2295. }
  2296. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  2297. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  2298. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  2299. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  2300. // 预算金额同比比 对比
  2301. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  2302. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  2303. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  2304. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  2305. if (!"0".equals(evaluationSumOld1)) {
  2306. yearonyearAmount1 = (evaluationSum11.subtract(evaluationSumOld11)).divide(evaluationSumOld11, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2307. }
  2308. if (!"0".equals(evaluationSumOld2)) {
  2309. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2310. }
  2311. if (!"0".equals(evaluationSumOld3)) {
  2312. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2313. }
  2314. if (!"0".equals(evaluationSumOld4)) {
  2315. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2316. }
  2317. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  2318. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  2319. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  2320. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  2321. // 存入集合
  2322. mapReturn.add(map1);
  2323. mapReturn.add(map2);
  2324. mapReturn.add(map3);
  2325. mapReturn.add(map4);
  2326. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  2327. // 当前年份月份统计
  2328. // 获取统计数据
  2329. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
  2330. List<Map<String, String>> mapList = new ArrayList<>();
  2331. mapList.addAll(listMap);
  2332. for (int i = 1; i <= 12; i++) {
  2333. boolean isYear = false;
  2334. for (Map<String, String> map : listMap) {
  2335. String yy = String.valueOf(map.get("yy"));
  2336. String yyNew = yy.replaceAll("^0*", "");
  2337. if (i == Integer.valueOf(yyNew)) {
  2338. isYear = true;
  2339. }
  2340. }
  2341. if (!isYear) {
  2342. Map<String, String> map1 = new HashMap<>();
  2343. String yy = String.format("%02d", i);
  2344. map1.put("yy", yy);
  2345. map1.put("countNum", 0 + "");
  2346. map1.put("evaluationSum", 0 + "");
  2347. mapList.add(map1);
  2348. }
  2349. }
  2350. Map<String, String> map1 = new HashMap<>();
  2351. Map<String, String> map2 = new HashMap<>();
  2352. Map<String, String> map3 = new HashMap<>();
  2353. Map<String, String> map4 = new HashMap<>();
  2354. Map<String, String> map5 = new HashMap<>();
  2355. Map<String, String> map6 = new HashMap<>();
  2356. Map<String, String> map7 = new HashMap<>();
  2357. Map<String, String> map8 = new HashMap<>();
  2358. Map<String, String> map9 = new HashMap<>();
  2359. Map<String, String> map10 = new HashMap<>();
  2360. Map<String, String> map11 = new HashMap<>();
  2361. Map<String, String> map12 = new HashMap<>();
  2362. for (Map<String, String> map : mapList) {
  2363. String yy = String.valueOf(map.get("yy"));
  2364. if ("01".equals(yy)) {
  2365. map1.putAll(map);
  2366. } else if ("02".equals(yy)) {
  2367. map2.putAll(map);
  2368. } else if ("03".equals(yy)) {
  2369. map3.putAll(map);
  2370. } else if ("04".equals(yy)) {
  2371. map4.putAll(map);
  2372. } else if ("05".equals(yy)) {
  2373. map5.putAll(map);
  2374. } else if ("06".equals(yy)) {
  2375. map6.putAll(map);
  2376. } else if ("07".equals(yy)) {
  2377. map7.putAll(map);
  2378. } else if ("08".equals(yy)) {
  2379. map8.putAll(map);
  2380. } else if ("09".equals(yy)) {
  2381. map9.putAll(map);
  2382. } else if ("10".equals(yy)) {
  2383. map10.putAll(map);
  2384. } else if ("11".equals(yy)) {
  2385. map11.putAll(map);
  2386. } else if ("12".equals(yy)) {
  2387. map12.putAll(map);
  2388. }
  2389. }
  2390. String countNum1 = String.valueOf(map1.get("countNum"));
  2391. String countNum2 = String.valueOf(map2.get("countNum"));
  2392. String countNum3 = String.valueOf(map3.get("countNum"));
  2393. String countNum4 = String.valueOf(map4.get("countNum"));
  2394. String countNum5 = String.valueOf(map5.get("countNum"));
  2395. String countNum6 = String.valueOf(map6.get("countNum"));
  2396. String countNum7 = String.valueOf(map7.get("countNum"));
  2397. String countNum8 = String.valueOf(map8.get("countNum"));
  2398. String countNum9 = String.valueOf(map9.get("countNum"));
  2399. String countNum10 = String.valueOf(map10.get("countNum"));
  2400. String countNum11 = String.valueOf(map11.get("countNum"));
  2401. String countNum12 = String.valueOf(map12.get("countNum"));
  2402. String evaluationSum1 = String.valueOf(map1.get("evaluationSum"));
  2403. String evaluationSum2 = String.valueOf(map2.get("evaluationSum"));
  2404. String evaluationSum3 = String.valueOf(map3.get("evaluationSum"));
  2405. String evaluationSum4 = String.valueOf(map4.get("evaluationSum"));
  2406. String evaluationSum5 = String.valueOf(map5.get("evaluationSum"));
  2407. String evaluationSum6 = String.valueOf(map6.get("evaluationSum"));
  2408. String evaluationSum7 = String.valueOf(map7.get("evaluationSum"));
  2409. String evaluationSum8 = String.valueOf(map8.get("evaluationSum"));
  2410. String evaluationSum9 = String.valueOf(map9.get("evaluationSum"));
  2411. String evaluationSum10 = String.valueOf(map10.get("evaluationSum"));
  2412. String evaluationSum11 = String.valueOf(map11.get("evaluationSum"));
  2413. String evaluationSum12 = String.valueOf(map12.get("evaluationSum"));
  2414. // 查询上一年月份数据
  2415. List<Map<String, String>> listMapOldMonth = pmDemandMapper.purchaseProjectNumberAnalysisOldYearMonth(pmDemandReqVo);
  2416. List<Map<String, String>> mapListOld = new ArrayList<>();
  2417. mapListOld.addAll(listMapOldMonth);
  2418. for (int i = 1; i <= 12; i++) {
  2419. boolean isYear = false;
  2420. for (Map<String, String> map : listMapOldMonth) {
  2421. String yy = String.valueOf(map.get("yy"));
  2422. String yyNew = yy.replaceAll("^0*", "");
  2423. if (i == Integer.valueOf(yyNew)) {
  2424. isYear = true;
  2425. }
  2426. }
  2427. if (!isYear) {
  2428. Map<String, String> map111 = new HashMap<>();
  2429. String yy = String.format("%02d", i);
  2430. map111.put("yy", yy);
  2431. map111.put("countNum", 0 + "");
  2432. map111.put("evaluationSum", 0 + "");
  2433. mapListOld.add(map111);
  2434. }
  2435. }
  2436. Map<String, String> mapOld1 = new HashMap<>();
  2437. Map<String, String> mapOld2 = new HashMap<>();
  2438. Map<String, String> mapOld3 = new HashMap<>();
  2439. Map<String, String> mapOld4 = new HashMap<>();
  2440. Map<String, String> mapOld5 = new HashMap<>();
  2441. Map<String, String> mapOld6 = new HashMap<>();
  2442. Map<String, String> mapOld7 = new HashMap<>();
  2443. Map<String, String> mapOld8 = new HashMap<>();
  2444. Map<String, String> mapOld9 = new HashMap<>();
  2445. Map<String, String> mapOld10 = new HashMap<>();
  2446. Map<String, String> mapOld11 = new HashMap<>();
  2447. Map<String, String> mapOld12 = new HashMap<>();
  2448. for (Map<String, String> mapOld : mapListOld) {
  2449. String yy = String.valueOf(mapOld.get("yy"));
  2450. if ("01".equals(yy)) {
  2451. mapOld1.putAll(mapOld);
  2452. } else if ("02".equals(yy)) {
  2453. mapOld2.putAll(mapOld);
  2454. } else if ("03".equals(yy)) {
  2455. mapOld3.putAll(mapOld);
  2456. } else if ("04".equals(yy)) {
  2457. mapOld4.putAll(mapOld);
  2458. } else if ("05".equals(yy)) {
  2459. mapOld5.putAll(mapOld);
  2460. } else if ("06".equals(yy)) {
  2461. mapOld6.putAll(mapOld);
  2462. } else if ("07".equals(yy)) {
  2463. mapOld7.putAll(mapOld);
  2464. } else if ("08".equals(yy)) {
  2465. mapOld8.putAll(mapOld);
  2466. } else if ("09".equals(yy)) {
  2467. mapOld9.putAll(mapOld);
  2468. } else if ("10".equals(yy)) {
  2469. mapOld10.putAll(mapOld);
  2470. } else if ("11".equals(yy)) {
  2471. mapOld11.putAll(mapOld);
  2472. } else if ("12".equals(yy)) {
  2473. mapOld12.putAll(mapOld);
  2474. }
  2475. }
  2476. String countNumOld1 = String.valueOf(mapOld1.get("countNum"));
  2477. String countNumOld2 = String.valueOf(mapOld2.get("countNum"));
  2478. String countNumOld3 = String.valueOf(mapOld3.get("countNum"));
  2479. String countNumOld4 = String.valueOf(mapOld4.get("countNum"));
  2480. String countNumOld5 = String.valueOf(mapOld5.get("countNum"));
  2481. String countNumOld6 = String.valueOf(mapOld6.get("countNum"));
  2482. String countNumOld7 = String.valueOf(mapOld7.get("countNum"));
  2483. String countNumOld8 = String.valueOf(mapOld8.get("countNum"));
  2484. String countNumOld9 = String.valueOf(mapOld9.get("countNum"));
  2485. String countNumOld10 = String.valueOf(mapOld10.get("countNum"));
  2486. String countNumOld11 = String.valueOf(mapOld11.get("countNum"));
  2487. String countNumOld12 = String.valueOf(mapOld12.get("countNum"));
  2488. String evaluationSumOld1 = String.valueOf(mapOld1.get("evaluationSum"));
  2489. String evaluationSumOld2 = String.valueOf(mapOld2.get("evaluationSum"));
  2490. String evaluationSumOld3 = String.valueOf(mapOld3.get("evaluationSum"));
  2491. String evaluationSumOld4 = String.valueOf(mapOld4.get("evaluationSum"));
  2492. String evaluationSumOld5 = String.valueOf(mapOld5.get("evaluationSum"));
  2493. String evaluationSumOld6 = String.valueOf(mapOld6.get("evaluationSum"));
  2494. String evaluationSumOld7 = String.valueOf(mapOld7.get("evaluationSum"));
  2495. String evaluationSumOld8 = String.valueOf(mapOld8.get("evaluationSum"));
  2496. String evaluationSumOld9 = String.valueOf(mapOld9.get("evaluationSum"));
  2497. String evaluationSumOld10 = String.valueOf(mapOld10.get("evaluationSum"));
  2498. String evaluationSumOld11 = String.valueOf(mapOld11.get("evaluationSum"));
  2499. String evaluationSumOld12 = String.valueOf(mapOld12.get("evaluationSum"));
  2500. BigDecimal countNum111 = new BigDecimal(countNum1);
  2501. BigDecimal countNum22 = new BigDecimal(countNum2);
  2502. BigDecimal countNum33 = new BigDecimal(countNum3);
  2503. BigDecimal countNum44 = new BigDecimal(countNum4);
  2504. BigDecimal countNum55 = new BigDecimal(countNum5);
  2505. BigDecimal countNum66 = new BigDecimal(countNum6);
  2506. BigDecimal countNum77 = new BigDecimal(countNum7);
  2507. BigDecimal countNum88 = new BigDecimal(countNum8);
  2508. BigDecimal countNum99 = new BigDecimal(countNum9);
  2509. BigDecimal countNum1010 = new BigDecimal(countNum10);
  2510. BigDecimal countNum1111 = new BigDecimal(countNum11);
  2511. BigDecimal countNum1212 = new BigDecimal(countNum12);
  2512. BigDecimal countNumOld111 = new BigDecimal(countNumOld1);
  2513. BigDecimal countNumOld22 = new BigDecimal(countNumOld2);
  2514. BigDecimal countNumOld33 = new BigDecimal(countNumOld3);
  2515. BigDecimal countNumOld44 = new BigDecimal(countNumOld4);
  2516. BigDecimal countNumOld55 = new BigDecimal(countNumOld5);
  2517. BigDecimal countNumOld66 = new BigDecimal(countNumOld6);
  2518. BigDecimal countNumOld77 = new BigDecimal(countNumOld7);
  2519. BigDecimal countNumOld88 = new BigDecimal(countNumOld8);
  2520. BigDecimal countNumOld99 = new BigDecimal(countNumOld9);
  2521. BigDecimal countNumOld1010 = new BigDecimal(countNumOld10);
  2522. BigDecimal countNumOld1111 = new BigDecimal(countNumOld11);
  2523. BigDecimal countNumOld1212 = new BigDecimal(countNumOld12);
  2524. BigDecimal evaluationSum111 = new BigDecimal(evaluationSum1);
  2525. BigDecimal evaluationSum22 = new BigDecimal(evaluationSum2);
  2526. BigDecimal evaluationSum33 = new BigDecimal(evaluationSum3);
  2527. BigDecimal evaluationSum44 = new BigDecimal(evaluationSum4);
  2528. BigDecimal evaluationSum55 = new BigDecimal(evaluationSum5);
  2529. BigDecimal evaluationSum66 = new BigDecimal(evaluationSum6);
  2530. BigDecimal evaluationSum77 = new BigDecimal(evaluationSum7);
  2531. BigDecimal evaluationSum88 = new BigDecimal(evaluationSum8);
  2532. BigDecimal evaluationSum99 = new BigDecimal(evaluationSum9);
  2533. BigDecimal evaluationSum1010 = new BigDecimal(evaluationSum10);
  2534. BigDecimal evaluationSum1111 = new BigDecimal(evaluationSum11);
  2535. BigDecimal evaluationSum1212 = new BigDecimal(evaluationSum12);
  2536. BigDecimal evaluationSumOld111 = new BigDecimal(evaluationSumOld1);
  2537. BigDecimal evaluationSumOld22 = new BigDecimal(evaluationSumOld2);
  2538. BigDecimal evaluationSumOld33 = new BigDecimal(evaluationSumOld3);
  2539. BigDecimal evaluationSumOld44 = new BigDecimal(evaluationSumOld4);
  2540. BigDecimal evaluationSumOld55 = new BigDecimal(evaluationSumOld5);
  2541. BigDecimal evaluationSumOld66 = new BigDecimal(evaluationSumOld6);
  2542. BigDecimal evaluationSumOld77 = new BigDecimal(evaluationSumOld7);
  2543. BigDecimal evaluationSumOld88 = new BigDecimal(evaluationSumOld8);
  2544. BigDecimal evaluationSumOld99 = new BigDecimal(evaluationSumOld9);
  2545. BigDecimal evaluationSumOld1010 = new BigDecimal(evaluationSumOld10);
  2546. BigDecimal evaluationSumOld1111 = new BigDecimal(evaluationSumOld11);
  2547. BigDecimal evaluationSumOld1212 = new BigDecimal(evaluationSumOld12);
  2548. // 项目数量环比 对比
  2549. BigDecimal monthonmonthNum1 = new BigDecimal(0.00);
  2550. BigDecimal monthonmonthNum2 = new BigDecimal(0.00);
  2551. BigDecimal monthonmonthNum3 = new BigDecimal(0.00);
  2552. BigDecimal monthonmonthNum4 = new BigDecimal(0.00);
  2553. BigDecimal monthonmonthNum5 = new BigDecimal(0.00);
  2554. BigDecimal monthonmonthNum6 = new BigDecimal(0.00);
  2555. BigDecimal monthonmonthNum7 = new BigDecimal(0.00);
  2556. BigDecimal monthonmonthNum8 = new BigDecimal(0.00);
  2557. BigDecimal monthonmonthNum9 = new BigDecimal(0.00);
  2558. BigDecimal monthonmonthNum10 = new BigDecimal(0.00);
  2559. BigDecimal monthonmonthNum11 = new BigDecimal(0.00);
  2560. BigDecimal monthonmonthNum12 = new BigDecimal(0.00);
  2561. if (!"0".equals(countNumOld12)) {
  2562. monthonmonthNum1 = (countNum111.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2563. }
  2564. if (!"0".equals(countNum1)) {
  2565. monthonmonthNum2 = (countNum22.subtract(countNum111)).divide(countNum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2566. }
  2567. if (!"0".equals(countNum2)) {
  2568. monthonmonthNum3 = (countNum33.subtract(countNum22)).divide(countNum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2569. }
  2570. if (!"0".equals(countNum3)) {
  2571. monthonmonthNum4 = (countNum44.subtract(countNum33)).divide(countNum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2572. }
  2573. if (!"0".equals(countNum4)) {
  2574. monthonmonthNum5 = (countNum55.subtract(countNum44)).divide(countNum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2575. }
  2576. if (!"0".equals(countNum5)) {
  2577. monthonmonthNum6 = (countNum66.subtract(countNum55)).divide(countNum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2578. }
  2579. if (!"0".equals(countNum6)) {
  2580. monthonmonthNum7 = (countNum77.subtract(countNum66)).divide(countNum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2581. }
  2582. if (!"0".equals(countNum7)) {
  2583. monthonmonthNum8 = (countNum88.subtract(countNum77)).divide(countNum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2584. }
  2585. if (!"0".equals(countNum8)) {
  2586. monthonmonthNum9 = (countNum99.subtract(countNum88)).divide(countNum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2587. }
  2588. if (!"0".equals(countNum9)) {
  2589. monthonmonthNum10 = (countNum1010.subtract(countNum99)).divide(countNum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2590. }
  2591. if (!"0".equals(countNum10)) {
  2592. monthonmonthNum11 = (countNum1111.subtract(countNum1010)).divide(countNum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2593. }
  2594. if (!"0".equals(countNum11)) {
  2595. monthonmonthNum12 = (countNum1212.subtract(countNum1111)).divide(countNum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2596. }
  2597. map1.put("monthonmonthNum", monthonmonthNum1.toString());
  2598. map2.put("monthonmonthNum", monthonmonthNum2.toString());
  2599. map3.put("monthonmonthNum", monthonmonthNum3.toString());
  2600. map4.put("monthonmonthNum", monthonmonthNum4.toString());
  2601. map5.put("monthonmonthNum", monthonmonthNum5.toString());
  2602. map6.put("monthonmonthNum", monthonmonthNum6.toString());
  2603. map7.put("monthonmonthNum", monthonmonthNum7.toString());
  2604. map8.put("monthonmonthNum", monthonmonthNum8.toString());
  2605. map9.put("monthonmonthNum", monthonmonthNum9.toString());
  2606. map10.put("monthonmonthNum", monthonmonthNum10.toString());
  2607. map11.put("monthonmonthNum", monthonmonthNum11.toString());
  2608. map12.put("monthonmonthNum", monthonmonthNum12.toString());
  2609. // 项目数量同比 对比
  2610. BigDecimal yearonyearNum1 = new BigDecimal(0.00);
  2611. BigDecimal yearonyearNum2 = new BigDecimal(0.00);
  2612. BigDecimal yearonyearNum3 = new BigDecimal(0.00);
  2613. BigDecimal yearonyearNum4 = new BigDecimal(0.00);
  2614. BigDecimal yearonyearNum5 = new BigDecimal(0.00);
  2615. BigDecimal yearonyearNum6 = new BigDecimal(0.00);
  2616. BigDecimal yearonyearNum7 = new BigDecimal(0.00);
  2617. BigDecimal yearonyearNum8 = new BigDecimal(0.00);
  2618. BigDecimal yearonyearNum9 = new BigDecimal(0.00);
  2619. BigDecimal yearonyearNum10 = new BigDecimal(0.00);
  2620. BigDecimal yearonyearNum11 = new BigDecimal(0.00);
  2621. BigDecimal yearonyearNum12 = new BigDecimal(0.00);
  2622. if (!"0".equals(countNumOld1)) {
  2623. yearonyearNum1 = (countNum111.subtract(countNumOld111)).divide(countNumOld111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2624. }
  2625. if (!"0".equals(countNumOld2)) {
  2626. yearonyearNum2 = (countNum22.subtract(countNumOld22)).divide(countNumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2627. }
  2628. if (!"0".equals(countNumOld3)) {
  2629. yearonyearNum3 = (countNum33.subtract(countNumOld33)).divide(countNumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2630. }
  2631. if (!"0".equals(countNumOld4)) {
  2632. yearonyearNum4 = (countNum44.subtract(countNumOld44)).divide(countNumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2633. }
  2634. if (!"0".equals(countNumOld5)) {
  2635. yearonyearNum5 = (countNum55.subtract(countNumOld55)).divide(countNumOld55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2636. }
  2637. if (!"0".equals(countNumOld6)) {
  2638. yearonyearNum6 = (countNum66.subtract(countNumOld66)).divide(countNumOld66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2639. }
  2640. if (!"0".equals(countNumOld7)) {
  2641. yearonyearNum7 = (countNum77.subtract(countNumOld77)).divide(countNumOld77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2642. }
  2643. if (!"0".equals(countNumOld8)) {
  2644. yearonyearNum8 = (countNum88.subtract(countNumOld88)).divide(countNumOld88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2645. }
  2646. if (!"0".equals(countNumOld9)) {
  2647. yearonyearNum9 = (countNum99.subtract(countNumOld99)).divide(countNumOld99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2648. }
  2649. if (!"0".equals(countNumOld10)) {
  2650. yearonyearNum10 = (countNum1010.subtract(countNumOld1010)).divide(countNumOld1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2651. }
  2652. if (!"0".equals(countNumOld11)) {
  2653. yearonyearNum11 = (countNum1111.subtract(countNumOld1111)).divide(countNumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2654. }
  2655. if (!"0".equals(countNumOld12)) {
  2656. yearonyearNum12 = (countNum1212.subtract(countNumOld1212)).divide(countNumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2657. }
  2658. map1.put("yearonyearNum", yearonyearNum1.toString());
  2659. map2.put("yearonyearNum", yearonyearNum2.toString());
  2660. map3.put("yearonyearNum", yearonyearNum3.toString());
  2661. map4.put("yearonyearNum", yearonyearNum4.toString());
  2662. map5.put("yearonyearNum", yearonyearNum5.toString());
  2663. map6.put("yearonyearNum", yearonyearNum6.toString());
  2664. map7.put("yearonyearNum", yearonyearNum7.toString());
  2665. map8.put("yearonyearNum", yearonyearNum8.toString());
  2666. map9.put("yearonyearNum", yearonyearNum9.toString());
  2667. map10.put("yearonyearNum", yearonyearNum10.toString());
  2668. map11.put("yearonyearNum", yearonyearNum11.toString());
  2669. map12.put("yearonyearNum", yearonyearNum12.toString());
  2670. // 预算金额环比 对比
  2671. BigDecimal monthonmonthAmount1 = new BigDecimal(0.00);
  2672. BigDecimal monthonmonthAmount2 = new BigDecimal(0.00);
  2673. BigDecimal monthonmonthAmount3 = new BigDecimal(0.00);
  2674. BigDecimal monthonmonthAmount4 = new BigDecimal(0.00);
  2675. BigDecimal monthonmonthAmount5 = new BigDecimal(0.00);
  2676. BigDecimal monthonmonthAmount6 = new BigDecimal(0.00);
  2677. BigDecimal monthonmonthAmount7 = new BigDecimal(0.00);
  2678. BigDecimal monthonmonthAmount8 = new BigDecimal(0.00);
  2679. BigDecimal monthonmonthAmount9 = new BigDecimal(0.00);
  2680. BigDecimal monthonmonthAmount10 = new BigDecimal(0.00);
  2681. BigDecimal monthonmonthAmount11 = new BigDecimal(0.00);
  2682. BigDecimal monthonmonthAmount12 = new BigDecimal(0.00);
  2683. if (!"0".equals(evaluationSumOld12)) {
  2684. monthonmonthAmount1 = (evaluationSum111.subtract(evaluationSumOld1212)).divide(evaluationSumOld1212, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2685. }
  2686. if (!"0".equals(evaluationSum1)) {
  2687. monthonmonthAmount2 = (evaluationSum22.subtract(evaluationSum111)).divide(evaluationSum111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2688. }
  2689. if (!"0".equals(evaluationSum2)) {
  2690. monthonmonthAmount3 = (evaluationSum33.subtract(evaluationSum22)).divide(evaluationSum22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2691. }
  2692. if (!"0".equals(evaluationSum3)) {
  2693. monthonmonthAmount4 = (evaluationSum44.subtract(evaluationSum33)).divide(evaluationSum33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2694. }
  2695. if (!"0".equals(evaluationSum4)) {
  2696. monthonmonthAmount5 = (evaluationSum55.subtract(evaluationSum44)).divide(evaluationSum44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2697. }
  2698. if (!"0".equals(evaluationSum5)) {
  2699. monthonmonthAmount6 = (evaluationSum66.subtract(evaluationSum55)).divide(evaluationSum55, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2700. }
  2701. if (!"0".equals(evaluationSum6)) {
  2702. monthonmonthAmount7 = (evaluationSum77.subtract(evaluationSum66)).divide(evaluationSum66, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2703. }
  2704. if (!"0".equals(evaluationSum7)) {
  2705. monthonmonthAmount8 = (evaluationSum88.subtract(evaluationSum77)).divide(evaluationSum77, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2706. }
  2707. if (!"0".equals(evaluationSum8)) {
  2708. monthonmonthAmount9 = (evaluationSum99.subtract(evaluationSum88)).divide(evaluationSum88, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2709. }
  2710. if (!"0".equals(evaluationSum9)) {
  2711. monthonmonthAmount10 = (evaluationSum1010.subtract(evaluationSum99)).divide(evaluationSum99, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2712. }
  2713. if (!"0".equals(evaluationSum10)) {
  2714. monthonmonthAmount11 = (evaluationSum1111.subtract(evaluationSum1010)).divide(evaluationSum1010, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2715. }
  2716. if (!"0".equals(evaluationSum11)) {
  2717. monthonmonthAmount12 = (evaluationSum1212.subtract(evaluationSum1111)).divide(evaluationSum1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2718. }
  2719. map1.put("monthonmonthAmount", monthonmonthAmount1.toString());
  2720. map2.put("monthonmonthAmount", monthonmonthAmount2.toString());
  2721. map3.put("monthonmonthAmount", monthonmonthAmount3.toString());
  2722. map4.put("monthonmonthAmount", monthonmonthAmount4.toString());
  2723. map5.put("monthonmonthAmount", monthonmonthAmount5.toString());
  2724. map6.put("monthonmonthAmount", monthonmonthAmount6.toString());
  2725. map7.put("monthonmonthAmount", monthonmonthAmount7.toString());
  2726. map8.put("monthonmonthAmount", monthonmonthAmount8.toString());
  2727. map9.put("monthonmonthAmount", monthonmonthAmount9.toString());
  2728. map10.put("monthonmonthAmount", monthonmonthAmount10.toString());
  2729. map11.put("monthonmonthAmount", monthonmonthAmount11.toString());
  2730. map12.put("monthonmonthAmount", monthonmonthAmount12.toString());
  2731. // 预算金额同比比 对比
  2732. BigDecimal yearonyearAmount1 = new BigDecimal(0.00);
  2733. BigDecimal yearonyearAmount2 = new BigDecimal(0.00);
  2734. BigDecimal yearonyearAmount3 = new BigDecimal(0.00);
  2735. BigDecimal yearonyearAmount4 = new BigDecimal(0.00);
  2736. BigDecimal yearonyearAmount5 = new BigDecimal(0.00);
  2737. BigDecimal yearonyearAmount6 = new BigDecimal(0.00);
  2738. BigDecimal yearonyearAmount7 = new BigDecimal(0.00);
  2739. BigDecimal yearonyearAmount8 = new BigDecimal(0.00);
  2740. BigDecimal yearonyearAmount9 = new BigDecimal(0.00);
  2741. BigDecimal yearonyearAmount10 = new BigDecimal(0.00);
  2742. BigDecimal yearonyearAmount11 = new BigDecimal(0.00);
  2743. BigDecimal yearonyearAmount12 = new BigDecimal(0.00);
  2744. if (!"0".equals(evaluationSumOld1)) {
  2745. yearonyearAmount1 = (evaluationSum111.subtract(evaluationSumOld111)).divide(evaluationSumOld1111, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2746. }
  2747. if (!"0".equals(evaluationSumOld2)) {
  2748. yearonyearAmount2 = (evaluationSum22.subtract(evaluationSumOld22)).divide(evaluationSumOld22, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2749. }
  2750. if (!"0".equals(evaluationSumOld3)) {
  2751. yearonyearAmount3 = (evaluationSum33.subtract(evaluationSumOld33)).divide(evaluationSumOld33, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2752. }
  2753. if (!"0".equals(evaluationSumOld4)) {
  2754. yearonyearAmount4 = (evaluationSum44.subtract(evaluationSumOld44)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2755. }
  2756. if (!"0".equals(evaluationSumOld5)) {
  2757. yearonyearAmount5 = (evaluationSum55.subtract(evaluationSumOld55)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2758. }
  2759. if (!"0".equals(evaluationSumOld6)) {
  2760. yearonyearAmount6 = (evaluationSum66.subtract(evaluationSumOld66)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2761. }
  2762. if (!"0".equals(evaluationSumOld7)) {
  2763. yearonyearAmount7 = (evaluationSum77.subtract(evaluationSumOld77)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2764. }
  2765. if (!"0".equals(evaluationSumOld8)) {
  2766. yearonyearAmount8 = (evaluationSum88.subtract(evaluationSumOld88)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2767. }
  2768. if (!"0".equals(evaluationSumOld9)) {
  2769. yearonyearAmount9 = (evaluationSum99.subtract(evaluationSumOld99)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2770. }
  2771. if (!"0".equals(evaluationSumOld10)) {
  2772. yearonyearAmount10 = (evaluationSum1010.subtract(evaluationSumOld1010)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2773. }
  2774. if (!"0".equals(evaluationSumOld11)) {
  2775. yearonyearAmount11 = (evaluationSum1111.subtract(evaluationSumOld1111)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2776. }
  2777. if (!"0".equals(evaluationSumOld12)) {
  2778. yearonyearAmount12 = (evaluationSum1212.subtract(evaluationSumOld1212)).divide(evaluationSumOld44, 4, BigDecimal.ROUND_CEILING).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
  2779. }
  2780. map1.put("yearonyearAmount", yearonyearAmount1.toString());
  2781. map2.put("yearonyearAmount", yearonyearAmount2.toString());
  2782. map3.put("yearonyearAmount", yearonyearAmount3.toString());
  2783. map4.put("yearonyearAmount", yearonyearAmount4.toString());
  2784. map5.put("yearonyearAmount", yearonyearAmount5.toString());
  2785. map6.put("yearonyearAmount", yearonyearAmount6.toString());
  2786. map7.put("yearonyearAmount", yearonyearAmount7.toString());
  2787. map8.put("yearonyearAmount", yearonyearAmount8.toString());
  2788. map9.put("yearonyearAmount", yearonyearAmount9.toString());
  2789. map10.put("yearonyearAmount", yearonyearAmount10.toString());
  2790. map11.put("yearonyearAmount", yearonyearAmount11.toString());
  2791. map12.put("yearonyearAmount", yearonyearAmount12.toString());
  2792. // 存入集合
  2793. mapReturn.add(map1);
  2794. mapReturn.add(map2);
  2795. mapReturn.add(map3);
  2796. mapReturn.add(map4);
  2797. mapReturn.add(map5);
  2798. mapReturn.add(map6);
  2799. mapReturn.add(map7);
  2800. mapReturn.add(map8);
  2801. mapReturn.add(map9);
  2802. mapReturn.add(map10);
  2803. mapReturn.add(map11);
  2804. mapReturn.add(map12);
  2805. }
  2806. return mapReturn;
  2807. }
  2808. //查询不同状态下的项目数据
  2809. public List<PmDemandResVo> getListByStatus(String projectStatus) {
  2810. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  2811. lw.eq(PmDemand::getProjectStatus, projectStatus);
  2812. List<PmDemand> demandList = this.baseMapper.selectList(lw);
  2813. //数据转换
  2814. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  2815. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  2816. pmDemandResponseVoList = demandChangeTo(demandList);
  2817. }
  2818. return pmDemandResponseVoList;
  2819. }
  2820. //字段转换and赋值
  2821. public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
  2822. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  2823. for (PmDemand pmDemand1 : pmDemandList) {
  2824. PmDemandResVo vo = new PmDemandResVo();
  2825. BeanUtils.copyProperties(pmDemand1, vo);
  2826. if (vo.getPurchaseDeptId() != null) {
  2827. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  2828. if (deptMap != null) {
  2829. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  2830. if (sysDeptResponseVo != null) {
  2831. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  2832. }
  2833. }
  2834. }
  2835. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  2836. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  2837. vo.setPurchaseServicesName(purchaseServicesName);
  2838. }
  2839. //项目类型
  2840. for (ProjectTypes value : ProjectTypes.values()) {
  2841. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  2842. vo.setProjectTypeName(value.getInfo());
  2843. break;
  2844. }
  2845. }
  2846. //是否为超限额计划
  2847. for (IsExcess value : IsExcess.values()) {
  2848. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  2849. vo.setIsExcessName(value.getInfo());
  2850. break;
  2851. }
  2852. }
  2853. //采购方式
  2854. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  2855. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  2856. vo.setPurchaseModeName(value.getInfo());
  2857. break;
  2858. }
  2859. }
  2860. //项目属性
  2861. for (ProjectAttribute value : ProjectAttribute.values()) {
  2862. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  2863. vo.setProjectAttrName(value.getInfo());
  2864. break;
  2865. }
  2866. }
  2867. //预警状态
  2868. for (WarnStatus value : WarnStatus.values()) {
  2869. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  2870. vo.setWarnStatusName(value.getInfo());
  2871. break;
  2872. }
  2873. }
  2874. //项目状态
  2875. for (PmProjectStatus value : PmProjectStatus.values()) {
  2876. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  2877. vo.setProjectStatusName(value.getInfo());
  2878. break;
  2879. }
  2880. }
  2881. try {
  2882. vo.setTipsMessage(pmDemandGetTips(vo.getPlanDeliverTime()));
  2883. if (vo.getTipsMessage().contains("超过")) {
  2884. vo.setIsExceedProject("1");
  2885. if (ObjectUtils.isEmpty(pmDemand1.getDelayReason())) {
  2886. //没有原因就可以填写滞后原因
  2887. vo.setIsWriteExceed("1");
  2888. }
  2889. }
  2890. } catch (ParseException e) {
  2891. e.printStackTrace();
  2892. }
  2893. pmDemandResponseVoList.add(vo);
  2894. }
  2895. return pmDemandResponseVoList;
  2896. }
  2897. /**
  2898. * 根据年度计划提报时间的阈值进行提示
  2899. *
  2900. * @return
  2901. */
  2902. public String pmDemandGetTips(Date planDeliverTime) throws ParseException {
  2903. if (!ObjectUtils.isEmpty(planDeliverTime)) {
  2904. //提示信息:定义距离结束时间一周内提示
  2905. Integer remindTine = 1000 * 60 * 60 * 24 * 7;
  2906. //少于一周便提醒
  2907. double surplus = planDeliverTime.getTime() - System.currentTimeMillis();
  2908. if (surplus < remindTine) {
  2909. int i = new Double(Math.ceil(surplus / 1000 / 60 / 60 / 24)).intValue();
  2910. //剩余天数(向上取整)
  2911. if (i > 0) {
  2912. return "距离计划交付时间不足" + i + "天";
  2913. } else {
  2914. return "已超过计划完成时间" + Math.abs(i) + "天";
  2915. }
  2916. }
  2917. }
  2918. return "";
  2919. }
  2920. /**
  2921. * 计算百分比:使用java.text.DecimalFormat实现
  2922. *
  2923. * @param x
  2924. * @param y
  2925. * @return
  2926. */
  2927. public static String getPercent(int x, int y) {
  2928. double d1 = x * 1.0;
  2929. double d2 = y * 1.0;
  2930. // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
  2931. DecimalFormat decimalFormat = new DecimalFormat("##.00%");
  2932. return decimalFormat.format(d1 / d2);
  2933. }
  2934. }