|
|
|
@ -293,61 +293,70 @@ public class PlanController {
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
|
|
|
public CommonResult<Boolean> updatePlanStatus(@Valid @RequestBody PlanStatusUpdateVO statusUpdateVO) {
|
|
|
|
public CommonResult<Boolean> updatePlanStatus(@Valid @RequestBody PlanStatusUpdateVO statusUpdateVO) {
|
|
|
|
PlanDO planDO = planMapper.selectById(statusUpdateVO.getId());
|
|
|
|
PlanDO planDO = planMapper.selectById(statusUpdateVO.getId());
|
|
|
|
// 试产
|
|
|
|
if (planDO == null) {
|
|
|
|
if ("pre".equals(statusUpdateVO.getCode())) {
|
|
|
|
return success(false);
|
|
|
|
planDO.setStatus(PlanStatusEnum.试产.getValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//开工
|
|
|
|
|
|
|
|
if ("start".equals(statusUpdateVO.getCode())) {
|
|
|
|
String code = statusUpdateVO.getCode();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 1) 先处理计划状态
|
|
|
|
|
|
|
|
if ("pre".equals(code)) {
|
|
|
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.试产.getValue());
|
|
|
|
|
|
|
|
} else if ("start".equals(code)) {
|
|
|
|
planDO.setStatus(PlanStatusEnum.量产.getValue());
|
|
|
|
planDO.setStatus(PlanStatusEnum.量产.getValue());
|
|
|
|
}
|
|
|
|
} else if ("pause".equals(code)) {
|
|
|
|
//暂停
|
|
|
|
|
|
|
|
else if ("pause".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.暂停.getValue());
|
|
|
|
planDO.setStatus(PlanStatusEnum.暂停.getValue());
|
|
|
|
}
|
|
|
|
} else if ("end".equals(code)) {
|
|
|
|
//完工
|
|
|
|
|
|
|
|
else if ("end".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.完工.getValue());
|
|
|
|
planDO.setStatus(PlanStatusEnum.完工.getValue());
|
|
|
|
}
|
|
|
|
} else if ("store".equals(code)) {
|
|
|
|
// 入库
|
|
|
|
|
|
|
|
else if ("store".equals(statusUpdateVO.getCode())) {
|
|
|
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.已入库.getValue());
|
|
|
|
planDO.setStatus(PlanStatusEnum.已入库.getValue());
|
|
|
|
|
|
|
|
} else if ("commence".equals(code)) {
|
|
|
|
|
|
|
|
planDO.setStatus(PlanStatusEnum.已开工.getValue());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 2) 先落库计划状态(store 最后一条判断依赖这个)
|
|
|
|
|
|
|
|
planMapper.updateById(planDO);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 3) 入库后创建入库单
|
|
|
|
|
|
|
|
if ("store".equals(code)) {
|
|
|
|
planService.createPlanStockIn(statusUpdateVO, planDO);
|
|
|
|
planService.createPlanStockIn(statusUpdateVO, planDO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 4) 任务状态联动
|
|
|
|
|
|
|
|
if (planDO.getTaskId() != null) {
|
|
|
|
TaskDO taskDO = taskService.getTask(planDO.getTaskId());
|
|
|
|
TaskDO taskDO = taskService.getTask(planDO.getTaskId());
|
|
|
|
if (taskDO != null) {
|
|
|
|
if (taskDO != null) {
|
|
|
|
// 条件1:任务单已完成排产(按你的字段,通常 isScheduled == 1)
|
|
|
|
|
|
|
|
boolean scheduledFinished = Integer.valueOf(1).equals(taskDO.getIsScheduled());
|
|
|
|
// commence -> 生产中
|
|
|
|
|
|
|
|
if ("commence".equals(code)) {
|
|
|
|
// 条件2:任务单下所有计划都为入库
|
|
|
|
taskDO.setStatus(TaskStatusEnum.生产中.getValue());
|
|
|
|
List<PlanDO> planList = planMapper.selectList(
|
|
|
|
|
|
|
|
Wrappers.<PlanDO>lambdaQuery()
|
|
|
|
|
|
|
|
.eq(PlanDO::getTaskId, planDO.getTaskId())
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
boolean allPlanFinished = !planList.isEmpty() && planList.stream()
|
|
|
|
|
|
|
|
.allMatch(p -> Integer.valueOf(PlanStatusEnum.已入库.getValue()).equals(p.getStatus()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scheduledFinished && allPlanFinished) {
|
|
|
|
|
|
|
|
taskDO.setStatus(TaskStatusEnum.已完成.getValue()); // 10-已完成
|
|
|
|
|
|
|
|
taskService.updateTask(taskDO);
|
|
|
|
taskService.updateTask(taskDO);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
// store -> 满足条件则已完成
|
|
|
|
else if ("commence".equals(statusUpdateVO.getCode())) {
|
|
|
|
if ("store".equals(code)) {
|
|
|
|
planDO.setStatus(PlanStatusEnum.已开工.getValue());
|
|
|
|
boolean scheduledFinished = Integer.valueOf(1).equals(taskDO.getIsScheduled());
|
|
|
|
|
|
|
|
|
|
|
|
// 修改任务单状态为生产中
|
|
|
|
List<PlanDO> planList = planMapper.selectList(
|
|
|
|
TaskDO taskDO = taskService.getTask(planDO.getTaskId());
|
|
|
|
Wrappers.<PlanDO>lambdaQuery()
|
|
|
|
if (taskDO != null) {
|
|
|
|
.eq(PlanDO::getTaskId, planDO.getTaskId())
|
|
|
|
taskDO.setStatus(TaskStatusEnum.生产中.getValue());
|
|
|
|
);
|
|
|
|
taskService.updateTask(taskDO);
|
|
|
|
|
|
|
|
|
|
|
|
boolean allPlanStored = !planList.isEmpty() && planList.stream()
|
|
|
|
|
|
|
|
.allMatch(p -> Integer.valueOf(PlanStatusEnum.已入库.getValue()).equals(p.getStatus()));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (scheduledFinished && allPlanStored) {
|
|
|
|
|
|
|
|
taskDO.setStatus(TaskStatusEnum.已完成.getValue());
|
|
|
|
|
|
|
|
taskService.updateTask(taskDO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
planMapper.updateById(planDO);
|
|
|
|
|
|
|
|
return success(true);
|
|
|
|
return success(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PutMapping("/updatePlanZjStatus")
|
|
|
|
@PutMapping("/updatePlanZjStatus")
|
|
|
|
@Operation(summary = "更新生产计划质检状态")
|
|
|
|
@Operation(summary = "更新生产计划质检状态")
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
|
|
|
@PreAuthorize("@ss.hasPermission('mes:plan:update')")
|
|
|
|
|