资源 占用 库存扣减
This commit is contained in:
+7
@@ -43,4 +43,11 @@ public class ResourceBaseVO {
|
||||
|
||||
private Boolean pretendDelete;
|
||||
|
||||
private String unit;
|
||||
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty("唯一资源被占用")
|
||||
private Boolean occupied;
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -44,4 +44,11 @@ public class ResourceExcelVO {
|
||||
|
||||
private Boolean pretendDelete;
|
||||
|
||||
private String unit;
|
||||
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty("唯一资源被占用")
|
||||
private Boolean occupied;
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -54,4 +54,11 @@ public class ResourceExportReqVO {
|
||||
|
||||
private Boolean pretendDelete;
|
||||
|
||||
private String unit;
|
||||
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty("唯一资源被占用")
|
||||
private Boolean occupied;
|
||||
|
||||
}
|
||||
|
||||
+7
@@ -56,4 +56,11 @@ public class ResourcePageReqVO extends PageParam {
|
||||
|
||||
private Boolean pretendDelete = false;
|
||||
|
||||
private String unit;
|
||||
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty("唯一资源被占用")
|
||||
private Boolean occupied;
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -50,10 +50,10 @@ public class TaskBaseVO {
|
||||
private Integer weight;
|
||||
|
||||
@ApiModelProperty("任务状态")
|
||||
private TaskStatus status;
|
||||
private TaskStatus status = TaskStatus.PLAN;
|
||||
|
||||
@ApiModelProperty("草稿")
|
||||
private Boolean draft;
|
||||
private Boolean draft = false;
|
||||
|
||||
private Boolean pretendDelete;
|
||||
}
|
||||
|
||||
+9
@@ -65,4 +65,13 @@ public class ResourceDO extends BaseDO {
|
||||
public Boolean getSolo() {
|
||||
return solo;
|
||||
}
|
||||
|
||||
@ApiModelProperty("单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty("数量")
|
||||
private Integer number;
|
||||
|
||||
@ApiModelProperty("唯一资源被占用")
|
||||
private Boolean occupied;
|
||||
}
|
||||
|
||||
+2
-2
@@ -74,10 +74,10 @@ public class ProjectServiceImpl implements ProjectService {
|
||||
|
||||
@Override
|
||||
public void updateProject(ProjectUpdateReqVO updateReqVO) {
|
||||
//检查项目新增、修改时的区域 是否能够使用
|
||||
this.checkProjectAreas(BeanUtil.copyProperties(updateReqVO, ProjectDO.class));
|
||||
// 校验存在
|
||||
this.validateProjectExists(updateReqVO.getId());
|
||||
//检查项目新增、修改时的区域 是否能够使用
|
||||
this.checkProjectAreas(BeanUtil.copyProperties(updateReqVO, ProjectDO.class));
|
||||
//项目修改完成时,,项目下所有任务未完成不能更改项目状态为完成
|
||||
if (updateReqVO.getState().equals(ProjectStateEnum.FINISH)){
|
||||
this.checkProjectTaskFinish(updateReqVO);
|
||||
|
||||
+36
@@ -99,6 +99,8 @@ public class TaskServiceImpl implements TaskService {
|
||||
|
||||
@Override
|
||||
public Long createTask(TaskCreateReqVO createReqVO) {
|
||||
//检查任务资源数量
|
||||
this.checkTaskResourceNumber(BeanUtil.copyProperties(createReqVO, TaskDO.class));
|
||||
// 插入
|
||||
TaskDO task = TaskConvert.INSTANCE.convert(createReqVO);
|
||||
taskMapper.insert(task);
|
||||
@@ -110,6 +112,8 @@ public class TaskServiceImpl implements TaskService {
|
||||
public void updateTask(TaskUpdateReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
this.validateTaskExists(updateReqVO.getId());
|
||||
//检查任务资源数量
|
||||
this.checkTaskResourceNumber(BeanUtil.copyProperties(updateReqVO, TaskDO.class));
|
||||
// 更新
|
||||
TaskDO updateObj = TaskConvert.INSTANCE.convert(updateReqVO);
|
||||
taskMapper.updateById(updateObj);
|
||||
@@ -472,6 +476,38 @@ public class TaskServiceImpl implements TaskService {
|
||||
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);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user