package org.jeecg.modules.largeScreen.convert;


import org.jeecg.modules.itdmDevice.entity.ItdmDevice;
import org.jeecg.modules.itdmDeviceRun.entity.ItdmDeviceRun;
import org.jeecg.modules.largeScreen.vo.ItdmDeviceRepairAlarmListVO;
import org.jeecg.modules.largeScreen.vo.ItdmDeviceWSVO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.springframework.util.CollectionUtils;
import org.mapstruct.factory.Mappers;

import java.util.Date;
import java.util.stream.Collectors;

@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE,imports ={ CollectionUtils.class, Collectors.class})
public interface ItdmDeviceConvert {

    ItdmDeviceConvert INSTANCE = Mappers.getMapper(ItdmDeviceConvert.class);

    ItdmDeviceWSVO convert(ItdmDevice convert);

    @Mapping(target = "deviceId",source = "itdmDevice.id")
    @Mapping(target = "day",source = "day")
    ItdmDeviceRepairAlarmListVO toList(ItdmDevice itdmDevice,Integer day);

    @Mapping(target = "deviceId",source = "deviceId")
    @Mapping(target = "deviceName",source = "deviceName")
    @Mapping(target = "deviceType",source = "deviceType")
    @Mapping(target = "timeBegin",source = "runStartTime")
    @Mapping(target = "timeEnd",source = "now")
    @Mapping(target = "timeDay",source = "d")
    @Mapping(target = "timeHour",source = "h")
    @Mapping(target = "timeMinute",source = "m")
    @Mapping(target = "timeSecond",source = "s")
    @Mapping(target = "timeRun",source = "timeRun")
    ItdmDeviceRun toItdmDeviceRun(String deviceId, String deviceName, String deviceType, Date runStartTime, Date now, Integer d, Integer h, Integer m, Integer s, String timeRun);

}
