|
@@ -1,6 +1,7 @@
|
|
|
package com.zksy.property.service.impl;
|
|
package com.zksy.property.service.impl;
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.zksy.property.domain.AReceiptInfo;
|
|
import com.zksy.property.domain.AReceiptInfo;
|
|
@@ -14,6 +15,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.time.LocalDate;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author Administrator
|
|
* @author Administrator
|
|
@@ -67,6 +72,83 @@ public class AReceiptInfoServiceImpl extends ServiceImpl<AReceiptInfoMapper, ARe
|
|
|
Page<AReceiptInfoVo> page = new Page<>(pageNum, pageSize);
|
|
Page<AReceiptInfoVo> page = new Page<>(pageNum, pageSize);
|
|
|
return areceiptInfoMapper.selectReceiptWithContractByPage(page, receiptNumber, payer, paymentMethod, contractNumber);
|
|
return areceiptInfoMapper.selectReceiptWithContractByPage(page, receiptNumber, payer, paymentMethod, contractNumber);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, BigDecimal> calculateMonthlyStatistics(int year) {
|
|
|
|
|
+ List<AReceiptInfo> receiptList = list(new QueryWrapper<AReceiptInfo>()
|
|
|
|
|
+ .ge("accounting_date", LocalDate.of(year, 1, 1))
|
|
|
|
|
+ .le("accounting_date", LocalDate.of(year, 12, 31)));
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, BigDecimal> monthlyData = new LinkedHashMap<>();
|
|
|
|
|
+ for (int month = 1; month <= 12; month++) {
|
|
|
|
|
+ monthlyData.put(String.format("%d-%02d", year, month), BigDecimal.ZERO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ // 统计数据
|
|
|
|
|
+ for (AReceiptInfo receipt : receiptList) {
|
|
|
|
|
+ if (receipt.getAccountingDate() != null && receipt.getTotalAmount() != null) {
|
|
|
|
|
+ String monthKey = String.format("%d-%02d",
|
|
|
|
|
+ year,
|
|
|
|
|
+ receipt.getAccountingDate().getMonthValue()
|
|
|
|
|
+ );
|
|
|
|
|
+ monthlyData.merge(monthKey, receipt.getTotalAmount(), BigDecimal::add);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return monthlyData;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, BigDecimal> calculateQuarterlyStatistics(int year) {
|
|
|
|
|
+ List<AReceiptInfo> receiptList = list(new QueryWrapper<AReceiptInfo>()
|
|
|
|
|
+ .ge("accounting_date", LocalDate.of(year, 1, 1))
|
|
|
|
|
+ .le("accounting_date", LocalDate.of(year, 12, 31)));
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, BigDecimal> quarterlyData = new TreeMap<>();
|
|
|
|
|
+ for (int quarter = 1; quarter <= 4; quarter++) {
|
|
|
|
|
+ quarterlyData.put(year + "Q" + quarter, BigDecimal.ZERO);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (AReceiptInfo receipt : receiptList) {
|
|
|
|
|
+ LocalDate date = receipt.getAccountingDate();
|
|
|
|
|
+ if (date != null && receipt.getTotalAmount() != null) {
|
|
|
|
|
+ int quarter = (date.getMonthValue() - 1) / 3 + 1;
|
|
|
|
|
+ String quarterKey = year + "Q" + quarter;
|
|
|
|
|
+ quarterlyData.merge(quarterKey, receipt.getTotalAmount(), BigDecimal::add);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return quarterlyData;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Map<String, BigDecimal> calculateYearlyStatistics() {
|
|
|
|
|
+ List<AReceiptInfo> receiptList = list();
|
|
|
|
|
+ Map<String, BigDecimal> yearlyData = new TreeMap<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (AReceiptInfo receipt : receiptList) {
|
|
|
|
|
+ LocalDate date = receipt.getAccountingDate();
|
|
|
|
|
+ if (date != null && receipt.getTotalAmount() != null) {
|
|
|
|
|
+ String yearKey = String.valueOf(date.getYear());
|
|
|
|
|
+ yearlyData.merge(yearKey, receipt.getTotalAmount(), BigDecimal::add);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return yearlyData;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<Integer> getExistingYears() {
|
|
|
|
|
+ List<AReceiptInfo> receiptList = list();
|
|
|
|
|
+
|
|
|
|
|
+ return receiptList.stream()
|
|
|
|
|
+ .map(AReceiptInfo::getAccountingDate)
|
|
|
|
|
+ .filter(Objects::nonNull)
|
|
|
|
|
+ .map(date -> date.getYear())
|
|
|
|
|
+ .distinct()
|
|
|
|
|
+ .sorted()
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|