suntianwu 2 anni fa
parent
commit
24dff49bf4

+ 13 - 9
purchase-admin/src/main/java/com/ozs/web/controller/pm/PmDemandController.java

@@ -71,16 +71,20 @@ public class PmDemandController extends BaseController {
     @ApiOperation(value = "需求建档", notes = "必传demandId,根据项目类型必传pmDemandEngineeringResponseVo(3:工程类)、pmDemandEquipResponseVo(0:装备类)、pmDemandMaterialsResponseVo(1:物资类)、pmDemandServeResponseVo(2:服务类)其中之一")
     @PostMapping("/bookBuilding")
     public AjaxResult bookBuilding(@RequestBody PmBookBuildingReqVo pmBookBuildingReqVo, HttpServletRequest request) {
-        if(pmBookBuildingReqVo.getDemandId() == null){
-            return AjaxResult.error("demandId不能为空");
-        }
-        PmDemand pmDemand = pmDemandService.getById(pmBookBuildingReqVo.getDemandId());
-        if(ObjectUtils.isEmpty(pmDemand)){
-            return error("demandId参数错误");
+        try {
+            if (pmBookBuildingReqVo.getDemandId() == null) {
+                return AjaxResult.error("demandId不能为空");
+            }
+            PmDemand pmDemand = pmDemandService.getById(pmBookBuildingReqVo.getDemandId());
+            if (ObjectUtils.isEmpty(pmDemand)) {
+                return error("demandId参数错误");
+            }
+            LoginUser loginUser = tokenService.getLoginUser(request);
+            pmBookBuildingReqVo.setUpdateBy(String.valueOf(loginUser.getUserId()));
+            return toAjax(pmDemandService.bookBuilding(pmBookBuildingReqVo));
+        } catch (Exception e) {
+            return error(e.getMessage());
         }
-        LoginUser loginUser = tokenService.getLoginUser(request);
-        pmBookBuildingReqVo.setUpdateBy(String.valueOf(loginUser.getUserId()));
-        return toAjax(pmDemandService.bookBuilding(pmBookBuildingReqVo));
     }
 
     @ApiOperation(value = "提交采购需求", notes = "必传demandId,其他字段不传")

+ 1 - 1
purchase-system/src/main/java/com/ozs/pm/service/IPmDemandService.java

@@ -45,7 +45,7 @@ public interface IPmDemandService extends IService<PmDemand>
      * @param pmBookBuildingReqVo 需求建档
      * @return 结果
      */
-    boolean bookBuilding(PmBookBuildingReqVo pmBookBuildingReqVo);
+    boolean bookBuilding(PmBookBuildingReqVo pmBookBuildingReqVo) throws Exception;
 
     /**
      * 查看流程图

+ 14 - 8
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -94,8 +94,6 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
     @Autowired
     private PmProjectConstructionService pmProjectConstructionService;
-    @Autowired
-    private PmDemandMapper demandMapper;
 
     @Autowired
     private BaseNoticeTypeService baseNoticeTypeService;
@@ -519,12 +517,14 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
      */
     @Override
     @Transactional(rollbackFor = Exception.class)
-    public boolean bookBuilding(PmBookBuildingReqVo vo) {
+    public boolean bookBuilding(PmBookBuildingReqVo vo) throws Exception {
         PmDemand pmDemand = this.getById(vo.getDemandId());
         String projectType = pmDemand.getProjectType();
         if(ProjectTypes.EQUIPMENTTYPE.getCode().equals(projectType)){ //装备类
             PmDemandEquipReqVo pmDemandEquipReqVo =  vo.getPmDemandEquipReqVo();
-
+            if(ObjectUtils.isEmpty(pmDemandEquipReqVo)){
+                throw new Exception("该需求是装备类的,pmDemandEquipReqVo不能为空");
+            }
             LambdaQueryWrapper<PmDemandEquip> lambdaQueryWrapper = new LambdaQueryWrapper<>();
             lambdaQueryWrapper.eq(PmDemandEquip::getDemandId,vo.getDemandId());
             PmDemandEquip pmDemandEquip = iPmDemandEquipService.getOne(lambdaQueryWrapper);
@@ -550,7 +550,9 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
         } else if(ProjectTypes.MATERIALTYPE.getCode().equals(projectType)) { //物资类
             PmDemandMaterialsReqVo pmDemandMaterialsReqVo =  vo.getPmDemandMaterialsReqVo();
-
+            if(ObjectUtils.isEmpty(pmDemandMaterialsReqVo)){
+                throw new Exception("该需求是物资类的,pmDemandMaterialsReqVo不能为空");
+            }
             LambdaQueryWrapper<PmDemandMaterials> lambdaQueryWrapper = new LambdaQueryWrapper<>();
             lambdaQueryWrapper.eq(PmDemandMaterials::getDemandId,vo.getDemandId());
             PmDemandMaterials pmDemandMaterials = iPmDemandMaterialsService.getOne(lambdaQueryWrapper);
@@ -576,7 +578,9 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
         } else if(ProjectTypes.SERVICESTYPE.getCode().equals(projectType)) { //服务类
             PmDemandServeReqVo pmDemandServeReqVo =  vo.getPmDemandServeReqVo();
-
+            if(ObjectUtils.isEmpty(pmDemandServeReqVo)){
+                throw new Exception("该需求是服务类的,pmDemandServeReqVo不能为空");
+            }
             LambdaQueryWrapper<PmDemandServe> lambdaQueryWrapper = new LambdaQueryWrapper<>();
             lambdaQueryWrapper.eq(PmDemandServe::getDemandId,vo.getDemandId());
             PmDemandServe pmDemandServe = iPmDemandServeService.getOne(lambdaQueryWrapper);
@@ -601,7 +605,9 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
 
         } else if(ProjectTypes.PLANTOEXAMINETYPE.getCode().equals(projectType)) { //工程类
             PmDemandEngineeringReqVo pmDemandEngineeringReqVo =  vo.getPmDemandEngineeringReqVo();
-
+            if(ObjectUtils.isEmpty(pmDemandEngineeringReqVo)){
+                throw new Exception("该需求是工程类的,pmDemandEngineeringReqVo不能为空");
+            }
             LambdaQueryWrapper<PmDemandEngineering> lambdaQueryWrapper = new LambdaQueryWrapper<>();
             lambdaQueryWrapper.eq(PmDemandEngineering::getDemandId,vo.getDemandId());
             PmDemandEngineering pmDemandEngineering = iPmDemandEngineeringService.getOne(lambdaQueryWrapper);
@@ -1550,7 +1556,7 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
     public AjaxResult getListByStatus(String projectStatus) {
         LambdaQueryWrapper<PmDemand> lw = new LambdaQueryWrapper<PmDemand>();
         lw.eq(PmDemand::getProjectStatus, projectStatus);
-        List<PmDemand> demandList = demandMapper.selectList(lw);
+        List<PmDemand> demandList = this.baseMapper.selectList(lw);
         //数据转换
         List<PmDemandResVo> pmDemandResponseVoList = new ArrayList<>();
         if (!ObjectUtils.isEmpty(demandList) && demandList.size() > 0) {