Bladeren bron

结算多页统计总和

qianxb 1 jaar geleden
bovenliggende
commit
fb19533200

+ 182 - 103
blade-service/blade-land/src/main/java/org/springblade/land/service/impl/ClearingAgreementInfoServiceImpl.java

@@ -24,6 +24,7 @@ import org.springblade.land.mapper.ClearingAgreementInfoMapper;
 import org.springblade.land.mapper.CompensationInfoMapper;
 import org.springblade.land.mapper.SettlementIntervalMapper;
 import org.springblade.land.service.*;
+import org.springblade.land.utils.CommonUtils;
 import org.springblade.land.utils.FileUtils;
 import org.springblade.land.vo.AreaPictureVO;
 import org.springblade.land.vo.ClearingAgreementInfoVO;
@@ -70,36 +71,35 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         //是新增还是修改
         Boolean isAdd = false;
         List<Long> ids = Func.toLongList(agreementIds);
-        List<AgreementLinkTable> linkTables = new ArrayList<>();
         if (info.getId() == null) {
             isAdd = true;
-            //复制一份当前合同下对应的结算协议到中间表
-            Long agreeId = SnowFlakeUtil.getId();
-            //先新增中间表,
-            List<WbsTreePrivate> tables = compensationInfoService.getTables(info.getProjectId(), info.getType() + 3);
-            linkTables = tables.stream().map(l -> {
-                AgreementLinkTable table = new AgreementLinkTable();
-                table.setTableId(Long.parseLong(l.getInitTableId()));
-                table.setProjectId(info.getProjectId());
-//            table.setTableDataId(SnowFlakeUtil.getId());
-//            table.setId(SnowFlakeUtil.getId());
-                table.setAgreementId(agreeId);
-                table.setPrivateId(l.getId());
-                table.setSort(l.getSort());
-                table.setExcelId(l.getExcelId());
-                table.setHtmlUrl(l.getHtmlUrl());
-                table.setTableName(l.getNodeName());
-                return table;
-            }).collect(Collectors.toList());
-            linkTableService.saveBatch(linkTables);
-            info.setId(agreeId);
+            info.setId(SnowFlakeUtil.getId());
         } else {
-            //存在则直接获取所有结算表单
-            linkTables = linkTableService.getByAgreementId(info.getId());
+            //存在则删除所有结算表单
+            linkTableService.deleteByAgreementIds(Arrays.asList(info.getId()));
             //修改则先还原之前补偿协议的状态
             ClearingAgreementInfo agreementInfo = this.getById(info.getId());
             compensationInfoService.batchUpdateStatus(Func.toLongList(agreementInfo.getAgreementIds()), 0);
         }
+        //复制一份当前合同下对应的结算协议到中间表
+
+        //先新增中间表,
+        List<WbsTreePrivate> tables = compensationInfoService.getTables(info.getProjectId(), info.getType() + 3);
+        List<AgreementLinkTable> linkTables = tables.stream().map(l -> {
+            AgreementLinkTable table = new AgreementLinkTable();
+            table.setTableId(Long.parseLong(l.getInitTableId()));
+            table.setProjectId(info.getProjectId());
+//            table.setTableDataId(SnowFlakeUtil.getId());
+//            table.setId(SnowFlakeUtil.getId());
+            table.setAgreementId(info.getId());
+            table.setPrivateId(l.getId());
+            table.setSort(l.getSort());
+            table.setExcelId(l.getExcelId());
+            table.setHtmlUrl(l.getHtmlUrl());
+            table.setTableName(l.getNodeName());
+            return table;
+        }).collect(Collectors.toList());
+        linkTableService.saveBatch(linkTables);
         //批量修改选中的状态
         compensationInfoService.batchUpdateStatus(ids, 1);
         //获取所有选中的补偿协议
@@ -131,11 +131,11 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         }
         //循环结算协议的统计字段,把补偿协议统计出来的字段设置到结算协议
         //生成封面
-        buildPdf1(linkTables.get(0), info.getStage());
+//        buildPdf1(linkTables.get(0), info.getStage());
         //生成补偿结算表
