首页 > 代码库 > 马拉松参赛人员旧版本最终版(私藏版)

马拉松参赛人员旧版本最终版(私藏版)

接上次改了一些后,加入map

>>>2*健康达人奖(每日步数达7500) 1*参与奖(11.11活动券 满246减46

service层代码如下:

public List<JoinMarathonView> joinMarathonList() {
List<JoinMarathonView> marathonjoinAllList = joinMarathonDao.getNamesByMarathon();
List<String> cityofonelist = null;
HashMap<String, Integer> awardMap = null;
int count = 0;
for (JoinMarathonView joinmaraOneList : marathonjoinAllList) {
List<JoinMarathonView> citysOfIdList = getCitysById(joinmaraOneList.getMemberId());
count = 0;
cityofonelist = new ArrayList<String>();
for (JoinMarathonView ct : citysOfIdList) {
cityofonelist.add(ct.getCity());
count++;
}
if (cityofonelist == null) {
joinmaraOneList.setCity("");
} else {
joinmaraOneList.setCity(cityofonelist.toString().replace("[", "").replace("]", ""));
joinmaraOneList.setCount(count);
}

List<Award> awards = getAwardsById(joinmaraOneList.getMemberId()); // 获取每个人的总奖牌
if (awards == null) {
joinmaraOneList.setAward_count(null);
} else {
awardMap = new HashMap<String, Integer>();
for (Award award : awards) {
String ac = award.getName()+"("+award.getMemo()+")";
if (awardMap.containsKey(ac)) {
awardMap.put(ac, (awardMap.get(ac).intValue()) + 1);
} else {
awardMap.put(ac, 1);
}
}
joinmaraOneList.setAward_count(awardMap);
}
}

return marathonjoinAllList;
}

附ftl页面显示块代码:

<table id="datatable"
class="table table-striped table-bordered dt-responsive nowrap order-column"
cellspacing="0" width="100%">
<thead>
<tr>
<th>人员ID</th>
<th>参赛人员姓名</th>
<th>性别</th>
<th>手机号</th>
<th>所在单位</th>
<th>参赛次数</th>
<th>参赛城市</th>
<th>报名时间</th>
<th>获得过的奖牌</th>
</tr>
</thead>
<tbody>
<#list joinList as join>
<tr>
<td>${join.id}</td><!-- 隐藏列 -->
<td class=‘dt-left‘><a href="http://www.mamicode.com/admin/marathon/detail?joinnameid=${join.id}">${join.membName}</a></td>
<td>${(join.gender == "1") ? string("男", "女")}</td>
<td>${join.mobile}</td>
<td>${join.hospital}</td>
<td>${join.count}</td>
<td>${join.city}</td>
<td>${join.createTime?string("yyyy-MM-dd HH:mm:ss")}</td>
<td>
<#list join.award_count?keys as key>
${join.award_count[key]}*${key}
</#list>
</td>
</tr>
</#list>
</tbody>
</table>

马拉松参赛人员旧版本最终版(私藏版)