|
@@ -94,6 +94,39 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void updateAnnualBudget(AnnualBudgetDTO dto) {
|
|
|
+ //收入数据校验
|
|
|
+ List<AnnualBudgetIncome> incomeList = dto.getIncomeList();
|
|
|
+ if (incomeList != null && incomeList.size() > 0){
|
|
|
+ for (AnnualBudgetIncome income : incomeList) {
|
|
|
+ if (income.getProjectId() == null){
|
|
|
+ throw new ServiceException("请选择项目名称");
|
|
|
+ }
|
|
|
+ if (income.getIncomeType() == null){
|
|
|
+ throw new ServiceException("请选择收入类别");
|
|
|
+ }
|
|
|
+ if (income.getPredictSignDate() == null){
|
|
|
+ throw new ServiceException("请选择预计签单时间");
|
|
|
+ }
|
|
|
+ if (income.getPredictContractMoney() == null){
|
|
|
+ throw new ServiceException("请输入预计新签合同额");
|
|
|
+ }
|
|
|
+ if (income.getPredictAnnualReturned() == null){
|
|
|
+ throw new ServiceException("请输入预计本年度回款额");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //支出数据校验
|
|
|
+ List<AnnualBudgetDisburse> disburseList = dto.getDisburseList();
|
|
|
+ if (disburseList != null && disburseList.size() > 0){
|
|
|
+ for (AnnualBudgetDisburse disburse : disburseList) {
|
|
|
+ if (disburse.getBudgetSubject() == null){
|
|
|
+ throw new ServiceException("请选择预算科目");
|
|
|
+ }
|
|
|
+ if (disburse.getSecondSubject() == null){
|
|
|
+ throw new ServiceException("请选择二级科目");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
//统计支出
|
|
|
Map<String, BigDecimal> map = statisticDisburse(dto);
|
|
|
BigDecimal disburseTotal = map.get("1");
|
|
@@ -941,6 +974,96 @@ public class AnnualBudgetServiceImpl extends BaseServiceImpl<AnnualBudgetMapper,
|
|
|
return vos;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 预算与实际统计-月度统计
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<BudgetAndPracticalByMonthVO> budgetAndPracticalByMonth(String year) {
|
|
|
+ int y = Integer.parseInt(year.substring(0, 4));
|
|
|
+ //获取年度预算
|
|
|
+ AnnualBudget budget = baseMapper.getThisYearBudget(y);
|
|
|
+ Boolean isAnnual = true;
|
|
|
+ AnnualBudgetVO2 preview;
|
|
|
+ List<AnnualBudgetVO2.IncomeDetail> monthIncome = new ArrayList<>();
|
|
|
+ List<AnnualBudgetVO2.disburseDetail> monthDisburse = new ArrayList<>();
|
|
|
+ if (budget != null) {
|
|
|
+ preview = this.preview(budget.getId());
|
|
|
+ monthIncome = preview.getMonthIncome();
|
|
|
+ monthDisburse = preview.getMonthDisburse();
|
|
|
+ }else {
|
|
|
+ isAnnual = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取所有项目当年每月的应回款
|
|
|
+ List<BigDecimal> returned1 = returnedInfoService.getAllMonthReturnedByYear(y,1);
|
|
|
+ //获取已经指定年分配月的成本测算
|
|
|
+ List<BigDecimal> budgets = budgetService.getAllMonthBudgetByYear(y);
|
|
|
+ //获取所有项目当年每月的实际回款
|
|
|
+ List<BigDecimal> returned2 = returnedInfoService.getAllMonthReturnedByYear(y,2);
|
|
|
+ //获取每月实际的人工支出
|
|
|
+ List<BigDecimal> staffCost = budgetService.getAllMonthStaffCostByYear(y);
|
|
|
+ //获取每月实际的维护支出
|
|
|
+ List<BigDecimal> maintainCost = budgetService.getAllMonthMaintainCostByYear(y);
|
|
|
+ //获取每月实际的报销支出
|
|
|
+ List<BigDecimal> reimburse = projectInfoService.getAllMonthReimburseByYear(y);
|
|
|
+ //结果集
|
|
|
+ List<BudgetAndPracticalByMonthVO> list = new ArrayList<>();
|
|
|
+
|
|
|
+ //分别计算12个月
|
|
|
+ List<String> months = Arrays.asList("一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月");
|
|
|
+ BigDecimal c1 = new BigDecimal(0);
|
|
|
+ BigDecimal c2 = new BigDecimal(0);
|
|
|
+ BigDecimal c3 = new BigDecimal(0);
|
|
|
+ BigDecimal c4 = new BigDecimal(0);
|
|
|
+ BigDecimal c5 = new BigDecimal(0);
|
|
|
+ BigDecimal c6 = new BigDecimal(0);
|
|
|
+ for (int i = 1; i <= 12; i++) {
|
|
|
+ BudgetAndPracticalByMonthVO vo1 = new BudgetAndPracticalByMonthVO();
|
|
|
+ //月份
|
|
|
+ vo1.setTime(months.get(i-1));
|
|
|
+ //年初月收入
|
|
|
+ if (isAnnual) {
|
|
|
+ vo1.setIncome1(monthIncome.get(i-1).getIncome());
|
|
|
+ c1 = c1.add(monthIncome.get(i-1).getIncome());
|
|
|
+ }else {
|
|
|
+ vo1.setIncome1(new BigDecimal(0));
|
|
|
+ c1 = c1.add(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ //年初月支出
|
|
|
+ if (isAnnual) {
|
|
|
+ vo1.setDisburse1(monthDisburse.get(i-1).getDisburse());
|
|
|
+ c2 = c2.add(monthDisburse.get(i-1).getDisburse());
|
|
|
+ }else {
|
|
|
+ vo1.setDisburse1(new BigDecimal(0));
|
|
|
+ c2 = c2.add(new BigDecimal(0));
|
|
|
+ }
|
|
|
+ //每月计划收入
|
|
|
+ vo1.setIncome2(returned1.get(i-1));
|
|
|
+ c3 = c3.add(returned1.get(i-1));
|
|
|
+ //每月计划支出
|
|
|
+ vo1.setDisburse2(budgets.get(i-1));
|
|
|
+ c4 = c4.add(budgets.get(i-1));
|
|
|
+ //实际每月收入
|
|
|
+ vo1.setIncome3(returned2.get(i-1));
|
|
|
+ c5 = c5.add(returned2.get(i-1));
|
|
|
+ //实际每月支出
|
|
|
+ vo1.setDisburse3(staffCost.get(i-1).add(maintainCost.get(i-1).add(reimburse.get(i-1))));
|
|
|
+ c6 = c6.add(staffCost.get(i-1).add(maintainCost.get(i-1).add(reimburse.get(i-1))));
|
|
|
+
|
|
|
+ list.add(vo1);
|
|
|
+ }
|
|
|
+ BudgetAndPracticalByMonthVO vo2 = new BudgetAndPracticalByMonthVO();
|
|
|
+ vo2.setTime("总计");
|
|
|
+ vo2.setIncome1(c1);
|
|
|
+ vo2.setDisburse1(c2);
|
|
|
+ vo2.setIncome2(c3);
|
|
|
+ vo2.setDisburse2(c4);
|
|
|
+ vo2.setIncome3(c5);
|
|
|
+ vo2.setDisburse3(c6);
|
|
|
+ list.add(vo2);
|
|
|
+ return list;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 统计支出 1支出总和2工资总和
|
|
|
*/
|