|
|
@@ -3,6 +3,7 @@ package com.jpsoft.employment.modules.base.controller;
|
|
|
import com.github.pagehelper.Page;
|
|
|
import com.jpsoft.employment.config.OSSConfig;
|
|
|
import com.jpsoft.employment.modules.base.entity.DepartmentInfo;
|
|
|
+import com.jpsoft.employment.modules.base.entity.TemplateInfo;
|
|
|
import com.jpsoft.employment.modules.base.entity.TemplateOption;
|
|
|
import com.jpsoft.employment.modules.base.service.DepartmentInfoService;
|
|
|
import com.jpsoft.employment.modules.base.service.TemplateInfoService;
|
|
|
@@ -46,6 +47,9 @@ public class FundIncomeInfoController {
|
|
|
@Autowired
|
|
|
private FundIncomeInfoService fundIncomeInfoService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TemplateInfoService templateInfoService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private TemplateOptionService templateOptionService;
|
|
|
|
|
|
@@ -163,6 +167,13 @@ public class FundIncomeInfoController {
|
|
|
fundIncomeInfo.setEndDate(sdf.parse(fundIncomeInfo.getEndDateStr()));
|
|
|
}
|
|
|
|
|
|
+ FundIncomeInfo orgItem = fundIncomeInfoService.get(fundIncomeInfo.getId());
|
|
|
+
|
|
|
+ if(orgItem.getCurMonthReceived()!=null&&fundIncomeInfo.getCurMonthReceived()!=null){
|
|
|
+ BigDecimal accumulateAmount = orgItem.getCurMonthReceived().add(fundIncomeInfo.getCurMonthReceived());
|
|
|
+ fundIncomeInfo.setCurMonthReceived(accumulateAmount);
|
|
|
+ }
|
|
|
+
|
|
|
int affectCount = fundIncomeInfoService.update(fundIncomeInfo);
|
|
|
|
|
|
if (affectCount > 0) {
|
|
|
@@ -486,7 +497,7 @@ public class FundIncomeInfoController {
|
|
|
|
|
|
map.put("total", total);
|
|
|
|
|
|
- BigDecimal accumulatedArrears = fundIncomeInfo.getBudgetRevenue();
|
|
|
+ BigDecimal accumulatedArrears = fundIncomeInfo.getCurBudgetRevenue();
|
|
|
if (total != null && accumulatedArrears != null) {
|
|
|
accumulatedArrears = accumulatedArrears.subtract(total);
|
|
|
}
|
|
|
@@ -746,6 +757,206 @@ public class FundIncomeInfoController {
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @ApiOperation(value = "各板块汇总表")
|
|
|
+ @RequestMapping(value = "summaryList", method = RequestMethod.POST)
|
|
|
+ public MessageResult<Object> summaryList(
|
|
|
+ String yearMonth, String name,
|
|
|
+ @RequestParam(value = "pageIndex", defaultValue = "1") int pageIndex,
|
|
|
+ @RequestParam(value = "pageSize", defaultValue = "20000") int pageSize,
|
|
|
+ @RequestParam(value = "exportFlag", defaultValue = "false") Boolean exportFlag,
|
|
|
+ HttpServletRequest request) {
|
|
|
+ String subject = (String) request.getAttribute("subject");
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<Object> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ Map<String, Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("template_id", "asc"));
|
|
|
+
|
|
|
+ String curMonth = "";
|
|
|
+ String startDate = "";
|
|
|
+ String endDate = "";
|
|
|
+ if (StringUtils.isNotEmpty(yearMonth)) {
|
|
|
+ startDate = yearMonth + "-01";
|
|
|
+ endDate = yearMonth + "-31";
|
|
|
+
|
|
|
+ searchParams.put("startDate", startDate);
|
|
|
+ searchParams.put("endDate", endDate);
|
|
|
+
|
|
|
+ curMonth = endDate;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
+ searchParams.put("name", "%" + name + "%");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ List<TemplateInfo> templateInfoList = templateInfoService.list();
|
|
|
+
|
|
|
+ List<String> curTemplateOptionList = new ArrayList<>();
|
|
|
+
|
|
|
+ if (templateInfoList.size() > 0) {
|
|
|
+ for (TemplateInfo templateInfo : templateInfoList) {
|
|
|
+ List<TemplateOption> templateOptionList = templateOptionService.findByTemplateId(templateInfo.getId());
|
|
|
+ for (TemplateOption option : templateOptionList) {
|
|
|
+ curTemplateOptionList.add(option.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (curTemplateOptionList.size() == 0) {
|
|
|
+ curTemplateOptionList.add("-1");
|
|
|
+ }
|
|
|
+
|
|
|
+ searchParams.put("templateOptionList", curTemplateOptionList);
|
|
|
+
|
|
|
+
|
|
|
+ Page<FundIncomeInfo> page = fundIncomeInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
+
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
+
|
|
|
+ String tempTemplateId = "";
|
|
|
+
|
|
|
+ for (FundIncomeInfo fundIncomeInfo : page) {
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
+ if (!fundIncomeInfo.getIsSum()) {
|
|
|
+ map.put("id", fundIncomeInfo.getId());
|
|
|
+ String templateId = fundIncomeInfo.getTemplateId();
|
|
|
+ map.put("templateId", templateId);
|
|
|
+ map.put("name", fundIncomeInfo.getName());
|
|
|
+ map.put("serialNumber", fundIncomeInfo.getSerialNumber());
|
|
|
+
|
|
|
+ BigDecimal budgetRevenue = fundIncomeInfo.getBudgetRevenue();
|
|
|
+ BigDecimal curBudgetRevenue = fundIncomeInfo.getCurBudgetRevenue();
|
|
|
+
|
|
|
+ map.put("budgetRevenue", budgetRevenue);
|
|
|
+ if (curBudgetRevenue == null || curBudgetRevenue.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ curBudgetRevenue = budgetRevenue;
|
|
|
+ }
|
|
|
+ map.put("curBudgetRevenue", curBudgetRevenue);
|
|
|
+ map.put("curMonthReceived", fundIncomeInfo.getCurMonthReceived());
|
|
|
+ map.put("accumulatedArrears", fundIncomeInfo.getAccumulatedArrears());
|
|
|
+
|
|
|
+ BigDecimal total = fundIncomeInfoService.sumBySerialNumber(fundIncomeInfo.getSerialNumber(), curMonth, templateId);
|
|
|
+
|
|
|
+ map.put("total", total);
|
|
|
+
|
|
|
+ BigDecimal accumulatedArrears = fundIncomeInfo.getBudgetRevenue();
|
|
|
+ if (total != null && accumulatedArrears != null) {
|
|
|
+ accumulatedArrears = accumulatedArrears.subtract(total);
|
|
|
+ }
|
|
|
+
|
|
|
+ //累计欠费
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
+
|
|
|
+ //实际总收入
|
|
|
+ map.put("actualTotalRevenue", total);
|
|
|
+
|
|
|
+ //构建汇总行
|
|
|
+ TemplateOption templateOption = templateOptionService.get(fundIncomeInfo.getTemplateOptionId());
|
|
|
+
|
|
|
+ TemplateInfo templateInfo = templateInfoService.get(templateOption.getTemplateId());
|
|
|
+
|
|
|
+ String title = templateInfo.getTitle();
|
|
|
+
|
|
|
+ if(!tempTemplateId.equals(templateInfo.getId())){
|
|
|
+ Map<String, Object> mapSum = new HashMap<>();
|
|
|
+ mapSum.put("name",title+"(合计)");
|
|
|
+ mapSum.put("isSum",true);
|
|
|
+
|
|
|
+ Map<String, BigDecimal> sumMap = fundIncomeInfoService.sumBudgetRevenue(null, startDate, endDate, templateId);
|
|
|
+
|
|
|
+ if (sumMap != null) {
|
|
|
+ BigDecimal tempBudgetRevenue = sumMap.get("sumBudget");
|
|
|
+ mapSum.put("budgetRevenue",tempBudgetRevenue);
|
|
|
+ }
|
|
|
+
|
|
|
+ mapList.add(mapSum);
|
|
|
+ }
|
|
|
+
|
|
|
+ tempTemplateId = templateInfo.getId();
|
|
|
+
|
|
|
+ mapList.add(map);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (exportFlag) {
|
|
|
+ String filePath = summaryListExportXls(mapList);
|
|
|
+ msgResult.setData(filePath);
|
|
|
+ } else {
|
|
|
+ Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
|
|
|
+ dataMap.put("data", mapList);
|
|
|
+ msgResult.setData(dataMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+ msgResult.setResult(false);
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //导出
|
|
|
+ private String summaryListExportXls(List<Map> mapList) {
|
|
|
+ String downloadUrl = "";
|
|
|
+
|
|
|
+ Workbook workbook = new HSSFWorkbook();
|
|
|
+ Sheet sheet = workbook.createSheet();
|
|
|
+
|
|
|
+ //表头
|
|
|
+ Row rowTitle = sheet.createRow(0);
|
|
|
+
|
|
|
+ String[] titles = new String[]{"序号", "收入子项目", "预算收入", "本月到账金额", "实际总收入", "累计欠费", "目前收入完全比率",
|
|
|
+ "累计已支出金额", "实际收入结余", "备注"};
|
|
|
+
|
|
|
+ for (int i = 0; i < titles.length; i++) {
|
|
|
+ Cell cell = rowTitle.createCell(i);
|
|
|
+ cell.setCellValue(titles[i]);
|
|
|
+ }
|
|
|
+
|
|
|
+ for (int i = 0; i < mapList.size(); i++) {
|
|
|
+ Map<String, Object> map = mapList.get(i);
|
|
|
+
|
|
|
+ Row row = sheet.createRow(i + 1);
|
|
|
+
|
|
|
+ int colIndex = 0;
|
|
|
+ row.createCell(colIndex++).setCellValue(i + 1);
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("name"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("budgetRevenue"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("curMonthReceived"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("actualTotalRevenue"), ""));
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("accumulatedArrears"), ""));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+
|
|
|
+ try {
|
|
|
+ workbook.write(output);
|
|
|
+
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+
|
|
|
+ downloadUrl = OSSUtil.upload(ossConfig, "summaryList", "各板块汇总表.xls", input);
|
|
|
+ } catch (Exception ex) {
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
+ }
|
|
|
+
|
|
|
+ return downloadUrl;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private String dateFormate(String str) {
|
|
|
//String s="45292.0"; //举例日期为2024-01-01 / 45292.0
|
|
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
|