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


import com.yuchen.saas.park.api.enums.AcidAssayResultEnum;
import com.yuchen.saas.park.api.enums.HealthCodeEnum;
import com.yuchen.saas.park.api.enums.TemperatureStatus;
import com.yuchen.saas.park.api.entity.park.ScanPrevention;
import com.yuchen.saas.park.api.vo.park.prevention.ScanPreventionVO;
import com.yuchen.saas.park.service.constant.TorchConstant;
import com.yuchen.saas.park.service.util.DateTimeUtils;
import org.nest.springwrap.core.mp.support.BaseEntityWrapper;

/**
 * @author 颜艺波
 * @date 2022/6/16 17:52
 * @Description
 */
public class ScanPreventionWrapper extends BaseEntityWrapper<ScanPrevention, ScanPreventionVO> {
    @Override
    public ScanPreventionVO entityVO(ScanPrevention entity) {
        ScanPreventionVO scanPreventionVO = new ScanPreventionVO();
        scanPreventionVO.setProductKey(entity.getProductKey());
        scanPreventionVO.setDeviceName(entity.getDeviceName());
        scanPreventionVO.setName(entity.getName());
        scanPreventionVO.setHealthCodeStatus(entity.getHealthCodeStatus());

        scanPreventionVO.setVaccineStatus(entity.getVaccineStatus());
        scanPreventionVO.setTravelCode(entity.getTravelCode());
        scanPreventionVO.setHealthCodeStatusDesc(HealthCodeEnum.getDescByCode(entity.getHealthCodeStatus()));
        scanPreventionVO.setInjectionTime(entity.getInjectionTime());
        scanPreventionVO.setInoculationLastTime(DateTimeUtils.timestampToDateTime(entity.getInoculationLastTime()));
        scanPreventionVO.setNucleicAcidAssayLastTime(DateTimeUtils.timestampToDateTime(entity.getNucleicAcidAssayLastTime()));
        scanPreventionVO.setNucleicAcidAssayResult(AcidAssayResultEnum.getDescByCode(entity.getNucleicAcidAssayResult()));
        scanPreventionVO.setParkId(entity.getParkId());
        scanPreventionVO.setPicUrl(entity.getPicUrl());
 /*       String time=String.valueOf(entity.getScanTime());
        Long time2=Long.valueOf(time.substring(0,10));
        System.out.println("time2"+time2);*/
        scanPreventionVO.setScanTime(DateTimeUtils.timestampToDateTime(entity.getScanTime()));
        scanPreventionVO.setTemperature(entity.getTemperature());
        if (entity.getTemperature() > Float.parseFloat(TorchConstant.TEMPERATURE)) {
            scanPreventionVO.setTemperatureStatus(TemperatureStatus.ABNORMAL.getCode());
            scanPreventionVO.setTemperatureStatusDesc(TemperatureStatus.ABNORMAL.getDescription());
        } else {
            scanPreventionVO.setTemperatureStatus(TemperatureStatus.NORMAL.getCode());
            scanPreventionVO.setTemperatureStatusDesc(TemperatureStatus.NORMAL.getDescription());
        }
        scanPreventionVO.setPassStatus(entity.getPassStatus());
      //  scanPreventionVO.setPassStatusDesc(PassEnum.getDescByCode(entity.getPassStatus()));
        return scanPreventionVO;
    }
}
