| | |
| | | package com.ruoyi.worker.controller; |
| | | |
| | | |
| | | import cn.afterturn.easypoi.cache.manager.IFileLoader; |
| | | import com.alibaba.fastjson2.JSONObject; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.ruoyi.common.core.constant.Constants; |
| | |
| | | import java.util.Map; |
| | | import java.util.Optional; |
| | | import java.util.Set; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | import javax.annotation.Resource; |
| | | |
| | | import lombok.Synchronized; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | |
| | | * |
| | | * @param state 订单状态(0:全部、1:待上门、2:已完结) |
| | | */ |
| | | @ApiOperation(value = "订单列表", tags = {"师傅端-订单列表"}) |
| | | @ApiOperation(value = "订单列表", tags = {"师傅端-订单列表[2.0]"}) |
| | | @GetMapping(value = "/orderList") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "订单状态(0:全部、1:待上门、2:已完结)", name = "state", dataType = "Integer", required = true) |
| | | @ApiImplicitParam(value = "订单状态(0:全部、1:待上门、2:已完结、7:待预约)", name = "state", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "姓名,电话,地址搜索", name = "searchValues", dataType = "String", required = false), |
| | | }) |
| | | public R<Page<Order>> orderList(@RequestParam Integer state, |
| | | @RequestParam String searchValues, |
| | | @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum, |
| | | @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { |
| | | LoginUserInfo loginWorker = tokenService.getLoginUserByWorker(); |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | Page<Order> dataList = orderClient.orderListWorker(loginWorker.getUserid(), state, pageNum, pageSize).getData(); |
| | | Page<Order> dataList = orderClient.orderListWorker(loginWorker.getUserid(), state,searchValues, pageNum, pageSize).getData(); |
| | | List<Order> orderList = dataList.getRecords(); |
| | | List<Integer> ids = orderList.stream().map(Order::getServeId).collect(Collectors.toList()); |
| | | if (!ids.isEmpty()) { |
| | |
| | | @ApiImplicitParam(value = "经度", name = "longitude", dataType = "Integer", required = true), |
| | | @ApiImplicitParam(value = "纬度", name = "latitude", dataType = "Integer", required = true) |
| | | }) |
| | | @Synchronized |
| | | public R<Boolean> coordinate(@RequestParam Double longitude, @RequestParam Double latitude) { |
| | | |
| | | System.err.println("调用记录经纬度"+ LocalDateTime.now()); |
| | |
| | | if (null == loginWorker) { |
| | | return R.loginExpire("登录失效!"); |
| | | } |
| | | Object cacheObject2 = redisService.getCacheObject("LOCK" + loginWorker.getUserid()); |
| | | if (cacheObject2!=null){ |
| | | return R.ok(); |
| | | }else { |
| | | redisService.setCacheObject("LOCK" + loginWorker.getUserid(),"1", 10L, TimeUnit.SECONDS); |
| | | } |
| | | |
| | | // 获取当天时间 |
| | | String today = DateUtils.dateTimeNow("yyyy-MM-dd"); |
| | | Integer workerId = loginWorker.getUserid(); |
| | |
| | | // 读取订单ID的JSON文件内容 |
| | | try { |
| | | String jsonContent = new String(Files.readAllBytes(Paths.get(jsonFilePath))); |
| | | System.out.println("JSON 文件内容:" + jsonContent); |
| | | List<ServeCoordinate> coordinate = JSONObject.parseObject(jsonContent, List.class); |
| | | // 订单轨迹信息 |
| | | ServeCoordinate data = new ServeCoordinate(); |
| | |
| | | LocalDateTime now = LocalDateTime.now(); |
| | | |
| | | // 减去三十分钟 |
| | | LocalDateTime thirtyMinutesAgo = now.minusMinutes(10); |
| | | LocalDateTime thirtyMinutesAgo = now.minusMinutes(5); |
| | | |
| | | // 定义日期时间格式 |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); |
| | |
| | | String nowStr = now.format(formatter); |
| | | |
| | | |
| | | redisService.setCacheObject("MARK:"+workerId+":"+nowStr,longitude + "," + latitude); |
| | | redisService.setCacheObject("MARK:"+workerId+":"+nowStr,longitude + "," + latitude, 10L, TimeUnit.MINUTES); |
| | | |
| | | String cacheObject = redisService.getCacheObject("MARK:" + workerId + ":" + formattedTime); |
| | | if (cacheObject!=null){ |
| | |
| | | System.err.println("-----当前距离"+distance); |
| | | //如果超出一定范围,存入Mark文件 |
| | | if (distance<50){ |
| | | redisService.setCacheObject("TIME:"+workerId,LocalDateTime.now()); |
| | | redisService.setCacheObject("TIME:"+workerId,LocalDateTime.now(), 10L, TimeUnit.MINUTES); |
| | | marker(longitude,latitude); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | redisService.deleteObject("LOCK" + loginWorker.getUserid()); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | |
| | | // 检查差值是否小于等于2分钟 |
| | | long minutes = Math.abs(duration.toMinutes()); |
| | | return minutes >= 10; |
| | | return minutes >= 5; |
| | | } |
| | | /** |
| | | * 师傅端-定时调度记录师傅当天的轨迹标点 |
| | |
| | | // 读取订单ID的JSON文件内容 |
| | | try { |
| | | String jsonContent = new String(Files.readAllBytes(Paths.get(jsonFilePath))); |
| | | System.out.println("JSON 文件内容:" + jsonContent); |
| | | List<ServeCoordinate> coordinate = JSONObject.parseObject(jsonContent, List.class); |
| | | // 订单轨迹信息 |
| | | ServeCoordinate data = new ServeCoordinate(); |
| | |
| | | // |
| | | // } |
| | | |
| | | @ApiOperation(value = "上传经纬度", tags = {"师傅端-首页"}) |
| | | @ApiOperation(value = "上传经纬度", tags = {"师傅端-首页[2.0]"}) |
| | | @GetMapping(value = "/putLocation") |
| | | @ApiImplicitParams({ |
| | | @ApiImplicitParam(value = "workId", name = "workId", dataType = "int", required = true), |
| | |
| | | public R<Object> orderNavigation(@RequestParam Integer workId, @RequestParam String longitude, |
| | | @RequestParam String latitude) { |
| | | Result<String> address = GaoDeMapUtil.getCityCode(longitude, latitude); |
| | | System.err.println(address.getDatas()); |
| | | String cityCode = address.getDatas(); |
| | | System.err.println("城市code"+cityCode); |
| | | String provinceCode = cityCode.substring(0, 2) + "0000"; |
| | | System.err.println("省份code"+provinceCode); |
| | | Set<Integer> strings = new HashSet<>(); |
| | | strings.add(workId); |
| | | redisService.setCacheSet("workerLocation:"+address.getDatas()+":", strings); |
| | | redisService.setCacheSet("workerLocation:"+cityCode+":", strings); |
| | | redisService.setCacheSet("workerLocation:"+provinceCode+":", strings); |
| | | redisService.setCacheObject("work:"+workId+":", longitude+","+latitude); |
| | | masterWorkerService.lambdaUpdate() |
| | | .set(MasterWorker::getWorkerLon, longitude) |
| | | .set(MasterWorker::getWorkerLat, latitude) |
| | | .eq(MasterWorker::getId, workId) |
| | | .eq(MasterWorker::getIsDelete, 0).update(); |
| | | return R.ok(); |
| | | |
| | | } |