GetCheckData.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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 AccountingProductService accountingProductService;
  32. private Long hospId;
  33. private Map<String, Department> departmentMap;
  34. private Map<String, Product> productMap;
  35. private Map<Long, Responsibility> responsibilityMap;
  36. private Map<Long, Accounting> accountingMap;
  37. private Map<Long, Long> responsibilityDepMap;
  38. private Map<Long, Long> accountProMap;
  39. public GetCheckData(Long hospId) {
  40. this.hospId = hospId;
  41. }
  42. public Map<String, Department> getDepartmentMap() {
  43. return departmentMap;
  44. }
  45. public Map<String, Product> getProductMap() {
  46. return productMap;
  47. }
  48. public Map<Long, Responsibility> getResponsibilityMap() {
  49. return responsibilityMap;
  50. }
  51. public Map<Long, Accounting> getAccountingMap() {
  52. return accountingMap;
  53. }
  54. public Map<Long, Long> getResponsibilityDepMap() {
  55. return responsibilityDepMap;
  56. }
  57. public Map<Long, Long> getAccountProMap() {
  58. return accountProMap;
  59. }
  60. public GetCheckData invoke() {
  61. departmentMap = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
  62. productMap = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
  63. responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
  64. accountingMap = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
  65. List<ResponsibilityDepartment> responsibilityDepartmentList = responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
  66. .eq(ResponsibilityDepartment::getHospId, hospId));
  67. if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
  68. throw new CostException(500, "没有科室责任中心对照数据");
  69. }
  70. List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
  71. if (CollectionUtils.isEmpty(accountingProductList)) {
  72. throw new CostException(500, "没有成本会计对照数据");
  73. }
  74. responsibilityDepMap = responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
  75. accountProMap = accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
  76. return this;
  77. }
  78. }