PmTaskReleaseController.java 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package com.ozs.web.controller.pm;
  2. import com.baomidou.mybatisplus.core.metadata.IPage;
  3. import com.ozs.common.annotation.Log;
  4. import com.ozs.common.constant.ModularConstans;
  5. import com.ozs.common.core.controller.BaseController;
  6. import com.ozs.common.core.domain.AjaxResult;
  7. import com.ozs.common.core.domain.entity.SysUser;
  8. import com.ozs.common.core.domain.model.LoginUser;
  9. import com.ozs.common.enums.BusinessType;
  10. import com.ozs.common.utils.StringUtils;
  11. import com.ozs.framework.web.service.TokenService;
  12. import com.ozs.pm.doman.vo.requestVo.PmBookBuildingReqVo;
  13. import com.ozs.pm.doman.vo.requestVo.PmDemandReqVo;
  14. import com.ozs.pm.doman.vo.responseVo.PmDemandResVo;
  15. import com.ozs.pm.service.IPmDemandService;
  16. import com.ozs.pm.service.PmDemandHisService;
  17. import io.swagger.annotations.Api;
  18. import io.swagger.annotations.ApiOperation;
  19. import org.springframework.beans.factory.annotation.Autowired;
  20. import org.springframework.security.access.prepost.PreAuthorize;
  21. import org.springframework.util.ObjectUtils;
  22. import org.springframework.web.bind.annotation.PostMapping;
  23. import org.springframework.web.bind.annotation.RequestBody;
  24. import org.springframework.web.bind.annotation.RequestMapping;
  25. import org.springframework.web.bind.annotation.RestController;
  26. import javax.servlet.http.HttpServletRequest;
  27. /**
  28. * 任务下达Controller
  29. *
  30. * @author ruoyi
  31. * @date 2023-01-16
  32. */
  33. @Api(tags = "任务下达")
  34. @RestController
  35. @RequestMapping("/pm/taskRelease")
  36. public class PmTaskReleaseController extends BaseController {
  37. @Autowired
  38. private IPmDemandService pmDemandService;
  39. @Autowired
  40. private TokenService tokenService;
  41. @Autowired
  42. private PmDemandHisService pmDemandHisService;
  43. /**
  44. * 任务下达查询列表
  45. */
  46. @ApiOperation(value = "任务下达查询列表", notes = "参数非必传")
  47. @PostMapping("/list")
  48. @PreAuthorize("@ss.hasPermi('pm:taskRelease:list')")
  49. @Log(title = ModularConstans.taskRelease, businessType = BusinessType.QUERY)
  50. public AjaxResult list(@RequestBody PmDemandReqVo pmDemandReqVo) {
  51. pmDemandReqVo.setIsAdmin(SysUser.isAdmin(getUserId()));
  52. pmDemandReqVo.setDeptId(getDeptId());
  53. pmDemandReqVo.setUserId(getUserId());
  54. IPage<PmDemandResVo> page = pmDemandService.selectPmDemandList(pmDemandReqVo, 2);
  55. return success(page);
  56. }
  57. @ApiOperation(value = "下达任务", notes = "必传demandId、taskReleaseTime和上传附件,其他字段不传")
  58. @PostMapping("/releaseTask")
  59. @PreAuthorize("@ss.hasPermi('pm:taskRelease:releaseTask')")
  60. @Log(title = ModularConstans.taskRelease, businessType = BusinessType.UPDATE)
  61. public AjaxResult releaseTask(@RequestBody PmDemandReqVo pmDemandReqVo, HttpServletRequest request) {
  62. if(pmDemandReqVo.getDemandId() == null){
  63. return AjaxResult.error("demandId不能为空");
  64. }
  65. if(pmDemandReqVo.getSysFileRefs() == null || pmDemandReqVo.getSysFileRefs().size() == 0){
  66. return AjaxResult.error("上传附件不能为空");
  67. }
  68. LoginUser loginUser = tokenService.getLoginUser(request);
  69. pmDemandReqVo.setUpdateBy(String.valueOf(loginUser.getUserId()));
  70. return toAjax(pmDemandService.releaseTask(pmDemandReqVo));
  71. }
  72. /**
  73. * 查看详情
  74. */
  75. @ApiOperation(value = "查看详情", notes = "必传demandId和详情类型(1项目计划,2需求建档,3任务下达,4中标信息,5合同信息,6建设情况),其他字段不传")
  76. @PostMapping("/view")
  77. @PreAuthorize("@ss.hasPermi('pm:taskRelease:view')")
  78. @Log(title = ModularConstans.taskRelease, businessType = BusinessType.QUERY)
  79. public AjaxResult view(@RequestBody PmDemandReqVo pmDemandReqVo) {
  80. if(pmDemandReqVo.getDemandId() == null){
  81. return AjaxResult.error("demandId不能为空");
  82. }
  83. if(StringUtils.isEmpty(pmDemandReqVo.getDetailType())){
  84. return AjaxResult.error("详情的类型不能为空");
  85. }
  86. return success(pmDemandService.selectPmDemandByDemandId(pmDemandReqVo.getDemandId(), pmDemandReqVo.getDetailType()));
  87. }
  88. /**
  89. * 查看历史详情
  90. */
  91. @ApiOperation(value = "查看历史详情", notes = "必传demandId和详情类型(1项目计划,2需求建档,3任务下达,4中标信息,5合同信息,6建设情况),returnOrderNumber(回退序号,0当前/1第一次回退/2第二次回退...),其他字段不传")
  92. @PostMapping("/viewHis")
  93. @PreAuthorize("@ss.hasPermi('pm:taskRelease:viewHis')")
  94. @Log(title = ModularConstans.purchaseExecution, businessType = BusinessType.QUERY)
  95. public AjaxResult viewHis(@RequestBody PmDemandReqVo pmDemandReqVo) {
  96. if(pmDemandReqVo.getDemandId() == null){
  97. return AjaxResult.error("demandId不能为空");
  98. }
  99. if(ObjectUtils.isEmpty(pmDemandReqVo.getDetailType())){
  100. return AjaxResult.error("详情的类型不能为空");
  101. }
  102. if(ObjectUtils.isEmpty(pmDemandReqVo.getReturnOrderNumber())){
  103. return AjaxResult.error("回退序号不能为空");
  104. }
  105. if(0 == pmDemandReqVo.getReturnOrderNumber()){
  106. return view(pmDemandReqVo);
  107. } else {
  108. return success(pmDemandHisService.selectPmDemandHisByDemandId(pmDemandReqVo.getDemandId(),pmDemandReqVo.getDetailType(),pmDemandReqVo.getReturnOrderNumber()));
  109. }
  110. }
  111. }