| | |
| | | package com.ruoyi.worker.controller; |
| | | |
| | | |
| | | import com.ruoyi.admin.api.entity.ExchangeDispatch; |
| | | import com.ruoyi.admin.api.entity.ChangeDispatch; |
| | | import com.ruoyi.admin.api.feignClient.AdminClient; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.exception.GlobalException; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import com.ruoyi.system.api.model.LoginUserInfo; |
| | | import com.ruoyi.worker.entity.Evaluate; |
| | | import com.ruoyi.worker.entity.MasterWorker; |
| | | import com.ruoyi.worker.entity.Order; |
| | | import com.ruoyi.worker.entity.ServeRecord; |
| | | import com.ruoyi.worker.entity.*; |
| | | import com.ruoyi.worker.request.OrderSubmitRequest; |
| | | import com.ruoyi.worker.service.EvaluateService; |
| | | import com.ruoyi.worker.service.MasterWorkerService; |
| | | import com.ruoyi.worker.service.OrderService; |
| | | import com.ruoyi.worker.service.ServeRecordService; |
| | | import com.ruoyi.worker.service.*; |
| | | import com.ruoyi.worker.vo.OrderDetailVO; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | private ServeRecordService serveRecordService; |
| | | @Resource |
| | | private EvaluateService evaluateService; |
| | | @Resource |
| | | private SysServeCoordinateService serveCoordinateService; |
| | | |
| | | /** |
| | | * 师傅端-获取订单列表 |
| | |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "改派原因", name = "reason", dataType = "String", required = true) |
| | | }) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<String> applyChange(@RequestParam Integer orderId, @RequestParam String reason) { |
| | | LoginUserInfo loginWorker = tokenService.getLoginUserByWorker(); |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | ChangeDispatch data = adminClient.changeDispatchOne(orderId).getData(); |
| | | if (null != data) { |
| | | return R.fail("当前订单已提交改派申请!"); |
| | | } |
| | | MasterWorker masterWorker = masterWorkerService.getById(loginWorker.getUserid()); |
| | | // 订单改派信息 |
| | | ExchangeDispatch exchangeDispatch = new ExchangeDispatch(); |
| | | exchangeDispatch.setWorkerId(masterWorker.getId()); |
| | | exchangeDispatch.setWorkerName(masterWorker.getRealName()); |
| | | exchangeDispatch.setApplyReason(reason); |
| | | exchangeDispatch.setApplyTime(DateUtils.getNowDate()); |
| | | exchangeDispatch.setState(0); |
| | | ChangeDispatch changeDispatch = new ChangeDispatch(); |
| | | changeDispatch.setWorkerId(masterWorker.getId()); |
| | | changeDispatch.setWorkerName(masterWorker.getRealName()); |
| | | changeDispatch.setApplyReason(reason); |
| | | changeDispatch.setApplyTime(DateUtils.getNowDate()); |
| | | changeDispatch.setState(0); |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderId).eq(Order::getIsDelete, 0).one(); |
| | | if (null == order) { |
| | | throw new GlobalException("订单信息异常!"); |
| | | } |
| | | exchangeDispatch.setOrderId(orderId); |
| | | exchangeDispatch.setOrderNumber(order.getOrderNumber()); |
| | | exchangeDispatch.setUserId(order.getUserId()); |
| | | exchangeDispatch.setUserName(order.getReservationName()); |
| | | changeDispatch.setOrderId(orderId); |
| | | changeDispatch.setOrderNumber(order.getOrderNumber()); |
| | | changeDispatch.setUserId(order.getUserId()); |
| | | changeDispatch.setUserName(order.getReservationName()); |
| | | // 添加改派信息 |
| | | Boolean save = adminClient.changeDispatchSave(exchangeDispatch).getData(); |
| | | Boolean save = adminClient.changeDispatchSave(changeDispatch).getData(); |
| | | return save ? R.ok() : R.fail(); |
| | | } |
| | | |
| | | /** |
| | | * 师傅端-已到达预约地点 |
| | | * |
| | | * @param orderId 订单id |
| | | */ |
| | | @ApiOperation(value = "订单路线导航", tags = {"师傅端-首页"}) |
| | | @GetMapping(value = "/orderNavigation") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "师傅所在经度", name = "longitude", dataType = "String", required = true), |
| | | @ApiImplicitParam(value = "师傅所在纬度", name = "latitude", dataType = "String", required = true) |
| | | }) |
| | | public R<Object> orderNavigation(@RequestParam Integer orderId, @RequestParam String longitude, |
| | | @RequestParam String latitude) { |
| | | LoginUserInfo loginWorker = tokenService.getLoginUserByWorker(); |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderId) |
| | | .eq(Order::getServerId, loginWorker.getUserid()) |
| | | .eq(Order::getIsDelete, 0).one(); |
| | | if (null == order) { |
| | | throw new GlobalException("请确认当前订单所派单师傅是否是您!"); |
| | | } |
| | | // 用户下单经纬度 |
| | | Double userLongitude = order.getLongitude(); |
| | | Double userLatitude = order.getLatitude(); |
| | | String userPosition = userLongitude + "," + userLatitude; |
| | | // 师傅当前位置 经纬度 |
| | | String workerPosition = longitude + "," + latitude; |
| | | return R.ok(orderService.orderNavigation(userPosition, workerPosition)); |
| | | } |
| | | |
| | | /** |
| | |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "orderId", name = "orderId", dataType = "Integer", required = true) |
| | | }) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> reachPosition(@RequestParam Integer orderId) { |
| | | LoginUserInfo loginWorker = tokenService.getLoginUserByWorker(); |
| | | if (null == loginWorker) { |
| | |
| | | if (null == order) { |
| | | throw new GlobalException("请确认当前订单所派单师傅是否是您!"); |
| | | } |
| | | order.setState(Constants.THREE); |
| | | // 待完工状态 |
| | | order.setState(Constants.TWO); |
| | | order.setArriveTime(new Date()); |
| | | return R.ok(orderService.updateById(order)); |
| | | } |
| | | |
| | |
| | | @ApiOperation(value = "订单详情", tags = {"师傅端-订单列表"}) |
| | | @GetMapping(value = "/orderDetail") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "orderId", name = "orderId", dataType = "Integer", required = true) |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true) |
| | | }) |
| | | public R<OrderDetailVO> orderDetail(@RequestParam Integer orderId) { |
| | | // 订单信息 |
| | |
| | | */ |
| | | @ApiOperation(value = "订单完工-提交订单", tags = {"师傅端-订单列表"}) |
| | | @PostMapping(value = "/orderSubmit") |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> orderSubmit(@RequestBody OrderSubmitRequest orderSubmitRequest) { |
| | | // 订单信息 |
| | | Order order = orderService.lambdaQuery().eq(Order::getId, orderSubmitRequest.getOrderId()) |
| | |
| | | return R.ok(update && save); |
| | | } |
| | | |
| | | /** |
| | | * 师傅端-定时调度记录师傅所走路线经纬度 |
| | | * |
| | | * @param orderId 订单id |
| | | * @param longitude 经度 |
| | | * @param latitude 纬度 |
| | | */ |
| | | @ApiOperation(value = "订单进行-记录路线经纬度", tags = {"师傅端-订单列表"}) |
| | | @GetMapping(value = "/coordinate") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "经度", name = "longitude", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "纬度", name = "latitude", dataType = "Integer", required = true) |
| | | }) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<Boolean> coordinate(@RequestParam Integer orderId, @RequestParam Double longitude, |
| | | @RequestParam Double latitude) { |
| | | LoginUserInfo loginWorker = tokenService.getLoginUserByWorker(); |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | SysServeCoordinate sysServeCoordinate = new SysServeCoordinate(); |
| | | sysServeCoordinate.setWorkerId(loginWorker.getUserid()); |
| | | sysServeCoordinate.setOrderId(orderId); |
| | | sysServeCoordinate.setCoordinate(longitude + "," + latitude); |
| | | sysServeCoordinate.setLongitude(BigDecimal.valueOf(longitude)); |
| | | sysServeCoordinate.setLatitude(BigDecimal.valueOf(latitude)); |
| | | return R.ok(serveCoordinateService.save(sysServeCoordinate)); |
| | | } |
| | | |
| | | } |