package com.gyee.runeconomy.service.auto.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.runeconomy.init.CacheContext;
import com.gyee.runeconomy.model.auto.ProBasicEquipment;
import com.gyee.runeconomy.model.auto.ProEconAlarmType;
import com.gyee.runeconomy.mapper.auto.ProEconAlarmTypeMapper;
import com.gyee.runeconomy.service.auto.IProEconAlarmTypeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 自定义类型 服务实现类
 * </p>
 *
 * @author wang
 * @since 2023-12-06
 */
@Service
public class ProEconAlarmTypeServiceImpl extends ServiceImpl<ProEconAlarmTypeMapper, ProEconAlarmType> implements IProEconAlarmTypeService {

    @Override
    public List<ProEconAlarmType> bylist(String wtid) {
        List<ProBasicEquipment> collect = CacheContext.wtls.stream().filter(wt -> wtid.equals(wt.getId())).collect(Collectors.toList());
        String model = "WT2000D121H85";
        if (collect != null || collect.size() > 0) {
            model = collect.get(0).getModelId();
        }
        QueryWrapper<ProEconAlarmType> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ProEconAlarmType::getCategory,model);
        List<ProEconAlarmType> proEconAlarmTypes = baseMapper.selectList(queryWrapper);
        return proEconAlarmTypes;
    }

    @Override
    public List<ProEconAlarmType> bylists(String model) {
        QueryWrapper<ProEconAlarmType> queryWrapper = new QueryWrapper<>();
        queryWrapper.lambda().eq(ProEconAlarmType::getCategory,model);
        List<ProEconAlarmType> proEconAlarmTypes = baseMapper.selectList(queryWrapper);
        return proEconAlarmTypes;
    }
}
