package com.jwipc.tender.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.common.collect.Lists;
import com.jwipc.security.dto.CurrentUserDTO;
import com.jwipc.tender.entity.ExpertManage;
import com.jwipc.tender.entity.PersonDimension;
import com.jwipc.tender.entity.QuotaManagement;
import com.jwipc.tender.mapper.QuotaManagementMapper;
import com.jwipc.tender.model.po.QuotaManagementPO;
import com.jwipc.tender.model.query.QuotaEditQuery;
import com.jwipc.tender.model.query.QuotaManagementQuery;
import com.jwipc.tender.service.IQuotaManagementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

/**
 * <p>
 * 供应商配额管理 服务实现类
 * </p>
 *
 * @author AL
 * @since 2024-03-02
 */
@Service
public class QuotaManagementServiceImpl extends ServiceImpl<QuotaManagementMapper, QuotaManagement> implements IQuotaManagementService {
    @Override
    public List<QuotaManagementPO> findByPage(Page<QuotaManagement> dbPage, QuotaManagementQuery query) {
        if (null != query) {
            if (null != query.getSyncStatus() && query.getSyncStatus() == -1) {
                query.setSyncStatus(null);
            }
            if (null != query.getAuditStatus() && query.getAuditStatus() == -1) {
                query.setAuditStatus(null);
            }
        }

        if (dbPage==null){
            return baseMapper.findByPage(query);
        }
        return baseMapper.findByPage(dbPage,query);

    }
    @Override
    public List<QuotaManagementPO> findByPageExport(Page<QuotaManagement> dbPage, QuotaManagementQuery query) {
        if (dbPage==null){
            return baseMapper.findByPage(query);
        }
        return baseMapper.findByPage(dbPage,query);

    }
    @Override
    public List<QuotaManagementPO> bidFindByPage(Page<QuotaManagement> dbPage, QuotaManagementQuery query) {

        if (dbPage==null){
            return baseMapper.bidFindByPage(query);
        }
        return baseMapper.bidFindByPage(dbPage,query);

    }
    @Override
    public List<QuotaManagementPO> editFindByPage(Page<QuotaManagement> dbPage, QuotaEditQuery query) {

        if (dbPage==null){
            return baseMapper.editFindByPage(query);
        }
        return baseMapper.editFindByPage(dbPage,query);

    }
    @Override
    public List<QuotaManagementPO> supplierFindByPage(Page<QuotaManagement> pageObj, QuotaEditQuery quotaAddQuery) {
        return baseMapper.supplierFindByPageForUpdate(quotaAddQuery);
    }


}
