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

import com.github.pagehelper.Page;
import com.github.pagehelper.page.PageMethod;
import net.northking.cctp.common.db.BasicDao;
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.common.saas.db.TenantEntityService;
import net.northking.cctp.executePlan.db.dao.AtuPlanInfoDao;
import net.northking.cctp.executePlan.db.entity.AtuPlanInfo;
import net.northking.cctp.executePlan.db.service.AtuPlanInfoService;
import net.northking.cctp.executePlan.dto.planInfo.AtuPlanInfoDetailDto;
import net.northking.cctp.executePlan.dto.planInfo.AtuPlanInfoPageDto;
import net.northking.cctp.executePlan.dto.planInfo.AtuPlanInfoQueryDto;
import net.northking.cctp.executePlan.dto.planInfo.AtuPlanPrincipalDto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 执行计划表
 *
 * <p>文件内容由代码生成器产生，请不要手动修改！ <br>
 * createdate:  2022-12-07 17:41:09  <br>
 * @author:  maven-cctp-plugin  <br>
 * @since:  1.0 <br>
 */
@Service
@ConditionalOnMissingBean(name = "AtuPlanInfoServiceImpl")
public class AtuPlanInfoServiceImpl extends TenantEntityService<AtuPlanInfo> implements AtuPlanInfoService
{
private static final Logger logger = LoggerFactory.getLogger(AtuPlanInfoServiceImpl.class);

  private final AtuPlanInfoDao atuPlanInfoDao;

  public AtuPlanInfoServiceImpl(AtuPlanInfoDao atuPlanInfoDao) {this.atuPlanInfoDao = atuPlanInfoDao;}

  @Override
  public BasicDao<AtuPlanInfo> getDao() {return atuPlanInfoDao;}

  @Override
  public AtuPlanInfo createEntity() { return new AtuPlanInfo();}

    @Override
    public AtuPlanInfo queryByLastBatchId(String batchId) {
        return atuPlanInfoDao.queryByLastBatchId(batchId);
    }

  @Override
  public List<AtuPlanInfo> queryPlanInfoByIds(List<String> objectIdsByNameAndType) {
    return this.atuPlanInfoDao.queryPlanInfoByIds(objectIdsByNameAndType);
  }

  @Override
    public List<String> queryFollowUpPlanIdList(String planId) {
        return atuPlanInfoDao.queryFollowUpPlanIdList(planId);
    }

  @Override
  public Pagination<AtuPlanInfoDetailDto> queryPlanInfoPage(QueryByPage<AtuPlanInfoQueryDto> queryByPage) {

    DefaultPagination<AtuPlanInfoDetailDto> pagination = new DefaultPagination<>();

    Page<AtuPlanInfoDetailDto> page = PageMethod.startPage(queryByPage.getPageNo(), queryByPage.getPageSize());
    List<AtuPlanInfoDetailDto> dtoList = atuPlanInfoDao.queryPageByPlan(queryByPage.getQuery());

    pagination.setRecordCount(page.getTotal());
    pagination.setPageNo(queryByPage.getPageNo());
    pagination.setPageSize(queryByPage.getPageSize());
    pagination.setRecords(dtoList);

    return pagination;
  }
  @Override
  public List<AtuPlanInfoDetailDto> queryPlanInfo(AtuPlanInfoQueryDto selectParamAtuPlanInfoQueryDto) {
    return atuPlanInfoDao.queryPageByPlan(selectParamAtuPlanInfoQueryDto);
  }

  @Override
  public void updatePrincipal(AtuPlanPrincipalDto dto) {
    atuPlanInfoDao.updatePrincipal(dto);
  }

  @Override
  public Pagination<AtuPlanInfoDetailDto> queryUpFrontPlan(QueryByPage<AtuPlanInfoPageDto> queryByPage) {
    DefaultPagination<AtuPlanInfoDetailDto> pagination = new DefaultPagination<>();
    Page<AtuPlanInfoDetailDto> page = PageMethod.startPage(queryByPage.getPageNo(), queryByPage.getPageSize());
    List<AtuPlanInfoDetailDto> pageList = atuPlanInfoDao.queryUpFrontPlan(queryByPage.getQuery());
    pagination.setRecordCount(page.getTotal());
    pagination.setPageNo(queryByPage.getPageNo());
    pagination.setPageSize(queryByPage.getPageSize());
    pagination.setRecords(pageList);
    return pagination;
  }

    @Override
    public List<AtuPlanInfo> queryByPage(int fromIndex, int toIndex) {
        return this.atuPlanInfoDao.queryByPage(fromIndex, toIndex);
    }

  @Override
  public Integer countdeleted(AtuPlanInfo countParams) {
    return atuPlanInfoDao.countDeleted(countParams);
  }

  @Override
  public Integer updatePlanRetryCount(AtuPlanInfo entity) {
    return this.atuPlanInfoDao.updatePlanRetryCount(entity);
  }

    @Override
    public List<String> selectManagerByProject(String projectId) {
        return this.atuPlanInfoDao.selectManagerByProject(projectId);
    }

    @Override
    public List<String> selectCreatorByProject(String projectId) {
      return this.atuPlanInfoDao.selectCreatorByProject(projectId);
    }

    @Override
    public List<String> selectUpdaterByProject(String projectId) {
      return this.atuPlanInfoDao.selectUpdaterByProject(projectId);
    }

  @Override
  public String clonePlanName(AtuPlanInfo atuPlanInfo) {
    return this.atuPlanInfoDao.clonePlanName(atuPlanInfo);
  }

  @Override
  public Integer updatePlanResultById(AtuPlanInfo atuPlanInfo) {
    return this.atuPlanInfoDao.updateByPrimaryKey(atuPlanInfo);
  }

  @Override
  public AtuPlanInfo findByBatchId(String batchId) {
    return this.atuPlanInfoDao.findByBatchId(batchId);
  }


  @Override
  public Integer updatePlanNextExecTime(AtuPlanInfo atuPlanInfo) {
    return this.atuPlanInfoDao.updatePlanNextExecTime(atuPlanInfo);
  }

  @Override
  public Integer updatePlanByLastBatchId(String batchId, String status) {
    return this.atuPlanInfoDao.updatePlanByLastBatchId(batchId, status);
  }

  @Override
  public void updatePlanByIds(List<String> ids) {
    atuPlanInfoDao.updatePlanByIds(ids);
  }

  @Override
  public Integer checkNameUnique(AtuPlanInfo info) {
    return atuPlanInfoDao.checkNameUnique(info);
  }

}

