|
@@ -16,6 +16,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -32,6 +33,12 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
|
|
|
|
|
|
private final IAnnualBudgetDisburseService disburseService;
|
|
|
|
|
|
+ private final IContractReturnedInfoService returnedInfoService;
|
|
|
+
|
|
|
+ private final IProjectCostBudgetService budgetService;
|
|
|
+
|
|
|
+ private final IContractInfoService contractInfoService;
|
|
|
+
|
|
|
/**
|
|
|
* 新增年度经营预算
|
|
|
* @param dto
|
|
@@ -50,11 +57,11 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
|
|
|
BigDecimal contractTotal = map2.get("1");
|
|
|
BigDecimal planReturnedTotal = map2.get("2");
|
|
|
|
|
|
- //总经营预算
|
|
|
+ //总经营预算,所有支出总额
|
|
|
dto.setTotalBudget(disburseTotal);
|
|
|
- //年度合同指标
|
|
|
- dto.setAnnualContractTarget(contractTotal);
|
|
|
- //年度利润指标
|
|
|
+ //年度合同指标,预计本年度回款总额
|
|
|
+ dto.setAnnualContractTarget(planReturnedTotal);
|
|
|
+ //年度利润指标, 合同指标减经营预算
|
|
|
dto.setAnnualProfitTarget(planReturnedTotal.subtract(disburseTotal));
|
|
|
//人工成本
|
|
|
dto.setStaffCost(staffTotal);
|
|
@@ -290,6 +297,74 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
|
|
|
return allBudgetSubject;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 门户-年度指标统计 ,统计今年的
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AnnualBudgetVO3 portalAnnualTarget() {
|
|
|
+ AnnualBudgetVO3 vo3 = new AnnualBudgetVO3();
|
|
|
+ //获取今年
|
|
|
+ int year = LocalDate.now().getYear();
|
|
|
+ //获取今年的年度预算
|
|
|
+ AnnualBudget annualBudget = baseMapper.getThisYearBudget(year);
|
|
|
+ if (annualBudget == null){
|
|
|
+ throw new ServiceException("请先做年度预算");
|
|
|
+ }
|
|
|
+ //年度利润指标
|
|
|
+ if (annualBudget.getAnnualContractTarget() == null){
|
|
|
+ annualBudget.setAnnualContractTarget(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ if (annualBudget.getAnnualProfitTarget() == null){
|
|
|
+ annualBudget.setAnnualProfitTarget(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ vo3.setAnnualProfitTarget(annualBudget.getAnnualProfitTarget());
|
|
|
+ //年度合同指标
|
|
|
+ vo3.setAnnualContractTarget(annualBudget.getAnnualContractTarget());
|
|
|
+ //获取今年的已收入:合同回款
|
|
|
+ BigDecimal yearReturned = returnedInfoService.getYearReturned(year);
|
|
|
+ vo3.setYearReturned(yearReturned);
|
|
|
+ //统计今年的已盈利:已收入-支出 ,目前已支出只统计闭环的计划
|
|
|
+ //获取一年人工支出
|
|
|
+ BigDecimal yearStaffDisburse = budgetService.getYearStaffDisburse(year);
|
|
|
+ vo3.setYearProfit(yearReturned.subtract(yearStaffDisburse));
|
|
|
+ //合同进度统计
|
|
|
+ if (vo3.getAnnualContractTarget() == null || vo3.getAnnualContractTarget().compareTo(BigDecimal.ZERO) == 0 || vo3.getYearReturned().compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ vo3.setContractSchedule(0);
|
|
|
+ }else {
|
|
|
+ vo3.setContractSchedule(vo3.getYearReturned().divide(vo3.getAnnualContractTarget(),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).intValue());
|
|
|
+ }
|
|
|
+ //利润进度统计
|
|
|
+ if (vo3.getAnnualProfitTarget() == null || vo3.getAnnualProfitTarget().compareTo(BigDecimal.ZERO) == 0 || vo3.getYearProfit().compareTo(BigDecimal.ZERO) == 0){
|
|
|
+ vo3.setProfitSchedule(0);
|
|
|
+ }else {
|
|
|
+ vo3.setProfitSchedule(vo3.getYearProfit().divide(vo3.getAnnualProfitTarget(),2,BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).intValue());
|
|
|
+ }
|
|
|
+ return vo3;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 门户-年度各项费用统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Map<String, BigDecimal> portalAnnualCost(String year) {
|
|
|
+ int y = Integer.parseInt(year);
|
|
|
+ Map<String,BigDecimal> map = new HashMap<>();
|
|
|
+ //总合同:当年所有合同金额
|
|
|
+ BigDecimal yearContractMoney = contractInfoService.getYearContractMoney(y);
|
|
|
+ map.put("yearContractMoney",yearContractMoney);
|
|
|
+ //总实际收入:当年所有回款
|
|
|
+ BigDecimal yearReturned = returnedInfoService.getYearReturned(y);
|
|
|
+ map.put("yearReturned",yearReturned);
|
|
|
+ //总实际支出:当年所有报销支出,和人工支出
|
|
|
+ BigDecimal yearStaffDisburse = budgetService.getYearStaffDisburse(y);
|
|
|
+ map.put("yearStaffDisburse",yearStaffDisburse);
|
|
|
+ //总计划支出:年度预算总计划支出
|
|
|
+ AnnualBudget annualBudget = baseMapper.getThisYearBudget(y);
|
|
|
+ BigDecimal totalBudget = annualBudget.getTotalBudget();
|
|
|
+ map.put("totalBudget",totalBudget);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统计支出 1支出总和2工资总和
|
|
|
*/
|