package com.gyee.runeconomy.controller;


import com.gyee.runeconomy.dto.R;
import com.gyee.runeconomy.dto.ResultMsg;
import com.gyee.runeconomy.model.auto.ProBasicEquipment;
import com.gyee.runeconomy.service.auto.IProBasicEquipmentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 风机&光伏 前端控制器
 * </p>
 *
 * @author wang
 * @since 2022-11-22
 */
@RestController
@RequestMapping("//pro-basic-equipment")
public class ProBasicEquipmentController {


    @Autowired
    private IProBasicEquipmentService proBasicEquipmentService;


    /**
     * 多条件获取设备列表
     *
     * @param companyId
     * @param windpowerstationIds
     * @param projectIds
     * @param lineIds
     * @param type
     * @return
     */
    @GetMapping("/equipment-list")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public R getWtPowerCurveFittingList(
            @RequestParam(value = "companyId", required = true) String companyId,
            @RequestParam(value = "windpowerstationIds", required = false) String windpowerstationIds,
            @RequestParam(value = "projectIds", required = false) String projectIds,
            @RequestParam(value = "lineIds", required = false) String lineIds,
            @RequestParam(value = "type", required = false) String type) {

        List<ProBasicEquipment> list = proBasicEquipmentService.getProBasicEquipmentList(companyId, windpowerstationIds, projectIds, lineIds, type);

        if (null != list) {
            return R.data(ResultMsg.ok(list));
        } else {
            return R.error(ResultMsg.error());
        }
    }

    /**
     * 多条件获取设备列表
     *
     * @param wpid
     * @return
     */
    @GetMapping("equipmentsByWpid")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public R getWtPowerCurveFittingList(
            @RequestParam(value = "wpid", required = false) String wpid) {

        List<ProBasicEquipment> list = proBasicEquipmentService.getProBasicEquipmentList(wpid);

        if (null != list) {
            return R.data(ResultMsg.ok(list));
        } else {
            return R.error(ResultMsg.error());
        }
    }

    /**
     * 多条件获取设备列表
     *
     * @param wpid
     * @return
     */
    @GetMapping("equipmentsByWpid2")
    @ResponseBody
    @CrossOrigin(origins = "*", maxAge = 3600)
    public R getWtPowerCurveFittingList2(
            @RequestParam(value = "wpid", required = false) String wpid) {

        List<ProBasicEquipment> list = proBasicEquipmentService.getProBasicEquipmentList2(wpid);

        if (null != list) {
            return R.data(ResultMsg.ok(list));
        } else {
            return R.error(ResultMsg.error());
        }
    }

}
