|
@@ -129,7 +129,13 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
@Override
|
|
|
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
|
|
|
public Result importIncomeGroup(List<List<Object>> list, User user, MultipartFile file,Integer year,Integer month) {
|
|
|
+ // 先检验当前年月是否存在数据
|
|
|
Long hospId = user.getHospId();
|
|
|
+ List<CostIncomeGroup> groups = this.list(new QueryWrapper<CostIncomeGroup>().lambda().eq(CostIncomeGroup::getHospId, hospId)
|
|
|
+ .eq(CostIncomeGroup::getDateYear, year).eq(CostIncomeGroup::getDateMonth, month));
|
|
|
+ if (!CollectionUtils.isEmpty(groups)){
|
|
|
+ throw new CostException(500,year+"年"+month+"月数据已存在");
|
|
|
+ }
|
|
|
// 移除前几行的抬头内容 list的大小对应的就是行数的大小
|
|
|
for (int i = list.size() - 1; i >= 0; i--) {
|
|
|
if (i == NumberConstant.ZERO || i == NumberConstant.ONE || i == NumberConstant.TWO || i == NumberConstant.THREE) {
|
|
@@ -139,13 +145,21 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
log.info("读取的数据为:{}", list);
|
|
|
List<IncomeErrorMessage> incomeErrorMessageList = new ArrayList<>();
|
|
|
//获取所有的科室 成本项目 责任中心 会计科目
|
|
|
- GetCheckData getCheckData = new GetCheckData(hospId).invoke();
|
|
|
- Map<String, Department> departmentMap = getCheckData.getDepartmentMap();
|
|
|
- Map<String, Product> productMap = getCheckData.getProductMap();
|
|
|
- Map<Long, Responsibility> responsibilityMap = getCheckData.getResponsibilityMap();
|
|
|
- Map<Long, Accounting> accountingMap = getCheckData.getAccountingMap();
|
|
|
- Map<Long, Long> responsibilityDepMap = getCheckData.getResponsibilityDepMap();
|
|
|
- Map<Long, Long> accountProMap = getCheckData.getAccountProMap();
|
|
|
+ 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));
|
|
|
+ if (CollectionUtils.isEmpty(responsibilityDepartmentList)) {
|
|
|
+ throw new CostException(500, "没有科室责任中心对照数据");
|
|
|
+ }
|
|
|
+ List<AccountingProduct> accountingProductList = accountingProductService.list(new QueryWrapper<AccountingProduct>().lambda().eq(AccountingProduct::getHospId, hospId));
|
|
|
+ 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));
|
|
|
List<CostIncomeGroup> costIncomeGroupArrayList = new ArrayList<>();
|
|
|
// 检验数据
|
|
|
checkImportData(list, incomeErrorMessageList, costIncomeGroupArrayList, departmentMap, productMap, responsibilityMap, accountingMap, responsibilityDepMap, accountProMap,hospId,year,month);
|
|
@@ -205,7 +219,6 @@ public class CostIncomeGroupServiceImpl extends ServiceImpl<CostIncomeGroupMappe
|
|
|
IncomeErrorMessage incomeErrorMessage = new IncomeErrorMessage();
|
|
|
List<Object> data = list.get(i);
|
|
|
log.info("用户输入的数据是{}", data);
|
|
|
- // TODO 暂时不走循环 直接获取数据的处理
|
|
|
// 成本项目的代码和名称
|
|
|
String productCode = data.get(0).toString();
|
|
|
String productName = data.get(1).toString();
|