|
@@ -1,16 +1,22 @@
|
|
|
package com.sckw.payment.service;
|
|
package com.sckw.payment.service;
|
|
|
|
|
|
|
|
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.req.FinanceCount;
|
|
import com.sckw.payment.model.vo.req.FinanceCount;
|
|
|
|
|
+import com.sckw.payment.model.vo.res.EChartsVo;
|
|
|
import com.sckw.payment.utils.DateTimeUtil;
|
|
import com.sckw.payment.utils.DateTimeUtil;
|
|
|
|
|
+import com.sckw.payment.utils.DecimalUtils;
|
|
|
import jakarta.annotation.Resource;
|
|
import jakarta.annotation.Resource;
|
|
|
-import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.math.RoundingMode;
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 工作台
|
|
* 工作台
|
|
@@ -20,7 +26,6 @@ import java.util.List;
|
|
|
*/
|
|
*/
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
-@RequiredArgsConstructor
|
|
|
|
|
public class WorkbenchService {
|
|
public class WorkbenchService {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
@@ -33,7 +38,7 @@ public class WorkbenchService {
|
|
|
|
|
|
|
|
//时间参数为空,按照默认维度统计
|
|
//时间参数为空,按照默认维度统计
|
|
|
if (StringUtils.isBlank(financeCount.getStartTime()) && StringUtils.isBlank(financeCount.getEndTime())) {
|
|
if (StringUtils.isBlank(financeCount.getStartTime()) && StringUtils.isBlank(financeCount.getEndTime())) {
|
|
|
- //按照周期维度生成时间段
|
|
|
|
|
|
|
+ //按照周期维度生成时间段2
|
|
|
if (circle == 1) {
|
|
if (circle == 1) {
|
|
|
//从今天倒推15天
|
|
//从今天倒推15天
|
|
|
time.add(DateTimeUtil.getComputeDaysStr(-14));
|
|
time.add(DateTimeUtil.getComputeDaysStr(-14));
|
|
@@ -54,6 +59,49 @@ public class WorkbenchService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
- return kwpSettlementRecordService.financeCount(time,entId);
|
|
|
|
|
|
|
+ DecimalFormat df = new DecimalFormat("0.00");
|
|
|
|
|
+ //获取数据,按照统计因子进行处理,并转换成万元
|
|
|
|
|
+ List<SettlementRecord> settlementRecords = kwpSettlementRecordService.financeCount(time, entId, circle);
|
|
|
|
|
+ return settlementRecords.stream().map(a -> {
|
|
|
|
|
+ EChartsVo eChartsVo = new EChartsVo();
|
|
|
|
|
+ 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));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return eChartsVo;
|
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|