package com.jwipc.order.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jwipc.order.entity.PurchaseOrderDetail;
import com.jwipc.order.mapper.PurchaseOrderDetailMapper;
import com.jwipc.order.model.po.PurchaseOrderDetailPO;
import com.jwipc.order.model.query.PurchaseOrderDetailQuery;
import com.jwipc.order.model.query.PurchaseOrderDetailsQuery;
import com.jwipc.order.service.IPurchaseOrderDetailService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import static com.baomidou.dynamic.datasource.support.DdConstants.SLAVE;

/**
 * <p>
 * 采购订单明细 服务实现类
 * </p>
 *
 * @author zhangjie
 * @since 2024-03-05
 */
@Service
@DS(SLAVE)
public class PurchaseOrderDetailServiceImpl extends ServiceImpl<PurchaseOrderDetailMapper, PurchaseOrderDetail> implements IPurchaseOrderDetailService {

    @Override
    public List<PurchaseOrderDetailPO> findList(Page<PurchaseOrderDetailPO> page, PurchaseOrderDetailQuery query) {
        return this.baseMapper.findList(page,query);
    }

    @Override
    public List<PurchaseOrderDetailPO> findDetails(Page<PurchaseOrderDetailPO> page, PurchaseOrderDetailsQuery query) {
        return this.baseMapper.findDetails(page,query);
    }

    @Override
    public List<PurchaseOrderDetailPO> findListUnlockForDeliveryCreate(List<String> ids) {
        return this.baseMapper.findListUnlockForDeliveryCreate(ids);
    }

    @Override
    public List<PurchaseOrderDetailPO> findList(PurchaseOrderDetailQuery query) {
        return this.baseMapper.findList(query);
    }

    @Override
    public PurchaseOrderDetail findForMark(Set<Integer> poStatus, String orderCode, String orderRow) {
        return this.baseMapper.findForMark(poStatus,orderCode,orderRow);
    }

    @Override
    public List<PurchaseOrderDetail> findForVerCount(String materialCode, Set<Integer> poStatus, String factoryCode) {
        return this.baseMapper.findForVerCount(materialCode,poStatus,factoryCode);
    }

    @Override
    public Long findCountForPage(PurchaseOrderDetailQuery query) {
        return this.baseMapper.findCountForPage(query);
    }

    @Override
    public List<PurchaseOrderDetail> getPurchaseOrderDetailListByList(List<PurchaseOrderDetail> query) {
        return baseMapper.getPurchaseOrderDetailListByList(query);
    }

    @Override
    public List<PurchaseOrderDetail> findByMaterialCodeAndFactoryWithStatus(String materialCode, String factory,
                                                                            ArrayList<Integer> status, int delFlag,String type)
    {
        return baseMapper.findByMaterialCodeAndFactoryWithStatus(materialCode,factory,status,delFlag,type);
    }

    /**
     * 查询模具产品关系表中的产品下单数量
     * @return
     */
    @Override
    public List<PurchaseOrderDetailPO> findNumByMaterialCodeList(){
        return baseMapper.findNumByMaterialCodeList();
    }
    /**
     * 查询模具产品关系表中的产品下单数量和
     * @return
     */
    @Override
    public List<PurchaseOrderDetailPO> findNumByMaterialCodeList1(String productCode){
        return baseMapper.findNumByMaterialCodeList1(productCode);
    }

    @Override
    public String getNewestForShortagePlan(String matnr, String werks) {
        return this.baseMapper.findNewestForShortagePlan(matnr,werks);
    }

    @Override
    public List<PurchaseOrderDetail> findBysupplierCodeAndFactoryCode(String supplierCode, String factoryCode,String orderCode) {
        return this.baseMapper.findBysupplierCodeAndFactoryCode(supplierCode,factoryCode,orderCode);
    }
}
