|
@@ -1,5 +1,6 @@
|
|
|
package com.sckw.payment.service;
|
|
package com.sckw.payment.service;
|
|
|
|
|
|
|
|
|
|
+import com.sckw.core.common.enums.NumberConstant;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.payment.model.vo.SettlementRecord;
|
|
import com.sckw.payment.model.vo.SettlementRecord;
|
|
|
import com.sckw.payment.model.vo.req.FinanceCount;
|
|
import com.sckw.payment.model.vo.req.FinanceCount;
|
|
@@ -14,8 +15,8 @@ import org.springframework.stereotype.Service;
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
import java.text.DecimalFormat;
|
|
import java.text.DecimalFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -30,6 +31,35 @@ public class WorkbenchService {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private KwpSettlementRecordService kwpSettlementRecordService;
|
|
private KwpSettlementRecordService kwpSettlementRecordService;
|
|
|
|
|
+ private final Map<String, Function<SettlementRecord, String>> map = new HashMap<>(NumberConstant.FOUR);
|
|
|
|
|
+
|
|
|
|
|
+ public WorkbenchService() {
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
+ map.put("1", (d) -> {
|
|
|
|
|
+ if (Objects.isNull(d.getReceivedMoney())) {
|
|
|
|
|
+ return "0.00";
|
|
|
|
|
+ }
|
|
|
|
|
+ return df.format(d.getReceivedMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP));
|
|
|
|
|
+ });
|
|
|
|
|
+ map.put("2", (d) -> {
|
|
|
|
|
+ if (Objects.isNull(d.getExactMoney())) {
|
|
|
|
|
+ return "0.00";
|
|
|
|
|
+ }
|
|
|
|
|
+ return df.format(d.getExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP));
|
|
|
|
|
+ });
|
|
|
|
|
+ map.put("3", (d) -> {
|
|
|
|
|
+ if (Objects.isNull(d.getOverdueExactMoney())) {
|
|
|
|
|
+ return "0.00";
|
|
|
|
|
+ }
|
|
|
|
|
+ return df.format(d.getOverdueExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP));
|
|
|
|
|
+ });
|
|
|
|
|
+ map.put("4", (d) -> {
|
|
|
|
|
+ BigDecimal overdueExactMoney = d.getOverdueExactMoney();
|
|
|
|
|
+ //总应收金额
|
|
|
|
|
+ BigDecimal totalReceiveMoney = d.getTotalReceiveMoney();
|
|
|
|
|
+ return DecimalUtils.financePercent(overdueExactMoney, totalReceiveMoney);
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
public Object financeCount(FinanceCount financeCount) {
|
|
public Object financeCount(FinanceCount financeCount) {
|
|
|
//周期维度 1-天 2-周 3-月
|
|
//周期维度 1-天 2-周 3-月
|
|
@@ -59,48 +89,13 @@ public class WorkbenchService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
- DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
//获取数据,按照统计因子进行处理,并转换成万元
|
|
//获取数据,按照统计因子进行处理,并转换成万元
|
|
|
List<SettlementRecord> settlementRecords = kwpSettlementRecordService.financeCount(time, entId, circle);
|
|
List<SettlementRecord> settlementRecords = kwpSettlementRecordService.financeCount(time, entId, circle);
|
|
|
return settlementRecords.stream().map(a -> {
|
|
return settlementRecords.stream().map(a -> {
|
|
|
EChartsVo eChartsVo = new EChartsVo();
|
|
EChartsVo eChartsVo = new EChartsVo();
|
|
|
eChartsVo.setCreateTime(a.getCreateTime());
|
|
eChartsVo.setCreateTime(a.getCreateTime());
|
|
|
- switch (financeCount.getFactorOne()) {
|
|
|
|
|
- case "1" ->
|
|
|
|
|
- eChartsVo.setFactorOne(df.format(a.getReceivedMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
|
|
|
|
|
- case "2" ->
|
|
|
|
|
- eChartsVo.setFactorOne(df.format(a.getExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
|
|
|
|
|
- case "3" ->
|
|
|
|
|
- eChartsVo.setFactorOne(df.format(a.getOverdueExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
|
|
|
|
|
- case "4" -> {
|
|
|
|
|
- BigDecimal overdueExactMoney = a.getOverdueExactMoney();
|
|
|
|
|
- //总应收金额
|
|
|
|
|
- BigDecimal totalReceiveMoney = a.getTotalReceiveMoney();
|
|
|
|
|
- if (totalReceiveMoney.compareTo(new BigDecimal("0.0")) <= 0) {
|
|
|
|
|
- eChartsVo.setFactorOne("0.00%");
|
|
|
|
|
- } else {
|
|
|
|
|
- eChartsVo.setFactorOne(DecimalUtils.financePercent(overdueExactMoney, totalReceiveMoney));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- switch (financeCount.getFactorTwo()) {
|
|
|
|
|
- case "1" ->
|
|
|
|
|
- eChartsVo.setFactorTwo(df.format(a.getReceivedMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
|
|
|
|
|
- case "2" ->
|
|
|
|
|
- eChartsVo.setFactorTwo(df.format(a.getExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
|
|
|
|
|
- case "3" ->
|
|
|
|
|
- eChartsVo.setFactorTwo(df.format(a.getOverdueExactMoney().divide(new BigDecimal("10000.0"), 2, RoundingMode.HALF_UP)));
|
|
|
|
|
- case "4" ->{
|
|
|
|
|
- BigDecimal overdueExactMoney = a.getOverdueExactMoney();
|
|
|
|
|
- //总应收金额
|
|
|
|
|
- BigDecimal totalReceiveMoney = a.getTotalReceiveMoney();
|
|
|
|
|
- if (totalReceiveMoney.compareTo(new BigDecimal("0.0")) <= 0) {
|
|
|
|
|
- eChartsVo.setFactorTwo("0.00%");
|
|
|
|
|
- } else {
|
|
|
|
|
- eChartsVo.setFactorTwo(DecimalUtils.financePercent(overdueExactMoney, totalReceiveMoney));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ eChartsVo.setFactorOne(map.get(financeCount.getFactorOne()).apply(a));
|
|
|
|
|
+ eChartsVo.setFactorTwo(map.get(financeCount.getFactorTwo()).apply(a));
|
|
|
return eChartsVo;
|
|
return eChartsVo;
|
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
}
|