PmDemandServiceImpl.java 105 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185
  1. package com.ozs.pm.service.impl;
  2. import java.text.DecimalFormat;
  3. import java.text.ParseException;
  4. import java.util.*;
  5. import java.util.stream.Collectors;
  6. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  7. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  8. import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
  9. import com.baomidou.mybatisplus.core.metadata.IPage;
  10. import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
  11. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  12. import com.ozs.base.domain.*;
  13. import com.ozs.base.domain.vo.BaseExpertVo;
  14. import com.ozs.base.service.*;
  15. import com.ozs.common.core.domain.AjaxResult;
  16. import com.ozs.common.core.domain.entity.SysDept;
  17. import com.ozs.common.core.domain.entity.SysRole;
  18. import com.ozs.common.core.domain.entity.SysUser;
  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.vo.responseVo.PlanQuarterResponseVo;
  27. import com.ozs.plan.service.PlanYearsService;
  28. import com.ozs.pm.doman.*;
  29. import com.ozs.pm.doman.vo.requestVo.*;
  30. import com.ozs.pm.doman.vo.responseVo.*;
  31. import com.ozs.pm.mapper.PmDemandMapper;
  32. import com.ozs.pm.service.*;
  33. import com.ozs.system.domain.SysFileInfo;
  34. import com.ozs.system.domain.SysFileRef;
  35. import com.ozs.system.domain.vo.SysRegionVO;
  36. import com.ozs.system.domain.vo.responseVo.SysDeptResponseVo;
  37. import com.ozs.system.mapper.SysDeptMapper;
  38. import com.ozs.system.mapper.SysRoleMapper;
  39. import com.ozs.system.service.*;
  40. import io.swagger.models.auth.In;
  41. import org.springframework.beans.factory.annotation.Autowired;
  42. import org.springframework.stereotype.Service;
  43. import org.springframework.transaction.annotation.Transactional;
  44. import org.springframework.util.CollectionUtils;
  45. import org.springframework.util.ObjectUtils;
  46. /**
  47. * 采购需求Service业务层处理
  48. *
  49. * @author ruoyi
  50. * @date 2023-01-16
  51. */
  52. @Service
  53. public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> implements IPmDemandService {
  54. @Autowired
  55. private PmDemandMapper pmDemandMapper;
  56. @Autowired
  57. private ISysDeptService deptService;
  58. @Autowired
  59. private ISysDictDataService dictDataService;
  60. @Autowired
  61. private SysFileService fileService;
  62. @Autowired
  63. private SysFileRefService sysFileRefService;
  64. @Autowired
  65. private IPmFlowChartService iPmFlowChartService;
  66. @Autowired
  67. private PmReleaseAnnouncementService pmReleaseAnnouncementService;
  68. @Autowired
  69. private BaseExpertService baseExpertService;
  70. @Autowired
  71. private PmDemandExpertRefService pmDemandExpertRefService;
  72. @Autowired
  73. private PmBidOpeningService pmBidOpeningService;
  74. @Autowired
  75. private PmBookBuildingService pmBookBuildingService;
  76. @Autowired
  77. private PmBidWinningService pmBidWinningService;
  78. @Autowired
  79. private PmBidFailureService pmBidFailureService;
  80. @Autowired
  81. private PmBidWinningOpeningRefService pmBidWinningOpeningRefService;
  82. @Autowired
  83. private PmContractInfoService pmContractInfoService;
  84. @Autowired
  85. private BaseAgencyService baseAgencyService;
  86. @Autowired
  87. private PmProjectConstructionService pmProjectConstructionService;
  88. @Autowired
  89. private BaseNoticeTypeService baseNoticeTypeService;
  90. @Autowired
  91. private BaseNoticeService baseNoticeService;
  92. @Autowired
  93. private PlanYearsService planYearsService;
  94. @Autowired
  95. private ISysRegionService iSysRegionService;
  96. @Autowired
  97. private SysRoleMapper sysRoleMapper;
  98. @Autowired
  99. private ISysUserService userService;
  100. @Autowired
  101. private SysDeptMapper deptMapper;
  102. /**
  103. * 查询采购需求
  104. *
  105. * @param demandId 采购需求主键
  106. * @return 采购需求
  107. */
  108. @Override
  109. public PmDemandResVo selectPmDemandByDemandId(Long demandId, String detailType) {
  110. PmDemand pmDemand = this.getById(demandId);
  111. if (pmDemand != null) {
  112. PmDemandResVo vo = new PmDemandResVo();
  113. vo.setProjectName(pmDemand.getProjectName());
  114. vo.setDemandId(demandId);
  115. if ("1".equals(detailType)) { //项目计划
  116. BeanUtils.copyProperties(pmDemand, vo);
  117. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptService.selectDeptById(vo.getPurchaseDeptId()).get("sysDept");
  118. if (sysDeptResponseVo != null) {
  119. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  120. }
  121. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  122. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  123. vo.setPurchaseServicesName(purchaseServicesName);
  124. }
  125. //采购需求附件
  126. List<SysFileInfo> demandFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND.getType());
  127. if (!ObjectUtils.isEmpty(demandFileInfos)) {
  128. vo.setDemandFileInfos(demandFileInfos);
  129. }
  130. //项目类型
  131. for (ProjectTypes value : ProjectTypes.values()) {
  132. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  133. vo.setProjectTypeName(value.getInfo());
  134. break;
  135. }
  136. }
  137. //是否为超限额计划
  138. for (IsExcess value : IsExcess.values()) {
  139. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  140. vo.setIsExcessName(value.getInfo());
  141. break;
  142. }
  143. }
  144. //采购方式
  145. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  146. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  147. vo.setPurchaseModeName(value.getInfo());
  148. break;
  149. }
  150. }
  151. //项目属性
  152. for (ProjectAttribute value : ProjectAttribute.values()) {
  153. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  154. vo.setProjectAttrName(value.getInfo());
  155. break;
  156. }
  157. }
  158. //预警状态
  159. for (WarnStatus value : WarnStatus.values()) {
  160. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  161. vo.setWarnStatusName(value.getInfo());
  162. break;
  163. }
  164. }
  165. //项目状态
  166. for (PmProjectStatus value : PmProjectStatus.values()) {
  167. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  168. vo.setProjectStatusName(value.getInfo());
  169. break;
  170. }
  171. }
  172. } else if ("2".equals(detailType)) { //需求建档
  173. //采购需求审核文件
  174. List<SysFileInfo> auditFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  175. if (!ObjectUtils.isEmpty(auditFileInfos)) {
  176. vo.setAuditFileInfos(auditFileInfos);
  177. }
  178. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  179. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  180. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  181. if (pmBookBuilding != null) {
  182. PmBookBuildingResVo responseVo = new PmBookBuildingResVo();
  183. BeanUtils.copyProperties(pmBookBuilding, responseVo);
  184. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  185. if (!ObjectUtils.isEmpty(fileInfos)) {
  186. responseVo.setFileInfos(fileInfos);
  187. }
  188. vo.setPmBookBuildingResVo(responseVo);
  189. }
  190. } else if ("3".equals(detailType)) { //任务下达
  191. //任务下达文件
  192. List<SysFileInfo> taskReleaseFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType());
  193. if (!ObjectUtils.isEmpty(taskReleaseFileInfos)) {
  194. vo.setTaskReleaseFileInfos(taskReleaseFileInfos);
  195. }
  196. } else if ("4".equals(detailType)) { //中标信息
  197. PmPurchaseExecutionResVo pmPurchaseExecutionResVo = new PmPurchaseExecutionResVo();
  198. //代理商信息
  199. BaseAgency baseAgency = this.baseAgencyService.getById(pmDemand.getAgencyId());
  200. pmPurchaseExecutionResVo.setBaseAgency(baseAgency);
  201. //发布公告列表
  202. LambdaQueryWrapper<PmReleaseAnnouncement> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  203. lambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  204. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = this.pmReleaseAnnouncementService.list(lambdaQueryWrapper);
  205. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  206. List<PmReleaseAnnouncementResVo> pmReleaseAnnouncementResVoList = new ArrayList<>();
  207. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  208. PmReleaseAnnouncementResVo pmReleaseAnnouncementResVo = new PmReleaseAnnouncementResVo();
  209. BeanUtils.copyProperties(pmReleaseAnnouncement, pmReleaseAnnouncementResVo);
  210. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  211. if (!ObjectUtils.isEmpty(fileInfos)) {
  212. pmReleaseAnnouncementResVo.setFileInfos(fileInfos);
  213. }
  214. pmReleaseAnnouncementResVoList.add(pmReleaseAnnouncementResVo);
  215. }
  216. pmPurchaseExecutionResVo.setPmReleaseAnnouncementResVoList(pmReleaseAnnouncementResVoList);
  217. }
  218. //专家信息列表
  219. List<PmBaseExpertResVo> pmBaseExpertResVoList = this.pmDemandExpertRefService.getPmBaseExpertResVoList(demandId);
  220. pmPurchaseExecutionResVo.setPmBaseExpertResVoList(pmBaseExpertResVoList);
  221. //开标信息列表
  222. List<PmBidOpeningResVo> pmBidOpeningResVoList = this.pmBidOpeningService.getPmBidOpeningResVoList(demandId);
  223. pmPurchaseExecutionResVo.setPmBidOpeningResVoList(pmBidOpeningResVoList);
  224. //中标信息列表
  225. LambdaQueryWrapper<PmBidWinning> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
  226. lambdaQueryWrapper1.eq(PmBidWinning::getDemandId, demandId)
  227. .eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
  228. PmBidWinning pmBidWinning = this.pmBidWinningService.getOne(lambdaQueryWrapper1);
  229. if (!ObjectUtils.isEmpty(pmBidWinning)) {
  230. LambdaQueryWrapper<PmBidWinningOpeningRef> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  231. lambdaQueryWrapper2.eq(PmBidWinningOpeningRef::getWinningId,pmBidWinning.getId())
  232. .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
  233. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = this.pmBidWinningOpeningRefService.list(lambdaQueryWrapper2);
  234. if(!ObjectUtils.isEmpty(pmBidWinningOpeningRefList)){
  235. List<PmBidWinningResVo> pmBidWinningResVoList = new ArrayList<>();
  236. for (PmBidWinningOpeningRef pmBidWinningOpeningRef : pmBidWinningOpeningRefList) {
  237. PmBidOpening pmBidOpening = this.pmBidOpeningService.getById(pmBidWinningOpeningRef.getOpeningId());
  238. if(pmBidOpening != null){
  239. PmBidWinningResVo pmBidWinningResVo = new PmBidWinningResVo();
  240. BeanUtils.copyProperties(pmBidWinning, pmBidWinningResVo);
  241. pmBidWinningResVo.setBidWinningName(pmBidOpening.getBidderName());
  242. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  243. if (!ObjectUtils.isEmpty(fileInfos)) {
  244. pmBidWinningResVo.setFileInfos(fileInfos);
  245. }
  246. pmBidWinningResVoList.add(pmBidWinningResVo);
  247. }
  248. }
  249. pmPurchaseExecutionResVo.setPmBidWinningResVoList(pmBidWinningResVoList);
  250. }
  251. }
  252. pmPurchaseExecutionResVo.setCallQuestion(pmDemand.getCallQuestion());
  253. //质疑情况
  254. List<SysFileInfo> callRequestFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  255. if (!ObjectUtils.isEmpty(callRequestFileInfos)) {
  256. pmPurchaseExecutionResVo.setCallRequestFileInfos(callRequestFileInfos);
  257. }
  258. //流标情况
  259. LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
  260. lambdaQueryWrapper2.eq(PmBidFailure::getDemandId, demandId).orderByDesc(PmBidFailure::getBidFailureTime);
  261. List<PmBidFailure> pmBidFailureList = this.pmBidFailureService.list(lambdaQueryWrapper2);
  262. if (!ObjectUtils.isEmpty(pmBidFailureList)) {
  263. List<PmBidFailureResVo> pmBidFailureResVoList = new ArrayList<>();
  264. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  265. PmBidFailureResVo pmBidFailureResVo = new PmBidFailureResVo();
  266. BeanUtils.copyProperties(pmBidFailure, pmBidFailureResVo);
  267. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  268. if (!ObjectUtils.isEmpty(fileInfos)) {
  269. pmPurchaseExecutionResVo.setFileInfos(fileInfos);
  270. }
  271. pmBidFailureResVoList.add(pmBidFailureResVo);
  272. }
  273. pmPurchaseExecutionResVo.setPmBidFailureResVoList(pmBidFailureResVoList);
  274. }
  275. //中标通知书
  276. List<SysFileInfo> pmBidWinningNotificationFileInfos = getSysFileInfoList(vo.getDemandId(), SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  277. if (!ObjectUtils.isEmpty(pmBidWinningNotificationFileInfos)) {
  278. pmPurchaseExecutionResVo.setPmBidWinningNotificationFileInfos(pmBidWinningNotificationFileInfos);
  279. }
  280. vo.setPmPurchaseExecutionResVo(pmPurchaseExecutionResVo);
  281. } else if ("5".equals(detailType)) { //合同信息
  282. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  283. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  284. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  285. if (pmContractInfo != null) {
  286. PmContractInfoResVo pmContractInfoResVo = new PmContractInfoResVo();
  287. BeanUtils.copyProperties(pmContractInfo, pmContractInfoResVo);
  288. //合同信息文件
  289. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  290. if (!ObjectUtils.isEmpty(fileInfos)) {
  291. pmContractInfoResVo.setFileInfos(fileInfos);
  292. }
  293. vo.setPmContractInfoResVo(pmContractInfoResVo);
  294. }
  295. } else if ("6".equals(detailType)) { //建设情况
  296. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  297. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  298. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  299. if (pmProjectConstruction != null) {
  300. PmProjectConstructionResVo pmProjectConstructionResVo = new PmProjectConstructionResVo();
  301. BeanUtils.copyProperties(pmProjectConstruction, pmProjectConstructionResVo);
  302. //建设情况文件
  303. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  304. if (!ObjectUtils.isEmpty(fileInfos)) {
  305. pmProjectConstructionResVo.setFileInfos(fileInfos);
  306. }
  307. vo.setPmProjectConstructionResVo(pmProjectConstructionResVo);
  308. }
  309. }
  310. return vo;
  311. } else {
  312. return null;
  313. }
  314. }
  315. /**
  316. * 查询采购需求列表
  317. *
  318. * @param pmDemandReqVo
  319. * @return 采购需求
  320. */
  321. @Override
  322. public IPage<PmDemandResVo> selectPmDemandList(PmDemandReqVo pmDemandReqVo, int reqType) {
  323. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<>();
  324. /*******************权限代码***********************/
  325. SysUser sysUser = userService.selectUserById(SecurityUtils.getUserId());
  326. Long deptId = sysUser.getDeptId();
  327. //获取登录用户的角色
  328. List<SysRole> sysRoles = sysRoleMapper.selectRolePermissionByUserId(SecurityUtils.getUserId());
  329. //获取属于求单位管理员的列表
  330. List<SysRole> sysRoleList2 = sysRoles.stream().filter(tdto -> tdto.getRoleKey().equals(SysRoleKey.DEMAND_UNIT.getCode())).collect(Collectors.toList());
  331. if (!ObjectUtils.isEmpty(sysRoleList2)) { //属于需求单位管理员
  332. lw.apply("(purchase_dept_id = " + deptId + ")" ) ;
  333. } else {
  334. //获取属于采购管理部门管理员 或 采购办管理员的列表
  335. List<SysRole> sysRoleList = sysRoles.stream().filter(tdto -> (tdto.getRoleKey().equals(SysRoleKey.PURCHASING_MANAGEMENT.getCode())
  336. || tdto.getRoleKey().equals(SysRoleKey.PROCUREMENT_OFFICE.getCode()))).collect(Collectors.toList());
  337. if (!ObjectUtils.isEmpty(sysRoleList)) { //属于采购管理部门管理员 或 采购办管理员
  338. //获取子部门列表
  339. List<SysDept> sysDeptSubs = deptMapper.selectChildrenDeptById(sysUser.getDeptId());
  340. String sysDeptSubStr = null;
  341. if(!ObjectUtils.isEmpty(sysDeptSubs)){
  342. List<String> sysDeptSubIds = sysDeptSubs.stream().map(SysDept::getDeptId).collect(Collectors.toList())
  343. .stream().map(x -> x + "").collect(Collectors.toList());
  344. sysDeptSubStr = String.join(",", sysDeptSubIds);
  345. }
  346. String condtionSql= null;
  347. if(ObjectUtils.isEmpty(sysDeptSubStr)){
  348. condtionSql = "(purchase_dept_id = " + deptId + " AND is_excess = 0) ";
  349. } else {
  350. condtionSql = "((purchase_dept_id = " + deptId + " AND is_excess = 0) " +
  351. " OR (purchase_dept_id IN ("+ sysDeptSubStr +") AND is_excess = 1))";
  352. }
  353. lw.apply(condtionSql);
  354. }
  355. }
  356. /*******************权限代码end***********************/
  357. if (!StringUtils.isBlank(pmDemandReqVo.getProjectName())) {
  358. lw.like(PmDemand::getProjectName, "%" + pmDemandReqVo.getProjectName() + "%");
  359. }
  360. if (!StringUtils.isBlank(pmDemandReqVo.getPurchaseServices())) {
  361. lw.eq(PmDemand::getPurchaseServices, pmDemandReqVo.getPurchaseServices());
  362. }
  363. if (!ObjectUtils.isEmpty(pmDemandReqVo.getProjectStatus() )) {
  364. lw.eq(PmDemand::getProjectStatus, pmDemandReqVo.getProjectStatus());
  365. }
  366. if (!ObjectUtils.isEmpty(pmDemandReqVo.getWarnStatus() )) {
  367. lw.eq(PmDemand::getWarnStatus, pmDemandReqVo.getWarnStatus());
  368. }
  369. if (!ObjectUtils.isEmpty(pmDemandReqVo.getIsExcess() )) {
  370. lw.eq(PmDemand::getIsExcess, pmDemandReqVo.getIsExcess());
  371. }
  372. if (!StringUtils.isBlank(pmDemandReqVo.getBeginDate())) {
  373. lw.apply("(plan_demand_sub_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_purchase_finish_time >= '" + pmDemandReqVo.getBeginDate() + "' or plan_deliver_time >= '" + pmDemandReqVo.getBeginDate() + "' )");
  374. }
  375. if (!StringUtils.isBlank(pmDemandReqVo.getEndDate())) {
  376. lw.apply("(plan_demand_sub_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_purchase_finish_time <= '" + pmDemandReqVo.getEndDate() + "' or plan_deliver_time <= '" + pmDemandReqVo.getEndDate() + "' )");
  377. }
  378. if (reqType == 1) { //需求审核单位列表
  379. lw.apply("(project_status = 6 or project_status = 8 )");
  380. } else if (reqType == 2) { //任务下达列表
  381. lw.apply("(project_status = 8 or project_status = 9 )");
  382. } else if (reqType == 3) { //采购执行列表
  383. lw.apply("(project_status = 9 or project_status = 10 or project_status = 11 or project_status = 12 or project_status = 13 or project_status = 14 or project_status = 15)");
  384. } else if (reqType == 4) { //合同信息列表
  385. lw.apply("(project_status = 15 or project_status = 16 )");
  386. } else if (reqType == 5) { //项目建设列表
  387. lw.apply("(project_status = 16 or project_status = 17 )");
  388. }
  389. IPage<PmDemand> pageRes = this.page(new Page<>(pmDemandReqVo.getPageNum(), pmDemandReqVo.getPageSize()), lw);
  390. IPage<PmDemandResVo> results = new Page<>(pageRes.getCurrent(), pageRes.getSize(), pageRes.getTotal());
  391. if (pageRes.getRecords() != null && pageRes.getRecords().size() > 0) {
  392. List<PmDemandResVo> pmDemandResVos = demandChangeTo(pageRes.getRecords());
  393. results.setRecords(pmDemandResVos);
  394. }
  395. return results;
  396. }
  397. /**
  398. * 需求建档
  399. *
  400. * @param vo 采购需求
  401. * @return 结果
  402. */
  403. @Override
  404. @Transactional(rollbackFor = Exception.class)
  405. public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
  406. PmDemand pmDemand = this.getById(vo.getDemandId());
  407. LambdaQueryWrapper<PmBookBuilding> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  408. lambdaQueryWrapper.eq(PmBookBuilding::getDemandId, vo.getDemandId());
  409. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(lambdaQueryWrapper);
  410. if (pmBookBuilding != null) {
  411. vo.setId(pmBookBuilding.getId());
  412. BeanUtils.copyProperties(vo, pmBookBuilding);
  413. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  414. pmBookBuilding.setUpdateTime(new Date());
  415. } else {
  416. pmBookBuilding = new PmBookBuilding();
  417. BeanUtils.copyProperties(vo, pmBookBuilding);
  418. pmBookBuilding.setCreateBy(vo.getUpdateBy());
  419. pmBookBuilding.setCreateTime(new Date());
  420. pmBookBuilding.setUpdateBy(vo.getUpdateBy());
  421. pmBookBuilding.setUpdateTime(pmBookBuilding.getCreateTime());
  422. }
  423. if (pmBookBuildingService.saveOrUpdate(pmBookBuilding)) {
  424. List<SysFileRef> sysFileRefs = vo.getSysFileRefs();
  425. uploadFile(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType(), sysFileRefs, vo.getUpdateBy());
  426. pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  427. pmDemand.setUpdateBy(vo.getUpdateBy());
  428. pmDemand.setUpdateTime(DateUtils.getNowDate());
  429. return this.updateById(pmDemand);
  430. } else {
  431. return false;
  432. }
  433. }
  434. private List<SysFileInfo> getSysFileInfoList(Long redId, Integer type) {
  435. HashMap<String, Object> map = new HashMap<>();
  436. map.put("red_id", redId);
  437. map.put("type", type);
  438. List<SysFileRef> fileRefs = sysFileRefService.listByMap(map);
  439. if (!ObjectUtils.isEmpty(fileRefs)) {
  440. List<SysFileInfo> fileInfos = new ArrayList<>();
  441. for (SysFileRef ref : fileRefs) {
  442. SysFileInfo fileInfo = fileService.getById(ref.getFileId());
  443. fileInfos.add(fileInfo);
  444. }
  445. return fileInfos;
  446. } else {
  447. return null;
  448. }
  449. }
  450. /**
  451. * 查看流程图
  452. *
  453. * @param demandId 采购需求主键
  454. * @return 采购需求
  455. */
  456. @Override
  457. public Object viewFlowChart(Long demandId) {
  458. PmDemand pmDemand = this.getById(demandId);
  459. String projectStatus = String.valueOf(pmDemand.getProjectStatus());
  460. String moduleName = null;
  461. if (PmProjectStatus.DEMAND_WAIT_FILL.getCode().equals(projectStatus) || PmProjectStatus.DEMAND_AUDIT_RETURN.getCode().equals(projectStatus)) {
  462. moduleName = "需求填制";
  463. } else if (PmProjectStatus.DEMAND_WAIT_COMMIT.getCode().equals(projectStatus)) {
  464. moduleName = "需求提交";
  465. } else if (PmProjectStatus.DEMAND_WAIT_AUDIT.getCode().equals(projectStatus)) {
  466. moduleName = "需求审核";
  467. } else if (PmProjectStatus.TASK_WAIT_RELEASE.getCode().equals(projectStatus)) {
  468. moduleName = "任务下达";
  469. } else if (PmProjectStatus.WAIT_SELECT_AGENT.getCode().equals(projectStatus)) {
  470. moduleName = "选取代理";
  471. } else if (PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode().equals(projectStatus)) {
  472. moduleName = "上传招标文件";
  473. } else if (PmProjectStatus.WAIT_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  474. moduleName = "发布公告";
  475. } else if (PmProjectStatus.WAIT_OPEN_BID.getCode().equals(projectStatus)) {
  476. moduleName = "填写专家信息,填写开标信息";
  477. } else if (PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode().equals(projectStatus)) {
  478. moduleName = "填写中标信息";
  479. } else if (PmProjectStatus.BIDDING_PUBLICITY.getCode().equals(projectStatus)) {
  480. moduleName = "质疑处理,上传中标通知书";
  481. } else if (PmProjectStatus.CONTRACT_WAIT_FILL.getCode().equals(projectStatus)) {
  482. moduleName = "合同填制";
  483. } else if (PmProjectStatus.UNDER_CONSTRUCTION.getCode().equals(projectStatus)) {
  484. moduleName = "建设文档填制";
  485. } else if (PmProjectStatus.COMPLETION_CONSTRUCTION.getCode().equals(projectStatus)) {
  486. moduleName = "项目归档";
  487. }
  488. return moduleName;
  489. }
  490. @Override
  491. public PmFlowChartResVo getModuleInfo(Long demandId, String moduleName) {
  492. LambdaQueryWrapper<PmFlowChart> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  493. lambdaQueryWrapper.eq(PmFlowChart::getModuleName, moduleName);
  494. PmFlowChart pmFlowChart = iPmFlowChartService.getOne(lambdaQueryWrapper);
  495. if (pmFlowChart == null) {
  496. return null;
  497. }
  498. PmFlowChartResVo vo = new PmFlowChartResVo();
  499. BeanUtils.copyProperties(pmFlowChart, vo);
  500. if ("需求填制".equals(moduleName)) {
  501. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND.getType());
  502. if (!ObjectUtils.isEmpty(fileInfos)) {
  503. vo.setFileInfos(fileInfos);
  504. }
  505. } else if ("需求提交".equals(moduleName)) {
  506. LambdaQueryWrapper<PmBookBuilding> pmBookBuildingLambdaQueryWrapper = new LambdaQueryWrapper<>();
  507. pmBookBuildingLambdaQueryWrapper.eq(PmBookBuilding::getDemandId, demandId);
  508. PmBookBuilding pmBookBuilding = pmBookBuildingService.getOne(pmBookBuildingLambdaQueryWrapper);
  509. if (pmBookBuilding != null) {
  510. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBookBuilding.getId(), SysFileRefEnum.PM_BOOK_BUILDING.getType());
  511. if (!ObjectUtils.isEmpty(fileInfos)) {
  512. vo.setFileInfos(fileInfos);
  513. }
  514. }
  515. } else if ("需求审核".equals(moduleName)) {
  516. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_DEMAND_EXAMINE.getType());
  517. if (!ObjectUtils.isEmpty(fileInfos)) {
  518. vo.setFileInfos(fileInfos);
  519. }
  520. } else if ("任务下达".equals(moduleName)) {
  521. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_TAST_RELEASE.getType());
  522. if (!ObjectUtils.isEmpty(fileInfos)) {
  523. vo.setFileInfos(fileInfos);
  524. }
  525. } else if ("选取代理".equals(moduleName)) {
  526. //do nothing
  527. } else if ("上传招标文件".equals(moduleName)) {
  528. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_FILE.getType());
  529. if (!ObjectUtils.isEmpty(fileInfos)) {
  530. vo.setFileInfos(fileInfos);
  531. }
  532. } else if ("发布公告".equals(moduleName)) {
  533. LambdaQueryWrapper<PmReleaseAnnouncement> pmReleaseAnnouncementLambdaQueryWrapper = new LambdaQueryWrapper<>();
  534. pmReleaseAnnouncementLambdaQueryWrapper.eq(PmReleaseAnnouncement::getDemandId, demandId);
  535. List<PmReleaseAnnouncement> pmReleaseAnnouncementList = pmReleaseAnnouncementService.list(pmReleaseAnnouncementLambdaQueryWrapper);
  536. if (!ObjectUtils.isEmpty(pmReleaseAnnouncementList)) {
  537. List<SysFileInfo> listAll = new ArrayList<>();
  538. for (PmReleaseAnnouncement pmReleaseAnnouncement : pmReleaseAnnouncementList) {
  539. List<SysFileInfo> fileInfos = getSysFileInfoList(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType());
  540. if (!ObjectUtils.isEmpty(fileInfos)) {
  541. listAll.addAll(fileInfos);
  542. }
  543. }
  544. if (!ObjectUtils.isEmpty(listAll)) {
  545. vo.setFileInfos(listAll);
  546. }
  547. }
  548. } else if ("填写专家信息".equals(moduleName)) {
  549. //do nothing
  550. } else if ("填写开标信息".equals(moduleName)) {
  551. //do nothing
  552. } else if ("填写中标信息".equals(moduleName)) {
  553. List<SysFileInfo> listAll = new ArrayList<>();
  554. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  555. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId, demandId);
  556. List<PmBidWinning> pmBidWinningList = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  557. if (!ObjectUtils.isEmpty(pmBidWinningList)) {
  558. for (PmBidWinning pmBidWinning : pmBidWinningList) {
  559. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType());
  560. if (!ObjectUtils.isEmpty(fileInfos)) {
  561. listAll.addAll(fileInfos);
  562. }
  563. }
  564. }
  565. LambdaQueryWrapper<PmBidFailure> pmBidFailureLambdaQueryWrapper = new LambdaQueryWrapper<>();
  566. pmBidFailureLambdaQueryWrapper.eq(PmBidFailure::getDemandId, demandId);
  567. List<PmBidFailure> pmBidFailureList = pmBidFailureService.list(pmBidFailureLambdaQueryWrapper);
  568. if (!ObjectUtils.isEmpty(pmBidFailureService)) {
  569. for (PmBidFailure pmBidFailure : pmBidFailureList) {
  570. List<SysFileInfo> fileInfos = getSysFileInfoList(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType());
  571. if (!ObjectUtils.isEmpty(fileInfos)) {
  572. listAll.addAll(fileInfos);
  573. }
  574. }
  575. }
  576. if (!ObjectUtils.isEmpty(listAll)) {
  577. vo.setFileInfos(listAll);
  578. }
  579. } else if ("质疑处理".equals(moduleName)) {
  580. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType());
  581. if (!ObjectUtils.isEmpty(fileInfos)) {
  582. vo.setFileInfos(fileInfos);
  583. }
  584. } else if ("上传中标通知书".equals(moduleName)) {
  585. List<SysFileInfo> fileInfos = getSysFileInfoList(demandId, SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType());
  586. if (!ObjectUtils.isEmpty(fileInfos)) {
  587. vo.setFileInfos(fileInfos);
  588. }
  589. } else if ("合同填制".equals(moduleName)) {
  590. LambdaQueryWrapper<PmContractInfo> pmContractInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
  591. pmContractInfoLambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  592. PmContractInfo pmContractInfo = pmContractInfoService.getOne(pmContractInfoLambdaQueryWrapper);
  593. if (pmContractInfo != null) {
  594. List<SysFileInfo> fileInfos = getSysFileInfoList(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType());
  595. if (!ObjectUtils.isEmpty(fileInfos)) {
  596. vo.setFileInfos(fileInfos);
  597. }
  598. }
  599. } else if ("建设文档填制".equals(moduleName)) {
  600. LambdaQueryWrapper<PmProjectConstruction> pmProjectConstructionLambdaQueryWrapper = new LambdaQueryWrapper<>();
  601. pmProjectConstructionLambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  602. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(pmProjectConstructionLambdaQueryWrapper);
  603. if (pmProjectConstruction != null) {
  604. List<SysFileInfo> fileInfos = getSysFileInfoList(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType());
  605. if (!ObjectUtils.isEmpty(fileInfos)) {
  606. vo.setFileInfos(fileInfos);
  607. }
  608. }
  609. } else if ("项目归档".equals(moduleName)) {
  610. //do nothing
  611. }
  612. return vo;
  613. }
  614. /**
  615. * 提交采购需求
  616. *
  617. * @param pmDemandReqVo
  618. * @return 结果
  619. */
  620. @Override
  621. @Transactional(rollbackFor = Exception.class)
  622. public boolean commit(PmDemandReqVo pmDemandReqVo) {
  623. PmDemand pmDemand = new PmDemand();
  624. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  625. pmDemand.setProjectStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  626. pmDemand.setRealDemandCommitTime(DateUtils.getNowDate());
  627. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  628. pmDemand.setUpdateTime(DateUtils.getNowDate());
  629. return this.updateById(pmDemand);
  630. }
  631. /**
  632. * 审核采购需求通过
  633. *
  634. * @param pmDemandReqVo
  635. * @return 结果
  636. */
  637. @Override
  638. @Transactional(rollbackFor = Exception.class)
  639. public boolean reviewTo(PmDemandReqVo pmDemandReqVo) {
  640. PmDemand pmDemand = new PmDemand();
  641. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  642. pmDemand.setProjectStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  643. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  644. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_DEMAND_EXAMINE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  645. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  646. pmDemand.setUpdateTime(DateUtils.getNowDate());
  647. pmDemand.setAuditTime(DateUtils.getNowDate());
  648. return this.updateById(pmDemand);
  649. }
  650. /**
  651. * 审核采购需求退回
  652. *
  653. * @param pmDemandReqVo
  654. * @return 结果
  655. */
  656. @Override
  657. @Transactional(rollbackFor = Exception.class)
  658. public boolean reviewReturn(PmDemandReqVo pmDemandReqVo) {
  659. UpdateWrapper<PmDemand> updateWrapper = new UpdateWrapper<>();
  660. updateWrapper.lambda().eq(PmDemand::getDemandId,pmDemandReqVo.getDemandId())
  661. .set(PmDemand::getProjectStatus,PmProjectStatus.DEMAND_AUDIT_RETURN.getCode())
  662. .set(PmDemand::getAdjustReason,pmDemandReqVo.getRefuseReason())
  663. .set(PmDemand::getRealDemandCommitTime,null)
  664. .set(PmDemand::getUpdateBy,pmDemandReqVo.getUpdateBy())
  665. .set(PmDemand::getUpdateTime,DateUtils.getNowDate())
  666. .set(PmDemand::getAuditTime,DateUtils.getNowDate());
  667. return this.update(updateWrapper);
  668. }
  669. /**
  670. * 下达任务
  671. *
  672. * @param pmDemandReqVo
  673. * @return 结果
  674. */
  675. @Override
  676. @Transactional(rollbackFor = Exception.class)
  677. public boolean releaseTask(PmDemandReqVo pmDemandReqVo) {
  678. PmDemand pmDemand = new PmDemand();
  679. pmDemand.setDemandId(pmDemandReqVo.getDemandId());
  680. pmDemand.setProjectStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  681. List<SysFileRef> sysFileRefs = pmDemandReqVo.getSysFileRefs();
  682. uploadFile(pmDemandReqVo.getDemandId(), SysFileRefEnum.PM_TAST_RELEASE.getType(), sysFileRefs, pmDemandReqVo.getUpdateBy());
  683. pmDemand.setUpdateBy(pmDemandReqVo.getUpdateBy());
  684. pmDemand.setUpdateTime(DateUtils.getNowDate());
  685. pmDemand.setAuditTime(DateUtils.getNowDate());
  686. return this.updateById(pmDemand);
  687. }
  688. @Override
  689. @Transactional(rollbackFor = Exception.class)
  690. public boolean uploadFile(Long redId, Integer fileType, List<SysFileRef> sysFileRefs, String upateBy) {
  691. if (!ObjectUtils.isEmpty(sysFileRefs)) {
  692. //删除老的
  693. QueryWrapper<SysFileRef> queryWrapper = new QueryWrapper<>();
  694. queryWrapper.lambda().eq(SysFileRef::getRedId, redId)
  695. .eq(SysFileRef::getType, fileType);
  696. List<SysFileRef> sysFileRefList = sysFileRefService.list(queryWrapper);
  697. if (!CollectionUtils.isEmpty(sysFileRefList)) {
  698. sysFileRefService.remove(queryWrapper);
  699. }
  700. //添加新的
  701. for (SysFileRef ref : sysFileRefs) {
  702. if (ref.getFileId() == null) {
  703. continue;
  704. }
  705. ref.setRedId(redId);
  706. ref.setType(fileType);
  707. ref.setCreated(upateBy);
  708. ref.setCreateTime(new Date());
  709. ref.setUpdated(upateBy);
  710. ref.setUpdateTime(ref.getCreateTime());
  711. sysFileRefService.save(ref);
  712. }
  713. return true;
  714. } else {
  715. return false;
  716. }
  717. }
  718. @Override
  719. @Transactional(rollbackFor = Exception.class)
  720. public boolean insertPmReleaseAnnouncement(PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) throws Exception {
  721. PmDemand pmDemand = this.getById(pmReleaseAnnouncementReqVo.getDemandId());
  722. if (ObjectUtils.isEmpty(pmDemand)) {
  723. throw new Exception("参数错误");
  724. }
  725. if (ObjectUtils.isEmpty(pmReleaseAnnouncementReqVo.getSysFileRefs())) {
  726. throw new Exception("上传附件不能为空");
  727. }
  728. PmReleaseAnnouncement pmReleaseAnnouncement = new PmReleaseAnnouncement();
  729. BeanUtils.copyProperties(pmReleaseAnnouncementReqVo, pmReleaseAnnouncement);
  730. if (pmReleaseAnnouncementService.saveOrUpdate(pmReleaseAnnouncement)) {
  731. uploadFile(pmReleaseAnnouncement.getId(), SysFileRefEnum.PM_ANNOUNCEMENT_FILE.getType(), pmReleaseAnnouncementReqVo.getSysFileRefs(), pmReleaseAnnouncementReqVo.getUpdateBy());
  732. PmDemand pmDemandUpdate = new PmDemand();
  733. pmDemandUpdate.setDemandId(pmReleaseAnnouncementReqVo.getDemandId());
  734. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  735. pmDemandUpdate.setUpdateTime(pmReleaseAnnouncementReqVo.getUpdateTime());
  736. pmDemandUpdate.setUpdateBy(pmReleaseAnnouncementReqVo.getUpdateBy());
  737. if (this.updateById(pmDemandUpdate)) {
  738. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  739. BaseNotice baseNotice = new BaseNotice();
  740. baseNotice.setName(pmDemand.getProjectName());
  741. baseNotice.setTitle(pmDemand.getProjectName() + "招标公告");
  742. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  743. lambdaQueryWrapper.eq(BaseNoticeType::getName, "招标公告");
  744. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  745. if (baseNoticeType == null) {
  746. throw new Exception("招标公告 公告类型不存在");
  747. }
  748. baseNotice.setType(baseNoticeType.getId());
  749. baseNotice.setReleaseTime(pmReleaseAnnouncement.getReleaseTime());
  750. return this.baseNoticeService.saveOrUpdate(baseNotice);
  751. } else {
  752. return false;
  753. }
  754. } else {
  755. return false;
  756. }
  757. }
  758. @Override
  759. @Transactional(rollbackFor = Exception.class)
  760. public boolean insertExpertBatch(PmBaseExpertFillReqVo pmBaseExpertFillReqVo) throws Exception {
  761. PmDemand pmDemand = this.getById(pmBaseExpertFillReqVo.getDemandId());
  762. if (ObjectUtils.isEmpty(pmDemand)) {
  763. throw new Exception("参数错误");
  764. }
  765. List<BaseExpert> baseExpertList = pmBaseExpertFillReqVo.getBaseExpertList();
  766. if (ObjectUtils.isEmpty(baseExpertList)) {
  767. throw new Exception("参数错误");
  768. }
  769. Date now = new Date();
  770. for (BaseExpert baseExpert : baseExpertList) {
  771. if (NameListType.BLACK.getCode().equals(baseExpert.getStatus())) {
  772. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")属于黑名单");
  773. } else {
  774. if (ObjectUtils.isEmpty(baseExpert.getStatus())) {
  775. baseExpert.setStatus(NameListType.WHITE.getCode());
  776. }
  777. }
  778. if (ObjectUtils.isEmpty(baseExpert.getVarietyPurchase()) || !baseExpert.getVarietyPurchase().contains(pmDemand.getProjectType())) {
  779. throw new Exception("该专家(身份证号:" + baseExpert.getIdNumber() + ")所属采购品种和项目类型不匹配");
  780. }
  781. if (ObjectUtils.isEmpty(baseExpert.getCreated())) {
  782. baseExpert.setCreated(pmBaseExpertFillReqVo.getCreateBy());
  783. baseExpert.setCreateTime(now);
  784. }
  785. if (ObjectUtils.isEmpty(baseExpert.getUpdated())) {
  786. baseExpert.setUpdated(pmBaseExpertFillReqVo.getUpdateBy());
  787. baseExpert.setUpdateTime(now);
  788. }
  789. if (baseExpertService.saveOrUpdate(baseExpert)) {
  790. LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  791. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  792. .eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  793. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertFillReqVo.getAccessTime());
  794. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(pmDemandExpertRefLambdaQueryWrapper);
  795. if (pmDemandExpertRef == null) {
  796. pmDemandExpertRef = new PmDemandExpertRef();
  797. pmDemandExpertRef.setCreateBy(pmBaseExpertFillReqVo.getCreateBy());
  798. pmDemandExpertRef.setCreateTime(now);
  799. }
  800. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  801. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  802. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertFillReqVo.getAccessTime()));
  803. pmDemandExpertRef.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
  804. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  805. pmDemandExpertRefService.saveOrUpdate(pmDemandExpertRef);
  806. }
  807. }
  808. return true;
  809. }
  810. @Override
  811. @Transactional(rollbackFor = Exception.class)
  812. public boolean extractExpertBatch(PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) throws Exception {
  813. Integer technicalExpertNumber = pmBaseExpertExtractReqVo.getTechnicalExpertNumber();
  814. if (technicalExpertNumber == null) {
  815. technicalExpertNumber = 0;
  816. }
  817. Integer economicExpertNumber = pmBaseExpertExtractReqVo.getEconomicExpertNumber();
  818. if (economicExpertNumber == null) {
  819. economicExpertNumber = 0;
  820. }
  821. Integer legalAffairsExpertNumber = pmBaseExpertExtractReqVo.getLegalAffairsExpertNumber();
  822. if (legalAffairsExpertNumber == null) {
  823. legalAffairsExpertNumber = 0;
  824. }
  825. Integer spareExpertNumber = pmBaseExpertExtractReqVo.getSpareExpertNumber();
  826. if (spareExpertNumber == null) {
  827. spareExpertNumber = 0;
  828. }
  829. String professional = pmBaseExpertExtractReqVo.getProfessional();
  830. if (spareExpertNumber > 0 && ObjectUtils.isEmpty(professional)) {
  831. throw new Exception("抽取备用专家必须选择专家专业");
  832. }
  833. PmDemand pmDemand = this.getById(pmBaseExpertExtractReqVo.getDemandId());
  834. if (ObjectUtils.isEmpty(pmDemand)) {
  835. throw new Exception("参数错误");
  836. }
  837. String needAvoidUnit = pmBaseExpertExtractReqVo.getNeedAvoidUnit();
  838. List<String> needAvoidUnitList = null;
  839. if (!ObjectUtils.isEmpty(needAvoidUnit)) {
  840. String[] arr = needAvoidUnit.split(",");
  841. needAvoidUnitList = Arrays.asList(arr);
  842. }
  843. String localArea = pmBaseExpertExtractReqVo.getLocalArea();
  844. List<String> sysRegionCodeList = new ArrayList<>();
  845. if (!ObjectUtils.isEmpty(localArea)) {
  846. if (!StringUtils.isNumeric(localArea)) {
  847. throw new Exception("地域必须传数字代码");
  848. }
  849. sysRegionCodeList.add(localArea);
  850. //找到该地域code对应的子列表
  851. List<SysRegionVO> sysRegionVOList = iSysRegionService.findChildDivisions(localArea);
  852. if (!ObjectUtils.isEmpty(sysRegionVOList)) {
  853. for (SysRegionVO vo : sysRegionVOList) {
  854. sysRegionCodeList.add(vo.getCode());
  855. }
  856. }
  857. }
  858. //从专家库中查询符合项目类型的以及是白名单的全部列表
  859. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
  860. lw.eq(BaseExpert::getVarietyPurchase, pmDemand.getProjectType())
  861. .eq(BaseExpert::getStatus, NameListType.WHITE.getCode())
  862. .notIn(!ObjectUtils.isEmpty(needAvoidUnitList), BaseExpert::getUnitInformation, needAvoidUnitList)
  863. .in(!ObjectUtils.isEmpty(sysRegionCodeList), BaseExpert::getLocalArea, sysRegionCodeList);
  864. List<BaseExpert> baseExpertList = baseExpertService.list(lw);
  865. if (ObjectUtils.isEmpty(baseExpertList)) {
  866. throw new Exception("没抽取到符合条件的专家");
  867. }
  868. //从列表中挑出来各个类型的子列表
  869. List<BaseExpert> technicalExpertList = new ArrayList<>();
  870. List<BaseExpert> economicExpertList = new ArrayList<>();
  871. List<BaseExpert> legalAffairsExpertList = new ArrayList<>();
  872. List<BaseExpert> spareExpertList = new ArrayList<>();
  873. for (BaseExpert baseExpert : baseExpertList) {
  874. if (technicalExpertNumber > 0) {
  875. if (baseExpert.getExpertType().contains(ExpertType.TECHNICAL_EXPERT.getCode())) {
  876. technicalExpertList.add(baseExpert);
  877. }
  878. }
  879. if (economicExpertNumber > 0) {
  880. if (baseExpert.getExpertType().contains(ExpertType.ECONOMIC_EXPERT.getCode())) {
  881. economicExpertList.add(baseExpert);
  882. }
  883. }
  884. if (legalAffairsExpertNumber > 0) {
  885. if (baseExpert.getExpertType().contains(ExpertType.LEGALAFFAIRS_EXPERT.getCode())) {
  886. legalAffairsExpertList.add(baseExpert);
  887. }
  888. }
  889. if (spareExpertNumber > 0) {
  890. String[] arr = professional.split(",");
  891. List<String> professionalList = Arrays.asList(arr);
  892. String majorType = baseExpert.getMajorType();
  893. if (!ObjectUtils.isEmpty(majorType)) {
  894. String[] arr2 = majorType.split(",");
  895. List<String> majorTypeList = Arrays.asList(arr2);
  896. if (hasIntersection(professionalList, majorTypeList)) {
  897. spareExpertList.add(baseExpert);
  898. }
  899. }
  900. }
  901. }
  902. //从子列表中随机抽取符合数据量的
  903. List<BaseExpert> alltExpertList = new ArrayList<>();
  904. if (!ObjectUtils.isEmpty(technicalExpertList)) {
  905. alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
  906. }
  907. if (!ObjectUtils.isEmpty(economicExpertList)) {
  908. alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
  909. }
  910. if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
  911. alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
  912. }
  913. if (!ObjectUtils.isEmpty(spareExpertList)) {
  914. alltExpertList.addAll(RandomUtil.getRandomList(spareExpertList, spareExpertNumber));
  915. }
  916. if (ObjectUtils.isEmpty(alltExpertList)) {
  917. throw new Exception("没抽取到符合条件的专家");
  918. } else {
  919. List<PmDemandExpertRef> pmDemandExpertRefList = new ArrayList<>();
  920. for (BaseExpert baseExpert : alltExpertList) {
  921. LambdaQueryWrapper<PmDemandExpertRef> baseExpertLambdaQueryWrapper = new LambdaQueryWrapper<>();
  922. baseExpertLambdaQueryWrapper.eq(PmDemandExpertRef::getExpertId, baseExpert.getId().longValue())
  923. .eq(PmDemandExpertRef::getDemandId, pmDemand.getDemandId())
  924. .eq(PmDemandExpertRef::getAccessTime, pmBaseExpertExtractReqVo.getAccessTime());
  925. PmDemandExpertRef pmDemandExpertRef = pmDemandExpertRefService.getOne(baseExpertLambdaQueryWrapper);
  926. if (pmDemandExpertRef == null) {
  927. pmDemandExpertRef = new PmDemandExpertRef();
  928. pmDemandExpertRef.setCreateBy(pmBaseExpertExtractReqVo.getCreateBy());
  929. pmDemandExpertRef.setCreateTime(new Date());
  930. }
  931. pmDemandExpertRef.setDemandId(pmDemand.getDemandId());
  932. pmDemandExpertRef.setExpertId(baseExpert.getId().longValue());
  933. pmDemandExpertRef.setAccessTime(DateUtils.parseDate(pmBaseExpertExtractReqVo.getAccessTime()));
  934. pmDemandExpertRef.setUpdateBy(pmBaseExpertExtractReqVo.getCreateBy());
  935. pmDemandExpertRef.setUpdateTime(pmDemandExpertRef.getCreateTime());
  936. pmDemandExpertRefList.add(pmDemandExpertRef);
  937. }
  938. return pmDemandExpertRefService.saveOrUpdateBatch(pmDemandExpertRefList);
  939. }
  940. }
  941. //二个列表是否有交集
  942. private boolean hasIntersection(List<String> professionalList, List<String> majorTypeList) {
  943. for (String professiona : professionalList) {
  944. for (String majorType : majorTypeList) {
  945. if (professiona.equals(majorType)) {
  946. return true;
  947. }
  948. }
  949. }
  950. return false;
  951. }
  952. @Override
  953. @Transactional(rollbackFor = Exception.class)
  954. public boolean insertBidOpeningBatch(PmBidOpeningFillReqVo pmBidOpeningFillReqVo) throws Exception {
  955. PmDemand pmDemand = this.getById(pmBidOpeningFillReqVo.getDemandId());
  956. if (ObjectUtils.isEmpty(pmDemand)) {
  957. throw new Exception("参数错误");
  958. }
  959. //从发布公告里获取开标时间
  960. LambdaQueryWrapper<PmReleaseAnnouncement> lw = new LambdaQueryWrapper<>();
  961. lw.eq(PmReleaseAnnouncement::getDemandId, pmDemand.getDemandId()).orderByDesc(PmReleaseAnnouncement::getReleaseTime)
  962. .last(" limit 1 ");
  963. PmReleaseAnnouncement pmReleaseAnnouncement = this.pmReleaseAnnouncementService.getOne(lw);
  964. if (pmReleaseAnnouncement == null) {
  965. throw new Exception("发布公告不存在");
  966. }
  967. Date tenderOpenTime = pmReleaseAnnouncement.getTenderOpenTime();
  968. Date now = new Date();
  969. List<PmBidOpening> pmBidOpeningList = pmBidOpeningFillReqVo.getPmBidOpeningList();
  970. for (PmBidOpening pmBidOpening : pmBidOpeningList) {
  971. if (ObjectUtils.isEmpty(pmBidOpening.getBidderName())) {
  972. throw new Exception("投标人名称不能为空");
  973. }
  974. if (ObjectUtils.isEmpty(pmBidOpening.getScore())) {
  975. throw new Exception("分数不能为空");
  976. }
  977. pmBidOpening.setOpenBidTime(tenderOpenTime);
  978. pmBidOpening.setDemandId(pmBidOpeningFillReqVo.getDemandId());
  979. pmBidOpening.setCreateBy(pmBidOpeningFillReqVo.getCreateBy());
  980. pmBidOpening.setCreateTime(now);
  981. pmBidOpening.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  982. pmBidOpening.setUpdateTime(now);
  983. }
  984. if (pmBidOpeningService.saveOrUpdateBatch(pmBidOpeningList)) {
  985. PmDemand pmDemandUpdate = new PmDemand();
  986. pmDemandUpdate.setDemandId(pmDemand.getDemandId());
  987. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  988. pmDemandUpdate.setUpdateTime(now);
  989. pmDemandUpdate.setUpdateBy(pmBidOpeningFillReqVo.getUpdateBy());
  990. return this.updateById(pmDemandUpdate);
  991. } else {
  992. return false;
  993. }
  994. }
  995. /**
  996. * 填写中标
  997. * @param pmBidWinningReqVo
  998. * @return
  999. * @throws Exception
  1000. */
  1001. @Override
  1002. @Transactional(rollbackFor = Exception.class)
  1003. public boolean insertPmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1004. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1005. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1006. throw new Exception("中标金额不能为空");
  1007. }
  1008. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1009. throw new Exception("中标单位信息列表不能为空");
  1010. }
  1011. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1012. throw new Exception("上传附件不能为空");
  1013. }
  1014. PmBidWinning pmBidWinning = new PmBidWinning();
  1015. BeanUtils.copyProperties(pmBidWinningReqVo, pmBidWinning);
  1016. //修改老的中标信息状态
  1017. if(ObjectUtils.isEmpty(pmBidWinningReqVo.getId())){ //属于新增
  1018. LambdaQueryWrapper<PmBidWinning> pmBidWinningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1019. pmBidWinningLambdaQueryWrapper.eq(PmBidWinning::getDemandId,pmBidWinningReqVo.getDemandId())
  1020. .eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
  1021. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(pmBidWinningLambdaQueryWrapper);
  1022. if(!ObjectUtils.isEmpty(pmBidWinninglist)){
  1023. for(PmBidWinning item : pmBidWinninglist) {
  1024. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1025. updateWrapper1.lambda().set(PmBidWinning::getStatus,BidWinningStatus.BE_REPLACED.getCode())
  1026. .eq(PmBidWinning::getId,item.getId());
  1027. pmBidWinningService.update(updateWrapper1);
  1028. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1029. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus,BidWinningStatus.BE_REPLACED.getCode())
  1030. .eq(PmBidWinningOpeningRef::getWinningId,item.getId())
  1031. .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
  1032. pmBidWinningOpeningRefService.update(updateWrapper2);
  1033. }
  1034. }
  1035. }
  1036. if (pmBidWinningService.saveOrUpdate(pmBidWinning)) {
  1037. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1038. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1039. LambdaQueryWrapper<PmBidWinningOpeningRef> pmBidWinningOpeningRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1040. pmBidWinningOpeningRefLambdaQueryWrapper.eq(PmBidWinningOpeningRef::getOpeningId, pmBidOpeningId)
  1041. .eq(PmBidWinningOpeningRef::getWinningId, pmBidWinning.getId());
  1042. PmBidWinningOpeningRef pmBidWinningOpeningRef = pmBidWinningOpeningRefService.getOne(pmBidWinningOpeningRefLambdaQueryWrapper);
  1043. if (pmBidWinningOpeningRef == null) {
  1044. pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1045. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1046. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1047. }
  1048. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1049. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1050. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1051. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1052. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1053. }
  1054. if (pmBidWinningOpeningRefService.saveOrUpdateBatch(pmBidWinningOpeningRefList)) {
  1055. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), pmBidWinningReqVo.getSysFileRefs(), pmBidWinningReqVo.getUpdateBy());
  1056. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1057. PmDemand pmDemand = this.getById(pmBidWinningReqVo.getDemandId());
  1058. BaseNotice baseNotice = new BaseNotice();
  1059. baseNotice.setName(pmDemand.getProjectName());
  1060. baseNotice.setTitle(pmDemand.getProjectName() + "中标公告");
  1061. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1062. lambdaQueryWrapper.eq(BaseNoticeType::getName, "中标公告");
  1063. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1064. if (baseNoticeType == null) {
  1065. throw new Exception("中标公告 公告类型不存在");
  1066. }
  1067. baseNotice.setType(baseNoticeType.getId());
  1068. baseNotice.setReleaseTime(pmBidWinningReqVo.getBidAnnouncementTime());
  1069. this.baseNoticeService.saveOrUpdate(baseNotice);
  1070. PmDemand pmDemandUpdate = new PmDemand();
  1071. pmDemandUpdate.setDemandId(pmBidWinningReqVo.getDemandId());
  1072. pmDemandUpdate.setProjectStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1073. pmDemandUpdate.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1074. pmDemandUpdate.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1075. return this.updateById(pmDemandUpdate);
  1076. } else {
  1077. return false;
  1078. }
  1079. } else {
  1080. return false;
  1081. }
  1082. }
  1083. @Override
  1084. @Transactional(rollbackFor = Exception.class)
  1085. public boolean updatePmBidWinning(PmBidWinningReqVo pmBidWinningReqVo) throws Exception {
  1086. List<Long> pmBidOpeningIdList = pmBidWinningReqVo.getPmBidOpeningIdList();
  1087. if (ObjectUtils.isEmpty(pmBidOpeningIdList)) {
  1088. throw new Exception("中标单位信息列表不能为空");
  1089. }
  1090. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getBidWinningAmount())) {
  1091. throw new Exception("中标金额不能为空");
  1092. }
  1093. if (ObjectUtils.isEmpty(pmBidWinningReqVo.getSysFileRefs())) {
  1094. throw new Exception("上传附件不能为空");
  1095. }
  1096. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1097. lw.eq(PmBidWinning::getDemandId, pmBidWinningReqVo.getDemandId()).eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
  1098. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1099. if (ObjectUtils.isEmpty(pmBidWinninglist)) {
  1100. throw new Exception("原中标信息不存在");
  1101. }
  1102. //修改老的状态
  1103. for(PmBidWinning item : pmBidWinninglist) {
  1104. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1105. updateWrapper1.lambda().set(PmBidWinning::getStatus,BidWinningStatus.BE_REPLACED.getCode())
  1106. .eq(PmBidWinning::getId,item.getId());
  1107. pmBidWinningService.update(updateWrapper1);
  1108. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1109. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus,BidWinningStatus.BE_REPLACED.getCode())
  1110. .eq(PmBidWinningOpeningRef::getWinningId,item.getId())
  1111. .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
  1112. pmBidWinningOpeningRefService.update(updateWrapper2);
  1113. }
  1114. //新增
  1115. PmBidWinning pmBidWinning = new PmBidWinning();
  1116. BeanUtils.copyProperties(pmBidWinninglist.get(0),pmBidWinning);
  1117. pmBidWinning.setId(null);
  1118. pmBidWinning.setBidWinningAmount(pmBidWinningReqVo.getBidWinningAmount());
  1119. pmBidWinning.setStatus(BidWinningStatus.NORMAL.getCode());
  1120. pmBidWinning.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1121. pmBidWinning.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1122. if (pmBidWinningService.save(pmBidWinning)) {
  1123. List<PmBidWinningOpeningRef> pmBidWinningOpeningRefList = new ArrayList<>();
  1124. for (Long pmBidOpeningId : pmBidOpeningIdList) {
  1125. PmBidWinningOpeningRef pmBidWinningOpeningRef = new PmBidWinningOpeningRef();
  1126. pmBidWinningOpeningRef.setOpeningId(pmBidOpeningId);
  1127. pmBidWinningOpeningRef.setWinningId(pmBidWinning.getId());
  1128. pmBidWinningOpeningRef.setStatus(BidWinningStatus.NORMAL.getCode());
  1129. pmBidWinningOpeningRef.setCreateBy(pmBidWinningReqVo.getCreateBy());
  1130. pmBidWinningOpeningRef.setCreateTime(pmBidWinningReqVo.getCreateTime());
  1131. pmBidWinningOpeningRef.setUpdateBy(pmBidWinningReqVo.getUpdateBy());
  1132. pmBidWinningOpeningRef.setUpdateTime(pmBidWinningReqVo.getUpdateTime());
  1133. pmBidWinningOpeningRefList.add(pmBidWinningOpeningRef);
  1134. }
  1135. LambdaQueryWrapper<SysFileRef> sysFileRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  1136. sysFileRefLambdaQueryWrapper.eq(SysFileRef::getType,SysFileRefEnum.PM_BID_WINNING_FILE.getType())
  1137. .eq(SysFileRef::getRedId,pmBidWinninglist.get(0));
  1138. List<SysFileRef> sysFileRefs = sysFileRefService.list(sysFileRefLambdaQueryWrapper);
  1139. uploadFile(pmBidWinning.getId(), SysFileRefEnum.PM_BID_WINNING_FILE.getType(), sysFileRefs, pmBidWinningReqVo.getUpdateBy());
  1140. return pmBidWinningOpeningRefService.saveBatch(pmBidWinningOpeningRefList);
  1141. } else {
  1142. return false;
  1143. }
  1144. }
  1145. /**
  1146. * 流标
  1147. * @param pmBidFailureReqVo
  1148. * @return
  1149. * @throws Exception
  1150. */
  1151. @Override
  1152. @Transactional(rollbackFor = Exception.class)
  1153. public boolean insertPmBidFailure(PmBidFailureReqVo pmBidFailureReqVo) throws Exception {
  1154. PmBidFailure pmBidFailure = new PmBidFailure();
  1155. BeanUtils.copyProperties(pmBidFailureReqVo, pmBidFailure);
  1156. if (pmBidFailureService.saveOrUpdate(pmBidFailure)) {
  1157. //把中标信息修改状态
  1158. LambdaQueryWrapper<PmBidWinning> lw = new LambdaQueryWrapper<>();
  1159. lw.eq(PmBidWinning::getDemandId, pmBidFailureReqVo.getDemandId()).eq(PmBidWinning::getStatus,BidWinningStatus.NORMAL.getCode());
  1160. List<PmBidWinning> pmBidWinninglist = pmBidWinningService.list(lw);
  1161. if (!ObjectUtils.isEmpty(pmBidWinninglist)) {
  1162. for(PmBidWinning item : pmBidWinninglist) {
  1163. UpdateWrapper<PmBidWinning> updateWrapper1 = new UpdateWrapper<>();
  1164. updateWrapper1.lambda().set(PmBidWinning::getStatus,BidWinningStatus.BE_BID_FAILURE.getCode())
  1165. .eq(PmBidWinning::getId,item.getId());
  1166. pmBidWinningService.update(updateWrapper1);
  1167. UpdateWrapper<PmBidWinningOpeningRef> updateWrapper2 = new UpdateWrapper<>();
  1168. updateWrapper2.lambda().set(PmBidWinningOpeningRef::getStatus,BidWinningStatus.BE_BID_FAILURE.getCode())
  1169. .eq(PmBidWinningOpeningRef::getWinningId,item.getId())
  1170. .eq(PmBidWinningOpeningRef::getStatus,BidWinningStatus.NORMAL.getCode());
  1171. pmBidWinningOpeningRefService.update(updateWrapper2);
  1172. }
  1173. }
  1174. uploadFile(pmBidFailure.getId(), SysFileRefEnum.PM_BID_FAILURE_FILE.getType(), pmBidFailureReqVo.getSysFileRefs(), pmBidFailureReqVo.getUpdateBy());
  1175. //发布公告生成后,会默认将该数据同步到公告管理和首页中
  1176. PmDemand pmDemand = this.getById(pmBidFailureReqVo.getDemandId());
  1177. BaseNotice baseNotice = new BaseNotice();
  1178. baseNotice.setName(pmDemand.getProjectName());
  1179. baseNotice.setTitle(pmDemand.getProjectName() + "流标公告");
  1180. LambdaQueryWrapper<BaseNoticeType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1181. lambdaQueryWrapper.eq(BaseNoticeType::getName, "流标公告");
  1182. BaseNoticeType baseNoticeType = baseNoticeTypeService.getOne(lambdaQueryWrapper);
  1183. if (baseNoticeType == null) {
  1184. throw new Exception("流标公告 公告类型不存在");
  1185. }
  1186. baseNotice.setType(baseNoticeType.getId());
  1187. baseNotice.setReleaseTime(pmBidFailureReqVo.getBidFailureTime());
  1188. this.baseNoticeService.saveOrUpdate(baseNotice);
  1189. PmDemand pmDemandUpdate = new PmDemand();
  1190. pmDemandUpdate.setDemandId(pmBidFailureReqVo.getDemandId());
  1191. pmDemandUpdate.setProjectStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1192. pmDemandUpdate.setUpdateTime(pmBidFailureReqVo.getUpdateTime());
  1193. pmDemandUpdate.setUpdateBy(pmBidFailureReqVo.getUpdateBy());
  1194. return this.updateById(pmDemandUpdate);
  1195. } else {
  1196. return false;
  1197. }
  1198. }
  1199. @Override
  1200. @Transactional(rollbackFor = Exception.class)
  1201. public boolean insertContractInfo(PmContractInfoReqVo pmContractInfoReqVo) throws Exception {
  1202. Long demandId = pmContractInfoReqVo.getDemandId();
  1203. if (ObjectUtils.isEmpty(demandId)) {
  1204. throw new Exception("采购需求ID不能为空");
  1205. }
  1206. PmDemand pmDemand = this.getById(demandId);
  1207. if (ObjectUtils.isEmpty(pmDemand)) {
  1208. throw new Exception("采购需求ID错误");
  1209. }
  1210. List<SysFileRef> sysFileRefs = pmContractInfoReqVo.getSysFileRefs();
  1211. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1212. throw new Exception("上传附件不能为空");
  1213. }
  1214. LambdaQueryWrapper<PmContractInfo> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1215. lambdaQueryWrapper.eq(PmContractInfo::getDemandId, demandId);
  1216. PmContractInfo pmContractInfo = pmContractInfoService.getOne(lambdaQueryWrapper);
  1217. if (pmContractInfo != null) {
  1218. pmContractInfoReqVo.setId(pmContractInfo.getId());
  1219. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1220. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1221. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1222. } else {
  1223. pmContractInfo = new PmContractInfo();
  1224. BeanUtils.copyProperties(pmContractInfoReqVo, pmContractInfo);
  1225. pmContractInfo.setCreateBy(pmContractInfoReqVo.getCreateBy());
  1226. pmContractInfo.setCreateTime(pmContractInfoReqVo.getCreateTime());
  1227. pmContractInfo.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1228. pmContractInfo.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1229. }
  1230. if (pmContractInfoService.saveOrUpdate(pmContractInfo)) {
  1231. this.uploadFile(pmContractInfo.getId(), SysFileRefEnum.PM_CONTRACT_INFO.getType(), sysFileRefs, pmContractInfoReqVo.getUpdateBy());
  1232. PmDemand pmDemandUpdate = new PmDemand();
  1233. pmDemandUpdate.setDemandId(demandId);
  1234. pmDemandUpdate.setProjectStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1235. pmDemandUpdate.setUpdateTime(pmContractInfoReqVo.getUpdateTime());
  1236. pmDemandUpdate.setUpdateBy(pmContractInfoReqVo.getUpdateBy());
  1237. return this.updateById(pmDemandUpdate);
  1238. } else {
  1239. return false;
  1240. }
  1241. }
  1242. @Override
  1243. @Transactional(rollbackFor = Exception.class)
  1244. public boolean insertProjectConstruction(PmProjectConstructionReqVo pmProjectConstructionReqVo) throws Exception {
  1245. Long demandId = pmProjectConstructionReqVo.getDemandId();
  1246. if (ObjectUtils.isEmpty(demandId)) {
  1247. throw new Exception("采购需求ID不能为空");
  1248. }
  1249. PmDemand pmDemand = this.getById(demandId);
  1250. if (ObjectUtils.isEmpty(pmDemand)) {
  1251. throw new Exception("采购需求ID错误");
  1252. }
  1253. List<SysFileRef> sysFileRefs = pmProjectConstructionReqVo.getSysFileRefs();
  1254. if (ObjectUtils.isEmpty(sysFileRefs)) {
  1255. throw new Exception("上传附件不能为空");
  1256. }
  1257. LambdaQueryWrapper<PmProjectConstruction> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  1258. lambdaQueryWrapper.eq(PmProjectConstruction::getDemandId, demandId);
  1259. PmProjectConstruction pmProjectConstruction = pmProjectConstructionService.getOne(lambdaQueryWrapper);
  1260. if (pmProjectConstruction != null) {
  1261. pmProjectConstructionReqVo.setId(pmProjectConstruction.getId());
  1262. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1263. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1264. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1265. } else {
  1266. pmProjectConstruction = new PmProjectConstruction();
  1267. BeanUtils.copyProperties(pmProjectConstructionReqVo, pmProjectConstruction);
  1268. pmProjectConstruction.setCreateBy(pmProjectConstructionReqVo.getCreateBy());
  1269. pmProjectConstruction.setCreateTime(pmProjectConstructionReqVo.getCreateTime());
  1270. pmProjectConstruction.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1271. pmProjectConstruction.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1272. }
  1273. if (pmProjectConstructionService.saveOrUpdate(pmProjectConstruction)) {
  1274. this.uploadFile(pmProjectConstruction.getId(), SysFileRefEnum.PM_PROJECT_CONSTRUCTION.getType(), sysFileRefs, pmProjectConstructionReqVo.getUpdateBy());
  1275. PmDemand pmDemandUpdate = new PmDemand();
  1276. pmDemandUpdate.setDemandId(demandId);
  1277. pmDemandUpdate.setProjectStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1278. pmDemandUpdate.setRealDeliverTime(pmProjectConstructionReqVo.getUpdateTime());
  1279. pmDemandUpdate.setUpdateTime(pmProjectConstructionReqVo.getUpdateTime());
  1280. pmDemandUpdate.setUpdateBy(pmProjectConstructionReqVo.getUpdateBy());
  1281. return this.updateById(pmDemandUpdate);
  1282. } else {
  1283. return false;
  1284. }
  1285. }
  1286. /**
  1287. * 通过需求ID列表 查询采购执行列表 sunhh
  1288. *
  1289. * @param demandIdList
  1290. * @return
  1291. */
  1292. @Override
  1293. public List<PmDemand> selectByDemandIdList(List<Integer> demandIdList) {
  1294. return this.baseMapper.selectByDemandIdList(demandIdList);
  1295. }
  1296. /**
  1297. * 专家库--查询抽取专家列表 非必传条件:专家名称,开始结束时间 sunhh
  1298. *
  1299. * @param baseExpertVo
  1300. * @return
  1301. */
  1302. @Override
  1303. public List<PmDemand> selectExtractionExpert(BaseExpertVo baseExpertVo) {
  1304. return this.baseMapper.selectExtractionExpert(baseExpertVo);
  1305. }
  1306. @Override
  1307. public List<PmDemandResVo> demandWaitCommit() {
  1308. return getListByStatus(PmProjectStatus.DEMAND_WAIT_COMMIT.getCode());
  1309. }
  1310. @Override
  1311. public List<PmDemandResVo> contractWaitFilled() {
  1312. return getListByStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  1313. }
  1314. @Override
  1315. public List<PmDemandResVo> projectWaitFinish() {
  1316. return getListByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1317. }
  1318. @Override
  1319. public List<PmDemandResVo> demandWaitExamine() {
  1320. return getListByStatus(PmProjectStatus.DEMAND_WAIT_AUDIT.getCode());
  1321. }
  1322. @Override
  1323. public List<PmDemandResVo> taskWaitRelease() {
  1324. return getListByStatus(PmProjectStatus.TASK_WAIT_RELEASE.getCode());
  1325. }
  1326. @Override
  1327. public List<PmDemandResVo> waitSelectAgent() {
  1328. return getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode());
  1329. }
  1330. @Override
  1331. public List<PmDemandResVo> waitUpBidFile() {
  1332. return getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode());
  1333. }
  1334. @Override
  1335. public List<PmDemandResVo> waitAnnouncement() {
  1336. return getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode());
  1337. }
  1338. @Override
  1339. public List<PmDemandResVo> waitOpenBid() {
  1340. return getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  1341. }
  1342. @Override
  1343. public List<PmDemandResVo> waitBidAnnouncement() {
  1344. return getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode());
  1345. }
  1346. @Override
  1347. public List<PmDemandResVo> biddingPublicity() {
  1348. return getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode());
  1349. }
  1350. @Override
  1351. public AjaxResult procurementOfficeWillManipulateTotal() {
  1352. List<HomeToDoQueryResVo> homeRes = new ArrayList<>();
  1353. // 待选取代理, 待上传招标文件, 待发布公告, 待开标, 待发布中标公告, 中标公示中
  1354. List<PmDemandResVo> demandRes = new ArrayList<>();
  1355. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_SELECT_AGENT.getCode()));
  1356. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getCode()));
  1357. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_ANNOUNCEMENT.getCode()));
  1358. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_OPEN_BID.getCode()));
  1359. demandRes.addAll(getListByStatus(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getCode()));
  1360. demandRes.addAll(getListByStatus(PmProjectStatus.BIDDING_PUBLICITY.getCode()));
  1361. //计划数据--发函催告
  1362. List<PlanQuarterResponseVo> planRes = planYearsService.willSendLetter();
  1363. //转为首页table展示数据
  1364. if (!ObjectUtils.isEmpty(demandRes) && demandRes.size() > 0) {
  1365. for (PmDemandResVo demandResVoVo : demandRes) {
  1366. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1367. BeanUtils.copyProperties(demandResVoVo, home);
  1368. homeRes.add(home);
  1369. }
  1370. }
  1371. if (!ObjectUtils.isEmpty(planRes) && planRes.size() > 0) {
  1372. for (PlanQuarterResponseVo planVo : planRes) {
  1373. HomeToDoQueryResVo home = new HomeToDoQueryResVo();
  1374. BeanUtils.copyProperties(planVo, home);
  1375. homeRes.add(home);
  1376. }
  1377. }
  1378. return AjaxResult.success(homeRes);
  1379. }
  1380. /**
  1381. * 统计分析-采购项目信息统计
  1382. *
  1383. * @param pmDemandReqVo
  1384. * @return
  1385. */
  1386. @Override
  1387. public Map<String, Integer> purchaseProjectStatistical(PmDemandReqVo pmDemandReqVo) {
  1388. Map<String, Integer> mapReturn = new HashMap<>();
  1389. // 查询项目总数量
  1390. Map<String, Integer> mapCount = pmDemandMapper.purchaseProjectStatistical(pmDemandReqVo);
  1391. // 查询已完成项目数量,预算金额数量
  1392. Map<String, Integer> mapYWC = pmDemandMapper.purchaseProjectStatisticalYWC(pmDemandReqVo);
  1393. // 查询新创建项目数量,预算金额数量
  1394. Map<String, Integer> mapXCJ = pmDemandMapper.purchaseProjectStatisticalXCJ(pmDemandReqVo);
  1395. // 查询去年完成项目数量,预算金额数量
  1396. Map<String, Integer> mapQNWC = pmDemandMapper.purchaseProjectStatisticalQNWC(pmDemandReqVo);
  1397. mapReturn.putAll(mapCount);
  1398. mapReturn.putAll(mapYWC);
  1399. mapReturn.putAll(mapXCJ);
  1400. mapReturn.putAll(mapQNWC);
  1401. return mapReturn;
  1402. }
  1403. @Override
  1404. public List<StatisticalChartsResVo> countByProjectAttr() {
  1405. List<StatisticalChartsResVo> resVos = pmDemandMapper.countByProjectAttr();
  1406. for (StatisticalChartsResVo chartsResVo : resVos) {
  1407. for (PmProjectStatus value : PmProjectStatus.values()) {
  1408. if (value.getCode().equals(chartsResVo.getColumnName())) {
  1409. chartsResVo.setColumnName(value.getInfo());
  1410. break;
  1411. }
  1412. }
  1413. }
  1414. return resVos;
  1415. }
  1416. @Override
  1417. public List<StatisticalChartsResVo> countByEvaluation(PmDemandReqVo pmDemandReqVo) {
  1418. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1419. //概算金额包括:100万以下采购任务、100至500万元采购任务、500至1000万元采购任务、1000至5000万元采购任务、5000至1亿元采购任务、1亿元及以上采购任务
  1420. StatisticalChartsResVo resVo = pmDemandMapper.countByEvaluationLt(100);
  1421. resVo.setColumnName("100万以下采购任务");
  1422. resVos.add(resVo);
  1423. StatisticalChartsResVo resVo1 = pmDemandMapper.countByEvaluationBet(100, 500);
  1424. resVo1.setColumnName("100至500万元采购任务");
  1425. resVos.add(resVo1);
  1426. StatisticalChartsResVo resVo2 = pmDemandMapper.countByEvaluationBet(500, 1000);
  1427. resVo2.setColumnName("500至1000万元采购任务");
  1428. resVos.add(resVo2);
  1429. StatisticalChartsResVo resVo3 = pmDemandMapper.countByEvaluationBet(1000, 5000);
  1430. resVo3.setColumnName("1000至5000万元采购任务");
  1431. resVos.add(resVo3);
  1432. StatisticalChartsResVo resVo4 = pmDemandMapper.countByEvaluationBet(5000, 10000);
  1433. resVo4.setColumnName("5000至1亿元采购任务");
  1434. resVos.add(resVo4);
  1435. StatisticalChartsResVo resVo5 = pmDemandMapper.countByEvaluationGt(10000);
  1436. resVo5.setColumnName("1亿元及以上采购任务");
  1437. resVos.add(resVo5);
  1438. return resVos;
  1439. }
  1440. @Override
  1441. public AjaxResult countProjectExceed(PmDemandReqVo pmDemandReqVo) {
  1442. HashMap<String, String> resMap = new HashMap<>();
  1443. //执行滞后采购项目:本年度所有的逾期项目数
  1444. //预算金额:本年度所有逾期项目累加的预算金额
  1445. StatisticalChartsResVo resVo = pmDemandMapper.countProjectExceed();
  1446. resMap.put("执行滞后采购项目", resVo.getNum());
  1447. resMap.put("预算金额", resVo.getEvaluationTotal());
  1448. //滞后项目数量占比:指本年度逾期项目数量/本年度所有项目数量
  1449. Integer thisYear = pmDemandMapper.countThisYear();
  1450. resMap.put("滞后项目数量占比", getPercent(Integer.parseInt(resVo.getNum()), thisYear));
  1451. return AjaxResult.success(resMap);
  1452. }
  1453. /**
  1454. * 统计不同时间维度的逾期项目
  1455. *
  1456. * @return
  1457. */
  1458. @Override
  1459. public AjaxResult exceedAnalysis(PmDemandReqVo pmDemandReqVo) {
  1460. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1461. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectExceedYear();
  1462. if (pmDemandReqVo.getTimeType().equals("1")) {
  1463. resMap.put("年", byYear);
  1464. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1465. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1466. for (StatisticalChartsResVo chartsResVo : byYear) {
  1467. for (int i = 1; i <= 4; i++) {
  1468. StatisticalChartsResVo quarter = pmDemandMapper.countProjectExceedQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
  1469. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1470. byQuarter.add(quarter);
  1471. }
  1472. }
  1473. resMap.put("季度", byQuarter);
  1474. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1475. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectExceedMonth();
  1476. resMap.put("月", byMonth);
  1477. }
  1478. return AjaxResult.success(resMap);
  1479. }
  1480. @Override
  1481. public AjaxResult taskQuantityAnalysis(PmDemandReqVo pmDemandReqVo) {
  1482. HashMap<String, List<StatisticalChartsResVo>> resMap = new HashMap<>();
  1483. //任务数量趋势分析:按照月、季度、年统计“项目属性”字段中“重大规划”属性的项目
  1484. List<StatisticalChartsResVo> byYear = pmDemandMapper.countProjectMajorByYear();
  1485. if (pmDemandReqVo.getTimeType().equals("1")) {
  1486. resMap.put("年", byYear);
  1487. } else if (pmDemandReqVo.getTimeType().equals("2")) {
  1488. List<StatisticalChartsResVo> byQuarter = new LinkedList<>();
  1489. for (StatisticalChartsResVo chartsResVo : byYear) {
  1490. for (int i = 1; i <= 4; i++) {
  1491. StatisticalChartsResVo quarter = pmDemandMapper.countProjectMajorByQuarter(i, Integer.parseInt(chartsResVo.getColumnName()));
  1492. quarter.setColumnName(chartsResVo.getColumnName() + "年第" + i + "季度");
  1493. byQuarter.add(quarter);
  1494. }
  1495. }
  1496. resMap.put("季度", byQuarter);
  1497. } else if (pmDemandReqVo.getTimeType().equals("3")) {
  1498. List<StatisticalChartsResVo> byMonth = pmDemandMapper.countProjectMajorByMonth();
  1499. resMap.put("月", byMonth);
  1500. }
  1501. return AjaxResult.success(resMap);
  1502. }
  1503. @Override
  1504. public AjaxResult newFinishPro() {
  1505. // 新完成采购任务数量:状态为“合同待填制”、“项目建设中”、“项目建设完成”的项目
  1506. // 预算金额:“合同待填制”、“项目建设中”、“项目建设完成”的项目累加的预算金额
  1507. List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNumTwo();
  1508. if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
  1509. for (StatisticalChartsResVo vo : everyStatusNum) {
  1510. switch (vo.getColumnName()) {
  1511. case "15":
  1512. vo.setColumnName(PmProjectStatus.CONTRACT_WAIT_FILL.getInfo());
  1513. case "16":
  1514. vo.setColumnName(PmProjectStatus.UNDER_CONSTRUCTION.getInfo());
  1515. case "17":
  1516. vo.setColumnName(PmProjectStatus.COMPLETION_CONSTRUCTION.getInfo());
  1517. }
  1518. }
  1519. }
  1520. //合同金额:“合同待填制”、“项目建设中”、“项目建设完成”的项目累加的合同金额
  1521. return AjaxResult.success(everyStatusNum);
  1522. }
  1523. @Override
  1524. public AjaxResult countEveryStatusNum(PmDemandReqVo pmDemandReqVo) {
  1525. //指项目进行到各个阶段的数量
  1526. //阶段包括:待选取代理、待上传招标文件、待发布公告、待开标、待发布中标公告、中标公式中
  1527. List<StatisticalChartsResVo> everyStatusNum = pmDemandMapper.countEveryStatusNum();
  1528. if (!ObjectUtils.isEmpty(everyStatusNum) && everyStatusNum.size() > 0) {
  1529. for (StatisticalChartsResVo vo : everyStatusNum) {
  1530. switch (vo.getColumnName()) {
  1531. case "9":
  1532. vo.setColumnName(PmProjectStatus.WAIT_SELECT_AGENT.getInfo());
  1533. case "10":
  1534. vo.setColumnName(PmProjectStatus.WAIT_UPLOAD_BID_FILE.getInfo());
  1535. case "11":
  1536. vo.setColumnName(PmProjectStatus.WAIT_ANNOUNCEMENT.getInfo());
  1537. case "12":
  1538. vo.setColumnName(PmProjectStatus.WAIT_OPEN_BID.getInfo());
  1539. case "13":
  1540. vo.setColumnName(PmProjectStatus.WAIT_BID_ANNOUNCEMENT.getInfo());
  1541. case "14":
  1542. vo.setColumnName(PmProjectStatus.BIDDING_PUBLICITY.getInfo());
  1543. }
  1544. }
  1545. }
  1546. return AjaxResult.success(everyStatusNum);
  1547. }
  1548. @Override
  1549. public AjaxResult exceedMarketAnalysis(PmDemandReqVo pmDemandReqVo) {
  1550. //所有滞后
  1551. List<PmDemand> demandList = pmDemandMapper.countProjectExceedAll();
  1552. //滞后时长包括:滞后1个月以内的采购任务、滞后1至3个月采购任务、滞后3至6个月采购任务、滞后6个月至1年采购任务、滞后1年以上采购任务
  1553. HashMap<String, Integer> map = new LinkedHashMap<>();
  1554. map.put("滞后1个月以内的采购任务", 0);
  1555. map.put("滞后1至3个月采购任务", 0);
  1556. map.put("滞后3至6个月采购任务", 0);
  1557. map.put("滞后6个月至1年采购任务", 0);
  1558. map.put("滞后1年以上采购任务", 0);
  1559. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1560. for (PmDemand demand : demandList) {
  1561. //滞后时间
  1562. Long exTime = null;
  1563. if (!ObjectUtils.isEmpty(demand.getRealDemandCommitTime()) && demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime() > 0) {
  1564. exTime = demand.getRealDemandCommitTime().getTime() - demand.getPlanDemandSubTime().getTime();
  1565. } else if (!ObjectUtils.isEmpty(demand.getRealPurchaseFinishTime()) && demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime() > 0) {
  1566. exTime = demand.getRealPurchaseFinishTime().getTime() - demand.getPlanPurchaseFinishTime().getTime();
  1567. } else if (!ObjectUtils.isEmpty(demand.getRealDeliverTime()) && demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime() > 0) {
  1568. exTime = demand.getRealDeliverTime().getTime() - demand.getPlanDeliverTime().getTime();
  1569. }
  1570. if (exTime < Long.valueOf("2592000000")) {
  1571. map.put("滞后1个月以内的采购任务", map.get("滞后1个月以内的采购任务") + 1);
  1572. }
  1573. if (exTime >= Long.valueOf("2592000000") && exTime < Long.valueOf("7776000000")) {
  1574. map.put("滞后1至3个月采购任务", map.get("滞后1至3个月采购任务") + 1);
  1575. }
  1576. if (exTime >= Long.valueOf("7776000000") && exTime < Long.valueOf("15552000000")) {
  1577. map.put("滞后3至6个月采购任务", map.get("滞后3至6个月采购任务") + 1);
  1578. }
  1579. if (exTime >= Long.valueOf("15552000000") && exTime < Long.valueOf("31104000000")) {
  1580. map.put("滞后6个月至1年采购任务", map.get("滞后6个月至1年采购任务") + 1);
  1581. }
  1582. if (exTime > Long.valueOf("31104000000")) {
  1583. map.put("滞后1年以上采购任务", map.get("滞后1年以上采购任务") + 1);
  1584. }
  1585. }
  1586. }
  1587. return AjaxResult.success(map);
  1588. }
  1589. @Override
  1590. public AjaxResult countMajorProject(PmDemandReqVo pmDemandReqVo) {
  1591. List<StatisticalChartsResVo> resVos = new ArrayList<>();
  1592. //数量:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目数
  1593. //预算金额:指本年度状态为“项目建设完成”的项目属性为“重大规划”的项目累加的预算金额
  1594. StatisticalChartsResVo resVo = new StatisticalChartsResVo();
  1595. resVo = pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1596. resVo.setColumnName("今年已完成数量");
  1597. resVos.add(resVo);
  1598. //正常推进项目:指本年度正在进行中的项目属性为“重大规划”的项目数
  1599. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1600. StatisticalChartsResVo resVo1 = new StatisticalChartsResVo();
  1601. resVo1 = pmDemandMapper.majorProjectByStatus(PmProjectStatus.UNDER_CONSTRUCTION.getCode());
  1602. resVo1.setColumnName("正常推进数量");
  1603. resVos.add(resVo1);
  1604. //执行滞后数量:指本年度逾期项目中,项目属性为“重大规划”的项目数
  1605. //预算金额:指本年度正在进行中的项目属性为“重大规划”的项目累加的预算金额
  1606. StatisticalChartsResVo resVo2 = new StatisticalChartsResVo();
  1607. resVo2 = pmDemandMapper.countMajorProjectExceed();
  1608. resVo2.setColumnName("执行滞后数量");
  1609. resVos.add(resVo2);
  1610. //上年度重大规划采购任务数量:指上年度项目中,项目属性为“重大规划”的项目数
  1611. //预算金额:指上年度项目中,项目属性为“重大规划”的项目累加的预算金额
  1612. StatisticalChartsResVo resVo3 = new StatisticalChartsResVo();
  1613. resVo3 = pmDemandMapper.countMajorProjectLastYear();
  1614. resVo3.setColumnName("上年度重大规划采购任务数量");
  1615. resVos.add(resVo3);
  1616. //resVo2=pmDemandMapper.majorProjectByStatus(PmProjectStatus.COMPLETION_CONSTRUCTION.getCode());
  1617. return AjaxResult.success(resVos);
  1618. }
  1619. /**
  1620. * 通过计划ID查询项目数据
  1621. *
  1622. * @param planId
  1623. * @return
  1624. */
  1625. @Override
  1626. public PmDemand selectByPlanId(Integer planId) {
  1627. return pmDemandMapper.selectByPlanId(planId);
  1628. }
  1629. /**
  1630. * 采购项目--项目数量分析
  1631. *
  1632. * @param pmDemandReqVo
  1633. * @return
  1634. */
  1635. @Override
  1636. public Map<String, Integer> purchaseProjectNumber(PmDemandReqVo pmDemandReqVo) {
  1637. return null;
  1638. }
  1639. /**
  1640. * 项目执行进度统计
  1641. * 1、正常推进项目数量:指未完成并且没有逾期的项目
  1642. * 预算金额:指未完成并且没有逾期的项目累加的预算金额
  1643. * 2、未完成采购任务:“合同待填制”状态之前的项目
  1644. * 预算金额:“合同待填制”状态之前的项目累加的预算金额
  1645. *
  1646. * @param pmDemandReqVo
  1647. * @return
  1648. */
  1649. @Override
  1650. public Map<String, Integer> purchaseProjectExecute(PmDemandReqVo pmDemandReqVo) {
  1651. Map<String, Integer> mapReturn = new HashMap<>();
  1652. // 正常推进项目数量、预算金额
  1653. Map<String, Integer> mapNormalPropulsion = pmDemandMapper.purchaseProjectExecuteNormalPropulsion(pmDemandReqVo);
  1654. // 未完成采购任务,预算金额
  1655. Map<String, Integer> mapIncomplete = pmDemandMapper.purchaseProjectExecuteIncomplete(pmDemandReqVo);
  1656. mapReturn.putAll(mapNormalPropulsion);
  1657. mapReturn.putAll(mapIncomplete);
  1658. return mapReturn;
  1659. }
  1660. /**
  1661. * 已完成项目数量统计
  1662. *
  1663. * @param pmDemandReqVo
  1664. * @return
  1665. */
  1666. @Override
  1667. public List<Map<String, Integer>> purchaseProjectCompleteNumber(PmDemandReqVo pmDemandReqVo) {
  1668. List<Map<String, Integer>> mapReturn = new ArrayList<>();
  1669. // 统计时间类型 1:年度,2:季度,3:月份
  1670. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1671. // 查询数据库中最小的年份
  1672. int minYear = pmDemandMapper.selectMinYear();
  1673. // 获取当前年份
  1674. Calendar calendar = Calendar.getInstance();
  1675. int year = calendar.get(Calendar.YEAR);
  1676. // 获取统计数据
  1677. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberYear(pmDemandReqVo);
  1678. mapReturn.addAll(listMap);
  1679. for (int i = minYear; i <= year; i++) {
  1680. for (Map<String, Integer> map : listMap) {
  1681. if (i != Integer.valueOf(map.get("yy"))) {
  1682. Map<String, Integer> map1 = new HashMap<>();
  1683. map1.put("yy", i);
  1684. map1.put("evaluation", 0);
  1685. map1.put("contractAmount", 0);
  1686. map1.put("countNum", 0);
  1687. mapReturn.add(map1);
  1688. }
  1689. }
  1690. }
  1691. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1692. // 当前年份季度统计
  1693. // 获取统计数据
  1694. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberQuarter(pmDemandReqVo);
  1695. mapReturn.addAll(listMap);
  1696. for (int i = 1; i <= 4; i++) {
  1697. for (Map<String, Integer> map : listMap) {
  1698. if (i != map.get("yy")) {
  1699. Map<String, Integer> map1 = new HashMap<>();
  1700. map1.put("yy", i);
  1701. map1.put("evaluation", 0);
  1702. map1.put("contractAmount", 0);
  1703. map1.put("countNum", 0);
  1704. mapReturn.add(map1);
  1705. }
  1706. }
  1707. }
  1708. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1709. // 当前年份月份统计
  1710. // 获取统计数据
  1711. List<Map<String, Integer>> listMap = pmDemandMapper.selectpurchaseProjectCompleteNumberMonth(pmDemandReqVo);
  1712. mapReturn.addAll(listMap);
  1713. for (int i = 1; i <= 12; i++) {
  1714. for (Map<String, Integer> map : listMap) {
  1715. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1716. map.put("yy", ii);
  1717. if (i != ii) {
  1718. Map<String, Integer> map1 = new HashMap<>();
  1719. map1.put("yy", i);
  1720. map1.put("evaluation", 0);
  1721. map1.put("contractAmount", 0);
  1722. map1.put("countNum", 0);
  1723. mapReturn.add(map1);
  1724. }
  1725. }
  1726. }
  1727. }
  1728. return mapReturn;
  1729. }
  1730. /**
  1731. * 各阶段项目数量分布
  1732. * @param pmDemandReqVo
  1733. * @return
  1734. */
  1735. @Override
  1736. public List<Map<String, String>> purchaseProjectDistribution(PmDemandReqVo pmDemandReqVo) {
  1737. // 项目计划 4之前(包括4)
  1738. List<String> xmjh = new ArrayList<>();
  1739. xmjh.add("4");
  1740. pmDemandReqVo.setProjectStatusList(xmjh);
  1741. Map<String, String> returnMapxmjh = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1742. returnMapxmjh.put("name", "计划管理");
  1743. // 需求建党 4之后(不包括4)
  1744. List<String> xqjd = new ArrayList<>();
  1745. xqjd.add("5");
  1746. xqjd.add("6");
  1747. xqjd.add("7");
  1748. xqjd.add("8");
  1749. pmDemandReqVo.setProjectStatusList(xqjd);
  1750. Map<String, String> returnMapxqjd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1751. returnMapxqjd.put("name", "需求管理");
  1752. // 任务下达 8之后(不包括8)
  1753. List<String> rwxd = new ArrayList<>();
  1754. rwxd.add("9");
  1755. pmDemandReqVo.setProjectStatusList(rwxd);
  1756. Map<String, String> returnMaprwxd = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1757. returnMaprwxd.put("name", "任务下达");
  1758. // 采购执行 9之后(不包括9)
  1759. List<String> cgzx = new ArrayList<>();
  1760. cgzx.add("10");
  1761. cgzx.add("11");
  1762. cgzx.add("12");
  1763. cgzx.add("13");
  1764. cgzx.add("14");
  1765. cgzx.add("15");
  1766. pmDemandReqVo.setProjectStatusList(cgzx);
  1767. Map<String, String> returnMapcgzx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1768. returnMapcgzx.put("name", "采购执行");
  1769. // 合同管理 15之后(不包括15)
  1770. List<String> htxx = new ArrayList<>();
  1771. htxx.add("16");
  1772. pmDemandReqVo.setProjectStatusList(htxx);
  1773. Map<String, String> returnMaphtxx = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1774. returnMaphtxx.put("name", "合同管理");
  1775. // 项目建设 17
  1776. List<String> xmjs = new ArrayList<>();
  1777. xmjs.add("16");
  1778. pmDemandReqVo.setProjectStatusList(xmjs);
  1779. Map<String, String> returnMapxmjs = pmDemandMapper.purchaseProjectDistribution(pmDemandReqVo);
  1780. returnMapxmjs.put("name", "合同管理");
  1781. List<Map<String, String>> returnMap = new ArrayList<>();
  1782. returnMap.add(returnMapxmjh);
  1783. returnMap.add(returnMapxqjd);
  1784. returnMap.add(returnMaprwxd);
  1785. returnMap.add(returnMapcgzx);
  1786. returnMap.add(returnMaphtxx);
  1787. returnMap.add(returnMapxmjs);
  1788. return returnMap;
  1789. }
  1790. /**
  1791. * 项目数量分析
  1792. * @param pmDemandReqVo
  1793. * @return
  1794. */
  1795. @Override
  1796. public List<Map<String, String>> purchaseProjectNumberAnalysis(PmDemandReqVo pmDemandReqVo) {
  1797. List<Map<String, String>> mapReturn = new ArrayList<>();
  1798. // 统计时间类型 1:年度,2:季度,3:月份
  1799. if ("1".equals(pmDemandReqVo.getTimeType())) {
  1800. // *** 年度的同比和环比不展示 *** //
  1801. // 查询数据库中最小的年份
  1802. int minYear = pmDemandMapper.selectMinYear();
  1803. // 获取当前年份
  1804. Calendar calendar = Calendar.getInstance();
  1805. int year = calendar.get(Calendar.YEAR);
  1806. // 获取统计数据
  1807. // 获取项目统计
  1808. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisYear(pmDemandReqVo);
  1809. mapReturn.addAll(listMap);
  1810. for (int i = minYear; i <= year; i++) {
  1811. for (Map<String, String> map : listMap) {
  1812. if (i != Integer.valueOf(map.get("yy"))) {
  1813. Map<String, String> map1 = new HashMap<>();
  1814. map1.put("yy", i + "");
  1815. map1.put("countNum", 0 + "");
  1816. mapReturn.add(map1);
  1817. }
  1818. }
  1819. }
  1820. } else if ("2".equals(pmDemandReqVo.getTimeType())) {
  1821. // 当前年份季度统计
  1822. // 获取统计数据
  1823. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisQuarter(pmDemandReqVo);
  1824. mapReturn.addAll(listMap);
  1825. for (int i = 1; i <= 4; i++) {
  1826. for (Map<String, String> map : listMap) {
  1827. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1828. map.put("yy", ii + "");
  1829. if (i != ii) {
  1830. Map<String, String> map1 = new HashMap<>();
  1831. map1.put("yy", i + "");
  1832. map1.put("countNum", 0 + "");
  1833. mapReturn.add(map1);
  1834. }
  1835. }
  1836. }
  1837. } else if ("3".equals(pmDemandReqVo.getTimeType())) {
  1838. // 当前年份月份统计
  1839. // 获取统计数据
  1840. List<Map<String, String>> listMap = pmDemandMapper.purchaseProjectNumberAnalysisMonth(pmDemandReqVo);
  1841. mapReturn.addAll(listMap);
  1842. for (int i = 1; i <= 12; i++) {
  1843. for (Map<String, String> map : listMap) {
  1844. int ii = Integer.parseInt(String.valueOf(map.get("yy")));
  1845. map.put("yy", ii + "");
  1846. if (i != ii) {
  1847. Map<String, String> map1 = new HashMap<>();
  1848. map1.put("yy", i + "");
  1849. map1.put("countNum", 0 + "");
  1850. mapReturn.add(map1);
  1851. }
  1852. }
  1853. }
  1854. }
  1855. return mapReturn;
  1856. }
  1857. //查询不同状态下的项目数据
  1858. public List<PmDemandResVo> getListByStatus(String projectStatus) {
  1859. LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
  1860. lw.eq(PmDemand::getProjectStatus, projectStatus);
  1861. List<PmDemand> demandList = this.baseMapper.selectList(lw);
  1862. //数据转换
  1863. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  1864. if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {
  1865. pmDemandResponseVoList = demandChangeTo(demandList);
  1866. }
  1867. return pmDemandResponseVoList;
  1868. }
  1869. //字段转换and赋值
  1870. public List<PmDemandResVo> demandChangeTo(List<PmDemand> pmDemandList) {
  1871. List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
  1872. for (PmDemand pmDemand1 : pmDemandList) {
  1873. PmDemandResVo vo = new PmDemandResVo();
  1874. BeanUtils.copyProperties(pmDemand1, vo);
  1875. if (vo.getPurchaseDeptId() != null) {
  1876. Map<String, Object> deptMap = deptService.selectDeptById(vo.getPurchaseDeptId());
  1877. if (deptMap != null) {
  1878. SysDeptResponseVo sysDeptResponseVo = (SysDeptResponseVo) deptMap.get("sysDept");
  1879. if (sysDeptResponseVo != null) {
  1880. vo.setPurchaseDeptName(sysDeptResponseVo.getDeptName());
  1881. }
  1882. }
  1883. }
  1884. String purchaseServicesName = dictDataService.selectDictLabel("purchase_services", vo.getPurchaseServices());
  1885. if (StringUtils.isNotEmpty(purchaseServicesName)) {
  1886. vo.setPurchaseServicesName(purchaseServicesName);
  1887. }
  1888. //项目类型
  1889. for (ProjectTypes value : ProjectTypes.values()) {
  1890. if (vo.getProjectType() != null && vo.getProjectType().equals(value.getCode())) {
  1891. vo.setProjectTypeName(value.getInfo());
  1892. break;
  1893. }
  1894. }
  1895. //是否为超限额计划
  1896. for (IsExcess value : IsExcess.values()) {
  1897. if (vo.getIsExcess() != null && vo.getIsExcess().equals(value.getCode())) {
  1898. vo.setIsExcessName(value.getInfo());
  1899. break;
  1900. }
  1901. }
  1902. //采购方式
  1903. for (PlanPurchaseMode value : PlanPurchaseMode.values()) {
  1904. if (vo.getPurchaseMode() != null && vo.getPurchaseMode().equals(value.getCode())) {
  1905. vo.setPurchaseModeName(value.getInfo());
  1906. break;
  1907. }
  1908. }
  1909. //项目属性
  1910. for (ProjectAttribute value : ProjectAttribute.values()) {
  1911. if (vo.getProjectAttr() != null && vo.getProjectAttr().equals(value.getCode())) {
  1912. vo.setProjectAttrName(value.getInfo());
  1913. break;
  1914. }
  1915. }
  1916. //预警状态
  1917. for (WarnStatus value : WarnStatus.values()) {
  1918. if (vo.getWarnStatus() != null && vo.getWarnStatus().equals(value.getCode())) {
  1919. vo.setWarnStatusName(value.getInfo());
  1920. break;
  1921. }
  1922. }
  1923. //项目状态
  1924. for (PmProjectStatus value : PmProjectStatus.values()) {
  1925. if (vo.getProjectStatus() != null && vo.getProjectStatus().equals(value.getCode())) {
  1926. vo.setProjectStatusName(value.getInfo());
  1927. break;
  1928. }
  1929. }
  1930. try {
  1931. vo.setTipsMessage(pmDemandGetTips(vo.getPlanDeliverTime()));
  1932. if (vo.getTipsMessage().contains("超过")) {
  1933. vo.setIsExceedProject("1");
  1934. }
  1935. } catch (ParseException e) {
  1936. e.printStackTrace();
  1937. }
  1938. pmDemandResponseVoList.add(vo);
  1939. }
  1940. return pmDemandResponseVoList;
  1941. }
  1942. /**
  1943. * 根据年度计划提报时间的阈值进行提示
  1944. *
  1945. * @return
  1946. */
  1947. public String pmDemandGetTips(Date planDeliverTime) throws ParseException {
  1948. if (!ObjectUtils.isEmpty(planDeliverTime)) {
  1949. //提示信息:定义距离结束时间一周内提示
  1950. Integer remindTine = 1000 * 60 * 60 * 24 * 7;
  1951. //少于一周便提醒
  1952. double surplus = planDeliverTime.getTime() - System.currentTimeMillis();
  1953. if (surplus < remindTine) {
  1954. int i = new Double(Math.ceil(surplus / 1000 / 60 / 60 / 24)).intValue();
  1955. //剩余天数(向上取整)
  1956. if (i > 0) {
  1957. return "距离计划交付时间不足" + i + "天";
  1958. } else {
  1959. return "已超过计划完成时间" + i + "天";
  1960. }
  1961. }
  1962. }
  1963. return "";
  1964. }
  1965. /**
  1966. * 计算百分比:使用java.text.DecimalFormat实现
  1967. *
  1968. * @param x
  1969. * @param y
  1970. * @return
  1971. */
  1972. public static String getPercent(int x, int y) {
  1973. double d1 = x * 1.0;
  1974. double d2 = y * 1.0;
  1975. // 设置保留几位小数, “.”后面几个零就保留几位小数,这里设置保留2位小数
  1976. DecimalFormat decimalFormat = new DecimalFormat("##.00%");
  1977. return decimalFormat.format(d1 / d2);
  1978. }
  1979. }