订单详情调整(未完成)
This commit is contained in:
		
							parent
							
								
									e10fb12fdd
								
							
						
					
					
						commit
						88662935de
					
				|  | @ -363,4 +363,13 @@ public class GeoUtils { | |||
|         return false; | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|      * 计算给定点到多边形的最短距离 | ||||
|      * */ | ||||
|     public double calculateMinDistanceToPolygon(Geometry polygon, double lon, double lat) { | ||||
|         Coordinate coord = new Coordinate(lon, lat); | ||||
|         Point point = new GeometryFactory().createPoint(coord); | ||||
|         return polygon.distance(point); // 返回给定点到多边形的最短距离 | ||||
|     } | ||||
| 
 | ||||
| } | ||||
|  |  | |||
|  | @ -366,4 +366,13 @@ public class EtOrder extends BaseEntity | |||
| 
 | ||||
|     /** 支付渠道 */ | ||||
|     public Long payChannel; | ||||
| 
 | ||||
|     /** 还车定位方式:1-设备定位;2-手机定位 */ | ||||
|     private String returnMode; | ||||
| 
 | ||||
|     /** 还车经度 */ | ||||
|     private String returnLon; | ||||
| 
 | ||||
|     /** 还车纬度 */ | ||||
|     private String returnLat; | ||||
| } | ||||
|  |  | |||
|  | @ -1,16 +1,15 @@ | |||
| package com.ruoyi.system.mapper; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDate; | ||||
| import java.util.List; | ||||
| import com.ruoyi.system.domain.EtOrder; | ||||
| import com.ruoyi.system.domain.EtOrderQuery; | ||||
| import com.ruoyi.system.domain.IncomeQuery; | ||||
| import com.ruoyi.system.domain.vo.IncomeVo; | ||||
| import com.ruoyi.system.domain.vo.IndexVo; | ||||
| import com.ruoyi.system.domain.vo.RechargeVo; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
| 
 | ||||
| import java.math.BigDecimal; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * 订单Mapper接口 | ||||
|  * | ||||
|  | @ -141,6 +140,14 @@ public interface EtOrderMapper | |||
|      */ | ||||
|     public int isInOrderBySn(@Param("sn") String sn); | ||||
| 
 | ||||
|     /** | ||||
|      * 查询当前车辆是否有正在进行中的订单 | ||||
|      * | ||||
|      * @param sn 用户id | ||||
|      * @return 结果 | ||||
|      */ | ||||
|     public EtOrder getInOrderBySn(@Param("sn") String sn); | ||||
| 
 | ||||
