package com.base.plan.controller;

import com.base.orbit.domain.AjaxResult;
import com.base.plan.model.entity.StripCalcResult;
import com.base.plan.model.param.DemandParam;
import com.base.plan.service.DemandService;
import com.base.plan.service.StripCalcResultService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@Api(value = "站点列表控制类")
@RestController
@RequestMapping("/api/demand")
public class DemandController {

    @Resource
    private DemandService demandService;

    @Resource
    StripCalcResultService stripCalcResultService;

    @ApiOperation(value = "需求提报", notes = "parentId数组")
    @PostMapping("/submit")
    public AjaxResult demandSubmit(@RequestBody @ApiParam(name = "parentId", value = "筹划id") Set<String> parentIds) {
        demandService.demandSubmit(parentIds);
        return AjaxResult.success();
    }

    @ApiOperation(value = "通过parentId进行筹划", notes = "parentId数组")
    @PostMapping("/plan")
    public AjaxResult demandPlan(@RequestBody @ApiParam(name = "parentId", value = "筹划id") Set<String> parentIds) {
        demandService.demandPlan(parentIds);
        return AjaxResult.success();
    }

    @ApiOperation(value = "查询条带计算结果", notes = "parentId数组", response = StripCalcResult.class)
    @GetMapping("/getStripCalcResult")
    public AjaxResult getStripCalcResult(){
        return AjaxResult.success(stripCalcResultService.getStripCalcResult());
    }

    /**
     * 根据parentId进行筹划方案生成
     * @param demandParam 筹划方案请求参数类
     * @return 筹划方案生成结果
     */
    @ApiOperation(value = "通过parentId进行筹划", notes = "parentId数组")
    @PostMapping("/planAllTarget")
    public AjaxResult planAllTarget(@RequestBody DemandParam demandParam) {
        return demandService.planAllTarget(demandParam);
    }
}
