| | |
| | | import com.dsh.course.feignClient.communityWorldCup.Model.WorldCup; |
| | | import com.dsh.course.feignClient.communityWorldCup.Model.WorldCupListAll; |
| | | import com.dsh.course.feignClient.communityWorldCup.WorldCupStoreClient; |
| | | import com.dsh.course.feignClient.communityWorldCup.Model.RegisteredPersonnel; |
| | | import com.dsh.course.feignClient.competition.model.Competition; |
| | | import com.dsh.course.feignClient.competition.model.CompetitionUser; |
| | | import com.dsh.course.feignClient.competition.model.GetPeopleQuery; |
| | | import com.dsh.guns.core.util.ToolUtil; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import com.dsh.guns.modular.system.util.DateUtil; |
| | | import com.dsh.guns.modular.system.util.ExcelUtil; |
| | | import com.dsh.guns.modular.system.util.QRCodeUtils; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | 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 java.sql.ResultSet; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.awt.image.BufferedImage; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.InputStream; |
| | | import java.io.OutputStream; |
| | | import java.net.URLEncoder; |
| | | import java.text.DateFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.zip.ZipEntry; |
| | | import java.util.zip.ZipOutputStream; |
| | | |
| | | /** |
| | | * @author zhibing.pu |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 跳转到已报名人员列表 |
| | | * @param model |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @RequestMapping("/openRegisteredPersonnel") |
| | | public String openRegisteredPersonnel(Model model, Integer id){ |
| | | model.addAttribute("id", id); |
| | | return PREFIX + "registeredPersonnel.html"; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 跳转到门店选择页面 |
| | |
| | | @ResponseBody |
| | | @PostMapping("/addWorldCup") |
| | | public ResultUtil addWorldCup(WorldCup worldCup, String stores){ |
| | | worldCup.setStatus(1); |
| | | if(worldCup.getStartTime().before(new Date())){ |
| | | worldCup.setStatus(2); |
| | | }else{ |
| | | worldCup.setStatus(1); |
| | | } |
| | | worldCup.setCreateTime(new Date()); |
| | | worldCup.setMatchNumber(0); |
| | | Integer integer = worldCupClient.addWorldCup(worldCup); |
| | |
| | | if(worldCup1.getStartTime().before(DateUtil.getDate())){ |
| | | return ResultUtil.error("赛事已开始,不能编辑"); |
| | | } |
| | | worldCupClient.editWorldCup(worldCup); |
| | | Integer maxPeople = worldCup1.getMaxPeople(); |
| | | int registeredNumber = worldCupClient.getRegisteredNumber(worldCup.getId()); |
| | | if(maxPeople.compareTo(registeredNumber) < 0){ |
| | | return ResultUtil.error("报名人数不能小于已报名人数"); |
| | | } |
| | | if(worldCup.getStartTime().before(new Date())){ |
| | | worldCup.setStatus(2); |
| | | }else{ |
| | | worldCup.setStatus(1); |
| | | } |
| | | worldCupClient.editWorldCup(JSON.toJSONString(worldCup)); |
| | | worldCupStoreClient.delWorldCupStore(worldCup.getId()); |
| | | JSONArray jsonArray = JSON.parseArray(stores); |
| | | for (int i = 0; i < jsonArray.size(); i++) { |
| | |
| | | WorldCup worldCup = new WorldCup(); |
| | | worldCup.setId(id); |
| | | worldCup.setStatus(state); |
| | | worldCupClient.editWorldCup(worldCup); |
| | | worldCupClient.editWorldCup(JSON.toJSONString(worldCup)); |
| | | //开始处理已支付的退费 |
| | | worldCupClient.cancelWorldCupRefund(id); |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取已报名人员列表 |
| | | * @param registeredPersonnel |
| | | * @return |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/registeredPersonnel") |
| | | public Object registeredPersonnel(RegisteredPersonnel registeredPersonnel){ |
| | | return worldCupClient.getRegisteredPersonnel(registeredPersonnel); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 下载二维码压缩包 |
| | | * @param registeredPersonnel |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/downloadQRCodeZip") |
| | | public void downloadQRCodeZip(RegisteredPersonnel registeredPersonnel, HttpServletResponse response){ |
| | | try { |
| | | registeredPersonnel.setOffset(0); |
| | | registeredPersonnel.setLimit(10000); |
| | | Map<String, Object> maps = worldCupClient.getRegisteredPersonnel(registeredPersonnel); |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>)maps.get("rows"); |
| | | response.setContentType("APPLICATION/OCTET-STREAM"); |
| | | response.setHeader("Content-Disposition","attachment; filename=" + URLEncoder.encode("二维码", "UTF-8") + ".zip"); |
| | | ZipOutputStream out = new ZipOutputStream(response.getOutputStream()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmssSSS"); |
| | | for(Map<String, Object> map : list){ |
| | | String id = map.get("id").toString(); |
| | | String isStudent = map.get("isStudent").toString(); |
| | | String name = map.get("name").toString() + sdf.format(new Date()); |
| | | String content = "{\"id\":" + id + ",\"isStudent\":" + isStudent + "}"; |
| | | QRCodeUtils.encode(content, name, "/usr/playpai/qrcode", false); |
| | | File file = new File("/usr/playpai/qrcode/" + name + ".jpg"); |
| | | FileInputStream fileInputStream = new FileInputStream(file); |
| | | |
| | | out.putNextEntry(new ZipEntry(name + ".jpg")); |
| | | int len = 0; |
| | | byte[] buf = new byte[1024]; |
| | | while ((len = fileInputStream.read(buf, 0, 1024)) != -1) { |
| | | out.write(buf, 0, len); |
| | | } |
| | | fileInputStream.close(); |
| | | } |
| | | out.finish(); |
| | | out.close(); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 下载已报名人员 |
| | | * @param registeredPersonnel |
| | | * @param response |
| | | */ |
| | | @ResponseBody |
| | | @GetMapping("/exportPersonnel") |
| | | public void exportPersonnel(RegisteredPersonnel registeredPersonnel, HttpServletResponse response){ |
| | | try { |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName ="已报名人员.xls"; |
| | | String[] title = new String[] {"姓名","性别","年龄","联系电话","身份证号","状态"}; |
| | | registeredPersonnel.setOffset(0); |
| | | registeredPersonnel.setLimit(10000); |
| | | Map<String, Object> maps = worldCupClient.getRegisteredPersonnel(registeredPersonnel); |
| | | List<Map<String, Object>> list = (List<Map<String, Object>>)maps.get("rows"); |
| | | 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("gender").toString(); |
| | | values[i][2] = d.get("age").toString(); |
| | | values[i][3] = d.get("phone").toString(); |
| | | values[i][4] = d.get("idcard").toString(); |
| | | Integer state1 = Integer.valueOf(d.get("state").toString()); |
| | | if(1 == state1){ |
| | | values[i][5] = "正常"; |
| | | }else { |
| | | values[i][5] = "取消"; |
| | | } |
| | | } |
| | | HSSFWorkbook wb = ExcelUtil.getHSSFWorkbook("Variance"+time1, title, values, null); |
| | | ExcelUtil.setResponseHeader(response, fileName); |
| | | OutputStream os = response.getOutputStream(); |
| | | wb.write(os); |
| | | os.flush(); |
| | | os.close(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |