/*
 * Author: Zev
 * 生成ServiceImpl
 */
package com.tofly.gpsboot.service.process.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.tofly.gpsboot.common.system.IsUseEnum;
import com.tofly.pojo.plan.vo.GpsdeviceVo;
import com.tofly.gpsboot.mapper.plan.GpsdeviceMapper;
import com.tofly.pojo.plan.Gpsdevice;
import com.tofly.gpsboot.service.process.GpsdeviceService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;


/**
 * 车载GPS设备信息表：TF_YWPN_GPSDEVICE_W
 *
 * @author admin
 * @date Thu Mar 18 00:00:00 CST 2021
 */
@Service("gpsdeviceService")
public class GpsdeviceServiceImpl extends ServiceImpl<GpsdeviceMapper, Gpsdevice> implements GpsdeviceService {

    @Override
    public List<GpsdeviceVo> viewConversion(List<Gpsdevice> infoList) {
        List<GpsdeviceVo> infoVoList = new ArrayList<>();
        infoList.forEach(info ->{
            GpsdeviceVo baseInfo = JSONObject.parseObject(JSON.toJSONString(info), GpsdeviceVo.class);
            baseInfo.setState(IsUseEnum.getCodeForValue(info.getState()));
            infoVoList.add(baseInfo);
        });

        return infoVoList;
    }
}
