| | |
| | | package com.ruoyi.admin.controller; |
| | | |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.admin.entity.MasterWorker; |
| | | import com.ruoyi.admin.entity.RecoveryClassify; |
| | | import com.ruoyi.admin.entity.RecoveryServe; |
| | | import com.ruoyi.admin.entity.RecoveryServePrice; |
| | | import com.ruoyi.admin.entity.Region; |
| | | 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.RecoveryClassifyService; |
| | | import com.ruoyi.admin.service.RecoveryServePriceService; |
| | | import com.ruoyi.admin.service.RecoveryServeService; |
| | | import com.ruoyi.admin.service.RegionService; |
| | | import com.ruoyi.admin.service.SiteService; |
| | | import com.ruoyi.admin.utils.DescribeInstances; |
| | | import com.ruoyi.admin.vo.OrderByServeRecordVO; |
| | | import com.ruoyi.admin.vo.OrderDetailVO; |
| | | import com.ruoyi.admin.vo.OrderReasinDto; |
| | | import com.ruoyi.admin.vo.ReassinDto; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | | import com.ruoyi.common.core.domain.BaseEntity; |
| | | import com.ruoyi.common.core.domain.R; |
| | | import com.ruoyi.common.core.utils.DateUtils; |
| | | import com.ruoyi.common.core.utils.SnowflakeIdWorker; |
| | | import com.ruoyi.common.core.vo.PaperInVo; |
| | | import com.ruoyi.common.core.vo.PrintDto; |
| | | import com.ruoyi.common.redis.service.RedisService; |
| | | 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.entity.Order; |
| | | import com.ruoyi.order.api.entity.OrderCountVO; |
| | | import com.ruoyi.order.api.entity.OrderPageCountVO; |
| | | import com.ruoyi.order.api.entity.OrderQueryRequest; |
| | | import com.ruoyi.order.api.entity.OrderRequest; |
| | | 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 io.swagger.annotations.ApiOperation; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.nio.file.Files; |
| | | import java.nio.file.Paths; |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.Collections; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | 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({ |
| | |
| | | }) |
| | | public R<OrderDetailVO> orderDetail(@RequestParam String id) { |
| | | // 独立orderService |
| | | return R.ok(orderService.orderListDetail(id)); |
| | | OrderDetailVO orderDetailVO = orderService.orderListDetail(id); |
| | | if (orderDetailVO.getServeRecordInfo().getPhoto()!=null&&!orderDetailVO.getServeRecordInfo().getPhoto().isEmpty()){ |
| | | if (orderDetailVO.getServeRecordInfo().getPhoto().get(0).equals("")){ |
| | | orderDetailVO.getServeRecordInfo().setPhoto(null); |
| | | } |
| | | } |
| | | return R.ok(orderDetailVO); |
| | | } |
| | | @Resource |
| | | private RecoveryClassifyService recoveryClassifyService; |
| | | |
| | | |
| | | /** |
| | | * 订单列表 |
| | | * |
| | | * @param orderQueryRequest 订单列表查询参数 |
| | | */ |
| | | @RequiresPermissions("order_list") |
| | | @ApiOperation(value = "订单列表-分页", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/queryPage") |
| | | public R<Page<Order>> queryPage(@RequestBody OrderQueryRequest orderQueryRequest) { |
| | |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | List<String> userCity = new ArrayList<>(); |
| | | if (loginUser.getIsFranchisee()) { |
| | | userCity = loginUser.getCityList(); |
| | | if (null == orderQueryRequest.getCityList() || orderQueryRequest.getCityList().isEmpty()) { |
| | | orderQueryRequest.setCityList(loginUser.getCityList()); |
| | | } else { |
| | | orderQueryRequest.getCityList().addAll(loginUser.getCityList()); |
| | | } |
| | | } |
| | | return R.ok(orderClient.queryPage(orderQueryRequest).getData()); |
| | | List<Integer> servIds = new ArrayList<>(); |
| | | if (orderQueryRequest.getClassNameId()!=null){ |
| | | List<Integer> classIds = recoveryClassifyService.lambdaQuery().eq(RecoveryClassify::getId, orderQueryRequest.getClassNameId()).list().stream().map(RecoveryClassify::getId).collect(Collectors.toList()); |
| | | servIds = recoveryServeService.lambdaQuery().eq(BaseEntity::getIsDelete,0).in(RecoveryServe::getClassifyId, classIds).list().stream().map(RecoveryServe::getId).collect(Collectors.toList()); |
| | | } |
| | | orderQueryRequest.setServIds(servIds); |
| | | Page<Order> data = orderClient.queryPage(orderQueryRequest).getData(); |
| | | if (null != data) { |
| | | for (Order record : data.getRecords()) { |
| | | // 回收服务信息 |
| | | Integer serverId = record.getServerId(); |
| | | MasterWorker masterWorker = masterWorkerService.lambdaQuery() |
| | | .eq(MasterWorker::getId, serverId) |
| | | .eq(MasterWorker::getIsDelete, 0).one(); |
| | | if (null != masterWorker) { |
| | | record.setServerName(masterWorker.getRealName()); |
| | | record.setServerPhone(masterWorker.getPhone()); |
| | | } |
| | | if (record.getAddress()!=null) { |
| | | record.setReservationAddress(record.getReservationAddress() + record.getAddress()); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(data); |
| | | } |
| | | |
| | | /** |
| | | * 订单id列表 |
| | | * |
| | | * @param orderQueryRequest 订单列表查询参数 |
| | | */ |
| | | @ApiOperation(value = "订单id列表-分页", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/queryIdList") |
| | | public R<List<String>> queryIdList(@RequestBody OrderQueryRequest orderQueryRequest) { |
| | | return R.ok(orderService.queryIdList(orderQueryRequest)); |
| | | } |
| | | /** |
| | | * 订单列表 |
| | | */ |
| | | @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()); |
| | | } |
| | | } |
| | | List<Integer> servIds = new ArrayList<>(); |
| | | if (orderQueryRequest.getClassNameId()!=null){ |
| | | List<Integer> classIds = recoveryClassifyService.lambdaQuery().eq(RecoveryClassify::getId, orderQueryRequest.getClassNameId()).list().stream().map(RecoveryClassify::getId).collect(Collectors.toList()); |
| | | servIds = recoveryServeService.lambdaQuery().eq(BaseEntity::getIsDelete,0).in(RecoveryServe::getClassifyId, classIds).list().stream().map(RecoveryServe::getId).collect(Collectors.toList()); |
| | | } |
| | | orderQueryRequest.setServIds(servIds); |
| | | |
| | | return R.ok(orderClient.orderPageCount(orderQueryRequest).getData()); |
| | | } |
| | | |
| | |
| | | * |
| | | * @param id 订单id |
| | | */ |
| | | @RequiresPermissions("order_detail") |
| | | @ApiOperation(value = "订单列表-订单详情", tags = {"后台-订单管理"}) |
| | | @GetMapping(value = "/detail") |
| | | @ApiImplicitParams({ |
| | |
| | | return R.ok(orderClient.detail(id).getData()); |
| | | } |
| | | |
| | | |
| | | @Resource |
| | | private RecoveryServePriceService recoveryServePriceService; |
| | | /** |
| | | * 新增订单 |
| | | * 后台订单为指定订单,默认为待上门状态 |
| | | * |
| | | * @param order 站点信息 |
| | | */ |
| | | @RequiresPermissions("order_save") |
| | | @ApiOperation(value = "订单列表-新增订单", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/save") |
| | | public R<String> save(@RequestBody OrderRequest order) { |
| | |
| | | .eq(MasterWorker::getIsDelete, 0).one(); |
| | | order.setServerName(masterWorker.getRealName()); |
| | | order.setServerPhone(masterWorker.getPhone()); |
| | | order.setAcceptTime(new Date()); |
| | | // 待上门 |
| | | order.setState(Constants.ONE); |
| | | } else { |
| | |
| | | RecoveryServe recoveryServe = recoveryServeService.lambdaQuery() |
| | | .eq(RecoveryServe::getId, order.getServeId()) |
| | | .eq(RecoveryServe::getIsDelete, 0).one(); |
| | | |
| | | order.setServeName(recoveryServe.getServeName()); |
| | | order.setServePrice(recoveryServe.getDefaultPrice()); |
| | | order.setOrderMoney(recoveryServe.getDefaultPrice()); |
| | | RecoveryServePrice one = recoveryServePriceService.lambdaQuery().eq(RecoveryServePrice::getCity, order.getCityCode()).eq(RecoveryServePrice::getRecoveryServeId, order.getServeId()).eq(BaseEntity::getIsDelete, 0).one(); |
| | | if (one==null) { |
| | | order.setOrderMoney(recoveryServe.getDefaultPrice()); |
| | | }else { |
| | | order.setOrderMoney(one.getRecoveryPrice()); |
| | | } |
| | | Boolean data = orderClient.save(order).getData(); |
| | | 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(); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // @RequiresPermissions({"reassignment_edit","order_edit"}) |
| | | |
| | | @ApiOperation(value = "订单列表-编辑", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/edit") |
| | | public R<String> edit(@RequestBody OrderRequest order) { |
| | | // 站点信息 |
| | | Site site = siteService.lambdaQuery() |
| | | .eq(Site::getId, order.getSiteId()) |
| | | .eq(Site::getIsDelete, 0).one(); |
| | | if (null != site) { |
| | | order.setSiteName(site.getSiteName()); |
| | | } |
| | | |
| | | // 师傅信息 |
| | | if (null != order.getServerId()) { |
| | | MasterWorker masterWorker = masterWorkerService.lambdaQuery() |
| | | .eq(MasterWorker::getId, order.getServerId()) |
| | | .eq(MasterWorker::getIsDelete, 0).one(); |
| | | order.setServerName(masterWorker.getRealName()); |
| | | order.setServerPhone(masterWorker.getPhone()); |
| | | } else { |
| | | // 待派单状态 |
| | | order.setState(Constants.ZERO); |
| | | } |
| | | RecoveryServe recoveryServe = recoveryServeService.lambdaQuery() |
| | | .eq(RecoveryServe::getId, order.getServeId()) |
| | | .eq(RecoveryServe::getIsDelete, 0).one(); |
| | | RecoveryServePrice one = recoveryServePriceService.lambdaQuery().eq(RecoveryServePrice::getCity, order.getCityCode()).eq(RecoveryServePrice::getRecoveryServeId, order.getServeId()).eq(BaseEntity::getIsDelete, 0).last("limit 1").one(); |
| | | if (one==null) { |
| | | order.setOrderMoney(recoveryServe.getDefaultPrice()); |
| | | }else { |
| | | order.setOrderMoney(one.getRecoveryPrice()); |
| | | } |
| | | order.setServeName(recoveryServe.getServeName()); |
| | | // 后台订单 |
| | | order.setType(Constants.ONE); |
| | | Boolean data = orderClient.edit(order).getData(); |
| | | |
| | | 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") |
| | | @PostMapping(value = "/reassignment") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "操作类型(1:订单派单;2:订单改派)", name = "type", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "订单id", name = "orderId", dataType = "Integer", required = true), |
| | |
| | | @ApiImplicitParam(value = "改派原因", name = "applyReason", dataType = "String") |
| | | }) |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R<String> reassignment(@RequestParam Integer type, @RequestParam String orderId, |
| | | @RequestParam Integer workerId, String applyReason) { |
| | | public R<String> reassignment(@RequestBody OrderReasinDto orderReasinDto) { |
| | | // String[] split = orderIds.split(","); |
| | | for (ReassinDto orderId : orderReasinDto.getReassinDtos()) { |
| | | |
| | | MasterWorker masterWorker = masterWorkerService.lambdaQuery() |
| | | .eq(MasterWorker::getId, workerId) |
| | | .eq(MasterWorker::getId, orderReasinDto.getWorkerId()) |
| | | .eq(MasterWorker::getIsDelete, 0).one(); |
| | | Order order = orderClient.exchangeOrder(type, orderId, workerId, |
| | | Order item = orderClient.detail(orderId.getOrderId()).getData(); |
| | | Order order = orderClient.exchangeOrder(orderId.getType(), orderId.getOrderId(), orderReasinDto.getWorkerId(), |
| | | masterWorker.getRealName(), masterWorker.getPhone()).getData(); |
| | | // 订单派单 |
| | | boolean result = true; |
| | | if (Constants.TWO.equals(type)) { |
| | | if (Constants.TWO.equals(orderId.getType())) { |
| | | if (order.getState().equals(Constants.SIX) || order.getState().equals(Constants.THREE)) { |
| | | orderClient.updateState(order.getId(), Constants.ONE); |
| | | } |
| | | // 生成改派信息 |
| | | ChangeDispatch changeDispatch = new ChangeDispatch(); |
| | | changeDispatch.setWorkerId(order.getServerId()); |
| | | changeDispatch.setWorkerName(order.getServerName()); |
| | | changeDispatch.setApplyReason(applyReason); |
| | | changeDispatch.setApplyTime(new Date()); |
| | | changeDispatch.setState(Constants.ONE); |
| | | changeDispatch.setOrderId(order.getId()); |
| | | changeDispatch.setOrderNumber(order.getOrderNumber()); |
| | | if (null != order.getUserId()) { |
| | | changeDispatch.setUserId(order.getUserId()); |
| | | // 订单状态为 待完工时,需要更改状态 待上门且清空师傅到达预约点时间 |
| | | if (order.getState().equals(Constants.TWO)) { |
| | | orderClient.updateStateAndArrivalTime(orderId.getOrderId(), Constants.ONE); |
| | | } |
| | | changeDispatch.setUserName(order.getReservationName()); |
| | | changeDispatch.setIsDelete(Constants.ZERO); |
| | | result = dispatchClient.saveRecord(changeDispatch).getData(); |
| | | // 生成改派信息 |
| | | // ChangeDispatch changeDispatch = new ChangeDispatch(); |
| | | // changeDispatch.setWorkerId(item.getServerId()); |
| | | // changeDispatch.setWorkerName(item.getServerName()); |
| | | // changeDispatch.setApplyReason(orderReasinDto.getApplyReason()); |
| | | // changeDispatch.setApplyTime(new Date()); |
| | | // changeDispatch.setState(Constants.ONE); |
| | | // changeDispatch.setOrderId(orderId.getOrderId()); |
| | | // changeDispatch.setOrderNumber(item.getOrderNumber()); |
| | | // if (null != item.getUserId()) { |
| | | // changeDispatch.setUserId(item.getUserId()); |
| | | // } |
| | | // changeDispatch.setUserName(item.getReservationName()); |
| | | // 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(orderReasinDto.getWorkerId())); |
| | | if (null != context) { |
| | | NettyWebSocketController.sendMsgToClient(context, "您有一条新的订单,请注意查收!"); |
| | | } |
| | | return result ? R.ok() : R.fail(); |
| | | // try { |
| | | // WebSocketServer.sendInfo("您有一条新的订单,请注意查收!", String.valueOf(workerId)); |
| | | // } catch (IOException e) { |
| | | // return R.fail("订单推送失败!"); |
| | | // } |
| | | } |
| | | |
| | | return R.ok() ; |
| | | } |
| | | |
| | | /** |
| | |
| | | * |
| | | * @param ids 站点多条id拼接 |
| | | */ |
| | | @RequiresPermissions("order_delete") |
| | | @ApiOperation(value = "订单列表-批量删除订单", tags = {"后台-订单管理"}) |
| | | @GetMapping(value = "/batchDelete") |
| | | @ApiImplicitParams({ |
| | |
| | | return R.ok(orderClient.batchDelete(ids).getData()); |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 订单列表-excel导出 |
| | | * |
| | | * @param orderQueryRequest 筛选参数 |
| | | */ |
| | | @RequiresPermissions("order_export") |
| | | @ApiOperation(value = "订单列表-excel导出", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/excelExport") |
| | | public R<String> excelExport(@RequestBody OrderQueryRequest orderQueryRequest, HttpServletResponse response) { |
| | | List<Integer> servIds = new ArrayList<>(); |
| | | if (orderQueryRequest.getClassNameId()!=null){ |
| | | List<Integer> classIds = recoveryClassifyService.lambdaQuery().eq(RecoveryClassify::getId, orderQueryRequest.getClassNameId()).list().stream().map(RecoveryClassify::getId).collect(Collectors.toList()); |
| | | servIds = recoveryServeService.lambdaQuery().eq(BaseEntity::getIsDelete,0).in(RecoveryServe::getClassifyId, classIds).list().stream().map(RecoveryServe::getId).collect(Collectors.toList()); |
| | | } |
| | | orderQueryRequest.setServIds(servIds); |
| | | |
| | | |
| | | R<List<Order>> result = orderClient.excelExport(orderQueryRequest); |
| | | // 独立orderService |
| | | return orderService.excelExport(result.getData(), 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); |
| | | } |
| | | |
| | | @ApiOperation(value = "ocr识别", tags = {"后台-首页"}) |
| | | @PostMapping (value = "/ocr") |
| | | public R<JSONObject> ocr(String ocrAddress) { |
| | | return R.ok(DescribeInstances.ocr(ocrAddress)); |
| | | } |
| | | |
| | | public static void main(String[] args) { |
| | | System.out.println(LocalDateTime.now().plusMonths(1)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * @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> map = masterWorkerList.stream().collect(Collectors.toMap(MasterWorker::getId, |
| | | // 师傅头像列表 |
| | | 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()) { |
| | | Integer workerId = record.getWorkerId(); |
| | | record.setProfilePicture(map.get(workerId)); |
| | | record.setRealName(realNameMap.get(workerId)); |
| | | record.setProfilePicture(profilePictureMap.get(workerId)); |
| | | } |
| | | return R.ok(data); |
| | | } |
| | | |
| | | @ApiOperation(value = "打印计数", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/print") |
| | | public R print(@RequestParam Long id) { |
| | | |
| | | orderClient.count(String.valueOf(id)); |
| | | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "打印入库单子", tags = {"后台-订单管理"}) |
| | | @PostMapping(value = "/paperCount") |
| | | public R paperCount(@RequestParam Integer id,@RequestParam String date) { |
| | | R<List<PaperInVo>> papercount = orderClient.papercount(String.valueOf(id),date); |
| | | for (PaperInVo datum : papercount.getData()) { |
| | | datum.setName(recoveryServeService.getById(datum.getServeId()).getServeName()); |
| | | } |
| | | PrintDto printDto =new PrintDto(); |
| | | printDto.setName(masterWorkerService.getById(id).getRealName()); |
| | | printDto.setPapers(papercount.getData()); |
| | | printDto.setDate(date); |
| | | return R.ok(printDto); |
| | | } |
| | | |
| | | @Resource |
| | | private RedisService redisService; |
| | | @ApiOperation(value = "地图统计", tags = {"后台-订单管理-地图统计"}) |
| | | @PostMapping(value = "/map/works") |
| | | public R<List<MasterWorker>> map(String cityCode,String name) { |
| | | |
| | | LoginUser loginUser = tokenService.getLoginUser(); |
| | | if (null == loginUser) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | if (cityCode==null) { |
| | | if (loginUser.getIsFranchisee()) { |
| | | cityCode = loginUser.getCityList().get(0); |
| | | } else { |
| | | cityCode = "420100"; |
| | | } |
| | | } |
| | | Set<Integer> workIds = redisService.getCacheSet("workerLocation:" + cityCode+":"); |
| | | if (workIds==null||workIds.isEmpty()){ |
| | | return R.ok(new ArrayList<>()); |
| | | } |
| | | List<MasterWorker> list = masterWorkerService.lambdaQuery().in(MasterWorker::getId, workIds).eq(name!=null&&name!="",MasterWorker::getRealName,name).eq(cityCode!=null&&cityCode!="", MasterWorker::getCityCode,cityCode).list(); |
| | | for (MasterWorker masterWorker : list) { |
| | | masterWorker.setLacation(redisService.getCacheObject("work:"+masterWorker.getId()+":")); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | @ApiOperation(value = "获师傅", tags = {"后台-订单管理-地图统计"}) |
| | | @PostMapping(value = "/map/line") |
| | | public R<List<OrderByServeRecordVO>> line(Integer id) { |
| | | List<OrderByServeRecordVO> list = new ArrayList<>(); |
| | | // 获取当天时间 |
| | | String today = DateUtils.dateTimeNow("yyyy-MM-dd"); |
| | | OrderByServeRecordVO orderByServeRecord = new OrderByServeRecordVO(); |
| | | |
| | | String masterFolderPath = "/usr/local/coordinate/" + id; |
| | | File masterFolder = new File(masterFolderPath); |
| | | // 检查师傅ID的文件夹是否存在,存在就读取轨迹数据 |
| | | System.out.println("文件是否存在:" + masterFolder.exists()); |
| | | if (masterFolder.exists()) { |
| | | // 检查订单ID的JSON文件是否存在,不存在则创建 |
| | | String jsonFilePath = masterFolderPath + "/" + today + ".json"; |
| | | // String jsonFilePath = "C:\\Users\\Admin\\Desktop\\1814257493315514369.json"; |
| | | File jsonFile = new File(jsonFilePath); |
| | | System.out.println("订单Json文件是否存在:" + jsonFile.exists()); |
| | | List<String> coordinateList = getCoordinateList(jsonFile, jsonFilePath); |
| | | orderByServeRecord.setCoordinate(coordinateList); |
| | | //获取轨迹标点 |
| | | String baseMarkerPath = "/usr/local/marker/" + id; |
| | | //标点根目录 |
| | | File markerMasterFolder = new File(baseMarkerPath); |
| | | if (markerMasterFolder.exists()) { |
| | | // 标点json文件路径 |
| | | String markerJsonFilePath = markerMasterFolder + "/" + today + ".json"; |
| | | File markerJsonFile = new File(markerJsonFilePath); |
| | | List<String> markerCoordinateList = getCoordinateList(markerJsonFile, |
| | | markerJsonFilePath); |
| | | orderByServeRecord.setMarker(markerCoordinateList); |
| | | } |
| | | list.add(orderByServeRecord); |
| | | } |
| | | return R.ok(list); |
| | | } |
| | | |
| | | /** |
| | | * 获取坐标集合 |
| | | * @param jsonFile json文件 |
| | | * @param jsonFilePath 文件路径 |
| | | * @return |
| | | */ |
| | | private static List<String> getCoordinateList(File jsonFile, String jsonFilePath) { |
| | | if (jsonFile.exists()) { |
| | | try { |
| | | String jsonContent = new String(Files.readAllBytes(Paths.get(jsonFilePath))); |
| | | System.out.println("JSON 文件内容:" + jsonContent); |
| | | List<com.alibaba.fastjson2.JSONObject> coordinate = com.alibaba.fastjson2.JSONObject.parseObject(jsonContent, List.class); |
| | | List<String> coordinateList = new ArrayList<>(); |
| | | if (null != coordinate) { |
| | | for (com.alibaba.fastjson2.JSONObject jsonObject : coordinate) { |
| | | Object s = jsonObject.get("coordinate"); |
| | | if (s != null) { |
| | | coordinateList.add(s.toString()); |
| | | } |
| | | } |
| | | } |
| | | return coordinateList; |
| | | } catch (IOException e) { |
| | | System.out.println(e.getMessage()); |
| | | } |
| | | } |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | @Resource |
| | | private RegionService regionService; |
| | | |
| | | @ApiOperation(value = "获取城市名字", tags = {"后台-订单管理-地图统计"}) |
| | | @PostMapping(value = "/map/cityName") |
| | | public R line(String cityCode) { |
| | | Region one = regionService.lambdaQuery().eq(Region::getCode, cityCode).one(); |
| | | return R.ok(one.getName(),""); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | // @ApiOperation(value = "获取司机的订单路线", tags = {"后台-订单管理-地图统计"}) |
| | | // @PostMapping(value = "/map/works/line") |
| | | // public R<List<MasterWorker>> map(@RequestParam Integer workId) { |
| | | // |
| | | // |
| | | // return R.ok(list); |
| | | // } |
| | | |
| | | |
| | | |
| | | } |