This commit is contained in:
邱贞招 2025-01-21 23:51:50 +08:00
parent 2e69d54674
commit fd28903b06
7 changed files with 39 additions and 37 deletions
electripper-admin/src/main/java/com/ruoyi/web/controller/iot/receive
electripper-common/src/main/java/com/ruoyi/common/utils
electripper-system/src/main
java/com/ruoyi/system
resources/mapper/system

View File

@ -171,8 +171,8 @@ public class ReceiveController {
// 坐标转换 WGS84 GCJ02 // 坐标转换 WGS84 GCJ02
double[] doubles = coordinateConvert(value); 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 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); log.info("转换后的GCJ02经纬度{}---{}", lon, lat);
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId()); EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(asDevice.getAreaId());
@ -181,7 +181,7 @@ public class ReceiveController {
if(ObjectUtil.isNotNull(area) && !oneMinuteDifference){ if(ObjectUtil.isNotNull(area) && !oneMinuteDifference){
/** 2. 判断是否在禁行区内 如果在, 根据配置‘禁行区内断电配置’进行断电 **/ /** 2. 判断是否在禁行区内 如果在, 根据配置‘禁行区内断电配置’进行断电 **/
String isAdminUnlocking = asDevice.getIsAdminUnlocking();// 是否是管理员开锁0-1- String isAdminUnlocking = asDevice.getIsAdminUnlocking();// 是否是管理员开锁0-1-
boolean noRidingArea = isNoRidingArea(value, asDevice, area, isAdminUnlocking); boolean noRidingArea = isNoRidingArea(lon, lat, value.getStatus(), asDevice, area, isAdminUnlocking);
/** 3.超出运营区外断电 包含靠近运营区播报 */ /** 3.超出运营区外断电 包含靠近运营区播报 */
outAreaOutage(value, asDevice, lon, lat, area, isAdminUnlocking, noRidingArea); outAreaOutage(value, asDevice, lon, lat, area, isAdminUnlocking, noRidingArea);
/** 4.锁同步关锁 */ /** 4.锁同步关锁 */
@ -406,11 +406,11 @@ public class ReceiveController {
} }
/* 禁行区内断电*/ /* 禁行区内断电*/
private boolean isNoRidingArea(LogEntry.LocationValue value, AsDevice device, EtOperatingArea area, String isAdminUnlocking) throws UnsupportedEncodingException, NoSuchAlgorithmException, InvalidKeyException { 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(), device.getAreaId()); boolean noRidingArea = asDeviceService.isNoRidingArea(device.getSn(), lon.toString(), lat.toString(), device.getAreaId());
if(noRidingArea){ if(noRidingArea){
String noRidingOutage = area.getNoRidingOutage(); 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()); log.info("禁行区内断电命令--SN" + device.getSn());
sendCommandWithCooldown(device, IotConstants.COMMAND_QLOSE + IotConstants.COMMAND_FREQUENCY_5, "禁行区内断电"); sendCommandWithCooldown(device, IotConstants.COMMAND_QLOSE + IotConstants.COMMAND_FREQUENCY_5, "禁行区内断电");
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);

View File

@ -38,6 +38,6 @@ public class LogEntry {
private Integer s;//卫星数量 private Integer s;//卫星数量
private Integer q;//质量 private Integer q;//电门 0-1-
} }
} }

View File

