package com.ruoyi.bst.locationLog.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ruoyi.bst.device.domain.DeviceVO;
import com.ruoyi.bst.device.service.DeviceIotService;
import com.ruoyi.bst.device.service.DeviceService;
import com.ruoyi.bst.device.utils.DeviceUtil;
import com.ruoyi.bst.locationLog.domain.LocationLog;
import com.ruoyi.bst.locationLog.service.LocationLogConverter;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.iot.domain.IotDeviceSysInfo;
import com.ruoyi.iot.domain.ReceiveMsg;
import com.ruoyi.iot.service.IotConverter;
import com.ruoyi.iot.util.IotUtil;

@Service
public class LocationLogConverterImpl implements LocationLogConverter {

    @Autowired
    private DeviceService deviceService;

    @Autowired
    private DeviceIotService deviceIotService;

    @Autowired
    private IotConverter iotConverter;

    @Override
    public LocationLog toPo(DeviceVO device) {
        if (device == null || StringUtils.isBlank(device.getMac())) {
            return null;
        }

        // 转为定位日志
        LocationLog po = new LocationLog();
        po.setMac(device.getMac());
        po.setSn(device.getSn());
        po.setStatus(device.getStatus());
        po.setLockStatus(device.getLockStatus());
        po.setIotStatus(device.getIotStatus());
        po.setQuality(device.getQuality());
        po.setVoltage(device.getVoltage());
        po.setSignal(device.getSignalStrength());
        po.setSatellites(device.getSatellites());
        po.setLongitude(device.getLongitude());
        po.setLatitude(device.getLatitude());
        po.setAt(device.getLastLocationTime());
        po.setDeviceId(device.getId());
        po.setOrderId(device.getOrderId());
        return po;
    }

}
