| | |
| | | if(ProjectConstant.COMMIT.equals(entity.getUsedStatus()) && ProjectStatusEnum.PENDDING.getType().equals(entity.getProjectStatus())){ |
| | | entity.setUsedStatus(ProjectConstant.PASS); |
| | | } |
| | | if(!checkProjectNameAndIdIsUnique(entity,null)){ |
| | | return Result.error("项目名或项目码已存在"); |
| | | } |
| | | baseMapper.insert(entity); |
| | | addPlan(entity.getId()); //添加计划表 |
| | | //添加文件 |
| | |
| | | return Result.ok("添加成功").data(entity.getId()); |
| | | } |
| | | |
| | | /** |
| | | * 判断项目名和项目码是否唯一 |
| | | * @param entity from true 来自add() false 来自edit() |
| | | * @return |
| | | */ |
| | | public boolean checkProjectNameAndIdIsUnique(ProjectInfo entity,Long updateId){ |
| | | QueryWrapper<ProjectInfo> queryWrapper = new QueryWrapper<ProjectInfo>(); |
| | | if (updateId == null) { |
| | | |
| | | queryWrapper.eq("project_name", entity.getProjectName()); |
| | | |
| | | if (StringUtils.isNotEmpty(entity.getProjectCode())) { |
| | | queryWrapper.or(); |
| | | queryWrapper.eq("project_code", entity.getProjectCode()); |
| | | } |
| | | |
| | | List<ProjectInfo> project = projectInfoMapper.selectList(queryWrapper); |
| | | |
| | | return project == null || project.isEmpty(); |
| | | }else { |
| | | |
| | | List<ProjectInfo> project = projectInfoMapper.checkProjectNameAndIdIsUnique(updateId,entity.getProjectName(),entity.getProjectCode()); |
| | | |
| | | return project == null || project.isEmpty(); |
| | | } |
| | | |
| | | } |
| | | |
| | | public void addPlan(Long projectInfoId) { |
| | | Plan plan = new Plan(); |
| | |
| | | @Override |
| | | public Result update(ProjectInfoForm form) { |
| | | ProjectInfo entity = baseMapper.selectById(form.getId()); |
| | | |
| | | // 为空抛IllegalArgumentException,做全局异常处理 |
| | | Assert.notNull(entity, "记录不存在"); |
| | | ProjectInfoForm.getEntityByForm(form, entity); |
| | |
| | | //如果是储备项目(未开工项目)不需要审核 |
| | | if (ProjectConstant.COMMIT.equals(entity.getUsedStatus()) && ProjectStatusEnum.PENDDING.getType().equals(entity.getProjectStatus())) { |
| | | entity.setUsedStatus(ProjectConstant.PASS); |
| | | } |
| | | if(!checkProjectNameAndIdIsUnique(entity,form.getId())){ |
| | | return Result.error("项目名或项目码已存在"); |
| | | } |
| | | //更新项目信息 |
| | | baseMapper.updateById(entity); |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Result editProject(ProjectForm form) { |
| | | if (ObjectUtil.isNotNull(form.getProjectInfoForm())) { |
| | | |
| | | if (ObjectUtil.isNull(form.getProjectInfoForm().getId())) { |
| | | //新增 |
| | | ((ProjectInfoServiceImpl) AopContext.currentProxy()).add(form.getProjectInfoForm()); |
| | | return ((ProjectInfoServiceImpl) AopContext.currentProxy()).add(form.getProjectInfoForm()); |
| | | |
| | | } else { |
| | | //更新 |
| | | ((ProjectInfoServiceImpl) AopContext.currentProxy()).update(form.getProjectInfoForm()); |
| | | return ((ProjectInfoServiceImpl) AopContext.currentProxy()).update(form.getProjectInfoForm()); |
| | | } |
| | | } |
| | | if (ObjectUtil.isNotNull(form.getProjectInvestmentInfoForm())) { |