PmDemandServiceImpl.java 115 KB

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