|
|
@ -99,6 +99,8 @@ public class TaskServiceImpl implements TaskService { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Long createTask(TaskCreateReqVO createReqVO) { |
|
|
|
public Long createTask(TaskCreateReqVO createReqVO) { |
|
|
|
|
|
|
|
//检查任务资源数量
|
|
|
|
|
|
|
|
this.checkTaskResourceNumber(BeanUtil.copyProperties(createReqVO, TaskDO.class)); |
|
|
|
// 插入
|
|
|
|
// 插入
|
|
|
|
TaskDO task = TaskConvert.INSTANCE.convert(createReqVO); |
|
|
|
TaskDO task = TaskConvert.INSTANCE.convert(createReqVO); |
|
|
|
taskMapper.insert(task); |
|
|
|
taskMapper.insert(task); |
|
|
@ -110,6 +112,8 @@ public class TaskServiceImpl implements TaskService { |
|
|
|
public void updateTask(TaskUpdateReqVO updateReqVO) { |
|
|
|
public void updateTask(TaskUpdateReqVO updateReqVO) { |
|
|
|
// 校验存在
|
|
|
|
// 校验存在
|
|
|
|
this.validateTaskExists(updateReqVO.getId()); |
|
|
|
this.validateTaskExists(updateReqVO.getId()); |
|
|
|
|
|
|
|
//检查任务资源数量
|
|
|
|
|
|
|
|
this.checkTaskResourceNumber(BeanUtil.copyProperties(updateReqVO, TaskDO.class)); |
|
|
|
// 更新
|
|
|
|
// 更新
|
|
|
|
TaskDO updateObj = TaskConvert.INSTANCE.convert(updateReqVO); |
|
|
|
TaskDO updateObj = TaskConvert.INSTANCE.convert(updateReqVO); |
|
|
|
taskMapper.updateById(updateObj); |
|
|
|
taskMapper.updateById(updateObj); |
|
|
@ -472,6 +476,38 @@ public class TaskServiceImpl implements TaskService { |
|
|
|
return list; |
|
|
|
return list; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 新增或修改检查任务所需资源数量 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void checkTaskResourceNumber(TaskDO taskDO){ |
|
|
|
|
|
|
|
if (!taskDO.getDraft()){ |
|
|
|
|
|
|
|
List<ResourceDTO> resourceList = taskDO.getResources().toJavaList(ResourceDTO.class); |
|
|
|
|
|
|
|
//任务状态更改成进行中 或 任务状态更改成完成
|
|
|
|
|
|
|
|
if (taskDO.getStatus().equals(TaskStatus.STARTED) || taskDO.getStatus().equals(TaskStatus.COMPLETE)){ |
|
|
|
|
|
|
|
resourceList.forEach(item ->{ |
|
|
|
|
|
|
|
ResourceDO resourceDO = resourceMapper.selectById(item.getResourceId().get(1)); |
|
|
|
|
|
|
|
//更改成进行中
|
|
|
|
|
|
|
|
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()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
resourceMapper.updateById(resourceDO); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|