/**
 * Copyright 2019 DH
 * All right reserved.
 * 项目名称: 大恒泰山系统
 * 创建日期:2022/8/28
 */
package org.springblade.modules.business.data.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.etl.entity.EtlRiverDataEntity;
import org.springblade.modules.business.data.dto.RtuDataRiverDTO;
import org.springblade.modules.business.data.entity.RtuDataRiverEntity;
import org.springblade.modules.business.data.mapper.RtuDataRiverMapper;
import org.springblade.modules.business.data.service.IRtuDataRiverService;
import org.springblade.modules.business.data.vo.RtuDataRiverVO;
import org.springframework.stereotype.Service;

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

/***
 * Date:2022/8/28
 * Title:文件所属模块（必须填写）
 * Description：对本文件的详细描述，原则上不能少于30字
 * @author dylan
 * @version 1.0
 * Remark：认为有必要的其他信息
 */
@Service
public class RtuDataRiverServiceImpl extends BaseServiceImpl<RtuDataRiverMapper, RtuDataRiverEntity> implements IRtuDataRiverService {
    @Override
    public IPage<RtuDataRiverVO> selectPage(IPage<RtuDataRiverVO> page, RtuDataRiverDTO rtuDataRiverDTO) {
        return page.setRecords(baseMapper.selectPage(page, rtuDataRiverDTO));
    }

    @Override
    public boolean updateRiverInfo(RtuDataRiverEntity entity) {
        LambdaQueryWrapper<RtuDataRiverEntity> dataWrapper = Wrappers.<RtuDataRiverEntity>query().lambda();
        dataWrapper.eq(RtuDataRiverEntity::getRtuCode, entity.getRtuCode());
        dataWrapper.eq(RtuDataRiverEntity::getIsDeleted, 0);
        RtuDataRiverEntity riverEntity = this.getOne(dataWrapper);
        if (null != riverEntity) {
            entity.setId(riverEntity.getId());
        }
        entity.setUpdateTime(new Date());
        return this.saveOrUpdate(entity);
    }

    @Override
    public IPage<RtuDataRiverVO> selectWaterPage(IPage<RtuDataRiverVO> page, RtuDataRiverDTO rtuDataRiverDTO) {
        return page.setRecords(baseMapper.selectWaterPage(page, rtuDataRiverDTO));
    }
}
