package com.tofly.xrtygis.custom.controller;

import com.tofly.common.core.entity.ResultRespone;
import com.tofly.xrtygis.custom.entity.dto.FixedDto;
import com.tofly.xrtygis.custom.service.WaterMakingService;
import com.tofly.xrtygis.entity.Costrlprice;
import com.tofly.xrtygis.entity.Costrlwater;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;
import java.util.List;


@RestController
@RequestMapping("/waterMaking")
@AllArgsConstructor
@Api(tags = "实际管理--制水成本改动")
public class WaterMakingController {

    private final WaterMakingService waterMakingService;


    @PostMapping("/insertWaterIndex")
    @ApiOperation("实际管理--填报制水指标")
    public ResultRespone insertWaterIndex(@RequestParam(value = "fileList", required = false)List<MultipartFile> fileList, Costrlwater costrlwater, String notes){
        return ResultRespone.success(waterMakingService.insertWaterIndex(fileList, costrlwater, notes));
    }

    @GetMapping("/getNotesInfo")
    @ApiOperation("实际管理--获取备注信息")
    @ApiImplicitParam(name = "waterId",value = "制水指标id",required = true,dataType = "long")
    public ResultRespone getNotesInfo(Long waterId){
        return ResultRespone.success(waterMakingService.getNotesInfo(waterId));
    }


    @PutMapping("/updateWaterIndex")
    @ApiOperation("实际管理--制水指标修改")
    public ResultRespone updateWaterIndex(@RequestParam(value = "fileList", required = false)List<MultipartFile> fileList, Costrlwater costrlwater,String notes){
        return ResultRespone.success(waterMakingService.updateWaterIndex(fileList, costrlwater, notes));
    }

    @PostMapping("/insertPrice")
    @ApiOperation("实际管理-填报制水单价")
    public ResultRespone  insertPrice(@Valid @RequestBody Costrlprice costrlprice){
        return ResultRespone.success(waterMakingService.insertPrice(costrlprice));
    }

    @PutMapping("/updatePrice")
    @ApiOperation("实际管理-修改制水单价")
    public ResultRespone updatePrice(@RequestBody Costrlprice costrlprice){
        return ResultRespone.success(waterMakingService.updatePrice(costrlprice));
    }

    @GetMapping("/correction")
    @ApiOperation("模拟纠偏")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "month",value = "yyyy-MM or yyyy",required = true,dataType = "string"),
            @ApiImplicitParam(name = "code",value = "0:月份查询 1：年份查询",required = true,dataType = "string")
    })
    @ApiImplicitParam(name = "month",value = "年月 yyyy-MM",required = true,dataType = "string")
    public ResultRespone simulationCorrection(String month,String code){
        return ResultRespone.success(waterMakingService.simulationCorrection(month,code));
    }

    @PostMapping("/insertFixed")
    @ApiOperation("添加单变信息")
    public ResultRespone insertFixed(@RequestBody FixedDto dto){
        return ResultRespone.success(waterMakingService.insertFixed(dto));
    }

    @PutMapping("/updateFixed")
    @ApiOperation("修改单变信息")
    public ResultRespone updateFixed(@RequestBody FixedDto dto){
        return ResultRespone.success(waterMakingService.updateFixed(dto));
    }

}
