• R/O
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revision11 (tree)
Time2015-06-29 21:21:28
Authorckoshien

Log Message

スタッツ画面打率TOP10を実装。

Change Summary

Incremental Difference

--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/action/ResultAction.java (revision 10)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/action/ResultAction.java (revision 11)
@@ -1,5 +1,7 @@
11 package cx.myhome.ckoshien.action;
22
3+import java.util.ArrayList;
4+import java.util.Collections;
35 import java.util.List;
46
57 import javax.annotation.Resource;
@@ -12,10 +14,13 @@
1214 import cx.myhome.ckoshien.dto.PitchingResultDto;
1315 import cx.myhome.ckoshien.entity.League;
1416 import cx.myhome.ckoshien.form.ResultForm;
17+import cx.myhome.ckoshien.logic.ResultLogic;
1518 import cx.myhome.ckoshien.service.BattingSumService;
1619 import cx.myhome.ckoshien.service.LeagueService;
1720 import cx.myhome.ckoshien.service.PitchingService;
1821 import cx.myhome.ckoshien.service.ResultService;
22+import cx.myhome.ckoshien.util.HomerunComparator;
23+import cx.myhome.ckoshien.util.RbiComparator;
1924
2025 public class ResultAction {
2126
@@ -38,6 +43,10 @@
3843 public int length;
3944 public List<GameResultDto> opponentList;
4045 public List<GameResultDto> resultList2;
46+public List<BattingResultDto> averageTop10;
47+public List<BattingResultDto> homerunTop10;
48+public ResultLogic resultLogic;
49+public List<BattingResultDto> rbiTop10;
4150
4251
4352 @Execute(validator = false)
@@ -53,7 +62,7 @@
5362 }catch(NumberFormatException e){
5463 return "index&redirect=true";
5564 }
56-
65+ System.setProperty("java.util.Arrays.useLegacyMergeSort", "true");
5766 resultList=resultService.findGameResult(Integer.parseInt(resultForm.id));
5867 resultList2=resultList;
5968 length=resultList.size();
@@ -60,6 +69,26 @@
6069 opponentList=resultService.findOpponentResult(Integer.parseInt(resultForm.id));
6170 battingResultList=battingSumService.findByPeriod(league.beginDate, league.endDate);
6271 pitchingResultList=pitchingService.findByPeriod(league.beginDate, league.endDate);
72+ resultLogic=new ResultLogic();
73+ //打率TOP10
74+ averageTop10=resultLogic.returnAverageTop10(battingResultList);
75+// Java7のソートにバグがありexceptionが発生するのでコメントアウト
76+// //HRTOP10
77+// homerunTop10=new ArrayList<BattingResultDto>();
78+// for(int i=0;i<battingResultList.size();i++){
79+// homerunTop10.add(battingResultList.get(i));
80+// }
81+// Collections.sort(homerunTop10, new HomerunComparator());
82+// Collections.reverse(homerunTop10);
83+// homerunTop10=resultLogic.returnHomerunTop10(homerunTop10);
84+// //打点TOP10
85+// rbiTop10=new ArrayList<BattingResultDto>();
86+// for(int i=0;i<battingResultList.size();i++){
87+// rbiTop10.add(battingResultList.get(i));
88+// }
89+// Collections.sort(rbiTop10, new RbiComparator());
90+// Collections.reverse(rbiTop10);
91+// rbiTop10=resultLogic.returnRbiTop10(rbiTop10);
6392 return "stats.jsp";
6493 }
6594 }
--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/logic/ResultLogic.java (nonexistent)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/logic/ResultLogic.java (revision 11)
@@ -0,0 +1,102 @@
1+package cx.myhome.ckoshien.logic;
2+
3+import java.util.ArrayList;
4+import java.util.List;
5+
6+import cx.myhome.ckoshien.dto.BattingResultDto;
7+
8+public class ResultLogic {
9+ public List<BattingResultDto> averageTop10;
10+ public BattingResultDto battingResultDto;
11+ public List<BattingResultDto> homerunTop10;
12+ public List<BattingResultDto> rbiTop10;
13+
14+ public List<BattingResultDto> returnAverageTop10(List<BattingResultDto> battingResultList){
15+ int j=0;
16+ int k=0;
17+ averageTop10=new ArrayList<BattingResultDto>();
18+ for(int i=0;i<battingResultList.size();i++){
19+ battingResultDto=new BattingResultDto();
20+ if(battingResultList.get(i).tpa>=42){
21+ j++;
22+ if (i>=1&&!(battingResultList.get(i-1).average==battingResultList.get(i).average)){
23+ battingResultDto.rank=j;
24+ k=j;
25+ }
26+ convert2BattingResultDto(battingResultList,i);
27+ if (battingResultDto.rank==null||battingResultDto.rank<=10){
28+ if (k>=11){
29+ break;
30+ }
31+ averageTop10.add(battingResultDto);
32+ }
33+ }
34+ }
35+ return averageTop10;
36+ }
37+
38+ public List<BattingResultDto> returnHomerunTop10(List<BattingResultDto> battingResultList){
39+ int j=0;
40+ int k=0;
41+ homerunTop10=new ArrayList<BattingResultDto>();
42+ for(int i=0;i<battingResultList.size();i++){
43+ battingResultDto=new BattingResultDto();
44+ j++;
45+ if (i==0){
46+ battingResultDto.rank=1;
47+ }
48+ if (i>=1 && (!battingResultList.get(i-1).homerun.equals(battingResultList.get(i).homerun))){
49+ battingResultDto.rank=j;
50+ k=j;
51+ }
52+ convert2BattingResultDto(battingResultList,i);
53+ if (battingResultDto.rank==null||battingResultDto.rank<=10){
54+ if (k>=11){
55+ break;
56+ }
57+ homerunTop10.add(battingResultDto);
58+
59+ }
60+ }
61+ return homerunTop10;
62+ }
63+
64+ public List<BattingResultDto> returnRbiTop10(List<BattingResultDto> battingResultList){
65+ int j=0;
66+ int k=0;
67+ rbiTop10=new ArrayList<BattingResultDto>();
68+ for(int i=0;i<battingResultList.size();i++){
69+ battingResultDto=new BattingResultDto();
70+ j++;
71+ if (i==0){
72+ battingResultDto.rank=1;
73+ }
74+ if (i>=1 && (!battingResultList.get(i-1).rbi.equals(battingResultList.get(i).rbi))){
75+ battingResultDto.rank=j;
76+ k=j;
77+ }
78+ convert2BattingResultDto(battingResultList,i);
79+ if (battingResultDto.rank==null||battingResultDto.rank<=10){
80+ if (k>=11){
81+ break;
82+ }
83+ rbiTop10.add(battingResultDto);
84+
85+ }
86+ }
87+ return rbiTop10;
88+ }
89+
90+ public void convert2BattingResultDto(List<BattingResultDto> battingResultList,int i){
91+ battingResultDto.atBats=battingResultList.get(i).atBats;
92+ battingResultDto.average=battingResultList.get(i).average;
93+ battingResultDto.fourBall=battingResultList.get(i).fourBall;
94+ battingResultDto.hit=battingResultList.get(i).hit;
95+ battingResultDto.homerun=battingResultList.get(i).homerun;
96+ battingResultDto.name=battingResultList.get(i).name;
97+ battingResultDto.rbi=battingResultList.get(i).rbi;
98+ battingResultDto.strikeOut=battingResultList.get(i).strikeOut;
99+ battingResultDto.tpa=battingResultList.get(i).tpa;
100+ battingResultDto.twobase=battingResultList.get(i).twobase;
101+ }
102+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/util/RbiComparator.java (nonexistent)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/util/RbiComparator.java (revision 11)
@@ -0,0 +1,24 @@
1+package cx.myhome.ckoshien.util;
2+
3+import java.util.Comparator;
4+
5+import cx.myhome.ckoshien.dto.BattingResultDto;
6+
7+public class RbiComparator implements Comparator<BattingResultDto>{
8+
9+ @Override
10+ public int compare(BattingResultDto o1, BattingResultDto o2) {
11+ if (o1.rbi > o2.rbi) {
12+ return 1;
13+
14+ } else if (o1.rbi == o2.rbi) {
15+ return 0;
16+
17+ } else {
18+ return -1;
19+
20+ }
21+
22+ }
23+
24+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/util/HomerunComparator.java (nonexistent)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/util/HomerunComparator.java (revision 11)
@@ -0,0 +1,24 @@
1+package cx.myhome.ckoshien.util;
2+
3+import java.util.Comparator;
4+
5+import cx.myhome.ckoshien.dto.BattingResultDto;
6+
7+public class HomerunComparator implements Comparator<BattingResultDto>{
8+
9+ @Override
10+ public int compare(BattingResultDto o1, BattingResultDto o2) {
11+ if (o1.homerun > o2.homerun) {
12+ return 1;
13+
14+ } else if (o1.homerun == o2.homerun) {
15+ return 0;
16+
17+ } else {
18+ return -1;
19+
20+ }
21+
22+ }
23+
24+}
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/form/GameSummaryForm.java (revision 10)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/form/GameSummaryForm.java (revision 11)
@@ -23,20 +23,32 @@
2323 @Required
2424 public String lastTeam;
2525 @Required
26+ @IntRange(min=0,max=40)
2627 public String firstRun;
2728 @Required
29+ @IntRange(min=0,max=40)
2830 public String lastRun;
2931 @Required
32+ @IntRange(min=0,max=20)
3033 public String top1st;
3134 @Required
35+ @IntRange(min=0,max=20)
3236 public String bottom1st;
37+ @IntRange(min=0,max=20)
3338 public String top2nd;
39+ @IntRange(min=0,max=20)
3440 public String bottom2nd;
41+ @IntRange(min=0,max=20)
3542 public String top3rd;
43+ @IntRange(min=0,max=20)
3644 public String bottom3rd;
45+ @IntRange(min=0,max=20)
3746 public String top4th;
47+ @IntRange(min=0,max=20)
3848 public String bottom4th;
49+ @IntRange(min=0,max=20)
3950 public String top5th;
51+ @IntRange(min=0,max=20)
4052 public String bottom5th;
4153
4254
@@ -44,16 +56,24 @@
4456 public List<String> playerRecordId;
4557 public List<String> playerId;
4658 //打席数
59+ @IntRange(min=1,max=8)
4760 public List<String> tpa;
4861 //打数
62+ @IntRange(min=0,max=8)
4963 public List<String> atBats;
5064 //安打
65+ @IntRange(min=0,max=8)
5166 public List<String> hit;
5267 //打点
68+ @IntRange(min=0,max=10)
5369 public List<String> rbi;
70+ @IntRange(min=0,max=8)
5471 public List<String> fourBall;
72+ @IntRange(min=0,max=8)
5573 public List<String> strikeOut;
74+ @IntRange(min=0,max=8)
5675 public List<String> twoBase;
76+ @IntRange(min=0,max=8)
5777 public List<String> homerun;
5878 //
5979 public List<String> myTeamId;
@@ -62,15 +82,25 @@
6282
6383 //投球成績関連
6484 public List<String> p_playerId;
85+ @IntRange(min=0,max=5)
6586 public List<String> inning1;
87+ @IntRange(min=0,max=2)
6688 public List<String> inning2;
89+ @IntRange(min=1,max=48)
6790 public List<String> pa;
91+ @IntRange(min=0,max=40)
6892 public List<String> p_hit;
93+ @IntRange(min=0,max=10)
6994 public List<String> p_homerun;
95+ @IntRange(min=0,max=20)
7096 public List<String> p_fourBall;
97+ @IntRange(min=0,max=15)
7198 public List<String> p_strikeOut;
99+ @IntRange(min=0,max=40)
72100 public List<String> runs;
101+ @IntRange(min=0,max=1)
73102 public List<String> complete;
103+ @IntRange(min=0,max=1)
74104 public List<String> shutout;
75105 public List<String> result;
76106 public List<String> p_myTeamId;
--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/dto/PitchingResultDto.java (revision 10)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/dto/PitchingResultDto.java (revision 11)
@@ -2,6 +2,7 @@
22
33 public class PitchingResultDto {
44 public Integer playerId;
5+ public Integer rank;
56 public String name;
67 public Integer gameCount;
78 public Double era;
--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/dto/BattingResultDto.java (revision 10)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/dto/BattingResultDto.java (revision 11)
@@ -11,6 +11,7 @@
1111 private static final long serialVersionUID = 1L;
1212
1313 public Integer playerId;
14+ public Integer rank;
1415 public String name;
1516
1617 public Double average;
--- trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/dto/GameResultDto.java (revision 10)
+++ trunk/JCBLScore/src/main/java/cx/myhome/ckoshien/dto/GameResultDto.java (revision 11)
@@ -2,6 +2,7 @@
22
33 public class GameResultDto {
44 public Integer teamId;
5+ public Integer rank;
56 public String teamName;
67 public String shortName;
78 public Integer gameCount;