package org.jeecg.modules.itdmGongDan.convert;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.itdmGongDan.entity.ItdmGongdanDetail;
import org.jeecg.modules.itdmGongDan.entity.ItdmGongdanMaster;
import org.jeecg.modules.itdmGongDan.entity.ItdmTestPlan;
import org.jeecg.modules.itdmGongDan.vo.DeviceCalendarDeviceListVO;
import org.jeecg.modules.itdmGongDan.vo.DeviceCalendarVO;
import org.jeecg.modules.itdmGongDan.vo.ItdmGongdanDetailListVO;
import org.jeecg.modules.weituo.entity.ItdmWeituoInfo;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.ReportingPolicy;
import org.mapstruct.factory.Mappers;
import org.springframework.util.CollectionUtils;

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

/**
 * 敏感词 Convert
 *
 * @author 永不言败
 */
@Mapper(unmappedTargetPolicy = ReportingPolicy.IGNORE,imports ={ CollectionUtils.class, Collectors.class})
public interface GongDanDetailConvert {

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

    ItdmGongdanDetailListVO convert(ItdmGongdanDetail convert);

    @Mapping(target ="records",source ="results" )
    Page<ItdmGongdanDetailListVO> converter(Page<ItdmGongdanDetail> page, List<ItdmGongdanDetailListVO> results);


    @Mapping(target ="id",source ="detail.id")
    @Mapping(target ="chuanganqi",source ="detail.chuanganqi")
    @Mapping(target ="testItemsId",source ="master.testItemsId")
    @Mapping(target ="weituoYangpinId",source ="master.weituoYangpinId")
    @Mapping(target ="shebeiId",source ="master.shebeiId")
    @Mapping(target ="createTime",source ="detail.createTime")
    @Mapping(target ="weituoClient",source ="itdmWeituoInfo.weituoClient")
    @Mapping(target ="weituoNo",source ="itdmWeituoInfo.weituoNo")
    @Mapping(target ="sampleModelSpecification",source ="sampleModelSpecification")
    ItdmGongdanDetailListVO toList(ItdmGongdanDetail detail, ItdmGongdanMaster master, ItdmTestPlan itdmTestPlan, ItdmWeituoInfo itdmWeituoInfo,String sampleModelSpecification);

    /**加上设备列表*/
    DeviceCalendarVO convertDeviceCalendarVO(Date workDate,List<DeviceCalendarDeviceListVO> deviceList);

    /**加上委托信息列表*/
    @Mapping(target ="weituoInfoList",source ="weituoInfoList")
    DeviceCalendarDeviceListVO convertWeituo(DeviceCalendarDeviceListVO vo, List<ItdmWeituoInfo> weituoInfoList);

}
