package cn.iocoder.yudao.module.smartfactory.dal.mysql.factorydata;

import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factorydata.vo.FactoryDataDetailRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factorydata.vo.FactoryDataPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.factorydata.vo.FactoryDataTotalVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factorydata.FactoryDataDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDate;
import java.util.List;

/**
 * 工厂出库入库数据 Mapper
 *
 * @author 符溶馨
 */
@Mapper
public interface FactoryDataMapper extends BaseMapperX<FactoryDataDO> {

    IPage<FactoryDataDetailRespVO> selectDetailPage(@Param("page") IPage<FactoryDataDetailRespVO> mpPage, @Param("reqVO") FactoryDataPageReqVO pageReqVO);

    default FactoryDataDO selectListByType(Long factoryId, LocalDate date, Integer type) {

        return selectOne(new LambdaQueryWrapperX<FactoryDataDO>()
                .eq(FactoryDataDO::getFactoryId, factoryId)
                .eq(FactoryDataDO::getDate, date)
                .eq(FactoryDataDO::getDataType, type));
    }

    default List<FactoryDataDO> selectListByFactoryAndDate(Long factoryId, String date) {

        return selectList(new LambdaQueryWrapperX<FactoryDataDO>()
                .eq(FactoryDataDO::getFactoryId, factoryId)
                .eq(FactoryDataDO::getDate, date));
    }

    FactoryDataTotalVO selectDataSum();
}