package com.cusc.nirvana.user.rnr.fp.converter;

import com.cusc.nirvana.user.rnr.fp.dto.FlowRnrInfoDTO;
import com.cusc.nirvana.user.rnr.fp.dto.FlowVehicleInfoDTO;
import com.cusc.nirvana.user.rnr.mg.dto.MgCardNoticeDTO;
import com.cusc.nirvana.user.rnr.mg.dto.OrgSimRelDTO;
import com.cusc.nirvana.user.util.CuscStringUtils;
import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers;

/**
 * Description: 联通切流转换器
 * <br />
 * CreateDate 2022-07-28 21:50:36
 *
 * @author yuyi
 **/
@Mapper
public interface CuFlowConverter {

    CuFlowConverter INSTANCE = Mappers.getMapper(CuFlowConverter.class);

    /**
     * Description: 从卡信息转为流量服务的车辆信息
     * <br />
     * CreateDate 2022-07-28 21:59:38
     *
     * @author yuyi
     **/
    default FlowVehicleInfoDTO vehicleFromOrgSim(OrgSimRelDTO orgSimRel) {
        FlowVehicleInfoDTO ret = new FlowVehicleInfoDTO();
        ret.setVehicleBrand(orgSimRel.getBrand());
        ret.setVehicleMode(orgSimRel.getVehicleModel());
        ret.setVehicleSerial(orgSimRel.getVehicleSeries());
        if(CuscStringUtils.isNotEmpty(orgSimRel.getInstallLocation())){
            ret.setSimPosition(Integer.parseInt(orgSimRel.getInstallLocation()));
        }
        return ret;
    }

    /**
     * Description: 从通知和车辆信息实例化 实名信息
     * <br />
     * CreateDate 2022-07-28 22:01:58
     *
     * @author yuyi
     **/
    default FlowRnrInfoDTO rnrFromCardNotice(MgCardNoticeDTO bean, FlowVehicleInfoDTO vehicleInfoDTO) {
        FlowRnrInfoDTO rnrInfo = new FlowRnrInfoDTO();
        rnrInfo.setVin(bean.getVin());
        rnrInfo.setIccid(bean.getIccid());
        rnrInfo.setVehicleInfo(vehicleInfoDTO);
        return rnrInfo;
    }
}