|     /** | ||||
|      * 检验预约订单只能有一个 | ||||
|      * | ||||
|  |  | |||
|  | @ -2412,17 +2412,16 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
| //    } | ||||
| 
 | ||||
|     private Boolean isParkingZoneByLocation(String longitude, String latitude,Long areaId) { | ||||
|         Boolean inCircle = false; | ||||
|         boolean inCircle = false; | ||||
|         EtParkingArea parkingArea = new EtParkingArea(); | ||||
|         parkingArea.setAreaId(areaId); | ||||
|         parkingArea.setStatus("0"); | ||||
|         parkingArea.setType(ServiceConstants.PARKING_AREA_TYPE_PARKFING); | ||||
|         List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea); | ||||
|         EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(areaId); | ||||
|         if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){ | ||||
|         if(ObjectUtil.isNull(parkingAreas) || parkingAreas.isEmpty()){ | ||||
|             log.info("运营区【{}】没有停车区,",areaId); | ||||
|             return true; | ||||
| //            throw new ServiceException("运营区【{}】没有停车区"+areaId.toString()); | ||||
|         } | ||||
|         double tolerance = area.getError(); // 误差距离 | ||||
|         for (EtParkingArea etParkingArea : parkingAreas) { | ||||
|  | @ -2433,8 +2432,6 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|             inCircle = GeoUtils.isInPolygonWithTolerance(longitude, latitude, geometry, tolerance); | ||||
|             if(inCircle){ | ||||
|                 log.info("位置【{},{}】在停车区【{}】内",longitude,latitude,etParkingArea.getParkingName()); | ||||
|                 inCircle = true; | ||||
|                 break; | ||||
|             }else{ | ||||
|                 log.info("位置【{},{}】不在停车区【{}】内",longitude,latitude,etParkingArea.getParkingName()); | ||||
|             } | ||||
|  | @ -2697,22 +2694,60 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|             if(ObjectUtil.isNotNull(latestLocation)){ | ||||
|                 BigDecimal longitude1 = BigDecimal.valueOf(latestLocation[1]).setScale(8, RoundingMode.HALF_UP); | ||||
|                 BigDecimal latitude1 = BigDecimal.valueOf(latestLocation[0]).setScale(8, RoundingMode.HALF_UP); | ||||
|                 log.info("【判断是否在停车区】,lon:{},lat:{}",longitude1,latitude1); | ||||
|                 log.info("【判断是否在停车区--设备的定位】,lon:{},lat:{}",longitude1,latitude1); | ||||
| 
 | ||||
|                 Boolean parkingZoneByLocation = isParkingZoneByLocation(longitude1.toString(), latitude1.toString(), Long.parseLong(areaId)); | ||||
|                 if(parkingZoneByLocation){ | ||||
|                     isInParkingAreaVo.setIsInParkingArea(true); | ||||
|                     isInParkingAreaVo.setParkingReturn("1".equals(area.getParkingReturn())); | ||||
|                     return isInParkingAreaVo; | ||||
|                     return getParkingAreaVo(isInParkingAreaVo, true, area,sn,"1",longitude1.toString(),latitude1.toString()); | ||||
|                 } | ||||
|                 // 如果longitude1和latitude1定位距离最近的停车点的距离小于50米,则可以用手机定位判断是否在停车区,如果大于50米,则直接返回不在停车区 | ||||
|                 double minDistanceToParkingArea = findMinDistanceToParkingAreas(Double.parseDouble(longitude1.toString()), Double.parseDouble(latitude1.toString()), Long.parseLong(areaId)); | ||||
|                 log.info("【判断是否在停车区(不在停车点内)--距离停车点最小距离】,minDistanceToParkingArea:{}",minDistanceToParkingArea); | ||||
|                 if (minDistanceToParkingArea > 50) { // 如果距离大于50米,直接返回不在停车区 | ||||
|                     log.info("【判断是否在停车区--大于50米,不在停车点内】,不在停车区"); | ||||
|                     return getParkingAreaVo(isInParkingAreaVo, false, area,sn,"1",longitude1.toString(),latitude1.toString()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|         Boolean parkingZoneByLocation = isParkingZoneByLocation(longitude, latitude, Long.parseLong(areaId)); | ||||
|         isInParkingAreaVo.setIsInParkingArea(parkingZoneByLocation); | ||||
|         //停车点还车:0-关闭;1-开启 | ||||
|         return getParkingAreaVo(isInParkingAreaVo, parkingZoneByLocation, area,sn,"2",longitude,latitude); | ||||
|     } | ||||
| 
 | ||||
|     private @NotNull IsInParkingAreaVo getParkingAreaVo(IsInParkingAreaVo isInParkingAreaVo, boolean isInParkingArea, EtOperatingArea area, String sn, | ||||
|     String returnMode, String longitude, String latitude) { | ||||
|         isInParkingAreaVo.setIsInParkingArea(isInParkingArea); | ||||
|         isInParkingAreaVo.setParkingReturn("1".equals(area.getParkingReturn())); | ||||
|         EtOrder inOrderBySn = etOrderMapper.getInOrderBySn(sn); | ||||
|         if(ObjectUtil.isNotNull(inOrderBySn)){ | ||||
|             EtOrder etOrder = new EtOrder(); | ||||
|             etOrder.setOrderNo(inOrderBySn.getOrderNo()); | ||||
|             etOrder.setReturnMode(returnMode); | ||||
|             etOrder.setReturnLon(longitude); | ||||
|             etOrder.setReturnLat(latitude); | ||||
|             etOrderMapper.updateEtOrderByOrderNo(etOrder); | ||||
|         } | ||||
|         return isInParkingAreaVo; | ||||
|     } | ||||
| 
 | ||||
|     private double findMinDistanceToParkingAreas(double longitude, double latitude, long areaId) { | ||||
|         EtParkingArea parkingArea = new EtParkingArea(); | ||||
|         parkingArea.setAreaId(areaId); | ||||
|         parkingArea.setStatus("0"); | ||||
|         parkingArea.setType(ServiceConstants.PARKING_AREA_TYPE_PARKFING); | ||||
|         List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea); | ||||
|         double minDistance = Double.MAX_VALUE; | ||||
| 
 | ||||
|         for (EtParkingArea etParkingArea : parkingAreas) { | ||||
|             Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary()); | ||||
|             double distance = GeoUtils.calculateMinDistanceToPolygon(geometry, longitude, latitude); | ||||
|             if (distance < minDistance) { | ||||
|                 minDistance = distance; | ||||
|             } | ||||
|         } | ||||
|         return minDistance; | ||||
|     } | ||||
| 
 | ||||
| 
 | ||||
|     /** | ||||
|      * 查询版本并更新 | ||||
|      */ | ||||
|  |  | |||
|  | @ -2249,8 +2249,7 @@ public class EtOrderServiceImpl implements IEtOrderService | |||
|      */ | ||||
|     @Override | ||||
|     public List<EtOrder> isInAuditOrder(Long userId,String orderNo) { | ||||
|         List<EtOrder> inOrder = etOrderMapper.isInAuditOrder(userId, orderNo); | ||||
|         return inOrder; | ||||
|         return etOrderMapper.isInAuditOrder(userId, orderNo); | ||||
|     } | ||||
|     /** | ||||
|      * 查询当前车辆是否有正在进行中的订单 | ||||
|  |  | |||
|  | @ -141,6 +141,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|         o.platform_service_fee, | ||||
|         o.operator_dividend, | ||||
|         o.pay_channel, | ||||
|         o.capped_amount, | ||||
|         o.rental_unit, | ||||
|         o.cost | ||||
|         FROM | ||||
|         et_order o | ||||
|  | @ -514,6 +516,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|             where sn = #{sn} and status =2  and type = 1 | ||||
|     </select> | ||||
| 
 | ||||
|     <select id="getInOrderBySn" resultMap="EtOrderResult" parameterType="String"> | ||||
|         <include refid="selectEtOrderVoNoRoute"/> | ||||
|             where sn = #{sn} and status =2  and type = 1 | ||||
|     </select> | ||||
| 
 | ||||
|     <select id="checkIsUnique" resultType="Integer" parameterType="Long"> | ||||
|         select count(1) from et_order | ||||
|         where user_id = #{userId} and status = 0 and type=1 | ||||
|  | @ -1194,6 +1201,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|             <if test="operatorDividend != null">operator_dividend = #{operatorDividend},</if> | ||||
|             <if test="payChannel != null">pay_channel = #{payChannel},</if> | ||||
|             <if test="cost != null">cost = #{cost},</if> | ||||
|             <if test="returnMode != null">return_mode = #{returnMode},</if> | ||||
|             <if test="returnLon != null">return_lon = #{returnLon},</if> | ||||
|             <if test="returnLat != null">return_lat = #{returnLat},</if> | ||||
|         </trim> | ||||
|         where order_id = #{orderId} | ||||
|     </update> | ||||
|  | @ -1254,6 +1264,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|             <if test="operatorDividend != null">operator_dividend = #{operatorDividend},</if> | ||||
|             <if test="payChannel != null">pay_channel = #{payChannel},</if> | ||||
|             <if test="cost != null">cost = #{cost},</if> | ||||
|             <if test="returnMode != null">return_mode = #{returnMode},</if> | ||||
|             <if test="returnLon != null">return_lon = #{returnLon},</if> | ||||
|             <if test="returnLat != null">return_lat = #{returnLat},</if> | ||||
|         </trim> | ||||
|         where order_no = #{orderNo} | ||||
|     </update> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user