| | |
| | | import com.ruoyi.admin.entity.MasterWorker; |
| | | import com.ruoyi.admin.entity.RecoveryServe; |
| | | import com.ruoyi.admin.entity.Site; |
| | | import com.ruoyi.admin.service.*; |
| | | import com.ruoyi.admin.sorcket.WebSocketServer; |
| | | import com.ruoyi.admin.netty.NettyChannelMap; |
| | | import com.ruoyi.admin.netty.NettyWebSocketController; |
| | | import com.ruoyi.admin.service.MasterWorkerService; |
| | | import com.ruoyi.admin.service.OrderService; |
| | | import com.ruoyi.admin.service.RecoveryServeService; |
| | | import com.ruoyi.admin.service.SiteService; |
| | | import com.ruoyi.admin.vo.OrderDetailVO; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | import com.ruoyi.common.core.utils.GaoDeMapUtil; |
| | | import com.ruoyi.common.core.utils.SnowflakeIdWorker; |
| | | import com.ruoyi.common.core.vo.CityInfoVO; |
| | | import com.ruoyi.common.security.annotation.Logical; |
| | | import com.ruoyi.common.security.annotation.RequiresPermissions; |
| | | import com.ruoyi.common.security.service.TokenService; |
| | | import com.ruoyi.order.api.entity.*; |
| | | import com.ruoyi.order.api.feignClient.ExchangeDispatchClient; |
| | | import com.ruoyi.order.api.feignClient.OrderClient; |
| | | import com.ruoyi.order.api.request.OrderCountDataRequest; |
| | | import com.ruoyi.system.api.model.LoginUser; |
| | | import io.netty.channel.ChannelHandlerContext; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | | import io.swagger.annotations.ApiImplicitParams; |
| | |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | |
| | | private ExchangeDispatchClient dispatchClient; |
| | | @Resource |
| | | private TokenService tokenService; |
| | | @Resource |
| | | private FranchiseeService franchiseeService; |
| | | |
| | | /** |
| | | * 雪花算法类 |
| | |
| | | * |
| | | * @param id 订单id |
| | | */ |
| | | @RequiresPermissions(value = {"user_detail", "order_detail"}, logical = Logical.OR) |
| | | @ApiOperation(value = "订单列表-查询订单详情(包含服务信息、师傅信息、服务记录、订单评价)", tags = {"后台-订单管理"}) |
| | | @GetMapping(value = "/orderDetail") |
| | | @ApiImplicitParams({ |
| | |
| | | * |
| | | * @param orderQueryRequest 订单列表查询参数 |
| | | */ |
| | | @RequiresPermissions("order_list") |
| | | @ApiOperation(value = "订单列表-分页", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/queryPage") |
| | | public R<Page<Order>> queryPage(@RequestBody OrderQueryRequest orderQueryRequest) { |
| | |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | if (loginUser.getIsFranchisee()) { |
| | | orderQueryRequest.setCityList(loginUser.getCityList()); |
| | | if (null == orderQueryRequest.getCityList() || orderQueryRequest.getCityList().isEmpty()) { |
| | | orderQueryRequest.setCityList(loginUser.getCityList()); |
| | | } else { |
| | | orderQueryRequest.getCityList().addAll(loginUser.getCityList()); |
| | | } |
| | | } |
| | | Page<Order> data = orderClient.queryPage(orderQueryRequest).getData(); |
| | | if (null != data) { |
| | |
| | | record.setServerName(masterWorker.getRealName()); |
| | | record.setServerPhone(masterWorker.getPhone()); |
| | | } |
| | | record.setReservationAddress(record.getReservationAddress() + record.getAddress()); |
| | | } |
| | | } |
| | | return R.ok(data); |
| | |
| | | /** |
| | | * 订单列表 |
| | | */ |
| | | @RequiresPermissions("order_list") |
| | | @ApiOperation(value = "订单列表-各订单数量统计", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/orderPageCount") |
| | | public R<OrderPageCountVO> orderPageCount(@RequestBody OrderQueryRequest orderQueryRequest) { |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | if (loginUser.getIsFranchisee()) { |
| | | if (null == orderQueryRequest.getCityList() || orderQueryRequest.getCityList().isEmpty()) { |
| | | orderQueryRequest.setCityList(loginUser.getCityList()); |
| | | } else { |
| | | orderQueryRequest.getCityList().addAll(loginUser.getCityList()); |
| | | } |
| | | } |
| | | return R.ok(orderClient.orderPageCount(orderQueryRequest).getData()); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param id 订单id |
| | | */ |
| | | @RequiresPermissions("order_detail") |
| | | @ApiOperation(value = "订单列表-订单详情", tags = {"后台-订单管理"}) |
| | | @GetMapping(value = "/detail") |
| | | @ApiImplicitParams({ |
| | |
| | | * |
| | | * @param order 站点信息 |
| | | */ |
| | | @RequiresPermissions("order_save") |
| | | @ApiOperation(value = "订单列表-新增订单", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/save") |
| | | public R<String> save(@RequestBody OrderRequest order) { |
| | |
| | | if (null == data) { |
| | | return R.fail(orderClient.save(order).getMsg()); |
| | | } |
| | | try { |
| | | WebSocketServer.sendInfo("您有一条新的订单,请注意查收!", String.valueOf(order.getServerId())); |
| | | } catch (IOException e) { |
| | | return R.fail("订单推送失败!"); |
| | | System.out.println("服务人员id:" + order.getServerId()); |
| | | ChannelHandlerContext context = NettyChannelMap.getData(String.valueOf(order.getServerId())); |
| | | System.out.println("socket连接信息:" + context); |
| | | if (null != context) { |
| | | System.out.println("服务端发送消息到: " + order.getServerId()); |
| | | NettyWebSocketController.sendMsgToClient(context, "您有一条新的订单,请注意查收!"); |
| | | } |
| | | return data ? R.ok() : R.fail(); |
| | | } |
| | |
| | | * |
| | | * @param type 1:订单派单;2:订单改派 |
| | | */ |
| | | @RequiresPermissions("order_reassignment") |
| | | @ApiOperation(value = "订单列表-订单派单/改派", tags = {"后台-订单管理"}) |
| | | @GetMapping(value = "/reassignment") |
| | | @ApiImplicitParams({ |
| | |
| | | changeDispatch.setIsDelete(Constants.ZERO); |
| | | result = dispatchClient.saveRecord(changeDispatch).getData(); |
| | | } |
| | | try { |
| | | WebSocketServer.sendInfo("您有一条新的订单,请注意查收!", String.valueOf(workerId)); |
| | | } catch (IOException e) { |
| | | return R.fail("订单推送失败!"); |
| | | ChannelHandlerContext context = NettyChannelMap.getData(String.valueOf(workerId)); |
| | | if (null != context) { |
| | | NettyWebSocketController.sendMsgToClient(context, "您有一条新的订单,请注意查收!"); |
| | | } |
| | | // try { |
| | | // WebSocketServer.sendInfo("您有一条新的订单,请注意查收!", String.valueOf(workerId)); |
| | | // } catch (IOException e) { |
| | | // return R.fail("订单推送失败!"); |
| | | // } |
| | | return result ? R.ok() : R.fail(); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param ids 站点多条id拼接 |
| | | */ |
| | | @RequiresPermissions("order_delete") |
| | | @ApiOperation(value = "订单列表-批量删除订单", tags = {"后台-订单管理"}) |
| | | @GetMapping(value = "/batchDelete") |
| | | @ApiImplicitParams({ |
| | |
| | | * |
| | | * @param orderQueryRequest 筛选参数 |
| | | */ |
| | | @RequiresPermissions("order_export") |
| | | @ApiOperation(value = "订单列表-excel导出", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/excelExport") |
| | | public R<String> excelExport(@RequestBody OrderQueryRequest orderQueryRequest, HttpServletResponse response) { |
| | |
| | | } |
| | | |
| | | /** |
| | | * 旧数据迁移 |
| | | * |
| | | * @param index 权限 |
| | | */ |
| | | @ApiOperation(value = "旧数据迁移", tags = {"后台-首页"}) |
| | | @GetMapping(value = "/oldData") |
| | | public R<String> oldData(@RequestParam Integer index, @RequestParam("pageNum") Integer pageNum, |
| | | @RequestParam("pageSize") Integer pageSize) { |
| | | return orderClient.oldData(index, pageNum, pageSize); |
| | | } |
| | | |
| | | /** |
| | | * 订单列表-excel导出 |
| | | * |
| | | * @param name 师傅姓名 |
| | | * @param phone 师傅电话 |
| | | */ |
| | | @RequiresPermissions("order_count") |
| | | @ApiOperation(value = "订单统计", tags = {"后台-订单管理"}) |
| | | @GetMapping(value = "/orderCount") |
| | | @ApiImplicitParams({ |
| | |
| | | public R<Page<OrderCountVO>> orderCount(String name, String phone, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | Page<OrderCountVO> data = orderClient.orderCount(name, phone, pageNum, pageSize).getData(); |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | List<String> cityList = new ArrayList<>(); |
| | | if (loginUser.getIsFranchisee()) { |
| | | cityList = loginUser.getCityList(); |
| | | } |
| | | // 查询参数 |
| | | OrderCountDataRequest orderCountDataRequest = new OrderCountDataRequest(); |
| | | orderCountDataRequest.setWorkerName(name); |
| | | orderCountDataRequest.setWorkerPhone(phone); |
| | | orderCountDataRequest.setCityList(cityList); |
| | | orderCountDataRequest.setPageNum(pageNum); |
| | | orderCountDataRequest.setPageSize(pageSize); |
| | | // 远程调用 |
| | | Page<OrderCountVO> data = orderClient.orderCount(orderCountDataRequest).getData(); |
| | | List<Integer> idList = data.getRecords().stream().map(OrderCountVO::getWorkerId) |
| | | .collect(Collectors.toList()); |
| | | List<MasterWorker> masterWorkerList; |
| | |
| | | masterWorkerList = masterWorkerService.lambdaQuery() |
| | | .eq(MasterWorker::getIsDelete, 0).list(); |
| | | } |
| | | // 师傅头像列表 |
| | | Map<Integer, String> profilePictureMap = masterWorkerList.stream().collect(Collectors.toMap(MasterWorker::getId, |
| | | mw -> Optional.ofNullable(mw.getProfilePicture()).orElse(""))); |
| | | // 师傅姓名 |
| | | Map<Integer, String> realNameMap = masterWorkerList.stream().collect(Collectors.toMap(MasterWorker::getId, |
| | | mw -> Optional.ofNullable(mw.getRealName()).orElse(""))); |
| | | for (OrderCountVO record : data.getRecords()) { |