package com.xhpc.order.service;

import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.order.domain.XhpcStatisticsStation;
import com.xhpc.order.domain.XhpcStatisticsTimeInterval;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author yuyang
 * @date 2021/8/31 16:21
 * @Version 1.0
 */
public interface IXhpcStatisticsService {

    /**
     * 小时统计
     * @param chargingStationIds         电站id集合
     * @param internetUserId      流量方id
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    List<Map<String, Object>> getTimeIntervalPage(HttpServletRequest request,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type);


    /**
     * 日期统计
     * @param chargingStationIds         电站id集合
     * @param internetUserId      流量方id
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    List<Map<String, Object>> getDateIntervalPage(HttpServletRequest request,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime);

    /**
     * 电站统计
     * @param chargingStationIds  电站集合
     * @param operatorIds        运营集合
     * @param internetUserId      流量方id
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    List<Map<String, Object>> getStationIntervalPage(HttpServletRequest request,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId,String chargingStationIds,String operatorIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime);

    /**
     * 运营商统计
     * @param operatorIds        运营商集合
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    List<Map<String, Object>> getOperatorIntervalPage(HttpServletRequest request,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId,String operatorIds,Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime);


    /**
     * 流量方统计
     * @param internetUserIds    流量方集合
     * @param internetUserId      流量方id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    List<Map<String, Object>> getInternetUserIntervalPage(HttpServletRequest request,String internetUserIds, Long internetUserId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime);


    /**
     * 终端统计
     * @param chargingStationId   电站id
     * @param terminalId          终端di
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    List<Map<String, Object>> getTerminalIntervalPage(HttpServletRequest request,String tenantId,Long chargingStationId, String terminalId, Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime);

    /**
     * 电站列表
     * @param operatorId      运营商id
     * @param userId          用户id
     * @param type            1 平台 2 运营商 3流量方
     * @return
     */
    AjaxResult getChargingStationList(HttpServletRequest request,String tenantId,Long operatorId,Long userId,Integer type);

    /**
     * 电桩列表
     * @param operatorId      运营商id
     * @param userId          用户id
     * @param type            1 平台 2 运营商 3流量方
     * @return
     */
    AjaxResult getChargingPileList(HttpServletRequest request,String tenantId,Long chargingStationId,Long operatorId,Long userId,Integer type,Integer display);

    /**
     * 运营商列表
     * @param operatorId      运营商id
     * @param userId          用户id
     * @param type            1 平台 2 运营商 3流量方
     * @return
     */
    AjaxResult getOperatorList(HttpServletRequest request,Long operatorId,Long userId,Integer type,String tenantId);


    AjaxResult getTenantList();

    /**
     * 流量方列表
     * @param internetUserId  流量方id
     * @param userId          用户id
     * @param type            1 平台 2 运营商 3流量方
     * @return
     */
    AjaxResult getInternetUserIList(HttpServletRequest request,Long internetUserId,Long userId,Integer type);


    /**
     * 终端列表
     * @param chargingStationId  电站id
     * @param userId          用户id
     * @param type            1 平台 2 运营商 3流量方
     * @return
     */
    AjaxResult getTerminalList(HttpServletRequest request,String tenantId,Long operatorId,Long chargingStationId,Long chargingPileId,Long userId,Integer type);

    /**
     * 订单来源列表
     * @param userId          用户id
     * @param type            1 平台 2 运营商 3流量方
     * @return
     */
    AjaxResult getSourceList(HttpServletRequest request,Long userId,Integer type);

    /**
     * 订单来源列表
     * @return
     */
    List<Map<String, Object>> getSumSourceList(HttpServletRequest request,String tenantId,Long operatorId,Long chargingStationId,Long chargingPileId,Long terminalId,String startTime, String endTime, String sourceIds, String chargingStationIds, String beginStartTime, String beginEndTime);


    /**
     * 机构统计
     * @param chargingStationIds         电站id集合
     * @param internetUserId      流量方id
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @param source           订单来源（0 C端用户 1 流量方用户 2社区用户 3B端用户）
     * @return
     */
    List<Map<String, Object>> getMechanismPage(HttpServletRequest request,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source);



    /**
     * 添加时段订单统计
     * @param xhpcStatisticsTimeInterval
     */
    void addStatisticsTime(XhpcStatisticsTimeInterval xhpcStatisticsTimeInterval);

    /**
     * 查询是否重复录入数据
     * @param historyOrderId
     * @return
     */
    int getStatisticsTimeHistoryOrderId(Long historyOrderId);
    /**
     * 添加订单统计
     *
     * @param xhpcStatisticsStation
     */
    void addStatisticsStation(XhpcStatisticsStation xhpcStatisticsStation);