@ -1,5 +1,7 @@
package com.ruoyi.common.utils.uuid; package com.ruoyi.common.utils.uuid;
import com.ruoyi.common.utils.SnowFlakeUtil;
/** /**
* ID生成器工具类 * ID生成器工具类
* *
@ -85,7 +87,7 @@ public class IdUtils
* @return 生成的随机码 * @return 生成的随机码
*/ */
public static String getOrderNo(String payType){ public static String getOrderNo(String payType){
return payType + System.currentTimeMillis(); return payType + SnowFlakeUtil.newId();
} }
/** /**

View File

@ -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);
/** /**
* 判断是否在禁行区内 * 判断是否在禁行区内

View File

@ -177,11 +177,11 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP); BigDecimal lat = BigDecimal.valueOf(doubles[0]).setScale(8, RoundingMode.HALF_UP);
device.setLongitude(lon.toString()); device.setLongitude(lon.toString());
device.setLatitude(lat.toString()); device.setLatitude(lat.toString());
device.setLastLocationTime(new Date(logEntry.getAt()));
}else{ }else{
device.setLongitude(null); device.setLongitude(null);
device.setLatitude(null); device.setLatitude(null);
} }
device.setLastLocationTime(new Date(logEntry.getAt()));
} }
if(ObjectUtil.isNotNull(areaId) && areaId!=0){ if(ObjectUtil.isNotNull(areaId) && areaId!=0){
SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId); SysDept sysDept = wxPayService.getDeptObjByAreaId(areaId);
@ -2506,29 +2506,24 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
* 是否禁行区内 * 是否禁行区内
*/ */
@Override @Override
public boolean isNoRidingArea(String sn,Long areaId) { public boolean isNoRidingArea(String sn, String lon, String lat, Long areaId) {
Boolean isNoRiding = false; boolean isNoRiding = false;
EtParkingArea parkingArea = new EtParkingArea(); EtParkingArea parkingArea = new EtParkingArea();
parkingArea.setAreaId(areaId); parkingArea.setAreaId(areaId);
parkingArea.setStatus("0"); parkingArea.setStatus("0");
List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea); List<EtParkingArea> parkingAreas = parkingAreaService.selectEtParkingAreaList(parkingArea);
if(ObjectUtil.isNull(parkingAreas) || parkingAreas.size() == 0){ if(ObjectUtil.isNull(parkingAreas) || parkingAreas.isEmpty()){
log.info("运营区【{}】没有禁行区,",areaId); log.info("运营区【{}】没有禁行区,",areaId);
// throw new ServiceException("运营区【{}】没有禁行区"+areaId.toString());
} }
for (EtParkingArea etParkingArea : parkingAreas) { for (EtParkingArea etParkingArea : parkingAreas) {
if(etParkingArea.getType().equals(ServiceConstants.PARKING_AREA_TYPE_BANNED_RIDING)){ 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()); Geometry geometry = GeoUtils.fromWkt(etParkingArea.getBoundary());
isNoRiding = GeoUtils.isInCircle(longitude, latitude, geometry); isNoRiding = GeoUtils.isInCircle(lon, lat, geometry);
if(isNoRiding){ if(isNoRiding){
// log.info("车辆【{}】在禁行区【{}】内",sn,etParkingArea.getParkingName()); log.info("车辆【{}】,经纬度【{}{}】在禁行区【{}】内",sn,lon,lat,etParkingArea.getParkingName());
isNoRiding = true; return true;
break;
}else{ }else{
// log.info("车辆【{}】不在禁行区【{}】内",sn,etParkingArea.getParkingName()); log.info("车辆【{}】,经纬度【{}{}】不在禁行区【{}】内",sn,lon,lat,etParkingArea.getParkingName());
} }
} }
} }

View File

