package com.xhpc.order.mapper;

import com.xhpc.common.domain.XhpcBarrierGateRecord;
import com.xhpc.common.domain.XhpcChargingPile;
import com.xhpc.order.domain.*;
import com.xhpc.order.dto.*;
import org.apache.ibatis.annotations.Param;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @author yuyang
 * @date 2021/8/7 15:09
 */
public interface XhpcRealTimeOrderMapper {

    /**
     * 添加实时充电订单
     * @param xhpcRealTimeOrder
     * @return
     */
    int insertXhpcRealTimeOrder(XhpcRealTimeOrder xhpcRealTimeOrder);

    /**
     * 添加实时充电订单
     * @param xhpcRealTimeOrderBms
     * @return
     */
    int insertRealTimeOrderBms(XhpcRealTimeOrderBms xhpcRealTimeOrderBms);

    int insertOrderOutputMax(XhpcOrderOutputMax xhpcOrderOutputMax);


    /**
     * 添加订单实时SOC
     * @param xhpcChargeOrderSoc
     * @return
     */
    int insertSOC(XhpcChargeOrderSoc xhpcChargeOrderSoc);

    /**
     * 添加订单实时电流
     * @param XhpcChargeOrderCurrent
     * @return
     */
    int insertCurrent(XhpcChargeOrderCurrent XhpcChargeOrderCurrent);

    /**
     * 添加订单实时电压
     * @param xhpcChargeOrderVoltage
     * @return
     */
    int insertVoltage(XhpcChargeOrderVoltage xhpcChargeOrderVoltage);


    /**
     * 实时订单接口
     * @param phone                       用户账号
     * @param transactionNumber           订单编号
     * @param source                      用户类型  0C端用户 1流量用户
     * @param chargingStationName         电站名称
     * @param terminalName                终端名称
     * @param operatorId                  运营商
     * @param startTime                   订单开始时间
     * @param endTime                     订单结束时间
     * @param number                        0 都没有 1 phone 有  2 用户类型有  3 都有
     * @return
     */
    List<Map<String,Object>> list(@Param("chargingStationId")Long chargingStationId,@Param("chargingPileId")Long chargingPileId,@Param("terminalId")Long terminalId,@Param("phone") String phone,@Param("transactionNumber") String transactionNumber,@Param("source") Integer source,@Param("chargingStationName") String chargingStationName,@Param("terminalName")String terminalName,@Param("operatorId") Long operatorId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("number") Integer number,@Param("status")Integer status,@Param("userId")Long userId,@Param("type")Integer type,
                                  @Param("affiliationOrganization")String affiliationOrganization,@Param("plateNum")String plateNum,@Param("internetId")Integer internetId,@Param("internetSerialNumber")String internetSerialNumber,@Param("tenantId")String tenantId);

    /**
     * 实时订单详情接口(PC端)
     * @param realTimeOrderId
     * @return
     */
    Map<String,Object> getMessage(@Param("realTimeOrderId")Long realTimeOrderId);

    /**
     * 获取场站信息
     */
    Map<String,Object> getXhpcChargingStationById(Long chargingStationId);
    /**
     * 异常订单详情接口(PC端)
     * @param chargeOrderId
     * @return
     */
    Map<String,Object> getMessageChargeOrderId(@Param("chargeOrderId")Long chargeOrderId);


    /**
     * 实时订单详情数据列表（PC）
     * @param chargingOrderId
     * @return
     */
    List<Map<String,Object>> timeList(@Param("chargingOrderId")Long chargingOrderId);

    /**
     * 实时订单详情数据列表BMS（PC）
     * @param chargingOrderId
     * @return
     */
    List<Map<String,Object>> timeBmsList(@Param("chargingOrderId")Long chargingOrderId);

    /**
     * 实时订单详情数据图表SOC（PC）
     * @param chargingOrderId
     * @return
     */
    Map<String,Object> timeChartSOCList(Long chargingOrderId);

    /**
     * 实时订单详情数据图表电压（PC）
     * @param chargingOrderId
     * @return
     */
    Map<String,Object> timeChartVoltageList(Long chargingOrderId);

