package com.kcim.dao.repository; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.kcim.common.enums.DateStyleEnum; import com.kcim.common.util.DateUtils; import com.kcim.common.util.UserContext; import com.kcim.dao.mapper.CostDepartmentProfitMapper; import com.kcim.dao.model.CostDepartmentProfit; import org.springframework.stereotype.Repository; import java.util.Date; import java.util.List; /** * @program: CostAccount * @description: * @author: Wang.YS * @create: 2024-01-17 20:48 **/ @Repository public class CostDepartmentProfitRepository extends ServiceImpl { public List getByProfitIds(String computeDate, List profitId) { Date dateTime = DateUtils.StringToDate(computeDate, DateStyleEnum.YYYY_MM); int year = DateUtil.year(dateTime); int month = DateUtil.month(dateTime) + 1; LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(CostDepartmentProfit::getYear,year); queryWrapper.eq(CostDepartmentProfit::getMonth,month); queryWrapper.eq(CostDepartmentProfit::getHospId, UserContext.getHospId()); queryWrapper.in(CostDepartmentProfit::getReportId,profitId); return this.list(queryWrapper); } public List getCurrentByReportType(Integer year, Integer month, Long hospId, String reportType, String responsibilityCode) { LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(CostDepartmentProfit::getYear,year); queryWrapper.eq(CostDepartmentProfit::getMonth,month); queryWrapper.eq(CostDepartmentProfit::getHospId, hospId); queryWrapper.eq(CostDepartmentProfit::getShareType,Integer.valueOf(reportType)); queryWrapper.eq(CostDepartmentProfit::getResponsibilityCode, responsibilityCode); return this.list(queryWrapper); } /** * 获取科室损益数据 * @param computeDate * @return */ public List getDepartmentProfit(String computeDate) { Date dateTime = DateUtils.StringToDate(computeDate, DateStyleEnum.YYYY_MM); int year = DateUtil.year(dateTime); int month = DateUtil.month(dateTime) + 1; LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.eq(CostDepartmentProfit::getYear,year); queryWrapper.eq(CostDepartmentProfit::getMonth,month); queryWrapper.eq(CostDepartmentProfit::getHospId, UserContext.getHospId()); return this.list(queryWrapper); } public Integer getMaxYear(Long hospId) { return this.baseMapper.getMaxYear(hospId); } public Integer getMaxMonth(Long hospId,Integer year) { return this.baseMapper.getMaxMonth(hospId,year); } }