| | |
| | | } |
| | | |
| | | finalData.put("typeData", typeDataMap); |
| | | } else if (type.equals(6)) { |
| | | // 模块6统计数据 |
| | | if (criteria.getSignDate().isEmpty()) { |
| | | throw new BadRequestException("检索时间不存在"); |
| | | } |
| | | List<Map<String, Object>> incomeDataList = new ArrayList<>(); |
| | | BigDecimal totalRecoveryFund = new BigDecimal(0); |
| | | BigDecimal totalUnRecoveryFund = new BigDecimal(0); |
| | | |
| | | for (Long companyId : companyIds) { |
| | | Map<String, Object> incomeDataMap = new HashMap<>(); |
| | | |
| | | // 获取合同信息 |
| | | ContractQueryCriteria queryCriteria = new ContractQueryCriteria(); |
| | | queryCriteria.setCompanyId(companyId); |
| | | queryCriteria.setSignDate(criteria.getSignDate()); |
| | | queryCriteria.setRecoveryStatus(Constant.RECOVERY_STATUS_ABANDON); |
| | | List<Contract> contractList = contractRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,queryCriteria,criteriaBuilder)); |
| | | // 过滤收入合同(仅乙方) |
| | | List<Contract> incomeContractList = contractList.stream().filter(item -> ElAdminConstant.Enum.CompanySuffix.findByCompanyName(firstMap.get(item.getFirstId())) == null && ElAdminConstant.Enum.CompanySuffix.findByCompanyName(secondMap.get(item.getSecondId())) != null).collect(Collectors.toList()); |
| | | // 初始化统计参数 |
| | | BigDecimal recoveryFund = new BigDecimal(0); |
| | | BigDecimal unRecoveryFund = new BigDecimal(0); |
| | | |
| | | for (Contract incomeContract : incomeContractList) { |
| | | BigDecimal currentContractAmount = incomeContract.getContractAmount() != null ? incomeContract.getContractAmount() : new BigDecimal(0); |
| | | BigDecimal currentServiceAmount = incomeContract.getServiceAmount() != null ? incomeContract.getServiceAmount() : new BigDecimal(0); |
| | | |
| | | BigDecimal paidAmount = contractPaymentRepository.countTotalAmountByContractId(incomeContract.getContractId()); |
| | | paidAmount = paidAmount != null ? paidAmount : new BigDecimal(0); |
| | | BigDecimal unpaidAmount = currentContractAmount.add(currentServiceAmount).subtract(paidAmount); |
| | | |
| | | recoveryFund = recoveryFund.add(paidAmount); |
| | | unRecoveryFund = unRecoveryFund.add(unpaidAmount); |
| | | // 总额计算 |
| | | totalRecoveryFund = totalRecoveryFund.add(paidAmount); |
| | | totalUnRecoveryFund = totalUnRecoveryFund.add(unpaidAmount); |
| | | } |
| | | |
| | | // 保存数据 |
| | | incomeDataMap.put("companyName", companyMap.get(companyId)); |
| | | incomeDataMap.put("recoveryFund", recoveryFund); |
| | | incomeDataMap.put("unRecoveryFund", unRecoveryFund); |
| | | incomeDataList.add(incomeDataMap); |
| | | } |
| | | // 总计数据 |
| | | Map<String, Object> totalIncomeDataMap = new HashMap<>(); |
| | | totalIncomeDataMap.put("companyName", "总计"); |
| | | totalIncomeDataMap.put("recoveryFund", totalRecoveryFund); |
| | | totalIncomeDataMap.put("unRecoveryFund", totalUnRecoveryFund); |
| | | |
| | | finalData.put("total", totalIncomeDataMap); |
| | | finalData.put("income", incomeDataList); |
| | | } |
| | | |
| | | return finalData; |