|
|
|
@ -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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|