|
@@ -16,6 +16,7 @@ import com.imed.costaccount.model.vo.CostIncomeGroupBeforeVO;
|
|
|
import com.imed.costaccount.model.vo.IncomeErrorMessage;
|
|
|
import com.imed.costaccount.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
@@ -145,12 +146,12 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
log.info("读取的数据为:{}", list);
|
|
|
List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
|
|
|
//获取所有的科室 成本项目 责任中心 会计科目
|
|
|
- Map<String, Department> departmentMap = departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
|
|
|
- Map<String, Product> productMap = productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
|
|
|
- Map<Long, Responsibility> responsibilityMap = responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
|
|
|
- Map<Long, Accounting> accountingMap = accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
|
|
|
- List<ResponsibilityDepartment> responsibilityDepartmentList = responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
|
|
|
- .eq(ResponsibilityDepartment::getHospId, hospId));
|
|
|
+ //
|
|
|
+ Map<String, Department> departmentMap = getDepartmentByCodeNameMap(hospId);
|
|
|
+ Map<String, Product> productMap = getProductByCodeNameMap(hospId);
|
|
|
+ Map<Long, Responsibility> responsibilityMap = getLongResponsibilityMap(hospId);
|
|
|
+ Map<Long, Accounting> accountingMap = getLongAccountingMap(hospId);
|
|
|
+ List<ResponsibilityDepartment> responsibilityDepartmentList = getResponsibilityDepartments(hospId);
|
|
|
if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
|
|
|
throw new CostException(500, "没有科室责任中心对照数据");
|
|
|
}
|
|
@@ -158,8 +159,8 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
if (CollectionUtils.isEmpty(accountingProductList)) {
|
|
|
throw new CostException(500, "没有成本会计对照数据");
|
|
|
}
|
|
|
- Map<Long, Long> responsibilityDepMap = responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
|
|
|
- Map<Long, Long> accountProMap = accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
|
|
|
+ Map<Long, Long> responsibilityDepMap = getDepartmentIdResponsibilityIdMap(responsibilityDepartmentList);
|
|
|
+ Map<Long, Long> accountProMap = getProductIdAccountIdMap(accountingProductList);
|
|
|
List<CostIncomeGroup> costIncomeGroupArrayList = new ArrayList<>();
|
|
|
// 检验数据
|
|
|
checkImportData(list, incomeErrorMessageList, costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap,hospId,year,month);
|
|
@@ -183,6 +184,51 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
return Result.ok();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 返回成本会计对照数据 Key 成本项目Id Value 会计科目Id
|
|
|
+ * @param accountingProductList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @NotNull
|
|
|
+ private Map<Long, Long> getProductIdAccountIdMap(List<AccountingProduct> accountingProductList) {
|
|
|
+ return accountingProductList.stream().collect(Collectors.toMap(AccountingProduct::getProductId, AccountingProduct::getAccountingId));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ *
|
|
|
+ * @param responsibilityDepartmentList
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @NotNull
|
|
|
+ private Map<Long, Long> getDepartmentIdResponsibilityIdMap(List<ResponsibilityDepartment> responsibilityDepartmentList) {
|
|
|
+ return responsibilityDepartmentList.stream().collect(Collectors.toMap(ResponsibilityDepartment::getDepartmentId, ResponsibilityDepartment::getResponsibilityId));
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ResponsibilityDepartment> getResponsibilityDepartments(Long hospId) {
|
|
|
+ return responsibilityDepartmentService.list(new QueryWrapper<ResponsibilityDepartment>().lambda()
|
|
|
+ .eq(ResponsibilityDepartment::getHospId, hospId));
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private Map<Long, Accounting> getLongAccountingMap(Long hospId) {
|
|
|
+ return accountingService.list(new QueryWrapper<Accounting>().lambda().eq(Accounting::getHospId, hospId)).stream().collect(Collectors.toMap(Accounting::getId, synOe -> synOe));
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private Map<Long, Responsibility> getLongResponsibilityMap(Long hospId) {
|
|
|
+ return responsibilityService.list(new QueryWrapper<Responsibility>().lambda().eq(Responsibility::getHospId, hospId)).stream().collect(Collectors.toMap(Responsibility::getId, synOe -> synOe));
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private Map<String, Product> getProductByCodeNameMap(Long hospId) {
|
|
|
+ return productService.list(new QueryWrapper<Product>().lambda().eq(Product::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getProductCode() + k.getProductName(), synOe -> synOe));
|
|
|
+ }
|
|
|
+
|
|
|
+ @NotNull
|
|
|
+ private Map<String, Department> getDepartmentByCodeNameMap(Long hospId) {
|
|
|
+ return departmentService.list(new QueryWrapper<Department>().lambda().eq(Department::getHospId, hospId)).stream().collect(Collectors.toMap(k -> k.getDepartmentCode() + k.getDepartmentName(), synOe -> synOe));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 导入收入数据
|
|
|
*
|