Просмотр исходного кода

1.累计到账金额逻辑修改
2.每月到账金额列表逻辑修改

yanliming 1 год назад
Родитель
Сommit
92e87ff708

+ 5 - 1
common/src/main/java/com/jpsoft/employment/modules/base/entity/IncomeModifyRecord.java

@@ -27,7 +27,7 @@ public class IncomeModifyRecord {
 				@ApiModelProperty(value = "原金额")
 	private BigDecimal originalAmount;
 	
-				@ApiModelProperty(value = "修改后当前金额")
+				@ApiModelProperty(value = "当前到账金额")
 	private BigDecimal currentAmount;
 	
 					@ApiModelProperty(value = "创建时间")
@@ -52,5 +52,9 @@ public class IncomeModifyRecord {
 	@Transient
 	@ApiModelProperty(value = "创建人")
 	private String createName;
+
+	@Transient
+	@ApiModelProperty(value = "当月累计到账金额")
+	private BigDecimal curAccumulate;
 	
 		}

+ 8 - 1
common/src/main/java/com/jpsoft/employment/modules/base/service/impl/FundIncomeInfoServiceImpl.java

@@ -67,7 +67,13 @@ public class FundIncomeInfoServiceImpl implements FundIncomeInfoService {
             incomeModifyRecord.setCreateTime(model.getUpdateTime());
             incomeModifyRecord.setIncomeId(model.getId());
             incomeModifyRecord.setOriginalAmount(oldItem.getCurMonthReceived());
-            incomeModifyRecord.setCurrentAmount(model.getCurMonthReceived());
+
+            if(oldItem.getCurMonthReceived()!=null){
+                incomeModifyRecord.setCurrentAmount(model.getCurMonthReceived().subtract(oldItem.getCurMonthReceived()));
+            }
+            else{
+                incomeModifyRecord.setCurrentAmount(model.getCurMonthReceived());
+            }
             incomeModifyRecordDAO.insert(incomeModifyRecord);
         }
 
@@ -78,6 +84,7 @@ public class FundIncomeInfoServiceImpl implements FundIncomeInfoService {
     @Override
     public int generateData(String templateId, String subject) throws ParseException {
         int count = 0;
+
         SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd");
 
         TemplateInfo templateInfo = templateInfoDAO.get(templateId);

+ 19 - 7
common/src/main/resources/mapper/base/FundIncomeInfo.xml

@@ -196,19 +196,26 @@
 			order by create_time
 		]]>
 	</select>
-	<select id="sumBudgetRevenue" resultType="java.util.HashMap">
+	<select id="sumBudgetRevenue" resultType="java.util.Map">
 		<![CDATA[
 			select
 			IFNULL(sum(budget_revenue),0) as 'sumBudget',
 			IFNULL(sum(cur_budget_revenue),0) as 'sumCurBudgetRevenue'
 			from base_fund_income_info
-			where del_flag=false
-			and serial_number like #{serialNumber}
-			and year_>=#{startDate}
-			and year_<=#{endDate}
-			and template_id=#{templateId}
-			order by create_time
 		]]>
+			<where>
+				del_flag=false
+				<if test="serialNumber != null">
+					and serial_number like #{serialNumber}
+				</if>
+				<![CDATA[
+					and year_>=#{startDate}
+					and year_<=#{endDate}
+					and template_id=#{templateId}
+				]]>
+			</where>
+			order by create_time
+
 	</select>
 	<select id="search" parameterType="hashmap" resultMap="FundIncomeInfoMap">
 		<![CDATA[
@@ -232,6 +239,11 @@
 			<if test="searchParams.name != null">
 				and name_ like #{searchParams.name}
 			</if>
+			<if test="searchParams.templateOptionList != null">
+				<foreach item="item" collection="searchParams.templateOptionList"  open="and template_option_id in (" separator="," close=")">
+					#{item}
+				</foreach>
+			</if>
 		</where>
 		<foreach item="sort" collection="sortList"  open="order by" separator=",">
 	        ${sort.name} ${sort.order}

+ 212 - 1
web/src/main/java/com/jpsoft/employment/modules/base/controller/FundIncomeInfoController.java

@@ -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");

+ 7 - 0
web/src/main/java/com/jpsoft/employment/modules/base/controller/IncomeModifyRecordController.java

@@ -228,6 +228,13 @@ public class IncomeModifyRecordController {
             if(user!=null){
                 incomeModifyRecord.setCreateName(user.getRealName());
             }
+
+            if(incomeModifyRecord.getOriginalAmount()!=null){
+                incomeModifyRecord.setCurAccumulate(incomeModifyRecord.getOriginalAmount().add(incomeModifyRecord.getCurrentAmount()));
+            }
+            else{
+                incomeModifyRecord.setCurAccumulate(incomeModifyRecord.getCurrentAmount());
+            }
         }