package com.kcim.dao.repository;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.kcim.common.constants.NumberConstant;
import com.kcim.dao.mapper.ComputeMedicalDepartmentProfitMapper;
import com.kcim.dao.model.ComputeMedicalDepartmentProfit;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @program: performance
 * @description:
 * @author: Wang.YS
 * @create: 2024-09-25 15:26
 **/
@Repository
public class ComputeMedicalDepartmentProfitRepository extends ServiceImpl<ComputeMedicalDepartmentProfitMapper, ComputeMedicalDepartmentProfit> {
    public List<ComputeMedicalDepartmentProfit> getByComputeDate(String computeDate, Long hospId, String reportType) {
        LambdaQueryWrapper<ComputeMedicalDepartmentProfit> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ComputeMedicalDepartmentProfit::getComputeDate, computeDate);
        queryWrapper.eq(ComputeMedicalDepartmentProfit::getHospId, hospId);
        queryWrapper.eq(ComputeMedicalDepartmentProfit::getReportType, reportType);

        return list(queryWrapper);

    }

    public List<ComputeMedicalDepartmentProfit> getByResponsibilityCode(String computeDate, Long hospId, String reportType, String responsibilityCode, Integer responsibilityType) {
        LambdaQueryWrapper<ComputeMedicalDepartmentProfit> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(ComputeMedicalDepartmentProfit::getComputeDate, computeDate);
        queryWrapper.eq(ComputeMedicalDepartmentProfit::getHospId, hospId);
        queryWrapper.eq(ComputeMedicalDepartmentProfit::getReportType, reportType);
        queryWrapper.eq(ComputeMedicalDepartmentProfit::getResponsibilityCode, responsibilityCode);
        if(responsibilityType.equals(NumberConstant.ZERO)){
            queryWrapper.eq(ComputeMedicalDepartmentProfit::getMedicalType, NumberConstant.ZERO);
        }
        return list(queryWrapper);
    }
}
