111
This commit is contained in:
		
							parent
							
								
									2e69d54674
								
							
						
					
					
						commit
						fd28903b06
					
				|  | @ -171,8 +171,8 @@ public class ReceiveController { | |||
| 
 | ||||
|                         // 坐标转换  WGS84 转 GCJ02 | ||||
|                         double[] doubles = coordinateConvert(value); | ||||
|                         BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP); | ||||
|                         BigDecimal lon = BigDecimal.valueOf(doubles[1]).setScale(8, RoundingMode.HALF_UP); | ||||
|                         BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP); | ||||
|                         log.info("转换后的GCJ02经纬度:{}---{}", lon, lat); | ||||
| 
 | ||||
|                         EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId()); | ||||
|  | @ -181,7 +181,7 @@ public class ReceiveController { | |||
|                         if(ObjectUtil.isNotNull(area) && !oneMinuteDifference){ | ||||
|                             /** 2. 判断是否在禁行区内  如果在, 根据配置‘禁行区内断电配置’进行断电 **/ | ||||
|                             String isAdminUnlocking = asDevice.getIsAdminUnlocking();// 是否是管理员开锁:0-否;1-是 | ||||
|                             boolean noRidingArea = isNoRidingArea(value, asDevice, area, isAdminUnlocking); | ||||
|                             boolean noRidingArea = isNoRidingArea(lon, lat, value.getStatus(), asDevice, area, isAdminUnlocking); | ||||
|                             /** 3.超出运营区外断电 包含靠近运营区播报 */ | ||||
|                             outAreaOutage(value, asDevice, lon, lat, area, isAdminUnlocking, noRidingArea); | ||||
|                             /** 4.锁同步关锁 */ | ||||
|  | @ -406,11 +406,11 @@ public class ReceiveController { | |||
|     } | ||||
| 
 | ||||
|     /* 禁行区内断电*/ | ||||
|     private boolean isNoRidingArea(LogEntry.LocationValue value, AsDevice device, EtOperatingArea area, String isAdminUnlocking) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { | ||||
|         boolean noRidingArea = asDeviceService.isNoRidingArea(device.getSn(), device.getAreaId()); | ||||
|     private boolean isNoRidingArea(BigDecimal lon,BigDecimal lat, Integer status, AsDevice device, EtOperatingArea area, String isAdminUnlocking) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { | ||||
|         boolean noRidingArea = asDeviceService.isNoRidingArea(device.getSn(), lon.toString(), lat.toString(), device.getAreaId()); | ||||
|         if(noRidingArea){ | ||||
|             String noRidingOutage = area.getNoRidingOutage(); | ||||
|             if (noRidingOutage.equals("1") && value.getStatus() != 3 && !isAdminUnlocking.equals("1")) { // 禁行区内断电 | ||||
|             if (noRidingOutage.equals("1") && status != 3 && !isAdminUnlocking.equals("1")) { // 禁行区内断电 | ||||
|                 log.info("禁行区内断电命令--SN:" + device.getSn()); | ||||
|                 sendCommandWithCooldown(device, IotConstants.COMMAND_QLOSE + IotConstants.COMMAND_FREQUENCY_5, "禁行区内断电"); | ||||
|                 device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); | ||||
|  |  | |||
|  | @ -38,6 +38,6 @@ public class LogEntry { | |||
| 
 | ||||
|         private Integer s;//卫星数量 | ||||
| 
 | ||||
|         private Integer q;//质量 | ||||
|         private Integer q;//电门 0-关;1-开 | ||||
|     } | ||||
| } | ||||
|  |  | |||
|  | @ -1,5 +1,7 @@ | |||
| package com.ruoyi.common.utils.uuid; | ||||
| 
 | ||||
| import com.ruoyi.common.utils.SnowFlakeUtil; | ||||
| 
 | ||||
| /** | ||||
|  * ID生成器工具类 | ||||
|  * | ||||
|  | @ -85,7 +87,7 @@ public class IdUtils | |||
|      * @return 生成的随机码 | ||||
|      */ | ||||
|     public static String getOrderNo(String payType){ | ||||
|         return payType + System.currentTimeMillis(); | ||||
|         return payType + SnowFlakeUtil.newId(); | ||||
|     } | ||||
| 
 | ||||
|     /** | ||||
|  |  | |||
|  | @ -336,7 +336,7 @@ public interface IAsDeviceService extends IService<AsDevice> | |||
|     /** | ||||
|      * 判断是否在禁行区内 | ||||
|      */ | ||||
|     public boolean isNoRidingArea(String sn,Long areaId); | ||||
|     public boolean isNoRidingArea(String sn, String lon,String lat,Long areaId); | ||||
| 
 | ||||
|     /** | ||||
|      * 判断是否在禁行区内 | ||||
|  |  | |||
|  | @ -177,11 +177,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|                 BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP); | ||||
|                 device.setLongitude(lon.toString()); | ||||
|                 device.setLatitude(lat.toString()); | ||||
|                 device.setLastLocationTime(new Date(logEntry.getAt())); | ||||
|             }else{ | ||||
|                 device.setLongitude(null); | ||||
|                 device.setLatitude(null); | ||||
|             } | ||||
|             device.setLastLocationTime(new Date(logEntry.getAt())); | ||||
|         } | ||||
|         if(ObjectUtil.isNotNull(areaId) && areaId!=0){ | ||||
|             SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId); | ||||
|  | @ -2506,29 +2506,24 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i | |||
|      * 是否禁行区内 | ||||
|      */ | ||||
|     @Override | ||||
|     public boolean isNoRidingArea(String sn,Long areaId) { | ||||
|         Boolean isNoRiding = false; | ||||
|     public boolean isNoRidingArea(String sn, String lon, String lat, Long areaId) { | ||||
|         boolean isNoRiding = false; | ||||
|         EtParkingArea parkingArea = new EtParkingArea(); | ||||
|         parkingArea.setAreaId(areaId); | ||||
|         parkingArea.setStatus("0"); | ||||
|         List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea); | ||||
|         if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){ | ||||
|         if(ObjectUtil.isNull(parkingAreas) || parkingAreas.isEmpty()){ | ||||
|             log.info("运营区【{}】没有禁行区,",areaId); | ||||
| //            throw new ServiceException("运营区【{}】没有禁行区"+areaId.toString()); | ||||
|         } | ||||
|         for (EtParkingArea etParkingArea : parkingAreas) { | ||||
|             if(etParkingArea.getType().equals(ServiceConstants.PARKING_AREA_TYPE_BANNED_RIDING)){ | ||||
|                 AsDevice device = asDeviceMapper.selectAsDeviceBySn(sn); | ||||
|                 String latitude = device.getLatitude(); | ||||
|                 String longitude = device.getLongitude(); | ||||
|                 Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary()); | ||||
|                 isNoRiding = GeoUtils.isInCircle(longitude, latitude, geometry); | ||||
|                 isNoRiding = GeoUtils.isInCircle(lon, lat, geometry); | ||||
|                 if(isNoRiding){ | ||||
| //                    log.info("车辆【{}】在禁行区【{}】内",sn,etParkingArea.getParkingName()); | ||||
|                     isNoRiding = true; | ||||
|                     break; | ||||
|                     log.info("车辆【{}】,经纬度【{},{}】在禁行区【{}】内",sn,lon,lat,etParkingArea.getParkingName()); | ||||
|                     return true; | ||||
|                 }else{ | ||||
| //                    log.info("车辆【{}】不在禁行区【{}】内",sn,etParkingArea.getParkingName()); | ||||
|                     log.info("车辆【{}】,经纬度【{},{}】不在禁行区【{}】内",sn,lon,lat,etParkingArea.getParkingName()); | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  |  | |||
|  | @ -598,8 +598,7 @@ public class EtTask { | |||
|             LogEntry.LocationValue value = logEntry.getValue(); | ||||
|             AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName()); | ||||
|             if(ObjectUtil.isNotNull(device) && !isRepeatMsg(msg,logEntry.getDevName())){ | ||||
| //                log.info("device: sn={},【{}】",device.getSn() , JSON.toJSONString(device)); | ||||
|                 if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus()) && device.getStatus().equals(ServiceConstants.VEHICLE_STATUS_IN_USING)){ | ||||
|                 if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus())){ | ||||
|                     updateLocationHandle(msg, logEntry, value, device); | ||||
|                 } | ||||
|             } | ||||
|  | @ -653,11 +652,13 @@ public class EtTask { | |||
| 
 | ||||
|         asynchronousSaveLog(msg, logEntry.getAt(), logEntry.getDevName(), lon, lat, device); | ||||
| 
 | ||||
|         AsDevice updateDevice = new AsDevice(); | ||||
|         updateDevice.setDeviceId(device.getDeviceId()); | ||||
|         BigDecimal voltage = new BigDecimal(value.getBat()); | ||||
|         if(voltage.compareTo(new BigDecimal(100)) > 0){ | ||||
|             voltage = voltage.divide(new BigDecimal(10)); | ||||
|         } | ||||
|         device.setVoltage(voltage.toString());//电压 | ||||
|         updateDevice.setVoltage(voltage.toString());//电压 | ||||
|         if(ObjectUtil.isNotNull(device.getModelId())){ | ||||
|             EtModel model = etModelService.selectEtModelByModelId(device.getModelId()); | ||||
|             if(ObjectUtil.isNotNull(model)){ | ||||
|  | @ -666,25 +667,25 @@ public class EtTask { | |||
|                     remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); | ||||
|                 } | ||||
|                 Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 | ||||
|                 device.setRemainingMileage(remainingMileage); | ||||
|                 device.setRemainingPower(electricQuantity.toString()); | ||||
|                 updateDevice.setRemainingMileage(remainingMileage); | ||||
|                 updateDevice.setRemainingPower(electricQuantity.toString()); | ||||
|             } | ||||
|         } | ||||
|         device.setLastTime(DateUtils.getNowDate()); | ||||
|         device.setSignalStrength(value.getCsq()); | ||||
|         device.setQuality(value.getQ()); | ||||
|         updateDevice.setLastTime(DateUtils.getNowDate()); | ||||
|         updateDevice.setSignalStrength(value.getCsq()); | ||||
|         updateDevice.setQuality(value.getQ()); | ||||
|         if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){ | ||||
|             device.setLatitude(lat.toString()); | ||||
|             device.setLongitude(lon.toString()); | ||||
|             device.setLastLocationTime(new Date(logEntry.getAt())); | ||||
|             device.setGps("1"); | ||||
|             updateDevice.setLatitude(lat.toString()); | ||||
|             updateDevice.setLongitude(lon.toString()); | ||||
|             updateDevice.setLastLocationTime(new Date(logEntry.getAt())); | ||||
|             updateDevice.setGps("1"); | ||||
|             // 信号强度 | ||||
|             device.setSatellites(value.getS()); | ||||
|             updateDevice.setSatellites(value.getS()); | ||||
|         }else{ | ||||
|             device.setGps("0"); | ||||
|             device.setSatellites(0); | ||||
|             updateDevice.setGps("0"); | ||||
|             updateDevice.setSatellites(0); | ||||
|         } | ||||
|         int i = deviceService.updateLocation(device); | ||||
|         int i = deviceService.updateLocation(updateDevice); | ||||
|         if(i>0){ | ||||
|             log.info("===============更新设备信息成功===========>{}", logEntry.getDevName()); | ||||
|         } | ||||
|  |  | |||
|  | @ -73,6 +73,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|                  left join et_area_rule ar on ar.rule_id = r.rule_id | ||||
|                  left join et_operating_area a  on a.area_id = ar.area_id | ||||
|         where r.is_deleted  = 0 and a.area_id = #{areaId} | ||||
|         order by r.order_num | ||||
|     </select> | ||||
| 
 | ||||
|     <select id="selectRuleListByModelId" parameterType="Long" resultType="Long"> | ||||
|  | @ -93,6 +94,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|                  left join et_area_rule ar on ar.rule_id = r.rule_id | ||||
|                  left join et_operating_area a  on a.area_id = ar.area_id | ||||
|         where r.is_deleted  = 0 and a.area_id = #{areaId} | ||||
|         order by r.order_num | ||||
|     </select> | ||||
| 
 | ||||
|     <select id="selectRuleNameListByAreaId" parameterType="Long" resultType="java.lang.String"> | ||||
|  | @ -101,6 +103,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|                  left join et_area_rule ar on ar.rule_id = r.rule_id | ||||
|                  left join et_operating_area a  on a.area_id = ar.area_id | ||||
|         where r.is_deleted  = 0 and a.area_id = #{areaId} | ||||
|         order by r.order_num | ||||
|     </select> | ||||
| 
 | ||||
|     <select id="selectRuleInfoListByModelId" resultType="com.ruoyi.system.domain.EtFeeRule"> | ||||
|  | @ -112,6 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | |||
|                  left join et_model_rule mr on mr.rule_id = r.rule_id | ||||
|                  left join et_model m  on m.model_id = mr.model_id | ||||
|         where r.is_deleted  = 0 and m.model_id = #{modelId} | ||||
|         order by r.order_num | ||||
|     </select> | ||||
| 
 | ||||
|     <insert id="insertEtFeeRule" parameterType="EtFeeRule" useGeneratedKeys="true" keyProperty="ruleId"> | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user