大屏页面初始化
This commit is contained in:
@@ -14,6 +14,7 @@ import org.springframework.stereotype.Controller;
|
|||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.math.RoundingMode;
|
import java.math.RoundingMode;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Controller
|
@Controller
|
||||||
public class erpJobs {
|
public class erpJobs {
|
||||||
@@ -25,8 +26,9 @@ public class erpJobs {
|
|||||||
@Resource
|
@Resource
|
||||||
private ErpTransactionFlowService flowService;
|
private ErpTransactionFlowService flowService;
|
||||||
|
|
||||||
@Scheduled(cron = "0 0 2 * * ?")
|
@Scheduled(cron = "10 30 2 * * ?")
|
||||||
public void updateErpIndex() {
|
public void updateErpIndex() {
|
||||||
|
try {
|
||||||
final BigDecimal BUDGET_AMOUNT = new BigDecimal("3000");
|
final BigDecimal BUDGET_AMOUNT = new BigDecimal("3000");
|
||||||
QueryWrapper<ErpTransactionFlow> query = new QueryWrapper<>();
|
QueryWrapper<ErpTransactionFlow> query = new QueryWrapper<>();
|
||||||
query.eq("year_date", DateUtils.getCurrentYear())
|
query.eq("year_date", DateUtils.getCurrentYear())
|
||||||
@@ -35,24 +37,28 @@ public class erpJobs {
|
|||||||
BigDecimal incomeAmount = flowList.stream()
|
BigDecimal incomeAmount = flowList.stream()
|
||||||
.filter(flow -> flow.getTransactionType().equals("2"))
|
.filter(flow -> flow.getTransactionType().equals("2"))
|
||||||
.map(ErpTransactionFlow::getAmount)
|
.map(ErpTransactionFlow::getAmount)
|
||||||
.filter(amount -> amount != null)
|
.filter(Objects::nonNull)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
BigDecimal expenseAmount = flowList.stream()
|
BigDecimal expenseAmount = flowList.stream()
|
||||||
.filter(flow -> flow.getTransactionType().equals("1"))
|
.filter(flow -> flow.getTransactionType().equals("1"))
|
||||||
.map(ErpTransactionFlow::getAmount)
|
.map(ErpTransactionFlow::getAmount)
|
||||||
.filter(amount -> amount != null)
|
.filter(Objects::nonNull)
|
||||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
//净利润
|
//净利润
|
||||||
BigDecimal netProfit = incomeAmount.subtract(expenseAmount);
|
BigDecimal netProfit = incomeAmount.subtract(expenseAmount);
|
||||||
//利润率
|
//利润率
|
||||||
BigDecimal profitRate = netProfit.divide(incomeAmount, 4, RoundingMode.HALF_UP)
|
BigDecimal profitRate = incomeAmount.equals(BigDecimal.ZERO)
|
||||||
|
? BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)
|
||||||
|
: netProfit.divide(incomeAmount, 4, RoundingMode.HALF_UP)
|
||||||
.multiply(new BigDecimal("100"))
|
.multiply(new BigDecimal("100"))
|
||||||
.setScale(2, RoundingMode.HALF_UP);
|
.setScale(2, RoundingMode.HALF_UP);
|
||||||
//占比
|
//占比
|
||||||
BigDecimal expenseIncomeRatio = expenseAmount.divide(incomeAmount, 4, RoundingMode.HALF_UP)
|
BigDecimal expenseIncomeRatio = incomeAmount.equals(BigDecimal.ZERO)
|
||||||
|
? BigDecimal.ZERO.setScale(2, RoundingMode.HALF_UP)
|
||||||
|
: expenseAmount.divide(incomeAmount, 4, RoundingMode.HALF_UP)
|
||||||
.multiply(new BigDecimal("100"))
|
.multiply(new BigDecimal("100"))
|
||||||
.setScale(2, RoundingMode.HALF_UP);
|
.setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
boolean isOverBudget = expenseAmount.compareTo(BUDGET_AMOUNT) > 0;
|
boolean isOverBudget = expenseAmount.compareTo(BUDGET_AMOUNT) > 0;
|
||||||
String budgetStatusName = isOverBudget ? "超出" : "正常";
|
String budgetStatusName = isOverBudget ? "超出" : "正常";
|
||||||
BigDecimal overBudgetAmount = isOverBudget ? expenseAmount.subtract(BUDGET_AMOUNT) : BigDecimal.ZERO;
|
BigDecimal overBudgetAmount = isOverBudget ? expenseAmount.subtract(BUDGET_AMOUNT) : BigDecimal.ZERO;
|
||||||
@@ -85,5 +91,10 @@ public class erpJobs {
|
|||||||
}
|
}
|
||||||
infoService.update(indexInfo, queryWrapper);
|
infoService.update(indexInfo, queryWrapper);
|
||||||
}
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user