/*
* Copyright (c) 京北方信息技术股份有限公司 Corporation 2022 . All rights reserved.
*
*/
package net.northking.cctp.device.db.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import net.northking.cctp.common.db.DefaultPagination;
import net.northking.cctp.common.db.Pagination;
import net.northking.cctp.common.http.QueryByPage;
import net.northking.cctp.device.db.dao.CdEngineInfoDao;
import net.northking.cctp.device.db.service.CdEngineInfoService;
import net.northking.cctp.device.db.entity.CdEngineInfo;

import net.northking.cctp.common.db.BasicDao;
import net.northking.cctp.common.db.PaginationService;

import net.northking.cctp.device.dto.engineInfo.CdEngineInfoDetailDto;
import net.northking.cctp.device.dto.engineInfo.CdEngineInfoQueryDto;
import net.northking.cctp.device.dto.engineInfo.CdEngineInfoVersionDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * 执行引擎信息表
 *
 * <p>文件内容由代码生成器产生，请不要手动修改！ <br>
 * createdate:  2022-09-28 14:45:49  <br>
 * @author:  maven-cctp-plugin  <br>
 * @since:  1.0 <br>
 */
@Service
@ConditionalOnMissingBean(name = "CdEngineInfoServiceImpl")
public class CdEngineInfoServiceImpl extends PaginationService<CdEngineInfo> implements CdEngineInfoService
{
private static final Logger logger = LoggerFactory.getLogger(CdEngineInfoServiceImpl.class);

  private final CdEngineInfoDao cdEngineInfoDao;

  public CdEngineInfoServiceImpl(CdEngineInfoDao cdEngineInfoDao) {this.cdEngineInfoDao = cdEngineInfoDao;}

  public BasicDao<CdEngineInfo> getDao() {return cdEngineInfoDao;}

  public CdEngineInfo createEntity() { return new CdEngineInfo();}

  @Override
  public Pagination<CdEngineInfoDetailDto> queryPages(QueryByPage<CdEngineInfoQueryDto> dto) {
    DefaultPagination<CdEngineInfoDetailDto> pagination = new DefaultPagination<>();
    Page<CdEngineInfoDetailDto> page = PageMethod.startPage(dto.getPageNo(), dto.getPageSize());
    List<CdEngineInfoDetailDto> list = this.cdEngineInfoDao.queryPages(dto.getQuery());
    pagination.setPageNo(dto.getPageNo());
    pagination.setPageSize(dto.getPageSize());
    pagination.setRecords(list);
    pagination.setRecordCount(page.getTotal());
    return pagination;
  }

  @Override
  public Integer updateVersion(CdEngineInfoVersionDto dto) {
    Integer update = this.cdEngineInfoDao.updateVersion(dto);
    return update;
  }

  @Override
  public List<CdEngineInfo> queryEngineInfoNotIds(List<String> ids, int deviceNum,String ipAddr) {
    return this.cdEngineInfoDao.queryEngineInfoNotIds(deviceNum,ids,ipAddr);
  }

  @Override
  public List<CdEngineInfo> queryEngineOffLive() {
    return this.cdEngineInfoDao.queryEngineOffLive(new Date());
  }

  @Override
  public void updateEngineStatus(List<String> ids) {
    this.cdEngineInfoDao.updateEngineStatus(ids);
  }

  /**
   * 范围查询引擎，返回需要的数量
   *
   * @param pcDeviceIds
   * @param countNeed
   * @return
   */
  @Override
  public List<CdEngineInfo> queryNgInDeviceIds(List<String> pcDeviceIds, int countNeed) {
    return this.cdEngineInfoDao.queryNgInDeviceIds(pcDeviceIds, countNeed);
  }

  @Override
  public List<CdEngineInfo> queryUsableEngine(List<String> deviceIdList) {
    return this.cdEngineInfoDao.queryUsableEngine(deviceIdList);
  }

  @Override
  protected void beforeInsert(CdEngineInfo record) {

  }

  @Override
  protected void beforeUpdate(CdEngineInfo record) {

  }


// ----      The End by Generator     ----//




}

