package com.zksy.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zksy.api.domain.WarningThreshold;
import com.zksy.api.mapper.WarningThresholdMapper;
import com.zksy.api.service.WarningThresholdService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【warning_threshold(预警阈值)】的数据库操作Service实现
* @createDate 2025-09-01 09:59:43
*/
@Service
public class WarningThresholdServiceImpl extends ServiceImpl<WarningThresholdMapper, WarningThreshold>
    implements WarningThresholdService{
    /**
     * 根据设备编号查询该设备所有预警值
     * device_code 字段支持多个设备编号，用逗号分隔
     */
    @Override
    public WarningThreshold getWarningThresholdByDeviceAndCode(String deviceCode, String warningCodes) {
        LambdaQueryWrapper<WarningThreshold> lambdaQueryWrapper = Wrappers.lambdaQuery(WarningThreshold.class)
                .apply("CONCAT(',', device_code, ',') LIKE CONCAT('%,', {0}, ',%')", deviceCode)
                .eq(WarningThreshold::getWarningCode,warningCodes);

        return baseMapper.selectOne(lambdaQueryWrapper);
    }
}




