GetCheckData.java 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. package com.imed.costaccount.model;
  2. import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  3. import com.imed.costaccount.common.exception.CostException;
  4. import com.imed.costaccount.service.*;
  5. import io.swagger.annotations.ApiModel;
  6. import lombok.Data;
  7. import org.springframework.beans.factory.annotation.Autowired;
  8. import org.springframework.util.CollectionUtils;
  9. import java.util.List;
  10. import java.util.Map;
  11. import java.util.stream.Collectors;
  12. /**
  13. * @author 李加喜
  14. * @Package com.imed.costaccount.model
  15. * @date 2021-08-10 17:15
  16. */
  17. @Data
  18. @ApiModel("获取数据")
  19. public class GetCheckData {
  20. @Autowired
  21. private DepartmentService departmentService;
  22. @Autowired
  23. private ResponsibilityService responsibilityService;
  24. @Autowired
  25. private ProductService productService;
  26. @Autowired
  27. private AccountingService accountingService;
  28. @Autowired
  29. private ResponsibilityDepartmentService responsibilityDepartmentService;
  30. @Autowired
  31. private CostIncomeGroupSetService costIncomeGroupSetService;
  32. @Autowired
  33. private AccountingProductService accountingProductService;
  34. private Long hospId;
  35. private Map<String, Department> departmentMap;
  36. private Map<String, Product> productMap;
  37. private Map<Long, Responsibility> responsibilityMap;
  38. private Map<Long, Accounting> accountingMap;
  39. private Map<Long, Long> responsibilityDepMap;
  40. private Map<Long, Long> accountProMap;
  41. private Map<Integer, CostIncomeGroupSet> incomeGroupSetMap;
  42. public GetCheckData(Long hospId) {
  43. this.hospId = hospId;
  44. }
  45. /**
  46. * 根据科室Code+Name获取指定科室
  47. * @return
  48. */
  49. public Map<String, Department> getDepartmentMap() {
  50. return departmentMap;
  51. }
  52. /**
  53. * 根据Product的Code+name 获取product
  54. * @return
  55. */
  56. public Map<String, Product> getProductMap() {
  57. return productMap;
  58. }
  59. /**
  60. * 根据id获取责任中心
  61. * @return
  62. */
  63. public Map<Long, Responsibility> getResponsibilityMap() {
  64. return responsibilityMap;
  65. }
  66. /**
  67. * 根据id后去会计科目
  68. * @return
  69. */
  70. public Map<Long, Accounting> getAccountingMap() {
  71. return accountingMap;
  72. }
  73. /**
  74. * 根据科室的id获取责任中心的Id
  75. * @return
  76. */
  77. public Map<Long, Long> getResponsibilityDepMap() {
  78. return responsibilityDepMap;
  79. }
  80. /**
  81. * 根据成本项目id获取会计科目Id
  82. * @return
  83. */
  84. public Map<Long, Long> getAccountProMap() {
  85. return accountProMap;
  86. }
  87. public Map<Integer, CostIncomeGroupSet> getIncomeGroupSetMap() {
  88. return incomeGroupSetMap;
  89. }
  90. /**
  91. * 根据开单科室状态科执行科室状态返回设置数据
  92. * @return
  93. */
  94. public GetCheckData invoke() {
  95. departmentMap = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
  96. productMap = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
  97. responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
  98. accountingMap = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
  99. incomeGroupSetMap = costIncomeGroupSetService.list(new QueryWrapper<CostIncomeGroupSet>().lambda().eq(CostIncomeGroupSet::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getOpenDepartmentStatus() + k.getStartDepartmentStatus(), synOe -> synOe));
  100. List<ResponsibilityDepartment> responsibilityDepartmentList = responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
  101. .eq(ResponsibilityDepartment::getHospId, hospId));
  102. if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
  103. throw new CostException(500, "没有科室责任中心对照数据");
  104. }
  105. List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
  106. if (CollectionUtils.isEmpty(accountingProductList)) {
  107. throw new CostException(500, "没有成本会计对照数据");
  108. }
  109. responsibilityDepMap = responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
  110. accountProMap = accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
  111. return this;
  112. }
  113. }