Commit 707b935e by dongshufeng

initial

parent 852654f6
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
apply plugin: 'java'
apply plugin: 'kotlin'
group 'cn.zju'
version '1.0-SNAPSHOT'
sourceCompatibility = 1.8
repositories {
mavenCentral()
maven {
credentials { username 'admin'; password 'admin19881109' }
url "http://dsp.sgool.cn:8887/nexus/content/repositories/releases"
}
}
dependencies {
}
// 编码设置
tasks.withType(Javadoc) { options.encoding = "UTF-8" }
tasks.withType(JavaCompile) { options.encoding = "UTF-8" }
}
\ No newline at end of file
FLOW ID,是否启用,名称,触发条件,触发条件参数,,
60121,TRUE,简单,Manual,,,
,,,,,,
FLOW ID,节点ID,名称,节点类型,参数,,
60121,1,suffix1,SOURCE_URL,https://pan.zju.edu.cn/share/8ff81c393101990a2c713f4acd,,
60121,2,input1,SOURCE_URL,https://pan.zju.edu.cn/share/6830465b5ffc871477871d365d,,
60121,3,join,Transform,"join(edge1,edge2,[""绞线"",""尺寸""],[""绞线"",""尺寸""],inner)",,
60121,4,sort,Transform,"sort(index, false, false)",,
60121,5,cal_image,TensorEval,"distance = [[0,0.7622,2.1342,1.7247],[0.7622,0,1.372,1.3025],[2.1342,1.372,0,1.5244],[1.7247,1.3025,1.5244,0]];
D = diag(GMR)+distance;
image = 0.0628*(ln(1/D)+8.02517);",,
60121,6,cal_real,SOURCE_URL,https://pan.zju.edu.cn/share/2ddfa2ed5c334b63885e0459f1,,
60121,7,Zabc,Transform,concat(horizontal),,
,,,,,,
FLOW ID,首尾节点,动作名称,DESC,动作类型,动作参数,
60121,1;3,edge1,,None,,
60121,2;3,edge2,,None,,
60121,3;4,rename,,Eval,select,"col(index);col(""绞线"");alias(col(""几何平均半径_m""),mat_4_1);"
60121,4;5,GMR,,Eval,select,col(mat_4_1);
60121,5;7,real,,Eval,select,"alias(col(mat_4_4),Zreal);"
60121,6;7,image,,Eval,select,"alias(col(mat_4_4),Zimag);"
\ No newline at end of file
index,绞线,尺寸
1,"26/7","336/400"
2,"26/7","336/400"
3,"26/7","336/400"
4,"6/1","4/0"
\ No newline at end of file
mat_4_4
0.190
0.0493
0.0493
0.0493
0.0493
0.190
0.0493
0.0493
0.0493
0.0493
0.190
0.0493
0.0493
0.0493
0.0493
0.190
671-692-,650-,684-,633-,611-,680-,646-,645-,634-,652-,632-,675-
,,10,,,11,,,,,9,14
,,,,,,,,,,7,
10,,,,13,,,,,8,,
,,,,,,,,5,,4,
,,13,,,,,,,,,
11,,,,,,,,,,,
,,,,,,,6,,,,
,,,,,,6,,,,3,
,,,5,,,,,,,,
,,8,,,,,,,,,
9,7,,4,,,,3,,,,
14,,,,,,,,,,,
\ No newline at end of file
序号,ID,资源类型,名称,描述,端子数量,属性分组1_名称,属性分组1_描述,属性分组1_属性
1,1,BaseVoltage,BaseVoltage,BaseVoltage,0,ieee,电压等级,1
2,2,ACline,ACLineSegment,交流线路,2,ieee,线路类型-长度,3;4
3,3,Switch,Breaker,Breaker,2,ieee,开关,2
4,4,Load,Load,Load,1,ieee,负荷,
5,5,Transformer,PowerTransformer,Transformer,2,ieee,变压器类型-R-X-原边电压等级,3;9;10;1
6,6,ShuntCompensator,ShuntCompensator,ShuntCompensator,1,ieee,并联补偿,
7,7,Busbar,BusbarSection,母线,1,ieee,母线-源,
\ No newline at end of file
序号,ID,属性标识,属性标题,数据类型,单位
1,1,nominalVoltage,电压等级,U64,V
2,2,normalOpen,normalOpen,Str,UnitOne
3,3,model,config,Str,UnitOne
4,4,length,长度,U64,ft
5,5,crossSectionArea,横截面积,U64,mm2
6,6,nominalVoltage,电压等级,U64,V
7,7,mRID,mRID,Str,UnitOne
8,8,EquipmentContainer,container,Str,UnitOne
9,9,R,电阻,F64,UnitOne
10,10,X,电抗,F64,UnitOne
\ No newline at end of file
Index,ID,Device Define Id,Name,Description,Terminal,Container,Name,ID,Property ID,Property Value,Property ID,Property Value,Property ID,Property Value
1,1,7,Infinite Bus,源,650,,ieee,1,,,,,,
2,2,1,BaseVoltage,电压等级,,,ieee,2,1,10000,,,,
3,3,2,line1,,632;645,,ieee,3,3,603,4,500,,
4,4,2,line2,,632;633,,ieee,4,3,602,4,500,,
5,5,5,transformer,变压器,633;634,,ieee,5,3,4.16-Gr.W 0.48-Gr.W,9,1.1,10,2
6,6,2,line3,,645;646,,ieee,6,3,603,4,300,,
7,7,2,line4,,650;632,,ieee,7,3,601,4,2000,,
8,8,2,line5,,684;652,,ieee,8,3,607,4,800,,
9,9,2,line6,,632;671,,ieee,9,3,601,4,2000,,
10,10,2,line7,,671;684,,ieee,10,3,604,4,300,,
11,11,2,line8,,671;680,,ieee,11,3,601,4,1000,,
12,12,3,switch,开关,671;692,,ieee,12,2,false,,,,
13,13,2,line9,,684;611,,ieee,13,3,605,4,300,,
14,14,2,line10,,692;675,,ieee,14,3,606,4,500,,
15,15,4,Load,负荷,634,,ieee,15,,,,,,
16,16,4,Load,,645,,ieee,16,,,,,,
17,17,4,Load,,646,,ieee,17,,,,,,
18,18,4,Load,,652,,ieee,18,,,,,,
19,19,4,Load,,671,,ieee,19,,,,,,
20,20,4,Load,,675,,ieee,20,,,,,,
21,21,4,Load,,692,,ieee,21,,,,,,
22,22,4,Load,,611,,ieee,22,,,,,,
Index,ID,Point ID,Dev ID,Terminal ID
1,1,1000001,1,10
2,2,1000002,5,634
3,3,1000003,5,634
4,4,1000004,5,634
5,5,1000005,5,634
6,6,1000006,5,634
7,7,1000007,5,634
8,8,1000008,3,645
9,9,1000009,3,645
10,10,1000010,6,646
11,11,1000011,6,646
12,12,1000012,8,652
13,13,1000013,8,652
14,14,1000014,9,671
15,15,1000015,9,671
16,16,1000016,9,671
17,17,1000017,9,671
18,18,1000018,9,671
19,19,1000019,9,671
20,20,1000020,14,675
21,21,1000021,14,675
22,22,1000022,14,675
23,23,1000023,14,675
24,24,1000024,14,675
25,25,1000025,14,675
26,26,1000026,12,692
27,27,1000027,12,692
28,28,1000028,13,611
29,29,1000029,13,611
\ No newline at end of file
Index,Point ID,Value
1,1000001,4160
2,1000002,160
3,1000003,110
4,1000004,120
5,1000005,90
6,1000006,120
7,1000007,90
8,1000008,170
9,1000009,125
10,1000010,230
11,1000011,132
12,1000012,128
13,1000013,86
14,1000014,385
15,1000015,220
16,1000016,385
17,1000017,220
18,1000018,385
19,1000019,220
20,1000020,485
21,1000021,190
22,1000022,68
23,1000023,60
24,1000024,290
25,1000025,212
26,1000026,170
27,1000027,151
28,1000028,170
29,1000029,80
\ No newline at end of file
Index,ID,Name,Alias,Is Discrete,Is Computing,Expression,Trans Expr,Inv Trans Expr,Change Expr,Zero Expr,Unit,Upper Limit,Lower Limit,Alarm 1,Alarm 2,Is Realtime,Is Realtime,Initial,Tags,Description
1,1000001,源电压,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,TotV
2,1000002,A相有功634,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsA
3,1000003,A相无功634,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsA
4,1000004,B相有功634,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsB
5,1000005,B相无功634,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsB
6,1000006,C相有功634,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsC
7,1000007,C相无功634,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsC
8,1000008,B相有功645,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsB
9,1000009,B相无功645,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsB
10,1000010,B相有功646,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsB
11,1000011,B相无功646,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsB
12,1000012,A相有功652,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsA
13,1000013,A相无功652,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsA
14,1000014,A相有功671,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsA
15,1000015,A相无功671,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsA
16,1000016,B相有功671,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsB
17,1000017,B相无功671,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsB
18,1000018,C相有功671,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsC
19,1000019,C相无功671,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsC
20,1000020,A相有功675,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsA
21,1000021,A相无功675,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsA
22,1000022,B相有功675,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsB
23,1000023,B相无功675,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsB
24,1000024,C相有功675,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsC
25,1000025,C相无功675,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsC
26,1000026,C相有功692,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsC
27,1000027,C相无功692,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsC
28,1000028,C相有功611,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhW_phsC
29,1000029,C相无功611,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,PhVAr_phsC
\ No newline at end of file
序号,ID,资源类型,名称,描述,端子数量,属性分组1_名称,属性分组1_描述,属性分组1_属性
1,1,BaseVoltage,BaseVoltage,BaseVoltage,0,ieee,电压等级,1
2,2,ACline,ACLineSegment,交流线路,2,ieee,线路类型-长度,3;4
3,3,Switch,Breaker,Breaker,2,ieee,开关,2
4,4,Load,Load,Load,1,ieee,负荷,
5,5,Transformer,PowerTransformer,Transformer,2,ieee,变压器类型-R-X,3;9;10
6,6,ShuntCompensator,ShuntCompensator,ShuntCompensator,1,ieee,并联补偿,
7,7,Busbar,BusbarSection,母线,1,ieee,母线-源,
序号,ID,属性标识,属性标题,数据类型,单位
1,1,nominalVoltage,电压等级,U64,V
2,2,normalOpen,开关状态,Str,UnitOne
3,3,model,型号,Str,UnitOne
4,4,length,长度,U64,ft
5,5,crossSectionArea,横截面积,U64,mm2
6,6,nominalVoltage,电压等级,U64,V
7,7,mRID,mRID,Str,UnitOne
8,8,EquipmentContainer,container,Str,UnitOne
9,9,R,电阻,F64,UnitOne
10,10,X,电抗,F64,UnitOne
Index,ID,Device Define Id,Name,Description,Terminal,Container,Name,ID,Property ID,Property Value,Property ID,Property Value,Property ID,Property Value
1,1,7,Infinite Bus,源,10,,ieee,1,,,,,,
2,2,2,line1,线路1,21;22,,ieee,2,3,"336,400 26/7",4,,,
3,3,5,transformer,变压器,31;32,,ieee,3,3,Wye-Delta Step Down,9,1.0,10,6.0
4,4,2,line2,线路2,41;42,,ieee,4,3,"336,400 26/7",4,,,
5,5,4,Load,负荷,50,,ieee,5,,,,,,
6,6,1,BaseVoltage,电压等级,60,,ieee,6,1,10000,,,,
\ No newline at end of file
Index,ID,Point ID,Dev ID,Terminal ID
1,1,1000001,1,10
2,2,1000002,5,50
3,3,1000003,5,50
4,4,1000004,5,50
5,5,1000005,5,50
6,6,1000006,5,50
7,7,1000007,5,50
\ No newline at end of file
Index,Point ID,Value
1,1000001,1
2,1000002,5
3,1000003,5
4,1000004,5
5,1000005,5
6,1000006,5
7,1000007,5
\ No newline at end of file
Index,ID,Name,Alias,Is Discrete,Is Computing,Expression,Trans Expr,Inv Trans Expr,Change Expr,Zero Expr,Unit,Upper Limit,Lower Limit,Alarm 1,Alarm 2,Is Realtime,Is Realtime,Initial,Tags,Description
1,1000001,源电压,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,
2,1000002,A相有功,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,
3,1000003,A相无功,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,
4,1000004,B相有功,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,
5,1000005,B相无功,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,
6,1000006,C相有功,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,
7,1000007,C相无功,,FALSE,FALSE,,,,,,,"0","0",,,FALSE,FALSE,0.0,,
\ No newline at end of file
尺寸,绞线,材料,直径_cm,几何平均半径_m,阻值_欧_per_km,容量_A
1,, 钢芯铝绞线,0.9017,0.001274064,0.857494377,200
1,7 STRD,铜,0.83312,0.003023616,0.475350144,270
1,CLASS A,铝合金,0.83312,0.003020568,0.76056023,177
2,6/1,钢芯铝绞线,0.80264,0.001274064,1.050119925,180
2,7 STRD,铜,0.74168,0.002691384,0.599003318,230
2,7/1,钢芯铝绞线,0.8255,0.001536192,1.025265015,180
2,AWG SLD,铜,0.65532,0.002548128,0.587197236,220
2,CLASS A,铝合金,0.74168,0.002691384,0.957535387,156
3,6/1,钢芯铝绞线,0.71374,0.00131064,1.286241565,160
3,AWG SLD,铜,0.58166,0.00227076,0.740676302,190
4,6/1,钢芯铝绞线,0.635,0.001331976,1.596927933,140
4,7/1,钢芯铝绞线,0.65278,0.001377696,1.584500478,140
4,AWG SLD,铜,0.51816,0.002020824,0.933923223,170
4,CLASS A,铝合金,0.58928,0.0021336,1.524227323,90
5,6/1,钢芯铝绞线,0.56642,0.001267968,1.975965303,120
5,AWG SLD,铜,0.462026,0.00179832,1.177501336,140
6,6/1,钢芯铝绞线,0.50292,0.001200912,2.473063492,100
6,AWG SLD,铜,0.41148,0.001603248,1.485080841,120
6,CLASS A,铝合金,0.46736,0.00169164,2.425217791,65
7,AWG SLD,铜,0.366522,0.001426464,1.870331937,110
8,AWG SLD,铜,0.32639,0.001267968,2.361216399,90
9,AWG SLD,铜,0.290576,0.001130808,2.905414642,80
10,AWG SLD,铜,0.258826,0.00100584,3.667714715,75
12,AWG SLD,铜,0.205232,0.000798576,5.825182994,40
14,AWG SLD,铜,0.162814,0.000633984,9.241179614,20
16,AWG SLD,铜,0.129032,0.000499872,14.74281382,10
18,AWG SLD,铜,0.102362,0.00039624,23.40872656,5
19,AWG SLD,铜,0.091186,0.000353568,29.52160513,4
20,AWG SLD,铜,0.08128,0.000313944,37.08601041,3
22,AWG SLD,铜,0.064262,0.000249936,59.3308437,2
24,AWG SLD,铜,0.051054,0.00019812,94.21004884,1
1/0,, 钢芯铝绞线,1.01092,0.001359408,0.695937465,230
1/0,7 STRD,铜,0.93472,0.003392424,0.377173251,310
1/0,CLASS A,铝合金,0.93472,0.00338328,0.602731555,202
2/0,, 钢芯铝绞线,1.13538,0.00155448,0.556128599,270
2/0,7 STRD,铜,1.05156,0.003816096,0.298880286,360
2/0,CLASS A,铝合金,1.05156,0.00381,0.477835634,230
3/0,12 STRD,铜,1.24968,0.004751832,0.237364385,420
3/0,6/1,钢芯铝绞线,1.27508,0.0018288,0.449252489,300
3/0,7 STRD,铜,1.17856,0.004279392,0.237364385,420
3/0,CLASS A,铝合金,1.17856,0.0042672,0.379658742,263
3/8,INCH STE,AAteel,0.9525,0.000003048,2.671902768,150
4/0,12 STRD,铜,1.40208,0.005334,0.188275939,490
4/0,19 STRD,铜,1.34112,0.005084064,0.188275939,480
4/0,6/1,钢芯铝绞线,1.43002,0.002481072,0.36785266,340
4/0,7 STRD,铜,1.32588,0.004812792,0.188275939,480
4/0,CLASS A,铝合金,1.32588,0.00481584,0.300744405,299
250000,12 STRD,铜,1.524,0.005797296,0.159692793,540
250000,19 STRD,铜,1.45796,0.005526024,0.159692793,540
250000,CON LAY,铝合金,1.44018,0.00521208,0.254762822,329
266800,26/7,钢芯铝绞线,1.63068,0.00661416,0.239228504,460
266800,CLASS A,铝合金,1.48844,0.00539496,0.238607131,320
300000,12 STRD,铜,1.66878,0.00633984,0.133595138,610
300000,19 STRD,铜,1.59766,0.006056376,0.133595138,610
300000,26/7,钢芯铝绞线,1.7272,0.0070104,0.212509476,490
300000,30/7,钢芯铝绞线,1.778,0.00734568,0.212509476,500
300000,CON LAY,铝合金,1.59766,0.00603504,0.212509476,350
336/400,26/7,钢芯铝绞线,1.83134,0.00743712,0.190140057,530
336400,30/7,钢芯铝绞线,1.88214,0.0077724,0.190140057,530
336400,CLASS A,铝合金,1.69164,0.0064008,0.189518685,410
350000,12 STRD,铜,1.8034,0.006858,0.11464327,670
350000,19 STRD,铜,1.72466,0.00652272,0.11464327,670
350000,CON LAY,铝合金,1.72466,0.00652272,0.182683585,399
397500,26/7,钢芯铝绞线,1.98882,0.0080772,0.160935539,590
397500,30/7,钢芯铝绞线,2.04724,0.00847344,0.160935539,600
397500,CLASS A,铝合金,1.83896,0.00694944,0.160314166,440
400000,19 STRD,铜,1.84404,0.00697992,0.100600246,730
450000,19 STRD,铜,1.9558,0.00740664,0.089664086,780
450000,CON LAG,铝合金,1.9558,0.00740664,0.142294357,450
477000,26/7,钢芯铝绞线,2.17932,0.0088392,0.134216511,670
477000,30/7,钢芯铝绞线,2.24282,0.00926592,0.134216511,670
477000,CLASS A,铝合金,2.0193,0.00774192,0.134216511,510
500000,19 STRD,铜,2.05994,0.00780288,0.080964868,840
500000,37 STRD,铜,2.06756,0.0079248,0.080964868,840
500000,CON LAY,铝合金,2.06502,0.0079248,0.128002784,483
556500,26/7,钢芯铝绞线,2.35458,0.00954024,0.115513192,730
556500,30/7,钢芯铝绞线,2.42062,0.00999744,0.115513192,730
556500,CLASS A,铝合金,2.17932,0.008382,0.115575329,560
600000,37 STRD,铜,2.26314,0.0086868,0.068040315,940
600000,CON LAY,铝合金,2.26314,0.0086868,0.106876111,520
605000,26/7,钢芯铝绞线,2.45364,0.00996696,0.106876111,760
605000,54/7,钢芯铝绞线,2.42062,0.00978408,0.110293661,750
636000,27/7,钢芯铝绞线,2.5146,0.0102108,0.100538109,780
636000,30/19,钢芯铝绞线,2.58826,0.01069848,0.100538109,780
636000,54/19,钢芯铝绞线,2.48158,0.01002792,0.104887718,770
636000,CLASS A,铝合金,2.33172,0.00896112,0.101283756,620
666600,54/7,钢芯铝绞线,2.54,0.01027176,0.099481775,800
700000,37 STRD,铜,2.44602,0.00938784,0.058843998,1040
700000,CON LAY,铝合金,2.44602,0.00938784,0.091963165,580
715500,26/7,钢芯铝绞线,2.66954,0.0108204,0.089601949,840
715500,30/19,钢芯铝绞线,2.74574,0.01133856,0.089601949,840
715500,54/7,钢芯铝绞线,2.63144,0.01063752,0.09208744,830
715500,CLASS A,铝合金,2.47396,0.00950976,0.090099047,680
750000,37 STRD,铝合金,2.53238,0.00972312,0.055177899,1090
750000,CON LAY,铝合金,2.53238,0.00972312,0.08637081,602
795000,26/7,钢芯铝绞线,2.81432,0.01143,0.080032808,900
795000,30/19,钢芯铝绞线,2.8956,0.01197864,0.080032808,910
795000,54/7,钢芯铝绞线,2.77622,0.01121664,0.085625163,900
795000,CLASS A,铝合金,2.60604,0.00999744,0.081399829,720
\ No newline at end of file
apply plugin: 'idea'
apply plugin: 'kotlin'
apply plugin: 'application'
mainClassName = 'AvailCapMain'
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
repositories {
mavenCentral()
}
dependencies {
compile('cn.zju:alg:2.1.1-rc32') {
transitive = false
}
compile "org.jgrapht:jgrapht-core:1.0.0"
compile "org.xerial:sqlite-jdbc:3.8.11.2"
// https://mvnrepository.com/artifact/com.alibaba/fastjson
compile "com.alibaba:fastjson:1.2.54"
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.11.0'
compile group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.11.0'
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
// compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
// testCompile group: 'junit', name: 'junit', version: '4.12'
}
compileKotlin {
kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
kotlinOptions.jvmTarget = "1.8"
}
jar {
from {
//添加依懒到打包文件
//configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtime.collect{zipTree(it)}
}
manifest {
attributes 'Main-Class': mainClassName
}
}
package com.jinyun.cap;
public interface CimConstants {
//measurement value sources:
public static final String MEASURE_VALUE_SOURCE_SCADA = "SCADA";
//the following is not used usually
public static final String MEASURE_VALUE_SOURCE_PMU = "PMU";
public static final String MEASURE_VALUE_SOURCE_SE = "SE";//todo:
}
package com.jinyun.cap;
import java.util.HashMap;
import java.util.Map;
public class FeederNameId {
Map<String, String> feederIdToName = new HashMap<>();
Map<String, String> feederNameToId = new HashMap<>();
public Map<String, String> getFeederIdToName() {
return feederIdToName;
}
public void setFeederIdToName(Map<String, String> feederIdToName) {
this.feederIdToName = feederIdToName;
}
public Map<String, String> getFeederNameToId() {
return feederNameToId;
}
public void setFeederNameToId(Map<String, String> feederNameToId) {
this.feederNameToId = feederNameToId;
}
}
package com.jinyun.cap;
import java.sql.Timestamp;
public class LineCurrentData {
Timestamp data;
double current;
public void setData(Timestamp data) {
this.data = data;
}
public Timestamp getData() {
return data;
}
public void setCurrent(double current) {
this.current = current;
}
public double getCurrent() {
return current;
}
}
package com.jinyun.cap;
public class LineParamData {
String devName;
String pole1;
String pole2;
double ratedI;
int type; // 1为JK,2为LGJ
public void setDevName(String devName) {
this.devName = devName;
}
public String getDevName() {
return devName;
}
public void setPole1(String pole1) {
this.pole1 = pole1;
}
public String getPole1() {
return pole1;
}
public void setPole2(String pole2) {
this.pole2 = pole2;
}
public String getPole2() {
return pole2;
}
public void setRatedI(double ratedI) {
this.ratedI = ratedI;
}
public double getRatedI() {
return ratedI;
}
public void setType(int type) {
this.type = type;
}
public int getType() {
return type;
}
}
package com.jinyun.cap;
public class LinePassRate {
String feederName;
String substation;
double[] passRate;
public String getFeederName() {
return feederName;
}
public void setFeederName(String feederName) {
this.feederName = feederName;
}
public String getSubstation() {
return substation;
}
public void setSubstation(String substation) {
this.substation = substation;
}
public double[] getPassRate() {
return passRate;
}
public void setPassRate(double[] passRate) {
this.passRate = passRate;
}
}
package com.jinyun.cap;
import java.util.ArrayList;
import java.util.List;
public class LoadPos {
double[] newLoad; // 接入的负荷
double[] newLoadI; // 接入负荷的电流
boolean[] canIn = new boolean[4];
double[][] swOrgLoad = new double[4][]; // 接入点开关原始负荷
double[][] swNewLoad = new double[4][96]; // 接入后开关电流
double[] swRateI = new double[4]; // 接入点开关限额
double[][] tfOrgLoad = new double[4][]; // 接入点公变原始负荷
double[][] tfNewLoad = new double[4][96]; // 接入后公变负荷
double[] tfRateCap = new double[4]; // 接入点公变额定容量
List<Integer> seasons = new ArrayList<>(4); // 季节
List<String> optEdges = new ArrayList<>(4); // 最优接入位置智能开关的mRID
List<String> optEdgeNames = new ArrayList<>(4); // 最优接入位置智能开关的名称
List<Double> seasonAvgCaps = new ArrayList<>(4); // 负荷接入后,线路剩余可接入容量(电流)的日平均值
List<Double> seasonMinCaps = new ArrayList<>(4); // 负荷接入后,线路剩余可接入容量(电流)的日最小值
List<Integer> seasons2 = new ArrayList<>(4);
List<String> optEdges2 = new ArrayList<>(4);
List<String> optEdgeNames2 = new ArrayList<>(4);
List<Double> seasonAvgCaps2 = new ArrayList<>(4);
List<Double> seasonMinCaps2 = new ArrayList<>(4);
String[] optTfs = new String[4]; // 最优接入位置公变的mRID
String[] optTfNames = new String[4]; // 最优接入位置公变的名称
String[] optPhase = new String[4]; // 公变接入相别
// season从0开始
public void calSwNewLoad(int season) {
for (int i = 0; i < 96; i++) {
swNewLoad[season][i] = newLoadI[i] + swOrgLoad[season][i];
}
}
public void calTfNewLoad(int season) {
for (int i = 0; i < 96; i++) {
tfNewLoad[season][i] = newLoad[i] + tfOrgLoad[season][i];
}
}
public void setSwOrgLoad(int season, double[] swOrgSeasonLoad) {
swOrgLoad[season] = swOrgSeasonLoad;
}
public void setSwNewLoad(int season, double[] swNewSeasonLoad) {
swNewLoad[season] = swNewSeasonLoad;
}
public void setTfOrgLoad(int season, double[] tfOrgSeasonLoad) {
tfOrgLoad[season] = tfOrgSeasonLoad;
}
public void setTfNewLoad(int season, double[] tfNewSeasonLoad) {
tfNewLoad[season] = tfNewSeasonLoad;
}
public void setOptTf(int season, String optTf) {
}
public double[] getNewLoad() {
return newLoad;
}
public void setNewLoad(double[] newLoad) {
this.newLoad = newLoad;
}
public double[] getNewLoadI() {
return newLoadI;
}
public void setNewLoadI(double[] newLoadI) {
this.newLoadI = newLoadI;
}
public boolean[] getCanIn() {
return canIn;
}
public void setCanIn(boolean[] canIn) {
this.canIn = canIn;
}
public double[][] getSwOrgLoad() {
return swOrgLoad;
}
public void setSwOrgLoad(double[][] swOrgLoad) {
this.swOrgLoad = swOrgLoad;
}
public double[][] getSwNewLoad() {
return swNewLoad;
}
public void setSwNewLoad(double[][] swNewLoad) {
this.swNewLoad = swNewLoad;
}
public double[] getSwRateI() {
return swRateI;
}
public void setSwRateI(double[] swRateI) {
this.swRateI = swRateI;
}
public double[][] getTfOrgLoad() {
return tfOrgLoad;
}
public void setTfOrgLoad(double[][] tfOrgLoad) {
this.tfOrgLoad = tfOrgLoad;
}
public double[][] getTfNewLoad() {
return tfNewLoad;
}
public void setTfNewLoad(double[][] tfNewLoad) {
this.tfNewLoad = tfNewLoad;
}
public double[] getTfRateCap() {
return tfRateCap;
}
public void setTfRateCap(double[] tfRateCap) {
this.tfRateCap = tfRateCap;
}
public void addLoadPos(int season, String optEdge, String optEdgeName, double seasonAvgCap, double seasonMinCap) {
this.seasons.add(season);
this.optEdges.add(optEdge);
this.optEdgeNames.add(optEdgeName);
this.seasonAvgCaps.add(seasonAvgCap);
this.seasonMinCaps.add(seasonMinCap);
}
public void addLoadPos2(int season, String optEdge, String optEdgeName, double seasonAvgCap, double seasonMinCap) {
this.seasons2.add(season);
this.optEdges2.add(optEdge);
this.optEdgeNames2.add(optEdgeName);
this.seasonAvgCaps2.add(seasonAvgCap);
this.seasonMinCaps2.add(seasonMinCap);
}
public List<Integer> getSeasons() {
return seasons;
}
public void setSeasons(List<Integer> seasons) {
this.seasons = seasons;
}
public List<String> getOptEdges() {
return optEdges;
}
public void setOptEdges(List<String> optEdges) {
this.optEdges = optEdges;
}
public List<String> getOptEdgeNames() {
return optEdgeNames;
}
public void setOptEdgeNames(List<String> optEdgeNames) {
this.optEdgeNames = optEdgeNames;
}
public List<Double> getSeasonAvgCaps() {
return seasonAvgCaps;
}
public void setSeasonAvgCaps(List<Double> seasonAvgCaps) {
this.seasonAvgCaps = seasonAvgCaps;
}
public List<Double> getSeasonMinCaps() {
return seasonMinCaps;
}
public void setSeasonMinCaps(List<Double> seasonMinCaps) {
this.seasonMinCaps = seasonMinCaps;
}
public List<Integer> getSeasons2() {
return seasons2;
}
public void setSeasons2(List<Integer> seasons2) {
this.seasons2 = seasons2;
}
public List<String> getOptEdges2() {
return optEdges2;
}
public void setOptEdges2(List<String> optEdges2) {
this.optEdges2 = optEdges2;
}
public List<String> getOptEdgeNames2() {
return optEdgeNames2;
}
public void setOptEdgeNames2(List<String> optEdgeNames2) {
this.optEdgeNames2 = optEdgeNames2;
}
public List<Double> getSeasonAvgCaps2() {
return seasonAvgCaps2;
}
public void setSeasonAvgCaps2(List<Double> seasonAvgCaps2) {
this.seasonAvgCaps2 = seasonAvgCaps2;
}
public List<Double> getSeasonMinCaps2() {
return seasonMinCaps2;
}
public void setSeasonMinCaps2(List<Double> seasonMinCaps2) {
this.seasonMinCaps2 = seasonMinCaps2;
}
public String[] getOptTfs() {
return optTfs;
}
public void setOptTfs(String[] optTfs) {
this.optTfs = optTfs;
}
public String[] getOptTfNames() {
return optTfNames;
}
public void setOptTfNames(String[] optTfNames) {
this.optTfNames = optTfNames;
}
public String[] getOptPhase() {
return optPhase;
}
public void setOptPhase(String[] optPhase) {
this.optPhase = optPhase;
}
}
package com.jinyun.cap;
public class LoadPosSeason {
int loadId;
String substation;
String feederName;
String canIn;
String tfName; // 最优接入位置公变的mRID
String tfMRID; // 最优接入位置公变的名称
String phase; // 公变接入相别
String time;
public int getLoadId() {
return loadId;
}
public void setLoadId(int loadId) {
this.loadId = loadId;
}
public String getSubstation() {
return substation;
}
public void setSubstation(String substation) {
this.substation = substation;
}
public String getFeederName() {
return feederName;
}
public void setFeederName(String feederName) {
this.feederName = feederName;
}
public String getCanIn() {
return canIn;
}
public void setCanIn(String canIn) {
this.canIn = canIn;
}
public String getTfName() {
return tfName;
}
public void setTfName(String tfName) {
this.tfName = tfName;
}
public String getTfMRID() {
return tfMRID;
}
public void setTfMRID(String tfMRID) {
this.tfMRID = tfMRID;
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
}
package com.jinyun.cap;
public class LoadPosSw {
String canIn;
String swName;
String swMRID;
double[] newLoadI; // 接入的负荷电流
double[] swOrgLoad; // 接入点开关原始负荷
double[] swNewLoad; // 接入后开关电流
double[] swRateI; // 接入点开关限额
public String getCanIn() {
return canIn;
}
public void setCanIn(String canIn) {
this.canIn = canIn;
}
public String getSwName() {
return swName;
}
public void setSwName(String swName) {
this.swName = swName;
}
public String getSwMRID() {
return swMRID;
}
public void setSwMRID(String swMRID) {
this.swMRID = swMRID;
}
public double[] getNewLoadI() {
return newLoadI;
}
public void setNewLoadI(double[] newLoadI) {
this.newLoadI = newLoadI;
}
public double[] getSwOrgLoad() {
return swOrgLoad;
}
public void setSwOrgLoad(double[] swOrgLoad) {
this.swOrgLoad = swOrgLoad;
}
public double[] getSwNewLoad() {
return swNewLoad;
}
public void setSwNewLoad(double[] swNewLoad) {
this.swNewLoad = swNewLoad;
}
public double[] getSwRateI() {
return swRateI;
}
public void setSwRateI(double[] swRateI) {
this.swRateI = swRateI;
}
}
package com.jinyun.cap;
public class LoadPosTf {
String canIn;
String tfName; // 最优接入位置公变的mRID
String tfMRID; // 最优接入位置公变的名称
String phase; // 公变接入相别
double[] newLoad; // 接入的负荷
double[] tfOrgLoad; // 接入点公变原始负荷
double[] tfNewLoad; // 接入后公变负荷
double[] tfRateCap; // 接入点公变额定容量
public String getCanIn() {
return canIn;
}
public void setCanIn(String canIn) {
this.canIn = canIn;
}
public String getTfName() {
return tfName;
}
public void setTfName(String tfName) {
this.tfName = tfName;
}
public String getTfMRID() {
return tfMRID;
}
public void setTfMRID(String tfMRID) {
this.tfMRID = tfMRID;
}
public String getPhase() {
return phase;
}
public void setPhase(String phase) {
this.phase = phase;
}
public double[] getNewLoad() {
return newLoad;
}
public void setNewLoad(double[] newLoad) {
this.newLoad = newLoad;
}
public double[] getTfOrgLoad() {
return tfOrgLoad;
}
public void setTfOrgLoad(double[] tfOrgLoad) {
this.tfOrgLoad = tfOrgLoad;
}
public double[] getTfNewLoad() {
return tfNewLoad;
}
public void setTfNewLoad(double[] tfNewLoad) {
this.tfNewLoad = tfNewLoad;
}
public double[] getTfRateCap() {
return tfRateCap;
}
public void setTfRateCap(double[] tfRateCap) {
this.tfRateCap = tfRateCap;
}
}
package com.jinyun.cap;
public class MaxMinAvailCap {
String feederName;
double availCap;
public String getFeederName() {
return feederName;
}
public void setFeederName(String feederName) {
this.feederName = feederName;
}
public double getAvailCap() {
return availCap;
}
public void setAvailCap(double availCap) {
this.availCap = availCap;
}
}
package com.jinyun.cap;
import java.sql.Timestamp;
public class SwitchData {
String devName;
String mRID;
Timestamp data;
double Ia;
double Ib;
double Ic;
public void setDevName(String devName) {
this.devName = devName;
}
public String getDevName() {
return devName;
}
public void setmRID(String mRID) {
this.mRID = mRID;
}
public String getmRID() {
return mRID;
}
public void setData(Timestamp data) {
this.data = data;
}
public Timestamp getData() {
return data;
}
public void setIa(double ia) {
Ia = ia;
}
public double getIa() {
return Ia;
}
public void setIb(double ib) {
Ib = ib;
}
public double getIb() {
return Ib;
}
public void setIc(double ic) {
Ic = ic;
}
public double getIc() {
return Ic;
}
}
package com.jinyun.cap;
import java.sql.Timestamp;
public class TFData {
String devName;
String mRID;
Timestamp date;
double Ia;
double Ib;
double Ic;
double Ua;
double Ub;
double Uc;
public void setDevName(String devName) {
this.devName = devName;
}
public String getDevName() {
return devName;
}
public void setmRID(String mRID) {
this.mRID = mRID;
}
public String getmRID() {
return mRID;
}
public void setDate(Timestamp date) {
this.date = date;
}
public Timestamp getDate() {
return date;
}
public void setIa(double ia) {
Ia = ia;
}
public double getIa() {
return Ia;
}
public void setIb(double ib) {
Ib = ib;
}
public double getIb() {
return Ib;
}
public void setIc(double ic) {
Ic = ic;
}
public double getIc() {
return Ic;
}
public void setUa(double ua) {
Ua = ua;
}
public double getUa() {
return Ua;
}
public void setUb(double ub) {
Ub = ub;
}
public double getUb() {
return Ub;
}
public void setUc(double uc) {
Uc = uc;
}
public double getUc() {
return Uc;
}
}
package com.jinyun.cap;
public class TfOverLoadRate {
String feederName;
String devName;
String mRID;
String lineName;
String lineMRID;
String substation;
double[] overLoadRate;
public String getFeederName() {
return feederName;
}
public void setFeederName(String feederName) {
this.feederName = feederName;
}
public String getDevName() {
return devName;
}
public void setDevName(String devName) {
this.devName = devName;
}
public String getmRID() {
return mRID;
}
public void setmRID(String mRID) {
this.mRID = mRID;
}
public String getSubstation() {
return substation;
}
public void setSubstation(String substation) {
this.substation = substation;
}
public String getLineName() {
return lineName;
}
public void setLineName(String lineName) {
this.lineName = lineName;
}
public String getLineMRID() {
return lineMRID;
}
public void setLineMRID(String lineMRID) {
this.lineMRID = lineMRID;
}
public double[] getOverLoadRate() {
return overLoadRate;
}
public void setOverLoadRate(double[] overLoadRate) {
this.overLoadRate = overLoadRate;
}
}
package com.jinyun.cap;
public class TfUb {
int loadState;
String devName;
String mRID;
String lineName;
String lineMRID;
String substation;
double maxLoad;
double ratedCap;
double ub;
double[] monthUb;
public int getLoadState() {
return loadState;
}
public void setLoadState(int loadState) {
this.loadState = loadState;
}
public String getDevName() {
return devName;
}
public void setDevName(String devName) {
this.devName = devName;
}
public String getmRID() {
return mRID;
}
public void setmRID(String mRID) {
this.mRID = mRID;
}
public String getSubstation() {
return substation;
}
public void setSubstation(String substation) {
this.substation = substation;
}
public String getLineName() {
return lineName;
}
public void setLineName(String lineName) {
this.lineName = lineName;
}
public String getLineMRID() {
return lineMRID;
}
public void setLineMRID(String lineMRID) {
this.lineMRID = lineMRID;
}
public double getMaxLoad() {
return maxLoad;
}
public void setMaxLoad(double maxLoad) {
this.maxLoad = maxLoad;
}
public double getRatedCap() {
return ratedCap;
}
public void setRatedCap(double ratedCap) {
this.ratedCap = ratedCap;
}
public double getUb() {
return ub;
}
public void setUb(double ub) {
this.ub = ub;
}
public double[] getMonthUb() {
return monthUb;
}
public void setMonthUb(double[] monthUb) {
this.monthUb = monthUb;
}
}
package com.jinyun.cap;
public class WarnLine {
int loadState;
String devName;
String mRID;
String substation;
String switchName;
String switchMRID;
double maxI;
double ratedCurrent;
double loadRate;
public int getLoadState() {
return loadState;
}
public void setLoadState(int loadState) {
this.loadState = loadState;
}
public String getDevName() {
return devName;
}
public void setDevName(String devName) {
this.devName = devName;
}
public String getmRID() {
return mRID;
}
public void setmRID(String mRID) {
this.mRID = mRID;
}
public String getSubstation() {
return substation;
}
public void setSubstation(String substation) {
this.substation = substation;
}
public String getSwitchName() {
return switchName;
}
public void setSwitchName(String switchName) {
this.switchName = switchName;
}
public String getSwitchMRID() {
return switchMRID;
}
public void setSwitchMRID(String switchMRID) {
this.switchMRID = switchMRID;
}
public double getMaxI() {
return maxI;
}
public void setMaxI(double maxI) {
this.maxI = maxI;
}
public double getRatedCurrent() {
return ratedCurrent;
}
public void setRatedCurrent(double ratedCurrent) {
this.ratedCurrent = ratedCurrent;
}
public double getLoadRate() {
return loadRate;
}
public void setLoadRate(double loadRate) {
this.loadRate = loadRate;
}
}
package com.jinyun.cap;
public class WarnTf {
int loadState;
String devName;
String mRID;
String lineName;
String lineMRID;
String substation;
double maxLoad;
double ratedCap;
double loadRate;
public int getLoadState() {
return loadState;
}
public void setLoadState(int loadState) {
this.loadState = loadState;
}
public String getDevName() {
return devName;
}
public void setDevName(String devName) {
this.devName = devName;
}
public String getmRID() {
return mRID;
}
public void setmRID(String mRID) {
this.mRID = mRID;
}
public String getSubstation() {
return substation;
}
public void setSubstation(String substation) {
this.substation = substation;
}
public String getLineName() {
return lineName;
}
public void setLineName(String lineName) {
this.lineName = lineName;
}
public String getLineMRID() {
return lineMRID;
}
public void setLineMRID(String lineMRID) {
this.lineMRID = lineMRID;
}
public double getMaxLoad() {
return maxLoad;
}
public void setMaxLoad(double maxLoad) {
this.maxLoad = maxLoad;
}
public double getRatedCap() {
return ratedCap;
}
public void setRatedCap(double ratedCap) {
this.ratedCap = ratedCap;
}
public double getLoadRate() {
return loadRate;
}
public void setLoadRate(double loadRate) {
this.loadRate = loadRate;
}
}
package com.jinyun.cap;
import zju.measure.DiscreteInfo
import zju.measure.MeasureInfo
/**
* 提供量测数据的接口
* @date 17-1-8.
*/
interface MeasureProvider {
fun getAnalogValue(measId: String, dataSource: String): Double?
fun getDiscreteValue(measId: String, dataSource: String): Int?
fun getAnalogsOfEquip(equip: String, dataSource: String): List<MeasureInfo>
fun getDiscreteOfEquip(equip: String, dataSource: String): DiscreteInfo?
fun setResourceManager(resourceManager: PowerSystem)
fun getSwitchStatus(switchId: String, dataSource: String): Boolean
}
\ No newline at end of file
###=====================================================================================
### appenders
###=====================================================================================
### direct log messages to stdout ###
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target=System.out
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n
### direct log messages to daily file ###
log4j.appender.DailyFile=org.apache.log4j.DailyRollingFileAppender
log4j.appender.DailyFile.File=c:/logs/aems.log
log4j.appender.DailyFile.DatePattern='.'yyyy-MM-dd
log4j.appender.DailyFile.layout=org.apache.log4j.PatternLayout
log4j.appender.DailyFile.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{2} %x %m%n
###=====================================================================================
### log level
###=====================================================================================
### the root
log4j.rootLogger=debug,stdout
#log4j.logger.org.mule=warn,stdout
log4j.logger.com.danga.MemCached.MemCachedClient=warn,stdout
log4j.logger.org.quartz=warn,stdout
#log4j.logger.zju.common.NewtonSolver=debug,stdout
<?xml version="1.0" encoding="UTF-8"?>
<Configuration status="WARN">
<Appenders>
<Console name="Console" target="SYSTEM_OUT">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %l - %msg%n"/>
<ThresholdFilter level="info" onMatch="ACCEPT" onMismatch="DENY"/>
</Console>
<File name="FileAppender" fileName="log/test.log" append="false">
<PatternLayout pattern="%d{HH:mm:ss.SSS} [%t] %-5level %l - %msg%n"/>
</File>
</Appenders>
<Loggers>
<Root level="info">
<AppenderRef ref="Console"/>
<AppenderRef ref="FileAppender"/>
</Root>
</Loggers>
</Configuration>
\ No newline at end of file
plugins {
id 'org.springframework.boot' version '2.1.6.RELEASE'
id 'io.spring.dependency-management' version '1.0.11.RELEASE'
id 'java'
}
apply plugin: 'application'
mainClassName = 'com.jinyun.web.DemoApplication'
group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
compile project(':jinyun:availCap')
implementation 'org.springframework.boot:spring-boot-starter'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
implementation group: 'com.auth0', name: 'java-jwt', version: '3.18.2'
compile group: 'org.mybatis.spring.boot', name: 'mybatis-spring-boot-starter', version: '2.2.0'
compile group: 'org.projectlombok', name: 'lombok', version: '1.16.22'
compile 'com.alibaba:fastjson:1.2.4'
runtimeOnly 'org.xerial:sqlite-jdbc:3.28.0'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
test {
useJUnitPlatform()
}
package com.jinyun.web;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableSwagger2
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
package com.jinyun.web;
import javax.sql.DataSource;
import org.apache.ibatis.session.SqlSessionFactory;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
@Configuration
@MapperScan("com.jinyun.**.dao") // 扫描DAO
public class MybatisConfig {
@Autowired
private DataSource dataSource;
@Bean
public SqlSessionFactory sqlSessionFactory() throws Exception {
SqlSessionFactoryBean sessionFactory = new SqlSessionFactoryBean();
sessionFactory.setDataSource(dataSource);
sessionFactory.setTypeAliasesPackage("com.jinyun.**.model"); // 扫描Model
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sessionFactory.setMapperLocations(resolver.getResources("classpath*:**/sqlmap/*.xml")); // 扫描映射文件
return sessionFactory.getObject();
}
}
package com.jinyun.web;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.ParameterBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.schema.ModelRef;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Parameter;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi(){
// 添加请求参数,我们这里把token作为请求头部参数传入后端
ParameterBuilder parameterBuilder = new ParameterBuilder();
List<Parameter> parameters = new ArrayList<Parameter>();
parameterBuilder.name("token").description("令牌")
.modelRef(new ModelRef("string")).parameterType("header").required(false).build();
parameters.add(parameterBuilder.build());
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.any()).paths(PathSelectors.any())
.build().globalOperationParameters(parameters);
// return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
// .select()
// .apis(RequestHandlerSelectors.any())
// .paths(PathSelectors.any()).build();
}
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title("SpringBoot API Doc")
.description("This is a restful api document of Spring Boot.")
.version("1.0")
.build();
}
}
package com.jinyun.web.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface PassToken {
boolean required() default true;
}
\ No newline at end of file
package com.jinyun.web.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.METHOD, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
public @interface UserLoginToken {
boolean required() default true;
}
package com.jinyun.web.config;
import com.jinyun.web.interceptor.AuthenticationInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
@Override
public void addInterceptors(InterceptorRegistry registry) {
registry.addInterceptor(authenticationInterceptor())
.addPathPatterns("/**"); // 拦截所有请求,通过判断是否有 @LoginRequired 注解 决定是否需要登录
}
@Bean
public AuthenticationInterceptor authenticationInterceptor() {
return new AuthenticationInterceptor();
}
}
package com.jinyun.web.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
public class WebConfig extends WebMvcConfigurerAdapter {
@Override
public void addCorsMappings(CorsRegistry registry) {
registry.addMapping("/**")
.allowedOrigins("*")
.allowedMethods("POST", "GET", "PUT", "OPTIONS", "DELETE")
.maxAge(3600)
.allowCredentials(true);
}
}
package com.jinyun.web.controller;
import com.alibaba.fastjson.JSONObject;
import com.jinyun.web.annotation.UserLoginToken;
import com.jinyun.web.entity.User;
import com.jinyun.web.service.CapService;
import com.jinyun.web.service.TokenService;
import com.jinyun.web.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
@Api(value = "desc of class", tags="DataImport",description = "数据导入")
//@RestController
@RequestMapping("import")
public class DataImportController {
@Autowired
CapService capService;
@ApiOperation("数据导入")
@PostMapping("/upload")
public String upload(@RequestBody MultipartFile file) throws IOException {
// for(MultipartFile file:files){
// String fileName = file.getOriginalFilename();
// String target = "d:/";
// File dest = new File(target+fileName);
// try {
// file.transferTo(dest);
// System.out.println( "上传成功");;
// } catch (IOException e) {
// e.printStackTrace();
// } catch (IllegalStateException e) {
// e.printStackTrace();
// }
// System.out.println( "上传失败");;
// }
String fileName = file.getOriginalFilename();
String target = "d:/";
File dest = new File(target+fileName);
try {
file.transferTo(dest);
return "上传成功";
} catch (IOException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
}
return "上传成功";
}
@ApiOperation(value = "数据导入列表", notes = "")
@RequestMapping(value = "/dataImportList",method = RequestMethod.GET)
public Object transformerInfoDetail() {
List result = capService.dataImportList();
return result;
}
}
package com.jinyun.web.controller;
import com.jinyun.web.annotation.UserLoginToken;
import com.jinyun.web.service.CapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
@Api(value = "desc of class", tags="LineBase",description = "线路台区")
@RestController
@RequestMapping("lineBase")
public class LineBaseController {
@Autowired
CapService capService;
@ApiOperation(value = "基础信息", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "开关ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/baseInfo",method = RequestMethod.GET)
@UserLoginToken
public Object baseInfo(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.baseInfo(mRID);
return result;
}
@ApiOperation(value = "夏季分析", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "开关ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/lineSummer",method = RequestMethod.GET)
@UserLoginToken
public Object lineSummer(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.lineSummer(mRID);
return result;
}
@ApiOperation(value = "冬季分析", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "开关ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/lineWinter",method = RequestMethod.GET)
@UserLoginToken
public Object lineWinter(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.lineWinter(mRID);
return result;
}
@ApiOperation(value = "峰谷分析", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "开关ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/linePs",method = RequestMethod.GET)
@UserLoginToken
public Object linePs(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.linePs(mRID);
return result;
}
@ApiOperation(value = "开关线路信息", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "线路ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/lineInfo",method = RequestMethod.GET)
@UserLoginToken
public Object lineInfo(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.lineInfo(mRID);
return result;
}
@ApiOperation(value = "公变信息", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "公变ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/transformerInfo",method = RequestMethod.GET)
@UserLoginToken
public Object transformerInfo(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.transformerInfo(mRID);
return result;
}
@ApiOperation(value = "线路信息明细", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "线路ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/lineInfoDetail",method = RequestMethod.GET)
@UserLoginToken
public Object lineInfoDetail(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.lineInfoDetail(mRID);
return result;
}
@ApiOperation(value = "公变信息明细", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "mRID", value = "公变ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/transformerInfoDetail",method = RequestMethod.GET)
@UserLoginToken
public Object transformerInfoDetail(@RequestParam("mRID") String mRID) {
Map<String,Object> result = capService.transformerInfoDetail(mRID);
return result;
}
}
package com.jinyun.web.controller;
import com.jinyun.web.annotation.UserLoginToken;
import com.jinyun.web.service.CapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(value = "desc of class", tags="LoadPos",description = "负荷接入分析")
@RestController
@RequestMapping("loadPos")
public class LoadPosController {
@Autowired
CapService capService;
@ApiOperation(value = "分析结果列表", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
@ApiImplicitParam(name = "rows", value = "行数", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
})
@RequestMapping(value = "/loadPosList",method = RequestMethod.GET)
@UserLoginToken
public Object loadPosSeason(@RequestParam("page") int page,@RequestParam("rows") int rows) {
int total = capService.loadPosListCout();
List loadPosList = new ArrayList();
if(total>0){
loadPosList = capService.loadPosList(page,rows);
}
Map<String,Object> result = new HashMap<>();
result.put("total",total);
result.put("rows",loadPosList);
return result;
}
@ApiOperation(value = "线路名称列表", notes = "")
@RequestMapping(value = "/lineNameList",method = RequestMethod.GET)
@UserLoginToken
public Object lineNameList() {
List result = capService.lineNameList();
return result;
}
@ApiOperation(value = "负荷接入分析", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "lineName", value = "线路名称", dataType = "string", paramType = "query",required = true),
@ApiImplicitParam(name = "cap", value = "负荷容量", dataType = "int", paramType = "query",example = "0",required = true),
@ApiImplicitParam(name = "type", value = "负荷特征(1为峰用电,2为谷用电,3为峰谷用电)", dataType = "int", paramType = "query",example = "0",required = true),
})
@RequestMapping(value = "/loadPosAnalysis",method = RequestMethod.GET)
@UserLoginToken
public Object loadPosAnalysis(@RequestParam("lineName") String lineName,@RequestParam("cap") int cap,@RequestParam("type") int type) {
Object result = capService.loadPosAnalysis(lineName, cap, type);
if(result != null)
return "分析完成";
else return "分析失败";
}
@ApiOperation(value = "高压负荷接入分析结果", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "loadId", value = "负荷ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/loadPosSw",method = RequestMethod.GET)
@UserLoginToken
public Object loadPosSw(@RequestParam("loadId") String loadId) {
Object result = capService.loadPosSw(loadId);
return result;
}
@ApiOperation(value = "低压负荷接入分析结果", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "loadId", value = "负荷ID", dataType = "string", paramType = "query",required = true),
})
@RequestMapping(value = "/loadPosTf",method = RequestMethod.GET)
@UserLoginToken
public Object loadPosTf(@RequestParam("loadId") String loadId) {
Object result = capService.loadPosTf(loadId);
return result;
}
}
package com.jinyun.web.controller;
import com.alibaba.fastjson.JSONObject;
import com.jinyun.web.annotation.UserLoginToken;
import com.jinyun.web.entity.User;
import com.jinyun.web.service.TokenService;
import com.jinyun.web.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.IOException;
@Api(value = "desc of class", tags="Login",description = "登录")
@RestController
@RequestMapping("login")
public class LoginController {
@Autowired
UserService userService;
@Autowired
TokenService tokenService;
//登录
@PostMapping("/login")
public Object login(@RequestBody User user){
JSONObject jsonObject=new JSONObject();
User userForBase=userService.findByUsername(user);
if(userForBase==null){
jsonObject.put("message","登录失败,用户不存在");
return jsonObject;
}else {
if (!userForBase.getPassword().equals(user.getPassword())){
jsonObject.put("message","登录失败,密码错误");
return jsonObject;
}else {
String token = tokenService.getToken(userForBase);
jsonObject.put("token", token);
jsonObject.put("user", userForBase);
return jsonObject;
}
}
}
@UserLoginToken
@GetMapping("/getMessage")
public String getMessage(){
return "你已通过验证";
}
}
package com.jinyun.web.controller;
import com.jinyun.web.annotation.UserLoginToken;
import com.jinyun.web.service.CapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(value = "desc of class", tags="LowMarginWarn",description = "低裕度预警分析")
@RestController
@RequestMapping("lowMarginWarn")
public class LowMarginWarnController {
@Autowired
CapService capService;
@ApiOperation(value = "lowMarginAnalysis", notes = "")
@RequestMapping(value = "/lowMarginAnalysis",method = RequestMethod.GET)
@UserLoginToken
public Object lowMarginAnalysis() {
Map<String, Object> result = capService.lowMarginAnalysis();
return result;
}
}
package com.jinyun.web.controller;
import com.jinyun.web.annotation.UserLoginToken;
import com.jinyun.web.service.CapService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api(value = "desc of class", tags="MainPage",description = "首页")
@RestController
@RequestMapping("mainPage")
public class MainPageController {
@Autowired
CapService capService;
@ApiOperation(value = "电网统计字段", notes = "")
@RequestMapping(value = "/gridStatistics",method = RequestMethod.GET)
@UserLoginToken
public Object gridStatistics() {
Map<String,Object> result = capService.gridStatistics();
return result;
}
@ApiOperation(value = "低裕度预警统计", notes = "")
@RequestMapping(value = "/lowMarginWarnStatistics",method = RequestMethod.GET)
@UserLoginToken
public Object lowMarginWarnStatistics() {
Map<String,Object> result = capService.lowMarginWarnStatistics();
return result;
}
@ApiOperation(value = "重载线路列表", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
@ApiImplicitParam(name = "rows", value = "行数", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
})
@RequestMapping(value = "/hardLineList",method = RequestMethod.GET)
@UserLoginToken
public Object hardLineList(@RequestParam("page") int page,@RequestParam("rows") int rows) {
int total = capService.hardLineListCount();
List hardLineList = new ArrayList();
if(total>0){
hardLineList = capService.hardLineList(page,rows);
}
Map<String,Object> result = new HashMap<>();
result.put("total",total);
result.put("rows",hardLineList);
return result;
}
@ApiOperation(value = "重载配变列表", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
@ApiImplicitParam(name = "rows", value = "行数", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
})
@RequestMapping(value = "/hardTransformerList",method = RequestMethod.GET)
@UserLoginToken
public Object hardTransformerList(@RequestParam("page") int page,@RequestParam("rows") int rows) {
int total = capService.hardTransformerListCount();
List hardTransformerList = new ArrayList();
if(total>0){
hardTransformerList = capService.hardTransformerList(page,rows);
}
Map<String,Object> result = new HashMap<>();
result.put("total",total);
result.put("rows",hardTransformerList);
return result;
}
@ApiOperation(value = "超载线路列表", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
@ApiImplicitParam(name = "rows", value = "行数", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
})
@RequestMapping(value = "/overLineList",method = RequestMethod.GET)
@UserLoginToken
public Object overLineList(@RequestParam("page") int page,@RequestParam("rows") int rows) {
int total = capService.overLineListCount();
List overLineList = new ArrayList();
if(total>0){
overLineList = capService.overLineList(page,rows);
}
Map<String,Object> result = new HashMap<>();
result.put("total",total);
result.put("rows",overLineList);
return result;
}
@ApiOperation(value = "超载配变列表", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
@ApiImplicitParam(name = "rows", value = "行数", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
})
@RequestMapping(value = "/overTransformerList",method = RequestMethod.GET)
@UserLoginToken
public Object overTransformerList(@RequestParam("page") int page,@RequestParam("rows") int rows) {
int total = capService.overTransformerListCount();
List overTransformerList = new ArrayList();
if(total>0){
overTransformerList = capService.overTransformerList(page,rows);
}
Map<String,Object> result = new HashMap<>();
result.put("total",total);
result.put("rows",overTransformerList);
return result;
}
@ApiOperation(value = "配变三相不平衡度", notes = "")
@RequestMapping(value = "/transformerUnbalance",method = RequestMethod.GET)
@UserLoginToken
public Object transformerUnbalance() {
Map<String,Object> result = capService.transformerUnbalance();
return result;
}
@ApiOperation(value = "配变三相不平衡度列表", notes = "")
@ApiImplicitParams({
@ApiImplicitParam(name = "page", value = "页码", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
@ApiImplicitParam(name = "rows", value = "行数", dataType = "int", paramType = "query",example = "0",defaultValue = "0",required = true),
})
@RequestMapping(value = "/transformerUnbalanceList",method = RequestMethod.GET)
@UserLoginToken
public Object transformerUnbalanceList(@RequestParam("page") int page,@RequestParam("rows") int rows) {
Map<String,Object> result = capService.transformerUnbalanceList(page,rows);
return result;
}
@ApiOperation(value = "线路电流合格率", notes = "")
@RequestMapping(value = "/linePassRate",method = RequestMethod.GET)
@UserLoginToken
public Object linePassRate() {
List result = capService.linePassRate();
return result;
}
@ApiOperation(value = "配变负荷越限统计", notes = "")
@RequestMapping(value = "/transformerOverLoadRate",method = RequestMethod.GET)
@UserLoginToken
public Object transformerOverLoadRate() {
Object result = capService.transformerOverLoadRate();
return result;
}
@ApiOperation(value = "线路可开放容量大小", notes = "")
@RequestMapping(value = "/maxMinAvailCap",method = RequestMethod.GET)
@UserLoginToken
public Object maxMinAvailCap() {
Map<String, Object> result = capService.maxMinAvailCap();
return result;
}
}
package com.jinyun.web.dao;
import com.jinyun.web.entity.User;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
public interface SysUserMapper {
public List<Map<String,Object>> selectAll();
User findByUsername(@Param("username") String username);
User findUserById(@Param("Id") String Id);
}
package com.jinyun.web.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ImportData {
String stationName;
String lineName;
String importTime;
}
package com.jinyun.web.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class LinePassRateWeb {
String feederName;
String substation;
double springRate;
double summerRate;
double autumnRate;
double winterRate;
}
package com.jinyun.web.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class TfOverLoadRateWeb {
String feederName;
String devName;
String mRID;
String lineName;
String lineMRID;
String substation;
double springRate;
double summerRate;
double autumnRate;
double winterRate;
}
package com.jinyun.web.entity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class User {
String Id;
String username;
String password;
}
package com.jinyun.web.interceptor;
import com.auth0.jwt.JWT;
import com.auth0.jwt.JWTVerifier;
import com.auth0.jwt.algorithms.Algorithm;
import com.auth0.jwt.exceptions.JWTDecodeException;
import com.auth0.jwt.exceptions.JWTVerificationException;
import com.jinyun.web.annotation.PassToken;
import com.jinyun.web.annotation.UserLoginToken;
import com.jinyun.web.entity.User;
import com.jinyun.web.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.method.HandlerMethod;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
/**
* @author jinbin
* @date 2018-07-08 20:41
*/
public class AuthenticationInterceptor implements HandlerInterceptor {
@Autowired
UserService userService;
@Override
public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object object) throws Exception {
if(httpServletRequest.getMethod().equals(RequestMethod.OPTIONS.name())){
httpServletResponse.setStatus(HttpStatus.OK.value());
return true;
}
String token = httpServletRequest.getHeader("token");// 从 http 请求头中取出 token
// 如果不是映射到方法直接通过
if(!(object instanceof HandlerMethod)){
return true;
}
HandlerMethod handlerMethod=(HandlerMethod)object;
Method method=handlerMethod.getMethod();
//检查是否有passtoken注释,有则跳过认证
if (method.isAnnotationPresent(PassToken.class)) {
PassToken passToken = method.getAnnotation(PassToken.class);
if (passToken.required()) {
return true;
}
}
//检查有没有需要用户权限的注解
if (method.isAnnotationPresent(UserLoginToken.class)) {
UserLoginToken userLoginToken = method.getAnnotation(UserLoginToken.class);
if (userLoginToken.required()) {
// 执行认证
if (token == null) {
throw new RuntimeException("403");
}
// 获取 token 中的 user id
String userId;
try {
userId = JWT.decode(token).getAudience().get(0);
} catch (JWTDecodeException j) {
throw new RuntimeException("401");
}
User user = userService.findUserById(userId);
if (user == null) {
throw new RuntimeException("用户不存在,请重新登录");
}
// 验证 token
JWTVerifier jwtVerifier = JWT.require(Algorithm.HMAC256(user.getPassword())).build();
try {
jwtVerifier.verify(token);
} catch (JWTVerificationException e) {
throw new RuntimeException("401");
}
return true;
}
}
return true;
}
@Override
public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
@Override
public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
}
}
package com.jinyun.web.interceptor;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
@ControllerAdvice
public class GloablExceptionHandler {
@ResponseBody
@ExceptionHandler(Exception.class)
public Object handleException(Exception e) {
String msg = e.getMessage();
if (msg == null || msg.equals("")) {
msg = "服务器出错";
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("message", msg);
return jsonObject;
}
}
package com.jinyun.web.service;
import java.util.List;
import java.util.Map;
public interface SysUserService {
List<Map<String,Object>> findAll();
}
\ No newline at end of file
package com.jinyun.web.service;
import com.auth0.jwt.JWT;
import com.auth0.jwt.algorithms.Algorithm;
import com.jinyun.web.entity.User;
import org.springframework.stereotype.Service;
import java.util.Date;
/**
* @author jinbin
* @date 2018-07-08 21:04
*/
@Service("TokenService")
public class TokenService {
public String getToken(User user) {
String token="";
Date expires = new Date(System.currentTimeMillis() + 24 * 60 * 60 * 1000);
token= JWT.create().withExpiresAt(expires)
.withAudience(user.getId())// 将 user id 保存到 token 里面
.sign(Algorithm.HMAC256(user.getPassword()));// 以 password 作为 token 的密钥
return token;
}
}
package com.jinyun.web.service;
import com.jinyun.web.dao.SysUserMapper;
import com.jinyun.web.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
/**
* @author jinbin
* @date 2018-07-08 20:52
*/
@Service("UserService")
public class UserService {
@Autowired
SysUserMapper userMapper;
public User findByUsername(User user){
return userMapper.findByUsername(user.getUsername());
}
public User findUserById(String userId) {
return userMapper.findUserById(userId);
}
}
package com.jinyun.web.service.impl;
import com.jinyun.web.dao.SysUserMapper;
import com.jinyun.web.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
@Service
public class SysUserServiceImpl implements SysUserService {
@Autowired
SysUserMapper sysUserMapper;
@Override
public List<Map<String,Object>> findAll() {
return sysUserMapper.selectAll();
}
}
package com.jinyin.web
import com.alibaba.fastjson.JSONObject
import com.jinyun.web.annotation.UserLoginToken
import com.jinyun.web.entity.User
import com.jinyun.web.service.TokenService
import com.jinyun.web.service.UserService
import io.swagger.annotations.Api
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PostMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@Api(value = "desc of class", tags = arrayOf("Login1"), description = "登录")
@RestController
@RequestMapping("login1")
class LoginController {
@Autowired
var userService: UserService? = null
@Autowired
var tokenService: TokenService? = null
//登录
@PostMapping("/login1")
fun login(user: User): Any {
val jsonObject = JSONObject()
val userForBase = userService!!.findByUsername(user)
return if (userForBase == null) {
jsonObject["message"] = "登录失败,用户不存在"
jsonObject
} else {
// if (userForBase.password != user.password) {
// jsonObject["message"] = "登录失败,密码错误"
// jsonObject
// } else {
// val token = tokenService!!.getToken(userForBase)
// jsonObject["token"] = token
// jsonObject["user"] = userForBase
// jsonObject
// }
}
}
@get:GetMapping("/getMessage1")
@get:UserLoginToken
val message: String
get() = "你已通过验证"
}
\ No newline at end of file
server:
port: 8080
spring:
datasource:
driverClassName: org.sqlite.JDBC
url: jdbc:sqlite:D:/test.db
username:
password:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jinyun.web.dao.SysUserMapper">
<select id="selectAll" resultType="map">
select * from test
</select>
<select id="findUserById" resultType="com.jinyun.web.entity.User">
select * from user where id=#{Id}
</select>
<select id="findByUsername" resultType="com.jinyun.web.entity.User">
select * from user where username=#{username}
</select>
</mapper>
\ No newline at end of file
include 'jinyun:availCap',
'jinyun:web'
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论