package com.xhpc.pp.logic;

import com.xhpc.common.enums.StationDeviceEnum;
import com.xhpc.pp.domain.XhpcDeviceMessage;
import com.xhpc.pp.mapper.XhpcDeviceMessageMapper;
import com.xhpc.pp.tx.ServiceParameter;
import com.xhpc.pp.tx.ServiceResult;
import com.xhpc.pp.tx.logic.ServiceLogic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Lazy
@Component("OfflineCardEraseReplyDataLogic")
public class OfflineCardEraseReplyDataLogic implements ServiceLogic {

    private static final Logger log = LoggerFactory.getLogger(OfflineCardEraseReplyDataLogic.class);

    @Resource
    XhpcDeviceMessageMapper deviceMessageMapper;


    @Override
    public ServiceResult service(ServiceParameter sp) throws Exception {

        //todo
        String remark = "充电桩下发离线卡数据清除";
        XhpcDeviceMessage deviceMessage = new XhpcDeviceMessage();
        deviceMessage.setType(StationDeviceEnum.PILE.getCode());
        deviceMessage.setSerialNumber(sp.getPileNo());
        deviceMessage.setRemark(remark);
        deviceMessage.setStatus(0);
        deviceMessage.setContent((String) sp.getParameters().get("hex"));
        deviceMessageMapper.insertByDomain(deviceMessage);
        return new ServiceResult(false);
    }

}