-        buildPdf2(linkTables.get(1),info.getAreaId());
+//        buildPdf2(linkTables.get(1),info.getAreaId());
         //生成补偿费发放统计表
-        buildPdf3(linkTables.get(2),ids);
+//        buildPdf3(linkTables.get(2),ids);
         //生成补偿费明细表
         buildPdf4(linkTables.get(3),ids,info.getStage());
         //生成补偿资金数量分配表
@@ -160,21 +160,21 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
             //获取项目名称
             String projectName = jdbcTemplate.queryForObject("select project_name from m_project_info where id = " + linkTable.getProjectId(), new BeanPropertyRowMapper<>(String.class));
             List<WbsFormElement> list = baseMapper.getTableElement(linkTable.getTableId());
-            Map<String, Object> DataInfo = new HashMap<>();
+            Map<Long,Map<String, Object>> dataInfos = new LinkedHashMap<>();
             //获取所有的补偿协议映射表中的发放表
             List<AgreementLinkTable> assignTable = baseMapper.getAllAssignTable(ids, "发放表");
             List<Long> longs = assignTable.stream().map(l -> l.getTableDataId()).collect(Collectors.toList());
             //获取发放表的配置
             List<WbsFormElement> dataElements = baseMapper.getTableElement(assignTable.get(0).getTableId());
             if (dataElements == null || dataElements.size() == 0){
-                compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+                compensationInfoService.getBussPdfInfo(linkTable.getId(), null);
             }
             Map<String, Integer> dataMap = dataElements.stream().collect(Collectors.toMap(WbsFormElement::getEKey, WbsFormElement::getDynamicDict));
             //获取所有补偿费发放表中的数据
             List<TableDataVO> dataVOS = compensationInfoMapper.getBussDataInfoByDataIds(longs);
             dataVOS = dataVOS.stream().filter(l -> dataMap.get(l.getDictKey()) != null).collect(Collectors.toList());
             if (dataVOS.size() == 0){
-                compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+                compensationInfoService.getBussPdfInfo(linkTable.getId(), null);
             }
             dataVOS.stream().forEach(l->l.setDictValue(dataMap.get(l.getDictKey())));
             Map<Integer, List<TableDataVO>> listMap = dataVOS.stream().collect(Collectors.groupingBy(TableDataVO::getDictValue));
@@ -203,24 +203,25 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                 }).collect(Collectors.toList());
                 allKey = allKey.stream().filter(l -> overMap.get(l.getDictKey()) != null).collect(Collectors.toList());
                 if (allKey.size() == 0){
-                    compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+                    compensationInfoService.getBussPdfInfo(linkTable.getId(), null);
                 }
                 allKey.stream().forEach(l->l.setDictValue(overMap.get(l.getDictKey())));
                 Map<Integer, List<TableDataVO>> listMap2 = allKey.stream().collect(Collectors.groupingBy(TableDataVO::getDictValue));
 
                 //确定长度的key的字典,因为其他字段可能为空,姓名不为空,所以通过姓名获取数据长度
-//                List<Integer> batchKey = Arrays.asList(80);
                 Integer nameDict = 80;
-                //非必填重复key的字典
+                //重复key的字典
                 List<Integer> batchKey2 = Arrays.asList(82, 400, 85, 86);
+                //重复key需要统计总和的字典
+                List<Integer> batchKey3 = Arrays.asList(82, 400, 85, 86);
                 //统计补偿总和
-                BigDecimal big = new BigDecimal(0);
+                Map<Long,BigDecimal> big = new HashMap<>();
                 //土地总和
-                BigDecimal big2 = new BigDecimal(0);
+                Map<Long,BigDecimal> big2 = new HashMap<>();
                 //青苗及地上总和
-                BigDecimal big3 = new BigDecimal(0);
+                Map<Long,BigDecimal> big3 = new HashMap<>();
                 //时段奖总和
-                BigDecimal big4 = new BigDecimal(0);
+                Map<Long,BigDecimal> big4 = new HashMap<>();
                 //当前数据有多少行
                 Integer rows = 0;
                 //当前数据的第一行
