package com.fizz.business.controller;

import com.fizz.business.domain.ProStoppage;
import com.fizz.business.form.ProStoppageForm;
import com.fizz.business.service.ProStoppageService;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.R;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

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

@RestController
@RequestMapping("/api/stoppage")
@Tag(name= "停机管理",description = "停机管理")
@Anonymous
public class ProStoppageController {

    @Resource
    private ProStoppageService proStoppageService;

//    @PostMapping("/add")
//    @ApiOperation("新增停机记录")
//    public R<Boolean> add(@RequestBody ProStoppage proStoppage) {
//        return R.ok(proStoppageService.addProStoppage(proStoppage));
//    }

    @PutMapping("/update")
    @Operation(summary = "修改停机记录")
    public R<Boolean> update(@RequestBody ProStoppage proStoppage) {
        return R.ok(proStoppageService.updateProStoppage(proStoppage));
    }

    @DeleteMapping("/delete/{stopid}")
    @Operation(summary ="删除实绩记录")
    public R<Boolean> delete(@PathVariable @Parameter(description="停机记录的唯一标识ID") Long stopid) {
        return R.ok(proStoppageService.deleteProStoppage(stopid));
    }

    @PostMapping("/list")
    @Operation(summary ="查询实绩记录")
    public R<List<ProStoppage>> list(@RequestBody ProStoppageForm form) {
        return R.ok(proStoppageService.listAll(form));
    }
    //计算停机次数停机时长 作业率
    @PostMapping("/calc")
    @Operation(summary ="计算停机次数停机时长 作业率")
    public R<List<Object>> calc(@RequestBody ProStoppageForm form) {
        return R.ok(proStoppageService.calc(form));
    }
}