    /**
     * 实时订单详情数据图表电流（PC）
     * @param chargingOrderId
     * @return
     */
    Map<String,Object> timeChartCurrentList(Long chargingOrderId);

    /**
     * 删除之前的实时订单数据
     */
    void deleteRealTimeOrder(@Param("chargingOrderId")Long chargingOrderId);

    void deleteChargeVoltage(@Param("chargingOrderId")Long chargingOrderId);

    void deleteChargeOrderSoc(@Param("chargingOrderId")Long chargingOrderId);

    void deleteChargeOrderCurrent(@Param("chargingOrderId")Long chargingOrderId);

    /**
     * 获取一条实时数据
     */
    XhpcRealTimeOrder getChargingOrderId(@Param("chargingOrderId")Long chargingOrderId,@Param("type")Integer type);

    /**
     * 获取该时段的电量
     * @param
     * @return
     */
    double getRealTimeOrderTime(@Param("chargingOrderId")Long chargingOrderId,@Param("startTime") String startTime, @Param("endTime") String endTime);

    int getDifferenceTime(@Param("chargingOrderId")Long chargingOrderId,@Param("time") String time);

    double getChargingDegreeTime(@Param("chargingOrderId")Long chargingOrderId,@Param("time") String time);

    Map<String,Object> getChargeOrderById(@Param("chargingOrderId")Long chargingOrderId);


    /**
     * 根据第三方平台及监管平台的operatorId 查询
     * @param operatorIdEvcs
     * @return
     */
    Map<String, Object> getOperatorIdEvcs(String operatorIdEvcs);


    /**
     * 查询该时段的计费公式
     */
    List<XhpcActivityFormulaDomainDto> getActivityFormulaTime(@Param("activityId") Integer activityId, @Param("startTime") String startTime, @Param("endTime") String endTime);

    /**
     * 查询该时间段是否有流量方活动
     */
    List<XhpcActivityInternetDomainDto> getActivityStationTime(@Param("internetUserId")Long internetUserId, @Param("startTime")String startTime, @Param("endTime")String endTime, @Param("chargingStationId")Long chargingStationId, @Param("tenantId")String tenantId);


    /**
     * 查询开始时间是否在活动中
     */
    List<XhpcActivityDiscountDto> getActivityDiscountTime(@Param("internetUserId")Long internetUserId, @Param("startTime")String startTime, @Param("userType")Integer userType, @Param("chargingStationId")Long chargingStationId, @Param("tenantId")String tenantId);


    /**
     * 查询该时段的计费公式
     */
    List<XhpcActivityFormulaDomainDto>  getActivityFormulaById(@Param("activityId") Integer activityId);


    //获取场站的费率时段
    List<RateTime> getRateTimeList(@Param("chargingStationId")Long chargingStationId, @Param("rateModelId")Long rateModelId,@Param("rateValue") String rateValue);

    XhpcActivityFormulaDomainDto getActivityFormulaTimeById(@Param("activityId") Integer activityId,@Param("startTime") String startTime, @Param("endTime") String endTime);


    void deleteOrderCurrent(@Param("time")String time);

    void deleteOrderVoltage(@Param("time")String time);

    void deleteOrderSoc(@Param("time")String time);

    void deleteRealTimeOrderTime(@Param("time")String time);

    void deleteOorderRedisRecord(@Param("time")String time);

    void deleteRealTimeOrderBms(@Param("time")String time);


    //获取桩id
    XhpcChargingPile getSerialNumber(@Param("serialNumber")String serialNumber);

    void insertXhpcBarrierGateRecord(XhpcBarrierGateRecord xhpcBarrierGateRecord);


    //查询该场站是否有占位费设置
    Map<String, Object> getXhpcPlaceholder(@Param("chargingStationId")Long chargingStationId,@Param("internetUserId")String internetUserId,@Param("source")String source);


    List<XhpcRateTimeYuDto> getReatTimeList(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("rateModelId")Long rateModelId);


    int insertXhpcHistoryOrderChargeDetails(XhpcHistoryOrderChargeDetails xhpcHistoryOrderChargeDetails);


    List<XhpcHistoryOrder> getOrderMassageOrRateTime();
}
