package com.gyee.runeconomy.controller.monitor;/*
@author   谢生杰
@date   2023/5/10-16:06
*/

import com.gyee.common.model.StringUtils;
import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.model.auto.ProBasicSquare;
import com.gyee.runeconomy.model.vo.LandformsVo;
import com.gyee.runeconomy.service.monitor.LandformsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

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

@Controller
@RequestMapping("/landforms")
@Api(value = "地貌图", tags = "地貌图")
public class LandformsController {
    @Resource
    private LandformsService landformsService;

    /**
     * 地貌图数据
     *
     * @return
     */
    @GetMapping("/data")
    @ResponseBody
    @ApiOperation(value = "数据信息", notes = "数据信息")
    public R data(@RequestParam(value = "foreignkeyid", required = true) String foreignkeyid) throws Exception {

        List<LandformsVo> resultList = landformsService.data(foreignkeyid);
        if (StringUtils.isNotNull(resultList)) {
            return R.data(ResultMsg.ok(resultList));
        } else {
            return R.error(ResultMsg.error());
        }
    }


    /**
     * 根据期次查询阵区
     *
     * @return
     */
    @GetMapping("/sqByPj")
    @ResponseBody
    @ApiOperation(value = "根据期次查询阵区", notes = "根据期次查询阵区")
    public R sqByPj(@RequestParam(value = "pjid", required = true) String pjid) throws Exception {

        List<ProBasicSquare> resultList = landformsService.sqByPj(pjid);
        if (StringUtils.isNotNull(resultList)) {
            return R.data(ResultMsg.ok(resultList));
        } else {
            return R.error(ResultMsg.error());
        }
    }

    /**
     * 根据逆变器查询数据列表
     *
     * @return
     */
    @GetMapping("/inverData")
    @ResponseBody
    @ApiOperation(value = "逆变器数据列表", notes = "逆变器数据列表")
    public R inverData(@RequestParam(value = "squareid", required = true) String squareid) throws Exception {

        List<Object> resultList = landformsService.inverData(squareid);
        if (StringUtils.isNotNull(resultList)) {
            return R.data(ResultMsg.ok(resultList));
        } else {
            return R.error(ResultMsg.error());
        }
    }


}
