diff --git a/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java index 895c85dd..5ab4be6c 100644 --- a/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java +++ b/zsw-farm/zsw-farm-api/src/main/java/cn/iocoder/yudao/module/farm/enums/ErrorCodeConstants.java @@ -33,5 +33,11 @@ public interface ErrorCodeConstants{ ErrorCode PROJECT_AREA_HAS_OCCUPIED = new ErrorCode(1000007014, "项目更新失败,所选区域已被其他进行中项目占用"); + + ErrorCode PROJECT_NOT_STARTING = new ErrorCode(1000007015, "任务更新失败,项目还没开始"); + + ErrorCode DISCUSS_ADD_FAIL = new ErrorCode(1000007016, "活动操作失败,只有任务在进行中才可以新增活动"); + + ErrorCode DISCUSS_TASK_IS_DRAFT = new ErrorCode(100000701, "活动操作失败,所属任务为草稿"); } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java index d812440f..0157b01e 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java @@ -47,7 +47,4 @@ public class ResourceBaseVO { private Integer number; - @ApiModelProperty("唯一资源被占用") - private Boolean occupied; - } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java index 6387ec97..4fd15d97 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java @@ -48,7 +48,4 @@ public class ResourceExcelVO { private Integer number; - @ApiModelProperty("唯一资源被占用") - private Boolean occupied; - } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java index 7ffd730f..24585d04 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java @@ -58,7 +58,4 @@ public class ResourceExportReqVO { private Integer number; - @ApiModelProperty("唯一资源被占用") - private Boolean occupied; - } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java index 7af3b1e0..e5ca931b 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java @@ -60,7 +60,4 @@ public class ResourcePageReqVO extends PageParam { private Integer number; - @ApiModelProperty("唯一资源被占用") - private Boolean occupied; - } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java index 53b8d5e2..a3f51f23 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java @@ -71,7 +71,4 @@ public class ResourceDO extends BaseDO { @ApiModelProperty("数量") private Integer number; - - @ApiModelProperty("唯一资源被占用") - private Boolean occupied; } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java index ed49acd1..9bfdfa72 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/discuss/DiscussServiceImpl.java @@ -12,9 +12,12 @@ import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO; import cn.iocoder.yudao.module.farm.controller.admin.workHour.dto.WorkUserMsgDTO; import cn.iocoder.yudao.module.farm.controller.admin.workHour.vo.WorkHourBaseVO; import cn.iocoder.yudao.module.farm.dal.dataobject.area.AreaDO; +import cn.iocoder.yudao.module.farm.dal.dataobject.task.TaskDO; import cn.iocoder.yudao.module.farm.dal.dataobject.workHour.WorkHourDO; import cn.iocoder.yudao.module.farm.dal.mysql.area.AreaMapper; +import cn.iocoder.yudao.module.farm.dal.mysql.task.TaskMapper; import cn.iocoder.yudao.module.farm.dal.mysql.workHour.WorkHourMapper; +import cn.iocoder.yudao.module.farm.enums.TaskStatus; import cn.iocoder.yudao.module.farm.service.area.AreaService; import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO; import cn.iocoder.yudao.module.system.dal.dataobject.user.AdminUserDO; @@ -63,9 +66,13 @@ public class DiscussServiceImpl implements DiscussService { private AreaService areaService; @Resource private AreaMapper areaMapper; + @Resource + private TaskMapper taskMapper; @Override public Long createDiscuss(DiscussCreateReqVO createReqVO) { + //只有所属任务进行中才可以添加活动 + this.canDiscussCreated(BeanUtil.copyProperties(createReqVO, DiscussDO.class)); // 插入 DiscussDO discuss = DiscussConvert.INSTANCE.convert(createReqVO); discussMapper.insert(discuss); @@ -111,6 +118,8 @@ public class DiscussServiceImpl implements DiscussService { public void updateDiscuss(DiscussUpdateReqVO updateReqVO) { // 校验存在 this.validateDiscussExists(updateReqVO.getId()); + //只有所属任务进行中才可以修改活动 + this.canDiscussCreated(BeanUtil.copyProperties(updateReqVO, DiscussDO.class)); // 更新 DiscussDO updateObj = DiscussConvert.INSTANCE.convert(updateReqVO); discussMapper.updateById(updateObj); @@ -213,4 +222,20 @@ public class DiscussServiceImpl implements DiscussService { PageVO returnList = PageUtil.convertPageInfo(discussDTOList); return R.success(returnList); } + + /** + * 任务进行中才能创建活动 + */ + public void canDiscussCreated(DiscussDO discussDO){ + TaskDO taskDO = taskMapper.selectById(discussDO.getTaskId()); + if (ObjectUtil.isNotEmpty(taskDO)){ + if (!taskDO.getStatus().equals(TaskStatus.STARTED)){ + throw exception(DISCUSS_ADD_FAIL); + } + if (taskDO.getDraft()){ + throw exception(DISCUSS_TASK_IS_DRAFT); + } + } + } + } diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java index 6bb756b5..0c2437fe 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.page.PageUtil; import cn.iocoder.yudao.framework.common.page.PageVO; +import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.farm.controller.admin.project.dto.ProjectListDTO; @@ -21,6 +22,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.zsw.base.R; import lombok.extern.slf4j.Slf4j; +import org.springframework.security.core.parameters.P; import org.springframework.stereotype.Service; import javax.annotation.Resource; import org.springframework.validation.annotation.Validated; @@ -156,7 +158,14 @@ public class ProjectServiceImpl implements ProjectService { } } queryWrapperX.orderByDesc(ProjectDO::getId); - List list = projectMapper.selectPage(new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize()), queryWrapperX).getRecords(); + + projectMapper.selectList(queryWrapperX); + PageParam pageParam = new PageParam(); + pageParam.setPageNo(pageDTO.getPageNum()); + pageParam.setPageSize(pageDTO.getPageSize()); + List list = projectMapper.selectPage(pageParam, queryWrapperX).getList(); + +// List list = projectMapper.selectPage(new Page<>(pageDTO.getPageNum(), pageDTO.getPageSize()), queryWrapperX).getRecords(); if (ObjectUtil.isEmpty(list)){ return R.success(PageUtil.emptyPage(pageDTO, ProjectListDTO.class)); diff --git a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java index 83a615a7..fe9bf797 100644 --- a/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java +++ b/zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java @@ -30,6 +30,7 @@ import cn.iocoder.yudao.module.farm.dal.mysql.project.ProjectMapper; import cn.iocoder.yudao.module.farm.dal.mysql.resource.ResourceMapper; import cn.iocoder.yudao.module.farm.dal.mysql.resourceType.ResourceTypeMapper; import cn.iocoder.yudao.module.farm.dal.mysql.taskCate.TaskCateMapper; +import cn.iocoder.yudao.module.farm.enums.ProjectStateEnum; import cn.iocoder.yudao.module.farm.enums.TaskMemberEnum; import cn.iocoder.yudao.module.farm.enums.TaskStatus; import cn.iocoder.yudao.module.system.dal.dataobject.CpUser.CpUserDO; @@ -42,6 +43,7 @@ import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.zsw.base.R; +import javafx.concurrent.Task; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -99,10 +101,13 @@ public class TaskServiceImpl implements TaskService { @Override public Long createTask(TaskCreateReqVO createReqVO) { + TaskDO task = BeanUtil.copyProperties(createReqVO, TaskDO.class); + //检查项目能否开始 + this.canTheTaskStart(task); //检查任务资源数量 - this.checkTaskResourceNumber(BeanUtil.copyProperties(createReqVO, TaskDO.class)); + this.checkTaskResourceNumber(task); + task.setDeptId(Objects.requireNonNull(SecurityFrameworkUtils.getLoginUser()).getDeptId()); // 插入 - TaskDO task = TaskConvert.INSTANCE.convert(createReqVO); taskMapper.insert(task); // 返回 return task.getId(); @@ -110,13 +115,15 @@ public class TaskServiceImpl implements TaskService { @Override public void updateTask(TaskUpdateReqVO updateReqVO) { + TaskDO task = BeanUtil.copyProperties(updateReqVO, TaskDO.class); + //检查项目能否开始 + this.canTheTaskStart(task); // 校验存在 this.validateTaskExists(updateReqVO.getId()); //检查任务资源数量 - this.checkTaskResourceNumber(BeanUtil.copyProperties(updateReqVO, TaskDO.class)); + this.checkTaskResourceNumber(task); // 更新 - TaskDO updateObj = TaskConvert.INSTANCE.convert(updateReqVO); - taskMapper.updateById(updateObj); + taskMapper.updateById(task); } @Override @@ -489,16 +496,10 @@ public class TaskServiceImpl implements TaskService { //更改成进行中 if (taskDO.getStatus().equals(TaskStatus.STARTED)){ resourceDO.setNumber(resourceDO.getNumber() - item.getNum()); - if (resourceDO.getSolo()){ - //唯一资源 更改成 已占用 - resourceDO.setOccupied(true); - } } //更改成已完成 if (taskDO.getStatus().equals(TaskStatus.COMPLETE)){ if (resourceDO.getSolo()){ - //唯一资源 更改成 未占用, 并返还数量 - resourceDO.setOccupied(false); resourceDO.setNumber(resourceDO.getNumber() + item.getNum()); } } @@ -509,5 +510,16 @@ public class TaskServiceImpl implements TaskService { } + /** + * 任务能否开始,只有所属项目开始了才可以开始 + */ + public void canTheTaskStart(TaskDO taskDO){ + if (!taskDO.getDraft() && taskDO.getStatus().equals(TaskStatus.STARTED)){ + ProjectDO project = projectMapper.selectById(taskDO.getProjectId()); + if (!project.getState().equals(ProjectStateEnum.STARTING)){ + throw exception(PROJECT_NOT_STARTING); + } + } + } }