PmDemandServiceImpl.java 170 KB

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