| | |
| | | import com.stylefeng.guns.core.shiro.ShiroUser; |
| | | import com.stylefeng.guns.modular.system.controller.resp.TDriverResp; |
| | | import com.stylefeng.guns.modular.system.controller.util.ExcelUtil; |
| | | import com.stylefeng.guns.modular.system.model.TAgent; |
| | | import com.stylefeng.guns.modular.system.model.TAppUser; |
| | | import com.stylefeng.guns.modular.system.controller.util.UUIDUtil; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.ITAgentService; |
| | | import com.stylefeng.guns.modular.system.service.ITBranchOfficeService; |
| | | import com.stylefeng.guns.modular.system.service.ITRegionService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.logging.log4j.core.util.UuidUtil; |
| | | import org.apache.poi.hssf.usermodel.HSSFWorkbook; |
| | | import org.apache.shiro.subject.Subject; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.util.StringUtils; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.stylefeng.guns.core.log.LogObjectHolder; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.stylefeng.guns.modular.system.model.TDriver; |
| | | import com.stylefeng.guns.modular.system.service.ITDriverService; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | |
| | | @Autowired |
| | | private ITDriverService tDriverService; |
| | | |
| | | @Autowired |
| | | private ITRegionService tRegionService; |
| | | |
| | | @Autowired |
| | | private ITAgentService tAgentService; |
| | | |
| | | @Autowired |
| | | private ITBranchOfficeService tBranchOfficeService; |
| | | |
| | | /** |
| | | * 跳转到首页 |
| | | */ |
| | |
| | | /** |
| | | * 跳转到修改 |
| | | */ |
| | | @RequestMapping("/tDriver_update/{tDriverId}") |
| | | public String tDriverUpdate(@PathVariable Integer tDriverId, Model model) { |
| | | @RequestMapping("/tDriver_update") |
| | | public String tDriverUpdate( Integer tDriverId, Model model) { |
| | | TDriver tDriver = tDriverService.selectById(tDriverId); |
| | | model.addAttribute("item",tDriver); |
| | | TDriverResp tDriverResp = new TDriverResp(); |
| | | BeanUtils.copyProperties(tDriver,tDriverResp); |
| | | |
| | | // 查询邀请人 |
| | | TDriver tDriver1 = tDriverService.selectById(tDriver.getInviterId()); |
| | | if(Objects.nonNull(tDriver1)){ |
| | | tDriverResp.setInviterName(tDriver1.getName()); |
| | | tDriverResp.setInviterPhone(tDriver1.getPhone()); |
| | | } |
| | | |
| | | // 查询区域 |
| | | TRegion district = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tDriver.getAreaCode()) |
| | | .last("LIMIT 1")); |
| | | TRegion city = tRegionService.selectOne(new EntityWrapper<TRegion>().eq("code", tDriver.getCityCode()) |
| | | .last("LIMIT 1")); |
| | | |
| | | tDriverResp.setArea(tDriver.getProvinceName()+"/"+tDriver.getCityName()+"/"+tDriver.getAreaName()); |
| | | if(Objects.nonNull(district) && Objects.nonNull(city)){ |
| | | tDriverResp.setAreaId(city.getParentId()+"/"+city.getId()+"/"+district.getId()); |
| | | } |
| | | |
| | | model.addAttribute("item",tDriverResp); |
| | | LogObjectHolder.me().set(tDriver); |
| | | return PREFIX + "tDriver_edit.html"; |
| | | } |
| | |
| | | @RequestMapping("/driverDetail") |
| | | public String driverDetail(Integer tDriverId, Model model) { |
| | | tDriverService.detail(tDriverId,model); |
| | | |
| | | return PREFIX + "tDriverDetail.html"; |
| | | } |
| | | |
| | | /** |
| | | * 跳转区域页面 |
| | | */ |
| | | @RequestMapping("/areaPage") |
| | | public String areaDetail(Model model) { |
| | | List<TRegion> tRegions = tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | model.addAttribute("province",tRegions); |
| | | return PREFIX + "tDriverArea.html"; |
| | | } |
| | | |
| | | /** |
| | |
| | | @RequestMapping(value = "/add") |
| | | @ResponseBody |
| | | public Object add(TDriver tDriver) { |
| | | |
| | | int count = tDriverService.selectCount(new EntityWrapper<TDriver>().eq("phone", tDriver.getPhone())); |
| | | if(count>0){ |
| | | return "该司机已存在!"; |
| | | } |
| | | |
| | | // 对省市区做处理 |
| | | String[] split = tDriver.getAreaId().split("/"); |
| | | // 查询省市 |
| | | // 黑龙江省/大兴安岭地区 |
| | | // 702/852 |
| | | TRegion province = tRegionService.selectById(split[0]); |
| | | tDriver.setProvinceName(province.getName()); |
| | | tDriver.setProvinceCode(province.getCode()); |
| | | |
| | | TRegion city = tRegionService.selectById(split[1]); |
| | | tDriver.setCityName(city.getName()); |
| | | tDriver.setCityCode(city.getCode()); |
| | | |
| | | TRegion area = tRegionService.selectById(split[2]); |
| | | tDriver.setAreaName(area.getName()); |
| | | tDriver.setAreaCode(area.getCode()); |
| | | |
| | | tDriver.setCode(UUIDUtil.getNumberRandom(16)); |
| | | tDriver.setBalance(BigDecimal.ZERO); |
| | | tDriver.setBackgroundBalance(BigDecimal.ZERO); |
| | | |
| | | // 通过省市查询代理商 |
| | | TAgent tAgent = tAgentService.selectOne(new EntityWrapper<TAgent>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tAgent)){ |
| | | tDriver.setAgentId(tAgent.getId()); |
| | | } |
| | | // 查询邀约人(司机端) |
| | | TDriver emergencyDriver = tDriverService.selectOne(new EntityWrapper<TDriver>().eq("phone", tDriver.getEmergencyPhone()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(emergencyDriver)){ |
| | | tDriver.setInviterId(emergencyDriver.getId()); |
| | | tDriver.setInviterType(2); |
| | | } |
| | | // 通过省市区查询分公司 |
| | | TBranchOffice tBranchOffice = tBranchOfficeService.selectOne(new EntityWrapper<TBranchOffice>().eq("provinceCode", province.getCode()) |
| | | .eq("cityCode", city.getCode()) |
| | | .eq("districtCode", area.getCode()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.nonNull(tBranchOffice)){ |
| | | tDriver.setBranchOfficeId(tBranchOffice.getId()); |
| | | } |
| | | |
| | | tDriverService.insert(tDriver); |
| | | return SUCCESS_TIP; |
| | | } |
| | |
| | | return tDriverService.selectById(tDriverId); |
| | | } |
| | | |
| | | @ApiOperation(value = "省查询",notes="省查询") |
| | | @RequestMapping(value = "/areaProvince") |
| | | @ResponseBody |
| | | public Object areaProvince(Model model) { |
| | | return tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id", 0)); |
| | | } |
| | | |
| | | @ApiOperation(value = "市区查询",notes="市区查询") |
| | | @RequestMapping(value = "/areaCity") |
| | | @ResponseBody |
| | | public Object areaCity(Integer parentId) { |
| | | return tRegionService.selectList(new EntityWrapper<TRegion>().eq("parent_id",parentId)); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "导出司机列表",notes="导出司机列表") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(name = "Authorization", value = "用户token(Bearer +token)", required = true, dataType = "String", paramType = "header", defaultValue = "Bearer eyJhbGciOiJIUzUxMiJ9....."), |