| | |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.gkhy.assess.common.api.CommonPage; |
| | | import com.gkhy.assess.common.constant.SuperAccountConstant; |
| | | import com.gkhy.assess.common.enums.DeleteFlagEnum; |
| | | import com.gkhy.assess.common.enums.UserIdentityEnum; |
| | | import com.gkhy.assess.common.exception.ApiException; |
| | | import com.gkhy.assess.common.utils.PageUtil; |
| | | import com.gkhy.assess.common.utils.StringUtils; |
| | | import com.gkhy.assess.system.domain.AssPlanPerson; |
| | | import com.gkhy.assess.system.domain.AssProject; |
| | | import com.gkhy.assess.system.domain.vo.PersonRecognitionVO; |
| | | import com.gkhy.assess.system.domain.vo.ProjectStaticVO; |
| | | import com.gkhy.assess.system.enums.ProgressPhaseEnum; |
| | | import com.gkhy.assess.system.enums.ReportProgressEnum; |
| | |
| | | throw new ApiException("用户机构id为空"); |
| | | } |
| | | project.setAgencyId(user.getAgencyId()); |
| | | }else { |
| | | //监管机构只能查看本辖区的项目 |
| | | if (!SuperAccountConstant.ADMINISTRATOR.equals(user.getUsername()) && !SuperAccountConstant.SUPER_ADMIN.equals(user.getUsername())){ |
| | | project.setCity(user.getManageRegion()); |
| | | } |
| | | } |
| | | PageUtil.startPage(); |
| | | List<AssProject> projects=baseMapper.projectList(project); |
| | | //获取签字确认人数 |
| | | handleProjectRecognitionCount(projects); |
| | | return CommonPage.restPage(projects); |
| | | } |
| | | |
| | | public void handleProjectRecognitionCount(List<AssProject> projects){ |
| | | List<Long>projectIds=projects.stream().map(item -> item.getId()).collect(Collectors.toList()); |
| | | if(!projectIds.isEmpty()) { |
| | | List<PersonRecognitionVO> personAndRecognitions = planPersonMapper.getPersonAndRecognitionCount(projectIds); |
| | | Map<Long, PersonRecognitionVO> map = personAndRecognitions.stream().collect(Collectors.toMap(PersonRecognitionVO::getProjectId, a -> a)); |
| | | for (AssProject project : projects) { |
| | | PersonRecognitionVO personRecognitionVO = map.get(project.getId()); |
| | | if (personRecognitionVO != null) { |
| | | project.setPersonRecognition(personRecognitionVO); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Override |
| | |
| | | if(user.getAgencyId()==null){ |
| | | throw new ApiException("用户机构id为空"); |
| | | } |
| | | project.setAgencyId(user.getAgencyId()); |
| | | if(!checkNameUnique(project)){ |
| | | throw new ApiException("项目名已存在"); |
| | | } |
| | | project.setAgencyId(user.getAgencyId()); |
| | | |
| | | project.setReportProgress(ReportProgressEnum.ADD.getCode()); |
| | | project.setCreateBy(ShiroUtils.getSysUser().getUsername()); |
| | | int row=baseMapper.insert(project); |
| | |
| | | //todo 权限校验 |
| | | SysUser user= ShiroUtils.getSysUser(); |
| | | checkUserAllowed(projectId); |
| | | AssProject project=new AssProject() |
| | | //判断项目流转状态 |
| | | AssProject project=getById(projectId); |
| | | if(project.getReportProgress().equals(ReportProgressEnum.CONFIRM_FINAL.getCode())){ |
| | | if(!user.getIdentity().equals(UserIdentityEnum.MONITOR.getCode())){ |
| | | throw new ApiException("没有权限删除确认完结的项目,请联系监管用户删除"); |
| | | } |
| | | } |
| | | project=new AssProject() |
| | | .setId(projectId) |
| | | .setDelFlag(DeleteFlagEnum.DELETED.getCode()); |
| | | project.setUpdateBy(user.getUsername()); |
| | |
| | | throw new ApiException("项目id不能为空"); |
| | | } |
| | | checkUserAllowed(projectId); |
| | | if(!checkNameUnique(project)){ |
| | | throw new ApiException("项目名已存在"); |
| | | } |
| | | // if(!checkNameUnique(project)){ |
| | | // throw new ApiException("项目名已存在"); |
| | | // } |
| | | project.setAgencyId(null);//机构id不能修改 |
| | | project.setReportProgress(null);//项目状态不能修改 |
| | | project.setUpdateBy(ShiroUtils.getSysUser().getUsername()); |
| | |
| | | @Override |
| | | public boolean checkNameUnique(AssProject project) { |
| | | Long projectId = project.getId()==null? -1L : project.getId(); |
| | | AssProject pro = baseMapper.getProjectByName(project.getName()); |
| | | AssProject pro = baseMapper.getProjectByName(project.getName(),project.getAgencyId()); |
| | | if (pro!=null && pro.getId().longValue() != projectId.longValue()) |
| | | { |
| | | return false; |