liding
2026-04-23 1b3d13f691957d4fffdfb3671dc09f66b6e3dfd0
src/main/java/com/ruoyi/production/controller/ProductionPlanController.java
@@ -12,11 +12,11 @@
import com.ruoyi.production.service.ProductionPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import jakarta.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.List;
@@ -34,78 +34,78 @@
@Api(tags = "主生产计划")
public class ProductionPlanController {
//    private final ProductionPlanService productionPlanService;
//
//    @GetMapping("/listPage")
//    @ApiOperation("获取生产计划列表")
//    public R<IPage<ProductionPlanVo>> productionPlanListPage(Page<ProductionPlanDto> page, ProductionPlanDto productionPlanDto) {
//        return R.ok(productionPlanService.listPage(page, productionPlanDto));
//    }
//
//    @GetMapping("/loadProdData")
//    @ApiOperation("拉取销售生产计划")
//    @Log(title = "拉取销售生产计划", businessType = BusinessType.INSERT)
//    public R loadProdData() {
//        productionPlanService.loadProdData();
//        return R.ok();
//    }
//
//    @PostMapping("/combine")
//    @Log(title = "合并生产计划", businessType = BusinessType.INSERT)
//    @ApiOperation("合并生产计划")
//    public R combine(@RequestBody ProductionPlanDto productionPlanDto) {
//        if (productionPlanDto.getIds() == null || productionPlanDto.getIds().isEmpty()) {
//            return R.fail("请选择要下发的生产计划");
//        }
//
//        if (productionPlanDto.getTotalAssignedQuantity() == null || productionPlanDto.getTotalAssignedQuantity().compareTo(BigDecimal.ZERO) <= 0) {
//            return R.fail("请输入下发数量");
//        }
//        return R.ok(productionPlanService.combine(productionPlanDto));
//    }
//
//    @PostMapping("")
//    @Log(title = "创建生产计划", businessType = BusinessType.INSERT)
//    @ApiOperation("创建生产计划")
//    public R add(@RequestBody ProductionPlanDto productionPlanDto) {
//        return R.ok(productionPlanService.add(productionPlanDto));
//    }
//
//    @PutMapping("")
//    @Log(title = "更新生产计划", businessType = BusinessType.UPDATE)
//    @ApiOperation("更新生产计划")
//    public R update(@RequestBody ProductionPlanDto productionPlanDto) {
//        return R.ok(productionPlanService.update(productionPlanDto));
//    }
//
//    @DeleteMapping("")
//    @Log(title = "删除生产计划", businessType = BusinessType.DELETE)
//    @ApiOperation("删除生产计划")
//    public R delete(@RequestBody List<Long> ids) {
//        return R.ok(productionPlanService.removeByIds(ids));
//    }
//
//    @PostMapping("/downloadTemplate")
//    @Log(title = "下载主生产计划导入模板", businessType = BusinessType.EXPORT)
//    @ApiOperation("下载主生产计划导入模板")
//    public void importTemplate(HttpServletResponse response) {
//        ExcelUtil<ProductionPlanImportDto> excelUtil = new ExcelUtil<>(ProductionPlanImportDto.class);
//        excelUtil.importTemplateExcel(response, "主生产计划导入模板");
//    }
//
//    @PostMapping("/import")
//    @ApiOperation("主生产计划数据导入")
//    @Log(title = "主生产计划数据导入", businessType = BusinessType.IMPORT)
//    public R importProdData(@RequestParam("file") MultipartFile file) {
//        productionPlanService.importProdData(file);
//        return R.ok("导入成功");
//    }
//
//    @PostMapping("/export")
//    @ApiOperation("主生产计划数据导出")
//    @Log(title = "主生产计划数据导出", businessType = BusinessType.EXPORT)
//    public void exportProdData(HttpServletResponse response, @RequestBody(required = false) List<Long> ids) {
//        productionPlanService.exportProdData(response, ids);
//    }
    private final ProductionPlanService productionPlanService;
    @GetMapping("/listPage")
    @ApiOperation("获取生产计划列表")
    public R<IPage<ProductionPlanVo>> productionPlanListPage(Page<ProductionPlanDto> page, ProductionPlanDto productionPlanDto) {
        return R.ok(productionPlanService.listPage(page, productionPlanDto));
    }
    @GetMapping("/loadProdData")
    @ApiOperation("拉取销售生产计划")
    @Log(title = "拉取销售生产计划", businessType = BusinessType.INSERT)
    public R loadProdData() {
        productionPlanService.loadProdData();
        return R.ok();
    }
    @PostMapping("/combine")
    @Log(title = "合并生产计划", businessType = BusinessType.INSERT)
    @ApiOperation("合并生产计划")
    public R combine(@RequestBody ProductionPlanDto productionPlanDto) {
        if (productionPlanDto.getIds() == null || productionPlanDto.getIds().isEmpty()) {
            return R.fail("请选择要下发的生产计划");
        }
        if (productionPlanDto.getTotalAssignedQuantity() == null || productionPlanDto.getTotalAssignedQuantity().compareTo(BigDecimal.ZERO) <= 0) {
            return R.fail("请输入下发数量");
        }
        return R.ok(productionPlanService.combine(productionPlanDto));
    }
    @PostMapping("")
    @Log(title = "创建生产计划", businessType = BusinessType.INSERT)
    @ApiOperation("创建生产计划")
    public R add(@RequestBody ProductionPlanDto productionPlanDto) {
        return R.ok(productionPlanService.add(productionPlanDto));
    }
    @PutMapping("")
    @Log(title = "更新生产计划", businessType = BusinessType.UPDATE)
    @ApiOperation("更新生产计划")
    public R update(@RequestBody ProductionPlanDto productionPlanDto) {
        return R.ok(productionPlanService.update(productionPlanDto));
    }
    @DeleteMapping("")
    @Log(title = "删除生产计划", businessType = BusinessType.DELETE)
    @ApiOperation("删除生产计划")
    public R delete(@RequestBody List<Long> ids) {
        return R.ok(productionPlanService.removeByIds(ids));
    }
    @PostMapping("/downloadTemplate")
    @Log(title = "下载主生产计划导入模板", businessType = BusinessType.EXPORT)
    @ApiOperation("下载主生产计划导入模板")
    public void importTemplate(HttpServletResponse response) {
        ExcelUtil<ProductionPlanImportDto> excelUtil = new ExcelUtil<>(ProductionPlanImportDto.class);
        excelUtil.importTemplateExcel(response, "主生产计划导入模板");
    }
    @PostMapping("/import")
    @ApiOperation("主生产计划数据导入")
    @Log(title = "主生产计划数据导入", businessType = BusinessType.IMPORT)
    public R importProdData(@RequestParam("file") MultipartFile file) {
        productionPlanService.importProdData(file);
        return R.ok("导入成功");
    }
    @PostMapping("/export")
    @ApiOperation("主生产计划数据导出")
    @Log(title = "主生产计划数据导出", businessType = BusinessType.EXPORT)
    public void exportProdData(HttpServletResponse response, @RequestBody(required = false) List<Long> ids) {
        productionPlanService.exportProdData(response, ids);
    }
}