From c1dcf956e2805391755508ad5ff0fc7399dfb64b Mon Sep 17 00:00:00 2001 From: 18650502300 <18650502300@163.com> Date: Fri, 27 Sep 2024 15:23:10 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=A0=B9=E6=8D=AEmac=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AE=BE=E5=A4=87=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/controller/app/AppController.java | 36 +++++- .../src/test/java/MainTests.java | 110 +++++++++--------- .../java/com/ruoyi/system/domain/EtOrder.java | 5 + .../ruoyi/system/domain/vo/AsDeviceVO.java | 22 ++++ .../system/service/IAsDeviceService.java | 3 +- .../service/impl/AsDeviceServiceImpl.java | 24 +++- .../service/impl/SysDeptServiceImpl.java | 2 +- .../java/com/ruoyi/system/task/EtTask.java | 8 ++ .../resources/mapper/system/EtOrderMapper.xml | 1 + 9 files changed, 148 insertions(+), 63 deletions(-) create mode 100644 electripper-system/src/main/java/com/ruoyi/system/domain/vo/AsDeviceVO.java diff --git a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java index 87115c3..27c1455 100644 --- a/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java +++ b/electripper-admin/src/main/java/com/ruoyi/web/controller/app/AppController.java @@ -26,11 +26,11 @@ import com.ruoyi.common.utils.map.GpsCoordinateUtils; import com.ruoyi.common.utils.onenet.Token; import com.ruoyi.framework.web.service.SysLoginService; import com.ruoyi.system.domain.*; +import com.ruoyi.system.domain.vo.AsDeviceVO; import com.ruoyi.system.mapper.AsDeviceMapper; import com.ruoyi.system.mapper.AsUserMapper; import com.ruoyi.system.mapper.EtOrderMapper; import com.ruoyi.system.service.*; -import com.wechat.pay.java.service.payments.model.Transaction; import com.wechat.pay.java.service.refund.model.Refund; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -350,6 +350,40 @@ public class AppController extends BaseController 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 asDevices = new ArrayList<>(); + for (String mac:macList) { + AsDeviceVO device = asDeviceService.selectAsDeviceByMac(mac); + if(ObjectUtil.isNotNull(device)){ + asDevices.add(device); + } + } + return success(asDevices); + } + /** * 查询当前用户是否有正在进行中的订单 */ diff --git a/electripper-admin/src/test/java/MainTests.java b/electripper-admin/src/test/java/MainTests.java index 7e9bd73..958442d 100644 --- a/electripper-admin/src/test/java/MainTests.java +++ b/electripper-admin/src/test/java/MainTests.java @@ -41,61 +41,61 @@ public class MainTests { // 记录开始时间 long startTime = System.nanoTime(); - AsDevice device = asDeviceService.selectAsDeviceByMac("75D30EA71454"); - BigDecimal lon = new BigDecimal("120.25709"); - BigDecimal lat = new BigDecimal("27.105487"); - - EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(device.getAreaId()); - String isAdminUnlocking = device.getIsAdminUnlocking();// 是否是管理员开锁:0-否;1-是 - - String nearBoundaryDistanceConfig = sysConfigService.selectConfigByKey("near.boundary.distance");// 靠近运营区边界时的播报距离 - log.info("靠近运营区边界时的播报距离==================:" + nearBoundaryDistanceConfig); - double nearBoundaryDistance = Double.parseDouble(nearBoundaryDistanceConfig); - String exceedArea = sysConfigService.selectConfigByKey("exceed.area.distance");// 超出运营区外断电距离 - log.info("超出运营区外断电距离================:" + exceedArea); - int exceedDistance = Integer.parseInt(exceedArea); - - - // 创建多边形对象 - Geometry polygon = GeoUtils.fromWkt(area.getBoundary()); - // 是否在缩短后的运营区边界内 - boolean inPolygonWithTolerance = GeoUtils.isInPolygonWithShorten(lon.toString(), lat.toString(), polygon, nearBoundaryDistance); - if(!inPolygonWithTolerance && !isAdminUnlocking.equals("1")){//没有在缩短后的运营区边界内 - boolean inPolygonWithTolerance1 = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, 0);// 是否在运营区内 - boolean isNearBoundary = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, exceedDistance ); - if(inPolygonWithTolerance1){//是否在运营区边界内 - // 在靠近运营区边界时发警报 - log.info("靠近运营区边界发警告命令--SN:" + device.getSn()); - asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "靠近运营区边界", null, null); - }else if(isNearBoundary){ // 是否在超出运营区边界多少米内 - //在20米范围内,发报警 - log.info("超出运营区"+exceedDistance+"米内发送警告命令--SN:" + device.getSn()); - asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区"+exceedDistance+"米内",null,null); - }else{ - // 超出运营区外断电 - String areaOutOutage = area.getAreaOutOutage(); - if (areaOutOutage.equals("1")) { // 超出营运区断电 - log.info("超出营运区断电命令--SN:" + device.getSn()); - asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null,null); - device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); - int updateAsDevice = asDeviceService.updateAsDevice(device); - if (updateAsDevice > 0) { - log.info("禁行区内断电--更新设备锁状态成功SN:" + device.getSn()); - } - } - } - }else{ - log.info("在运营区域内"); - } - - // 记录结束时间 - long endTime = System.nanoTime(); - - // 计算执行时间(以毫秒为单位) - long duration = (endTime - startTime) / 1_000_000; - - // 输出执行时间 - System.out.println("Execution time: " + duration + " milliseconds"); +// AsDevice device = asDeviceService.selectAsDeviceByMac("75D30EA71454"); +// BigDecimal lon = new BigDecimal("120.25709"); +// BigDecimal lat = new BigDecimal("27.105487"); +// +// EtOperatingArea area = etOperatingAreaService.selectEtOperatingAreaByAreaId(device.getAreaId()); +// String isAdminUnlocking = device.getIsAdminUnlocking();// 是否是管理员开锁:0-否;1-是 +// +// String nearBoundaryDistanceConfig = sysConfigService.selectConfigByKey("near.boundary.distance");// 靠近运营区边界时的播报距离 +// log.info("靠近运营区边界时的播报距离==================:" + nearBoundaryDistanceConfig); +// double nearBoundaryDistance = Double.parseDouble(nearBoundaryDistanceConfig); +// String exceedArea = sysConfigService.selectConfigByKey("exceed.area.distance");// 超出运营区外断电距离 +// log.info("超出运营区外断电距离================:" + exceedArea); +// int exceedDistance = Integer.parseInt(exceedArea); +// +// +// // 创建多边形对象 +// Geometry polygon = GeoUtils.fromWkt(area.getBoundary()); +// // 是否在缩短后的运营区边界内 +// boolean inPolygonWithTolerance = GeoUtils.isInPolygonWithShorten(lon.toString(), lat.toString(), polygon, nearBoundaryDistance); +// if(!inPolygonWithTolerance && !isAdminUnlocking.equals("1")){//没有在缩短后的运营区边界内 +// boolean inPolygonWithTolerance1 = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, 0);// 是否在运营区内 +// boolean isNearBoundary = GeoUtils.isInPolygonWithTolerance(lon.toString(), lat.toString(), polygon, exceedDistance ); +// if(inPolygonWithTolerance1){//是否在运营区边界内 +// // 在靠近运营区边界时发警报 +// log.info("靠近运营区边界发警告命令--SN:" + device.getSn()); +// asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY2, "靠近运营区边界", null, null); +// }else if(isNearBoundary){ // 是否在超出运营区边界多少米内 +// //在20米范围内,发报警 +// log.info("超出运营区"+exceedDistance+"米内发送警告命令--SN:" + device.getSn()); +// asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_PLAY3, "超出运营区"+exceedDistance+"米内",null,null); +// }else{ +// // 超出运营区外断电 +// String areaOutOutage = area.getAreaOutOutage(); +// if (areaOutOutage.equals("1")) { // 超出营运区断电 +// log.info("超出营运区断电命令--SN:" + device.getSn()); +// asDeviceService.sendCommand(device.getMac(), Token.getToken(), IotConstants.COMMAND_QLOSE+IotConstants.COMMAND_FREQUENCY_5, "超出营运区断电",null,null); +// device.setLockStatus(ServiceConstants.LOCK_STATUS_CLOSE); +// int updateAsDevice = asDeviceService.updateAsDevice(device); +// if (updateAsDevice > 0) { +// log.info("禁行区内断电--更新设备锁状态成功SN:" + device.getSn()); +// } +// } +// } +// }else{ +// log.info("在运营区域内"); +// } +// +// // 记录结束时间 +// long endTime = System.nanoTime(); +// +// // 计算执行时间(以毫秒为单位) +// long duration = (endTime - startTime) / 1_000_000; +// +// // 输出执行时间 +// System.out.println("Execution time: " + duration + " milliseconds"); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java index 4919184..3f3efb5 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/EtOrder.java @@ -29,6 +29,11 @@ public class EtOrder extends BaseEntity @Excel(name = "区域id") private Long areaId; + /** 运营商id */ + @Excel(name = "运营商id") + @TableField(exist = false) + private Long deptId; + /** 区域 */ @Excel(name = "区域") private String area; diff --git a/electripper-system/src/main/java/com/ruoyi/system/domain/vo/AsDeviceVO.java b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/AsDeviceVO.java new file mode 100644 index 0000000..51cb810 --- /dev/null +++ b/electripper-system/src/main/java/com/ruoyi/system/domain/vo/AsDeviceVO.java @@ -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; +} diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java index e6ac6f6..a37a764 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/IAsDeviceService.java @@ -7,6 +7,7 @@ import com.ruoyi.system.domain.AsDevice; import com.ruoyi.system.domain.EtLocationLog; import com.ruoyi.system.domain.EtOperatingArea; 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.EtOrderVo; import com.ruoyi.system.domain.vo.IsInParkingAreaVo; @@ -35,7 +36,7 @@ public interface IAsDeviceService extends IService * @param mac 设备主键 * @return 设备 */ - public AsDevice selectAsDeviceByMac(String mac); + public AsDeviceVO selectAsDeviceByMac(String mac); /** * 根据SN查询设备信息 diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java index eae58b8..02d8012 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/AsDeviceServiceImpl.java @@ -30,6 +30,7 @@ import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.ObjectUtils; import org.jetbrains.annotations.NotNull; import org.locationtech.jts.geom.Geometry; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -172,8 +173,21 @@ public class AsDeviceServiceImpl extends ServiceImpl i * @return 设备 */ @Override - public AsDevice selectAsDeviceByMac(String mac) { - return asDeviceMapper.selectAsDeviceByMac(mac); + public AsDeviceVO selectAsDeviceByMac(String 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,9 +212,9 @@ public class AsDeviceServiceImpl extends ServiceImpl i EtModel model = etModelService.selectEtModelByModelId(asDevice.getModelId()); if(ObjectUtil.isNotNull(model)){ asDevice.setModel(model.getModel()); - } - if(StrUtil.isNotBlank(asDevice.getVoltage())){ - asDevice.setRemainingMileage(CommonUtil.getRemainingMileage(asDevice.getVoltage(),model.getFullVoltage(),model.getLowVoltage(),model.getFullEndurance())); + if(StrUtil.isNotBlank(asDevice.getVoltage())){ + asDevice.setRemainingMileage(CommonUtil.getRemainingMileage(asDevice.getVoltage(),model.getFullVoltage(),model.getLowVoltage(),model.getFullEndurance())); + } } String msg = redisCache.getCacheObject(CacheConstants.CACHE_DEVICE_KEY + asDevice.getSn()); if(StrUtil.isNotBlank(msg)){ diff --git a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java index f7ab9e4..88cec42 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java +++ b/electripper-system/src/main/java/com/ruoyi/system/service/impl/SysDeptServiceImpl.java @@ -337,7 +337,7 @@ public class SysDeptServiceImpl implements ISysDeptService if (StrUtil.isNotBlank(dept.getIsUsePlatformApp()) && dept.getIsUsePlatformApp().equals("true")) { SysDept platform = deptMapper.selectDeptById(100L); dept.setAppid(platform.getAppid()); -// dept.setAppSecret(platform.getAppSecret()); + dept.setAppSecret(platform.getAppSecret()); dept.setAppName(platform.getAppName()); dept.setDomain(platform.getDomain()); } diff --git a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java index ee8c2e2..27bb948 100644 --- a/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java +++ b/electripper-system/src/main/java/com/ruoyi/system/task/EtTask.java @@ -738,4 +738,12 @@ public class EtTask { } log.info("-------------------【定时任务】判断优惠券是否过期---结束----------------"); } + + /** + * 五分钟更新电动车的状态 + * + */ + public void updateDeviceStatus(){ + log.info("-------------------【定时任务】五分钟更新电动车的状态---开始----------------"); + } } diff --git a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml index be95546..3160510 100644 --- a/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml +++ b/electripper-system/src/main/resources/mapper/system/EtOrderMapper.xml @@ -153,6 +153,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and o.order_no like concat('%', #{orderNo}, '%') and oa.area_name like concat('%', #{area}, '%') and o.area_id = #{areaId} + and d.dept_id = #{deptId} and u.user_name like concat('%', #{userName}, '%') and u.phonenumber like concat('%', #{phonenumber}, '%') and o.user_id = #{userId}