CostDepartmentProfitRepository.java 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. package com.kcim.dao.repository;
  2. import cn.hutool.core.date.DateUtil;
  3. import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4. import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5. import com.kcim.common.enums.DateStyleEnum;
  6. import com.kcim.common.util.DateUtils;
  7. import com.kcim.common.util.UserContext;
  8. import com.kcim.dao.mapper.CostDepartmentProfitMapper;
  9. import com.kcim.dao.model.CostDepartmentProfit;
  10. import org.springframework.stereotype.Repository;
  11. import java.util.Date;
  12. import java.util.List;
  13. /**
  14. * @program: CostAccount
  15. * @description:
  16. * @author: Wang.YS
  17. * @create: 2024-01-17 20:48
  18. **/
  19. @Repository
  20. public class CostDepartmentProfitRepository extends ServiceImpl<CostDepartmentProfitMapper, CostDepartmentProfit> {
  21. public List<CostDepartmentProfit> getByProfitIds(String computeDate, List<Long> profitId) {
  22. Date dateTime = DateUtils.StringToDate(computeDate, DateStyleEnum.YYYY_MM);
  23. int year = DateUtil.year(dateTime);
  24. int month = DateUtil.month(dateTime) + 1;
  25. LambdaQueryWrapper<CostDepartmentProfit> queryWrapper = new LambdaQueryWrapper<>();
  26. queryWrapper.eq(CostDepartmentProfit::getYear,year);
  27. queryWrapper.eq(CostDepartmentProfit::getMonth,month);
  28. queryWrapper.eq(CostDepartmentProfit::getHospId, UserContext.getHospId());
  29. queryWrapper.in(CostDepartmentProfit::getReportId,profitId);
  30. return this.list(queryWrapper);
  31. }
  32. public List<CostDepartmentProfit> getCurrentByReportType(Integer year, Integer month, Long hospId, String reportType, String responsibilityCode) {
  33. LambdaQueryWrapper<CostDepartmentProfit> queryWrapper = new LambdaQueryWrapper<>();
  34. queryWrapper.eq(CostDepartmentProfit::getYear,year);
  35. queryWrapper.eq(CostDepartmentProfit::getMonth,month);
  36. queryWrapper.eq(CostDepartmentProfit::getHospId, hospId);
  37. queryWrapper.eq(CostDepartmentProfit::getShareType,Integer.valueOf(reportType));
  38. queryWrapper.eq(CostDepartmentProfit::getResponsibilityCode, responsibilityCode);
  39. return this.list(queryWrapper);
  40. }
  41. /**
  42. * 获取科室损益数据
  43. * @param computeDate
  44. * @return
  45. */
  46. public List<CostDepartmentProfit> getDepartmentProfit(String computeDate) {
  47. Date dateTime = DateUtils.StringToDate(computeDate, DateStyleEnum.YYYY_MM);
  48. int year = DateUtil.year(dateTime);
  49. int month = DateUtil.month(dateTime) + 1;
  50. LambdaQueryWrapper<CostDepartmentProfit> queryWrapper = new LambdaQueryWrapper<>();
  51. queryWrapper.eq(CostDepartmentProfit::getYear,year);
  52. queryWrapper.eq(CostDepartmentProfit::getMonth,month);
  53. queryWrapper.eq(CostDepartmentProfit::getHospId, UserContext.getHospId());
  54. return this.list(queryWrapper);
  55. }
  56. public Integer getMaxYear(Long hospId) {
  57. return this.baseMapper.getMaxYear(hospId);
  58. }
  59. public Integer getMaxMonth(Long hospId,Integer year) {
  60. return this.baseMapper.getMaxMonth(hospId,year);
  61. }
  62. }