| | |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.your.entity.*; |
| | | import cn.exrick.xboot.your.service.IAddOilService; |
| | | import cn.exrick.xboot.your.service.ICarService; |
| | | import cn.exrick.xboot.your.service.IDrivingRecordService; |
| | | import cn.exrick.xboot.your.service.IOrderTaskService; |
| | | import cn.exrick.xboot.your.service.*; |
| | | import cn.exrick.xboot.your.vo.CarVo; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.Wrapper; |
| | |
| | | @Autowired |
| | | private IDrivingRecordService iDrivingRecordService; |
| | | @Autowired |
| | | private IOrderTaskService iOrderTaskService; |
| | | private ICustomerService iCustomerService; |
| | | |
| | | |
| | | @RequestMapping(value = "/get/{id}", 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(); |
| | |
| | | queryWrapper.ge(beginTime!=null && beginTime!="","add_date",beginTime); |
| | | |
| | | wrapper.le(endTime!=null && endTime!="","in_time",endTime); |
| | | queryWrapper.le(endTime!=null && endTime!="","add_date",beginTime); |
| | | queryWrapper.le(endTime!=null && endTime!="","add_date",endTime); |
| | | |
| | | QueryWrapper<OrderTask> wrapper1 = new QueryWrapper<>(); |
| | | |
| | |
| | | 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; |
| | | } |
| | | } |
| | |
| | | @ApiOperation(value = "编辑或更新数据") |
| | | public Result<Car> saveOrUpdate(Car car) { |
| | | |
| | | QueryWrapper<Car> wrapper = new QueryWrapper<>(); |
| | | QueryWrapper<Car> wrapper1 = new QueryWrapper<>(); |
| | | if (!car.getUserId().equals("")){ |
| | | wrapper.eq("user_id",car.getUserId()); |
| | | Car car1 = iCarService.getOne(wrapper); |
| | | if (car1!=null && !car1.getId().equals(car.getId())){ |
| | | return new ResultUtil<Car>().setErrorMsg("该驾驶员已被其他车辆绑定,请先解绑"); |
| | | } |
| | | } |
| | | |
| | | if (!car.getFollowUserId().equals("")){ |
| | | wrapper1.eq("follow_user_id",car.getFollowUserId()); |
| | | Car car1 = iCarService.getOne(wrapper1); |
| | | if (car1!=null && !car1.getId().equals(car.getId())){ |
| | | return new ResultUtil<Car>().setErrorMsg("该配送员已被其他车辆绑定,请先解绑"); |
| | | } |
| | | } |
| | | |
| | | if (iCarService.saveOrUpdate(car)) { |
| | | return new ResultUtil<Car>().setData(car); |
| | | } |
| | | |
| | | return new ResultUtil<Car>().setErrorMsg("操作失败"); |
| | | } |
| | | |