PmDemandController.java 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  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.common.annotation.Log;
  5. import com.ozs.common.constant.ModularConstans;
  6. import com.ozs.common.core.domain.entity.SysUser;
  7. import com.ozs.common.core.domain.model.LoginUser;
  8. import com.ozs.common.enums.BusinessType;
  9. import com.ozs.common.utils.StringUtils;
  10. import com.ozs.framework.web.service.TokenService;
  11. import com.ozs.pm.doman.PmDemand;
  12. import com.ozs.pm.doman.PmDemandHis;
  13. import com.ozs.pm.doman.vo.requestVo.PmBookBuildingReqVo;
  14. import com.ozs.pm.doman.vo.requestVo.PmDemandReqVo;
  15. import com.ozs.pm.doman.vo.responseVo.PmDemandResVo;
  16. import com.ozs.pm.service.IPmDemandService;
  17. import com.ozs.pm.service.PmDemandHisService;
  18. import io.swagger.annotations.Api;
  19. import io.swagger.annotations.ApiOperation;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.security.access.prepost.PreAuthorize;
  22. import org.springframework.util.ObjectUtils;
  23. import org.springframework.web.bind.annotation.*;
  24. import com.ozs.common.core.controller.BaseController;
  25. import com.ozs.common.core.domain.AjaxResult;
  26. import javax.servlet.http.HttpServletRequest;
  27. import javax.validation.constraints.NotEmpty;
  28. import java.util.*;
  29. /**
  30. * 采购需求Controller
  31. *
  32. * @author ruoyi
  33. * @date 2023-01-16
  34. */
  35. @Api(tags = "采购需求")
  36. @RestController
  37. @RequestMapping("/pm/demand")
  38. public class PmDemandController extends BaseController {
  39. @Autowired
  40. private IPmDemandService pmDemandService;
  41. @Autowired
  42. private TokenService tokenService;
  43. @Autowired
  44. private PmDemandHisService pmDemandHisService;
  45. /**
  46. * 查询采购需求列表
  47. */
  48. @ApiOperation(value = "查询采购需求列表", notes = "参数非必传")
  49. @PostMapping("/list")
  50. @PreAuthorize("@ss.hasPermi('pm:demand:list')")
  51. @Log(title = ModularConstans.demand, businessType = BusinessType.QUERY)
  52. public AjaxResult list(@RequestBody PmDemandReqVo pmDemandReqVo) {
  53. pmDemandReqVo.setDeptId(getDeptId());
  54. pmDemandReqVo.setIsAdmin(SysUser.isAdmin(getUserId()));
  55. pmDemandReqVo.setUserId(getUserId());
  56. IPage<PmDemandResVo> page = pmDemandService.selectPmDemandList(pmDemandReqVo, 0);
  57. return success(page);
  58. }
  59. /**
  60. * 查看详情
  61. */
  62. @ApiOperation(value = "查看详情", notes = "必传demandId和详情类型(1项目计划,2需求建档,3任务下达,4中标信息,5合同信息,6建设情况),其他字段不传")
  63. @PostMapping("/view")
  64. // @PreAuthorize("@ss.hasPermi('pm:demand:view')") 首页去除权限
  65. @Log(title = ModularConstans.demand, businessType = BusinessType.QUERY)
  66. public AjaxResult view(@RequestBody PmDemandReqVo pmDemandReqVo) {
  67. if(pmDemandReqVo.getDemandId() == null){
  68. return AjaxResult.error("demandId不能为空");
  69. }
  70. if(StringUtils.isEmpty(pmDemandReqVo.getDetailType())){
  71. return AjaxResult.error("详情的类型不能为空");
  72. }
  73. return success(pmDemandService.selectPmDemandByDemandId(pmDemandReqVo.getDemandId(),pmDemandReqVo.getDetailType()));
  74. }
  75. /**
  76. * 获取回退下拉列表
  77. */
  78. @ApiOperation(value = "获取回退下拉列表", notes = "必传demandId")
  79. @GetMapping("/getReturnList")
  80. @PreAuthorize("@ss.hasPermi('pm:demand:getReturnList')")
  81. @Log(title = ModularConstans.demand, businessType = BusinessType.QUERY)
  82. public AjaxResult getReturnList(@NotEmpty(message = "需求ID不能为空")
  83. @RequestParam(value = "demandId", required = true) Long demandId) {
  84. List< Map<String,Integer>> list = new ArrayList<>();
  85. LambdaQueryWrapper<PmDemandHis> lambdaQueryWrapper = new LambdaQueryWrapper<>();
  86. lambdaQueryWrapper.eq(PmDemandHis::getDemandId,demandId).orderByAsc(PmDemandHis::getReturnOrderNumber);
  87. List<PmDemandHis> pmDemandHisList = this.pmDemandHisService.list(lambdaQueryWrapper);
  88. if(!ObjectUtils.isEmpty(pmDemandHisList)){
  89. Map<String,Integer> map = new HashMap<>();
  90. map.put("当前信息",0);
  91. list.add(map);
  92. for (PmDemandHis pmDemandHis : pmDemandHisList) {
  93. Map<String,Integer> map2 = new HashMap<>();
  94. map2.put("第" + pmDemandHis.getReturnOrderNumber() + "回退",pmDemandHis.getReturnOrderNumber());
  95. list.add(map2);
  96. }
  97. }
  98. return success(list);
  99. }
  100. /**
  101. * 查看历史详情
  102. */
  103. @ApiOperation(value = "查看历史详情", notes = "必传demandId和详情类型(1项目计划,2需求建档,3任务下达,4中标信息,5合同信息,6建设情况),必传returnOrderNumber(回退序号,0当前/1第一次回退/2第二次回退...),其他字段不传")
  104. @PostMapping("/viewHis")
  105. @PreAuthorize("@ss.hasPermi('pm:demand:viewHis')")
  106. @Log(title = ModularConstans.demand, businessType = BusinessType.QUERY)
  107. public AjaxResult viewHis(@RequestBody PmDemandReqVo pmDemandReqVo) {
  108. if(pmDemandReqVo.getDemandId() == null){
  109. return AjaxResult.error("demandId不能为空");
  110. }
  111. if(ObjectUtils.isEmpty(pmDemandReqVo.getDetailType())){
  112. return AjaxResult.error("详情的类型不能为空");
  113. }
  114. if(ObjectUtils.isEmpty(pmDemandReqVo.getReturnOrderNumber())){
  115. return AjaxResult.error("回退序号不能为空");
  116. }
  117. if(0 == pmDemandReqVo.getReturnOrderNumber()){
  118. return success(pmDemandService.selectPmDemandByDemandId(pmDemandReqVo.getDemandId(),pmDemandReqVo.getDetailType()));
  119. } else {
  120. return success(pmDemandHisService.selectPmDemandHisByDemandId(pmDemandReqVo.getDemandId(),pmDemandReqVo.getDetailType(),pmDemandReqVo.getReturnOrderNumber()));
  121. }
  122. }
  123. /**
  124. * 需求建档
  125. */
  126. @ApiOperation(value = "需求建档", notes = "必传demandId,根据项目类型必传pmDemandEngineeringResponseVo(3:工程类)、pmDemandEquipResponseVo(0:装备类)、pmDemandMaterialsResponseVo(1:物资类)、pmDemandServeResponseVo(2:服务类)其中之一")
  127. @PostMapping("/bookBuilding")
  128. @PreAuthorize("@ss.hasPermi('pm:demand:bookBuilding')")
  129. @Log(title = ModularConstans.demand, businessType = BusinessType.INSERT)
  130. public AjaxResult bookBuilding(@NotEmpty(message = "数据为空") @RequestBody PmBookBuildingReqVo pmBookBuildingReqVo, HttpServletRequest request) {
  131. try {
  132. if (pmBookBuildingReqVo.getDemandId() == null) {
  133. return AjaxResult.error("demandId不能为空");
  134. }
  135. PmDemand pmDemand = pmDemandService.getById(pmBookBuildingReqVo.getDemandId());
  136. if (ObjectUtils.isEmpty(pmDemand)) {
  137. return error("demandId参数错误");
  138. }
  139. if (ObjectUtils.isEmpty(pmBookBuildingReqVo.getBudgetAmount())) {
  140. return error("预算金额不能为空");
  141. }
  142. if (ObjectUtils.isEmpty(pmBookBuildingReqVo.getDemandCommitTime())) {
  143. return error("需求提报时间不能为空");
  144. }
  145. LoginUser loginUser = tokenService.getLoginUser(request);
  146. pmBookBuildingReqVo.setCreateBy(String.valueOf(loginUser.getUserId()));
  147. pmBookBuildingReqVo.setCreateTime(new Date());
  148. pmBookBuildingReqVo.setUpdateBy(String.valueOf(loginUser.getUserId()));
  149. pmBookBuildingReqVo.setUpdateTime(pmBookBuildingReqVo.getCreateTime());
  150. return toAjax(pmDemandService.bookBuilding(pmBookBuildingReqVo));
  151. } catch (Exception e) {
  152. return error(e.getMessage());
  153. }
  154. }
  155. @ApiOperation(value = "提交采购需求", notes = "必传demandId,其他字段不传")
  156. @PostMapping("/commit")
  157. @PreAuthorize("@ss.hasPermi('pm:demand:commit')")
  158. @Log(title = ModularConstans.demand, businessType = BusinessType.UPDATE)
  159. public AjaxResult commit(@RequestBody PmDemandReqVo pmDemandReqVo, HttpServletRequest request) {
  160. if(pmDemandReqVo.getDemandId() == null){
  161. return AjaxResult.error("demandId不能为空");
  162. }
  163. LoginUser loginUser = tokenService.getLoginUser(request);
  164. pmDemandReqVo.setUpdateBy(String.valueOf(loginUser.getUserId()));
  165. return toAjax(pmDemandService.commit(pmDemandReqVo));
  166. }
  167. /**
  168. * 查看流程图,获取当前阶段名字
  169. */
  170. @ApiOperation(value = "查看流程图,获取当前阶段名字", notes = "必传demandId,其他字段不传")
  171. @PostMapping("/viewFlowChart")
  172. @PreAuthorize("@ss.hasPermi('pm:demand:viewFlowChart')")
  173. @Log(title = ModularConstans.demand, businessType = BusinessType.QUERY)
  174. public AjaxResult viewFlowChart(@RequestBody PmDemandReqVo pmRequestVo) {
  175. if(pmRequestVo.getDemandId() == null){
  176. return AjaxResult.error("demandId不能为空");
  177. }
  178. return success(pmDemandService.viewFlowChart(pmRequestVo.getDemandId()));
  179. }
  180. /**
  181. * 审核单位查询采购需求列表
  182. */
  183. @ApiOperation(value = "审核单位查询采购需求列表", notes = "参数非必传")
  184. @PostMapping("/examineList")
  185. @PreAuthorize("@ss.hasPermi('pm:examine:list')")
  186. @Log(title = ModularConstans.demandExamine, businessType = BusinessType.QUERY)
  187. public AjaxResult examineList(@RequestBody PmDemandReqVo pmDemandReqVo) {
  188. pmDemandReqVo.setIsAdmin(SysUser.isAdmin(getUserId()));
  189. pmDemandReqVo.setDeptId(getDeptId());
  190. pmDemandReqVo.setUserId(getUserId());
  191. IPage<PmDemandResVo> page = pmDemandService.selectPmDemandList(pmDemandReqVo, 1);
  192. return success(page);
  193. }
  194. @ApiOperation(value = "审核采购需求通过", notes = "必传demandId和上传附件,其他字段不传")
  195. @PostMapping("/reviewTo")
  196. @PreAuthorize("@ss.hasPermi('pm:examine:reviewTo')")
  197. @Log(title = ModularConstans.demandExamine, businessType = BusinessType.UPDATE)
  198. public AjaxResult reviewTo(@RequestBody PmDemandReqVo pmDemandReqVo, HttpServletRequest request) {
  199. if(pmDemandReqVo.getDemandId() == null){
  200. return AjaxResult.error("demandId不能为空");
  201. }
  202. if(pmDemandReqVo.getSysFileRefs() == null || pmDemandReqVo.getSysFileRefs().size() == 0){
  203. return AjaxResult.error("上传附件不能为空");
  204. }
  205. LoginUser loginUser = tokenService.getLoginUser(request);
  206. pmDemandReqVo.setUpdateBy(String.valueOf(loginUser.getUserId()));
  207. return toAjax(pmDemandService.reviewTo(pmDemandReqVo));
  208. }
  209. @ApiOperation(value = "审核采购需求退回", notes = "必传demandId和退回原因,其他字段不传")
  210. @PostMapping("/reviewReturn")
  211. @PreAuthorize("@ss.hasPermi('pm:examine:reviewReturn')")
  212. @Log(title = ModularConstans.demandExamine, businessType = BusinessType.UPDATE)
  213. public AjaxResult reviewReturn(@RequestBody PmDemandReqVo pmDemandReqVo, HttpServletRequest request) {
  214. if(pmDemandReqVo.getDemandId() == null){
  215. return AjaxResult.error("demandId不能为空");
  216. }
  217. if(StringUtils.isEmpty(pmDemandReqVo.getRefuseReason())){
  218. return AjaxResult.error("退回原因不能为空");
  219. }
  220. LoginUser loginUser = tokenService.getLoginUser(request);
  221. pmDemandReqVo.setUpdateBy(String.valueOf(loginUser.getUserId()));
  222. return toAjax(pmDemandService.reviewReturn(pmDemandReqVo));
  223. }
  224. }