List<T>的ForEach方法(可以使用“语句lambda”作为其参数),如下例子:

private void OKButton_Click(object sender, RoutedEventArgs e) {
            this.DialogResult = true;
      //  GetSelectedJZ(Shu.Items[0] as TreeViewItem);
            //选择后返回
            if (GetJZ_Event!=null) {
            //排除不是建筑的选项
                V_FQ.Rows.Where(a =>
                V_FQ.Value(a, "cc").ToString() == "1"
                ).ToList().ForEach(b => {
                    if (Shu.SelectedItemsZJ.Contains(V_FQ.Value(b, "zj").ToString()))
                        Shu.SelectedItemsZJ.Remove(V_FQ.Value(b, "zj").ToString());
                });
                GetJZ_Event(Shu.SelectedItemsZJ);
            }
        }

 

 _graphicsManager.Graphics.Where<Graphic>(
                        (item) =>
                        {
                            if ((ShowAperture)item.Symbol.GetValue(PolicePictureMarkerSymbol.ShowApertureProperty) == ShowAperture.Yes)
                            {
                                item.SetShowAperture(ShowAperture.No);
                                return true;
                            }
                            else
                            {
                                return false;
                            }
                        }
                    );


                    _graphicsManager.Graphics.Where<Graphic>(item => (ShowAperture)item.Symbol.GetValue(PolicePictureMarkerSymbol.ShowApertureProperty) == ShowAperture.Yes).ToList().ForEach(p => p.SetShowAperture(ShowAperture.No));

                    _graphicsManager.Graphics.Where<Graphic>(item => (ShowAperture)item.Symbol.GetValue(PolicePictureMarkerSymbol.ShowApertureProperty) == ShowAperture.Yes).ToList().ForEach((p) =>
                        {
                            p.SetShowAperture(ShowAperture.No);
                        });

转载于:https://www.cnblogs.com/changbaishan/archive/2013/05/30/3107436.html

优化这段代码public static void readExcel(String fileName) { List<Version> versions = EasyExcel.read(fileName, Version.class, null).sheet("版本号").doReadSync(); List<TableInfo> tableInfoList = EasyExcel.read(fileName, TableInfo.class, null).sheet("数据库&数据表").doReadSync(); List<TableField> tableFieldList = EasyExcel.read(fileName, TableField.class, null).sheet("字段").doReadSync(); List<HopIndex> hopIndexList = EasyExcel.read(fileName, HopIndex.class, null).sheet("跳数索引").doReadSync(); Map<String, List<TableInfo>> tableInfoMap = tableInfoList.stream().collect(Collectors.groupingBy(TableInfo::getEnDataBaseName)); Map<String, List<TableField>> tableFieldMap = tableFieldList.stream().collect(Collectors.groupingBy(TableField::getEnTableName)); Map<String, List<HopIndex>> hopIndexMap = hopIndexList.stream().collect(Collectors.groupingBy(HopIndex::getEnTableName)); List<TableInfo> tableInfos1 = new ArrayList<>(); List<TableInfo> tableInfos2 = new ArrayList<>(); tableInfoMap.forEach((dbName, tableList) -> { if (tableList.size() < 200) { tableInfos1.addAll(tableList); } else { tableInfos2.addAll(tableList); } }); List<TableField> tableFields = new ArrayList<>(); List<HopIndex> hopIndex = new ArrayList<>(); for (TableInfo tableInfo : tableInfos1) { String enTableName = tableInfo.getEnTableName(); tableFields.addAll(tableFieldMap.get(enTableName)); List<HopIndex> hops = hopIndexMap.get(enTableName); if (hops !=null){ hopIndex.addAll(hops); } } String name = filepath + File.separator + "明细层_V1.0_" + DateUtil.date().toString(DatePattern.PURE_DATE_PATTERN) + "1.xls"; ExcelWriter excelWriter = EasyExcel.write(name).build(); ExcelUtil.writerExcel(excelWriter, "版本号", Version.class, versions); ExcelUtil.writerExcel(excelWriter, "数据库&数据表", TableInfo.class, tableInfos1); ExcelUtil.writerExcel(excelWriter, "字段", TableField.class, tableFields); ExcelUtil.writerExcel(excelWriter, "跳数索引", HopIndex.class, hopIndex); ExcelUtil.close(excelWriter); tableFields.clear(); hopIndex.clear(); for (TableInfo tableInfo : tableInfos2) { String enTableName = tableInfo.getEnTableName(); tableFields.addAll(tableFieldMap.get(enTableName)); List<HopIndex> hops = hopIndexMap.get(enTableName); if (hops !=null){ hopIndex.addAll(hops); } } name = filepath + File.separator + "明细层_V1.0" + DateUtil.date().toString(DatePattern.PURE_DATE_PATTERN) + "_2.xls"; excelWriter = EasyExcel.write(name).build(); ExcelUtil.writerExcel(excelWriter, "版本号", Version.class, versions); ExcelUtil.writerExcel(excelWriter, "数据库&数据表", TableInfo.class, tableInfos2); ExcelUtil.writerExcel(excelWriter, "字段", TableField.class, tableFields); ExcelUtil.writerExcel(excelWriter, "跳数索引", HopIndex.class, hopIndex); ExcelUtil.close(excelWriter); }
05-30
jdk8 优化以下代码: for (DqExecuteResult dqExecuteResult : dqExecuteResults) { String errorOutputPath = dqExecuteResult.getErrorOutputPath(); Path path = new Path(errorOutputPath); R<List<String>> getFileResult = resourceClient.getFilesAtPath(path.toUri().getPath()); if (null != getFileResult && getFileResult.isSuccess()) { for (String fullPath : getFileResult.getData()) { R<List<String>> previewResult = resourceClient.viewFileByPath(new Path(fullPath).toUri().getPath(), query.getCurrent(), query.getSize(), "\n"); if (null != previewResult && previewResult.isSuccess()) { if("原始库".equals(datasourceName)){ Long datasourceId = iDataSourceClient.queryRawDataSource().getId(); List<MetaColumn> tableColumns = iDataSourceMetaClient.getTableColumns(datasourceId, tableName); for (MetaColumn metaColumn : tableColumns){ headers.add(metaColumn.getColumnName()); } } else if("标准库".equals(datasourceName)){ Long datasourceId = iDataSourceClient.queryModelDataSource().getId(); List<MetaColumn> tableColumns = iDataSourceMetaClient.getTableColumns(datasourceId, tableName); for (MetaColumn metaColumn : tableColumns){ headers.add(metaColumn.getColumnName()); } } int headerSize = headers.size(); List<String> datas = previewResult.getData(); StringBuilder contextBuilder = new StringBuilder(); for(String data : datas){ contextBuilder.append(data.replaceAll("[\r\n\t]", " ")); contextBuilder.append("\n"); } StringReader reader = new StringReader(contextBuilder.toString()); Iterable<CSVRecord> records = CSVFormat.DEFAULT.parse(reader); for (CSVRecord record : records) { if (record.size() == headerSize){ List<String> content = new ArrayList<>(); for (String column : record) { content.add(column); } contents.add(content); } } } } } }
最新发布
06-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值