@@ -229,6 +230,10 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                 Integer oneTableRows = 0;
                 //判断每一张表有多少行,合并表时用于填充统计
                 Map<Long,Integer> tableRows = new LinkedHashMap<>();
+                //一共需要多少表
+                Integer tableTotal = 0;
+                //表单id,按顺序
+                LinkedList<Long> tableIds = new LinkedList<>();
                 //先设置姓名,查看一共有多少条数据
                 if (listMap.get(nameDict) != null && listMap.get(nameDict).size() > 0) {
                     List<TableDataVO> voList = listMap.get(nameDict);
@@ -249,26 +254,59 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                     List<String> keys = new ArrayList<>();
                     voList2 = voList2.stream().sorted(Comparator.comparing(TableDataVO::getDictRow)).collect(Collectors.toList());
                     keys.addAll(voList2.stream().map(l -> l.getTabKey()).collect(Collectors.toList()));
-                    //设置单表总行数
+                    //单表总行数
                     oneTableRows = keys.size();
-                    //!!暂时没判断多页,到时候要分隔集合
-                    for (int i = 0; i < data.size(); i++) {
-                        DataInfo.put(keys.get(i), data.get(i));
+                    //判断数据长度是否超过单表总行数
+                    List<List<Object>> lists = CommonUtils.splitList(data, oneTableRows);
+                    tableTotal = lists.size();
+                    for (int i = 0; i < tableTotal; i++) {
+                        Map<String, Object> DataInfo = new HashMap<>();
+                        if (i == 0){
+                            dataInfos.put(linkTable.getId(),DataInfo);
+                            tableIds.add(linkTable.getId());
+                        }else {
+                            //复制表,返回表id
+                            Long aLong = this.copyTable(linkTable);
+                            dataInfos.put(aLong,DataInfo);
+                            tableIds.add(aLong);
+                        }
+                    }
+                    //为多表的统计字段设置默认值
+                    for (Long id : tableIds) {
+                        big.put(id,new BigDecimal(0));
+                        big2.put(id,new BigDecimal(0));
+                        big3.put(id,new BigDecimal(0));
+                        big4.put(id,new BigDecimal(0));
+                    }
+
+                    //多页分开存入
+                    for (int i = 0; i < tableTotal; i++) {
+                        Map<String, Object> DataInfo = dataInfos.get(tableIds.get(i));
+                        List<Object> data2 = lists.get(i);
+                        for (int j = 0; j < data2.size(); j++) {
+                            DataInfo.put(keys.get(j), data2.get(j));
+                        }
                     }
                     elementMap.remove(nameDict);
                 }else {
-                    compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+                    compensationInfoService.getBussPdfInfo(linkTable.getId(), null);
                 }
                 for (Integer dict : elementMap.keySet()) {
                     if (batchKey2.contains(dict)) {
                         if (dict.equals(400)) {
                             //单独处理青苗+地面
                             //取出83(青苗)数据集合
-                            List<TableDataVO> voList = listMap.get(83);
+                            List<TableDataVO> voList = new ArrayList<>();
+                            if (listMap.get(83) != null) {
+                                voList = listMap.get(83);
+                            }
                             //重置数据顺序,先按表单分组,再按照行顺序重新装入集合
                             Map<Long, List<TableDataVO>> map = voList.stream().collect(Collectors.groupingBy(TableDataVO::getPKeyId));
                             //取出84(地面)数据集合
-                            List<TableDataVO> voList2 = listMap.get(84);
+                            List<TableDataVO> voList2 = new ArrayList<>();
+                            if (listMap.get(84) != null){
+                                voList2 = listMap.get(84);
+                            }
                             //重置数据顺序,先按表单分组,再按照行顺序重新装入集合
                             Map<Long, List<TableDataVO>> map2 = voList2.stream().collect(Collectors.groupingBy(TableDataVO::getPKeyId));
                             //根据总行数和起始位置,生成青苗+地面的集合
@@ -276,26 +314,26 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                             for (Long aLong : tableRows.keySet()) {
                                 Integer ro = tableRows.get(aLong);
                                 //获取当前表青苗集合,并且按照行转换为map
-                                List<TableDataVO> vos = map.get(aLong);
+                                List<TableDataVO> vos = new ArrayList<>();
                                 //因为可能整张表都没填写,所以为null
-                                if (vos == null) {
-                                    vos = new ArrayList<>();
+                                if (map.size() != 0 && map.get(aLong) != null) {
+                                    vos = map.get(aLong);
                                 }
                                 Map<Integer, BigDecimal> map3 = vos.stream().collect(Collectors.groupingBy(TableDataVO::getDictRow,
                                         Collectors.mapping(l -> new BigDecimal(l.getTabVal()), Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
                                 //获取当前表地面集合
-                                List<TableDataVO> vos2 = map2.get(aLong);
-                                if (vos2 == null) {
-                                    vos2 = new ArrayList<>();
+                                List<TableDataVO> vos2 = new ArrayList<>();
+                                if (map2.size() != 0 && map2.get(aLong) != null) {
+                                    vos2 = map2.get(aLong);
                                 }
                                 Map<Integer, BigDecimal> map4 = vos2.stream().collect(Collectors.groupingBy(TableDataVO::getDictRow,
                                         Collectors.mapping(l -> new BigDecimal(l.getTabVal()), Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
                                 for (int i = oneRows; i < (oneRows + ro); i++) {
                                     BigDecimal value = new BigDecimal(0);
-                                    if (map3.get(i) != null) {
+                                    if (map3.size() != 0 && map3.get(i) != null) {
                                         value = value.add(map3.get(i));
                                     }
-                                    if (map4.get(i) != null) {
+                                    if (map4.size() != 0 && map4.get(i) != null) {
                                         value = value.add(map4.get(i));
                                     }
                                     values.add(value);
@@ -305,17 +343,28 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                             //取出位置集合
                             List<TableDataVO> voList3 = listMap2.get(dict);
                             List<String> keys = new ArrayList<>();
-                            keys.addAll(voList3.stream().sorted(Comparator.comparing(TableDataVO::getDictRow)).map(l -> l.getTabKey()).collect(Collectors.toList()));
                             //重置key位置,按照行从小到大
-                            //!!暂时没判断多页,到时候要分隔集合
-                            for (int i = 0; i < rows; i++) {
-                                DataInfo.put(keys.get(i), values.get(i));
-                                //如果是合计的就要添加进总合计
-                                big3 = big3.add(new BigDecimal(values.get(i) + ""));
+                            keys.addAll(voList3.stream().sorted(Comparator.comparing(TableDataVO::getDictRow)).map(l -> l.getTabKey()).collect(Collectors.toList()));
+                            //
+                            List<List<Object>> lists = CommonUtils.splitList(values, oneTableRows);
+                            //多页分开存入
+                            for (int i = 0; i < tableTotal; i++) {
+                                Map<String, Object> DataInfo = dataInfos.get(tableIds.get(i));
+                                List<Object> data2 = lists.get(i);
+                                BigDecimal decimal = new BigDecimal(0);
+                                for (int j = 0; j < data2.size(); j++) {
+                                    DataInfo.put(keys.get(j), data2.get(j));
+                                    decimal = decimal.add(new BigDecimal(data2.get(i) + ""));
+                                }
+                                big3.put(tableIds.get(i),decimal);
                             }
+
                         } else {
                             //取出数据
-                            List<TableDataVO> voList = listMap.get(dict);
+                            List<TableDataVO> voList = new ArrayList<>();
+                            if (listMap.get(dict) != null){
+                                voList = listMap.get(dict);
+                            }
                             //重置数据顺序,先按表单分组,再按照行顺序重新装入集合
                             Map<Long, List<TableDataVO>> map = voList.stream().collect(Collectors.groupingBy(TableDataVO::getPKeyId));
                             //根据总行数和起始位置,生成青苗+地面的集合
@@ -323,12 +372,15 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                             for (Long aLong : tableRows.keySet()) {
                                 Integer ro = tableRows.get(aLong);
                                 //获取当前表青苗集合,并且按照行转换为map
-                                List<TableDataVO> vos = map.get(aLong);
+                                List<TableDataVO> vos = new ArrayList<>();
+                                if (map.size() != 0 && map.get(aLong) != null) {
+                                    vos = map.get(aLong);
+                                }
                                 Map<Integer, BigDecimal> map3 = vos.stream().collect(Collectors.groupingBy(TableDataVO::getDictRow,
                                         Collectors.mapping(l -> new BigDecimal(l.getTabVal()), Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
                                 for (int i = oneRows; i < (oneRows + ro); i++) {
                                     BigDecimal value = new BigDecimal(0);
-                                    if (map3.get(i) != null) {
+                                    if (map3.size() != 0 &&  map3.get(i) != null) {
                                         value = value.add(map3.get(i));
                                     }
                                     values.add(value);
@@ -338,22 +390,30 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                             List<TableDataVO> voList3 = listMap2.get(dict);
                             List<String> keys = new ArrayList<>();
                             keys.addAll(voList3.stream().sorted(Comparator.comparing(TableDataVO::getDictRow)).map(l -> l.getTabKey()).collect(Collectors.toList()));
-                            //重置key位置,按照行从小到大
-                            //!!暂时没判断多页,到时候要分隔集合
-                            for (int i = 0; i < rows; i++) {
-                                DataInfo.put(keys.get(i), values.get(i));
-                                //如果是合计的就要添加进总合计
+                            //判断数据长度是否超过单表总行数
+                            List<List<Object>> lists = CommonUtils.splitList(values, oneTableRows);
+                            //多页分开存入
+                            for (int i = 0; i < tableTotal; i++) {
+                                Map<String, Object> DataInfo = dataInfos.get(tableIds.get(i));
+                                List<Object> data2 = lists.get(i);
+                                BigDecimal decimal = new BigDecimal(0);
+                                for (int j = 0; j < data2.size(); j++) {
+                                    DataInfo.put(keys.get(j), data2.get(j));
+                                    if (batchKey3.contains(dict)){
+                                        decimal = decimal.add(new BigDecimal(data2.get(j)+""));
+                                    }
+                                }
                                 if (dict == 82) {
                                     //土地
-                                    big2 = big2.add(new BigDecimal(values.get(i) + ""));
+                                    big2.put(tableIds.get(i),decimal);
                                 }
                                 if (dict == 85) {
                                     //时段
-                                    big4 = big4.add(new BigDecimal(values.get(i) + ""));
+                                    big4.put(tableIds.get(i),decimal);
                                 }
                                 //如果是合计的就要添加进总合计
                                 if (dict == 86) {
-                                    big = big.add(new BigDecimal(values.get(i) + ""));
+                                    big.put(tableIds.get(i),decimal);
                                 }
                             }
                         }
@@ -363,44 +423,49 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
                 for (Integer dict : elementMap.keySet()) {
                     if (!batchKey2.contains(dict)) {
                         TableDataVO vo = listMap2.get(dict).get(0);
-                        switch (dict) {
-                            case 197:
-                                //项目名称
-                                DataInfo.put(vo.getTabKey(),projectName);
-                                break;
-                            case 198:
-                                //当天日期
-                                DataInfo.put(vo.getTabKey(),LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
-                                break;
-                            case 199:
-                                //周期
-                                DataInfo.put(vo.getTabKey(),stage);
-                                break;
-                            case 301:
-                                //合计补偿总计
-                                DataInfo.put(vo.getTabKey(), big);
-                                break;
-                            case 401:
-                                //制表人
-                                DataInfo.put(vo.getTabKey(), "王文");
-                                break;
-                            case 402:
-                                //总计土地
-                                DataInfo.put(vo.getTabKey(), big2);
-                                break;
-                            case 403:
-                                //总计青苗及地上
-                                DataInfo.put(vo.getTabKey(), big3);
-                                break;
-                            case 404:
-                                //总计时段奖
-                                DataInfo.put(vo.getTabKey(), big4);
-                                break;
+                        for (int i = 0; i < tableTotal; i++) {
+                            Map<String, Object> DataInfo = dataInfos.get(tableIds.get(i));
+                            switch (dict) {
+                                case 197:
+                                    //项目名称
+                                    DataInfo.put(vo.getTabKey(), projectName);
+                                    break;
+                                case 198:
+                                    //当天日期
+                                    DataInfo.put(vo.getTabKey(), LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy年MM月dd日")));
+                                    break;
+                                case 199:
+                                    //周期
+                                    DataInfo.put(vo.getTabKey(), stage);
+                                    break;
+                                case 301:
+                                    //合计补偿总计
+                                    DataInfo.put(vo.getTabKey(), big.get(tableIds.get(i)));
+                                    break;
+                                case 401:
+                                    //制表人
+                                    DataInfo.put(vo.getTabKey(), "王文");
+                                    break;
+                                case 402:
+                                    //总计土地
+                                    DataInfo.put(vo.getTabKey(), big2.get(tableIds.get(i)));
+                                    break;
+                                case 403:
+                                    //总计青苗及地上
+                                    DataInfo.put(vo.getTabKey(), big3.get(tableIds.get(i)));
+                                    break;
+                                case 404:
+                                    //总计时段奖
+                                    DataInfo.put(vo.getTabKey(), big4.get(tableIds.get(i)));
+                                    break;
+                            }
                         }
                     }
                 }
             }
-            compensationInfoService.getBussPdfInfo(linkTable.getId(), DataInfo);
+            for (Long aLong : dataInfos.keySet()) {
+                compensationInfoService.getBussPdfInfo(aLong, dataInfos.get(aLong));
+            }
         } catch (Exception e) {
             throw new ServiceException("补偿费明细表生成失败:"+e.getMessage());
         }
@@ -643,6 +708,19 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         return linkTableService.getByAgreementId(id);
     }
 
+    /**
+     * 根据结算表单信息,复制表单,返回id
+     */
+    public Long copyTable(AgreementLinkTable linkTable){
+        Long id = SnowFlakeUtil.getId();
+        linkTable.setId(id);
+        Integer count = compensationInfoMapper.getTableCount(linkTable.getAgreementId(), linkTable.getTableId());
+        String[] s = linkTable.getTableName().split("__");
+        linkTable.setTableName(s[0]+"__"+ count);
+        linkTableService.save(linkTable);
+        return id;
+    }
+
     /**
      * 结算统计面积
      *
@@ -801,7 +879,8 @@ public class ClearingAgreementInfoServiceImpl extends BaseServiceImpl<ClearingAg
         List<String> data = new ArrayList<>();
         //获取协议所有的表单
         List<AgreementLinkTable> list = linkTableService.list(new LambdaQueryWrapper<AgreementLinkTable>()
-                .eq(AgreementLinkTable::getAgreementId, agreementId));
+                .eq(AgreementLinkTable::getAgreementId, agreementId)
+                .orderByAsc(AgreementLinkTable::getSort,AgreementLinkTable::getId));
         for (AgreementLinkTable table : list) {
             if (StringUtils.isNotEmpty(table.getPdfUrl())) {
                 data.add(table.getPdfUrl());

+ 37 - 0
blade-service/blade-land/src/main/java/org/springblade/land/utils/CommonUtils.java

@@ -0,0 +1,37 @@
+package org.springblade.land.utils;
+
+import org.springframework.util.CollectionUtils;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * @Param
+ * @Author wangwl
+ * @Date 2023/10/16 15:40
+ **/
+public class CommonUtils {
+    /**
+     * Description: Java8 Stream分割list集合
+     *
+     * @param list      集合数据
+     * @param splitSize 几个分割一组
+     * @return 集合分割后的集合
+     */
+    public static <T> List<List<T>> splitList(List<T> list, int splitSize) {
+        //判断集合是否为空
+        if (CollectionUtils.isEmpty(list))
+            return Collections.emptyList();
+        //计算分割后的大小
+        int maxSize = (list.size() + splitSize - 1) / splitSize;
+        //开始分割
+        return Stream.iterate(0, n -> n + 1)
+                .limit(maxSize)
+                .parallel()
+                .map(a -> list.parallelStream().skip(a * splitSize).limit(splitSize).collect(Collectors.toList()))
+                .filter(b -> !b.isEmpty())
+                .collect(Collectors.toList());
+    }
+}