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

import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.handlinggroupuseramount.dto.StaffWagesPageDTO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.HandlingGroupUserAmountPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.handlinggroupuseramount.vo.StaffWagesPageVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.handlinggroupuseramount.HandlingGroupUserAmountDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

/**
 * 搬运组每日个人工资记录 Mapper
 *
 * @author 艾楷
 */
@Mapper
public interface HandlingGroupUserAmountMapper extends BaseMapperX<HandlingGroupUserAmountDO> {

    default PageResult<HandlingGroupUserAmountDO> selectPage(HandlingGroupUserAmountPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<HandlingGroupUserAmountDO>()
                .eqIfPresent(HandlingGroupUserAmountDO::getUserId, reqVO.getUserId())
                .eqIfPresent(HandlingGroupUserAmountDO::getDateStr, reqVO.getDateStr())
                .eqIfPresent(HandlingGroupUserAmountDO::getAmount, reqVO.getAmount())
                .betweenIfPresent(HandlingGroupUserAmountDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(HandlingGroupUserAmountDO::getId));
    }

    /**
     * @param page
     * @param vo
     * @return
     */
    IPage<HandlingGroupUserAmountDO> getHandlingGroupUserAmountPage(@Param("page") Page page, @Param("vo") HandlingGroupUserAmountPageReqVO vo);

    /**
     * 员工工资列表
     *
     * @param page
     * @param dto
     * @return
     */
    IPage<StaffWagesPageVO> staffWagesPage(@Param("page") Page page, @Param("dto") StaffWagesPageDTO dto);

    /**
     * 获取月工资列表
     *
     * @param factoryId
     * @param dateList
     * @param name
     * @return
     */
    List<Map<String, Object>> getListByMonth(@Param("id") Long id, @Param("factoryId") Long factoryId, @Param("dateList") List<String> dateList, @Param("name") String name);

    /**
     * 列表
     *
     * @param vo
     * @return
     */
    List<HandlingGroupUserAmountDO> getHandlingGroupUserAmountList(@Param("vo") HandlingGroupUserAmountPageReqVO vo);

    List<HandlingGroupUserAmountDO> getByHandlingGroupIds(@Param("handlingGroupIds") List<Long> handlingGroupIds);

    List<HandlingGroupUserAmountDO> selectAmountSum(@Param("factoryId") Long factoryId, @Param("month") String month);

    Long selectIsExists(@Param("factoryId") Long factoryId, @Param("month") String month);

    /**
     * 通过工厂列表ids 和日期列表 和 搬运组ids 获取
     *
     * @param factoryIds
     * @param dateStrList
     * @param handlingGroupIds
     * @return
     */
    List<HandlingGroupUserAmountDO> getByFactorIdAndDateStrAndHandlingGroupId(@Param("factoryIds") List<Long> factoryIds, @Param("dateStrList") List<String> dateStrList, @Param("handlingGroupIds") List<Long> handlingGroupIds);
}
