Переглянути джерело

1.汇总表改为树形表格形式展示数据
2.开始添加子项目时,增加终止日和时间区间填写

yanliming 11 місяців тому
батько
коміт
4d6b66ce93

+ 2 - 0
common/src/main/java/com/jpsoft/employment/modules/base/dao/TemplateOptionDAO.java

@@ -17,7 +17,9 @@ public interface TemplateOptionDAO {
 	int delete(String id);
 	List<TemplateOption> list();
 	List<TemplateOption> findByTemplateId(String templateId);
+    List<TemplateOption> findByTemplateIdAndLen(@Param("templateId")String templateId,@Param("length")int length);
 	List<TemplateOption> findByConditions(@Param("searchParams") Map<String, Object> searchParams);
 	String findLastIndexByTemplateId(String templateId);
 	List<TemplateOption> search(Map<String, Object> searchParams, List<Sort> sortList);
+	List<TemplateOption> findByTemplateIdAndNum(@Param("templateId")String templateId,@Param("serialNum")String serialNum,@Param("length")int length);
 }

+ 4 - 0
common/src/main/java/com/jpsoft/employment/modules/base/entity/TemplateOption.java

@@ -78,6 +78,10 @@ public class TemplateOption {
 	@ApiModelProperty(value = "当前预算收入")
 	private BigDecimal curBudgetRevenue;
 
+
+	@ApiModelProperty(value = "是否计算入汇总表(默认计入)")
+	private Boolean isCountSummary;
+
 	@Transient
 	@ApiModelProperty(value = "收入时间区间")
 	private String[] incomeTimeRangeArr;

+ 2 - 0
common/src/main/java/com/jpsoft/employment/modules/base/service/TemplateOptionService.java

@@ -21,7 +21,9 @@ public interface TemplateOptionService {
 	int delete(String id);
 	List<TemplateOption> list();
 	List<TemplateOption> findByTemplateId(String templateId);
+    List<TemplateOption> findByTemplateIdAndLen(String templateId,int length);
 	List<TemplateOption> findByConditions(Map<String, Object> searchParams);
 	String findLastIndexByTemplateId(String templateId);
 	Page<TemplateOption> pageSearch(Map<String, Object> searchParams, int pageNum, int pageSize, boolean count, List<Sort> sortList);
+	List<TemplateOption> findByTemplateIdAndNum(String templateId,String serialNum,int length);
 }

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

@@ -120,7 +120,7 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
         if (count > 0) {
             List<FundIncomeInfo> fundIncomeInfoList = fundIncomeInfoDAO.findByTemplateOptionId(model.getId());
 
-            for (FundIncomeInfo fundIncomeInfo:fundIncomeInfoList) {
+            for (FundIncomeInfo fundIncomeInfo : fundIncomeInfoList) {
                 fundIncomeInfo.setUpdateTime(model.getUpdateTime());
                 fundIncomeInfo.setUpdateBy(model.getUpdateBy());
                 fundIncomeInfo.setName(model.getName());
@@ -156,15 +156,34 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
             templateOption.setCreateBy(subject);
             templateOption.setDelFlag(false);
 
-            String[] arr = templateOption.getDepartmentIdArr();
-            String departmentId = "";
-            for (String departId : arr) {
-                departmentId += departId + ",";
+
+            if (templateOption.getDepartmentIdArr() != null && templateOption.getDepartmentIdArr().length > 0) {
+                String[] arr = templateOption.getDepartmentIdArr();
+                String departmentId = "";
+                for (String departId : arr) {
+                    departmentId += departId + ",";
+                }
+
+                if (StringUtils.isNotEmpty(departmentId)) {
+                    departmentId = departmentId.substring(0, departmentId.lastIndexOf(","));
+                    templateOption.setDepartmentIds(departmentId);
+                }
             }
-            if (StringUtils.isNotEmpty(departmentId)) {
-                departmentId.substring(0, departmentId.lastIndexOf(","));
-                templateOption.setDepartmentIds(departmentId);
+
+            if (templateOption.getIncomeTimeRangeArr() != null && templateOption.getIncomeTimeRangeArr().length > 0) {
+                String[] arr = templateOption.getIncomeTimeRangeArr();
+
+                String incomeTimeStr = "";
+                for (String dateStr : arr) {
+                    incomeTimeStr += dateStr + ",";
+                }
+
+                if (StringUtils.isNotEmpty(incomeTimeStr)) {
+                    incomeTimeStr = incomeTimeStr.substring(0, incomeTimeStr.lastIndexOf(","));
+                    templateOption.setIncomeTimeRange(incomeTimeStr);
+                }
             }
+
             affectCount += templateOptionDAO.insert(templateOption);
         }
 
@@ -197,6 +216,11 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
         return templateOptionDAO.findByTemplateId(templateId);
     }
 
+    @Override
+    public List<TemplateOption> findByTemplateIdAndLen(String templateId, int length) {
+        return templateOptionDAO.findByTemplateIdAndLen(templateId, length);
+    }
+
     @Override
     public List<TemplateOption> findByConditions(Map<String, Object> searchParams) {
         return templateOptionDAO.findByConditions(searchParams);
@@ -215,4 +239,10 @@ public class TemplateOptionServiceImpl implements TemplateOptionService {
 
         return page;
     }
+
+
+    @Override
+    public List<TemplateOption> findByTemplateIdAndNum(String templateId, String serialNum, int length) {
+        return templateOptionDAO.findByTemplateIdAndNum(templateId, serialNum, length);
+    }
 }

+ 4 - 0
common/src/main/resources/mapper/base/FundIncomeInfo.xml

@@ -201,6 +201,7 @@
 		<where>
 			<![CDATA[
 				del_flag=false
+				and year_>=#{startDate}
 				and year_<=#{endDate}
 				and template_option_id = #{templateOptionId}
 			]]>
@@ -261,6 +262,9 @@
 			<if test="searchParams.name != null">
 				and name_ like #{searchParams.name}
 			</if>
+			<if test="searchParams.serialNum != null">
+				and serial_number like #{searchParams.serialNum}
+			</if>
 			<if test="searchParams.templateOptionList != null">
 				<foreach item="item" collection="searchParams.templateOptionList"  open="and template_option_id in (" separator="," close=")">
 					#{item}

+ 22 - 2
common/src/main/resources/mapper/base/TemplateOption.xml

@@ -22,6 +22,8 @@
         <result property="endDate" column="end_date" />
         <result property="chargePerson" column="charge_person" />
         <result property="curBudgetRevenue" column="cur_budget_revenue" />
+        <result property="isCountSummary" column="is_count_summary" />
+
     </resultMap>
     <insert id="insert" parameterType="com.jpsoft.employment.modules.base.entity.TemplateOption">
         <!--
@@ -33,7 +35,7 @@
 		insert into base_template_option
 	    (id_,template_id,serial_num,name_,budget_revenue,index_,create_time,update_time,
 	    create_by,update_by,del_flag,department_ids,is_sum,income_time_range,income_type,
-	    end_date,charge_person,cur_budget_revenue)
+	    end_date,charge_person,cur_budget_revenue,is_count_summary)
 		values
 		(
 #{id,jdbcType=VARCHAR}
@@ -54,6 +56,7 @@
 ,#{endDate,jdbcType= TIMESTAMP }
 ,#{chargePerson,jdbcType=VARCHAR}
 ,#{curBudgetRevenue,jdbcType= NUMERIC }
+,#{isCountSummary,jdbcType= NUMERIC }
 		)
 	]]>
     </insert>
@@ -114,6 +117,9 @@
             <if test="curBudgetRevenue!=null">
                 cur_budget_revenue=#{curBudgetRevenue,jdbcType= NUMERIC },
             </if>
+            <if test="isCountSummary!=null">
+                is_count_summary=#{isCountSummary,jdbcType= NUMERIC },
+            </if>
         </set>
         where id_=#{id}
     </update>
@@ -126,7 +132,7 @@
     <select id="list" resultMap="TemplateOptionMap">
 		select * from base_template_option
 	</select>
-    <select id="findLastIndexByTemplateId" resultType="String">
+    <select id="findLastIndexByTemplateId" resultType="java.lang.String">
 		select index_ from base_template_option
 		where del_flag=false
 		and template_id=#{templateId}
@@ -139,6 +145,13 @@
 		and template_id=#{templateId}
 		order by index_ asc
 	</select>
+    <select id="findByTemplateIdAndLen" resultMap="TemplateOptionMap">
+		select * from base_template_option
+		where del_flag=false
+		and template_id=#{templateId}
+		and length(serial_num)=#{length}
+		order by index_ asc
+	</select>
     <select id="search" parameterType="hashmap" resultMap="TemplateOptionMap">
         <![CDATA[
 			select * from base_template_option
@@ -168,5 +181,12 @@
         </where>
         order by index_ asc
     </select>
+    <select id="findByTemplateIdAndNum" resultMap="TemplateOptionMap">
+        SELECT * FROM base_template_option
+        WHERE del_flag=false and template_id=#{templateId}
+        and serial_num LIKE #{serialNum}
+        and length(serial_num)=#{length}
+        order by index_ asc
+	</select>
 
 </mapper>

+ 244 - 99
web/src/main/java/com/jpsoft/employment/modules/base/controller/FundIncomeInfoController.java

@@ -778,6 +778,8 @@ public class FundIncomeInfoController {
 
             List<Sort> sortList = new ArrayList<>();
             sortList.add(new Sort("template_id", "asc"));
+            sortList.add(new Sort("index_", "asc"));
+
 
             String curMonth = "";
             String startDate = "";
@@ -796,129 +798,172 @@ public class FundIncomeInfoController {
                 searchParams.put("name", "%" + name + "%");
             }
 
+            List<Map> mapList = new ArrayList<>();
 
-            List<TemplateInfo> templateInfoList = templateInfoService.list();
+            BigDecimal curBudgetRevenueTotal = BigDecimal.ZERO;
+            BigDecimal accumulatedArrearsTotal = BigDecimal.ZERO;
 
-            List<String> curTemplateOptionList = new ArrayList<>();
+            List<TemplateInfo> templateInfoList1 = templateInfoService.list();
 
-            if (templateInfoList.size() > 0) {
-                for (TemplateInfo templateInfo : templateInfoList) {
-                    List<TemplateOption> templateOptionList = templateOptionService.findByTemplateId(templateInfo.getId());
-                    for (TemplateOption option : templateOptionList) {
-                        curTemplateOptionList.add(option.getId());
+            for (TemplateInfo templateInfo : templateInfoList1) {
+                Map<String, Object> map = new HashMap<>();
+                map.put("id", templateInfo.getId());
+                map.put("name", templateInfo.getTitle() + "(汇总)");
+                map.put("isSum", true);
+
+                BigDecimal accumulatedArrearsTotalSum = BigDecimal.ZERO;
+
+                BigDecimal totalSum = BigDecimal.ZERO;
+
+                searchParams.put("templateId", templateInfo.getId());
+
+                List<TemplateOption> templateOptionList = templateOptionService.findByTemplateIdAndLen(templateInfo.getId(), 1);
+
+                List<Map> mapList1 = new ArrayList<>();
+
+                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);
+
+
+                        BigDecimal accumulatedArrearsSum = BigDecimal.ZERO;
+
+                        Map<String, BigDecimal> mapSum = fundIncomeInfoService.sumBudgetRevenue(templateOption.getSerialNum() + ".%", startDate, endDate, templateInfo.getId());
+
+                        String sumCurBudgetRevenue = mapSum.get("sumCurBudgetRevenue").toString();
+
+                        map1.put("curBudgetRevenue", sumCurBudgetRevenue);
+
+                        //总体汇总金额
+                        BigDecimal totalSum1 = new BigDecimal(sumCurBudgetRevenue);
+                        totalSum = totalSum.add(totalSum1);
+
+                        List<Map> mapList2 = new ArrayList<>();
+
+//                        searchParams.put("serialNum", templateOption.getSerialNum() + ".%");
+//
+//                        Page<FundIncomeInfo> page = fundIncomeInfoService.pageSearch(searchParams, pageIndex, pageSize, true, sortList);
+//                        for (FundIncomeInfo fundIncomeInfo : page.getResult()) {
+//                            if (!fundIncomeInfo.getIsSum()) {
+//                                Map map2 = new HashMap();
+//                                map2.put("id", fundIncomeInfo.getId());
+//                                map2.put("serialNum", fundIncomeInfo.getSerialNumber());
+//                                map2.put("name", fundIncomeInfo.getName());
+//                                BigDecimal curBudgetRevenue = fundIncomeInfo.getCurBudgetRevenue();
+//
+//                                map2.put("curBudgetRevenue", curBudgetRevenue);
+//
+//                                BigDecimal curMonthReceived = BigDecimal.ZERO;
+//
+//                                if (fundIncomeInfo.getCurMonthReceived() != null) {
+//                                    curMonthReceived = fundIncomeInfo.getCurMonthReceived();
+//                                }
+//
+//                                map2.put("curMonthReceived", curMonthReceived);
+//
+//                                BigDecimal actualTotalRevenue = fundIncomeInfoService.sumBySerialNumber(fundIncomeInfo.getSerialNumber(), curMonth, templateInfo.getId());
+//                                map2.put("actualTotalRevenue", actualTotalRevenue);
+//
+//                                BigDecimal accumulatedArrears = fundIncomeInfo.getCurBudgetRevenue();
+//                                if (actualTotalRevenue != null && accumulatedArrears != null) {
+//                                    accumulatedArrears = accumulatedArrears.subtract(actualTotalRevenue);
+//                                }
+//
+//                                //累计欠费
+//                                map2.put("accumulatedArrears", accumulatedArrears);
+//
+//                                //累计欠费合计
+//                                if (accumulatedArrears.compareTo(BigDecimal.ZERO) > 0) {
+//                                    accumulatedArrearsSum = accumulatedArrearsSum.add(accumulatedArrears);
+//                                }
+//
+//
+//                                BigDecimal percentage = BigDecimal.ZERO;
+//
+//                                if (actualTotalRevenue != null && curBudgetRevenue != null) {
+//                                    if (actualTotalRevenue.compareTo(BigDecimal.ZERO) != 0) {
+//                                        if (actualTotalRevenue.compareTo(curBudgetRevenue) < 1) {
+//                                            percentage = actualTotalRevenue.divide(curBudgetRevenue, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
+//                                        } else {
+//                                            percentage = BigDecimal.valueOf(100);
+//                                        }
+//                                    }
+//                                }
+//
+//                                map2.put("percentage", percentage);
+//
+//                                mapList2.add(map2);
+//                            }
+//                        }
+
+                        map1.put("accumulatedArrears", accumulatedArrearsSum);
+
+                        accumulatedArrearsTotalSum = accumulatedArrearsTotalSum.add(accumulatedArrearsSum);
+
+                        mapList2 = getChildTemplateOption(templateOption.getTemplateId(), templateOption.getSerialNum(), curMonth, startDate, endDate);
+
+
+                        map1.put("children", mapList2);
+
+                        mapList1.add(map1);
                     }
                 }
-            }
-
-            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());
+                map.put("accumulatedArrears", accumulatedArrearsTotalSum);
+                map.put("curBudgetRevenue", totalSum);
 
-                    BigDecimal total = fundIncomeInfoService.sumBySerialNumber(fundIncomeInfo.getSerialNumber(), curMonth, templateId);
+                BigDecimal percentage = BigDecimal.ZERO;
 
-                    map.put("total", total);
+                if (totalSum != null && accumulatedArrearsTotalSum != null) {
+                    BigDecimal tempDec = totalSum.subtract(accumulatedArrearsTotalSum);
 
-                    BigDecimal accumulatedArrears = curBudgetRevenue;
-                    if (total != null && accumulatedArrears != null) {
-                        accumulatedArrears = accumulatedArrears.subtract(total);
+                    if (tempDec.compareTo(BigDecimal.ZERO) != 0) {
+                        percentage = tempDec.divide(totalSum, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                     }
+                }
 
-                    //累计欠费
-                    map.put("accumulatedArrears", accumulatedArrears);
-
-                    //实际总收入
-                    map.put("actualTotalRevenue", total);
+                map.put("percentage", percentage);
 
-                    //构建汇总行
-                    TemplateOption templateOption = templateOptionService.get(fundIncomeInfo.getTemplateOptionId());
+                curBudgetRevenueTotal = curBudgetRevenueTotal.add(totalSum);
+                accumulatedArrearsTotal = accumulatedArrearsTotal.add(accumulatedArrearsTotalSum);
 
-                    TemplateInfo templateInfo = templateInfoService.get(templateOption.getTemplateId());
+                map.put("children", mapList1);
 
-                    String title = templateInfo.getTitle();
+                mapList.add(map);
+            }
 
-                    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);
+            //汇总
+            Map<String, Object> map = new HashMap<>();
+            map.put("id", "-1");
+            map.put("name", "总计");
+            map.put("curBudgetRevenue", curBudgetRevenueTotal);
+            map.put("accumulatedArrears", accumulatedArrearsTotal);
 
-                        if (sumMap != null) {
-                            BigDecimal tempBudgetRevenue = sumMap.get("sumCurBudgetRevenue");
-                            mapSum.put("curBudgetRevenue", tempBudgetRevenue);
-
-                            List<TemplateOption> templateOptionList = templateOptionService.findByTemplateId(templateId);
-                            BigDecimal sumAcc = BigDecimal.ZERO;
-                            for (TemplateOption item : templateOptionList) {
-                                BigDecimal sum = fundIncomeInfoService.sumByTemplateOptionId(item.getId(), startDate, endDate);
-
-                                FundIncomeInfo fundIncome = fundIncomeInfoService.findOneByTemplateOptionId(item.getId(), startDate, endDate);
-
-                                BigDecimal tempNum = BigDecimal.ZERO;
-
-                                if (fundIncome != null) {
-                                    if (fundIncome.getCurBudgetRevenue() != null) {
-                                        tempNum = fundIncome.getCurBudgetRevenue();
-                                    } else {
-                                        tempNum = fundIncome.getBudgetRevenue();
-                                    }
-                                }
-                                if(tempNum!=null){
-                                    BigDecimal c = tempNum.subtract(sum);
-
-                                    if (c.compareTo(BigDecimal.ZERO) > 0) {
-                                        sumAcc = sumAcc.add(c);
-                                    }
-                                }
-                            }
-
-                            mapSum.put("accumulatedArrears", sumAcc);
-                        }
+            BigDecimal percentage = BigDecimal.ZERO;
 
+            if (curBudgetRevenueTotal != null && accumulatedArrearsTotal != null) {
+                BigDecimal tempDec = curBudgetRevenueTotal.subtract(accumulatedArrearsTotal);
 
-                        mapList.add(mapSum);
-                    }
-
-                    tempTemplateId = templateInfo.getId();
-
-                    mapList.add(map);
+                if (tempDec.compareTo(BigDecimal.ZERO) != 0) {
+                    percentage = tempDec.divide(curBudgetRevenueTotal, 4, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100));
                 }
             }
 
+            map.put("percentage", percentage);
+
+            mapList.add(map);
+
             if (exportFlag) {
                 String filePath = summaryListExportXls(mapList);
                 msgResult.setData(filePath);
             } else {
-                Map<String, Object> dataMap = PojoUtils.pageWrapper(page);
+                Map<String, Object> dataMap = new HashMap<>();
                 dataMap.put("data", mapList);
                 msgResult.setData(dataMap);
             }
@@ -934,6 +979,59 @@ public class FundIncomeInfoController {
     }
 
 
+    private List<Map> getChildTemplateOption(String id, String serialNum, String curMonth, String startDate, String endDate) {
+        List<Map> mapList = new ArrayList<>();
+
+        List<TemplateOption> templateOptionList = templateOptionService.findByTemplateIdAndNum(id, serialNum + "%", serialNum.length() + 2);
+
+        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());
+
+            if (item.getIsSum()) {
+                Map<String, BigDecimal> sumMap = fundIncomeInfoService.sumBudgetRevenue(item.getSerialNum() + "%", startDate, endDate, item.getTemplateId());
+
+                String sumCurBudgetRevenue = sumMap.get("sumCurBudgetRevenue").toString();
+
+                map.put("curBudgetRevenue", sumCurBudgetRevenue);
+
+                List<Map> mapChildList = getChildTemplateOption(item.getTemplateId(), item.getSerialNum(), curMonth, startDate, endDate);
+                map.put("children", mapChildList);
+            } else {
+
+                Map<String, BigDecimal> sumMap = fundIncomeInfoService.sumBudgetRevenue(item.getSerialNum(), startDate, endDate, item.getTemplateId());
+
+                BigDecimal curMonthReceived = fundIncomeInfoService.sumByTemplateOptionId(item.getId(),startDate,endDate);
+
+                //本月到账
+                map.put("curMonthReceived", curMonthReceived);
+
+                String sumCurBudgetRevenue = sumMap.get("sumCurBudgetRevenue").toString();
+
+                //预算收入
+                map.put("curBudgetRevenue", sumCurBudgetRevenue);
+
+                BigDecimal actualTotalRevenue = fundIncomeInfoService.sumBySerialNumber(item.getSerialNum(), curMonth, item.getTemplateId());
+
+                //实际总收入
+                map.put("actualTotalRevenue", actualTotalRevenue);
+            }
+
+            mapList.add(map);
+        }
+
+        return mapList;
+    }
+
+
     //导出
     private String summaryListExportXls(List<Map> mapList) {
         String downloadUrl = "";
@@ -944,26 +1042,73 @@ public class FundIncomeInfoController {
         //表头
         Row rowTitle = sheet.createRow(0);
 
-        String[] titles = new String[]{"序号", "收入子项目", "预算收入", "本月到账金额", "实际总收入", "累计欠费", "目前收入完全比率",
+        String[] titles = new String[]{"排序号", "序号", "收入子项目", "预算收入", "本月到账金额", "实际总收入", "累计欠费", "目前收入完全比率",
                 "累计已支出金额", "实际收入结余", "备注"};
 
         for (int i = 0; i < titles.length; i++) {
             Cell cell = rowTitle.createCell(i);
             cell.setCellValue(titles[i]);
         }
+        int addRow = 1;
 
         for (int i = 0; i < mapList.size(); i++) {
             Map<String, Object> map = mapList.get(i);
 
-            Row row = sheet.createRow(i + 1);
+            Row row = sheet.createRow(addRow);
 
             int colIndex = 0;
-            row.createCell(colIndex++).setCellValue(i + 1);
+            row.createCell(colIndex++).setCellValue(addRow);
+            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("curBudgetRevenue"), ""));
             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("percentage"), ""));
