package com.zd.netty.base;

import com.payne.reader.base.Consumer;
import com.payne.reader.bean.receive.InventoryTag;
import com.zd.netty.service.ISendService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @author Administrator
 */
@Slf4j
@Component
public class FridConsumer implements Consumer<InventoryTag> {

    @Autowired
    private ISendService sendService;

    @Override
    public void accept(InventoryTag tag) {
        try {
            tag.setEpc(tag.getEpc().replace(" ", ""));
            com.zd.system.api.domain.InventoryTag  inventoryTag = new com.zd.system.api.domain.InventoryTag ();
            BeanUtils.copyProperties(tag,inventoryTag);
            sendService.send(inventoryTag);
        } catch (BeansException e) {
            log.error(e.getMessage());
        }
    }
}
