package com.muyu.enterpise.service.impl.faultDetectionStrategy;


import com.muyu.domain.CarFaultRule;
import com.muyu.domain.FaultReport;
import com.muyu.enterpise.service.FaultDetectionStrategy;
import org.springframework.stereotype.Service;

/**
 * 针对纯电车的故障检测逻辑
 *  * @className: PureElectricCarFaultDetectionStrategy  ️✈️
 *  * @author: Yang 鹏  🦅
 *  * @date: 2024/9/23 22:06 ⏰
 *  * @Version: 1.0
 *  * @description:
 */
@Service(value = "PureElectricCar")
public class PureElectricCarFaultDetectionStrategy implements FaultDetectionStrategy {



    @Override
    public FaultReport detectFaults(CarFaultRule carFaultRule) {


        //检测车速是否处于正常范围
        if (carFaultRule.getSpeed()>200 || carFaultRule.getSpeed()<0){
            return new FaultReport("纯电车","车速不在正常范围内,请注意");
        }
        //检测总里程数是否超过正常数
        if (carFaultRule.getTM()>5000000){
            return new FaultReport("纯电车","总里程数已超标,请注意");
        }
        //检测总电压是否正常
        if (carFaultRule.getTV()>650){
            return new FaultReport("纯电车","总电压过高,请注意");
        }
        //检测电流是否超标
        if (carFaultRule.getCC()>50){
            return new FaultReport("纯电车","电流过高,请注意");
        }
        //检测绝缘电阻
        if (carFaultRule.getIR()>100000){
            return new FaultReport("纯电车","绝缘电阻过高,请注意");
        }
        return null;
    }
}
