package vip.xiaonuo.production.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.production.entity.ProductionReceive;
import vip.xiaonuo.production.entity.ProductionWorkstopPlan;
import vip.xiaonuo.production.entity.vo.*;
import vip.xiaonuo.production.param.*;
import vip.xiaonuo.production.service.IProductionWorkstopPlanService;

import java.util.List;

/**
 * <p>
 * 生成管控车间计划 前端控制器
 * </p>
 *
 * @author author
 * @since 2024-12-12
 */
@RestController
@Api(tags = "生成管控车间计划")
@ApiSupport(author = "wang", order = 1)
@Validated
public class ProductionWorkstopPlanController {

    @Autowired
    private IProductionWorkstopPlanService workstopPlanService;

    @PostMapping("/production-work-plan/getList")
    @ApiOperationSupport(order = 1)
    @ApiOperation("生成管控车间计划列表")
    public CommonResult<List<ProductionPlanVo>> getList(@RequestBody ProductionPlanParam planParam) {
        return CommonResult.data(workstopPlanService.getList(planParam));
    }

    @PostMapping("/production-work-plan/getTarget")
    @ApiOperationSupport(order = 2)
    @ApiOperation("大屏生成与质量指标")
    public CommonResult<ProductionWorkPlanTargetVo> getTarget(@RequestBody ProductionTargetParam targetParam) {
        return CommonResult.data(workstopPlanService.getTarget(targetParam));
    }


    @PostMapping("/production-work-plan/getDetail")
    @ApiOperationSupport(order = 3)
    @ApiOperation("大屏生成与质量指标详情")
    public CommonResult<List<ProductionPlanDetailVo>> getDetail(@RequestBody ProductionDetailParam detailParam) {
        return CommonResult.data(workstopPlanService.getDetail(detailParam));
    }

    @PostMapping("/production-work-plan/listScreen")
    @ApiOperationSupport(order = 4)
    @ApiOperation("大屏主要产品计划与实际产量")
    public CommonResult<List<ProductionVo>> listScreen(@RequestBody ProductionScreenParam screenParam) {
        return CommonResult.data(workstopPlanService.listScreen(screenParam));
    }

    @PostMapping("/production-work-plan/getTop")
    @ApiOperationSupport(order = 5)
    @ApiOperation("大屏各车间产品完成率排名top10，包含全部")
    public CommonResult<IPage<ProductionWorkstopPlan>> getTop(@RequestBody ProductionPageParam pageParam) {
        return CommonResult.data(workstopPlanService.getTop(pageParam));
    }


    @PostMapping("/production-work-plan/listLocation")
    @ApiOperationSupport(order = 6)
    @ApiOperation("车间列表")
    public CommonResult<List<ProductionLocationVo>> listLocation(@RequestBody ProductionVoParam voParam) {
        return CommonResult.data(workstopPlanService.listLocation(voParam));
    }


    @PostMapping("/production-work-plan/listProductionName")
    @ApiOperationSupport(order = 7)
    @ApiOperation("产品名称列表")
    public CommonResult<List<ProductionNameVo>> listProductionName(@RequestBody ProductionVoParam voParam) {
        return CommonResult.data(workstopPlanService.listProductionName(voParam));
    }
}
