package com.kcim.dao.mapper;

import com.kcim.dao.model.IncomeCollection;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kcim.dao.model.dto.CollectDTO;
import com.kcim.vo.CodeAndNameVO;
import com.kcim.vo.CollectedVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.util.List;

/**
 * 归集后列表
 * 
 * @author huangrui
 * @date 2021-08-09 15:26:28
 */
@Mapper
public interface IncomeCollectionMapper extends BaseMapper<IncomeCollection> {

    /**
     * 分页List
     *
     * @param collectDTO {@link CollectDTO}
     * @return {@link CollectedVO}
     */
    List<CollectedVO> getCollectList(@Param("collectDTO") CollectDTO collectDTO);

    /**
     * 总数
     * @param collectDTO {@link CollectDTO}
     * @return
     */
    int getCollectListCount(@Param("collectDTO") CollectDTO collectDTO);

    /**
     * 计算总金额
     * @param collectDTO {@link CollectDTO}
     * @return
     */
    BigDecimal getTotalAmount(@Param("collectDTO") CollectDTO collectDTO);

    BigDecimal getShareLevelTotalAmount(@Param("collectDTO") CollectDTO collectDTO);

    BigDecimal getResponsibilityTotalAmount(@Param("collectDTO") CollectDTO collectDTO);

    /**
     * 纵向计算所有的amount
     * @param responsibilityCode
     * @param accountingCodes
     * @param hospId
     * @param date
     * @return
     */
    BigDecimal getCountByResponseAndAccounts(@Param("responsibilityCode") String responsibilityCode, @Param("accountingCodes") List<String> accountingCodes, @Param("hospId") Long hospId, @Param("date") String date);


    List<CodeAndNameVO> getResponsibility(@Param("hospId") Long hospId, @Param("responsibilityCode") String responsibilityCode, @Param("date") String date);

    List<CodeAndNameVO> getAccount(@Param("hospId") Long hospId, @Param("date") String date);

    BigDecimal getCountAccountAndResponsibilities(@Param("hospId") Long hospId, @Param("date") String date, @Param("code") String code, @Param("responsibilityCodes") List<String> responsibilityCodes);

    BigDecimal getCountByResponsibilitiesAndAccounts(@Param("responsibilityCodes") List<String> responsibilityCodes, @Param("accountingCodes") List<String> accountingCodes, @Param("hospId") Long hospId, @Param("date") String date);

    List<IncomeCollection> getResponsibilitiesAccounts(@Param("year") int year, @Param("month") int month, @Param("hospId") Long hospId);

}
