|
|
@@ -820,217 +820,413 @@ public class FundIncomeInfoController {
|
|
|
map.put("name", templateInfo.getTitle() + "(汇总)");
|
|
|
map.put("isSum", true);
|
|
|
|
|
|
- BigDecimal accumulatedArrearsTotalSum = BigDecimal.ZERO;
|
|
|
+ Map<String, BigDecimal> sumMap = fundIncomeInfoService.sumBudgetRevenue(null, startDate, endDate, templateInfo.getId());
|
|
|
|
|
|
- BigDecimal totalSum = BigDecimal.ZERO;
|
|
|
+ //BigDecimal curMonthReceived = fundExpensesInfoService.sumByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
|
- BigDecimal totalCurMonthReceived = BigDecimal.ZERO;
|
|
|
+ FundIncomeInfo fundIncomeInfo = fundIncomeInfoService.findOneByTemplateOptionId(templateInfo.getId(), startDate, endDate);
|
|
|
|
|
|
- BigDecimal totalActualTotalRevenue = BigDecimal.ZERO;
|
|
|
+ //责任人
|
|
|
+ String chargePerson = "";
|
|
|
+ if (fundIncomeInfo != null) {
|
|
|
+ chargePerson = fundIncomeInfo.getChargePerson();
|
|
|
+ }
|
|
|
+ map.put("chargePerson", chargePerson);
|
|
|
|
|
|
- searchParams.put("templateId", templateInfo.getId());
|
|
|
+ //本月收入
|
|
|
+ BigDecimal sumCurMonthReceived = BigDecimal.ZERO;
|
|
|
+ if (sumMap.get("sumCurMonthReceived") != null) {
|
|
|
+ sumCurMonthReceived = new BigDecimal(sumMap.get("sumCurMonthReceived").toString());
|
|
|
+ }
|
|
|
+ map.put("curMonthReceived", sumCurMonthReceived);
|
|
|
|
|
|
- List<TemplateOption> templateOptionList = templateOptionService.findByTemplateIdAndLen(templateInfo.getId(), 1);
|
|
|
+ curMonthReceivedTotal = curMonthReceivedTotal.add(sumCurMonthReceived);
|
|
|
|
|
|
- List<Map> mapList1 = new ArrayList<>();
|
|
|
+ //预算收入
|
|
|
+ BigDecimal sumCurBudgetRevenue = BigDecimal.ZERO;
|
|
|
+ if (sumMap.get("sumCurBudgetRevenue") != null) {
|
|
|
+ sumCurBudgetRevenue = new BigDecimal(sumMap.get("sumCurBudgetRevenue").toString());
|
|
|
+ }
|
|
|
+ map.put("curBudgetRevenue", sumCurBudgetRevenue);
|
|
|
|
|
|
- for (TemplateOption templateOption : templateOptionList) {
|
|
|
- if (templateOption.getIsSum()) {
|
|
|
- Map map1 = new HashMap();
|
|
|
- map1.put("id", templateOption.getId());
|
|
|
- map1.put("serialNum", templateOption.getSerialNum());
|
|
|
- map1.put("name", templateOption.getName() + "(合计)");
|
|
|
- map1.put("isSum2", true);
|
|
|
+ curBudgetRevenueTotal = curBudgetRevenueTotal.add(sumCurBudgetRevenue);
|
|
|
|
|
|
|
|
|
- BigDecimal accumulatedArrearsSum = BigDecimal.ZERO;
|
|
|
+ BigDecimal actualTotalRevenue = fundIncomeInfoService.sumBySerialNumber(null, curMonth, templateInfo.getId());
|
|
|
|
|
|
- Map<String, BigDecimal> mapSum = fundIncomeInfoService.sumBudgetRevenue2(templateOption.getSerialNum() + ".%", startDate, endDate, templateInfo.getId(),templateOption.getSerialNum());
|
|
|
+ //实际总收入
|
|
|
+ map.put("actualTotalRevenue", actualTotalRevenue);
|
|
|
|
|
|
- BigDecimal sumCurBudgetRevenue = BigDecimal.ZERO;
|
|
|
- if (mapSum.get("sumCurBudgetRevenue") != null) {
|
|
|
- sumCurBudgetRevenue = new BigDecimal(mapSum.get("sumCurBudgetRevenue").toString());
|
|
|
- }
|
|
|
+ actualTotalRevenueTotal = actualTotalRevenueTotal.add(actualTotalRevenue);
|
|
|
|
|
|
- BigDecimal sumCurMonthReceived = BigDecimal.ZERO;
|
|
|
- if (mapSum.get("sumCurMonthReceived") != null) {
|
|
|
- sumCurMonthReceived = new BigDecimal(mapSum.get("sumCurMonthReceived").toString());
|
|
|
- }
|
|
|
+ BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
|
|
|
- map1.put("curMonthReceived", sumCurMonthReceived);
|
|
|
+ if (sumCurBudgetRevenue != null) {
|
|
|
+ if (actualTotalRevenue != null) {
|
|
|
+ accumulatedArrears = sumCurBudgetRevenue.subtract(actualTotalRevenue);
|
|
|
+ } else {
|
|
|
+ accumulatedArrears = sumCurBudgetRevenue;
|
|
|
+ }
|
|
|
|
|
|
- map1.put("curBudgetRevenue", sumCurBudgetRevenue);
|
|
|
+ if (accumulatedArrears.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ map.put("overIncome", accumulatedArrears.abs());
|
|
|
+ accumulatedArrears = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- Map<String, BigDecimal> accSumMap = fundIncomeInfoService.sumBudgetRevenue2(templateOption.getSerialNum() + "%", startYearDate, endDate, templateOption.getTemplateId(),templateOption.getSerialNum());
|
|
|
+ //累计欠费
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
|
|
|
- BigDecimal actualTotalRevenue = BigDecimal.ZERO;
|
|
|
- if (accSumMap.get("sumCurMonthReceived") != null) {
|
|
|
- actualTotalRevenue = new BigDecimal(accSumMap.get("sumCurMonthReceived").toString());
|
|
|
- }
|
|
|
+ accumulatedArrearsTotal = accumulatedArrearsTotal.add(accumulatedArrears);
|
|
|
|
|
|
- map1.put("actualTotalRevenue", actualTotalRevenue);
|
|
|
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
+ if (sumCurBudgetRevenue != null) {
|
|
|
+ if (sumCurBudgetRevenue.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ percentage = actualTotalRevenue.divide(sumCurBudgetRevenue, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- //总体汇总金额
|
|
|
- totalCurMonthReceived = totalCurMonthReceived.add(sumCurMonthReceived);
|
|
|
- totalSum = totalSum.add(sumCurBudgetRevenue);
|
|
|
- totalActualTotalRevenue = totalActualTotalRevenue.add(actualTotalRevenue);
|
|
|
+ //完成比例
|
|
|
+ if (percentage.compareTo(new BigDecimal(100)) == 1) {
|
|
|
+ percentage = new BigDecimal(100);
|
|
|
+ }
|
|
|
+ map.put("percentage", percentage);
|
|
|
|
|
|
- //累计欠费
|
|
|
- List<Map<String, BigDecimal>> accListMap = fundIncomeInfoService.findBudgetRevenue(templateOption.getSerialNum() + "%", startYearDate, endDate, templateOption.getTemplateId());
|
|
|
|
|
|
- BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
- BigDecimal accumulatedArrears1 = BigDecimal.ZERO;
|
|
|
+ List<TemplateOption> childrenItemList = templateOptionService.findByTemplateIdAndLen(templateInfo.getId(), 1);
|
|
|
|
|
|
- for (Map<String, BigDecimal> mapItem : accListMap) {
|
|
|
- if (mapItem != null && mapItem.get("accAmount") != null) {
|
|
|
- BigDecimal accAmount = mapItem.get("accAmount");
|
|
|
+ boolean hasChildren = true;
|
|
|
+ if (childrenItemList.size() == 0) {
|
|
|
+ hasChildren = false;
|
|
|
+ }
|
|
|
|
|
|
- accumulatedArrears1 = accumulatedArrears1.add(accAmount);
|
|
|
+ map.put("hasChildren", hasChildren);
|
|
|
|
|
|
- if (accAmount.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- accAmount = BigDecimal.ZERO;
|
|
|
- }
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
|
|
|
- accumulatedArrears = accumulatedArrears.add(accAmount);
|
|
|
- }
|
|
|
- }
|
|
|
+ //汇总
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ map.put("id", "-1");
|
|
|
+ map.put("name", "总计");
|
|
|
+ map.put("curBudgetRevenue", curBudgetRevenueTotal);
|
|
|
+ map.put("accumulatedArrears", accumulatedArrearsTotal);
|
|
|
+ map.put("actualTotalRevenue", actualTotalRevenueTotal);
|
|
|
+ map.put("curMonthReceived", curMonthReceivedTotal);
|
|
|
+ if (overIncomeTotal.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ map.put("overIncome", overIncomeTotal);
|
|
|
+ }
|
|
|
|
|
|
- if (accumulatedArrears != null && accumulatedArrears1 != null) {
|
|
|
- BigDecimal overIncome = accumulatedArrears.subtract(accumulatedArrears1);
|
|
|
- if (overIncome.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- map1.put("overIncome", overIncome);
|
|
|
- }
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
|
|
|
- }
|
|
|
- map1.put("accumulatedArrears", accumulatedArrears);
|
|
|
+ if (curBudgetRevenueTotal != null && actualTotalRevenueTotal != null) {
|
|
|
+ if (curBudgetRevenueTotal.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ percentage = actualTotalRevenueTotal.divide(curBudgetRevenueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- accumulatedArrearsTotalSum = accumulatedArrearsTotalSum.add(accumulatedArrearsSum);
|
|
|
+ map.put("percentage", percentage);
|
|
|
|
|
|
- BigDecimal percentage = BigDecimal.ZERO;
|
|
|
+ mapList.add(map);
|
|
|
|
|
|
- if (sumCurBudgetRevenue != null && actualTotalRevenue != null) {
|
|
|
- if (sumCurBudgetRevenue.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- percentage = actualTotalRevenue.divide(sumCurBudgetRevenue, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
- }
|
|
|
- }
|
|
|
+ if (exportFlag) {
|
|
|
+ for (Map mapItem : mapList) {
|
|
|
+ String templateId = mapItem.get("id").toString();
|
|
|
|
|
|
- map1.put("percentage", percentage);
|
|
|
+ List<Map> childrenMap = getAllChildMapData(templateId,null,yearMonth);
|
|
|
|
|
|
+ mapItem.put("children", childrenMap);
|
|
|
+ }
|
|
|
|
|
|
- List<Map> mapList2 = getChildTemplateOption(templateOption.getTemplateId(), templateOption.getSerialNum(), curMonth, startDate, endDate, startYearDate);
|
|
|
+ String filePath = summaryListExportXls(mapList);
|
|
|
+ msgResult.setData(filePath);
|
|
|
+ } else {
|
|
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
+ dataMap.put("data", mapList);
|
|
|
+ msgResult.setData(dataMap);
|
|
|
+ }
|
|
|
|
|
|
- map1.put("children", mapList2);
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
|
- mapList1.add(map1);
|
|
|
- }
|
|
|
- }
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+ msgResult.setResult(false);
|
|
|
+ }
|
|
|
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
|
|
|
- //map.put("accumulatedArrears", accumulatedArrearsTotalSum);
|
|
|
- map.put("curBudgetRevenue", totalSum);
|
|
|
|
|
|
- map.put("curMonthReceived", totalCurMonthReceived);
|
|
|
|
|
|
- map.put("actualTotalRevenue", totalActualTotalRevenue);
|
|
|
+ private List<Map> getAllChildMapData(String id, String serialNum, String yearMonth) {
|
|
|
|
|
|
- curMonthReceivedTotal = curMonthReceivedTotal.add(totalCurMonthReceived);
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
|
|
|
- curBudgetRevenueTotal = curBudgetRevenueTotal.add(totalSum);
|
|
|
+ String curMonth = "";
|
|
|
+ String startDate = "";
|
|
|
+ String endDate = "";
|
|
|
+ String startYearDate = "";
|
|
|
+ if (StringUtils.isNotEmpty(yearMonth)) {
|
|
|
+ startYearDate = yearMonth.substring(0, 4) + "-01-01";
|
|
|
+ startDate = yearMonth + "-01";
|
|
|
+ endDate = yearMonth + "-31";
|
|
|
|
|
|
- actualTotalRevenueTotal = actualTotalRevenueTotal.add(totalActualTotalRevenue);
|
|
|
+ curMonth = endDate;
|
|
|
+ }
|
|
|
|
|
|
- BigDecimal percentage = BigDecimal.ZERO;
|
|
|
|
|
|
- if (totalSum != null && accumulatedArrearsTotalSum != null) {
|
|
|
- if (totalSum.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- percentage = totalActualTotalRevenue.divide(totalSum, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
- }
|
|
|
- }
|
|
|
+ int length = 1;
|
|
|
+ String templateId;
|
|
|
+ List<TemplateOption> templateOptionList;
|
|
|
|
|
|
- map.put("percentage", percentage);
|
|
|
+ if (StringUtils.isNotEmpty(serialNum)) {
|
|
|
+ length = serialNum.length() + 2;
|
|
|
+ TemplateOption templateOption = templateOptionService.get(id);
|
|
|
+ templateId = templateOption.getTemplateId();
|
|
|
+ templateOptionList = templateOptionService.findByTemplateIdAndNum(templateId, serialNum + "%", length);
|
|
|
+ } else {
|
|
|
+ templateId = id;
|
|
|
+ templateOptionList = templateOptionService.findByTemplateIdAndLen(templateId, length);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
- //累计欠费
|
|
|
- List<Map<String, BigDecimal>> accListMap = fundIncomeInfoService.findBudgetRevenue(null, startYearDate, endDate, templateInfo.getId());
|
|
|
+ for (TemplateOption item : templateOptionList) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
|
- BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
- BigDecimal accumulatedArrears1 = BigDecimal.ZERO;
|
|
|
+ map.put("id", item.getId());
|
|
|
+ String name = item.getName();
|
|
|
+ if (item.getIsSum()) {
|
|
|
+ name += "(汇总)";
|
|
|
+ }
|
|
|
+ map.put("name", name);
|
|
|
+ map.put("isSum2", item.getIsSum());
|
|
|
+ map.put("serialNum", item.getSerialNum());
|
|
|
|
|
|
- for (Map<String, BigDecimal> mapItem : accListMap) {
|
|
|
- if (mapItem != null && mapItem.get("accAmount") != null) {
|
|
|
- BigDecimal accAmount = mapItem.get("accAmount");
|
|
|
+ Map<String, BigDecimal> sumMap = fundIncomeInfoService.sumBudgetRevenue(item.getSerialNum() + "%", startDate, endDate, item.getTemplateId());
|
|
|
|
|
|
- accumulatedArrears1 = accumulatedArrears1.add(accAmount);
|
|
|
+ //BigDecimal curMonthReceived = fundExpensesInfoService.sumByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
|
- if (accAmount.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
- accAmount = BigDecimal.ZERO;
|
|
|
- }
|
|
|
+ FundIncomeInfo fundIncomeInfo = fundIncomeInfoService.findOneByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
|
- accumulatedArrears = accumulatedArrears.add(accAmount);
|
|
|
- }
|
|
|
+ //责任人
|
|
|
+ String chargePerson = "";
|
|
|
+ if (fundIncomeInfo != null) {
|
|
|
+ chargePerson = fundIncomeInfo.getChargePerson();
|
|
|
+ }
|
|
|
+ map.put("chargePerson", chargePerson);
|
|
|
+
|
|
|
+ //本月收入
|
|
|
+ BigDecimal sumCurMonthReceived = BigDecimal.ZERO;
|
|
|
+ if (sumMap.get("sumCurMonthReceived") != null) {
|
|
|
+ sumCurMonthReceived = new BigDecimal(sumMap.get("sumCurMonthReceived").toString());
|
|
|
+ }
|
|
|
+ map.put("curMonthReceived", sumCurMonthReceived);
|
|
|
+
|
|
|
+ //预算收入
|
|
|
+ BigDecimal sumCurBudgetRevenue = BigDecimal.ZERO;
|
|
|
+ if (sumMap.get("sumCurBudgetRevenue") != null) {
|
|
|
+ sumCurBudgetRevenue = new BigDecimal(sumMap.get("sumCurBudgetRevenue").toString());
|
|
|
+ }
|
|
|
+ map.put("curBudgetRevenue", sumCurBudgetRevenue);
|
|
|
+
|
|
|
+ BigDecimal actualTotalRevenue = fundIncomeInfoService.sumBySerialNumber(item.getSerialNum() + "%", curMonth, item.getTemplateId());
|
|
|
+
|
|
|
+ //实际总收入
|
|
|
+ map.put("actualTotalRevenue", actualTotalRevenue);
|
|
|
+
|
|
|
+ BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ if (sumCurBudgetRevenue != null) {
|
|
|
+ if (actualTotalRevenue != null) {
|
|
|
+ accumulatedArrears = sumCurBudgetRevenue.subtract(actualTotalRevenue);
|
|
|
+ } else {
|
|
|
+ accumulatedArrears = sumCurBudgetRevenue;
|
|
|
}
|
|
|
|
|
|
- if (accumulatedArrears != null && accumulatedArrears1 != null) {
|
|
|
- BigDecimal overIncome = accumulatedArrears.subtract(accumulatedArrears1);
|
|
|
- if (overIncome.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- map.put("overIncome", overIncome);
|
|
|
- overIncomeTotal = overIncomeTotal.add(overIncome);
|
|
|
- }
|
|
|
+ if (accumulatedArrears.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ map.put("overIncome", accumulatedArrears.abs());
|
|
|
+ accumulatedArrears = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //累计欠费
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
+ if (sumCurBudgetRevenue != null) {
|
|
|
+ if (sumCurBudgetRevenue.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ percentage = actualTotalRevenue.divide(sumCurBudgetRevenue, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- map.put("accumulatedArrears", accumulatedArrears);
|
|
|
+ //完成比例
|
|
|
+ if (percentage.compareTo(new BigDecimal(100)) == 1) {
|
|
|
+ percentage = new BigDecimal(100);
|
|
|
+ }
|
|
|
+ map.put("percentage", percentage);
|
|
|
|
|
|
- accumulatedArrearsTotal = accumulatedArrearsTotal.add(accumulatedArrears);
|
|
|
|
|
|
- map.put("children", mapList1);
|
|
|
+ List<TemplateOption> childrenItemList = templateOptionService.findByTemplateIdAndLen(id, length + 2);
|
|
|
|
|
|
- mapList.add(map);
|
|
|
+ boolean hasChildren = true;
|
|
|
+ if (childrenItemList.size() == 0) {
|
|
|
+ hasChildren = false;
|
|
|
}
|
|
|
|
|
|
+ map.put("hasChildren", hasChildren);
|
|
|
|
|
|
- //汇总
|
|
|
+ if(hasChildren){
|
|
|
+ List<Map> childrenMap = getAllChildMapData(item.getId(),item.getSerialNum(),yearMonth);
|
|
|
+ map.put("children", childrenMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ return mapList;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "各板块汇总表子项目")
|
|
|
+ @RequestMapping(value = "childTemplateOption", method = RequestMethod.POST)
|
|
|
+ public MessageResult<Object> childTemplateOption(String id, String serialNum, String yearMonth) {
|
|
|
+
|
|
|
+ MessageResult<Object> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ List<Map> mapList = getChildMapData(id, serialNum, yearMonth);
|
|
|
+
|
|
|
+ msgResult.setData(mapList);
|
|
|
+ msgResult.setResult(true);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ private List<Map> getChildMapData(String id, String serialNum, String yearMonth) {
|
|
|
+
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+
|
|
|
+ String curMonth = "";
|
|
|
+ String startDate = "";
|
|
|
+ String endDate = "";
|
|
|
+ String startYearDate = "";
|
|
|
+ if (StringUtils.isNotEmpty(yearMonth)) {
|
|
|
+ startYearDate = yearMonth.substring(0, 4) + "-01-01";
|
|
|
+ startDate = yearMonth + "-01";
|
|
|
+ endDate = yearMonth + "-31";
|
|
|
+
|
|
|
+ curMonth = endDate;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ int length = 1;
|
|
|
+ String templateId;
|
|
|
+ List<TemplateOption> templateOptionList;
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(serialNum)) {
|
|
|
+ length = serialNum.length() + 2;
|
|
|
+ TemplateOption templateOption = templateOptionService.get(id);
|
|
|
+ templateId = templateOption.getTemplateId();
|
|
|
+ templateOptionList = templateOptionService.findByTemplateIdAndNum(templateId, serialNum + "%", length);
|
|
|
+ } else {
|
|
|
+ templateId = id;
|
|
|
+ templateOptionList = templateOptionService.findByTemplateIdAndLen(templateId, length);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ for (TemplateOption item : templateOptionList) {
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
- map.put("id", "-1");
|
|
|
- map.put("name", "总计");
|
|
|
- map.put("curBudgetRevenue", curBudgetRevenueTotal);
|
|
|
- map.put("accumulatedArrears", accumulatedArrearsTotal);
|
|
|
- map.put("actualTotalRevenue", actualTotalRevenueTotal);
|
|
|
- map.put("curMonthReceived", curMonthReceivedTotal);
|
|
|
- if (overIncomeTotal.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- map.put("overIncome", overIncomeTotal);
|
|
|
+
|
|
|
+ map.put("id", item.getId());
|
|
|
+ String name = item.getName();
|
|
|
+ if (item.getIsSum()) {
|
|
|
+ name += "(汇总)";
|
|
|
}
|
|
|
+ map.put("name", name);
|
|
|
+ map.put("isSum2", item.getIsSum());
|
|
|
+ map.put("serialNum", item.getSerialNum());
|
|
|
|
|
|
- BigDecimal percentage = BigDecimal.ZERO;
|
|
|
+ Map<String, BigDecimal> sumMap = fundIncomeInfoService.sumBudgetRevenue(item.getSerialNum() + "%", startDate, endDate, item.getTemplateId());
|
|
|
|
|
|
- if (curBudgetRevenueTotal != null && actualTotalRevenueTotal != null) {
|
|
|
- if (curBudgetRevenueTotal.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
- percentage = actualTotalRevenueTotal.divide(curBudgetRevenueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ //BigDecimal curMonthReceived = fundExpensesInfoService.sumByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
+
|
|
|
+ FundIncomeInfo fundIncomeInfo = fundIncomeInfoService.findOneByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
+
|
|
|
+ //责任人
|
|
|
+ String chargePerson = "";
|
|
|
+ if (fundIncomeInfo != null) {
|
|
|
+ chargePerson = fundIncomeInfo.getChargePerson();
|
|
|
+ }
|
|
|
+ map.put("chargePerson", chargePerson);
|
|
|
+
|
|
|
+ //本月收入
|
|
|
+ BigDecimal sumCurMonthReceived = BigDecimal.ZERO;
|
|
|
+ if (sumMap.get("sumCurMonthReceived") != null) {
|
|
|
+ sumCurMonthReceived = new BigDecimal(sumMap.get("sumCurMonthReceived").toString());
|
|
|
+ }
|
|
|
+ map.put("curMonthReceived", sumCurMonthReceived);
|
|
|
+
|
|
|
+ //预算收入
|
|
|
+ BigDecimal sumCurBudgetRevenue = BigDecimal.ZERO;
|
|
|
+ if (sumMap.get("sumCurBudgetRevenue") != null) {
|
|
|
+ sumCurBudgetRevenue = new BigDecimal(sumMap.get("sumCurBudgetRevenue").toString());
|
|
|
+ }
|
|
|
+ map.put("curBudgetRevenue", sumCurBudgetRevenue);
|
|
|
+
|
|
|
+ BigDecimal actualTotalRevenue = fundIncomeInfoService.sumBySerialNumber(item.getSerialNum() + "%", curMonth, item.getTemplateId());
|
|
|
+
|
|
|
+ //实际总收入
|
|
|
+ map.put("actualTotalRevenue", actualTotalRevenue);
|
|
|
+
|
|
|
+ BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ if (sumCurBudgetRevenue != null) {
|
|
|
+ if (actualTotalRevenue != null) {
|
|
|
+ accumulatedArrears = sumCurBudgetRevenue.subtract(actualTotalRevenue);
|
|
|
+ } else {
|
|
|
+ accumulatedArrears = sumCurBudgetRevenue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (accumulatedArrears.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ map.put("overIncome", accumulatedArrears.abs());
|
|
|
+ accumulatedArrears = BigDecimal.ZERO;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //累计欠费
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
+ if (sumCurBudgetRevenue != null) {
|
|
|
+ if (sumCurBudgetRevenue.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
+ percentage = actualTotalRevenue.divide(sumCurBudgetRevenue, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //完成比例
|
|
|
+ if (percentage.compareTo(new BigDecimal(100)) == 1) {
|
|
|
+ percentage = new BigDecimal(100);
|
|
|
+ }
|
|
|
map.put("percentage", percentage);
|
|
|
|
|
|
- mapList.add(map);
|
|
|
|
|
|
- if (exportFlag) {
|
|
|
- String filePath = summaryListExportXls(mapList);
|
|
|
- msgResult.setData(filePath);
|
|
|
- } else {
|
|
|
- Map<String, Object> dataMap = new HashMap<>();
|
|
|
- dataMap.put("data", mapList);
|
|
|
- msgResult.setData(dataMap);
|
|
|
+ List<TemplateOption> childrenItemList = templateOptionService.findByTemplateIdAndLen(id, length + 2);
|
|
|
+
|
|
|
+ boolean hasChildren = true;
|
|
|
+ if (childrenItemList.size() == 0) {
|
|
|
+ hasChildren = false;
|
|
|
}
|
|
|
|
|
|
- msgResult.setResult(true);
|
|
|
+ map.put("hasChildren", hasChildren);
|
|
|
|
|
|
- } catch (Exception ex) {
|
|
|
- logger.error(ex.getMessage(), ex);
|
|
|
- msgResult.setResult(false);
|
|
|
+ mapList.add(map);
|
|
|
}
|
|
|
|
|
|
- return msgResult;
|
|
|
+ return mapList;
|
|
|
}
|
|
|
|
|
|
|