Files
klp-oa/klp-aps/src/main/java/com/klp/aps/controller/ApsPlanController.java
2026-03-08 16:02:44 +08:00

56 lines
1.7 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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