総当たり表の実装完了
| @@ -14,6 +14,8 @@ | ||
| 14 | 14 | <!-- ================================= Global Exception Definitions --> |
| 15 | 15 | |
| 16 | 16 | <global-exceptions> |
| 17 | + <exception path="/WEB-INF/view/systemErr.jsp" key="errors.system" | |
| 18 | + type="java.lang.Exception"/> | |
| 17 | 19 | </global-exceptions> |
| 18 | 20 | |
| 19 | 21 | <!-- =================================== Global Forward Definitions --> |
| @@ -25,8 +27,8 @@ | ||
| 25 | 27 | |
| 26 | 28 | <action-mappings> |
| 27 | 29 | </action-mappings> |
| 28 | - | |
| 29 | 30 | |
| 31 | + | |
| 30 | 32 | <!-- ===================================== Controller Configuration --> |
| 31 | 33 | |
| 32 | 34 | <controller |
| @@ -8,6 +8,7 @@ | ||
| 8 | 8 | import org.seasar.struts.annotation.Execute; |
| 9 | 9 | |
| 10 | 10 | import cx.myhome.ckoshien.dto.BattingResultDto; |
| 11 | +import cx.myhome.ckoshien.dto.GameResultDto; | |
| 11 | 12 | import cx.myhome.ckoshien.dto.PitchingResultDto; |
| 12 | 13 | import cx.myhome.ckoshien.entity.League; |
| 13 | 14 | import cx.myhome.ckoshien.form.ResultForm; |
| @@ -14,6 +15,7 @@ | ||
| 14 | 15 | import cx.myhome.ckoshien.service.BattingSumService; |
| 15 | 16 | import cx.myhome.ckoshien.service.LeagueService; |
| 16 | 17 | import cx.myhome.ckoshien.service.PitchingService; |
| 18 | +import cx.myhome.ckoshien.service.ResultService; | |
| 17 | 19 | |
| 18 | 20 | public class ResultAction { |
| 19 | 21 |
| @@ -30,7 +32,14 @@ | ||
| 30 | 32 | @Resource |
| 31 | 33 | public PitchingService pitchingService; |
| 32 | 34 | public List<PitchingResultDto> pitchingResultList; |
| 35 | +public List<GameResultDto> resultList; | |
| 36 | +@Resource | |
| 37 | +public ResultService resultService; | |
| 38 | +public int length; | |
| 39 | +public List<GameResultDto> opponentList; | |
| 40 | +public List<GameResultDto> resultList2; | |
| 33 | 41 | |
| 42 | + | |
| 34 | 43 | @Execute(validator = false) |
| 35 | 44 | public String index(){ |
| 36 | 45 | leagueList=leagueService.findAllOrderById(); |
| @@ -44,7 +53,12 @@ | ||
| 44 | 53 | }catch(NumberFormatException e){ |
| 45 | 54 | return "index&redirect=true"; |
| 46 | 55 | } |
| 47 | - battingResultList=battingSumService.findByPeriod(league.beginDate, league.endDate); | |
| 56 | + | |
| 57 | + resultList=resultService.findGameResult(Integer.parseInt(resultForm.id)); | |
| 58 | + resultList2=resultList; | |
| 59 | + length=resultList.size(); | |
| 60 | + opponentList=resultService.findOpponentResult(Integer.parseInt(resultForm.id)); | |
| 61 | + battingResultList=battingSumService.findByPeriod(league.beginDate, league.endDate); | |
| 48 | 62 | pitchingResultList=pitchingService.findByPeriod(league.beginDate, league.endDate); |
| 49 | 63 | return "stats.jsp"; |
| 50 | 64 | } |
| @@ -1,9 +1,5 @@ | ||
| 1 | 1 | package cx.myhome.ckoshien.action; |
| 2 | 2 | |
| 3 | -import java.text.ParseException; | |
| 4 | -import java.text.SimpleDateFormat; | |
| 5 | -import java.util.ArrayList; | |
| 6 | -import java.util.Calendar; | |
| 7 | 3 | import java.util.List; |
| 8 | 4 | import java.sql.Date; |
| 9 | 5 | import javax.annotation.Resource; |
| @@ -12,8 +8,6 @@ | ||
| 12 | 8 | import org.seasar.struts.annotation.ActionForm; |
| 13 | 9 | import org.seasar.struts.annotation.Execute; |
| 14 | 10 | |
| 15 | -import sun.org.mozilla.javascript.internal.regexp.SubString; | |
| 16 | - | |
| 17 | 11 | import cx.myhome.ckoshien.dto.BattingResultDto; |
| 18 | 12 | import cx.myhome.ckoshien.entity.BattingSum; |
| 19 | 13 | import cx.myhome.ckoshien.entity.Game; |
| @@ -24,7 +18,6 @@ | ||
| 24 | 18 | import cx.myhome.ckoshien.entity.Team; |
| 25 | 19 | import cx.myhome.ckoshien.form.BattingSumForm; |
| 26 | 20 | import cx.myhome.ckoshien.form.GameSummaryForm; |
| 27 | -import cx.myhome.ckoshien.form.PlayerForm; | |
| 28 | 21 | import cx.myhome.ckoshien.logic.GameSummaryLogic; |
| 29 | 22 | import cx.myhome.ckoshien.service.BattingSumService; |
| 30 | 23 | import cx.myhome.ckoshien.service.GameService; |
| @@ -108,7 +101,9 @@ | ||
| 108 | 101 | game.leagueId=leagueList.get(i).id; |
| 109 | 102 | break; |
| 110 | 103 | } |
| 104 | + | |
| 111 | 105 | } |
| 106 | + | |
| 112 | 107 | gameService.insert(game); |
| 113 | 108 | battingSumForm = Beans.createAndCopy(BattingSumForm.class, gameSummaryForm).execute(); |
| 114 | 109 | for(int i=0;i<battingSumForm.atBats.size();i++){ |
| @@ -60,4 +60,15 @@ | ||
| 60 | 60 | .getResultList(); |
| 61 | 61 | return resultList; |
| 62 | 62 | } |
| 63 | + | |
| 64 | + public List<GameResultDto> findOpponentResult(Integer leagueId){ | |
| 65 | + Map<String, Object> param = new HashMap<String, Object>(); | |
| 66 | + param.put("leagueId", leagueId); | |
| 67 | + resultList= | |
| 68 | + jdbcManager | |
| 69 | + .selectBySqlFile(GameResultDto.class, "cx.myhome.ckoshien.sql.Opponent.sql", param) | |
| 70 | + .getResultList(); | |
| 71 | + return resultList; | |
| 72 | + } | |
| 73 | + | |
| 63 | 74 | } |
| \ No newline at end of file |
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | |
| 3 | 3 | import java.util.List; |
| 4 | 4 | |
| 5 | +import org.seasar.struts.annotation.IntRange; | |
| 5 | 6 | import org.seasar.struts.annotation.Required; |
| 6 | 7 | |
| 7 | 8 | public class GameSummaryForm { |
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | public class GameResultDto { |
| 4 | 4 | public Integer teamId; |
| 5 | 5 | public String teamName; |
| 6 | + public String shortName; | |
| 6 | 7 | public Integer gameCount; |
| 7 | 8 | public Integer win; |
| 8 | 9 | public Integer lose; |
| @@ -10,4 +11,5 @@ | ||
| 10 | 11 | public Double percentage; |
| 11 | 12 | public Integer points; |
| 12 | 13 | public Integer leagueId; |
| 14 | + public Integer opponent; | |
| 13 | 15 | } |
| @@ -0,0 +1,10 @@ | ||
| 1 | +SELECT | |
| 2 | + team_id, | |
| 3 | + opponent, | |
| 4 | + sum(win) as win, | |
| 5 | + sum(lose) as lose, | |
| 6 | + sum(draw) as draw, | |
| 7 | + league_id | |
| 8 | + FROM result | |
| 9 | + WHERE league_id=/*leagueId*/ | |
| 10 | + group by team_id,opponent; | |
| \ No newline at end of file |
| @@ -1,6 +1,7 @@ | ||
| 1 | 1 | SELECT |
| 2 | 2 | r.team_id, |
| 3 | 3 | team_name, |
| 4 | + short_name, | |
| 4 | 5 | sum(win)+sum(lose)+sum(draw) as game_count, |
| 5 | 6 | sum(win) as win, |
| 6 | 7 | sum(lose)as lose, |