package com.xhpc.order.controller;

import com.xhpc.common.core.web.controller.BaseController;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.core.web.page.TableDataInfo;
import com.xhpc.order.service.IXhpcRealTimeOrderService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author yuyang
 * @date 2021/8/9 21:15
 */
@RestController
@RequestMapping("/realTimeOrder")
@Api(value = "实时订单接口", tags = "实时订单接口")
public class XhpcRealTimeOrderController extends BaseController {


    @Autowired
    private IXhpcRealTimeOrderService xhpcRealTimeOrderService;


    /**
     * 实时/异常订单接口（PC）
     * @param phone                       用户账号
     * @param transactionNumber           订单编号
     * @param source                      用户类型  0C端用户 1流量用户
     * @param chargingStationName         电站名称
     * @param terminalName                终端名称
     * @param operatorId                  运营商
     * @param startTime                   订单开始时间
     * @param endTime                     订单结束时间
     * @param status                      状态（-1准备充电 0开始充电 1自动结算，2异常，3平台结算）
     * @param userId                      用户id
     * @param type                        1 平台 2 运营商 3流量方
     * @param affiliationOrganization     归属机构(暂不查询)
     * @param plateNum                    车牌号
     * @param internetId                流量方名称
     * @param internetSerialNumber        流量方订单号
     * @return
     */
    @GetMapping("/list")
    public TableDataInfo list(String tenantId,Long chargingStationId,Long chargingPileId,Long terminalId, String phone,String transactionNumber,Integer source,String chargingStationName,String terminalName,Long operatorId,String startTime,String endTime,Integer status,Long userId, Integer type,
                             String affiliationOrganization,String plateNum,Integer internetId,String internetSerialNumber)
    {
        List<Map<String,Object>> list = xhpcRealTimeOrderService.list(tenantId,chargingStationId,chargingPileId,terminalId,phone, transactionNumber, source, chargingStationName,terminalName, operatorId, startTime, endTime,status,userId,type,affiliationOrganization,plateNum,internetId,internetSerialNumber);
        return getDataTable(list);
    }

    /**
     *   实时/异常订单详情（PC）
     */
    @GetMapping("/getMessage")
    public AjaxResult getMessage(Long realTimeOrderId,Long chargeOrderId)
    {
        return AjaxResult.success(xhpcRealTimeOrderService.getMessage(realTimeOrderId,chargeOrderId));

    }

    /**
     * 实时/异常订单详情数据列表（PC）
     * @param chargingOrderId
     * @return
     */
    @GetMapping("/timeList")
    public TableDataInfo timeList(@RequestParam Long chargingOrderId)
    {
        startPage();
        List<Map<String,Object>> list = xhpcRealTimeOrderService.timeList(chargingOrderId);
        return getDataTable(list);
    }

    @GetMapping("/timeBmsList")
    public TableDataInfo timeBmsList(@RequestParam Long chargingOrderId)
    {
        List<Map<String,Object>> list = xhpcRealTimeOrderService.timeBmsList(chargingOrderId);
        return getDataTable(list);
    }
//    /**
//     * 实时/异常订单详情数据图表（PC）
//     * @param chargingOrderId
//     * @return
//     */
//    @GetMapping("/timeChartList")
//    public AjaxResult timeChartList(@RequestParam Long chargingOrderId)
//    {
//        return xhpcRealTimeOrderService.timeChartList(chargingOrderId);
//    }

    /**
     * 实时/异常订单详情数据电压图表（PC）
     * @param chargingOrderId
     * @return
     */
    @GetMapping("/timeChartListVoltage")
    public AjaxResult timeChartListVoltage(@RequestParam Long chargingOrderId)
    {
        return xhpcRealTimeOrderService.timeChartListVoltage(chargingOrderId);
    }

    /**
     * 实时/异常订单详情数据电流图表（PC）
     * @param chargingOrderId
     * @return
     */
    @GetMapping("/timeChartListCurrent")
    public AjaxResult timeChartListCurrent(@RequestParam Long chargingOrderId)
    {
        return xhpcRealTimeOrderService.timeChartListCurrent(chargingOrderId);
    }
    /**
     * 实时/异常订单详情数据soc图表（PC）
     * @param chargingOrderId
     * @return
     */
    @GetMapping("/timeChartListSoc")
    public AjaxResult timeChartListSoc(@RequestParam Long chargingOrderId)
    {
        return xhpcRealTimeOrderService.timeChartListSoc(chargingOrderId);
    }


    /**
     *异常订单审核详情
     */
    @GetMapping("/getExamineMessage")
    public AjaxResult getExamineMessage(Long realTimeOrderId,Long chargeOrderId){
        return xhpcRealTimeOrderService.getExamineMessageYu(realTimeOrderId,chargeOrderId);
    }

    /**
     * 异常订单审核
     * @param chargingOrderId     订单id
     * @param powerPrice          电费
     * @param servicePrice        服务费
     * @return
     */
    @GetMapping("/getExamine")
    public AjaxResult getExamine(@RequestParam Long chargingOrderId,@RequestParam BigDecimal powerPrice,@RequestParam BigDecimal servicePrice,@RequestParam BigDecimal chargingDegree,@RequestParam String startTime ,@RequestParam String endTime){
        return xhpcRealTimeOrderService.getExamine(chargingOrderId,powerPrice,servicePrice,chargingDegree,startTime,endTime);
    }


    @GetMapping("/getExamineYu")
    public AjaxResult getExamineYu(){
        return xhpcRealTimeOrderService.getExamineYu();
    }
}
