| | |
| | | private ITCompanyService tCompanyService; |
| | | |
| | | @Autowired |
| | | private ITCompanyCityService tCompanyCityService; |
| | | |
| | | @Autowired |
| | | private ITDriverServiceService tDriverServiceService; |
| | | |
| | | @Autowired |
| | |
| | | private ShiroExtUtil shiroExtUtil; |
| | | @Autowired |
| | | private IDriverWorkService iDriverWorkService; |
| | | @Autowired |
| | | private ITRegionService regionService; |
| | | |
| | | /** |
| | | * 跳转投诉页面 |
| | |
| | | public String tDriverAdd(Model model) { |
| | | List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2).eq("state", 0).ne("flag", 3)); |
| | | model.addAttribute("companyList", companyList); |
| | | |
| | | |
| | | Integer roleType = shiroExtUtil.getUser().getRoleType(); |
| | | model.addAttribute("roleType", roleType); |
| | | if (2 == roleType) { |
| | |
| | | model.addAttribute("franchiseeList", null); |
| | | } |
| | | //查询当前用户所属分公司/加盟商 |
| | | model.addAttribute("objectName", tCompanyService.selectById(shiroExtUtil.getUser().getObjectId()).getName()); |
| | | TCompany currentCompany = tCompanyService.selectById(shiroExtUtil.getUser().getObjectId()); |
| | | model.addAttribute("objectName", currentCompany.getName()); |
| | | // 分公司/加盟商账号传入公司经营业务信息和经营区域 |
| | | if (2 == roleType || 3 == roleType) { |
| | | model.addAttribute("companyData", currentCompany); |
| | | model.addAttribute("companyId", currentCompany.getId()); |
| | | } |
| | | |
| | | //查询线路列表 |
| | | if(1 != roleType){ |
| | |
| | | } else if (2 == roleType) { |
| | | List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3).eq("state", 0).ne("flag", 3).eq("superiorId", shiroExtUtil.getUser().getObjectId())); |
| | | model.addAttribute("franchiseeList", franchiseeList); |
| | | // 分公司账号传入公司ID用于加载经营区域 |
| | | model.addAttribute("currentCompanyId", shiroExtUtil.getUser().getObjectId()); |
| | | } else if (3 == roleType) { |
| | | // 加盟商账号传入上级分公司ID用于加载经营区域 |
| | | TCompany franchisee = tCompanyService.selectById(shiroExtUtil.getUser().getObjectId()); |
| | | model.addAttribute("currentCompanyId", franchisee.getSuperiorId()); |
| | | } |
| | | |
| | | //查询平台ID |
| | |
| | | map.put("list", list); |
| | | TCompany company = tCompanyService.selectById(oneId); |
| | | map.put("company", company); |
| | | // 获取公司经营区域 |
| | | List<TCompanyCity> companyCityList = tCompanyCityService.selectList( |
| | | new EntityWrapper<TCompanyCity>().eq("companyId", oneId).eq("state", 1)); |
| | | map.put("companyCityList", companyCityList); |
| | | return map; |
| | | } |
| | | |
| | | /** |
| | | * 根据公司ID获取经营区域列表(省市区联动) |
| | | */ |
| | | @RequestMapping(value = "/getCompanyCityList") |
| | | @ResponseBody |
| | | public Object getCompanyCityList(@RequestParam Integer companyId) { |
| | | List<TCompanyCity> list = tCompanyCityService.selectList( |
| | | new EntityWrapper<TCompanyCity>().eq("companyId", companyId).eq("state", 1)); |
| | | // 获取区域详细信息 |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (TCompanyCity city : list) { |
| | | Map<String, Object> item = new HashMap<>(); |
| | | item.put("id", city.getId()); |
| | | item.put("provinceCode", city.getProvinceCode()); |
| | | item.put("cityCode", city.getCityCode()); |
| | | item.put("areaCode", city.getAreaCode()); |
| | | // 获取省市区名称 |
| | | TRegion province = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", city.getProvinceCode())); |
| | | TRegion cityRegion = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", city.getCityCode())); |
| | | TRegion area = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", city.getAreaCode())); |
| | | item.put("provinceName", province != null ? province.getName() : ""); |
| | | item.put("cityName", cityRegion != null ? cityRegion.getName() : ""); |
| | | item.put("areaName", area != null ? area.getName() : ""); |
| | | item.put("provinceId", province != null ? province.getId() : ""); |
| | | item.put("cityId", cityRegion != null ? cityRegion.getId() : ""); |
| | | item.put("areaId", area != null ? area.getId() : ""); |
| | | result.add(item); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | |
| | |
| | | TDriver tDriver = tDriverService.selectById(tDriverId); |
| | | DriverWork driverWork = iDriverWorkService.selectOne(new EntityWrapper<DriverWork>().eq("driverId", tDriverId).eq("state", 1)); |
| | | if(null != driverWork && !tDriver.getCarId().equals(carId)){ |
| | | throw new RuntimeException("司机上班中,不能更换车辆"); |
| | | return ResultUtil.error("司机上班中,不能更换车辆"); |
| | | } |
| | | tDriver.setCarId(carId); |
| | | tDriverService.updateById(tDriver); |
| | | } |
| | | return SUCCESS_TIP; |
| | | return ResultUtil.success(); |
| | | } |
| | | |
| | | /** |
| | |
| | | driver.setAddType(2); |
| | | driver.setAddObjectId(shiroExtUtil.getUser().getObjectId()); |
| | | driver.setPlaceOfEmployment(cell201); |
| | | if(ToolUtil.isNotEmpty(cell201)){ |
| | | TRegion tRegion = regionService.selectOne(new EntityWrapper<TRegion>().eq("code", cell201)); |
| | | String placeOfPractice = ""; |
| | | if(null != tRegion){ |
| | | Integer parentId = tRegion.getParentId(); |
| | | if(0 != parentId){ |
| | | TRegion tRegion1 = regionService.selectById(parentId); |
| | | if(0 != tRegion1.getParentId()){ |
| | | TRegion tRegion2 = regionService.selectById(tRegion1.getParentId()); |
| | | placeOfPractice = tRegion2.getName() + "," + tRegion1.getName() + "," + tRegion.getName(); |
| | | }else{ |
| | | placeOfPractice = tRegion1.getName() + "," + tRegion.getName(); |
| | | } |
| | | }else{ |
| | | placeOfPractice = tRegion.getName(); |
| | | } |
| | | } |
| | | driver.setPlaceOfPractice(placeOfPractice); |
| | | } |
| | | if (SinataUtil.isNotEmpty(eight)) { |
| | | driver.setDriverAddress(eight); |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // 校验经营业务是否在公司经营范围内 |
| | | TCompany company = itCompanyService.selectById(companyId); |
| | | String serviceError = validateDriverService(company, "是".equals(nine), "是".equals(ten), "是".equals(eleven)); |
| | | if (serviceError != null) { |
| | | return new ErrorTip(500, serviceError); |
| | | } |
| | | |
| | | // 校验从业地是否在公司经营区域内 |
| | | String placeError = validatePlaceOfEmployment(companyId, cell1701, 2); |
| | | if (placeError != null) { |
| | | return new ErrorTip(500, placeError); |
| | | } |
| | | |
| | | TDriver driver = new TDriver(); |
| | | driver.setAccount(fifteen); |
| | | driver.setJobNumber(eight); |
| | |
| | | if (companyId == 0 && franchiseeId == 0) { |
| | | return new ErrorTip(500, "当前登录账户上级分公司不能为空"); |
| | | } |
| | | |
| | | |
| | | // 校验经营业务是否在公司经营范围内 |
| | | TCompany company = itCompanyService.selectById(companyId); |
| | | String serviceError = validateDriverService(company, "是".equals(eight), "是".equals(nine), "是".equals(ten)); |
| | | if (serviceError != null) { |
| | | return new ErrorTip(500, serviceError); |
| | | } |
| | | |
| | | // 校验从业地是否在公司经营区域内 |
| | | String placeError = validatePlaceOfEmployment(companyId, cell1701, 3); |
| | | if (placeError != null) { |
| | | return new ErrorTip(500, placeError); |
| | | } |
| | | |
| | | TDriver driver = new TDriver(); |
| | | driver.setAccount(fourteen); |
| | | driver.setJobNumber(seven); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 校验经营业务是否在公司经营范围内 |
| | | * @param company 公司 |
| | | * @param isSpe 是否快车 |
| | | * @param isTaxi 是否出租车 |
| | | * @param isCross 是否跨城 |
| | | * @return 错误信息,null表示校验通过 |
| | | */ |
| | | private String validateDriverService(TCompany company, boolean isSpe, boolean isTaxi, boolean isCross) { |
| | | if (company == null) { |
| | | return null; |
| | | } |
| | | if (isSpe && (company.getIsSpe() == null || company.getIsSpe() != 1)) { |
| | | return "公司未开通快车业务"; |
| | | } |
| | | if (isTaxi && (company.getIsTaxi() == null || company.getIsTaxi() != 1)) { |
| | | return "公司未开通出租车业务"; |
| | | } |
| | | if (isCross && (company.getIsCross() == null || company.getIsCross() != 1)) { |
| | | return "公司未开通跨城出行业务"; |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 校验从业地是否在公司经营区域内 |
| | | * @param companyId 公司ID |
| | | * @param placeOfEmployment 从业地行政编号 |
| | | * @return 错误信息,null表示校验通过 |
| | | */ |
| | | private String validatePlaceOfEmployment(Integer companyId, String placeOfEmployment, Integer roleType) { |
| | | if (companyId == null || SinataUtil.isEmpty(placeOfEmployment)) { |
| | | return null; |
| | | } |
| | | if (roleType.equals(3)) { |
| | | //查询该加盟商所属的分公司 |
| | | TCompany tCompany = tCompanyService.selectById(companyId); |
| | | if (Objects.nonNull(tCompany) && Objects.nonNull(tCompany.getSuperiorId())) { |
| | | companyId = tCompany.getSuperiorId(); |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | List<TCompanyCity> companyCityList = tCompanyCityService.selectList( |
| | | new EntityWrapper<TCompanyCity>().eq("companyId", companyId).eq("state", 1)); |
| | | if (companyCityList == null || companyCityList.isEmpty()) { |
| | | return null; // 公司没有设置经营区域,不做限制 |
| | | } |
| | | // 检查从业地是否在公司经营区域内 |
| | | for (TCompanyCity city : companyCityList) { |
| | | if (city.getAreaCode() != null && placeOfEmployment.equals(String.valueOf(city.getAreaCode()))) { |
| | | return null; // 匹配区级 |
| | | } |
| | | if (city.getCityCode() != null && placeOfEmployment.startsWith(String.valueOf(city.getCityCode()).substring(0, 4))) { |
| | | return null; // 匹配市级 |
| | | } |
| | | } |
| | | return "从业地不在公司经营区域内"; |
| | | } |
| | | |
| | | /** |
| | | * 获取公司经营区域的默认从业地 |
| | | * @param companyId 公司ID |
| | | * @return 默认从业地行政编号 |
| | | */ |
| | | private String getDefaultPlaceOfEmployment(Integer companyId) { |
| | | if (companyId == null) { |
| | | return null; |
| | | } |
| | | List<TCompanyCity> companyCityList = tCompanyCityService.selectList( |
| | | new EntityWrapper<TCompanyCity>().eq("companyId", companyId).eq("state", 1).last(" limit 1")); |
| | | if (companyCityList != null && !companyCityList.isEmpty()) { |
| | | TCompanyCity city = companyCityList.get(0); |
| | | if (city.getAreaCode() != null) { |
| | | return String.valueOf(city.getAreaCode()); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | /** |
| | | * 导出司机信息 |
| | | */ |
| | | @RequestMapping(value = "/outDriver") |