|  |  |  | 
|---|
|  |  |  | if(bike.getSiteId() ==null){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,请按要求前往停车点停车!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | lockBikes(bike.getDeviceSn(),Constants.ZERO);//发起关锁指令请求 | 
|---|
|  |  |  | lockBikes(bike.getDeviceSn(),Constants.ONE);//发起关锁指令请求 | 
|---|
|  |  |  | backIds.add(rides.getId()); | 
|---|
|  |  |  | rides.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey());//已还车 | 
|---|
|  |  |  | rides.setBackSiteId(bike.getSiteId());//还车站点 | 
|---|
|  |  |  | 
|---|
|  |  |  | goodsorder.setEditDate(date); | 
|---|
|  |  |  | goodsorder.setEditor(null); | 
|---|
|  |  |  | goodsorderService.dealCloseGoodsorderBiz( goodsorder,Constants.REFUND_TYPE.NORMAL.getKey(),memberRides); | 
|---|
|  |  |  | //更新电动车车辆状态 | 
|---|
|  |  |  | bikesMapper.update(null,new UpdateWrapper<Bikes>().lambda().set(Bikes::getStatus,Constants.ZERO).eq(Bikes::getType,Constants.ONE) | 
|---|
|  |  |  | .apply(" code in ( select m.bike_code from member_rides m where m.ordre_id = '"+goodsorder.getId()+"' ) ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private Bikes getElecBikeByCode(String bikeCode) { | 
|---|
|  |  |  | 
|---|
|  |  |  | APIResult<T0201_0500> data = result.block(); | 
|---|
|  |  |  | if(!data.isSuccess()){ | 
|---|
|  |  |  | //如果开锁失败,则返回异常 | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,"+(type ==0?"车辆关锁":"车辆开锁")+"失败,请稍后重试,或者联系园区管理人员!"); | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(), "对不起,"+(type ==0?"车辆开锁":"车辆关锁")+"失败,请稍后重试,或者联系园区管理人员!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 查询停车站点信息 | 
|---|
|  |  |  | 
|---|
|  |  |  | if(array == null || array.size() ==0){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(PositionUtil.isInPolygon(lat,lng,array)){ | 
|---|
|  |  |  | if(PositionUtil.isInPolygon(lng,lat,array)){ | 
|---|
|  |  |  | //如果在停车点范围内; | 
|---|
|  |  |  | site = sites; | 
|---|
|  |  |  | break; | 
|---|
|  |  |  | 
|---|
|  |  |  | Bikes bike = getElecBikeByCode(memberRides.getBikeCode()); | 
|---|
|  |  |  | //查询停车位置是否符合停车位置规范 | 
|---|
|  |  |  | checkPausePostionBiz(bike); | 
|---|
|  |  |  | lockBikes(bike.getDeviceSn(),Constants.ONE);//发起关锁指令请求 | 
|---|
|  |  |  | memberRides.setPauseDate(new Date()); | 
|---|
|  |  |  | memberRides.setEditDate(memberRides.getBackDate()); | 
|---|
|  |  |  | memberRides.setStatus(Constants.MEMBER_RIDES_STATUS.RIDES_PAUSING.getKey()); | 
|---|
|  |  |  | 
|---|
|  |  |  | ruleType =Integer.parseInt( systemDictDataBiz.queryByCode(Constants.MINI_PROGRAMME,Constants.PAUSE_BIKE_TYPE).getCode()); | 
|---|
|  |  |  | }catch (Exception e){ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(ruleType == 0){ | 
|---|
|  |  |  | if(ruleType == 1){ | 
|---|
|  |  |  | //如果仅限于园区临时停车 | 
|---|
|  |  |  | List<LocaltionDTO> array = new ArrayList<>(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | if(array == null || array.size() ==0){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,园区运营区域配置有误,请联系园区管理员处理!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if( !PositionUtil.isInPolygon(bike.getLatitude().doubleValue(),bike.getLongitude().doubleValue(),array)){ | 
|---|
|  |  |  | if( !PositionUtil.isInPolygon(bike.getLongitude().doubleValue(),bike.getLatitude().doubleValue(),array)){ | 
|---|
|  |  |  | //如果在停车点范围内; | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(), "对不起,请按要求在园区运营区域范围内停车!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | if(m.getLongitude()!=0){ | 
|---|
|  |  |  | bike.setLongitude(new BigDecimal(m.getLongitude()).divide(new BigDecimal(1000000),8,BigDecimal.ROUND_HALF_UP)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | updateMapLocation(bike); | 
|---|
|  |  |  | bike.setHeartDate(DateUtil.getDateFromLocalDateTime(m.getDeviceTime())); | 
|---|
|  |  |  | if(m.getAttributes()!=null ){ | 
|---|
|  |  |  | Battery battery= (Battery) m.getAttributes().get(AttributeKey.Battery); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void updateMapLocation(Bikes bike) { | 
|---|
|  |  |  | if(bike.getLatitude() == null || bike.getLongitude() == null){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | PositionUtil.AMap aMap =PositionUtil.transform(bike.getLongitude().doubleValue() ,bike.getLatitude().doubleValue()); | 
|---|
|  |  |  | bike.setLatitude(new BigDecimal(aMap.getLatitude())); | 
|---|
|  |  |  | bike.setLongitude(new BigDecimal(aMap.getLongitude())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public ConcurrentMap<String,Integer> cacheOpenLock = new ConcurrentReferenceHashMap<>(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | if(bike == null && StringUtils.isBlank(bike.getParamId())){ | 
|---|
|  |  |  | //如果车辆类型是空 | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), " 该车型暂时不能借车操作哦,请更换其他车型重试!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!Constants.equalsInteger(bike.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"对不起,该车辆已被锁定借用,请尝试更换其他车辆!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | cacheOpenLock.put(openElecBikeRequest.getCode(), 1); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | 
|---|
|  |  |  | //根据车型查询计价方案 | 
|---|
|  |  |  | isValidePricingType(bike,memberRides) ; | 
|---|
|  |  |  | MemberRidesDetailResponse memberRidesDetailResponse = new MemberRidesDetailResponse(); | 
|---|
|  |  |  | this.lockBikes(bike.getDeviceSn(),1); | 
|---|
|  |  |  | this.lockBikes(bike.getDeviceSn(),0); | 
|---|
|  |  |  | //存储骑行记录 | 
|---|
|  |  |  | memberRides.setId(Constants.getUUID()); | 
|---|
|  |  |  | memberRides.setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | 
|---|
|  |  |  | //如果车辆类型是空 | 
|---|
|  |  |  | throw  new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "车型信息异常,请联系管理员"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | this.lockBikes(bike.getDeviceSn(),1); | 
|---|
|  |  |  | this.lockBikes(bike.getDeviceSn(),0); | 
|---|
|  |  |  | //更新骑行状态为骑行中 | 
|---|
|  |  |  | memberRides.setEditDate(memberRides.getBackDate()); | 
|---|
|  |  |  | memberRides.setStatus(Constants.MEMBER_RIDES_STATUS.RIDES_RUNNING.getKey()); | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(Bikes::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(Bikes::getCode,rides.getBikeCode()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | lockBikes(bike.getDeviceSn(),Constants.ZERO);//发起关锁指令请求 | 
|---|
|  |  |  | lockBikes(bike.getDeviceSn(),Constants.ONE);//发起关锁指令请求 | 
|---|
|  |  |  | rides.setStatus(Constants.MEMBER_RIDES_STATUS.BACK_CYCLING.getKey());//已还车 | 
|---|
|  |  |  | rides.setBackSiteId(bike.getSiteId());//还车站点 | 
|---|
|  |  |  | rides.setBackDate(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  | goodsorder.setEditDate(date); | 
|---|
|  |  |  | goodsorder.setEditor(null); | 
|---|
|  |  |  | goodsorderService.dealCloseGoodsorderBiz( goodsorder,Constants.REFUND_TYPE.NORMAL.getKey(),memberRides); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //更新电动车车辆状态 | 
|---|
|  |  |  | bikesMapper.update(null,new UpdateWrapper<Bikes>().lambda().set(Bikes::getStatus,Constants.ZERO).eq(Bikes::getType,Constants.ONE) | 
|---|
|  |  |  | .apply(" code in ( select m.bike_code from member_rides m where m.ordre_id = '"+goodsorder.getId()+"' ) ") | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //发送小程序通知 | 
|---|
|  |  |  | Member member = memberMapper.selectById(goodsorder.getMemberId()); | 
|---|
|  |  |  | if(Objects.nonNull(member)&&StringUtils.isNotBlank(member.getOpenid())){ | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    public void test(double lat,double lng){ | 
|---|
|  |  |  | //        this.getBackSiteByPostion(lat,lng); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|