package com.gci.boot.modules.customer.service.impl;

import com.gci.boot.modules.customer.entity.TbInspectionTask;
import com.gci.boot.modules.customer.entity.TbInspectionTaskVehicle;
import com.gci.boot.modules.customer.mapper.TbInspectionTaskVehicleMapper;
import com.gci.boot.modules.customer.service.ITbInspectionTaskVehicleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 巡检任务关联车辆 服务实现类
 * </p>
 *
 * @author 2464
 * @since 2023-10-16
 */
@Service
public class TbInspectionTaskVehicleServiceImpl extends ServiceImpl<TbInspectionTaskVehicleMapper, TbInspectionTaskVehicle> implements ITbInspectionTaskVehicleService {
    @Override
    public void saveItem(TbInspectionTask check) {
		/*QueryWrapper<TbInspectionTaskVehicle> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("inspection_task_id", check.getId());
		remove(queryWrapper);*/
        if(check.getVehicles()==null||check.getVehicles().size()<1) {
            return;
        }
        List<TbInspectionTaskVehicle> projects = new ArrayList<>();
        for(TbInspectionTaskVehicle project:check.getVehicles()) {
            project.setId(null);
            project.setInspectionTaskId(check.getId());
            projects.add(project);
        }
        saveBatch(projects);
    }
}