+            addRow++;
+
+            if (map.get("children") != null) {
+                List<Map> mapList1 = (List<Map>) map.get("children");
+                for (int j = 0; j < mapList1.size(); j++) {
+                    Map<String, Object> map1 = mapList1.get(j);
+                    Row rowChild = sheet.createRow(addRow);
+
+                    int colIndexChild = 0;
+
+                    rowChild.createCell(colIndexChild++).setCellValue(addRow);
+                    rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map1.get("serialNum"), ""));
+                    rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map1.get("name"), ""));
+                    rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map1.get("curBudgetRevenue"), ""));
+                    rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map1.get("curMonthReceived"), ""));
+                    rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map1.get("actualTotalRevenue"), ""));
+                    rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map1.get("accumulatedArrears"), ""));
+                    rowChild.createCell(colIndexChild++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map1.get("percentage"), ""));
+                    addRow++;
+
+                    if (map1.get("children") != null) {
+                        List<Map> mapList2 = (List<Map>) map1.get("children");
+
+                        for (int k = 0; k < mapList2.size(); k++) {
+                            Map<String, Object> map2 = mapList2.get(k);
+                            Row rowChild2 = sheet.createRow(addRow);
+
+                            int colIndexChild2 = 0;
+
+                            rowChild2.createCell(colIndexChild2++).setCellValue(addRow);
+                            rowChild2.createCell(colIndexChild2++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("serialNum"), ""));
+                            rowChild2.createCell(colIndexChild2++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("name"), ""));
+                            rowChild2.createCell(colIndexChild2++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("curBudgetRevenue"), ""));
+                            rowChild2.createCell(colIndexChild2++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("curMonthReceived"), ""));
+                            rowChild2.createCell(colIndexChild2++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("actualTotalRevenue"), ""));
+                            rowChild2.createCell(colIndexChild2++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("accumulatedArrears"), ""));
+                            rowChild2.createCell(colIndexChild2++).setCellValue(com.jpsoft.employment.modules.common.utils.StringUtils.strValue(map2.get("percentage"), ""));
+                            addRow++;
+                        }
+                    }
+
+                }
+
+            }
 
         }
 

+ 5 - 0
web/src/main/java/com/jpsoft/employment/modules/base/controller/TemplateOptionController.java

@@ -133,6 +133,11 @@ public class TemplateOptionController {
                         }
                         item.setDepartmentNames(departmentNames);
                         item.setDepartmentIdArr(arrayId);
+
+                        if(StringUtils.isNotEmpty(item.getIncomeTimeRange())){
+                            String[] incomeTimeRangeArr = item.getIncomeTimeRange().split(",");
+                            item.setIncomeTimeRangeArr(incomeTimeRangeArr);
+                        }
                     }