Browse Source

资源 占用 库存扣减

zyh
WIN-IDGBLFHC1K6\Administrator 3 years ago
parent
commit
ab09d4a524
  1. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java
  2. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java
  3. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java
  4. 7
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java
  5. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java
  6. 9
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java
  7. 4
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java
  8. 36
      zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

7
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceBaseVO.java

@ -43,4 +43,11 @@ public class ResourceBaseVO {
private Boolean pretendDelete; private Boolean pretendDelete;
private String unit;
private Integer number;
@ApiModelProperty("唯一资源被占用")
private Boolean occupied;
} }

7
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExcelVO.java

@ -44,4 +44,11 @@ public class ResourceExcelVO {
private Boolean pretendDelete; private Boolean pretendDelete;
private String unit;
private Integer number;
@ApiModelProperty("唯一资源被占用")
private Boolean occupied;
} }

7
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourceExportReqVO.java

@ -54,4 +54,11 @@ public class ResourceExportReqVO {
private Boolean pretendDelete; private Boolean pretendDelete;
private String unit;
private Integer number;
@ApiModelProperty("唯一资源被占用")
private Boolean occupied;
} }

7
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/resource/vo/ResourcePageReqVO.java

@ -56,4 +56,11 @@ public class ResourcePageReqVO extends PageParam {
private Boolean pretendDelete = false; private Boolean pretendDelete = false;
private String unit;
private Integer number;
@ApiModelProperty("唯一资源被占用")
private Boolean occupied;
} }

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/controller/admin/task/vo/TaskBaseVO.java

@ -50,10 +50,10 @@ public class TaskBaseVO {
private Integer weight; private Integer weight;
@ApiModelProperty("任务状态") @ApiModelProperty("任务状态")
private TaskStatus status; private TaskStatus status = TaskStatus.PLAN;
@ApiModelProperty("草稿") @ApiModelProperty("草稿")
private Boolean draft; private Boolean draft = false;
private Boolean pretendDelete; private Boolean pretendDelete;
} }

9
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/dal/dataobject/resource/ResourceDO.java

@ -65,4 +65,13 @@ public class ResourceDO extends BaseDO {
public Boolean getSolo() { public Boolean getSolo() {
return solo; return solo;
} }
@ApiModelProperty("单位")
private String unit;
@ApiModelProperty("数量")
private Integer number;
@ApiModelProperty("唯一资源被占用")
private Boolean occupied;
} }

4
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/project/ProjectServiceImpl.java

@ -74,10 +74,10 @@ public class ProjectServiceImpl implements ProjectService {
@Override @Override
public void updateProject(ProjectUpdateReqVO updateReqVO) { public void updateProject(ProjectUpdateReqVO updateReqVO) {
//检查项目新增、修改时的区域 是否能够使用
this.checkProjectAreas(BeanUtil.copyProperties(updateReqVO, ProjectDO.class));
// 校验存在 // 校验存在
this.validateProjectExists(updateReqVO.getId()); this.validateProjectExists(updateReqVO.getId());
//检查项目新增、修改时的区域 是否能够使用
this.checkProjectAreas(BeanUtil.copyProperties(updateReqVO, ProjectDO.class));
//项目修改完成时,,项目下所有任务未完成不能更改项目状态为完成 //项目修改完成时,,项目下所有任务未完成不能更改项目状态为完成
if (updateReqVO.getState().equals(ProjectStateEnum.FINISH)){ if (updateReqVO.getState().equals(ProjectStateEnum.FINISH)){
this.checkProjectTaskFinish(updateReqVO); this.checkProjectTaskFinish(updateReqVO);

36
zsw-farm/zsw-farm-impl/src/main/java/cn/iocoder/yudao/module/farm/service/task/TaskServiceImpl.java

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

Loading…
Cancel
Save