/*
 * Author: Zev
 * 生成ServiceImpl
 */
package com.tofly.gpsboot.service.trouble.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.tofly.pojo.trouble.vo.ToubleplanVo;
import com.tofly.gpsboot.mapper.trouble.ToubleplanMapper;
import com.tofly.gpsboot.service.trouble.ToubleplanService;
import com.tofly.pojo.plan.Plan;
import org.springframework.stereotype.Service;
import com.tofly.pojo.trouble.Toubleplan;

import java.util.List;


/**
 * 隐患巡查计划关联信息表
 *
 * @author admin
 * @date Thu Mar 18 00:00:00 CST 2021
 */
@Service("toubleplanService")
public class ToubleplanServiceImpl extends ServiceImpl<ToubleplanMapper, Toubleplan> implements ToubleplanService {

    @Override
    public void saveToublePlanRelation(List<Plan> planList,Long toubleId){
        planList.forEach(info ->{
            Toubleplan toubleplan = new Toubleplan();
            toubleplan.setPlanId(info.getId());
            toubleplan.setTroubleId(toubleId);
            this.save(toubleplan);
        });
    }

    @Override
    public List<ToubleplanVo> viewConversion(List<Toubleplan> infoList) {
        // 无转换类型
        return JSONArray.parseArray(JSON.toJSONString(infoList), ToubleplanVo.class);
    }
}
