1.根据mac数据查询设备信息
This commit is contained in:
parent
49f9a34979
commit
c1dcf956e2
|
@ -26,11 +26,11 @@ import com.ruoyi.common.utils.map.GpsCoordinateUtils;
|
||||||
import com.ruoyi.common.utils.onenet.Token;
|
import com.ruoyi.common.utils.onenet.Token;
|
||||||
import com.ruoyi.framework.web.service.SysLoginService;
|
import com.ruoyi.framework.web.service.SysLoginService;
|
||||||
import com.ruoyi.system.domain.*;
|
import com.ruoyi.system.domain.*;
|
||||||
|
import com.ruoyi.system.domain.vo.AsDeviceVO;
|
||||||
import com.ruoyi.system.mapper.AsDeviceMapper;
|
import com.ruoyi.system.mapper.AsDeviceMapper;
|
||||||
import com.ruoyi.system.mapper.AsUserMapper;
|
import com.ruoyi.system.mapper.AsUserMapper;
|
||||||
import com.ruoyi.system.mapper.EtOrderMapper;
|
import com.ruoyi.system.mapper.EtOrderMapper;
|
||||||
import com.ruoyi.system.service.*;
|
import com.ruoyi.system.service.*;
|
||||||
import com.wechat.pay.java.service.payments.model.Transaction;
|
|
||||||
import com.wechat.pay.java.service.refund.model.Refund;
|
import com.wechat.pay.java.service.refund.model.Refund;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
|
@ -350,6 +350,40 @@ public class AppController extends BaseController
|
||||||
return success(device);
|
return success(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// /**
|
||||||
|
// * 根据mac 查询设备信息
|
||||||
|
// */
|
||||||
|
// @GetMapping("/getDeviceInfoByMac")
|
||||||
|
// public AjaxResult getDeviceInfoByMac(String mac)
|
||||||
|
// {
|
||||||
|
// if(StrUtil.isBlank(mac)){
|
||||||
|
// logger.info("没有mac号参数:【mac={}】",mac);
|
||||||
|
// return error("未传mac号参数");
|
||||||
|
// }
|
||||||
|
// AsDevice device = asDeviceService.selectAsDeviceByMac(mac);
|
||||||
|
// return success(device);
|
||||||
|
// }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据mac数据查询设备信息
|
||||||
|
*/
|
||||||
|
@GetMapping("/getDeviceInfoByMacList")
|
||||||
|
public AjaxResult getDeviceInfoByMacList(String[] macList)
|
||||||
|
{
|
||||||
|
if(ObjectUtil.isNull(macList)){
|
||||||
|
logger.info("没有mac号数组参数:【macList={}】",macList);
|
||||||
|
return error("未传mac号参数");
|
||||||
|
}
|
||||||
|
ArrayList<AsDeviceVO> asDevices = new ArrayList<>();
|
||||||
|
for (String mac:macList) {
|
||||||
|
AsDeviceVO device = asDeviceService.selectAsDeviceByMac(mac);
|
||||||
|
if(ObjectUtil.isNotNull(device)){
|
||||||
|
asDevices.add(device);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return success(asDevices);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询当前用户是否有正在进行中的订单
|
* 查询当前用户是否有正在进行中的订单
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -41,61 +41,61 @@ public class MainTests {
|
||||||
// 记录开始时间
|
// 记录开始时间
|
||||||
long startTime = System.nanoTime();
|
long startTime = System.nanoTime();
|
||||||
|
|
||||||
AsDevice device = asDeviceService.selectAsDeviceByMac("75D30EA71454");
|
// AsDevice device = asDeviceService.selectAsDeviceByMac("75D30EA71454");
|
||||||
BigDecimal lon = new BigDecimal("120.25709");
|
// BigDecimal lon = new BigDecimal("120.25709");
|
||||||
BigDecimal lat = new BigDecimal("27.105487");
|
// BigDecimal lat = new BigDecimal("27.105487");
|
||||||
|
//
|
||||||
EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(device.getAreaId());
|
// EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(device.getAreaId());
|
||||||
String isAdminUnlocking = device.getIsAdminUnlocking();// 是否是管理员开锁:0-否;1-是
|
// String isAdminUnlocking = device.getIsAdminUnlocking();// 是否是管理员开锁:0-否;1-是
|
||||||
|
//
|
||||||
String nearBoundaryDistanceConfig = sysConfigService.selectConfigByKey("near.boundary.distance");// 靠近运营区边界时的播报距离
|
// String nearBoundaryDistanceConfig = sysConfigService.selectConfigByKey("near.boundary.distance");// 靠近运营区边界时的播报距离
|
||||||
log.info("靠近运营区边界时的播报距离==================:" + nearBoundaryDistanceConfig);
|
// log.info("靠近运营区边界时的播报距离==================:" + nearBoundaryDistanceConfig);
|
||||||
double nearBoundaryDistance = Double.parseDouble(nearBoundaryDistanceConfig);
|
// double nearBoundaryDistance = Double.parseDouble(nearBoundaryDistanceConfig);
|
||||||
String exceedArea = sysConfigService.selectConfigByKey("exceed.area.distance");// 超出运营区外断电距离
|
// String exceedArea = sysConfigService.selectConfigByKey("exceed.area.distance");// 超出运营区外断电距离
|
||||||
log.info("超出运营区外断电距离================:" + exceedArea);
|
// log.info("超出运营区外断电距离================:" + exceedArea);
|
||||||
int exceedDistance = Integer.parseInt(exceedArea);
|
// int exceedDistance = Integer.parseInt(exceedArea);
|
||||||
|
//
|
||||||
|
//
|
||||||
// 创建多边形对象
|
// // 创建多边形对象
|
||||||
Geometry polygon = GeoUtils.fromWkt(area.getBoundary());
|
// Geometry polygon = GeoUtils.fromWkt(area.getBoundary());
|
||||||
// 是否在缩短后的运营区边界内
|
// // 是否在缩短后的运营区边界内
|
||||||
boolean inPolygonWithTolerance = GeoUtils.isInPolygonWithShorten(lon.toString(), lat.toString(), polygon, nearBoundaryDistance);
|
// boolean inPolygonWithTolerance = GeoUtils.isInPolygonWithShorten(lon.toString(), lat.toString(), polygon, nearBoundaryDistance);
|
||||||
if(!inPolygonWithTolerance && !isAdminUnlocking.equals("1")){//没有在缩短后的运营区边界内
|
// if(!inPolygonWithTolerance && !isAdminUnlocking.equals("1")){//没有在缩短后的运营区边界内
|
||||||
boolean inPolygonWithTolerance1 = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, 0);// 是否在运营区内
|
// boolean inPolygonWithTolerance1 = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, 0);// 是否在运营区内
|
||||||
boolean isNearBoundary = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, exceedDistance );
|
// boolean isNearBoundary = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, exceedDistance );
|
||||||
if(inPolygonWithTolerance1){//是否在运营区边界内
|
// if(inPolygonWithTolerance1){//是否在运营区边界内
|
||||||
// 在靠近运营区边界时发警报
|
// // 在靠近运营区边界时发警报
|
||||||
log.info("靠近运营区边界发警告命令--SN:" + device.getSn());
|
// log.info("靠近运营区边界发警告命令--SN:" + device.getSn());
|
||||||
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "靠近运营区边界", null, null);
|
// asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "靠近运营区边界", null, null);
|
||||||
}else if(isNearBoundary){ // 是否在超出运营区边界多少米内
|
// }else if(isNearBoundary){ // 是否在超出运营区边界多少米内
|
||||||
//在20米范围内,发报警
|
// //在20米范围内,发报警
|
||||||
log.info("超出运营区"+exceedDistance+"米内发送警告命令--SN:" + device.getSn());
|
// log.info("超出运营区"+exceedDistance+"米内发送警告命令--SN:" + device.getSn());
|
||||||
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区"+exceedDistance+"米内",null,null);
|
// asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区"+exceedDistance+"米内",null,null);
|
||||||
}else{
|
// }else{
|
||||||
// 超出运营区外断电
|
// // 超出运营区外断电
|
||||||
String areaOutOutage = area.getAreaOutOutage();
|
// String areaOutOutage = area.getAreaOutOutage();
|
||||||
if (areaOutOutage.equals("1")) { // 超出营运区断电
|
// if (areaOutOutage.equals("1")) { // 超出营运区断电
|
||||||
log.info("超出营运区断电命令--SN:" + device.getSn());
|
// log.info("超出营运区断电命令--SN:" + device.getSn());
|
||||||
asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null,null);
|
// asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null,null);
|
||||||
device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
// device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE);
|
||||||
int updateAsDevice = asDeviceService.updateAsDevice(device);
|
// int updateAsDevice = asDeviceService.updateAsDevice(device);
|
||||||
if (updateAsDevice > 0) {
|
// if (updateAsDevice > 0) {
|
||||||
log.info("禁行区内断电--更新设备锁状态成功SN:" + device.getSn());
|
// log.info("禁行区内断电--更新设备锁状态成功SN:" + device.getSn());
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}else{
|
// }else{
|
||||||
log.info("在运营区域内");
|
// log.info("在运营区域内");
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
// 记录结束时间
|
// // 记录结束时间
|
||||||
long endTime = System.nanoTime();
|
// long endTime = System.nanoTime();
|
||||||
|
//
|
||||||
// 计算执行时间(以毫秒为单位)
|
// // 计算执行时间(以毫秒为单位)
|
||||||
long duration = (endTime - startTime) / 1_000_000;
|
// long duration = (endTime - startTime) / 1_000_000;
|
||||||
|
//
|
||||||
// 输出执行时间
|
// // 输出执行时间
|
||||||
System.out.println("Execution time: " + duration + " milliseconds");
|
// System.out.println("Execution time: " + duration + " milliseconds");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,11 @@ public class EtOrder extends BaseEntity
|
||||||
@Excel(name = "区域id")
|
@Excel(name = "区域id")
|
||||||
private Long areaId;
|
private Long areaId;
|
||||||
|
|
||||||
|
/** 运营商id */
|
||||||
|
@Excel(name = "运营商id")
|
||||||
|
@TableField(exist = false)
|
||||||
|
private Long deptId;
|
||||||
|
|
||||||
/** 区域 */
|
/** 区域 */
|
||||||
@Excel(name = "区域")
|
@Excel(name = "区域")
|
||||||
private String area;
|
private String area;
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.ruoyi.system.domain.vo;
|
||||||
|
|
||||||
|
import com.ruoyi.common.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class AsDeviceVO {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 设备Mac号 */
|
||||||
|
@Excel(name = "设备Mac号")
|
||||||
|
private String mac;
|
||||||
|
|
||||||
|
/** 设备SN号 */
|
||||||
|
@Excel(name = "设备SN号")
|
||||||
|
private String sn;
|
||||||
|
|
||||||
|
/** 是否绑定 */
|
||||||
|
@Excel(name = "是否绑定")
|
||||||
|
private Boolean isBand;
|
||||||
|
}
|
|
@ -7,6 +7,7 @@ import com.ruoyi.system.domain.AsDevice;
|
||||||
import com.ruoyi.system.domain.EtLocationLog;
|
import com.ruoyi.system.domain.EtLocationLog;
|
||||||
import com.ruoyi.system.domain.EtOperatingArea;
|
import com.ruoyi.system.domain.EtOperatingArea;
|
||||||
import com.ruoyi.system.domain.response.OrderResponse;
|
import com.ruoyi.system.domain.response.OrderResponse;
|
||||||
|
import com.ruoyi.system.domain.vo.AsDeviceVO;
|
||||||
import com.ruoyi.system.domain.vo.DeviceNumVo;
|
import com.ruoyi.system.domain.vo.DeviceNumVo;
|
||||||
import com.ruoyi.system.domain.vo.EtOrderVo;
|
import com.ruoyi.system.domain.vo.EtOrderVo;
|
||||||
import com.ruoyi.system.domain.vo.IsInParkingAreaVo;
|
import com.ruoyi.system.domain.vo.IsInParkingAreaVo;
|
||||||
|
@ -35,7 +36,7 @@ public interface IAsDeviceService extends IService<AsDevice>
|
||||||
* @param mac 设备主键
|
* @param mac 设备主键
|
||||||
* @return 设备
|
* @return 设备
|
||||||
*/
|
*/
|
||||||
public AsDevice selectAsDeviceByMac(String mac);
|
public AsDeviceVO selectAsDeviceByMac(String mac);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据SN查询设备信息
|
* 根据SN查询设备信息
|
||||||
|
|
|
@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.ObjectUtils;
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.locationtech.jts.geom.Geometry;
|
import org.locationtech.jts.geom.Geometry;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -172,8 +173,21 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
* @return 设备
|
* @return 设备
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public AsDevice selectAsDeviceByMac(String mac) {
|
public AsDeviceVO selectAsDeviceByMac(String mac) {
|
||||||
return asDeviceMapper.selectAsDeviceByMac(mac);
|
AsDeviceVO asDeviceVO = new AsDeviceVO();
|
||||||
|
AsDevice asDevice = asDeviceMapper.selectAsDeviceByMac(mac);
|
||||||
|
if(ObjectUtil.isNull(asDevice)){
|
||||||
|
asDeviceVO.setMac(mac);
|
||||||
|
asDeviceVO.setIsBand(false);
|
||||||
|
}else{
|
||||||
|
BeanUtils.copyProperties(asDevice,asDeviceVO);
|
||||||
|
if(StrUtil.isBlank(asDevice.getSn())){
|
||||||
|
asDeviceVO.setIsBand(false);
|
||||||
|
}else{
|
||||||
|
asDeviceVO.setIsBand(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return asDeviceVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -198,10 +212,10 @@ public class AsDeviceServiceImpl extends ServiceImpl<AsDeviceMapper, AsDevice> i
|
||||||
EtModel model = etModelService.selectEtModelByModelId(asDevice.getModelId());
|
EtModel model = etModelService.selectEtModelByModelId(asDevice.getModelId());
|
||||||
if(ObjectUtil.isNotNull(model)){
|
if(ObjectUtil.isNotNull(model)){
|
||||||
asDevice.setModel(model.getModel());
|
asDevice.setModel(model.getModel());
|
||||||
}
|
|
||||||
if(StrUtil.isNotBlank(asDevice.getVoltage())){
|
if(StrUtil.isNotBlank(asDevice.getVoltage())){
|
||||||
asDevice.setRemainingMileage(CommonUtil.getRemainingMileage(asDevice.getVoltage(),model.getFullVoltage(),model.getLowVoltage(),model.getFullEndurance()));
|
asDevice.setRemainingMileage(CommonUtil.getRemainingMileage(asDevice.getVoltage(),model.getFullVoltage(),model.getLowVoltage(),model.getFullEndurance()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
String msg = redisCache.getCacheObject(CacheConstants.CACHE_DEVICE_KEY + asDevice.getSn());
|
String msg = redisCache.getCacheObject(CacheConstants.CACHE_DEVICE_KEY + asDevice.getSn());
|
||||||
if(StrUtil.isNotBlank(msg)){
|
if(StrUtil.isNotBlank(msg)){
|
||||||
log.info("【根据sn号查询车辆实时信息】-========redis缓存中的数据:" + msg);
|
log.info("【根据sn号查询车辆实时信息】-========redis缓存中的数据:" + msg);
|
||||||
|
|
|
@ -337,7 +337,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
if (StrUtil.isNotBlank(dept.getIsUsePlatformApp()) && dept.getIsUsePlatformApp().equals("true")) {
|
if (StrUtil.isNotBlank(dept.getIsUsePlatformApp()) && dept.getIsUsePlatformApp().equals("true")) {
|
||||||
SysDept platform = deptMapper.selectDeptById(100L);
|
SysDept platform = deptMapper.selectDeptById(100L);
|
||||||
dept.setAppid(platform.getAppid());
|
dept.setAppid(platform.getAppid());
|
||||||
// dept.setAppSecret(platform.getAppSecret());
|
dept.setAppSecret(platform.getAppSecret());
|
||||||
dept.setAppName(platform.getAppName());
|
dept.setAppName(platform.getAppName());
|
||||||
dept.setDomain(platform.getDomain());
|
dept.setDomain(platform.getDomain());
|
||||||
}
|
}
|
||||||
|
|
|
@ -738,4 +738,12 @@ public class EtTask {
|
||||||
}
|
}
|
||||||
log.info("-------------------【定时任务】判断优惠券是否过期---结束----------------");
|
log.info("-------------------【定时任务】判断优惠券是否过期---结束----------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 五分钟更新电动车的状态
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public void updateDeviceStatus(){
|
||||||
|
log.info("-------------------【定时任务】五分钟更新电动车的状态---开始----------------");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -153,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<if test="orderNo != null and orderNo != ''"> and o.order_no like concat('%', #{orderNo}, '%')</if>
|
<if test="orderNo != null and orderNo != ''"> and o.order_no like concat('%', #{orderNo}, '%')</if>
|
||||||
<if test="area != null and area != ''"> and oa.area_name like concat('%', #{area}, '%')</if>
|
<if test="area != null and area != ''"> and oa.area_name like concat('%', #{area}, '%')</if>
|
||||||
<if test="areaId != null"> and o.area_id = #{areaId}</if>
|
<if test="areaId != null"> and o.area_id = #{areaId}</if>
|
||||||
|
<if test="deptId != null"> and d.dept_id = #{deptId}</if>
|
||||||
<if test="userName != null and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
|
<if test="userName != null and userName != ''"> and u.user_name like concat('%', #{userName}, '%')</if>
|
||||||
<if test="phonenumber != null and phonenumber != ''"> and u.phonenumber like concat('%', #{phonenumber}, '%')</if>
|
<if test="phonenumber != null and phonenumber != ''"> and u.phonenumber like concat('%', #{phonenumber}, '%')</if>
|
||||||
<if test="userId != null and userId != ''"> and o.user_id = #{userId}</if>
|
<if test="userId != null and userId != ''"> and o.user_id = #{userId}</if>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user