Преглед изворни кода

1.增加导入其他模板项目
2.增加从excel导入模板项目

yanliming пре 3 месеци
родитељ
комит
051184f9fa

+ 11 - 5
common/src/main/resources/mapper/base/FundIncomeInfo.xml

@@ -198,12 +198,18 @@
 	<select id="sumBySerialNumber" resultType="java.math.BigDecimal">
 		<![CDATA[
 			select IFNULL(sum(cur_month_received),0) from base_fund_income_info
-			where del_flag=false
-			and serial_number=#{serialNumber}
-			and year_<=#{curMonth}
-			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_<=#{curMonth}
+				and template_id=#{templateId}
+			]]>
+		</where>
+		order by create_time
 	</select>
 	<select id="sumByTemplateOptionId" resultType="java.math.BigDecimal">
 		select IFNULL(sum(cur_month_received),0) from base_fund_income_info

+ 329 - 133
web/src/main/java/com/jpsoft/employment/modules/base/controller/FundIncomeInfoController.java

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

+ 209 - 14
web/src/main/java/com/jpsoft/employment/modules/base/controller/TemplateOptionController.java

@@ -1,6 +1,8 @@
 package com.jpsoft.employment.modules.base.controller;
 
 import com.github.pagehelper.Page;
+import com.github.pagehelper.util.StringUtil;
+import com.jpsoft.employment.config.OSSConfig;
 import com.jpsoft.employment.modules.base.dto.TemplateOptionDTO;
 import com.jpsoft.employment.modules.base.entity.DepartmentInfo;
 import com.jpsoft.employment.modules.base.entity.TemplateInfo;
@@ -10,17 +12,27 @@ import com.jpsoft.employment.modules.common.dto.Sort;
 import com.jpsoft.employment.modules.common.dto.MessageResult;
 import com.jpsoft.employment.modules.base.entity.TemplateOption;
 import com.jpsoft.employment.modules.base.service.TemplateOptionService;
+import com.jpsoft.employment.modules.common.utils.OSSUtil;
+import com.jpsoft.employment.modules.common.utils.POIUtils;
 import com.jpsoft.employment.modules.common.utils.PojoUtils;
 import com.jpsoft.employment.modules.sys.entity.User;
 import com.jpsoft.employment.modules.sys.service.UserService;
+import io.swagger.annotations.ApiImplicitParam;
+import io.swagger.annotations.ApiImplicitParams;
 import io.swagger.annotations.ApiOperation;
 import org.apache.commons.lang3.StringUtils;
