package com.jwipc.order.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.jwipc.order.entity.BasicForcaseQuota;

import com.jwipc.order.mapper.BasicForcaseQuotaMapper;

import com.jwipc.order.model.po.BasicForcaseQuotaPO;
import com.jwipc.order.model.query.BasicForeignQuotaQuery;
import com.jwipc.order.model.query.BasicPlanQuery;

import com.jwipc.order.service.IBasicForcaseQuotaService;

import org.springframework.stereotype.Service;


import java.util.*;


/**
 * @Author: swq
 * @Date: 2024/3/14 11:24
 */
@Service
public class BasicForcaseQuotaServiceImpl extends ServiceImpl<BasicForcaseQuotaMapper, BasicForcaseQuota> implements IBasicForcaseQuotaService {

    /**
     * 查看所有数据
     *
     * @param pg     分页信息
     * @param query  查询参数
     * @param planId 计划ID
     * @param page   分页
     * @param limit  分页
     * @return 数据
     */
    @Override
    public List<BasicForcaseQuotaPO> getDateDataByPlanId(Page<BasicForcaseQuotaPO> pg, BasicPlanQuery query, Long planId, Integer page, Integer limit) {
        return this.baseMapper.getDateDataByPlanId(pg, query, planId, page, limit);
    }

    /**
     * 根据明细ID和供应商编码获取数据
     *
     * @param detailId     明细ID
     * @param supplierCode 供应商编码
     * @return 数据
     */
    @Override
    public List<BasicForcaseQuotaPO> getDataByDetailAndSupplier(Long detailId, String supplierCode) {
        return this.baseMapper.getDataByDetailAndSupplier(detailId, supplierCode);
    }

    /**
     * 获取供应商回复列表
     */
    @Override
    public List<BasicForcaseQuotaPO> findForPage(Page<BasicForcaseQuotaPO> toPage, BasicForeignQuotaQuery query, Long id) {
        if (null == toPage) {
            return this.baseMapper.selectForPage(query, id);
        }
        return this.baseMapper.selectForPage(toPage, query, id);
    }



    /**
     * 根据版本 获取回复数据
     *
     * @param version 版本
     * @return 回复数据
     */
    @Override
    public List<BasicForcaseQuotaPO> findReplyListByVersionId(Long version) {
        return this.baseMapper.findReplyListByVersionId(version);
    }



    /**
     * 根据计划获取供应商回复进度
     *
     * @param planId 计划ID
     */
    @Override
    public List<BasicForcaseQuotaPO> getSupplierReply(Long planId) {
        return this.baseMapper.getSupplierReply(planId);
    }

    @Override
    public List<BasicForcaseQuotaPO> bySupplierCodeGetReply(
            Long planId, String supplierCode,
            Long replyUserId, String isRiskMaterial,  String purchaseGroup,
            List<Long> detailIdList){
        List<BasicForcaseQuotaPO> replyDtoList = this.baseMapper.bySupplierCodeGetReply(planId, supplierCode, replyUserId, isRiskMaterial, purchaseGroup, null);
        return replyDtoList;
    }

    /**
     * 获取时间区间
     *
     * @param planId 计划ID
     * @return 区间
     */
    @Override

    public List<BasicForcaseQuotaPO> findDateInterval(Long planId){
        return this.baseMapper.findDateInterval(planId);
    }

}
