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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.tofly.api.UserClent;
import com.tofly.gpsboot.common.Constant;
import com.tofly.gpsboot.mapper.plan.PlanInspectUserMapper;
import com.tofly.gpsboot.service.paln.task.PlanInspectUserService;
import com.tofly.pojo.User;
import com.tofly.pojo.plan.PlanInspectUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;


/**
 * 计划与巡检人关联表
 *
 * @author admin
 * @date Tue Mar 30 00:00:00 CST 2021
 */
@Service("planInspectUserService")
public class PlanInspectUserServiceImpl extends ServiceImpl<PlanInspectUserMapper, PlanInspectUser> implements PlanInspectUserService {


    @Autowired
    private PlanInspectUserMapper planInspectUserMapper;

    @Override
    public String getInspectUserList(Long planId) {
        StringBuffer str = new StringBuffer("");
        List<PlanInspectUser> inspectUserList = this.list(new QueryWrapper<PlanInspectUser>().lambda().eq(PlanInspectUser::getPlanId, planId));
        inspectUserList.forEach(info -> {
            if (null != info.getUserId()) {
                str.append(planInspectUserMapper.getUserName(info.getUserId())).append(Constant.CSV);
            }


        });
        if (StringUtils.isEmpty(str)) {
            return "";
        }
        return str.deleteCharAt(str.length() - 1).toString();
    }

    @Override
    public String getInspectUserIdList(Long planId) {
        StringBuffer str = new StringBuffer("");
        List<PlanInspectUser> inspectUserList = this.list(new QueryWrapper<PlanInspectUser>().lambda().eq(PlanInspectUser::getPlanId, planId));
        inspectUserList.forEach(info -> {
            if (null != info.getUserId()) {
                str.append(info.getUserId()).append(Constant.CSV);
            }


        });
        if (StringUtils.isEmpty(str)) {
            return "";
        }
        return str.deleteCharAt(str.length() - 1).toString();
    }
}
