| | |
| | | |
| | | import cn.exrick.xboot.core.common.utils.PageUtil; |
| | | import cn.exrick.xboot.core.common.utils.ResultUtil; |
| | | import cn.exrick.xboot.core.common.utils.SecurityUtil; |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.core.entity.User; |
| | | import cn.exrick.xboot.your.entity.*; |
| | | import cn.exrick.xboot.your.service.*; |
| | | import cn.exrick.xboot.your.vo.CarVo; |
| | |
| | | @Autowired |
| | | private IDrivingRecordService iDrivingRecordService; |
| | | @Autowired |
| | | private ICustomerService iCustomerService; |
| | | private SecurityUtil securityUtil; |
| | | |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | |
| | | return new ResultUtil<List<Car>>().setData(list); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getBindCar", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取绑定的车辆") |
| | | public Result<Car> getBindCar() { |
| | | String userId = securityUtil.getCurrUser().getId(); |
| | | QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>(); |
| | | carQueryWrapper.eq("user_id",userId).or().eq("follow_user_id",userId); |
| | | Car car = iCarService.getOne(carQueryWrapper); |
| | | return new ResultUtil<Car>().setData(car); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getAll", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取全部数据") |
| | | public Result<List<CarVo>> getAll(String beginTime,String endTime,PageVo page) { |
| | | List<CarVo> carVos = new ArrayList<>(); |
| | | |
| | | java.text.DecimalFormat df =new java.text.DecimalFormat("#.##"); |
| | | IPage<Car> list = iCarService.getAll2(PageUtil.initMpPage(page)); |
| | | for (Car car:list.getRecords()){ |
| | | CarVo carVo = new CarVo(); |
| | |
| | | AddOil addOil = iAddOilService.getOne(queryWrapper); |
| | | |
| | | if (addOil!=null){ |
| | | carVo.setMoney(addOil.getMoney()); |
| | | carVo.setOilWear(addOil.getAmount()); |
| | | carVo.setMoney(Double.parseDouble(df.format(addOil.getMoney()))); |
| | | carVo.setOilWear(Double.parseDouble(df.format(addOil.getAmount()))); |
| | | } |
| | | |
| | | if (drivingRecord!=null) { |
| | |
| | | @RequestMapping(value = "/getInfo", method = RequestMethod.GET) |
| | | @ApiOperation(value = "通过车辆id获取") |
| | | public Result<List<Car>> getInfo(String beginTime,String endTime) { |
| | | java.text.DecimalFormat df =new java.text.DecimalFormat("#.##"); |
| | | |
| | | QueryWrapper<Car> wrapper = new QueryWrapper<>(); |
| | | wrapper.ge(beginTime!=null && beginTime!="","a.add_date",beginTime); |
| | | wrapper.le(endTime!=null && endTime!="","a.add_date",endTime); |
| | |
| | | for (Car car:list2){ |
| | | for (Car car1:list){ |
| | | if (car.getId().equals(car1.getId())){ |
| | | car1.setAmount(car.getAmount()); |
| | | car1.setMileage(car.getMileage()); |
| | | car1.setMoney(car.getMoney()); |
| | | car1.setAmount(Double.parseDouble(df.format(car.getAmount()))); |
| | | car1.setMileage(Double.parseDouble(df.format(car.getMileage()))); |
| | | car1.setMoney(Double.parseDouble(df.format(car.getMoney()))); |
| | | car1.setAllAmount(Double.parseDouble(df.format(car1.getAllAmount()))); |
| | | car1.setAllMileage(Double.parseDouble(df.format(car1.getAllMileage()))); |
| | | car1.setAllMoney(Double.parseDouble(df.format(car1.getAllMoney()))); |
| | | continue; |
| | | } |
| | | } |
| | |
| | | |
| | | @RequestMapping(value = "/bindCar", method = RequestMethod.POST) |
| | | @ApiOperation(value = "绑定车辆人员") |
| | | public Result<Car> bindCar(String carId,String userId) { |
| | | Car car = iCarService.getById(carId); |
| | | car.setUserId(userId); |
| | | iCarService.saveOrUpdate(car); |
| | | public Result<Car> bindCar(String carId,String userId) {//A车张三 李四 B车王五,赵六 |
| | | User user = securityUtil.getCurrUser(); |
| | | QueryWrapper<Car> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("user_id",user.getId()).or().eq("follow_user_id",user.getId()); |
| | | Car one = iCarService.getOne(queryWrapper);//原来的车 |
| | | |
| | | if(one!=null){ |
| | | //如果还是选了原来的车则不用变 |
| | | if(one.getId().equals(carId)){ |
| | | |
| | | }else{ |
| | | //如果选了另一辆车,先把原来的车的人员清空 |
| | | if(user.getType2()==0){ |
| | | one.setUserId(""); |
| | | }else{ |
| | | one.setFollowUserId(""); |
| | | } |
| | | iCarService.saveOrUpdate(one); |
| | | |
| | | //绑定上新选的车 |
| | | Car car = iCarService.getById(carId); |
| | | if(car!=null){ |
| | | if(user.getType2()==0){ |
| | | car.setUserId(user.getId()); |
| | | }else{ |
| | | car.setFollowUserId(user.getId()); |
| | | } |
| | | iCarService.saveOrUpdate(car); |
| | | } |
| | | } |
| | | }else{ |
| | | Car car = iCarService.getById(carId); |
| | | if(car!=null){ |
| | | if(user.getType2()==0){ |
| | | car.setUserId(user.getId()); |
| | | }else{ |
| | | car.setFollowUserId(user.getId()); |
| | | } |
| | | iCarService.saveOrUpdate(car); |
| | | } |
| | | } |
| | | return ResultUtil.success("绑定成功"); |
| | | } |
| | | |