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

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gyee.alarm.model.auto.ProBasicEquipment;
import com.gyee.alarm.model.auto.ProBasicEquipmentPoint;
import com.gyee.alarm.mapper.auto.ProBasicEquipmentPointMapper;
import com.gyee.alarm.model.auto.ProBasicProject;
import com.gyee.alarm.service.auto.IProBasicEquipmentPointService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gyee.common.model.StringUtils;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 设备测点 服务实现类
 * </p>
 *
 * @author shilin
 * @since 2022-10-31
 */
@Service
public class ProBasicEquipmentPointServiceImpl extends ServiceImpl<ProBasicEquipmentPointMapper, ProBasicEquipmentPoint> implements IProBasicEquipmentPointService {

    @Override
    public List<ProBasicEquipmentPoint> getPointListAI(String windturbineId, List<String> uniformcodeList_AI) {
        QueryWrapper<ProBasicEquipmentPoint> qw = new QueryWrapper<>();

        if (StringUtils.isNotEmpty(windturbineId)){
            qw.like("windturbine_id",windturbineId);
        }
        if (uniformcodeList_AI != null && !uniformcodeList_AI.isEmpty()) {
            qw.in("uniform_code", uniformcodeList_AI);
        }
            qw.ne("nem_code", "INITIAL");

        List<ProBasicEquipmentPoint> list = baseMapper.selectList(qw);
        return list;
    }

    @Override
    public List<ProBasicEquipmentPoint> getPointListDI(String windturbineId, List<String> uniformcodeList_AI) {
        QueryWrapper<ProBasicEquipmentPoint> qw = new QueryWrapper<>();

        if (StringUtils.isNotEmpty(windturbineId)){
            qw.like("windturbine_id",windturbineId);
        }
        if (uniformcodeList_AI != null && !uniformcodeList_AI.isEmpty()) {
            qw.in("uniform_code", uniformcodeList_AI);
        }
            qw.ne("nem_code", "INITIAL");

        List<ProBasicEquipmentPoint> list = baseMapper.selectList(qw);
        return list;
    }

    @Override
    public List<ProBasicEquipmentPoint> selectByStationAndModel(String stationStr, String modelId) {
        QueryWrapper<ProBasicEquipmentPoint> qw = new QueryWrapper<>();
        if (StringUtils.isNotEmpty(stationStr)) {
            qw.lambda().eq(ProBasicEquipmentPoint::getWindpowerstationId, stationStr);
        }
        if (StringUtils.isNotEmpty(modelId)) {
            qw.lambda().eq(ProBasicEquipmentPoint::getModelId, modelId);
        }
        List<ProBasicEquipmentPoint> list = baseMapper.selectList(qw);
        return list;
    }
}
