package com.xhpc.pp.logic;

import com.xhpc.mapper.XhpcMessageMapper;
import com.xhpc.pp.domain.XhpcMessage;
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.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;

import java.util.Map;

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

    private static final Logger log = LoggerFactory.getLogger(BmsInterruptDataLogic.class);
    @Autowired
    private XhpcMessageMapper xhpcMessageMapper;

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

        Map<String, Object> req = sp.getParameters();
        XhpcMessage msg = new XhpcMessage();
        msg.setContent((String) req.get("hex"));
        msg.setChargeOrderNo((String) req.get("orderNo"));
        msg.setRemark("充电桩与 BMS 充电阶段 BMS 中止报文");
        xhpcMessageMapper.insertItemsBy(msg);
        return new ServiceResult(false);
    }

}
