package com.ho.business.service;


import com.ho.business.entity.Device;
import com.ho.business.entity.Station;
import com.ho.business.vo.req.DeviceReqVO;
import com.ho.business.vo.req.EventColReq;
import com.ho.business.vo.req.OperatingStatistic;
import com.ho.business.vo.req.StationReq;
import com.ho.business.vo.req.device.DeviceAddReq;
import com.ho.business.vo.req.device.DeviceIntervalReqVo;
import com.ho.business.vo.req.device.DeviceListReq;
import com.ho.business.vo.req.device.DeviceTreeReq;
import com.ho.business.vo.req.deviceModel.SynchronousReqVo;
import com.ho.business.vo.req.export.ExportReq;
import com.ho.business.vo.req.point.PointCurveReq;
import com.ho.business.vo.req.point.PointReqVO;
import com.ho.business.vo.resp.DeviceRespVO;
import com.ho.business.vo.resp.cabin.TemperatureVoltageResp;
import com.ho.business.vo.resp.chargepile.ChargePileRespVO;
import com.ho.business.vo.resp.point.BeforeSendOrderResp;
import com.ho.common.tools.entity.SimpleUser;
import com.ho.common.tools.util.PageResult;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;

/**
 * @author yule
 * @description 针对表【device】的数据库操作Service
 * @createDate 2022-08-25 16:11:14
 */
public interface DeviceService {

    PageResult<DeviceRespVO> getPageListByInfo(DeviceReqVO deviceReqVO);

    /**
     * 根据deviceType，返回同一类型的设备
     *
     * @param deviceReqVO
     * @return
     */
    List<DeviceRespVO> getListByDeviceType(DeviceReqVO deviceReqVO);

    List<DeviceRespVO> getListByInfo(List<String> deviceTypeList, DeviceReqVO deviceReqVO);

    List<DeviceRespVO> getList(DeviceReqVO deviceReqVO);

    //电站的设备类型
    List<DeviceRespVO> getListByDeviceType(Integer stationId, String deviceType);

    List<DeviceRespVO> getListByIdsAndDeviceType(List<Integer> stationIds, String deviceType);

    /**
     * 根据电站类型模糊去匹配
     * @param stationId
     * @param deviceType 设备类型前加"#"匹配
     * @return
     */
    List<DeviceRespVO> getListByFuzzyDeviceType(Integer stationId, String deviceType);

    List<DeviceRespVO> getListByDeviceTypeAndPid(Integer stationId, Integer pid, String deviceType);

    //入库新增
    int insertSelective(Device device);

    int insertBatch(DeviceAddReq adddevice);

    //修改充电桩
    int updateChargePile(Device device);

    int updateDevice(Device device);

    int update(Device device);

    int updateByStationId(Station station);

    void deleteById(Integer id);

    Device selectById(Integer id);


    List<ChargePileRespVO> selectBySrcIds(Integer stationId, List<Integer> srcIds);

    DeviceRespVO getDeviceRespVO(Integer id);

    //根据电站id和srcId查询
    Device selectByStationIdAndSrcId(Integer stationId, Integer srcId);

    Device selectByStationIdAndSrcIdAndLng(Integer stationId, Integer srcId,String lang);


    List<DeviceRespVO> selectByGroup(Integer groupId);

    List<String> selectDistinctDeviceTypeByStationId(Integer stationId);

    List<DeviceRespVO> getDeviceByStationId(Integer stationId,String lang);

    List<DeviceRespVO> getDeviceByStationIds(List<Integer> stationIds);

    List<DeviceRespVO> selectByIds(List<Integer> deviceIds);

    List<DeviceRespVO> selectByStation(Integer stationId);

    /**
     * 根据电站id和设备的pid查询设备
     *
     * @param stationId 电站id
     * @param pId       设备的父id
     * @return
     */
    List<DeviceRespVO> selectByStationIdAndPId(Integer stationId, Integer pId);

    /**
     * 判断设备是否在线
     *
     * @param device 设备
     * @return
     */
    boolean isOnLine(Device device);

    List<DeviceRespVO> getIntervalDevice(DeviceIntervalReqVo vo);

    /**
     * 根据电站id以及设备srcId查询设备
     *
     * @param map (k = 电站id,v = 设备srcId集合)
     * @return
     */
    List<DeviceRespVO> selectByStationIdAndSrcIds(Map<Integer, List<Integer>> map);

    List<Device> selectByStationIdAndSrcIdsVirtual(DeviceListReq deviceListReq);

    List<EventColReq> getQueryEventParam(DeviceListReq deviceListReq);

    /**
     * 根据电站id查询设备srcId不为0的
     *
     * @param stationId
     * @return
     */
    List<DeviceRespVO> selectByIdAndSrcIdNotZero(Integer stationId,String lang);

    /**
     * 查询设备需要设备接入点
     *
     * @param stationId
     * @return
     */
    List<DeviceRespVO> selectDeviceByStationId(Integer stationId,String lang);

    /**
     * 查询所有设备，不包含接入点
     *
     * @param stationId
     * @return
     */
    List<DeviceRespVO> selectAllDeviceAndSrcIdNotZero(Integer stationId,String lang);

    /**
     * 获取单个设备电压电流正太分布数据
     *
     * @return
     */
    TemperatureVoltageResp getTemperatureVoltageData(DeviceTreeReq vo);


    /**
     * 在命令下发前准备参数
     *
     * @param stationReq
     * @return
     */
    BeforeSendOrderResp beforeOrderSend(StationReq stationReq);

    List<Device> getRealDevice(Device device);

    void getSynchronousVD(SynchronousReqVo vo);

    List<DeviceRespVO> selectGroup(List<DeviceRespVO> deviceRespVOS);

    List<Device> selectBySelect(Device deviceValue);

    /**
     * 根据电站,获取所有电芯电压/温度分布
     * @param vo
     * @return
     */
    TemperatureVoltageResp getCellVoltageAndTemperature(DeviceTreeReq vo);

    /**
     * 根据电站,获取所有电芯电压/温度分布按编号排列
     * @param vo
     * @return
     */
    TemperatureVoltageResp getCellVoltageAndTemperatureNum(DeviceTreeReq vo);
    /**
     * 获取历史曲线查询的默认值(有功功率,soc等)
     * @param stationId
     * @return
     */
    PointCurveReq getDefaultValue(Integer stationId, SimpleUser user);

    List<OperatingStatistic> getOperatingStatistic(Integer stationId);

    List<OperatingStatistic> getOperatingStatistic2(Integer stationId);


    DeviceRespVO selectBySrcIdAndStationId(Integer stationId, Integer srcId);

    /**
     * 导出数据
     * @param vo
     * @return
     */
    void exportExcel(ExportReq vo, HttpServletResponse response);

    /**
     * 导入数据
     * @param file
     * @param type
     */
    void importExcel(MultipartFile file, Integer type);
}
