package com.tofly.qualitycontrol.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.tofly.qualitycontrol.common.QualityControlConstant;
import com.tofly.qualitycontrol.entity.PlanProcess;
import com.tofly.qualitycontrol.mapper.PlanProcessMapper;
import com.tofly.qualitycontrol.service.IPlanProcessService;
import com.tofly.qualitycontrol.vo.PlanAuditHistoryVO;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

import static com.tofly.qualitycontrol.util.QualityControlUtil.getVO;

/**
 * @author B
 */
@Service
@RequiredArgsConstructor
public class PlanProcessServiceImpl extends ServiceImpl<PlanProcessMapper,PlanProcess> implements IPlanProcessService, QualityControlConstant {

	@Override
	public List<PlanAuditHistoryVO> getHistoryList(Long id) {
		List<PlanProcess> list = baseMapper.loadToExamineInfo(id);
		List<PlanAuditHistoryVO> voList = Lists.newArrayList();

		if (CollectionUtils.isNotEmpty(list)) {
			list.forEach(l -> voList.add(getVO(l,PlanAuditHistoryVO.class)));
		}
		return voList;
	}

}
