package com.zksy.info.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zksy.info.domain.EQuarterlyWaterUsage;
import com.zksy.info.service.EQuarterlyWaterUsageService;
import com.zksy.info.mapper.EQuarterlyWaterUsageMapper;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author Administrator
* @description 针对表【e_quarterly_water_usage(季度用水明细表（单位：吨）)】的数据库操作Service实现
* @createDate 2025-07-02 09:27:41
*/
@Service
public class EQuarterlyWaterUsageServiceImpl extends ServiceImpl<EQuarterlyWaterUsageMapper, EQuarterlyWaterUsage>
    implements EQuarterlyWaterUsageService{

    @Override
    public Page<EQuarterlyWaterUsage> findByPage(long pageNum, long pageSize, String unitName, String unifiedSocialCreditCode, String annual, String isCurrentlyInArrears) {
        Page<EQuarterlyWaterUsage> page = new Page<>(pageNum,pageSize);
        LambdaQueryWrapper<EQuarterlyWaterUsage> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(unitName != null,EQuarterlyWaterUsage::getUnitName,unitName);
        queryWrapper.like(unifiedSocialCreditCode != null,EQuarterlyWaterUsage::getUnifiedSocialCreditCode,unifiedSocialCreditCode);
        queryWrapper.like(annual != null,EQuarterlyWaterUsage::getAnnual,annual);
        queryWrapper.like(isCurrentlyInArrears != null,EQuarterlyWaterUsage::getIsCurrentlyInArrears,isCurrentlyInArrears);
        queryWrapper.orderByDesc(EQuarterlyWaterUsage::getUpdateTime);
        Page<EQuarterlyWaterUsage> page1 = this.page(page, queryWrapper);
        return page1;
    }

    @Override
    public List<EQuarterlyWaterUsage> getEQuarterlyWaterUsageList(String unitName, String unifiedSocialCreditCode, String annual, String isCurrentlyInArrears) {
        LambdaQueryWrapper<EQuarterlyWaterUsage> queryWrapper = new LambdaQueryWrapper();
        queryWrapper.like(unitName != null,EQuarterlyWaterUsage::getUnitName,unitName);
        queryWrapper.like(unifiedSocialCreditCode != null,EQuarterlyWaterUsage::getUnifiedSocialCreditCode,unifiedSocialCreditCode);
        queryWrapper.like(annual != null,EQuarterlyWaterUsage::getAnnual,annual);
        queryWrapper.like(isCurrentlyInArrears != null,EQuarterlyWaterUsage::getIsCurrentlyInArrears,isCurrentlyInArrears);
        queryWrapper.orderByDesc(EQuarterlyWaterUsage::getUpdateTime);
        List<EQuarterlyWaterUsage> list = this.list(queryWrapper);
        return list;
    }
}




