package com.njcn.product.terminal.mysqlTerminal.service.impl;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.product.terminal.mysqlTerminal.mapper.DeptLineMapper;
import com.njcn.product.terminal.mysqlTerminal.pojo.dto.LineDevGetDTO;
import com.njcn.product.terminal.mysqlTerminal.pojo.po.DeptLine;
import com.njcn.product.terminal.mysqlTerminal.service.DeptLineService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author denghuajun
 * @date 2022/1/12 17:32
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DeptLineServiceImpl extends ServiceImpl<DeptLineMapper, DeptLine> implements DeptLineService {

    private final DeptLineMapper deptLineMapper;


    @Override
    public List<DeptLine> selectDeptBindLines(List<String> ids) {
        return this.lambdaQuery().in(DeptLine::getId, ids).list();
    }

    @Override
    public Map<String, List<LineDevGetDTO>> lineDevGet(List<Integer> devDataType, Integer type, Integer lineRunFlag) {
        List<LineDevGetDTO> deptLines = deptLineMapper.lineDevGet(devDataType, type, lineRunFlag);
        return deptLines.stream().collect(Collectors.groupingBy(LineDevGetDTO::getUnitId));
    }


}
