package com.fizz.business.controller;


import com.fizz.business.constants.enums.DeviceEnum;
import com.fizz.business.dto.CoilPositionDTO;
import com.fizz.business.form.AdjustPosForm;
import com.fizz.business.form.WebOperateMatForm;
import com.fizz.business.service.TrackService;
import com.fizz.business.vo.CoilMeasureVO;
import com.fizz.business.vo.HalfReturnInfoVO;
import com.fizz.business.vo.ReturnInfoVO;
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.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * @author baomidou
 * @since 2023-05-17
 */
@RestController
@RequestMapping("/api/track")
@Tag(name = "过程跟踪")
@Anonymous
public class TrackController {
    @Autowired
    TrackService trackService;

    @PutMapping("/manual/operate/mat")
    @Operation(description = "页面手动操作钢卷")
    public R<String> manualOperateMat(@RequestBody @Valid WebOperateMatForm form) {
        trackService.webOperateMat(form);
        return R.ok();
    }

    @PutMapping("/position")
    @Operation(description = "页面手动调整钢卷位置")
    public R<String> adjustPosition(@RequestBody @Valid AdjustPosForm form) {

        trackService.adjustPosition(form);
        return R.ok();
    }

    @GetMapping("/return/info")
     @Operation(description = "获取回退数据")
    public R<ReturnInfoVO> getReturnInfo(@RequestParam("posIdx") int posIdx) {

        return R.ok(trackService.getReturnInfo(posIdx));
    }

    @GetMapping("/coil/position")
     @Operation(description = "获取跟踪带钢位置")
    public R<CoilPositionDTO> getCoilPosition() {

        return R.ok(trackService.getCoilPosition());
    }

}