+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 org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 
@@ -41,6 +53,9 @@ public class TemplateOptionController {
     @Autowired
     private UserService userService;
 
+    @Autowired
+    private OSSConfig ossConfig;
+
     @ApiOperation(value = "创建空记录")
     @GetMapping("create")
     public MessageResult<List<TemplateOption>> create() {
@@ -65,7 +80,7 @@ public class TemplateOptionController {
 
         String lastIndex = templateOptionService.findLastIndexByTemplateId(templateId);
 
-        if(StringUtils.isNotEmpty(lastIndex)){
+        if (StringUtils.isNotEmpty(lastIndex)) {
             templateOption.setIndex(Integer.parseInt(lastIndex));
         }
 
@@ -134,7 +149,7 @@ public class TemplateOptionController {
                         item.setDepartmentNames(departmentNames);
                         item.setDepartmentIdArr(arrayId);
 
-                        if(StringUtils.isNotEmpty(item.getIncomeTimeRange())){
+                        if (StringUtils.isNotEmpty(item.getIncomeTimeRange())) {
                             String[] incomeTimeRangeArr = item.getIncomeTimeRange().split(",");
                             item.setIncomeTimeRangeArr(incomeTimeRangeArr);
                         }
@@ -160,7 +175,6 @@ public class TemplateOptionController {
     }
 
 
-
     @ApiOperation(value = "获取信息")
     @GetMapping("editItem/{id}")
     public MessageResult<TemplateOption> editItem(@PathVariable("id") String id) {
@@ -328,7 +342,7 @@ public class TemplateOptionController {
             TemplateOptionDTO dto = new TemplateOptionDTO();
 
             TemplateInfo templateInfo = templateInfoService.get(id);
-            if(templateInfo!=null){
+            if (templateInfo != null) {
                 dto.setStatus(templateInfo.getStatus());
             }
 
@@ -397,7 +411,7 @@ public class TemplateOptionController {
             TemplateOption templateOption = templateOptionService.get(id);
 
             if (templateOption != null) {
-                if(StringUtils.isNotEmpty(templateOption.getIncomeTimeRange())){
+                if (StringUtils.isNotEmpty(templateOption.getIncomeTimeRange())) {
                     String[] incomeTimeRangeArr = templateOption.getIncomeTimeRange().split(",");
                     templateOption.setIncomeTimeRangeArr(incomeTimeRangeArr);
                 }
@@ -460,11 +474,9 @@ public class TemplateOptionController {
     }
 
 
-
-
-    @ApiOperation(value="添加信息")
+    @ApiOperation(value = "添加信息")
     @PostMapping("addAndFundIncome")
-    public MessageResult<TemplateOption> addAndFundIncome(@RequestBody TemplateOption templateOption,@RequestAttribute String subject){
+    public MessageResult<TemplateOption> addAndFundIncome(@RequestBody TemplateOption templateOption, @RequestAttribute String subject) {
         MessageResult<TemplateOption> msgResult = new MessageResult<>();
 
         try {
@@ -482,9 +494,8 @@ public class TemplateOptionController {
                 msgResult.setResult(false);
                 msgResult.setMessage("数据库添加失败");
             }
-        }
-        catch(Exception ex){
-            logger.error(ex.getMessage(),ex);
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
 
             msgResult.setResult(false);
             msgResult.setMessage(ex.getMessage());
@@ -494,8 +505,6 @@ public class TemplateOptionController {
     }
 
 
-
-
     @ApiOperation(value = "更新名称以及相关收入项目名称")
     @PostMapping("updateNameAndFundIncome")
     public MessageResult<Integer> updateNameAndFundIncome(@RequestBody TemplateOption templateOption, @RequestAttribute String subject) {
@@ -524,4 +533,190 @@ public class TemplateOptionController {
         return msgResult;
     }
 
+
+    @ApiOperation(value = "复制模板项目")
+    @RequestMapping(value = "copyOptionList", method = RequestMethod.POST)
+    public MessageResult<TemplateOptionDTO> copyOptionList(
+            String selectId, String templateId,HttpServletRequest request) {
+        String subject = (String) request.getAttribute("subject");
+
+        //当前用户ID
+        System.out.println(subject);
+
+        MessageResult<TemplateOptionDTO> msgResult = new MessageResult<>();
+
+        User user = userService.get(subject);
+
+        DepartmentInfo departmentUser = departmentInfoService.get(user.getDepartmentId());
+
+        Map<String, Object> searchParams = new HashMap<>();
+
+        if (departmentUser != null) {
+            searchParams.put("departmentId", "%" + departmentUser.getId() + "%");
+        }
+
+        searchParams.put("templateId", selectId);
+
+        TemplateOptionDTO dto = new TemplateOptionDTO();
+
+        TemplateInfo templateInfo = templateInfoService.get(selectId);
+        if (templateInfo != null) {
+            dto.setStatus(templateInfo.getStatus());
+            dto.setTemplateId(templateId);
+        }
+
+        List<TemplateOption> templateOptionList = templateOptionService.findByConditions(searchParams);
+
+        if (templateOptionList.size() == 0) {
+            templateOptionList = new ArrayList<>();
+        } else {
+            for (TemplateOption item : templateOptionList) {
+                if (StringUtils.isNotEmpty(item.getIncomeTimeRange())) {
+                    String[] incomeTimeRangeArr = item.getIncomeTimeRange().split(",");
+                    item.setIncomeTimeRangeArr(incomeTimeRangeArr);
+                }
+
+                if (StringUtils.isNotEmpty(item.getDepartmentIds())) {
+                    String[] arrayId = item.getDepartmentIds().split(",");
+                    String departmentNames = "";
+                    for (String departmentId : arrayId) {
+                        DepartmentInfo departmentInfo = departmentInfoService.get(departmentId);
+                        departmentNames += departmentInfo.getName() + ",";
+                    }
+
+                    if (StringUtils.isNotEmpty(departmentNames)) {
+                        departmentNames = departmentNames.substring(0, departmentNames.lastIndexOf(","));
+                    }
+                    item.setDepartmentNames(departmentNames);
+                }
+
+                if (StringUtils.isNotEmpty(item.getIncomeType())) {
+                    String type = item.getIncomeType();
+                    switch (type) {
+                        case "1":
+                            item.setIncomeTypeN("按月");
+                            break;
+                        case "2":
+                            item.setIncomeTypeN("按年");
+                            break;
+                        case "3":
+                            item.setIncomeTypeN("按季");
+                            break;
+                        case "4":
+                            item.setIncomeTypeN("按学期");
+                            break;
+                    }
+                }
+            }
+        }
+
+        dto.setTemplateId(templateId);
+        dto.setTemplateOptionList(templateOptionList);
+
+        msgResult.setResult(true);
+        msgResult.setData(dto);
+
+        return msgResult;
+    }
+
+
+    @ApiOperation(value = "导入excel数据")
+    @PostMapping("importXls")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "uploadFile", value = "上传文件", required = true, paramType = "form", dataType = "__file")
+    })
+    public MessageResult<TemplateOptionDTO> importXls(MultipartFile uploadFile, String templateId, @RequestAttribute String subject) {
+        MessageResult<TemplateOptionDTO> msgResult = new MessageResult<>();
+
+        try {
+            User user = userService.get(subject);
+
+            DepartmentInfo departmentUser = departmentInfoService.get(user.getDepartmentId());
+
+            Map<String, Object> searchParams = new HashMap<>();
+
+            if (departmentUser != null) {
+                searchParams.put("departmentId", "%" + departmentUser.getId() + "%");
+            }
+
+            searchParams.put("templateId", templateId);
+
+            TemplateOptionDTO dto = new TemplateOptionDTO();
+
+            TemplateInfo templateInfo = templateInfoService.get(templateId);
+            if (templateInfo != null) {
+                dto.setStatus(templateInfo.getStatus());
+            }
+
+            POIUtils poiUtils = new POIUtils(uploadFile.getInputStream());
+            int sheetIndex = 0;
+            Sheet sheet1 = poiUtils.getSheetAt(sheetIndex);
+
+            int count = sheet1.getLastRowNum();
+
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+            List<TemplateOption> templateOptionList = new ArrayList<>();
+
+            for (int rowIndex = 1; rowIndex <= count; rowIndex++) {
+                String serialNum = poiUtils.getCellValue(sheetIndex, rowIndex, 0).toString().replace(" ", "");
+                String name = poiUtils.getCellValue(sheetIndex, rowIndex, 1).toString().replace(" ", "");
+                String isSumStr = poiUtils.getCellValue(sheetIndex, rowIndex, 2).toString().replace(" ", "");
+                String budgetRevenueStr = poiUtils.getCellValue(sheetIndex, rowIndex, 3).toString().replace(" ", "");
+                String incomeTimeRangeStr = poiUtils.getCellValue(sheetIndex, rowIndex, 4).toString();
+                String endDateStr = poiUtils.getCellValue(sheetIndex, rowIndex, 5).toString();
+                String chargePerson = poiUtils.getCellValue(sheetIndex, rowIndex, 6).toString().replace(" ", "");
+                String indexStr = poiUtils.getCellValue(sheetIndex, rowIndex, 7).toString().replace(" ", "");
+
+
+                TemplateOption templateOption = new TemplateOption();
+                templateOption.setSerialNum(serialNum);
+                templateOption.setName(name);
+                if (isSumStr.equals("是")) {
+                    templateOption.setIsSum(true);
+                } else {
+                    templateOption.setIsSum(false);
+                }
+
+                if (StringUtils.isNotEmpty(budgetRevenueStr)) {
+                    BigDecimal budgetRevenue = new BigDecimal(budgetRevenueStr);
+                    templateOption.setBudgetRevenue(budgetRevenue);
+                }
+
+                if(StringUtils.isNotEmpty(incomeTimeRangeStr)){
+                    templateOption.setIncomeTimeRange(incomeTimeRangeStr);
+                    String[] incomeTimeRangeArr = templateOption.getIncomeTimeRange().split(",");
+                    templateOption.setIncomeTimeRangeArr(incomeTimeRangeArr);
+                }
+
+                if(StringUtils.isNotEmpty(endDateStr)){
+                    templateOption.setEndDate(sdf.parse(endDateStr));
+                }
+
+                templateOption.setChargePerson(chargePerson);
+
+                if(StringUtils.isNotEmpty(indexStr)){
+                    templateOption.setIndex(Integer.parseInt(indexStr));
+                }
+
+
+                templateOptionList.add(templateOption);
+            }
+
+            dto.setTemplateId(templateId);
+            dto.setTemplateOptionList(templateOptionList);
+
+            msgResult.setResult(true);
+            msgResult.setData(dto);
+
+        } catch (Exception ex) {
+            logger.error(ex.getMessage(), ex);
+
+            msgResult.setResult(false);
+            msgResult.setMessage(ex.getMessage());
+        }
+
+        return msgResult;
+    }
+
 }

+ 433 - 0
web/src/main/java/com/jpsoft/employment/utils/POIUtils.java

@@ -0,0 +1,433 @@
+package com.jpsoft.lotteryActivity.utils;
+
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.hssf.converter.ExcelToHtmlConverter;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.*;
+import org.w3c.dom.Document;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import java.io.*;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Description:POI解析Excel获取所有数据(支持xls/xlsx)
+ *
+ * @author zhjun 2015-11-5
+ */
+public class POIUtils {
+    InputStream ins = null;
+    Workbook wb = null;
+    List<Object[]> dataList = new ArrayList<Object[]>(100);
+
+    public static void createBorder(CellStyle cellStyle) {
+        if (cellStyle != null) {
+            cellStyle.setBorderTop(BorderStyle.THIN);
+            cellStyle.setBorderBottom(BorderStyle.THIN);
+            cellStyle.setBorderLeft(BorderStyle.THIN);
+            cellStyle.setBorderRight(BorderStyle.THIN);
+            cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);
+        }
+    }
+
+    public static Cell setCellValue(Row row, int i, String value) {
+        // TODO Auto-generated method stub
+        Cell cell = row.createCell(i);
+        cell.setCellValue(value);
+
+        return cell;
+    }
+
+    public static Cell setCellValue(Row row, int i, int value) {
+        // TODO Auto-generated method stub
+        Cell cell = row.createCell(i);
+        cell.setCellValue(value);
+
+        return cell;
+    }
+
+    public static Cell setCellValue(Row row, int cellIndex, CellStyle cellStyle, Object value) {
+        Cell cell = row.createCell(cellIndex);
+        cell.setCellStyle(cellStyle);
+
+        if (value != null) {
+            if (value instanceof BigDecimal) {
+                cell.setCellValue(((BigDecimal) value).doubleValue());
+            } else if (value instanceof String) {
+                cell.setCellValue(value.toString());
+            } else if (value instanceof Integer) {
+                cell.setCellValue(Double.valueOf(value.toString()));
+            } else if (value instanceof Long) {
+                cell.setCellValue(Double.valueOf(value.toString()));
+            }
+        }
+
+        return cell;
+    }
+
+    public static String xls2html(HSSFWorkbook wb) {
+        String result = "";
+
+        try {
+            ExcelToHtmlConverter converter = new ExcelToHtmlConverter(DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument());
+            converter.setOutputColumnHeaders(false);
+            converter.setOutputRowNumbers(false);
+
+            converter.processWorkbook(wb);
+
+            Document htmlDocument = converter.getDocument();
+            ByteArrayOutputStream out = new ByteArrayOutputStream();
+            DOMSource domSource = new DOMSource(htmlDocument);
+            StreamResult streamResult = new StreamResult(out);
+            TransformerFactory tf = TransformerFactory.newInstance();
+            Transformer serializer = tf.newTransformer();
+            serializer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+            serializer.setOutputProperty(OutputKeys.INDENT, "yes");
+            serializer.setOutputProperty(OutputKeys.METHOD, "html");
+            serializer.transform(domSource, streamResult);
+            out.close();
+
+            result = new String(out.toByteArray(), "UTF-8");
+        } catch (Exception ex) {
+            ex.printStackTrace();
+        }
+
+        return result;
+    }
+
+    /**
+     * 通过流读取
+     *
+     * @param ins
+     */
+    public POIUtils(InputStream ins) {
+        try {
+            wb = WorkbookFactory.create(ins);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ins != null) {
+                try {
+                    ins.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    public POIUtils() {
+        this.wb = new HSSFWorkbook();
+    }
+
+    public POIUtils(Workbook workbook) {
+        this.wb = workbook;
+    }
+
+    public Sheet getSheetAt(int sheetIndex){
+        return wb.getSheetAt(sheetIndex);
+    }
+
+    public Workbook getWorkbook(){
+        return wb;
+    }
+
+    /**
+     * 通过文件读取
+     *
+     * @param file
+     */
+    public POIUtils(File file) {
+        try {
+            ins = new FileInputStream(file);
+            wb = WorkbookFactory.create(ins);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ins != null) {
+                try {
+                    ins.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 通过文件路径读取
+     *
+     * @param path
+     */
+    public POIUtils(String path) {
+        try {
+            ins = new FileInputStream(path);
+            wb = WorkbookFactory.create(ins);
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (ins != null) {
+                try {
+                    ins.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+
+    /**
+     * 取Excel所有数据,包含header
+     *
+     * @return List<Object   [   ]>
+     */
+    public List<Object[]> getAllData(int sheetIndex) {
+        int columnNum = 0;
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        if (sheet.getRow(0) != null) {
+            columnNum = sheet.getRow(0).getLastCellNum() - sheet.getRow(0).getFirstCellNum();
+        }
+        if (columnNum > 0) {
+            for (Row row : sheet) {
+                Object[] singleRow = new Object[columnNum];
+                int n = 0;
+
+                for (int i = 0; i < columnNum; i++) {
+                    Cell cell = row.getCell(i, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+                    singleRow[n] = getCellValue(cell);
+                    n++;
+                }
+
+                //在后续方法中校验
+//				if("".equals(singleRow[0])){continue;}//如果第一列为空,跳过
+
+                dataList.add(singleRow);
+            }
+        }
+        return dataList;
+    }
+
+    public List<Object[]> getAllData(int sheetIndex, int firstRowNum) {
+        int columnNum = 0;
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        if (sheet.getRow(0) != null) {
+            columnNum = sheet.getRow(firstRowNum).getLastCellNum();
+        }
+        if (columnNum > 0) {
+            for (Row row : sheet) {
+                Object[] singleRow = new Object[columnNum];
+                int n = 0;
+                for (int i = 0; i < columnNum; i++) {
+                    Cell cell = row.getCell(i, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+                    singleRow[n] = getCellValue(cell);
+                    n++;
+                }
+                if ("".equals(singleRow[0])) {
+                    continue;
+                }//如果第一行为空,跳过
+                dataList.add(singleRow);
+            }
+        }
+        return dataList;
+    }
+
+    public Object getCellValue(int sheetIndex,int rowIndex,int colIndex){
+        Row row = wb.getSheetAt(sheetIndex).getRow(rowIndex);
+        Cell cell = row.getCell(colIndex, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
+
+        return getCellValue(cell);
+    }
+
+    /**
+     * 获取列的数据信息
+     *
+     * @param cell
+     * @return
+     */
+    public Object getCellValue(Cell cell) {
+        Object cellValue = null;
+        FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
+
+        switch (cell.getCellType()) {
+            case BLANK:
+                cellValue = "";
+                break;
+            case BOOLEAN:
+                cellValue = Boolean.toString(cell.getBooleanCellValue());
+                break;
+            //数值
+            case NUMERIC:
+                DecimalFormat df = new DecimalFormat("0");
+                double value = cell.getNumericCellValue();
+
+                if (value > Math.floor(value)) {
+                    df = new DecimalFormat("0.00");
+                }
+
+                cellValue = df.format(value);
+                break;
+            case STRING:
+                cellValue = cell.getStringCellValue().trim();
+                break;
+            case ERROR:
+                cellValue = "";
+                break;
+            case FORMULA:
+                CellValue cv = evaluator.evaluate(cell);
+
+                if (cv.getCellType() == CellType.STRING) {
+                    cellValue = cv.getStringValue();
+                } else if (cv.getCellType() == CellType.NUMERIC) {
+                    cellValue = cv.getNumberValue();
+                } else {
+                    cellValue = cell.getCellFormula();
+                }
+
+                break;
+            default:
+                cellValue = "";
+        }
+
+        return cellValue;
+    }
+
+
+    /**
+     * 返回Excel最大行index值,实际行数要加1
+     *
+     * @return
+     */
+    public int getRowNum(int sheetIndex) {
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        return sheet.getLastRowNum();
+    }
+
+    /**
+     * 返回数据的列数
+     *
+     * @param sheetIndex
+     * @return
+     */
+    public int getColumnNum(int sheetIndex) {
+        Sheet sheet = wb.getSheetAt(sheetIndex);
+        Row row = sheet.getRow(0);
+        if (row != null && row.getLastCellNum() > 0) {
+            return row.getLastCellNum();
+        }
+        return 0;
+    }
+
+    /**
+     * 获取某一行数据
+     *
+     * @param rowIndex 计数从0开始,rowIndex为0代表header行
+     * @return
+     */
+    public Object[] getRowData(int sheetIndex, int rowIndex) {
+        Object[] dataArray = null;
+        if (rowIndex > this.getColumnNum(sheetIndex)) {
+            return dataArray;
+        } else {
+//			dataArray = new Object[this.getColumnNum(sheetIndex)];
+            return this.dataList.get(rowIndex);
+        }
+    }
+
+
+    /**
+     * 获取某一列数据
+     *
+     * @param colIndex
+     * @return
+     */
+    public Object[] getColumnData(int sheetIndex, int colIndex) {
+        Object[] dataArray = null;
+        if (colIndex > this.getColumnNum(sheetIndex)) {
+            return dataArray;
+        } else {
+            if (this.dataList != null && this.dataList.size() > 0) {
+                dataArray = new Object[this.getRowNum(sheetIndex) + 1];
+                int index = 0;
+                for (Object[] rowData : dataList) {
+                    if (rowData != null) {
+                        dataArray[index] = rowData[colIndex];
+                        index++;
+                    }
+                }
+            }
+        }
+
+        return dataArray;
+    }
+
+    public static void main(String[] args) {
+        POIUtils re = new POIUtils("D:\\fpb.xlsx");
+
+        List<Object[]> objList = re.getAllData(0);
+
+        for (int i = 0; i < objList.size(); i++) {
+            String result = "";
+            for (int j = 0; j < objList.get(i).length; j++) {
+                result += objList.get(i)[j] + "_";
+            }
+
+            System.out.println(result);
+        }
+    }
+
+    public Workbook exportErrorXls(int sheetIndex,int validateColIndex, int rowNum) {
+        Workbook destBook = new HSSFWorkbook();
+        Sheet destSheet = destBook.createSheet();
+
+        //复制列头
+        Sheet srcSheet = wb.getSheetAt(sheetIndex);
+        Row srcHeaderRow = wb.getSheetAt(sheetIndex).getRow(0);
+        Row destHeaderRow = destSheet.createRow(0);
+
+        for (int i=0;i<srcHeaderRow.getLastCellNum();i++){
+            if (srcHeaderRow.getCell(i)!=null) {
+                destHeaderRow.createCell(i).setCellValue(srcHeaderRow.getCell(i).getStringCellValue());
+            }
+            else{
+                break;
+            }
+        }
+
+        int srcRowIndex = 1;
+        int destRowIndex = 1;
+
+        while(srcRowIndex<= rowNum){
+            Row dataRow1 = srcSheet.getRow(srcRowIndex);
+
+            if(dataRow1!=null) {
+                Cell cell = dataRow1.getCell(validateColIndex);
+
+                if (cell != null && StringUtils.isNotEmpty(cell.getStringCellValue())) {
+                    Row dataRow2 = destSheet.createRow(destRowIndex);
+
+                    int lastCellNum = Math.min(dataRow1.getLastCellNum(),100);
+
+                    for (int i = 0; i < lastCellNum; i++) {
+                        if (dataRow1.getCell(i) != null) {
+                            dataRow2.createCell(i).setCellValue((String) getCellValue(0, srcRowIndex, i));
+                        }
+                    }
+
+                    destRowIndex++;
+                }
+            }
+
+            srcRowIndex++;
+        }
+
+        return destBook;
+    }
+}