| | |
| | | |
| | | import com.dsh.course.feignClient.communityWorldCup.Model.*; |
| | | import com.dsh.course.feignClient.communityWorldCup.WorldCupClient; |
| | | import com.dsh.guns.modular.system.util.ExcelUtil; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | | 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.ResponseBody; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.OutputStream; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | |
| | | |
| | | |
| | | @RequestMapping("/openWorldCupGameStatisticsListInfo") |
| | | public String openWorldCupGameStatisticsListInfo(Model model, Integer id){ |
| | | model.addAttribute("id", id); |
| | | public String openWorldCupGameStatisticsListInfo(Model model, Long participantId, Integer participantType){ |
| | | model.addAttribute("participantId", participantId); |
| | | model.addAttribute("participantType", participantType); |
| | | return PREFIX + "worldCupGameStatisticsListInfo.html"; |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping("/openUserGameRecord") |
| | | public String openUserGameRecord(){ |
| | | return PREFIX + "userGameRecord.html"; |
| | | } |
| | | |
| | | |
| | | |
| | |
| | | worldCupClient.changeScore(changeScore); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出用户统计列表 |
| | | * @param worldCupGameStatisticsInfoList |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/exportUserStatistics") |
| | | public void exportUserStatistics(WorldCupGameStatisticsInfoList worldCupGameStatisticsInfoList, HttpServletResponse response){ |
| | | worldCupGameStatisticsInfoList.setOffset(0); |
| | | worldCupGameStatisticsInfoList.setLimit(100000); |
| | | Map<String, Object> map = worldCupClient.getUserGameRecordList(worldCupGameStatisticsInfoList); |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>)map.get("rows"); |
| | | |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName ="用户统计.xls"; |
| | | String[] title = new String[] {"用户姓名","联系电话","身份证号","已比赛场次","胜-负场次","胜率"}; |
| | | String[][] values = new String[list.size()][]; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Map<String, Object> d = list.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0] = d.get("name").toString(); |
| | | values[i][1] = d.get("phone").toString(); |
| | | values[i][2] = null == d.get("idcard") ? "" : d.get("idcard").toString(); |
| | | values[i][3] = d.get("totalSession").toString(); |
| | | values[i][4] = d.get("win").toString() + "-" + d.get("lose").toString(); |
| | | values[i][5] = d.get("winRate").toString() + "%"; |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取用户比赛列表 |
| | | * @param worldCupGameStatisticsInfoList |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/getUserGameRecordList") |
| | | public Object getUserGameRecordList(WorldCupGameStatisticsInfoList worldCupGameStatisticsInfoList){ |
| | | return worldCupClient.getUserGameRecordList(worldCupGameStatisticsInfoList); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 获取用户比赛记录 |
| | | * @param userGameRecordList |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/userGameRecordList") |
| | | public Object userGameRecordList(UserGameRecordList userGameRecordList){ |
| | | return worldCupClient.userGameRecordList(userGameRecordList); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 导出用户比赛记录 |
| | | * @param userGameRecordList |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/exportUserGameRecord") |
| | | public void exportUserGameRecord(UserGameRecordList userGameRecordList, HttpServletResponse response){ |
| | | userGameRecordList.setOffset(0); |
| | | userGameRecordList.setLimit(100000); |
| | | Map<String, Object> map = worldCupClient.userGameRecordList(userGameRecordList); |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>)map.get("rows"); |
| | | |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName ="比赛记录.xls"; |
| | | String[] title = new String[] {"用户姓名","参与比赛","比赛时间","比分","结果"}; |
| | | String[][] values = new String[list.size()][]; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Map<String, Object> d = list.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0] = d.get("userName").toString(); |
| | | values[i][1] = d.get("name").toString(); |
| | | values[i][2] = d.get("startTime").toString(); |
| | | values[i][3] = d.get("score").toString(); |
| | | values[i][4] = d.get("matchResult").toString(); |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook(time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |