|
|
|
@ -28,6 +28,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.CpUser.CpUserMapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
|
import com.zsw.base.R; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.collections4.CollectionUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import org.springframework.validation.annotation.Validated; |
|
|
|
|
|
|
|
|
@ -116,6 +117,8 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
|
|
public ProjectRespVO getProject(Long id) { |
|
|
|
|
ProjectDO projectDO = projectMapper.selectById(id); |
|
|
|
|
ProjectRespVO respVO = BeanUtil.copyProperties(projectDO, ProjectRespVO.class); |
|
|
|
|
CpUserDO mainUser = ObjectUtil.isEmpty(projectDO.getMainPerson()) ? null : cpUserMapper.selectById(projectDO.getMainPerson()); |
|
|
|
|
respVO.setMainPersonMsg(mainUser); |
|
|
|
|
List<CpUserDO> userList = ObjectUtil.isEmpty(projectDO.getMembers()) ? new ArrayList<>() : cpUserMapper.selectList(CpUserDO::getId, projectDO.getMembers()); |
|
|
|
|
respVO.setUserList(userList); |
|
|
|
|
return respVO; |
|
|
|
@ -129,7 +132,31 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public PageResult<ProjectDO> getProjectPage(ProjectPageReqVO pageReqVO) { |
|
|
|
|
return projectMapper.selectPage(pageReqVO); |
|
|
|
|
LambdaQueryWrapperX<ProjectDO> lambdaQueryWrapperX = new LambdaQueryWrapperX<ProjectDO>(); |
|
|
|
|
//搜索执行人
|
|
|
|
|
if (ObjectUtil.isNotEmpty(pageReqVO.getExecutorName())){ |
|
|
|
|
lambdaQueryWrapperX.apply("JSON_CONTAINS(members, '"+ pageReqVO.getExecutorName()+"')"); |
|
|
|
|
} |
|
|
|
|
//区域
|
|
|
|
|
if (ObjectUtil.isNotEmpty(pageReqVO.getAreaId())){ |
|
|
|
|
List<AreaDO> allAreaList = areaService.getAreaAndSubArea(pageReqVO.getAreaId()); |
|
|
|
|
List<Long> allIdList = allAreaList.stream().map(AreaDO::getId).collect(Collectors.toList()); |
|
|
|
|
lambdaQueryWrapperX.apply("JSON_OVERLAPS(areas, '"+ allIdList+"') = 1" ); |
|
|
|
|
} |
|
|
|
|
lambdaQueryWrapperX.likeIfPresent(ProjectDO::getName, pageReqVO.getName()) |
|
|
|
|
.eqIfPresent(ProjectDO::getContent, pageReqVO.getContent()) |
|
|
|
|
.eqIfPresent(ProjectDO::getAreas, pageReqVO.getAreas()) |
|
|
|
|
.eqIfPresent(ProjectDO::getCropId, pageReqVO.getCropId()) |
|
|
|
|
.eqIfPresent(ProjectDO::getState, pageReqVO.getState()) |
|
|
|
|
.eqIfPresent(ProjectDO::getImages, pageReqVO.getImages()) |
|
|
|
|
.betweenIfPresent(ProjectDO::getPlanStartTime, pageReqVO.getBeginPlanStartTime(), pageReqVO.getEndPlanStartTime()) |
|
|
|
|
.betweenIfPresent(ProjectDO::getPlanEndTime, pageReqVO.getBeginPlanEndTime(), pageReqVO.getEndPlanEndTime()) |
|
|
|
|
.eqIfPresent(ProjectDO::getWeight, pageReqVO.getWeight()) |
|
|
|
|
.betweenIfPresent(ProjectDO::getCreateTime, pageReqVO.getBeginCreateTime(), pageReqVO.getEndCreateTime()) |
|
|
|
|
.eqIfPresent(ProjectDO::getPretendDelete, pageReqVO.getPretendDelete()) |
|
|
|
|
.eqIfPresent(ProjectDO::getDraft, pageReqVO.getDraft()) |
|
|
|
|
.orderByDesc(ProjectDO::getId); |
|
|
|
|
return projectMapper.selectPage(pageReqVO, lambdaQueryWrapperX); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -154,7 +181,6 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
|
|
//查看自己的草稿
|
|
|
|
|
queryWrapperX.eqIfPresent(ProjectDO::getCreator, getLoginUserId()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(pageDTO.getMyProject()) && pageDTO.getMyProject()){ |
|
|
|
|
CpUserDO user = cpUserMapper.selectOne(CpUserDO::getUserId, getLoginUser().getUsername()); |
|
|
|
|
if (ObjectUtil.isNotEmpty(user)){ |
|
|
|
@ -162,6 +188,13 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
|
|
queryWrapperX.apply(" ((JSON_CONTAINS(members, '"+ user.getId()+"') or creator = " + getLoginUserId() +"))"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
//根据区域id展示
|
|
|
|
|
if (ObjectUtil.isNotEmpty(pageDTO.getAreaId())){ |
|
|
|
|
List<AreaDO> allAreaList = areaService.getAreaAndSubArea(pageDTO.getAreaId()); |
|
|
|
|
List<Long> allIdList = allAreaList.stream().map(AreaDO::getId).collect(Collectors.toList()); |
|
|
|
|
queryWrapperX.apply("JSON_OVERLAPS(areas, '"+ allIdList+"') = 1" ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
queryWrapperX.orderByDesc(ProjectDO::getId); |
|
|
|
|
|
|
|
|
|
PageParam pageParam = new PageParam(); |
|
|
|
@ -263,6 +296,13 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
|
|
*/ |
|
|
|
|
public void checkProjectAreas(ProjectDO projectDO){ |
|
|
|
|
if (projectDO.getState().equals(ProjectStateEnum.STARTING)){ |
|
|
|
|
ProjectDO old = projectMapper.selectById(projectDO.getId()); |
|
|
|
|
|
|
|
|
|
//区域没修改 跳过下面的检查
|
|
|
|
|
if (CollectionUtils.isEqualCollection(projectDO.getAreas(), old.getAreas())){ |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//检查项目所选区域是否占用
|
|
|
|
|
List<AreaDO> areaList = areaService.getAreaList(projectDO.getAreas()); |
|
|
|
|
List<AreaDO> occupiedList = areaList.stream().filter(item -> item.getOccupied()).collect(Collectors.toList()); |
|
|
|
@ -288,7 +328,7 @@ public class ProjectServiceImpl implements ProjectService {
|
|
|
|
|
//项目更改失败, 进行中的项目不可修改作物
|
|
|
|
|
throw exception(PROJECT_STARTING_CANT_CHANGE_CROP); |
|
|
|
|
} |
|
|
|
|
if (!project.getAreas().equals(updateProject.getAreas())){ |
|
|
|
|
if (!CollectionUtils.isEqualCollection(project.getAreas(), updateProject.getAreas())){ |
|
|
|
|
//项目更改失败, 进行中的项目不可修改区域
|
|
|
|
|
throw exception(PROJECT_STARTING_CANT_CHANGE_AREA); |
|
|
|
|
} |
|
|
|
|