| | |
| | | package com.dsh.guns.modular.system.controller.code; |
| | | |
| | | |
| | | import com.alibaba.druid.sql.visitor.functions.If; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.dsh.course.feignClient.account.CityManagerClient; |
| | | import com.dsh.course.feignClient.account.CoachClient; |
| | |
| | | import com.dsh.course.feignClient.account.model.CoachType; |
| | | import com.dsh.course.feignClient.other.model.Site; |
| | | import com.dsh.guns.config.UserExt; |
| | | import com.dsh.guns.modular.system.model.CoachChangeStateVO; |
| | | import com.dsh.guns.modular.system.model.CoachQuery; |
| | | import com.dsh.guns.modular.system.model.Store; |
| | | import com.dsh.guns.modular.system.model.TStore; |
| | | import com.dsh.guns.modular.system.service.IStoreService; |
| | | import com.dsh.guns.modular.system.model.*; |
| | | import com.dsh.guns.modular.system.service.*; |
| | | import com.dsh.guns.modular.system.util.ResultUtil; |
| | | import org.bouncycastle.math.raw.Mod; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.Model; |
| | |
| | | private CoachClient coachClient; |
| | | @Autowired |
| | | private CityManagerClient cityManagerClient; |
| | | @Autowired |
| | | private ICityService cityService; |
| | | @Autowired |
| | | private TOperatorService operatorService; |
| | | @Autowired |
| | | private TOperatorCityService operatorCityService; |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | /** |
| | | * 跳转教练管理首页 |
| | |
| | | */ |
| | | @RequestMapping("/addCoach") |
| | | public String addCoach(Model model) { |
| | | List<CityManager> province = cityManagerClient.listAll(); |
| | | Set<String> seenNames = new HashSet<>(); |
| | | List<CityManager> result = new ArrayList<>(); |
| | | for (CityManager cityManager : province) { |
| | | if(!seenNames.contains(cityManager.getProvince())){ |
| | | result.add(cityManager); |
| | | seenNames.add(cityManager.getProvince()); |
| | | } |
| | | } |
| | | List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | model.addAttribute("list",list1); |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | CoachQuery coachQuery = new CoachQuery(); |
| | |
| | | String roleid = UserExt.getUser().getRoleid(); |
| | | model.addAttribute("role",roleid); |
| | | model.addAttribute("data",data); |
| | | model.addAttribute("list",result); |
| | | model.addAttribute("objectType",objectType); |
| | | model.addAttribute("objectId",objectId); |
| | | model.addAttribute("coachType",list); |
| | |
| | | @ResponseBody |
| | | @RequestMapping(value = "/add") |
| | | public ResultUtil addCoach(@RequestBody Coach coach) { |
| | | |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | if (UserExt.getUser().getObjectType() == 2){ |
| | | coach.setCityManagerId(objectId); |
| | |
| | | coachClient.changeState(vo); |
| | | return ResultUtil.success(); |
| | | } |
| | | /** |
| | | * 根据选择的市 查询有哪些运营商管理了所选的市 |
| | | * |
| | | * @return |
| | | */ |
| | | @RequestMapping("/getYys") |
| | | @ResponseBody |
| | | public Object getYys(String pCode,String cCode){ |
| | | // 先获取管理全国的运营商 |
| | | List<TOperator> type = operatorService.list(new QueryWrapper<TOperator>().eq("type", 1)); |
| | | // 根据所选市 查询管理了这个市的运营商 |
| | | // 获取管理指定区域的运营商的ID 然后去重 |
| | | List<Integer> collect = operatorCityService.list(new QueryWrapper<TOperatorCity>()).stream().map(TOperatorCity::getOperatorId) |
| | | .distinct().collect(Collectors.toList()); |
| | | // 遍历 判断当前运营商是否管理了所选市 |
| | | for (Integer integer : collect) { |
| | | // 查询是否管理了省 |
| | | TOperatorCity code = operatorCityService.getOne(new QueryWrapper<TOperatorCity>().eq("code", pCode).eq("operatorId",integer)); |
| | | if (code==null)continue; |
| | | List<TOperatorCity> pid = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("pid", code.getId())); |
| | | // 如果pid长度为0 则说明管理整个省 |
| | | if (pid.size()==0){ |
| | | type.add(operatorService.getOne(new QueryWrapper<TOperator>() |
| | | .eq("id",integer))); |
| | | } |
| | | for (TOperatorCity tOperatorCity : pid) { |
| | | if (tOperatorCity.getCode().toString().equals(cCode)){ |
| | | TOperator id = operatorService.getOne(new QueryWrapper<TOperator>() |
| | | .eq("id", tOperatorCity.getOperatorId())); |
| | | if (id!=null)type.add(id); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | return type; |
| | | } |
| | | |
| | | /** |
| | | * 跳转修改教练页面 |
| | |
| | | CoachQuery coachQuery = new CoachQuery(); |
| | | coachQuery.setId(id); |
| | | List<CoachSerchVO> data = coachClient.listAll(coachQuery); |
| | | List<CityManager> province = cityManagerClient.listAll(); |
| | | Set<String> seenNames = new HashSet<>(); |
| | | List<CityManager> result = new ArrayList<>(); |
| | | List<CityManager> city = new ArrayList<>(); |
| | | for (CityManager cityManager : province) { |
| | | if(!seenNames.contains(cityManager.getProvince())){ |
| | | result.add(cityManager); |
| | | seenNames.add(cityManager.getProvince()); |
| | | List<TCity> list1 = cityService.list(new LambdaQueryWrapper<TCity>().eq(TCity::getParentId, 0)); |
| | | // 省 |
| | | model.addAttribute("list",list1); |
| | | // 市 |
| | | Integer code = cityService.getOne(new QueryWrapper<TCity>() |
| | | .eq("code", data.get(0).getProvinceCode())).getId(); |
| | | |
| | | List<TCity> pid = cityService.list(new QueryWrapper<TCity>().eq("parent_id", code)); |
| | | model.addAttribute("city",pid); |
| | | // 获取所选省市下的运营商列表 |
| | | // 先获取管理全国的运营商 |
| | | List<TOperator> type = operatorService.list(new QueryWrapper<TOperator>().eq("type", 1)); |
| | | // 根据所选市 查询管理了这个市的运营商 |
| | | // 获取管理指定区域的运营商的ID 然后去重 |
| | | List<Integer> collect = operatorCityService.list(new QueryWrapper<TOperatorCity>()).stream().map(TOperatorCity::getOperatorId) |
| | | .distinct().collect(Collectors.toList()); |
| | | // 遍历 判断当前运营商是否管理了所选市 |
| | | for (Integer integer : collect) { |
| | | // 查询是否管理了省 |
| | | TOperatorCity code1 = operatorCityService.getOne(new QueryWrapper<TOperatorCity>() |
| | | .eq("code", data.get(0).getProvinceCode()) |
| | | .eq("operatorId",integer) |
| | | ); |
| | | if (code1==null)continue; |
| | | List<TOperatorCity> pid1 = operatorCityService.list(new QueryWrapper<TOperatorCity>().eq("pid", code1.getId())); |
| | | // 如果pid长度为0 则说明管理整个省 |
| | | if (pid1.size()==0){ |
| | | type.add(operatorService.getOne(new QueryWrapper<TOperator>() |
| | | .eq("id",integer))); |
| | | } |
| | | if(data.get(0).getProvince().equals(cityManager.getProvince())){ |
| | | city.add(cityManager); |
| | | for (TOperatorCity tOperatorCity : pid1) { |
| | | if (tOperatorCity.getCode().toString().equals(data.get(0).getCityCode())){ |
| | | TOperator id1 = operatorService.getOne(new QueryWrapper<TOperator>() |
| | | .eq("id", tOperatorCity.getOperatorId())); |
| | | if (id1!=null)type.add(id1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | Integer objectType = UserExt.getUser().getObjectType(); |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | List<CityManager> accounts = cityManagerClient.getAccount(data.get(0).getCity()); |
| | | List<CoachType> list = coachTypeClient.list(); |
| | | String roleid = UserExt.getUser().getRoleid(); |
| | | model.addAttribute("role",roleid); |
| | | model.addAttribute("data",data.get(0)); |
| | | model.addAttribute("list",result); |
| | | model.addAttribute("city",city); |
| | | model.addAttribute("cityManagers",accounts); |
| | | model.addAttribute("cityManagers",type); |
| | | model.addAttribute("objectType",objectType); |
| | | model.addAttribute("objectId",objectId); |
| | | model.addAttribute("coachType",list); |
| | |
| | | Integer objectId = UserExt.getUser().getObjectId(); |
| | | coachQuery.setOperatorId(objectId); |
| | | } |
| | | |
| | | return coachClient.listAll(coachQuery); |
| | | List<CoachSerchVO> coachSerchVOS = coachClient.listAll(coachQuery); |
| | | for (CoachSerchVO coachSerchVO : coachSerchVOS) { |
| | | Integer cityManagerId = coachSerchVO.getCityManagerId(); |
| | | TOperator byId = operatorService.getById(cityManagerId); |
| | | Integer userId = byId.getUserId(); |
| | | User byId1 = userService.getById(userId); |
| | | coachSerchVO.setNameAndPhone(byId.getName()+""+byId1.getPhone()); |
| | | } |
| | | return coachSerchVOS; |
| | | } |
| | | } |