package com.ruoyi.bst.orderDevice.domain;

import java.math.BigDecimal;
import java.time.LocalDateTime;

import com.ruoyi.common.utils.MathUtils;
import com.ruoyi.iot.util.BatUtil;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

@Data
public class OrderDeviceVO extends OrderDevice{

    // 订单信息
    @ApiModelProperty("订单编号")
    private String orderNo;
    @ApiModelProperty("订单用户ID")
    private Long orderUserId;
    @ApiModelProperty("订单用户名称")
    private String orderUserName;
    @ApiModelProperty("订单开始时间")
    private LocalDateTime orderStartTime;
    @ApiModelProperty("订单结束时间")
    private LocalDateTime orderEndTime;
    @ApiModelProperty("订单最大可用时间")
    private LocalDateTime orderMaxTime;
    @ApiModelProperty("订单运营区ID")
    private Long orderAreaId;
    @ApiModelProperty("运营区是否开启还车审核")
    private Boolean orderAreaReturnVerify;

    // 设备信息
    @ApiModelProperty("设备电压")
    private BigDecimal deviceVoltage;
    @ApiModelProperty("设备在线状态")
    private String deviceOnlineStatus;
    @ApiModelProperty("设备经度")
    private BigDecimal deviceLongitude;
    @ApiModelProperty("设备纬度")
    private BigDecimal deviceLatitude;
    @ApiModelProperty("设备锁状态")
    private String deviceLockStatus;
    @ApiModelProperty("设备商户名称")
    private String deviceMchName;

    // 车型
    @ApiModelProperty("车型")
    private String deviceModelName;
    @ApiModelProperty("车型是否允许用户打开坐垫锁")
    private Boolean deviceModelEnableSeat;
    @ApiModelProperty("车型满电电压")
    private BigDecimal deviceModelFullVoltage;
    @ApiModelProperty("车型低电电压")
    private BigDecimal deviceModelLowVoltage;

    // 设备剩余续航（公里）
    public BigDecimal getDeviceRemainEndurance() {
        BigDecimal remainEndurance = MathUtils.mulDecimal(getDeviceRemainingPower(), getDeviceModelFullEndurance());
        return remainEndurance.divide(new BigDecimal(100), 2, BigDecimal.ROUND_HALF_UP);
    }

    public BigDecimal getDeviceRemainingPower() {
        return BatUtil.calcPowerPoint(deviceVoltage, deviceModelFullVoltage, deviceModelLowVoltage);
    }
}
