package com.yuchen.saas.park.service.service.impl;

import com.alibaba.fastjson.JSON;
import com.yuchen.saas.park.api.entity.device.PmgBatSmartEquipment;
import com.yuchen.saas.park.api.entity.park.PmgBatFaceCaptureEventData;
import com.yuchen.saas.park.service.mapper.FaceCaptureEventDataMapper;
import com.yuchen.saas.park.service.service.FaceCaptureService;
import com.yuchen.saas.parking.api.vo.IoTEvent;
import org.nest.springwrap.core.mp.base.BaseServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @ClassName FaceCaptureServiceImpl
 * @Description 人脸抓拍相关接口实现
 * @Author 张逸飞
 * @Date 2022/7/16 15:31
 */
@Service
public class FaceCaptureServiceImpl extends BaseServiceImpl<FaceCaptureEventDataMapper, PmgBatFaceCaptureEventData>
        implements FaceCaptureService {

    @Override
    public void inputEventData(PmgBatSmartEquipment pmgBatSmartEquipment, IoTEvent deviceEvent) {
        // 将事件内的数据转换为实体类
        PmgBatFaceCaptureEventData eventData = JSON.parseObject(JSON.toJSONString(deviceEvent.getOut()),
                PmgBatFaceCaptureEventData.class);
        eventData.setParkId(pmgBatSmartEquipment.getParkId());
        eventData.setCreateUser(pmgBatSmartEquipment.getCreateUser());
        eventData.setCreateDept(pmgBatSmartEquipment.getCreateDept());
        eventData.setTenantId(pmgBatSmartEquipment.getTenantId());
        save(eventData);
        // 推送前端
    }

}
