56 lines
1.7 KiB
Java
56 lines
1.7 KiB
Java
package com.klp.aps.controller;
|
||
|
||
import com.klp.common.core.controller.BaseController;
|
||
import com.klp.common.core.domain.R;
|
||
import com.klp.aps.domain.dto.ApsAutoScheduleReq;
|
||
import com.klp.aps.domain.dto.ApsPlanCreateReq;
|
||
import com.klp.aps.service.ApsAutoScheduleService;
|
||
import com.klp.aps.service.ApsPlanService;
|
||
import lombok.RequiredArgsConstructor;
|
||
import org.springframework.validation.annotation.Validated;
|
||
import org.springframework.web.bind.annotation.*;
|
||
|
||
/**
|
||
* APS 计划(MVP)
|
||
*/
|
||
@Validated
|
||
@RequiredArgsConstructor
|
||
@RestController
|
||
@RequestMapping("/aps/plan")
|
||
public class ApsPlanController extends BaseController {
|
||
|
||
private final ApsPlanService apsPlanService;
|
||
private final ApsAutoScheduleService apsAutoScheduleService;
|
||
|
||
/**
|
||
* POST /aps/plan/create
|
||
* 创建计划头与明细,返回 planId
|
||
*/
|
||
@PostMapping("/create")
|
||
public R<Long> create(@Validated @RequestBody ApsPlanCreateReq req) {
|
||
Long planId = apsPlanService.createPlan(req, getUsername());
|
||
return R.ok(planId);
|
||
}
|
||
|
||
/**
|
||
* POST /aps/plan/auto-schedule
|
||
* 自动排程生成 operation + change_log,并更新 plan 状态
|
||
*/
|
||
@PostMapping("/auto-schedule")
|
||
public R<Void> autoSchedule(@Validated @RequestBody ApsAutoScheduleReq req) {
|
||
apsAutoScheduleService.autoSchedule(req, getUsername());
|
||
return R.ok();
|
||
}
|
||
|
||
/**
|
||
* POST /aps/plan/publish/{planId}
|
||
* 仅允许已排产(plan.status=1) 的计划发布,状态流转为 2(已发布/生产中)
|
||
*/
|
||
@PostMapping("/publish/{planId}")
|
||
public R<Void> publish(@PathVariable Long planId) {
|
||
apsPlanService.publishPlan(planId, getUsername());
|
||
return R.ok();
|
||
}
|
||
}
|
||
|