| | |
| | | package com.dsh.guns.modular.system.controller.code; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.dsh.course.feignClient.account.model.TAppUser; |
| | | import com.dsh.course.feignClient.competition.CompetitionClient; |
| | | import com.dsh.course.feignClient.competition.model.*; |
| | | import com.dsh.guns.config.UserExt; |
| | |
| | | import com.dsh.guns.core.util.ToolUtil; |
| | | import com.dsh.guns.modular.system.model.TCity; |
| | | import com.dsh.guns.modular.system.model.TOperator; |
| | | import com.dsh.guns.modular.system.model.TOperatorCity; |
| | | import com.dsh.guns.modular.system.model.TStore; |
| | | import com.dsh.guns.modular.system.service.ICityService; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import com.dsh.guns.modular.system.service.TOperatorCityService; |
| | | import com.dsh.guns.modular.system.service.TOperatorService; |
| | | import com.dsh.guns.modular.system.util.ExcelUtil; |
| | | import com.dsh.guns.modular.system.util.OBSUploadUtil; |
| | | 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.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import sun.rmi.runtime.Log; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.OutputStream; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private ICityService cityService; |
| | | |
| | | /** |
| | | * 导出赛事已报名用户列表 |
| | | */ |
| | | |
| | | @RequestMapping(value = "/export") |
| | | @ResponseBody |
| | | public void exportUserInfo(Integer id, Integer state, HttpServletResponse response) { |
| | | try { |
| | | Competition byId = competitionClient.queryById(id); |
| | | String name = byId.getName(); |
| | | Date date = new Date(); |
| | | DateFormat format = new SimpleDateFormat("yyyyMMdd"); |
| | | String time1 = format.format(date); |
| | | String fileName =name+"报名信息.xls"; |
| | | String[] title = new String[] {"姓名","性别","联系电话","身份证号","状态"}; |
| | | GetPeopleQuery query = new GetPeopleQuery(); |
| | | query.setId(id); |
| | | query.setState(state); |
| | | List<CompetitionUser> list = competitionClient.getPeoples(query); |
| | | String[][] values = new String[list.size()][]; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | CompetitionUser d = list.get(i); |
| | | values[i] = new String[title.length]; |
| | | values[i][0] = d.getName(); |
| | | Integer sex = d.getSex(); |
| | | if(Objects.nonNull(sex)){ |
| | | if(1 == sex){ |
| | | values[i][1] = "男"; |
| | | }else if(2 == sex){ |
| | | values[i][1] = "女"; |
| | | } |
| | | }else { |
| | | values[i][1] = "未知"; |
| | | } |
| | | values[i][2] = d.getPhone(); |
| | | values[i][3] = d.getIdCard(); |
| | | Integer state1 = d.getState(); |
| | | if(1 == state1){ |
| | | values[i][4] = "正常"; |
| | | }else if(2 == state1){ |
| | | values[i][4] = "冻结"; |
| | | }else { |
| | | values[i][4] = "删除"; |
| | | } |
| | | } |
| | | 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(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | |
| | | public String index(Model model) { |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | model.addAttribute("list",list); |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | model.addAttribute("type",objectType); |
| | | return PREFIX + "TCompetition.html"; |
| | | } |
| | | |
| | |
| | | |
| | | List<TOperator> list1 = tOperatorService.list(); |
| | | model.addAttribute("yysList",list1); |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | model.addAttribute("type",objectType); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | List<TStore> operatorId = storeService.list(new QueryWrapper<TStore>().eq("operatorId", objectId)); |
| | | model.addAttribute("stores",operatorId); |
| | | if (UserExt.getUser().getObjectType()==2){ |
| | | // 查询这个运营商管理的省 |
| | | TOperator id = tOperatorService.getOne(new QueryWrapper<TOperator>().eq("id", UserExt.getUser().getObjectId())); |
| | | if (id.getType()==1){ |
| | | // 全国 |
| | | List<TCity> list3 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | model.addAttribute("province",list3); |
| | | }else{ |
| | | // 找到他管理的省 |
| | | List<TOperatorCity> list4 = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("operatorId", UserExt.getUser().getObjectId()).eq("pid", 0)); |
| | | model.addAttribute("province",list4); |
| | | } |
| | | model.addAttribute("operator",objectId); |
| | | // 查询当前运营商管理了哪些门店 |
| | | List<TStore> stores = storeService |
| | | .list(new QueryWrapper<TStore>() |
| | | .eq("operatorId", UserExt.getUser().getObjectId())); |
| | | model.addAttribute("stores",stores); |
| | | } |
| | | if (UserExt.getUser().getObjectType()==1) model.addAttribute("operator",0); |
| | | TStore byId = storeService.getById(UserExt.getUser().getObjectId()); |
| | | if (UserExt.getUser().getObjectType()==3) model.addAttribute("operator",byId.getOperatorId()); |
| | | List<TOperator> list2 = tOperatorService.list(); |
| | | model.addAttribute("yysList",list2); |
| | | return PREFIX + "TCompetition_add.html"; |
| | | } |
| | | |
| | |
| | | */ |
| | | @RequestMapping("/tCompetition_update/{id}") |
| | | public String tCarUpdate(@PathVariable Integer id, Model model) { |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | model.addAttribute("objectType",objectType); |
| | | Competition competition = competitionClient.queryById(id); |
| | | System.out.println("======competition======"+competition); |
| | | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); |
| | | String startTime = formatter.format(competition.getStartTime()); |
| | | model.addAttribute("startTime",startTime); |
| | | String endTime = formatter.format(competition.getEndTime()); |
| | | model.addAttribute("endTime",endTime); |
| | | String registerEndTime = formatter.format(competition.getRegisterEndTime()); |
| | | model.addAttribute("registerEndTime",registerEndTime); |
| | | |
| | | |
| | | |
| | | |
| | | model.addAttribute("item",competition); |
| | | String[] split = competition.getStoreId().split(","); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | for (String s : split) { |
| | | integers.add(Integer.valueOf(s)); |
| | | } |
| | | |
| | | model.addAttribute("storeIds",integers); |
| | | |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode())); |
| | | List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId())); |
| | |
| | | } |
| | | @RequestMapping("/tCompetition_info/{id}") |
| | | public String tCarInfo(@PathVariable Integer id, Model model) { |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | model.addAttribute("objectType",objectType); |
| | | Competition competition = competitionClient.queryById(id); |
| | | SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | String startTime = formatter.format(competition.getStartTime()); |
| | | model.addAttribute("startTime",startTime); |
| | | String endTime = formatter.format(competition.getEndTime()); |
| | | model.addAttribute("endTime",endTime); |
| | | String registerEndTime = formatter.format(competition.getRegisterEndTime()); |
| | | model.addAttribute("registerEndTime",registerEndTime); |
| | | model.addAttribute("item",competition); |
| | | List<TCity> list = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, competition.getProvinceCode())); |
| | |
| | | model.addAttribute("list1",list1); |
| | | model.addAttribute("list2",list2); |
| | | model.addAttribute("type",2); |
| | | String[] split = competition.getStoreId().split(","); |
| | | List<Integer> integers = new ArrayList<>(); |
| | | for (String s : split) { |
| | | integers.add(Integer.valueOf(s)); |
| | | } |
| | | |
| | | model.addAttribute("storeIds",integers); |
| | | return PREFIX + "TCompetition_edit.html"; |
| | | } |
| | | @RequestMapping("/tCompetition_user/{id}") |
| | |
| | | if(ids.size()==0){ |
| | | ids.add(-1); |
| | | } |
| | | if (UserExt.getUser().getObjectType()== 2){ |
| | | if (shopName == null) |
| | | shopName = ""; |
| | | List<Integer> operatorId = storeService.list(new QueryWrapper<TStore>() |
| | | .eq("operatorId", UserExt.getUser().getObjectId()) |
| | | .like("name",shopName)) |
| | | .stream().map(TStore::getId).collect(Collectors.toList()); |
| | | ids = operatorId; |
| | | } |
| | | Page<Competition> page = new PageFactory<Competition>().defaultPage(); |
| | | ListQuery listQuery = new ListQuery(page.getSize(),page.getCurrent(),provinceCode,cityCode,eventName,time,state,registerCondition,ids); |
| | | ListQuery listQuery = new ListQuery(page.getSize(),page.getCurrent(),provinceCode,cityCode,eventName,time,state,registerCondition,ids,UserExt.getUser().getObjectType()); |
| | | Page<Competition> competitions = competitionClient.list(listQuery); |
| | | List<Competition> records = new ArrayList<>(); |
| | | for (Competition competition : competitions.getRecords()) { |
| | | if (competition.getStatus()==4){ |
| | | continue; |
| | | } |
| | | |
| | | // 当前时间小于开始时间 |
| | | if (competition.getStartTime().after(new Date())){ |
| | | competition.setStatus(1); |
| | | } |
| | | if (competition.getStartTime().before(new Date())){ |
| | | |
| | | |
| | | if (competition.getEndTime().after(new Date())){ |
| | | competition.setStatus(2); |
| | | }else{ |
| | | competition.setStatus(3); |
| | | } |
| | | } |
| | | if (competition.getStatus()!=state && state != null){ |
| | | }else{ |
| | | records.add(competition); |
| | | } |
| | | for (TStore tStore : list) { |
| | | String[] split = competition.getStoreId().split(","); |
| | | |
| | | for (String s : split) { |
| | | if(s.equals(String.valueOf(tStore.getId()))){ |
| | | if (competition.getStoreName()==null){ |
| | |
| | | } |
| | | } |
| | | } |
| | | competitions.setRecords(records); |
| | | System.err.println(competitions.getRecords()); |
| | | return super.packForBT(competitions); |
| | | } |
| | | |
| | |
| | | public Object listUser(@PathVariable Integer id,Integer state) { |
| | | try { |
| | | Page<Object> page = new PageFactory<>().defaultPage(); |
| | | Page<CompetitionUser> data = competitionClient.getPeopleFromId(new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state)); |
| | | Page<CompetitionUser> data = competitionClient.getPeopleFromId |
| | | (new GetPeopleQuery(page.getSize(),page.getCurrent(),id,state)); |
| | | return super.packForBT(data); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | |
| | | if (UserExt.getUser().getObjectType() == 1){ |
| | | competition.setAuditStatus(2); |
| | | }else { |
| | | }else if (UserExt.getUser().getObjectType() == 2){ |
| | | competition.setAuditStatus(1); |
| | | competition.setOperatorId(UserExt.getUser().getObjectId()); |
| | | } |
| | | |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | competition.setStartTime(format1.parse(competition.getSTime())); |
| | | competition.setEndTime(format1.parse(competition.getETime())); |
| | | competition.setRegisterEndTime(format.parse(competition.getREndTime())); |
| | | // SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | | // SimpleDateFormat format1 = new SimpleDateFormat("yyyy-MM-dd"); |
| | | // competition.setStartTime(format1.parse(competition.getSTime())); |
| | | // competition.setEndTime(format1.parse(competition.getETime())); |
| | | // competition.setRegisterEndTime(format.parse(competition.getREndTime())); |
| | | competitionClient.add(competition); |
| | | return new SuccessTip<>(); |
| | | }catch (Exception e){ |
| | |
| | | if(ToolUtil.isEmpty(competition.getRegistrationNotes())){ |
| | | competition.setRegistrationNotes(competition1.getRegistrationNotes()); |
| | | } |
| | | if (UserExt.getUser().getObjectType() == 1){ |
| | | competition.setAuditStatus(2); |
| | | }else{ |
| | | competition.setAuditStatus(1); |
| | | } |
| | | |
| | | competitionClient.update(competition); |
| | | return new SuccessTip<>(); |
| | | }catch (Exception e){ |
| | |
| | | |
| | | |
| | | @RequestMapping(value = "/cancel") |
| | | public Object cancel(Integer id) { |
| | | public Object cancel(Integer TCompetitionId) { |
| | | try { |
| | | competitionClient.cancel(id); |
| | | competitionClient.cancel(TCompetitionId); |
| | | return SUCCESS_TIP; |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | |
| | | } |
| | | } |
| | | |
| | | @Autowired |
| | | private TOperatorCityService operatorCityService; |
| | | @RequestMapping(value = "/onChange") |
| | | @ResponseBody |
| | | public Object onChange(Integer oneId) { |
| | | System.out.println("======"+oneId); |
| | | List<TOperatorCity> list = operatorCityService.list(new LambdaQueryWrapper<TOperatorCity>().eq(TOperatorCity::getOperatorId, oneId).eq(TOperatorCity::getType, 2)); |
| | | if (list.size()!=0){ |
| | | return list; |
| | | } |
| | | |
| | | try { |
| | | TCity one = cityService.getOne(new LambdaQueryWrapper<TCity>().eq(TCity::getCode, oneId)); |
| | | return cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId,one.getId())); |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |