package com.sptg.estate.biz.service.impl;

import com.baomidou.mybatisplus.enums.SqlLike;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.sptg.common.core.constant.OperationConstant;
import com.sptg.estate.api.entity.NoticePushDeviceDetails;
import com.sptg.estate.biz.mapper.NoticePushDeviceDetailsMapper;
import com.sptg.estate.biz.service.NoticePushDeviceDetailsServiceInterface;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * title: NoticePushDeviceDetailsServiceImpl
 * package: com.sptg.estate.biz.security.impl
 * description: 公告发布设备详细-服务层实现
 *
 *
 *
 */
@Service
public class NoticePushDeviceDetailsServiceImpl extends ServiceImpl<NoticePushDeviceDetailsMapper, NoticePushDeviceDetails> implements NoticePushDeviceDetailsServiceInterface {

    @Override
    public Page<NoticePushDeviceDetails> showNoticePushDeviceDetailsList(NoticePushDeviceDetails noticePushDeviceDetails) {
        Page<NoticePushDeviceDetails> page = noticePushDeviceDetails.getPage();
        EntityWrapper<NoticePushDeviceDetails> wrapper = new EntityWrapper<NoticePushDeviceDetails>();

        //发布状态
        Integer pushStatus = noticePushDeviceDetails.getPushStatus();
        String serialNumber = noticePushDeviceDetails.getSerialNumber();
        String deviceName = noticePushDeviceDetails.getDeviceName();
        String xqName = noticePushDeviceDetails.getXqName();
        String dyName = noticePushDeviceDetails.getDyName();
        String taskId = noticePushDeviceDetails.getPushId();

        if(StringUtils.hasText(taskId)){
            wrapper.eq("l_task_id", Long.parseLong(taskId));
        }
        if(pushStatus!=null){
            wrapper.eq("i_push_status", pushStatus);
        }
        if(StringUtils.hasText(serialNumber)){
            wrapper.eq("s_serial_number", serialNumber);
        }
        if(StringUtils.hasText(deviceName)){
            wrapper.eq("s_device_name", deviceName);
        }
        if(StringUtils.hasText(xqName)){
            wrapper.eq("s_xq_name", xqName);
        }
        if(StringUtils.hasText(dyName)){
            wrapper.eq("s_dy_name", dyName);
        }
        //分页查询
        List<NoticePushDeviceDetails> noticePushDeviceDetailsList = this.baseMapper.showNoticePushDeviceDetailsList(page, wrapper);
        page.setRecords(noticePushDeviceDetailsList);
        return page;
    }
}
