@@ -15,6 +15,8 @@ import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule ;
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic10Excel ;
import com.njcn.jbsyncdata.pojo.DisPhotovoltaic380Excel ;
import com.njcn.jbsyncdata.pojo.DistributionAreaExcel ;
import com.njcn.jbsyncdata.pojo.ZhangDistributionAreaExcel ;
import io.swagger.annotations.ApiOperation ;
import org.springframework.web.bind.annotation.PostMapping ;
@@ -452,55 +454,152 @@ public class PubUtils {
//***************************************************添加结束********************************************************
// public static void main(String[] args) throws IOException {
// //读取10kV的数据
// List<DisPhotovoltaic10Excel> list10kV = EasyExcel.read("D:\\temp\\基础表.xlsx")
// .excelType(ExcelTypeEnum.XLSX)
// .head(DisPhotovoltaic10Excel.class)
// .headRowNumber(2)
// .sheet(0).doReadSync();
// list10kV = list10kV.stream()
// .filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
// .filter(t -> StrUtil.isNotBlank(t.getStageID()))
// .filter(StreamUtil.distinctByKey(DisPhotovoltaic10Excel::getGenerationUserID))
// .collect(Collectors.toList());
// //读取380V的数据
// List<DisPhotovoltaic380Excel> list380v = EasyExcel.read("D:\\temp\\基础表.xlsx")
// .excelType(ExcelTypeEnum.XLSX)
// .head(DisPhotovoltaic380Excel.class)
// .headRowNumber(2)
// .sheet(1).doReadSync();
// list380v = list380v.stream()
// .filter(t -> StrUtil.isNotBlank(t.getGenerationUserID()))
// .filter(t -> StrUtil.isNotBlank(t.getStageID()))
// .filter(StreamUtil.distinctByKey(DisPhotovoltaic380Excel::getGenerationUserID))
// .collect(Collectors.toList());
// //读取所有没数据的用户号
// FileReader fileReader = new FileReader("D:\\temp\\all.txt");
// List<String> noData = fileReader.readLines();
// Set<String> noDataSet = new HashSet<>(noData);
// FileReader fileReader2 = new FileReader("D:\\temp\\part.txt");
// List<String> noPartData = fileReader2.readLines();
// Set<String> noPartDataSet = new HashSet<>(noPartData);
//
// long millis = System.currentTimeMillis();
// //梳理10kV全部没有数据的
// List<DisPhotovoltaic10Excel> collect = list10kV.stream().filter(t -> noDataSet.contains(t.getGenerationUserID())).collect(Collectors.toList());
// EasyExcel.write("D:\\temp\\10kV全部没有数据的.xlsx", DisPhotovoltaic10Excel.class).sheet("10kV全部没有数据的").doWrite(collect);
// long millis1 = System.currentTimeMillis();
// System.out.println("10kV全部没有数据的耗时: " + (millis1 - millis));
// //10kV部分没有数据的
// Map<String, List<String>> noPartDataMap = noPartDataSet.stream().collect(Collectors.groupingBy(t -> t.substring(0, t.indexOf(StrPool.COMMA))));
// Map<String, List<DisPhotovoltaic10Excel>> all10kVMap = list10kV.stream().collect(Collectors.groupingBy(DisPhotovoltaic10Excel::getGenerationUserID));
// Set<String> keyedSet1 = all10kVMap.keySet();
// List<DisPhotovoltaic10Excel> final10kVUserData = new LinkedList<>();
// String info;
// for (String userId : keyedSet1) {
// List<String> infoList = noPartDataMap.get(userId);
// if (CollectionUtil.isNotEmpty(infoList)) {
// info = infoList.get(0);
// DisPhotovoltaic10Excel disPhotovoltaic10Excel = all10kVMap.get(userId).get(0);
// info = info.substring(info.indexOf(StrPool.COMMA) + 1);
// info = info.replaceAll(StrPool.AT, "||")
// .replaceAll("A_phsA", "A相电流")
// .replaceAll("A_phsB", "B相电流")
// .replaceAll("A_phsC", "C相电流")
// .replaceAll("PhV_phsA", "A相电压")
// .replaceAll("PhV_phsB", "B相电压")
// .replaceAll("PhV_phsC", "C相电压")
// .replaceAll("TotW", "有功")
// .replaceAll("TotVar", "无功");
// disPhotovoltaic10Excel.setTypes(info);
// final10kVUserData.add(disPhotovoltaic10Excel);
// }
// }
// EasyExcel.write("D:\\temp\\10kV部分没有数据的.xlsx", DisPhotovoltaic10Excel.class).sheet("10kV部分没有数据的").doWrite(final10kVUserData);
// long millis2 = System.currentTimeMillis();
// System.out.println("10kV部分没有数据的: " + (millis2 - millis1));
// //梳理380V全部没有数据的
// List<DisPhotovoltaic380Excel> collect4 = list380v.stream().filter(t -> noDataSet.contains(t.getGenerationUserID())).collect(Collectors.toList());
// EasyExcel.write("D:\\temp\\380V全部没有数据的.xlsx", DisPhotovoltaic380Excel.class).sheet("380V全部没有数据的").doWrite(collect4);
// long millis3 = System.currentTimeMillis();
// System.out.println("380V全部没有数据的: " + (millis3 - millis2));
// //380V部分没有数据的
// Map<String, List<DisPhotovoltaic380Excel>> all380VMap = list380v.stream().collect(Collectors.groupingBy(DisPhotovoltaic380Excel::getGenerationUserID));
// Set<String> keyedSet = noPartDataMap.keySet();
// List<DisPhotovoltaic380Excel> final380VUserData = new LinkedList<>();
// List<DisPhotovoltaic380Excel> disPhotovoltaic380ExcelList;
// DisPhotovoltaic380Excel disPhotovoltaic380Excel;
// for (String userId : keyedSet) {
// disPhotovoltaic380ExcelList = all380VMap.get(userId);
// if (CollectionUtil.isNotEmpty(disPhotovoltaic380ExcelList)) {
// disPhotovoltaic380Excel = disPhotovoltaic380ExcelList.get(0);
// info = noPartDataMap.get(userId).get(0);
// info = info.substring(info.indexOf(StrPool.COMMA) + 1);
// info = info.replaceAll(StrPool.AT, "||")
// .replaceAll("A_phsA", "A相电流")
// .replaceAll("A_phsB", "B相电流")
// .replaceAll("A_phsC", "C相电流")
// .replaceAll("PhV_phsA", "A相电压")
// .replaceAll("PhV_phsB", "B相电压")
// .replaceAll("PhV_phsC", "C相电压")
// .replaceAll("TotW", "有功")
// .replaceAll("TotVar", "无功");
// disPhotovoltaic380Excel.setTypes(info);
// final380VUserData.add(disPhotovoltaic380Excel);
// }
// }
// EasyExcel.write("D:\\temp\\380V部分没有数据的.xlsx", DisPhotovoltaic380Excel.class).sheet("380V部分没有数据的").doWrite(final380VUserData);
// long millis4 = System.currentTimeMillis();
// System.out.println("380V部分没有数据的: " + (millis4 - millis3));
// }
public static void main ( String [ ] args ) throws IOException {
//读取10kV的数据
List < DisPhotovoltaic10 Excel > list10kV = EasyExcel . read ( " D: \\ temp \\ 基础表 .xlsx" )
. excelType ( ExcelTypeEnum . XLSX )
. head ( DisPhotovoltaic10Excel . class )
. headRowNumber ( 2 )
List < DistributionArea Excel > list = EasyExcel . read ( " D: \\ test \\ 唐山 .xlsx" )
. head ( DistributionAreaExcel . class )
. sheet ( 0 ) . doReadSync ( ) ;
list10kV = list10kV . stream ( )
. filter ( t - > StrUtil . isNotBlank ( t . getGenerationUser ID( ) ) )
. filter ( t - > StrUtil . isNotBlank ( t . getStageID ( ) ) )
. filter ( StreamUtil . distinctByKey ( DisPhotovoltaic10Excel : : getGenerationUserID ) )
list = list . stream ( )
. filter ( t - > ! " #N/A " . equals ( t . getPms ID( ) ) )
. collect ( Collectors . toList ( ) ) ;
//读取380V的数据
List < DisPhotovoltaic380Excel > list380v = EasyExcel . read ( " D: \\ temp \\ 基础表.xlsx " )
. excelType ( ExcelTypeEnum . XLSX )
. head ( DisPhotovoltaic380Excel . class )
. headRowNumber ( 2 )
. sheet ( 1 ) . doReadSync ( ) ;
list380v = list380v . stream ( )
. filter ( t - > StrUtil . isNotBlank ( t . getGenerationUserID ( ) ) )
. filter ( t - > StrUtil . isNotBlank ( t . getStageID ( ) ) )
. filter ( StreamUtil . distinctByKey ( DisPhotovoltaic380Excel : : getGenerationUserID ) )
. collect ( Collectors . toList ( ) ) ;
//读取所有没数据的用户号
FileReader fileReader = new FileR eader ( " D: \\ temp \\ all.txt " ) ;
List < ZhangDistributionAreaExcel > listZhang = EasyExcel . r ead( " D: \\ test \\ 张家口.xlsx " )
. head ( ZhangDistributionAreaExcel . class )
. doReadAllSync ( ) ;
listZhang = listZhang . stream ( )
. filter ( t - > StrUtil . isNotBlank ( t . getId ( ) ) )
. filter ( StreamUtil . distinctByKey ( ZhangDistributionAreaExcel : : getId ) )
. filter ( t - > ! " #N/A " . equals ( t . getPmsID ( ) ) )
. filter ( t - > StrUtil . isNotBlank ( t . getPmsID ( ) ) )
. collect ( Collectors . toList ( ) ) ;
//读取所有没数据的用户号
FileReader fileReader = new FileReader ( " D: \\ test \\ all.txt " ) ;
List < String > noData = fileReader . readLines ( ) ;
Set < String > noDataSet = new HashSet < > ( noData ) ;
FileReader fileReader2 = new FileReader ( " D: \\ temp \\ part.txt " ) ;
FileReader fileReader2 = new FileReader ( " D: \\ test \\ part.txt " ) ;
List < String > noPartData = fileReader2 . readLines ( ) ;
Set < String > noPartDataSet = new HashSet < > ( noPartData ) ;
long millis = System . currentTimeMillis ( ) ;
//梳理10kV全部 没有数据的
List < DisPhotovoltaic10 Excel > collect = list10kV . stream ( ) . filter ( t - > noDataSet . contains ( t . getGenerationUser ID ( ) ) ) . collect ( Collectors . toList ( ) ) ;
EasyExcel . write ( " D: \\ temp \\ 10kV 全部没有数据的.xlsx" , DisPhotovoltaic10 Excel . class ) . sheet ( " 10kV 全部没有数据的" ) . doWrite ( collect ) ;
//唐山 没有数据的信息
List < DistributionArea Excel > collect = list . stream ( ) . filter ( t - > noDataSet . contains ( t . getPms ID ( ) ) ) . collect ( Collectors . toList ( ) ) ;
EasyExcel . write ( " D: \\ test \\ 唐山 全部没有数据的.xlsx" , DistributionArea Excel . class ) . sheet ( " 唐山 全部没有数据的" ) . doWrite ( collect ) ;
long millis1 = System . currentTimeMillis ( ) ;
System . out . println ( " 10kV 全部没有数据的耗时:" + ( millis1 - millis ) ) ;
//10kV 部分没有数据的
System . out . println ( " 唐山 全部没有数据的耗时:" + ( millis1 - millis ) ) ;
//唐山 部分没有数据的
Map < String , List < String > > noPartDataMap = noPartDataSet . stream ( ) . collect ( Collectors . groupingBy ( t - > t . substring ( 0 , t . indexOf ( StrPool . COMMA ) ) ) ) ;
Map < String , List < DisPhotovoltaic10 Excel > > all10kVMap = list10kV . stream ( ) . collect ( Collectors . groupingBy ( DisPhotovoltaic10 Excel : : getGenerationUser ID ) ) ;
Map < String , List < DistributionArea Excel > > all10kVMap = list . stream ( ) . collect ( Collectors . groupingBy ( DistributionArea Excel : : getPms ID ) ) ;
Set < String > keyedSet1 = all10kVMap . keySet ( ) ;
List < DisPhotovoltaic10 Excel > final10kVUserData = new LinkedList < > ( ) ;
List < DistributionArea Excel > final10kVUserData = new LinkedList < > ( ) ;
String info ;
for ( String userId : keyedSet1 ) {
List < String > infoList = noPartDataMap . get ( userId ) ;
if ( CollectionUtil . isNotEmpty ( infoList ) ) {
info = infoList . get ( 0 ) ;
DisPhotovoltaic10 Excel disPhotovoltaic10Excel = all10kVMap . get ( userId ) . get ( 0 ) ;
DistributionArea Excel disPhotovoltaic10Excel = all10kVMap . get ( userId ) . get ( 0 ) ;
info = info . substring ( info . indexOf ( StrPool . COMMA ) + 1 ) ;
info = info . replaceAll ( StrPool . AT , " || " )
. replaceAll ( " A_phsA " , " A相电流 " )
@@ -515,20 +614,22 @@ public class PubUtils {
final10kVUserData . add ( disPhotovoltaic10Excel ) ;
}
}
EasyExcel . write ( " D: \\ temp \\ 10kV 部分没有数据的.xlsx" , DisPhotovoltaic10 Excel . class ) . sheet ( " 10kV 部分没有数据的" ) . doWrite ( final10kVUserData ) ;
EasyExcel . write ( " D: \\ test \\ 唐山 部分没有数据的.xlsx" , DistributionArea Excel . class ) . sheet ( " 唐山 部分没有数据的" ) . doWrite ( final10kVUserData ) ;
long millis2 = System . currentTimeMillis ( ) ;
System . out . println ( " 10kV 部分没有数据的:" + ( millis2 - millis1 ) ) ;
System . out . println ( " 唐山 部分没有数据的:" + ( millis2 - millis1 ) ) ;
//梳理380V全部没有数据的
List < DisPhotovoltaic380 Excel> collect4 = list380v . stream ( ) . filter ( t - > noDataSet . contains ( t . getGenerationUser ID ( ) ) ) . collect ( Collectors . toList ( ) ) ;
EasyExcel . write ( " D: \\ temp \\ 380V 全部没有数据的.xlsx" , DisPhotovoltaic380 Excel. class ) . sheet ( " 380V 全部没有数据的" ) . doWrite ( collect4 ) ;
List < ZhangDistributionArea Excel> collect4 = listZhang . stream ( ) . filter ( t - > noDataSet . contains ( t . getPms ID ( ) ) ) . collect ( Collectors . toList ( ) ) ;
EasyExcel . write ( " D: \\ test \\ 张家口 全部没有数据的.xlsx" , ZhangDistributionArea Excel. class ) . sheet ( " 张家口 全部没有数据的" ) . doWrite ( collect4 ) ;
long millis3 = System . currentTimeMillis ( ) ;
System . out . println ( " 380V 全部没有数据的:" + ( millis3 - millis2 ) ) ;
System . out . println ( " 张家口 全部没有数据的:" + ( millis3 - millis2 ) ) ;
//380V部分没有数据的
Map < String , List < DisPhotovoltaic380 Excel> > all380VMap = list380v . stream ( ) . collect ( Collectors . groupingBy ( DisPhotovoltaic380 Excel: : getGenerationUser ID ) ) ;
Map < String , List < ZhangDistributionArea Excel> > all380VMap = listZhang . stream ( ) . collect ( Collectors . groupingBy ( ZhangDistributionArea Excel: : getPms ID ) ) ;
Set < String > keyedSet = noPartDataMap . keySet ( ) ;
List < DisPhotovoltaic380 Excel> final380VUserData = new LinkedList < > ( ) ;
List < DisPhotovoltaic380 Excel> disPhotovoltaic380ExcelList ;
DisPhotovoltaic380 Excel disPhotovoltaic380Excel ;
List < ZhangDistributionArea Excel> final380VUserData = new LinkedList < > ( ) ;
List < ZhangDistributionArea Excel> disPhotovoltaic380ExcelList ;
ZhangDistributionArea Excel disPhotovoltaic380Excel ;
for ( String userId : keyedSet ) {
disPhotovoltaic380ExcelList = all380VMap . get ( userId ) ;
if ( CollectionUtil . isNotEmpty ( disPhotovoltaic380ExcelList ) ) {
@@ -548,9 +649,8 @@ public class PubUtils {
final380VUserData . add ( disPhotovoltaic380Excel ) ;
}
}
EasyExcel . write ( " D: \\ temp \\ 380V 部分没有数据的.xlsx" , DisPhotovoltaic380 Excel. class ) . sheet ( " 380V 部分没有数据的" ) . doWrite ( final380VUserData ) ;
EasyExcel . write ( " D: \\ test \\ 张家口 部分没有数据的.xlsx" , ZhangDistributionArea Excel. class ) . sheet ( " 张家口 部分没有数据的" ) . doWrite ( final380VUserData ) ;
long millis4 = System . currentTimeMillis ( ) ;
System . out . println ( " 380V 部分没有数据的:" + ( millis4 - millis3 ) ) ;
System . out . println ( " 张家口 部分没有数据的:" + ( millis4 - millis3 ) ) ;
}
}