PmPurchaseExecutionController.java 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775
  1. package com.ozs.web.controller.pm;
  2. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  3. import com.baomidou.mybatisplus.core.metadata.IPage;
  4. import com.ozs.base.domain.BaseAgency;
  5. import com.ozs.base.domain.BaseExpert;
  6. import com.ozs.base.domain.BaseProfessional;
  7. import com.ozs.base.domain.BaseUnitInformation;
  8. import com.ozs.base.domain.vo.BaseExpertVo;
  9. import com.ozs.base.domain.vo.BaseProfessionalVo;
  10. import com.ozs.base.service.BaseAgencyService;
  11. import com.ozs.base.service.BaseExpertService;
  12. import com.ozs.base.service.BaseProfessionalService;
  13. import com.ozs.common.annotation.Log;
  14. import com.ozs.common.constant.ModularConstans;
  15. import com.ozs.common.core.controller.BaseController;
  16. import com.ozs.common.core.domain.AjaxResult;
  17. import com.ozs.common.core.domain.entity.SysUser;
  18. import com.ozs.common.enums.*;
  19. import com.ozs.common.utils.RandomUtil;
  20. import com.ozs.common.utils.StringUtils;
  21. import com.ozs.pm.doman.*;
  22. import com.ozs.pm.doman.vo.requestVo.*;
  23. import com.ozs.pm.doman.vo.responseVo.PmDemandResVo;
  24. import com.ozs.pm.service.*;
  25. import com.ozs.system.domain.SysFileRef;
  26. import io.swagger.annotations.Api;
  27. import io.swagger.annotations.ApiOperation;
  28. import org.springframework.beans.BeanUtils;
  29. import org.springframework.security.access.prepost.PreAuthorize;
  30. import org.springframework.util.ObjectUtils;
  31. import org.springframework.beans.factory.annotation.Autowired;
  32. import org.springframework.web.bind.annotation.*;
  33. import javax.validation.constraints.NotEmpty;
  34. import java.util.*;
  35. /**
  36. * 采购执行Controller
  37. *
  38. * @author ruoyi
  39. * @date 2023-01-16
  40. */
  41. @Api(tags = "采购执行")
  42. @RestController
  43. @RequestMapping("/pm/purchaseExecution")
  44. public class PmPurchaseExecutionController extends BaseController {
  45. @Autowired
  46. private IPmDemandService pmDemandService;
  47. @Autowired
  48. private PmDemandHisService pmDemandHisService;
  49. @Autowired
  50. private BaseAgencyService baseAgencyService;
  51. @Autowired
  52. private BaseExpertService baseExpertService;
  53. @Autowired
  54. private PmDemandExpertRefService pmDemandExpertRefService;
  55. @Autowired
  56. private PmBidOpeningService pmBidOpeningService;
  57. @Autowired
  58. private BaseProfessionalService baseProfessionalService;
  59. @Autowired
  60. private PmExpertFeedbackService pmExpertFeedbackService;
  61. @Autowired
  62. private PmProcurementDocumentsReviewService pmProcurementDocumentsReviewService;
  63. @Autowired
  64. private PmBidFailureService pmBidFailureService;
  65. @Autowired
  66. private PmCallQuestionService pmCallQuestionService;
  67. /**
  68. * 采购执行查询列表
  69. */
  70. @ApiOperation(value = "采购执行查询列表", notes = "参数非必传")
  71. @PostMapping("/list")
  72. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:list')")
  73. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  74. public AjaxResult list(@RequestBody PmDemandReqVo pmDemandReqVo) {
  75. pmDemandReqVo.setIsAdmin(SysUser.isAdmin(getUserId()));
  76. pmDemandReqVo.setDeptId(getDeptId());
  77. pmDemandReqVo.setUserId(getUserId());
  78. IPage<PmDemandResVo> page = pmDemandService.selectPmDemandList(pmDemandReqVo, 3);
  79. return success(page);
  80. }
  81. /**
  82. * 查询代理机构列表
  83. */
  84. @ApiOperation(value = "查询代理机构列表", notes = "采购需求ID必传")
  85. @GetMapping("/getAgencyList")
  86. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:getAgencyList')")
  87. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  88. public AjaxResult getAgencyList(@NotEmpty(message = "采购需求ID不能为空")
  89. @RequestParam(value = "demandId", required = true) Long demandId) {
  90. PmDemand pmDemand = pmDemandService.getById(demandId);
  91. if(ObjectUtils.isEmpty(pmDemand)){
  92. return error("参数错误");
  93. }
  94. LambdaQueryWrapper<BaseAgency> lw = new LambdaQueryWrapper<>();
  95. lw.eq(BaseAgency::getCompanyType,pmDemand.getProjectType());
  96. lw.eq(BaseAgency::getStatus,0);//白名单
  97. List<BaseAgency> agencyList = baseAgencyService.list(lw);
  98. return success(agencyList);
  99. }
  100. /**
  101. * 选取代理-选择填写招标代理机构信息
  102. */
  103. @ApiOperation(value = "选取代理-选择填写招标代理机构信息",notes = "采购需求ID和代理机构ID必传")
  104. @GetMapping("/selectAgency")
  105. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:selectAgency')")
  106. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  107. public AjaxResult selectAgency(@NotEmpty(message = "采购需求ID不能为空")
  108. @RequestParam(value = "demandId", required = true) Long demandId,
  109. @NotEmpty(message = "代理机构ID不能为空")
  110. @RequestParam(value = "agencyId", required = true) Long agencyId,
  111. @RequestParam(value = "purchaseTaskDocumentNumber", required = false) String purchaseTaskDocumentNumber) {
  112. PmDemand pmDemand = pmDemandService.getById(demandId);
  113. if(ObjectUtils.isEmpty(pmDemand)){
  114. return error("参数错误");
  115. }
  116. BaseAgency baseAgency = baseAgencyService.getById(agencyId);
  117. if(ObjectUtils.isEmpty(baseAgency)){
  118. return error("参数错误");
  119. }
  120. PmDemand pmDemandUpdate = new PmDemand();
  121. pmDemandUpdate.setDemandId(demandId);
  122. pmDemandUpdate.setProjectStatus(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  123. pmDemandUpdate.setAgencyId(agencyId);
  124. pmDemandUpdate.setPurchaseTaskDocumentNumber(purchaseTaskDocumentNumber);
  125. pmDemandUpdate.setExtractAgencyTime(new Date());
  126. pmDemandUpdate.setUpdateTime(pmDemandUpdate.getExtractAgencyTime());
  127. pmDemandUpdate.setUpdateBy(getUserId().toString());
  128. return success(pmDemandService.updateById(pmDemandUpdate));
  129. }
  130. /**
  131. * 选取代理-抽取招标代理机构信息
  132. */
  133. @ApiOperation(value = "选取代理-抽取招标代理机构信息",notes = "采购需求ID必传")
  134. @GetMapping("/extractAgency")
  135. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:extractAgency')")
  136. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  137. public AjaxResult extractAgency(@NotEmpty(message = "采购需求id不能为空")
  138. @RequestParam(value = "demandId", required = true) Long demandId,
  139. @RequestParam(value = "purchaseTaskDocumentNumber", required = false) String purchaseTaskDocumentNumber) {
  140. PmDemand pmDemand = pmDemandService.getById(demandId);
  141. if(ObjectUtils.isEmpty(pmDemand)){
  142. return error("参数错误");
  143. }
  144. LambdaQueryWrapper<BaseAgency> lw = new LambdaQueryWrapper<>();
  145. lw.eq(BaseAgency::getCompanyType,pmDemand.getProjectType());
  146. lw.eq(BaseAgency::getStatus,0); //白名单
  147. List<BaseAgency> baseAgencyList = baseAgencyService.list(lw);
  148. if (ObjectUtils.isEmpty(baseAgencyList)){
  149. return error("没有符合的招标代理机构,抽取失败!");
  150. }
  151. BaseAgency any = (BaseAgency)(RandomUtil.getRandomList(baseAgencyList,1).get(0));
  152. PmDemand pmDemandUpdate = new PmDemand();
  153. pmDemandUpdate.setDemandId(demandId);
  154. pmDemandUpdate.setProjectStatus(PmProjectStatus.EXPERT_FEEDBACK.getCode());
  155. pmDemandUpdate.setAgencyId(any.getId());
  156. pmDemandUpdate.setPurchaseTaskDocumentNumber(purchaseTaskDocumentNumber);
  157. pmDemandUpdate.setExtractAgencyTime(new Date());
  158. pmDemandUpdate.setUpdateTime(pmDemandUpdate.getExtractAgencyTime());
  159. pmDemandUpdate.setUpdateBy(getUserId().toString());
  160. return success(pmDemandService.updateById(pmDemandUpdate));
  161. }
  162. @ApiOperation(value = "1-2专家意见反馈",notes = "采购需求ID和上传附件必传")
  163. @PostMapping("/expertFeedback")
  164. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:expertFeedback')")
  165. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.IMPORT)
  166. public AjaxResult expertFeedback(@NotEmpty(message = "数据为空") @RequestBody PmExpertFeedbackReqVo pmExpertFeedbackReqVo) {
  167. Long demandId = pmExpertFeedbackReqVo.getDemandId();
  168. if(ObjectUtils.isEmpty(demandId)){
  169. return error("参数错误");
  170. }
  171. PmDemand pmDemand = pmDemandService.getById(demandId);
  172. if(ObjectUtils.isEmpty(pmDemand)){
  173. return error("参数错误");
  174. }
  175. List<SysFileRef> sysFileRefs = pmExpertFeedbackReqVo.getSysFileRefs();
  176. if(ObjectUtils.isEmpty(sysFileRefs)){
  177. return error("上传附件不能为空");
  178. }
  179. PmExpertFeedback pmExpertFeedback = new PmExpertFeedback();
  180. BeanUtils.copyProperties(pmExpertFeedbackReqVo,pmExpertFeedback);
  181. if(pmExpertFeedbackService.save(pmExpertFeedback)){
  182. pmDemandService.uploadFile(pmExpertFeedback.getId(), SysFileRefEnum.PM_EXPERT_FEEDBACK.getType(),sysFileRefs,getUserId().toString());
  183. PmDemand pmDemandUpdate = new PmDemand();
  184. pmDemandUpdate.setDemandId(demandId);
  185. pmDemandUpdate.setProjectStatus(PmProjectStatus.PROCUREMENT_DOCUMENTS_REVIEW.getCode());
  186. pmDemandUpdate.setUpdateTime(new Date());
  187. pmDemandUpdate.setUpdateBy(getUserId().toString());
  188. return success(pmDemandService.updateById(pmDemandUpdate));
  189. } else {
  190. return error("保存失败");
  191. }
  192. }
  193. @ApiOperation(value = "1-3采购文件编制审核",notes = "采购需求ID和上传附件必传")
  194. @PostMapping("/uploadBidFile")
  195. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:uploadBidFile')")
  196. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.IMPORT)
  197. public AjaxResult uploadBidFile(@NotEmpty(message = "数据为空") @RequestBody PmProcurementDocumentsReviewReqVo pmProcurementDocumentsReviewReqVo) {
  198. Long demandId = pmProcurementDocumentsReviewReqVo.getDemandId();
  199. if(ObjectUtils.isEmpty(demandId)){
  200. return error("参数错误");
  201. }
  202. PmDemand pmDemand = pmDemandService.getById(demandId);
  203. if(ObjectUtils.isEmpty(pmDemand)){
  204. return error("参数错误");
  205. }
  206. List<SysFileRef> sysFileRefs = pmProcurementDocumentsReviewReqVo.getSysFileRefs();
  207. if(ObjectUtils.isEmpty(sysFileRefs)){
  208. return error("上传附件不能为空");
  209. }
  210. PmProcurementDocumentsReview pmProcurementDocumentsReview = new PmProcurementDocumentsReview();
  211. BeanUtils.copyProperties(pmProcurementDocumentsReviewReqVo,pmProcurementDocumentsReview);
  212. if(this.pmProcurementDocumentsReviewService.save(pmProcurementDocumentsReview)){
  213. pmDemandService.uploadFile(pmProcurementDocumentsReview.getId(), SysFileRefEnum.PM_BID_FILE.getType(),sysFileRefs,getUserId().toString());
  214. PmDemand pmDemandUpdate = new PmDemand();
  215. pmDemandUpdate.setDemandId(demandId);
  216. pmDemandUpdate.setProjectStatus(PmProjectStatus.PROCUREMENT_ANNOUNCEMENT.getCode());
  217. pmDemandUpdate.setUpdateTime(new Date());
  218. pmDemandUpdate.setUpdateBy(getUserId().toString());
  219. return success(pmDemandService.updateById(pmDemandUpdate));
  220. } else {
  221. return error("保存失败");
  222. }
  223. }
  224. @ApiOperation(value = "发布公告")
  225. @PostMapping("/insertPmReleaseAnnouncement")
  226. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:insertPmReleaseAnnouncement')")
  227. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.INSERT)
  228. public AjaxResult insertPmReleaseAnnouncement(@NotEmpty(message = "数据为空")
  229. @RequestBody PmReleaseAnnouncementReqVo pmReleaseAnnouncementReqVo) {
  230. try {
  231. Long demandId = pmReleaseAnnouncementReqVo.getDemandId();
  232. if(ObjectUtils.isEmpty(demandId)){
  233. return error("参数错误");
  234. }
  235. pmReleaseAnnouncementReqVo.setCreateBy(getUserId().toString());
  236. pmReleaseAnnouncementReqVo.setCreateTime(new Date());
  237. pmReleaseAnnouncementReqVo.setUpdateBy(pmReleaseAnnouncementReqVo.getCreateBy());
  238. pmReleaseAnnouncementReqVo.setUpdateTime(pmReleaseAnnouncementReqVo.getCreateTime());
  239. return toAjax(pmDemandService.insertPmReleaseAnnouncement(pmReleaseAnnouncementReqVo));
  240. } catch (Exception e) {
  241. return error(e.getMessage());
  242. }
  243. }
  244. @ApiOperation(value = "1-5标前质疑投诉",notes = "采购需求ID必传")
  245. @PostMapping("/handlePreCallQuestion")
  246. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:handlePreCallQuestion')")
  247. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  248. public AjaxResult handlePreCallQuestion(@NotEmpty(message = "数据为空")
  249. @RequestBody PmCallQuestionReqVo pmCallQuestionReqVo) {
  250. try {
  251. Long demandId = pmCallQuestionReqVo.getDemandId();
  252. if(ObjectUtils.isEmpty(demandId)){
  253. return error("参数错误");
  254. }
  255. PmDemand pmDemand = pmDemandService.getById(demandId);
  256. if(ObjectUtils.isEmpty(pmDemand)){
  257. return error("参数错误");
  258. }
  259. if("1".equals(pmCallQuestionReqVo.getCallQuestion())) { //有质疑
  260. if (ObjectUtils.isEmpty(pmCallQuestionReqVo.getCallQuestionTime())) {
  261. return error("质疑时间不能为空");
  262. }
  263. }
  264. PmCallQuestion pmCallQuestion = new PmCallQuestion();
  265. BeanUtils.copyProperties(pmCallQuestionReqVo,pmCallQuestion);
  266. pmCallQuestion.setType("0");
  267. if(pmCallQuestionService.save(pmCallQuestion)) {
  268. if("1".equals(pmCallQuestion.getCallQuestion())) { //有质疑
  269. List<SysFileRef> sysFileRefs = pmCallQuestionReqVo.getSysFileRefs();
  270. pmDemandService.uploadFile(pmCallQuestion.getId(), SysFileRefEnum.PM_PRE_BID_CALL_QUESTION.getType(),sysFileRefs,getUserId().toString());
  271. }
  272. }
  273. pmDemand.setProjectStatus(PmProjectStatus.WAIT_OPEN_BID.getCode());
  274. pmDemand.setUpdateBy(getUserId().toString());
  275. pmDemand.setUpdateTime(new Date());
  276. return toAjax(pmDemandService.updateById(pmDemand));
  277. } catch (Exception e) {
  278. return error(e.getMessage());
  279. }
  280. }
  281. @ApiOperation(value = "获取专家身份证号列表")
  282. @GetMapping("/getExpertIdNumberList")
  283. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:getExpertIdNumberList')")
  284. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  285. public AjaxResult getExpertIdNumberList(@NotEmpty(message = "采购需求id不能为空")
  286. @RequestParam(value = "demandId", required = true) Long demandId) {
  287. PmDemand pmDemand = pmDemandService.getById(demandId);
  288. if(ObjectUtils.isEmpty(pmDemand)){
  289. return error("参数错误");
  290. }
  291. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<BaseExpert>();
  292. lw.eq(BaseExpert::getVarietyPurchase,pmDemand.getProjectType())
  293. .eq(BaseExpert::getStatus,NameListType.WHITE.getCode());
  294. List<BaseExpert> baseExpertList = baseExpertService.list(lw);
  295. List<String> idNumberList = new ArrayList<>();
  296. if (!ObjectUtils.isEmpty(baseExpertList)) {
  297. for(BaseExpert baseExpert :baseExpertList ){
  298. idNumberList.add(baseExpert.getIdNumber());
  299. }
  300. }
  301. return success(idNumberList);
  302. }
  303. @ApiOperation(value = "根据身份证号查询专家", notes = "必传 查询条件:身份证号")
  304. @GetMapping("/findExpertWithIdNumber")
  305. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:findExpertWithIdNumber')")
  306. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  307. public AjaxResult findExpertWithIdNumber(@NotEmpty(message = "采购需求id不能为空")
  308. @RequestParam(value = "demandId", required = true) Long demandId,
  309. @NotEmpty(message = "身份证号不能为空")
  310. @RequestParam(value = "idNumber", required = true) String idNumber) {
  311. PmDemand pmDemand = pmDemandService.getById(demandId);
  312. if(ObjectUtils.isEmpty(pmDemand)){
  313. return error("参数错误");
  314. }
  315. LambdaQueryWrapper<BaseExpert> lw = new LambdaQueryWrapper<>();
  316. lw.eq(BaseExpert::getIdNumber,idNumber);
  317. BaseExpert baseExpert = baseExpertService.getOne(lw);
  318. if(baseExpert != null){
  319. if(NameListType.BLACK.getCode().equals(baseExpert.getStatus())){
  320. return error("该专家属于黑名单");
  321. }
  322. if(!ObjectUtils.isEmpty(pmDemand.getProjectType()) && !pmDemand.getProjectType().equals(baseExpert.getVarietyPurchase())){
  323. return error("该专家所属采购品种和项目类型不匹配");
  324. }
  325. }
  326. return success(baseExpert);
  327. }
  328. @ApiOperation(value = "查询专业库树结构", notes = "非必传 查询条件:品目名称")
  329. @PostMapping("/selectBaseProfessional")
  330. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:selectBaseProfessional')")
  331. @Log(title = ModularConstans.professional, businessType = BusinessType.QUERY)
  332. public AjaxResult selectBaseProfessional(@RequestBody BaseProfessionalVo baseProfessionalVo) {
  333. List<BaseProfessionalVo> baseSupplierList = baseProfessionalService.selectBaseProfessionalVo(baseProfessionalVo);
  334. return success(baseSupplierList);
  335. }
  336. @ApiOperation(value = "填写专家信息批量提交", notes = "必传 采购需求ID和专家信息列表,注意:若该专家已经在库里存在,需要传专家对象BaseExpert的ID")
  337. @PostMapping("/insertExpertBatch")
  338. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:insertExpertBatch')")
  339. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.INSERT)
  340. public AjaxResult insertExpertBatch(@NotEmpty(message = "参数不能为空") @RequestBody PmBaseExpertFillReqVo pmBaseExpertFillReqVo) {
  341. try {
  342. if (ObjectUtils.isEmpty(pmBaseExpertFillReqVo)
  343. || ObjectUtils.isEmpty(pmBaseExpertFillReqVo.getDemandId())
  344. || ObjectUtils.isEmpty(pmBaseExpertFillReqVo.getAccessTime())
  345. || ObjectUtils.isEmpty(pmBaseExpertFillReqVo.getBaseExpertList())) {
  346. return error("参数错误");
  347. }
  348. pmBaseExpertFillReqVo.setCreateBy(getUserId().toString());
  349. pmBaseExpertFillReqVo.setUpdateBy(pmBaseExpertFillReqVo.getCreateBy());
  350. return toAjax(pmDemandService.insertExpertBatch(pmBaseExpertFillReqVo));
  351. } catch (Exception e) {
  352. return error(e.getMessage());
  353. }
  354. }
  355. @ApiOperation(value = "获取回避单位下拉列表")
  356. @GetMapping("/getExpertUnitList")
  357. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:getExpertUnitList')")
  358. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  359. public AjaxResult getExpertUnitList() {
  360. List<BaseUnitInformation> baseUnitInformationList = baseExpertService.getBaseUnitInformationList();
  361. if(ObjectUtils.isEmpty(baseUnitInformationList)){
  362. return error("专家单位列表是空的");
  363. }
  364. Set<String> set = new HashSet<>();
  365. for(BaseUnitInformation baseUnitInformation : baseUnitInformationList) {
  366. set.add(baseUnitInformation.getUnitName());
  367. }
  368. return success(set);
  369. }
  370. /**
  371. * 抽取专家
  372. */
  373. @ApiOperation(value = "抽取专家",notes = "采购需求ID必传")
  374. @PostMapping("/extractExpertBatch")
  375. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:extractExpertBatch')")
  376. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  377. public AjaxResult extractExpertBatch(@NotEmpty(message = "参数不能为空")
  378. @RequestBody PmBaseExpertExtractReqVo pmBaseExpertExtractReqVo) {
  379. try {
  380. if (ObjectUtils.isEmpty(pmBaseExpertExtractReqVo)
  381. || ObjectUtils.isEmpty(pmBaseExpertExtractReqVo.getDemandId())
  382. || ObjectUtils.isEmpty(pmBaseExpertExtractReqVo.getAccessTime())) {
  383. return error("参数错误");
  384. }
  385. return toAjax(pmDemandService.extractExpertBatch(pmBaseExpertExtractReqVo));
  386. } catch (Exception e) {
  387. return error(e.getMessage());
  388. }
  389. }
  390. @ApiOperation(value = "填写开标信息",notes = "采购需求ID必传")
  391. @PostMapping("/insertBidOpeningBatch")
  392. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:insertBidOpeningBatch')")
  393. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.INSERT)
  394. public AjaxResult insertBidOpeningBatch(@NotEmpty(message = "数据为空")
  395. @RequestBody PmBidOpeningFillReqVo pmBidOpeningFillReqVo) {
  396. try {
  397. if (ObjectUtils.isEmpty(pmBidOpeningFillReqVo)
  398. || ObjectUtils.isEmpty(pmBidOpeningFillReqVo.getDemandId())
  399. || ObjectUtils.isEmpty(pmBidOpeningFillReqVo.getPmBidOpeningList())) {
  400. return error("参数错误");
  401. }
  402. pmBidOpeningFillReqVo.setCreateBy(getUserId().toString());
  403. pmBidOpeningFillReqVo.setUpdateBy(getUserId().toString());
  404. return toAjax(pmDemandService.insertBidOpeningBatch(pmBidOpeningFillReqVo));
  405. } catch (Exception e) {
  406. return error(e.getMessage());
  407. }
  408. }
  409. /**
  410. * 中标基本情况填制-开标信息下拉列表
  411. */
  412. @ApiOperation(value = "中标基本情况填制-开标信息下拉列表", notes = "必传选需求ID")
  413. @GetMapping("/getPullDownBidOpeningList")
  414. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:getPullDownBidOpeningList')")
  415. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  416. public AjaxResult getPullDownBidOpeningList(@NotEmpty(message = "需求ID不能为空")
  417. @RequestParam(value = "demandId", required = true) Long demandId) {
  418. LambdaQueryWrapper<PmBidOpening> pmBidOpeningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  419. pmBidOpeningLambdaQueryWrapper.eq(PmBidOpening::getDemandId,demandId)
  420. .orderByDesc(PmBidOpening::getScore)
  421. ;
  422. List<PmBidOpening> pmBidOpeningList = pmBidOpeningService.list(pmBidOpeningLambdaQueryWrapper);
  423. return success(pmBidOpeningList);
  424. }
  425. @ApiOperation(value = "中标基本情况填制-中标情况填制提交",notes = "采购需求ID必传")
  426. @PostMapping("/insertPmBidWinning")
  427. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:insertPmBidWinning')")
  428. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.INSERT)
  429. public AjaxResult insertPmBidWinning(@NotEmpty(message = "数据为空")
  430. @RequestBody PmBidWinningReqVo pmBidWinningReqVo) {
  431. try {
  432. Long demandId = pmBidWinningReqVo.getDemandId();
  433. if(ObjectUtils.isEmpty(demandId)){
  434. return error("采购需求ID不能为空");
  435. }
  436. pmBidWinningReqVo.setCreateBy(getUserId().toString());
  437. pmBidWinningReqVo.setCreateTime(new Date());
  438. pmBidWinningReqVo.setUpdateBy(pmBidWinningReqVo.getCreateBy());
  439. pmBidWinningReqVo.setUpdateTime(pmBidWinningReqVo.getCreateTime());
  440. return toAjax(pmDemandService.insertPmBidWinning(pmBidWinningReqVo));
  441. } catch (Exception e) {
  442. return error(e.getMessage());
  443. }
  444. }
  445. @ApiOperation(value = "中标基本情况填制-更换中标人提交",notes = "采购需求ID必传")
  446. @PostMapping("/updatePmBidWinning")
  447. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:updatePmBidWinning')")
  448. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  449. public AjaxResult updatePmBidWinning(@NotEmpty(message = "数据为空")
  450. @RequestBody PmBidWinningReqVo pmBidWinningReqVo) {
  451. try {
  452. Long demandId = pmBidWinningReqVo.getDemandId();
  453. if(ObjectUtils.isEmpty(demandId)){
  454. return error("采购需求ID不能为空");
  455. }
  456. pmBidWinningReqVo.setUpdateBy(getUserId().toString());
  457. pmBidWinningReqVo.setUpdateTime(new Date());
  458. return toAjax(pmDemandService.updatePmBidWinning(pmBidWinningReqVo));
  459. } catch (Exception e) {
  460. return error(e.getMessage());
  461. }
  462. }
  463. @ApiOperation(value = "流标情况填制",notes = "采购需求ID必传")
  464. @PostMapping("/insertPmBidFailure")
  465. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:insertPmBidFailure')")
  466. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.INSERT)
  467. public AjaxResult insertPmBidFailure(@NotEmpty(message = "数据为空")
  468. @RequestBody PmBidFailureReqVo pmBidFailureReqVo) {
  469. try {
  470. Long demandId = pmBidFailureReqVo.getDemandId();
  471. if(ObjectUtils.isEmpty(demandId)){
  472. return error("参数错误");
  473. }
  474. pmBidFailureReqVo.setCreateBy(getUserId().toString());
  475. pmBidFailureReqVo.setCreateTime(new Date());
  476. pmBidFailureReqVo.setUpdateBy(pmBidFailureReqVo.getCreateBy());
  477. pmBidFailureReqVo.setUpdateTime(pmBidFailureReqVo.getCreateTime());
  478. return toAjax(pmDemandService.insertPmBidFailure(pmBidFailureReqVo));
  479. } catch (Exception e) {
  480. return error(e.getMessage());
  481. }
  482. }
  483. @ApiOperation(value = "流废标处置-质疑处理",notes = "采购需求ID必传")
  484. @PostMapping("/handleBidFailureCallQuestion")
  485. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:handleBidFailureCallQuestion')")
  486. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  487. public AjaxResult handleBidFailureCallQuestion(@NotEmpty(message = "数据为空")
  488. @RequestBody PmCallQuestionReqVo pmCallQuestionReqVo) {
  489. try {
  490. Long demandId = pmCallQuestionReqVo.getDemandId();
  491. if(ObjectUtils.isEmpty(demandId)){
  492. return error("参数错误");
  493. }
  494. PmDemand pmDemand = pmDemandService.getById(demandId);
  495. if(ObjectUtils.isEmpty(pmDemand)){
  496. return error("参数错误");
  497. }
  498. if("1".equals(pmCallQuestionReqVo.getCallQuestion())) { //有质疑
  499. if (ObjectUtils.isEmpty(pmCallQuestionReqVo.getCallQuestionTime())) {
  500. return error("质疑时间不能为空");
  501. }
  502. }
  503. LambdaQueryWrapper<PmBidFailure> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  504. lambdaQueryWrapper.eq(PmBidFailure::getDemandId,pmDemand.getDemandId())
  505. .orderByDesc(PmBidFailure::getBidFailureTime)
  506. .last(" limit 1");
  507. PmBidFailure bidFailure = this.pmBidFailureService.getOne(lambdaQueryWrapper);
  508. if (ObjectUtils.isEmpty(bidFailure)) {
  509. return error("没有流标信息");
  510. }
  511. PmBidFailure bidFailureUpdate = new PmBidFailure();
  512. bidFailureUpdate.setId(bidFailure.getId());
  513. bidFailureUpdate.setCallQuestion(pmCallQuestionReqVo.getCallQuestion());
  514. bidFailureUpdate.setCallQuestionTime(pmCallQuestionReqVo.getCallQuestionTime());
  515. if("1".equals(bidFailureUpdate.getCallQuestion())){ //有质疑
  516. List<SysFileRef> sysFileRefs = pmCallQuestionReqVo.getSysFileRefs();
  517. pmDemandService.uploadFile(bidFailureUpdate.getId(), SysFileRefEnum.PM_BID_FAILURE_CALL_QUESTION.getType(),sysFileRefs,getUserId().toString());
  518. }
  519. bidFailureUpdate.setUpdateBy(getUserId().toString());
  520. bidFailureUpdate.setUpdateTime(new Date());
  521. return toAjax(pmBidFailureService.updateById(bidFailureUpdate));
  522. } catch (Exception e) {
  523. return error(e.getMessage());
  524. }
  525. }
  526. @ApiOperation(value = "流废标退回",notes = "采购需求ID必传")
  527. @GetMapping("/returnBidFailure")
  528. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:returnBidFailure')")
  529. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  530. public AjaxResult returnBidFailure(@NotEmpty(message = "采购需求id不能为空")
  531. @RequestParam(value = "demandId", required = true) Long demandId) {
  532. try {
  533. return toAjax(pmDemandHisService.returnBidFailure(demandId, getUserId().toString()));
  534. } catch (Exception e) {
  535. return error(e.getMessage());
  536. }
  537. }
  538. @ApiOperation(value = "标后质疑",notes = "采购需求ID必传")
  539. @PostMapping("/handleCallQuestion")
  540. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:handleCallQuestion')")
  541. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.UPDATE)
  542. public AjaxResult handleCallQuestion(@NotEmpty(message = "数据为空")
  543. @RequestBody PmCallQuestionReqVo pmCallQuestionReqVo) {
  544. try {
  545. Long demandId = pmCallQuestionReqVo.getDemandId();
  546. if(ObjectUtils.isEmpty(demandId)){
  547. return error("参数错误");
  548. }
  549. PmDemand pmDemand = pmDemandService.getById(demandId);
  550. if(ObjectUtils.isEmpty(pmDemand)){
  551. return error("参数错误");
  552. }
  553. if("1".equals(pmCallQuestionReqVo.getCallQuestion())) { //有质疑
  554. if (ObjectUtils.isEmpty(pmCallQuestionReqVo.getCallQuestionTime())) {
  555. return error("质疑时间不能为空");
  556. }
  557. }
  558. PmCallQuestion pmCallQuestion = new PmCallQuestion();
  559. BeanUtils.copyProperties(pmCallQuestionReqVo,pmCallQuestion);
  560. pmCallQuestion.setType("1");
  561. if(pmCallQuestionService.save(pmCallQuestion)) {
  562. if("1".equals(pmCallQuestion.getCallQuestion())) { //有质疑
  563. List<SysFileRef> sysFileRefs = pmCallQuestionReqVo.getSysFileRefs();
  564. pmDemandService.uploadFile(demandId, SysFileRefEnum.PM_BID_CALL_QEUSTION_FILE.getType(), sysFileRefs, getUserId().toString());
  565. }
  566. }
  567. pmDemand.setUpdateBy(getUserId().toString());
  568. pmDemand.setUpdateTime(new Date());
  569. return toAjax(pmDemandService.updateById(pmDemand));
  570. } catch (Exception e) {
  571. return error(e.getMessage());
  572. }
  573. }
  574. @ApiOperation(value = "上传中标通知书",notes = "采购需求ID和上传附件必传")
  575. @PostMapping("/uploadBidWinningNotification")
  576. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:uploadBidWinningNotification')")
  577. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.IMPORT)
  578. public AjaxResult uploadBidWinningNotification(@NotEmpty(message = "数据为空") @RequestBody PmPurchaseExecutionReqVo pmPurchaseExecutionReqVo) {
  579. Long demandId = pmPurchaseExecutionReqVo.getDemandId();
  580. if(ObjectUtils.isEmpty(demandId)){
  581. return error("参数错误");
  582. }
  583. PmDemand pmDemand = pmDemandService.getById(demandId);
  584. if(ObjectUtils.isEmpty(pmDemand)){
  585. return error("参数错误");
  586. }
  587. List<SysFileRef> sysFileRefs = pmPurchaseExecutionReqVo.getSysFileRefs();
  588. if(ObjectUtils.isEmpty(sysFileRefs)){
  589. return error("上传附件不能为空");
  590. }
  591. if (pmDemandService.uploadFile(demandId, SysFileRefEnum.PM_BID_WINNING_NOTIFICATION.getType(),sysFileRefs,getUserId().toString())) {
  592. PmDemand pmDemandUpdate = new PmDemand();
  593. pmDemandUpdate.setDemandId(demandId);
  594. pmDemandUpdate.setProjectStatus(PmProjectStatus.CONTRACT_WAIT_FILL.getCode());
  595. pmDemandUpdate.setRealPurchaseFinishTime(new Date());
  596. pmDemandUpdate.setUpdateTime(new Date());
  597. pmDemandUpdate.setUpdateBy(getUserId().toString());
  598. return success(pmDemandService.updateById(pmDemandUpdate));
  599. } else {
  600. return error("保存上传附件失败");
  601. }
  602. }
  603. /**
  604. * 查看详情
  605. */
  606. @ApiOperation(value = "查看详情", notes = "必传demandId和详情类型(1项目计划,2需求建档,3任务下达,4中标信息,5合同信息,6建设情况),其他字段不传")
  607. @PostMapping("/view")
  608. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:view')")
  609. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  610. public AjaxResult view(@RequestBody PmDemandReqVo pmDemandReqVo) {
  611. if(pmDemandReqVo.getDemandId() == null){
  612. return AjaxResult.error("demandId不能为空");
  613. }
  614. if(StringUtils.isEmpty(pmDemandReqVo.getDetailType())){
  615. return AjaxResult.error("详情的类型不能为空");
  616. }
  617. return success(pmDemandService.selectPmDemandByDemandId(pmDemandReqVo.getDemandId(),pmDemandReqVo.getDetailType()));
  618. }
  619. /**
  620. * 查看历史详情
  621. */
  622. @ApiOperation(value = "查看详情", notes = "必传demandId和详情类型(1项目计划,2需求建档,3任务下达,4中标信息,5合同信息,6建设情况),returnOrderNumber(回退序号,0当前/1第一次回退/2第二次回退...),其他字段不传")
  623. @PostMapping("/view")
  624. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:view')")
  625. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  626. public AjaxResult viewHis(@RequestBody PmDemandReqVo pmDemandReqVo) {
  627. if(pmDemandReqVo.getDemandId() == null){
  628. return AjaxResult.error("demandId不能为空");
  629. }
  630. if(ObjectUtils.isEmpty(pmDemandReqVo.getDetailType())){
  631. return AjaxResult.error("详情的类型不能为空");
  632. }
  633. if(ObjectUtils.isEmpty(pmDemandReqVo.getReturnOrderNumber())){
  634. return AjaxResult.error("回退序号不能为空");
  635. }
  636. if(0 == pmDemandReqVo.getReturnOrderNumber()){
  637. return view(pmDemandReqVo);
  638. } else {
  639. return success(pmDemandHisService.selectPmDemandHisByDemandId(pmDemandReqVo.getDemandId(),pmDemandReqVo.getDetailType(),pmDemandReqVo.getReturnOrderNumber()));
  640. }
  641. }
  642. /**
  643. * 专家信息查看详情列表
  644. */
  645. @ApiOperation(value = "专家信息查看详情列表", notes = "必传需求ID和选取时间(yyyy-MM-dd)")
  646. @GetMapping("/getBaseExpertList")
  647. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:getBaseExpertList')")
  648. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  649. public AjaxResult getBaseExpertList(@NotEmpty(message = "需求ID不能为空")
  650. @RequestParam(value = "demandId", required = true) Long demandId,
  651. @NotEmpty(message = "选取时间不能为空")
  652. @RequestParam(value = "accessTime", required = true) String accessTime) {
  653. LambdaQueryWrapper<PmDemandExpertRef> pmDemandExpertRefLambdaQueryWrapper = new LambdaQueryWrapper<>();
  654. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getDemandId,demandId);
  655. pmDemandExpertRefLambdaQueryWrapper.eq(PmDemandExpertRef::getAccessTime,accessTime);
  656. List<PmDemandExpertRef> pmDemandExpertRefList = pmDemandExpertRefService.list(pmDemandExpertRefLambdaQueryWrapper);
  657. List<BaseExpertVo> baseExpertVoList = new ArrayList<>();
  658. if(!ObjectUtils.isEmpty(pmDemandExpertRefList)) {
  659. for(PmDemandExpertRef pmDemandExpertRef : pmDemandExpertRefList) {
  660. BaseExpert baseExpert = baseExpertService.getById(pmDemandExpertRef.getExpertId());
  661. if(baseExpert != null){
  662. BaseExpertVo baseExpertVo = new BaseExpertVo();
  663. BeanUtils.copyProperties(baseExpert,baseExpertVo);
  664. baseExpertVo.setMajorTypeName(getMajorTypeName(baseExpertVo.getMajorType()));
  665. baseExpertVo.setExpertTypeName(ExpertType.getCodeToInfo(baseExpertVo.getExpertType()));
  666. baseExpertVo.setVarietyPurchaseName(PurchaseType.getCodeToInfo(baseExpertVo.getVarietyPurchase()));
  667. baseExpertVoList.add(baseExpertVo);
  668. }
  669. }
  670. }
  671. return success(baseExpertVoList);
  672. }
  673. private String getMajorTypeName(String majorType){
  674. if(ObjectUtils.isEmpty(majorType)) {
  675. return null;
  676. }
  677. LambdaQueryWrapper<BaseProfessional> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  678. lambdaQueryWrapper.in(BaseProfessional::getProfessionalCode,majorType.split(","));
  679. List<BaseProfessional> list = this.baseProfessionalService.list(lambdaQueryWrapper);
  680. if(ObjectUtils.isEmpty(list)){
  681. return null;
  682. }
  683. StringBuilder sb = new StringBuilder();
  684. for(BaseProfessional baseProfessional : list){
  685. sb.append(baseProfessional.getProfessionalName()).append(",");
  686. }
  687. String majorTypeName = sb.toString();
  688. if(majorTypeName.endsWith(",")){
  689. majorTypeName = majorTypeName.substring(0, majorTypeName.length() - 1);
  690. }
  691. return majorTypeName;
  692. }
  693. /**
  694. * 开标信息查看详情列表
  695. */
  696. @ApiOperation(value = "开标信息查看详情列表", notes = "必传选需求ID和开标时间(yyyy-MM-dd)")
  697. @GetMapping("/getBidOpeningList")
  698. @PreAuthorize("@ss.hasPermi('pm:purchaseExecution:getBidOpeningList')")
  699. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  700. public AjaxResult getBidOpeningList(@NotEmpty(message = "需求ID不能为空")
  701. @RequestParam(value = "demandId", required = true) Long demandId,
  702. @NotEmpty(message = "开标时间不能为空")
  703. @RequestParam(value = "openBidTime", required = true) String openBidTime) {
  704. LambdaQueryWrapper<PmBidOpening> pmBidOpeningLambdaQueryWrapper = new LambdaQueryWrapper<>();
  705. pmBidOpeningLambdaQueryWrapper.eq(PmBidOpening::getDemandId,demandId)
  706. .eq(PmBidOpening::getOpenBidTime,openBidTime).orderByDesc(PmBidOpening::getScore);
  707. List<PmBidOpening> pmBidOpeningList = pmBidOpeningService.list(pmBidOpeningLambdaQueryWrapper);
  708. return success(pmBidOpeningList);
  709. }
  710. }