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

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

import com.tofly.api.UserClent;
import com.tofly.gpsboot.common.system.IsTransferEnum;
import com.tofly.pojo.plan.vo.PlanchildVo;
import com.tofly.gpsboot.mapper.plan.PlanchildMapper;
import com.tofly.gpsboot.service.paln.task.PlanService;
import com.tofly.pojo.User;
import com.tofly.pojo.plan.Plan;
import com.tofly.pojo.plan.Planchild;
import com.tofly.gpsboot.service.paln.task.PlanchildService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;


/**
 * 巡检子计划信息表：TF_YWPN_PLANCHILD_W
 *
 * @author admin
 * @date Thu Mar 18 00:00:00 CST 2021
 */
@Service("planchildService")
public class PlanchildServiceImpl extends ServiceImpl<PlanchildMapper, Planchild> implements PlanchildService {


    @Override
    public void generatePlanChildList(Set<Long> userIdList, Long planId){
        List<Planchild> planChildList = new ArrayList<>();
        userIdList.forEach(user -> {
            // 则生成对应计划的子计划
            Planchild planchild = new Planchild();
            planchild.setPlanId(planId);
            planchild.setRespUser(user);
            planchild.setPlanState(IsTransferEnum.IS_TRANSFER_NORMAL.getCode());
            planChildList.add(planchild);
        });
        this.saveBatch(planChildList);
    }
}