    /**
     * 查询是否重复录入数据
     * @param historyOrderId
     * @param type
     * @return
     */
    int getStatisticsStationHistoryOrderId(Long historyOrderId,Integer type);

    // -------------------- 导出功能 ------------------


    /**
     * 小时统计导出
     * @param chargingStationIds         电站id集合
     * @param internetUserId      流量方id
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    void timeIntervalExport(HttpServletRequest request,HttpServletResponse response,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId, String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type) throws IOException;


    /**
     * 日期统计导出
     * @param chargingStationIds         电站id集合
     * @param internetUserId      流量方id
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    void dateIntervalExport(HttpServletRequest request,HttpServletResponse response,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId, String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime) throws IOException;

    /**
     * 电站统计导出
     * @param chargingStationIds  电站集合
     * @param operatorIds        运营集合
     * @param internetUserId      流量方id
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    void stationIntervalExport(HttpServletRequest request,HttpServletResponse response,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId, String chargingStationIds,String operatorIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime) throws IOException;

    /**
     * 运营商统计导出
     * @param operatorIds        运营商集合
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    void operatorIntervalExport(HttpServletRequest request,HttpServletResponse response,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId, String operatorIds,Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime) throws IOException;


    /**
     * 订单来源统计导出
     * @return
     */
    void getSumSourceListExport(HttpServletRequest request,HttpServletResponse response,String tenantId,Long operatorId,Long chargingStationId,Long chargingPileId,Long terminalId, String startTime, String endTime, String sourceIds,String chargingStationIds, String beginStartTime, String beginEndTime) throws IOException;


    /**
     * 终端统计导出
     * @param chargingStationId   电站id
     * @param terminalId          终端di
     * @param operatorId          运营商id
     * @param startTime           订单开始时间
     * @param endTime             订单结束时间
     * @param userId              用户id
     * @param type             1 平台 2 运营商 3流量方
     * @return
     */
    void terminalIntervalExport(HttpServletRequest request,HttpServletResponse response,String tenantId, Long chargingStationId, String terminalId, Long operatorId, String startTime, String endTime, Long userId, Integer type, String beginStartTime, String beginEndTime) throws IOException;

    void getMechanismExport(HttpServletRequest request,HttpServletResponse response,String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId,String chargingStationIds, Long internetUserId, Long operatorId, String startTime, String endTime, Long userId, Integer type,Integer source) throws IOException ;

    /**
     * 今日订单量
     */
    Map<String, Object> getToday(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type);
    /**
     * 今日订电量
     */
    Map<String, Object> getOrderElectricityQuantity(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type);
    /**
     * 今日营收
     */
    Map<String, Object> getTodayRrevenue(Long operatorId,Long chargingStationId,Long chargingPileId,Integer type);

    /**
     * 今日电枪实时状态
     */
    List<Map<String, Object>> getTodayTerminal(Long operatorId,Long chargingStationId,Long chargingPileId);

    /**
     * 充电数据
     *
     * @param state       1 充电数据  2.创建订单量
     */
    Map<String, Object> getDateOrder(Integer state,Long operatorId,Long chargingStationId,Long chargingPileId,Integer type,String startTime,String endTime);

    /**
     * 空订单统计
     */
    List<Map<String, Object>>  getEmptyOrder(Long chargingStationId,String startTime,String endTime);

    /**
     * 异常订单量列表统计
     */
    List<Map<String, Object>> getWorkHistoryOrderList(Long operatorId,Long chargingStationId,Long chargingPileId,Long terminalId,String stopReason,String startTime,String endTime,Integer type);

    /**
     * 工单类型统计
     * @return
     */
    List<Map<String, Object>> getWorkOrderNumber();


    List<Map<String, Object>> getChargeOrderFaultPage(HttpServletRequest request,Long chargingStationId,String serialNumber,String startTime, String endTime);


    void getChargeOrderFaultPageExport(HttpServletRequest request,HttpServletResponse response,Long chargingStationId,String serialNumber,String startTime, String endTime) throws IOException ;

    Map<String, Object> getHistoryOrderMassage(Long chargeOrderId);


    List<Map<String, Object>> getChargingPileStatusPage(HttpServletRequest request,String chargingStationId,String serialNumber,String statusName,String startTime, String endTime);



    void getChargingPileStatusPageExport(HttpServletRequest request,HttpServletResponse response,String chargingStationId,String serialNumber,String statusName,String startTime, String endTime) throws IOException ;

}
