package com.thinkunion.park.service.common.entity;

import com.thinkunion.park.service.common.constant.ParkingConstant;
import com.thinkunion.park.service.common.utils.JSONPrint;
import lombok.Data;
import lombok.experimental.Accessors;
import lombok.extern.slf4j.Slf4j;
import org.nest.springwrap.core.tool.utils.DateUtil;
import org.nest.springwrap.core.tool.utils.StringUtil;

import java.util.Date;

/**
 * @author 钱江
 * @description 车辆入场时获取的票根
 * @date 2022/10/1 下午8:18
 * @version 0.3.0
 */
@Data
@Accessors(chain = true)
@Slf4j
public class EnterPassTicket extends PassTicket {

    public EnterPassTicket() {
        super();
    }

    public EnterPassTicket(String plateNo, int passStatus, String passMessage, String monthlyCardLed, int billType) {
        super(plateNo, passStatus, passMessage, monthlyCardLed, billType);
    }

    public EnterPassTicket(String plateNo, int passStatus, String passMessage, String monthlyCardLed, Integer billType,
                           Integer subParkingType) {
        super(plateNo, passStatus, passMessage, monthlyCardLed, billType, subParkingType);
    }

    @Override
    public String getLan1() {
        if (this.isPassForbid()) {
            if (this.subParkingType != null && this.subParkingType == ParkingConstant.SubBillType.TeamTemporary) {
                return "团队车位已满";
            }
            if (this.billType != null && this.billType == ParkingConstant.BillType.SpcBlackListCar) {
                return "禁止放行,"+this.spcMessage;
            }

            return "禁止放行";
        }
        if(StringUtil.isNotBlank(this.spcMessage)){
            return  this.spcMessage;
        }
        return "欢迎光临";
    }

    @Override
    public String getLan2() {
        if (this.isAnonymous()) {
            return this.getPlateNoIfAnonymous();
        }
        return this.getPlateNo();
    }

    @Override
    public String getLan3() {
        if (this.isMonthlyCard()) {
            return this.getMonthlyCardLed();
        }
        return this.getPassMessage();
    }

    @Override
    public String getLan4() {
        return "时间: " + DateUtil.formatDateTime(new Date());
    }


    public void printSelf() {
        log.info("\n\n========================================================================生成入场票根 {} \n lan1 {} " +
                        "\n lan2 {} \n lan3 {} \n lan4 {} \n {} \n" +
                        "===================================================================================\n\n",
                this.getPlateNo(), this.getLan1(),
                this.getLan2(),
                this.getLan3(), this.getLan4(), JSONPrint.printObject(this));
    }

    @Override
    public String getVoiceContent() {
        String voiceContent = this.getPlateNo().concat("欢迎光临");
        if (this.isPassForbid()) {
            voiceContent = this.getPassMessage();
        }
        return voiceContent;
    }

    @Override
    public EnterPassTicket setPlateNo(String plateNo) {
        super.setPlateNo(plateNo);
        return this;
    }

    @Override
    public EnterPassTicket setPassStatus(Integer passStatus) {
        super.setPassStatus(passStatus);
        return this;
    }

    @Override
    public EnterPassTicket setPassMessage(String passMessage) {
        super.setPassMessage(passMessage);
        return this;
    }

    @Override
    public EnterPassTicket setMonthlyCardLed(String monthlyCardLed) {
        super.setMonthlyCardLed(monthlyCardLed);
        return this;
    }

    @Override
    public EnterPassTicket setBillType(Integer billType) {
        super.setBillType(billType);
        return this;
    }

    @Override
    public EnterPassTicket setSubParkingType(Integer subParkingType) {
        super.setSubParkingType(subParkingType);
        return this;
    }
}