@ -598,8 +598,7 @@ public class EtTask {
LogEntry.LocationValue value = logEntry.getValue(); LogEntry.LocationValue value = logEntry.getValue();
AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName()); AsDevice device = asDeviceMapper.selectAsDeviceByMac(logEntry.getDevName());
if(ObjectUtil.isNotNull(device) && !isRepeatMsg(msg,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())){
if(ServiceConstants.LOCK_STATUS_OPEN.equals(device.getLockStatus()) && device.getStatus().equals(ServiceConstants.VEHICLE_STATUS_IN_USING)){
updateLocationHandle(msg, logEntry, value, device); updateLocationHandle(msg, logEntry, value, device);
} }
} }
@ -653,11 +652,13 @@ public class EtTask {
asynchronousSaveLog(msg, logEntry.getAt(), logEntry.getDevName(), lon, lat, device); asynchronousSaveLog(msg, logEntry.getAt(), logEntry.getDevName(), lon, lat, device);
AsDevice updateDevice = new AsDevice();
updateDevice.setDeviceId(device.getDeviceId());
BigDecimal voltage = new BigDecimal(value.getBat()); BigDecimal voltage = new BigDecimal(value.getBat());
if(voltage.compareTo(new BigDecimal(100)) > 0){ if(voltage.compareTo(new BigDecimal(100)) > 0){
voltage = voltage.divide(new BigDecimal(10)); voltage = voltage.divide(new BigDecimal(10));
} }
device.setVoltage(voltage.toString());//电压 updateDevice.setVoltage(voltage.toString());//电压
if(ObjectUtil.isNotNull(device.getModelId())){ if(ObjectUtil.isNotNull(device.getModelId())){
EtModel model = etModelService.selectEtModelByModelId(device.getModelId()); EtModel model = etModelService.selectEtModelByModelId(device.getModelId());
if(ObjectUtil.isNotNull(model)){ if(ObjectUtil.isNotNull(model)){
@ -666,25 +667,25 @@ public class EtTask {
remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance()); remainingMileage = CommonUtil.getRemainingMileage(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage(), model.getFullEndurance());
} }
Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百 Integer electricQuantity = CommonUtil.getElectricQuantity(device.getVoltage(), model.getFullVoltage(), model.getLowVoltage());//电量百分百
device.setRemainingMileage(remainingMileage); updateDevice.setRemainingMileage(remainingMileage);
device.setRemainingPower(electricQuantity.toString()); updateDevice.setRemainingPower(electricQuantity.toString());
} }
} }
device.setLastTime(DateUtils.getNowDate()); updateDevice.setLastTime(DateUtils.getNowDate());
device.setSignalStrength(value.getCsq()); updateDevice.setSignalStrength(value.getCsq());
device.setQuality(value.getQ()); updateDevice.setQuality(value.getQ());
if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){ if(BigDecimal.ZERO.compareTo(lon) != 0 && BigDecimal.ZERO.compareTo(lat) != 0){
device.setLatitude(lat.toString()); updateDevice.setLatitude(lat.toString());
device.setLongitude(lon.toString()); updateDevice.setLongitude(lon.toString());
device.setLastLocationTime(new Date(logEntry.getAt())); updateDevice.setLastLocationTime(new Date(logEntry.getAt()));
device.setGps("1"); updateDevice.setGps("1");
// 信号强度 // 信号强度
device.setSatellites(value.getS()); updateDevice.setSatellites(value.getS());
}else{ }else{
device.setGps("0"); updateDevice.setGps("0");
device.setSatellites(0); updateDevice.setSatellites(0);
} }
int i = deviceService.updateLocation(device); int i = deviceService.updateLocation(updateDevice);
if(i>0){ if(i>0){
log.info("===============更新设备信息成功===========>{}", logEntry.getDevName()); log.info("===============更新设备信息成功===========>{}", logEntry.getDevName());
} }

View File

@ -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_area_rule ar on ar.rule_id = r.rule_id
left join et_operating_area a on a.area_id = ar.area_id left join et_operating_area a on a.area_id = ar.area_id
where r.is_deleted = 0 and a.area_id = #{areaId} where r.is_deleted = 0 and a.area_id = #{areaId}
order by r.order_num
</select> </select>
<select id="selectRuleListByModelId" parameterType="Long" resultType="Long"> <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_area_rule ar on ar.rule_id = r.rule_id
left join et_operating_area a on a.area_id = ar.area_id left join et_operating_area a on a.area_id = ar.area_id
where r.is_deleted = 0 and a.area_id = #{areaId} where r.is_deleted = 0 and a.area_id = #{areaId}
order by r.order_num
</select> </select>
<select id="selectRuleNameListByAreaId" parameterType="Long" resultType="java.lang.String"> <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_area_rule ar on ar.rule_id = r.rule_id
left join et_operating_area a on a.area_id = ar.area_id left join et_operating_area a on a.area_id = ar.area_id
where r.is_deleted = 0 and a.area_id = #{areaId} where r.is_deleted = 0 and a.area_id = #{areaId}
order by r.order_num
</select> </select>
<select id="selectRuleInfoListByModelId" resultType="com.ruoyi.system.domain.EtFeeRule"> <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_rule mr on mr.rule_id = r.rule_id
left join et_model m on m.model_id = mr.model_id left join et_model m on m.model_id = mr.model_id
where r.is_deleted = 0 and m.model_id = #{modelId} where r.is_deleted = 0 and m.model_id = #{modelId}
order by r.order_num
</select> </select>
<insert id="insertEtFeeRule" parameterType="EtFeeRule" useGeneratedKeys="true" keyProperty="ruleId"> <insert id="insertEtFeeRule" parameterType="EtFeeRule" useGeneratedKeys="true" keyProperty="ruleId">