|
@@ -0,0 +1,1120 @@
|
|
|
|
|
+package com.jpsoft.employment.modules.base.controller;
|
|
|
|
|
+
|
|
|
|
|
+import com.github.pagehelper.Page;
|
|
|
|
|
+import com.jpsoft.employment.config.OSSConfig;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.dto.AddRowDTO;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.entity.*;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.DepartmentInfoService;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.TemplateInfoService;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.TemplateOptionService;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.dto.Sort;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.dto.MessageResult;
|
|
|
|
|
+import com.jpsoft.employment.modules.base.service.FundExpensesInfoService;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.utils.OSSUtil;
|
|
|
|
|
+import com.jpsoft.employment.modules.common.utils.PojoUtils;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
+
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
+
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/base/fundExpensesInfo")
|
|
|
|
|
+public class FundExpensesInfoController {
|
|
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FundExpensesInfoService fundExpensesInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private DepartmentInfoService departmentInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TemplateInfoService templateInfoService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TemplateOptionService templateOptionService;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private OSSConfig ossConfig;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "创建空记录")
|
|
|
|
|
+ @GetMapping("create")
|
|
|
|
|
+ public MessageResult<FundExpensesInfo> create() {
|
|
|
|
|
+ MessageResult<FundExpensesInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ FundExpensesInfo fundExpensesInfo = new FundExpensesInfo();
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setData(fundExpensesInfo);
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "添加信息")
|
|
|
|
|
+ @PostMapping("add")
|
|
|
|
|
+ public MessageResult<FundExpensesInfo> add(@RequestBody FundExpensesInfo fundExpensesInfo, @RequestAttribute String subject) {
|
|
|
|
|
+ MessageResult<FundExpensesInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ Date now = new Date();
|
|
|
|
|
+ fundExpensesInfo.setId(UUID.randomUUID().toString());
|
|
|
|
|
+ fundExpensesInfo.setDelFlag(false);
|
|
|
|
|
+ fundExpensesInfo.setCreateBy(subject);
|
|
|
|
|
+ fundExpensesInfo.setCreateTime(now);
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fundExpensesInfo.getEndDateStr())) {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ fundExpensesInfo.setEndDate(sdf.parse(fundExpensesInfo.getEndDateStr()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ fundExpensesInfo.setYear(now);
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = fundExpensesInfoService.insert(fundExpensesInfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(fundExpensesInfo);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("数据库添加失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "获取信息")
|
|
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
|
|
+ public MessageResult<FundExpensesInfo> edit(@PathVariable("id") String id) {
|
|
|
|
|
+ MessageResult<FundExpensesInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ FundExpensesInfo fundExpensesInfo = fundExpensesInfoService.get(id);
|
|
|
|
|
+
|
|
|
|
|
+ if (fundExpensesInfo != null) {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ if (fundExpensesInfo.getEndDate() != null) {
|
|
|
|
|
+ fundExpensesInfo.setEndDateStr(sdf.format(fundExpensesInfo.getEndDate()));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fundExpensesInfo.getExpensesType())) {
|
|
|
|
|
+ String type = fundExpensesInfo.getExpensesType();
|
|
|
|
|
+ switch (type) {
|
|
|
|
|
+ case "1":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按月");
|
|
|
|
|
+ case "2":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按年");
|
|
|
|
|
+ case "3":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按季");
|
|
|
|
|
+ case "4":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按学期");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(fundExpensesInfo);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(fundExpensesInfo);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "更新用户")
|
|
|
|
|
+ @PostMapping("update")
|
|
|
|
|
+ public MessageResult<FundExpensesInfo> update(@RequestBody FundExpensesInfo fundExpensesInfo, @RequestAttribute String subject) {
|
|
|
|
|
+ MessageResult<FundExpensesInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ fundExpensesInfo.setUpdateBy(subject);
|
|
|
|
|
+ fundExpensesInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fundExpensesInfo.getEndDateStr())) {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ fundExpensesInfo.setEndDate(sdf.parse(fundExpensesInfo.getEndDateStr()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FundExpensesInfo orgItem = fundExpensesInfoService.get(fundExpensesInfo.getId());
|
|
|
|
|
+
|
|
|
|
|
+ if (orgItem.getCurMonthReceived() != null && fundExpensesInfo.getCurMonthReceived() != null) {
|
|
|
|
|
+ BigDecimal accumulateAmount = orgItem.getCurMonthReceived().add(fundExpensesInfo.getCurMonthReceived());
|
|
|
|
|
+ fundExpensesInfo.setCurMonthReceived(accumulateAmount);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = fundExpensesInfoService.update(fundExpensesInfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(fundExpensesInfo);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("数据库更新失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "批量保存")
|
|
|
|
|
+ @PostMapping("batchSave")
|
|
|
|
|
+ public MessageResult<FundExpensesInfo> batchSave(@RequestBody List<FundExpensesInfo> list, @RequestAttribute String subject) {
|
|
|
|
|
+ MessageResult<FundExpensesInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ int affectCount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (FundExpensesInfo fundExpensesInfo : list) {
|
|
|
|
|
+ fundExpensesInfo.setUpdateBy(subject);
|
|
|
|
|
+ fundExpensesInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fundExpensesInfo.getEndDateStr())) {
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+ fundExpensesInfo.setEndDate(sdf.parse(fundExpensesInfo.getEndDateStr()));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ affectCount += fundExpensesInfoService.update(fundExpensesInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("数据库更新失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "删除用户")
|
|
|
|
|
+ @PostMapping("delete/{id}")
|
|
|
|
|
+ public MessageResult<FundExpensesInfo> delete(@PathVariable("id") String id, @RequestAttribute String subject) {
|
|
|
|
|
+ MessageResult<FundExpensesInfo> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+
|
|
|
|
|
+ FundExpensesInfo fundExpensesInfo = fundExpensesInfoService.get(id);
|
|
|
|
|
+ fundExpensesInfo.setDelFlag(true);
|
|
|
|
|
+ fundExpensesInfo.setUpdateBy(subject);
|
|
|
|
|
+ fundExpensesInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ int affectCount = fundExpensesInfoService.update(fundExpensesInfo);
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("数据库删除失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "批量删除")
|
|
|
|
|
+ @PostMapping("batchDelete")
|
|
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject) {
|
|
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ int affectCount = 0;
|
|
|
|
|
+
|
|
|
|
|
+ for (String id : idList) {
|
|
|
|
|
+ FundExpensesInfo fundExpensesInfo = fundExpensesInfoService.get(id);
|
|
|
|
|
+ fundExpensesInfo.setDelFlag(true);
|
|
|
|
|
+ fundExpensesInfo.setUpdateBy(subject);
|
|
|
|
|
+ fundExpensesInfo.setUpdateTime(new Date());
|
|
|
|
|
+
|
|
|
|
|
+ affectCount += fundExpensesInfoService.update(fundExpensesInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (affectCount > 0) {
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+ msgResult.setData(affectCount);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "列表")
|
|
|
|
|
+ @RequestMapping(value = "pageList", method = RequestMethod.POST)
|
|
|
|
|
+ public MessageResult<Object> pageList(
|
|
|
|
|
+ String yearMonth, String name, String templateId,
|
|
|
|
|
+ @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("index_", "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 + "%");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(templateId)) {
|
|
|
|
|
+ searchParams.put("templateId", templateId);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ Page<FundExpensesInfo> page = fundExpensesInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
|
|
|
|
|
+
|
|
|
|
|
+ SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
+
|
|
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ for (FundExpensesInfo fundExpensesInfo : page) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("id", fundExpensesInfo.getId());
|
|
|
|
|
+ map.put("name", fundExpensesInfo.getName());
|
|
|
|
|
+ map.put("serialNumber", fundExpensesInfo.getSerialNumber());
|
|
|
|
|
+ map.put("chargePerson", fundExpensesInfo.getChargePerson());
|
|
|
|
|
+ map.put("isSum", fundExpensesInfo.getIsSum());
|
|
|
|
|
+ BigDecimal budgetRevenue = fundExpensesInfo.getBudgetExpenses();
|
|
|
|
|
+ BigDecimal curBudgetRevenue = fundExpensesInfo.getCurBudgetExpenses();
|
|
|
|
|
+ if (fundExpensesInfo.getIsSum() != null) {
|
|
|
|
|
+ if (fundExpensesInfo.getIsSum()) {
|
|
|
|
|
+ String serialNumber = fundExpensesInfo.getSerialNumber();
|
|
|
|
|
+ Map<String, BigDecimal> sumMap = fundExpensesInfoService.sumBudgetRevenue(serialNumber + ".%", startDate, endDate, templateId);
|
|
|
|
|
+
|
|
|
|
|
+ if (sumMap != null) {
|
|
|
|
|
+ budgetRevenue = sumMap.get("sumBudget");
|
|
|
|
|
+ curBudgetRevenue = sumMap.get("sumCurBudgetExpenses");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ map.put("budgetRevenue", budgetRevenue);
|
|
|
|
|
+ if (curBudgetRevenue == null || curBudgetRevenue.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
|
|
+ curBudgetRevenue = budgetRevenue;
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("curBudgetRevenue", curBudgetRevenue);
|
|
|
|
|
+ map.put("accountName", fundExpensesInfo.getAccountName());
|
|
|
|
|
+ map.put("curMonthReceived", fundExpensesInfo.getCurMonthReceived());
|
|
|
|
|
+ //map.put("actualTotalRevenue", fundIncomeInfo.getActualTotalRevenue());
|
|
|
|
|
+ //map.put("accumulatedArrears", fundIncomeInfo.getAccumulatedArrears());
|
|
|
|
|
+
|
|
|
|
|
+ String endDateStr = "";
|
|
|
|
|
+ String incomeTypeN = "";
|
|
|
|
|
+ String yearMonthStr = "";
|
|
|
|
|
+ String updateTime = "";
|
|
|
|
|
+ String createTime = "";
|
|
|
|
|
+ String year = "";
|
|
|
|
|
+
|
|
|
|
|
+ if (fundExpensesInfo.getYear() != null) {
|
|
|
|
|
+ year = sdf.format(fundExpensesInfo.getYear());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (fundExpensesInfo.getCreateTime() != null) {
|
|
|
|
|
+ createTime = sdf3.format(fundExpensesInfo.getCreateTime());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (fundExpensesInfo.getUpdateTime() != null) {
|
|
|
|
|
+ updateTime = sdf3.format(fundExpensesInfo.getUpdateTime());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (fundExpensesInfo.getEndDate() != null) {
|
|
|
|
|
+ fundExpensesInfo.setEndDateStr(sdf.format(fundExpensesInfo.getEndDate()));
|
|
|
|
|
+ endDateStr = sdf.format(fundExpensesInfo.getEndDate());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (fundExpensesInfo.getEndDate() != null) {
|
|
|
|
|
+ fundExpensesInfo.setEndDateStr(sdf.format(fundExpensesInfo.getEndDate()));
|
|
|
|
|
+ endDateStr = sdf.format(fundExpensesInfo.getEndDate());
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fundExpensesInfo.getExpensesType())) {
|
|
|
|
|
+ String type = fundExpensesInfo.getExpensesType();
|
|
|
|
|
+ switch (type) {
|
|
|
|
|
+ case "1":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按月");
|
|
|
|
|
+ incomeTypeN = "按月";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "2":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按年");
|
|
|
|
|
+ incomeTypeN = "按年";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "3":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按季");
|
|
|
|
|
+ incomeTypeN = "按季";
|
|
|
|
|
+ break;
|
|
|
|
|
+ case "4":
|
|
|
|
|
+ fundExpensesInfo.setExpensesTypeN("按学期");
|
|
|
|
|
+ incomeTypeN = "按学期";
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ map.put("endDateStr", endDateStr);
|
|
|
|
|
+ map.put("endDate", endDateStr);
|
|
|
|
|
+ map.put("incomeTypeN", incomeTypeN);
|
|
|
|
|
+
|
|
|
|
|
+ if (fundExpensesInfo.getYear() != null) {
|
|
|
|
|
+ yearMonthStr = sdf2.format(fundExpensesInfo.getYear());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ map.put("yearMonthStr", yearMonthStr);
|
|
|
|
|
+ map.put("yearMonth", yearMonthStr);
|
|
|
|
|
+
|
|
|
|
|
+ map.put("createTime", createTime);
|
|
|
|
|
+ map.put("updateTime", updateTime);
|
|
|
|
|
+ map.put("incomeTimeRange", fundExpensesInfo.getExpensesTimeRange());
|
|
|
|
|
+
|
|
|
|
|
+ map.put("attachment", fundExpensesInfo.getAttachment());
|
|
|
|
|
+
|
|
|
|
|
+ String incomeDepartment = "";
|
|
|
|
|
+ if (StringUtils.isNotEmpty(fundExpensesInfo.getExpensesDepartment())) {
|
|
|
|
|
+ String[] incomeDepartmentArr = fundExpensesInfo.getExpensesDepartment().split(",");
|
|
|
|
|
+ for (String departId : incomeDepartmentArr) {
|
|
|
|
|
+ DepartmentInfo departmentInfo = departmentInfoService.get(departId);
|
|
|
|
|
+ if (departmentInfo != null) {
|
|
|
|
|
+ incomeDepartment += departmentInfo.getName() + ",";
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StringUtils.isNotEmpty(incomeDepartment)) {
|
|
|
|
|
+ incomeDepartment = incomeDepartment.substring(0, incomeDepartment.lastIndexOf(","));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ map.put("departmentStr", incomeDepartment);
|
|
|
|
|
+ map.put("accountingName", fundExpensesInfo.getAccountingName());
|
|
|
|
|
+ map.put("bak", fundExpensesInfo.getBak());
|
|
|
|
|
+ map.put("year", year);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal total = fundExpensesInfoService.sumBySerialNumber(fundExpensesInfo.getSerialNumber(), curMonth, templateId);
|
|
|
|
|
+
|
|
|
|
|
+ map.put("total", total);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal accumulatedArrears = fundExpensesInfo.getCurBudgetExpenses();
|
|
|
|
|
+ if (total != null && accumulatedArrears != null) {
|
|
|
|
|
+ accumulatedArrears = accumulatedArrears.subtract(total);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //累计欠费
|
|
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
|
|
+
|
|
|
|
|
+ //实际总收入
|
|
|
|
|
+ map.put("actualTotalRevenue", total);
|
|
|
|
|
+
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (exportFlag) {
|
|
|
|
|
+ String filePath = exportXls(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 exportXls(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("serialNumber"), ""));
|
|
|
|
|
+ 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("accountName"), ""));
|
|
|
|
|
+ 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"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("incomeTimeRange"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("incomeTypeN"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("endDateStr"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("incomeDepartment"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("accountingName"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("bak"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("yearMonthStr"), ""));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ workbook.write(output);
|
|
|
|
|
+
|
|
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
|
|
+
|
|
|
|
|
+ downloadUrl = OSSUtil.upload(ossConfig, "fundExpensesList", "预算支出列表.xls", input);
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return downloadUrl;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @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"));
|
|
|
|
|
+ sortList.add(new Sort("index_", "asc"));
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ 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";
|
|
|
|
|
+
|
|
|
|
|
+ searchParams.put("startDate", startDate);
|
|
|
|
|
+ searchParams.put("endDate", endDate);
|
|
|
|
|
+
|
|
|
|
|
+ curMonth = endDate;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (StringUtils.isNotEmpty(name)) {
|
|
|
|
|
+ searchParams.put("title", "%" + name + "%");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ searchParams.put("type", "2");
|
|
|
|
|
+
|
|
|
|
|
+ List<Map> mapList = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal curBudgetExpensesTotal = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal accumulatedArrearsTotal = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal actualTotalExpensesTotal = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal curMonthReceivedTotal = BigDecimal.ZERO;
|
|
|
|
|
+ BigDecimal overIncomeTotal = BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<TemplateInfo> templateInfoList1 = templateInfoService.list(searchParams, sortList);
|
|
|
|
|
+
|
|
|
|
|
+ for (TemplateInfo templateInfo : templateInfoList1) {
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("id", templateInfo.getId());
|
|
|
|
|
+ map.put("name", templateInfo.getTitle() + "(汇总)");
|
|
|
|
|
+ map.put("isSum", true);
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, BigDecimal> sumMap = fundExpensesInfoService.sumBudgetRevenue(null, startDate, endDate, templateInfo.getId());
|
|
|
|
|
+
|
|
|
|
|
+ //BigDecimal curMonthReceived = fundExpensesInfoService.sumByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
+
|
|
|
|
|
+ FundExpensesInfo fundExpensesInfo = fundExpensesInfoService.findOneByTemplateOptionId(templateInfo.getId(), startDate, endDate);
|
|
|
|
|
+
|
|
|
|
|
+ //责任人
|
|
|
|
|
+ String chargePerson = "";
|
|
|
|
|
+ if (fundExpensesInfo != null) {
|
|
|
|
|
+ chargePerson = fundExpensesInfo.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);
|
|
|
|
|
+
|
|
|
|
|
+ curMonthReceivedTotal = curMonthReceivedTotal.add(sumCurMonthReceived);
|
|
|
|
|
+
|
|
|
|
|
+ //预算支出
|
|
|
|
|
+ BigDecimal sumCurBudgetExpenses = BigDecimal.ZERO;
|
|
|
|
|
+ if (sumMap.get("sumCurBudgetExpenses") != null) {
|
|
|
|
|
+ sumCurBudgetExpenses = new BigDecimal(sumMap.get("sumCurBudgetExpenses").toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("curBudgetExpenses", sumCurBudgetExpenses);
|
|
|
|
|
+
|
|
|
|
|
+ curBudgetExpensesTotal = curBudgetExpensesTotal.add(sumCurBudgetExpenses);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal actualTotalExpenses = fundExpensesInfoService.sumBySerialNumber(null, curMonth, templateInfo.getId());
|
|
|
|
|
+
|
|
|
|
|
+ //实际总支出
|
|
|
|
|
+ map.put("actualTotalExpenses", actualTotalExpenses);
|
|
|
|
|
+
|
|
|
|
|
+ actualTotalExpensesTotal = actualTotalExpensesTotal.add(actualTotalExpenses);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ if (sumCurBudgetExpenses != null) {
|
|
|
|
|
+ if (actualTotalExpenses != null) {
|
|
|
|
|
+ accumulatedArrears = sumCurBudgetExpenses.subtract(actualTotalExpenses);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ accumulatedArrears = sumCurBudgetExpenses;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (accumulatedArrears.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
+ map.put("overIncome", accumulatedArrears.abs());
|
|
|
|
|
+ accumulatedArrears = BigDecimal.ZERO;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //累计欠费
|
|
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
|
|
+
|
|
|
|
|
+ accumulatedArrearsTotal = accumulatedArrearsTotal.add(accumulatedArrears);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
|
|
+ if (sumCurBudgetExpenses != null) {
|
|
|
|
|
+ if (sumCurBudgetExpenses.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
+ percentage = actualTotalExpenses.divide(sumCurBudgetExpenses, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //完成比例
|
|
|
|
|
+ if (percentage.compareTo(new BigDecimal(100)) == 1) {
|
|
|
|
|
+ percentage = new BigDecimal(100);
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("percentage", percentage);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<TemplateOption> childrenItemList = templateOptionService.findByTemplateIdAndLen(templateInfo.getId(), 1);
|
|
|
|
|
+
|
|
|
|
|
+ boolean hasChildren = true;
|
|
|
|
|
+ if (childrenItemList.size() == 0) {
|
|
|
|
|
+ hasChildren = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ map.put("hasChildren", hasChildren);
|
|
|
|
|
+
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //汇总
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
|
+ map.put("id", "-1");
|
|
|
|
|
+ map.put("name", "总计");
|
|
|
|
|
+ map.put("curBudgetExpenses", curBudgetExpensesTotal);
|
|
|
|
|
+ map.put("accumulatedArrears", accumulatedArrearsTotal);
|
|
|
|
|
+ map.put("actualTotalExpenses", actualTotalExpensesTotal);
|
|
|
|
|
+ map.put("curMonthReceived", curMonthReceivedTotal);
|
|
|
|
|
+ if (overIncomeTotal.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
|
|
+ map.put("overIncome", overIncomeTotal);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ if (curBudgetExpensesTotal != null && actualTotalExpensesTotal != null) {
|
|
|
|
|
+ if (curBudgetExpensesTotal.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
+ percentage = actualTotalExpensesTotal.divide(curBudgetExpensesTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ map.put("percentage", percentage);
|
|
|
|
|
+
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+
|
|
|
|
|
+ if (exportFlag) {
|
|
|
|
|
+ for (Map mapItem : mapList) {
|
|
|
|
|
+ String templateId = mapItem.get("id").toString();
|
|
|
|
|
+
|
|
|
|
|
+ List<Map> childrenMap = getAllChildMapData(templateId,null,yearMonth);
|
|
|
|
|
+
|
|
|
|
|
+ mapItem.put("children", childrenMap);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String filePath = summaryListExportXls(mapList);
|
|
|
|
|
+ msgResult.setData(filePath);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ Map<String, Object> dataMap = new HashMap<>();
|
|
|
|
|
+ dataMap.put("data", mapList);
|
|
|
|
|
+ msgResult.setData(dataMap);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ msgResult.setResult(true);
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception ex) {
|
|
|
|
|
+ logger.error(ex.getMessage(), ex);
|
|
|
|
|
+ msgResult.setResult(false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return msgResult;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @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", item.getId());
|
|
|
|
|
+ String name = item.getName();
|
|
|
|
|
+ if (item.getIsSum()) {
|
|
|
|
|
+ name += "(汇总)";
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("name", name);
|
|
|
|
|
+ map.put("isSum2", item.getIsSum());
|
|
|
|
|
+ map.put("serialNum", item.getSerialNum());
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, BigDecimal> sumMap = fundExpensesInfoService.sumBudgetRevenue(item.getSerialNum() + "%", startDate, endDate, item.getTemplateId());
|
|
|
|
|
+
|
|
|
|
|
+ //BigDecimal curMonthReceived = fundExpensesInfoService.sumByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
+
|
|
|
|
|
+ FundExpensesInfo fundExpensesInfo = fundExpensesInfoService.findOneByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
+
|
|
|
|
|
+ //责任人
|
|
|
|
|
+ String chargePerson = "";
|
|
|
|
|
+ if (fundExpensesInfo != null) {
|
|
|
|
|
+ chargePerson = fundExpensesInfo.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 sumCurBudgetExpenses = BigDecimal.ZERO;
|
|
|
|
|
+ if (sumMap.get("sumCurBudgetExpenses") != null) {
|
|
|
|
|
+ sumCurBudgetExpenses = new BigDecimal(sumMap.get("sumCurBudgetExpenses").toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("curBudgetExpenses", sumCurBudgetExpenses);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal actualTotalExpenses = fundExpensesInfoService.sumBySerialNumber(item.getSerialNum() + "%", curMonth, item.getTemplateId());
|
|
|
|
|
+
|
|
|
|
|
+ //实际总支出
|
|
|
|
|
+ map.put("actualTotalExpenses", actualTotalExpenses);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ if (sumCurBudgetExpenses != null) {
|
|
|
|
|
+ if (actualTotalExpenses != null) {
|
|
|
|
|
+ accumulatedArrears = sumCurBudgetExpenses.subtract(actualTotalExpenses);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ accumulatedArrears = sumCurBudgetExpenses;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (accumulatedArrears.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
+ map.put("overIncome", accumulatedArrears.abs());
|
|
|
|
|
+ accumulatedArrears = BigDecimal.ZERO;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //累计欠费
|
|
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
|
|
+ if (sumCurBudgetExpenses != null) {
|
|
|
|
|
+ if (sumCurBudgetExpenses.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
+ percentage = actualTotalExpenses.divide(sumCurBudgetExpenses, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //完成比例
|
|
|
|
|
+ if (percentage.compareTo(new BigDecimal(100)) == 1) {
|
|
|
|
|
+ percentage = new BigDecimal(100);
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("percentage", percentage);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<TemplateOption> childrenItemList = templateOptionService.findByTemplateIdAndLen(id, length + 2);
|
|
|
|
|
+
|
|
|
|
|
+ boolean hasChildren = true;
|
|
|
|
|
+ if (childrenItemList.size() == 0) {
|
|
|
|
|
+ hasChildren = false;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ map.put("hasChildren", hasChildren);
|
|
|
|
|
+
|
|
|
|
|
+ mapList.add(map);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return mapList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private List<Map> getAllChildMapData(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", item.getId());
|
|
|
|
|
+ String name = item.getName();
|
|
|
|
|
+ if (item.getIsSum()) {
|
|
|
|
|
+ name += "(汇总)";
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("name", name);
|
|
|
|
|
+ map.put("isSum2", item.getIsSum());
|
|
|
|
|
+ map.put("serialNum", item.getSerialNum());
|
|
|
|
|
+
|
|
|
|
|
+ Map<String, BigDecimal> sumMap = fundExpensesInfoService.sumBudgetRevenue(item.getSerialNum() + "%", startDate, endDate, item.getTemplateId());
|
|
|
|
|
+
|
|
|
|
|
+ //BigDecimal curMonthReceived = fundExpensesInfoService.sumByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
+
|
|
|
|
|
+ FundExpensesInfo fundExpensesInfo = fundExpensesInfoService.findOneByTemplateOptionId(item.getId(), startDate, endDate);
|
|
|
|
|
+
|
|
|
|
|
+ //责任人
|
|
|
|
|
+ String chargePerson = "";
|
|
|
|
|
+ if (fundExpensesInfo != null) {
|
|
|
|
|
+ chargePerson = fundExpensesInfo.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 sumCurBudgetExpenses = BigDecimal.ZERO;
|
|
|
|
|
+ if (sumMap.get("sumCurBudgetExpenses") != null) {
|
|
|
|
|
+ sumCurBudgetExpenses = new BigDecimal(sumMap.get("sumCurBudgetExpenses").toString());
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("curBudgetExpenses", sumCurBudgetExpenses);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal actualTotalExpenses = fundExpensesInfoService.sumBySerialNumber(item.getSerialNum() + "%", curMonth, item.getTemplateId());
|
|
|
|
|
+
|
|
|
|
|
+ //实际总支出
|
|
|
|
|
+ map.put("actualTotalExpenses", actualTotalExpenses);
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal accumulatedArrears = BigDecimal.ZERO;
|
|
|
|
|
+
|
|
|
|
|
+ if (sumCurBudgetExpenses != null) {
|
|
|
|
|
+ if (actualTotalExpenses != null) {
|
|
|
|
|
+ accumulatedArrears = sumCurBudgetExpenses.subtract(actualTotalExpenses);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ accumulatedArrears = sumCurBudgetExpenses;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (accumulatedArrears.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
|
|
+ map.put("overIncome", accumulatedArrears.abs());
|
|
|
|
|
+ accumulatedArrears = BigDecimal.ZERO;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //累计欠费
|
|
|
|
|
+ map.put("accumulatedArrears", accumulatedArrears);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ BigDecimal percentage = BigDecimal.ZERO;
|
|
|
|
|
+ if (sumCurBudgetExpenses != null) {
|
|
|
|
|
+ if (sumCurBudgetExpenses.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
|
+ percentage = actualTotalExpenses.divide(sumCurBudgetExpenses, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //完成比例
|
|
|
|
|
+ if (percentage.compareTo(new BigDecimal(100)) == 1) {
|
|
|
|
|
+ percentage = new BigDecimal(100);
|
|
|
|
|
+ }
|
|
|
|
|
+ map.put("percentage", percentage);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ List<TemplateOption> childrenItemList = templateOptionService.findByTemplateIdAndLen(id, length + 2);
|
|
|
|
|
+
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //导出
|
|
|
|
|
+ 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]);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ AddRowDTO addRow = new AddRowDTO();
|
|
|
|
|
+ addRow.setRows(1);
|
|
|
|
|
+
|
|
|
|
|
+ for (int i = 0; i < mapList.size(); i++) {
|
|
|
|
|
+ Map<String, Object> map = mapList.get(i);
|
|
|
|
|
+
|
|
|
|
|
+ Row row = sheet.createRow(addRow.getRows());
|
|
|
|
|
+
|
|
|
|
|
+ int colIndex = 0;
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(addRow.getRows());
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("serialNum"), ""));
|
|
|
|
|
+ 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("curBudgetExpenses"), ""));
|
|
|
|
|
+ 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("actualTotalExpenses"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("accumulatedArrears"), ""));
|
|
|
|
|
+ row.createCell(colIndex++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map.get("percentage"), ""));
|
|
|
|
|
+
|
|
|
|
|
+ addRow.setRows(addRow.getRows() + 1);
|
|
|
|
|
+
|
|
|
|
|
+ if (map.get("children") != null) {
|
|
|
|
|
+ writeDataToExcel(sheet, map, addRow);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ 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 void writeDataToExcel(Sheet sheet, Map map, AddRowDTO addRow) {
|
|
|
|
|
+ List<Map> mapList = (List<Map>) map.get("children");
|
|
|
|
|
+
|
|
|
|
|
+ for (int k = 0; k < mapList.size(); k++) {
|
|
|
|
|
+ Map<String, Object> map2 = mapList.get(k);
|
|
|
|
|
+ Row rowChild = sheet.createRow(addRow.getRows());
|
|
|
|
|
+
|
|
|
|
|
+ int colIndexChild = 0;
|
|
|
|
|
+
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(addRow.getRows());
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("serialNum"), ""));
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("name"), ""));
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("curBudgetExpenses"), ""));
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("curMonthReceived"), ""));
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("actualTotalExpenses"), ""));
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("accumulatedArrears"), ""));
|
|
|
|
|
+ rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("percentage"), ""));
|
|
|
|
|
+
|
|
|
|
|
+ addRow.setRows(addRow.getRows() + 1);
|
|
|
|
|
+
|
|
|
|
|
+ if (map2.get("children") != null) {
|
|
|
|
|
+ writeDataToExcel(sheet, map2, addRow);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|