| | |
| | | import cn.exrick.xboot.core.common.vo.PageVo; |
| | | import cn.exrick.xboot.core.common.vo.Result; |
| | | import cn.exrick.xboot.your.entity.DrivingRecord; |
| | | import cn.exrick.xboot.your.entity.OrderTask; |
| | | import cn.exrick.xboot.your.service.IDrivingRecordService; |
| | | import cn.hutool.core.date.DateUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | @Autowired |
| | | private IDrivingRecordService iDrivingRecordService; |
| | | |
| | | @RequestMapping(value = "/orderConfirm", method = RequestMethod.POST) |
| | | @ApiOperation(value = "订单确认") |
| | | public Result<DrivingRecord> orderConfirm(DrivingRecord record) { |
| | | if(StrUtil.isEmpty(record.getCarId())){ |
| | | return ResultUtil.error("车辆id不能为空"); |
| | | } |
| | | |
| | | String format = DateUtil.format(new Date(), "yyyy-MM-dd"); |
| | | QueryWrapper<DrivingRecord> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("driving_date",format); |
| | | wrapper.eq("car_id",record.getCarId()); |
| | | int count = iDrivingRecordService.count(wrapper); |
| | | if(count>0){ |
| | | return ResultUtil.error("今日已核对,请勿重复提交"); |
| | | } |
| | | |
| | | record.setDrivingDate(DateUtil.parse(format)); |
| | | iDrivingRecordService.saveOrUpdate(record); |
| | | return ResultUtil.success("操作成功"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/updateMileage", method = RequestMethod.POST) |
| | | @ApiOperation(value = "添加行车记录") |
| | | public Result<DrivingRecord> updateMileage(String carId,int mileage,String userId,String inDate) { |
| | | String format = DateUtil.format(new Date(), "yyyy-MM-dd"); |
| | | QueryWrapper<DrivingRecord> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("driving_date",format); |
| | | wrapper.eq("car_id",carId); |
| | | DrivingRecord drivingRecord = iDrivingRecordService.getOne(wrapper); |
| | | drivingRecord.setMileage(mileage); |
| | | drivingRecord.setInTime(DateUtil.parseDate(inDate)); |
| | | drivingRecord.setUserId(userId); |
| | | iDrivingRecordService.saveOrUpdate(drivingRecord); |
| | | return new ResultUtil<DrivingRecord>().setSuccessMsg("添加成功"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/get/{id}", method = RequestMethod.GET) |
| | | @ApiOperation(value = "通过id获取") |
| | | public Result<DrivingRecord> get(@PathVariable String id) { |