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

import com.hzbank.testteam.autotest.dependencies.baseDefineDependency.exception.InvalidException;
import net.northking.cctp.common.db.BasicDao;
import net.northking.cctp.common.db.PaginationService;
import net.northking.cctp.executePlan.db.dao.AtuPlanBatchDao;
import net.northking.cctp.executePlan.db.entity.AtuPlanBatch;
import net.northking.cctp.executePlan.db.service.AtuPlanBatchService;
import net.northking.cctp.executePlan.dto.planBatch.AtuPlanBatchDetailDto;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;


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

  private final AtuPlanBatchDao atuPlanBatchDao;

  public AtuPlanBatchServiceImpl(AtuPlanBatchDao atuPlanBatchDao) {this.atuPlanBatchDao = atuPlanBatchDao;}

  @Override
  public BasicDao<AtuPlanBatch> getDao() {return atuPlanBatchDao;}

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

  @Override
  protected void beforeInsert(AtuPlanBatch record) {

  }

  @Override
  protected void beforeUpdate(AtuPlanBatch record) {

  }

    @Override
    public List<AtuPlanBatch> queryPlanMaxBatchNumList(String endTime, int fromIndex, int toIndex) {
        return atuPlanBatchDao.queryPlanMaxBatchNumList(endTime, fromIndex, toIndex);
    }


    @Override
    public Integer updateByEntity(AtuPlanBatch entity) {
        return this.atuPlanBatchDao.updateByPrimaryKey(entity);
    }

    @Override
    public AtuPlanBatchDetailDto queryBatchDetailById(String batchId) {
        return this.atuPlanBatchDao.queryBatchDetailById(batchId);
    }

  @Override
  public int countPlanMaxBatch(String endTime) {
    return this.atuPlanBatchDao.countPlanMaxBatch(endTime);
  }

    @Override
    public List<AtuPlanBatch> queryNeedClearBatch(LocalDateTime localDateTime) {
        if (localDateTime == null) {
          throw new InvalidException("时间不能为空");
        }
        return this.atuPlanBatchDao.queryNeedClearBatch(localDateTime);
    }

  /**
   * 更新批次表附件清除字段
   *
   * @param batchIds 批次Ids
   */
  @Override
    public void updateAttachmentClearStatusByIds(List<String> batchIds) {
      if (CollectionUtils.isEmpty(batchIds)) {
        return;
      }
      this.atuPlanBatchDao.updateAttachmentClearStatusByIds(batchIds);
    }


}

