From c7be2ef037c5aebb0cd8f1f33e5fa934389e6083 Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期三, 26 十月 2022 17:51:43 +0800
Subject: [PATCH] changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | 131 ++++++++++++++++++++++---------------------
1 files changed, 68 insertions(+), 63 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
index c591d87..0223e89 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java
@@ -19,16 +19,14 @@
import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder;
import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5C3HeartbeatReportInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A1TernaryCodeReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightResetReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.EmptyRequestInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1DeviceMacRespInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A1TernaryCodeRespInnerFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
-import com.sandu.ximon.admin.manager.iot.rrpc.enums.A1OrderEnum;
-import com.sandu.ximon.admin.manager.iot.rrpc.enums.A2OrderEnum;
-import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
-import com.sandu.ximon.admin.manager.iot.rrpc.enums.DeviceStateEnum;
+import com.sandu.ximon.admin.manager.iot.rrpc.enums.*;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.param.PoleBindingParam;
import com.sandu.ximon.admin.param.PoleParam;
@@ -261,7 +259,7 @@
DeviceOnLineCountVO ledNova = new DeviceOnLineCountVO();
ledPlayerEntities.forEach(
Volume -> {
- String s = redisUtils.get(DeviceRedisKey.IP_BROADCAST + Volume.getId());
+ String s = redisUtils.get(DeviceRedisKey.NOVA + Volume.getId());
if (s != null) {
RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
if (redisDeviceStatus.getStatus() == 0) {
@@ -368,12 +366,19 @@
//鍗曠伅
List<LightBo> lights = SpringContextHolder.getBean(LightService.class).listLightOnHome();
+ BaseConditionVO baseConditionVO = new BaseConditionVO();
+ baseConditionVO.setPageNo(1);
+ baseConditionVO.setPageSize(999);
+ System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: " + LocalDateTime.now());
+ CommonPage commonPage = SpringContextHolder.getBean(LightReportErrorService.class).queryErrorCode(baseConditionVO);
+ System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: " + LocalDateTime.now());
new Thread(new Runnable() {
@Override
public void run() {
+
AtomicInteger onLine = new AtomicInteger(0);
AtomicInteger offLine = new AtomicInteger(0);
- AtomicInteger error = new AtomicInteger(0);
+ AtomicInteger error = new AtomicInteger(commonPage.getList().size());
DeviceOnLineCountVO light = new DeviceOnLineCountVO();
@@ -390,7 +395,7 @@
offLine.getAndIncrement();
}
} else {
- error.getAndIncrement();
+ offLine.getAndIncrement();
}
}
);
@@ -420,20 +425,23 @@
DeviceOnLineCountVO c3m = new DeviceOnLineCountVO();
c3mChargings.forEach(
device -> {
- String s = redisUtils.get(DeviceRedisKey.C3M + device.getC3Id());
+ String s = redisUtils.get(C3mRedisConstant.C3_STATUS.getCode() + device.getC3Mac());
+ RedisDeviceStatus redisDeviceStatus = new RedisDeviceStatus();
+ redisDeviceStatus.setDeviceId(device.getC3Id().toString());
if (s != null) {
- RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
- if (redisDeviceStatus.getStatus() == 0) {
+ A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
+ // 鍏呯數妗╁彛鐘舵�佷綅 1.绌洪棽 2.鍏呯數涓� 3.鍏呯數涓柇锛岀瓑寰呮湇鍔″櫒纭 4.鍏呯數缁撴潫锛岀瓑寰呮湇鍔″櫒纭 5.鏈夋晠闅� 6.涓庡厖鐢垫々瀵规帴涓�
+ if ("5".equals(heartBeatDataPackage.getStatusBit())) {
+ //鏁呴殰
+ onLine.getAndIncrement();
+ error.getAndIncrement();
+ } else {
//鍦ㄧ嚎
onLine.getAndIncrement();
- } else if (redisDeviceStatus.getStatus() == 1) {
- //绂荤嚎
- offLine.getAndIncrement();
- } else {
- error.getAndIncrement();
}
} else {
- error.getAndIncrement();
+ //绂荤嚎
+ offLine.getAndIncrement();
}
}
);
@@ -463,7 +471,7 @@
DeviceOnLineCountVO air = new DeviceOnLineCountVO();
airEquipments.forEach(
device -> {
- String s = redisUtils.get(DeviceRedisKey.AIR + device.getAirMac());
+ String s = redisUtils.get(DeviceRedisKey.AIR + device.getMac());
if (s != null) {
RedisDeviceStatus redisDeviceStatus = JSON.parseObject(s, RedisDeviceStatus.class);
if (redisDeviceStatus.getStatus() == 0) {
@@ -569,7 +577,7 @@
}
}).start();
try {
- countDownLatch.await(12000, TimeUnit.MILLISECONDS);
+ countDownLatch.await(20000, TimeUnit.MILLISECONDS);
countDownLatchUtil.remove(str);
} catch (InterruptedException e) {
throw new RuntimeException(e);
@@ -719,25 +727,24 @@
* @param param
* @return
*/
- public List<Pole> isBind(List<Pole> list, PoleStatesParam param) {
- List<Pole> bindList = new ArrayList<>();//宸茬粦瀹氬鎴�
- List<Pole> unbindList = new ArrayList<>();//鏈粦瀹氬鎴�
- list.forEach(bindwarpper -> {
-// Long clientId = bindwarpper.getClientId();
- if (bindwarpper.getClientId() == null) {//鍒ゆ柇鏄惁缁戝畾
- unbindList.add(bindwarpper);
- } else {
- bindList.add(bindwarpper);
- }
- });
- if (param.getBingStates() == 0) {
- return bindList;
- } else if (param.getBingStates() == 1) {
- return unbindList;
- }
- return list;
- }
-
+// public List<Pole> isBind(List<Pole> list, PoleStatesParam param) {
+// List<Pole> bindList = new ArrayList<>();//宸茬粦瀹氬鎴�
+// List<Pole> unbindList = new ArrayList<>();//鏈粦瀹氬鎴�
+// list.forEach(bindwarpper -> {
+//// Long clientId = bindwarpper.getClientId();
+// if (bindwarpper.getClientId() == null) {//鍒ゆ柇鏄惁缁戝畾
+// unbindList.add(bindwarpper);
+// } else {
+// bindList.add(bindwarpper);
+// }
+// });
+// if (param.getBingStates() == 0) {
+// return bindList;
+// } else if (param.getBingStates() == 1) {
+// return unbindList;
+// }
+// return list;
+// }
public List<Pole> isTrue(List<Pole> list, PoleStatesParam param) {
//瀹炰綋鐏潌
List<Pole> isTrue = new ArrayList<>();
@@ -856,8 +863,8 @@
*
* @return 鏄惁鎴愬姛
*/
- public boolean unBindPole(Long poleId, String deviceCode) {
- return poleBindingService.unBindPole(poleId, deviceCode);
+ public boolean unBindPole(Long poleId, String deviceCode,Integer deviceType) {
+ return poleBindingService.unBindPole(poleId, deviceCode,deviceType);
}
@@ -874,7 +881,7 @@
}
String deviceName = byId.getDeviceCode();
if (deviceName.isEmpty()) {
- throw new BusinessException("璇ョ伅鏉哅ca涓虹┖");
+ throw new BusinessException("璇ョ伅鏉哅ac涓虹┖");
}
IRequestFrame build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build();
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, build);
@@ -1101,7 +1108,11 @@
if (pole == null) {
throw new BusinessException("鐏潌涓嶅瓨鍦�");
}
+
+ //涓�绾у鎴� -1 userId
+ //浜岀骇瀹㈡埛 涓婄骇瀹㈡埛id userId
pole.setClientId(-1L);
+ pole.setUserId(-1L);
r = updateById(pole);
if (!r) {
@@ -1115,22 +1126,15 @@
public List<Pole> getOwnerPole(BaseConditionVO baseConditionVO, String keyword, Long cilentId) {
LambdaQueryWrapper<Pole> eq;
-// if(SecurityUtils.getClientId()!=null){
- PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
if (clientService.findClientId(cilentId)) {
- eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getUserId, cilentId);
+ eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId);
} else {
- PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
eq = Wrappers.lambdaQuery(Pole.class).eq(Pole::getClientId, cilentId).or(pole -> {
pole.eq(Pole::getUserId, cilentId);
});
}
-// }else {
-// PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
-// eq = Wrappers.lambdaQuery(Pole.class);
-// }
- PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+
if (!keyword.isEmpty()) {
eq.like(Pole::getPoleName, keyword).or(code -> {
code.like(Pole::getPoleCode, keyword);
@@ -1138,6 +1142,7 @@
deviceCode.like(Pole::getDeviceCode, keyword);
});
}
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
List<Pole> list;
list = list(eq);
setCount(list);
@@ -1297,16 +1302,16 @@
Long poleId = param.getPoleId();
Pole pole = getById(poleId);
PoleBinding air = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 3));
- PoleBinding nova = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 1));
- LedPlayerEntity LED = SpringContextHolder.getBean(LedPlayerEntityService.class).getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, nova.getDeviceCode()));
- if (pole == null) {
- throw new BusinessException("鐏潌涓嶅瓨鍦�");
- }
if (air == null) {
throw new BusinessException("鏈粦瀹氬ぇ姘旂洃娴嬭澶�");
}
+ PoleBinding nova = poleBindingService.getOne(Wrappers.lambdaQuery(PoleBinding.class).eq(PoleBinding::getPoleId, poleId).eq(PoleBinding::getDeviceType, 1));
if (nova == null) {
throw new BusinessException("鏈粦瀹歯ova璁惧");
+ }
+ LedPlayerEntity LED = SpringContextHolder.getBean(LedPlayerEntityService.class).getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, nova.getDeviceCode()));
+ if (pole == null) {
+ throw new BusinessException("鐏潌涓嶅瓨鍦�");
}
//鑾峰彇澶ф皵鐩戞祴鏁版嵁
A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage data = SpringContextHolder.getBean(AirDataService.class).getDataByPoleid(poleId);
@@ -1329,7 +1334,7 @@
}
//璁剧疆瑙﹀彂鏉′欢 瀛樺叆Redis 15鍒嗛挓瓒呮椂 15鍒嗛挓鍐呭啀娆¤皟鐢ㄧ洿鎺ヨ繑鍥�
- redisUtils.set("redisStatusKeyTimeout", System.currentTimeMillis(), 60*15);
+ redisUtils.set("redisStatusKeyTimeout", System.currentTimeMillis(), 60 * 15);
CountDownLatch countDownLatch = new CountDownLatch(7);//todo
//鑾峰彇涓�涓�7浣嶉殢鏈烘暟
@@ -1361,14 +1366,14 @@
System.out.println("鍗曠伅鎵ц");
}
}).start();
- new Thread(new Runnable() {
- @Override
- public void run() {
- SpringContextHolder.getBean(C3ChargingService.class).setCacheData();
- countDownLatchUtil.countDown(str);
- System.out.println("鍏呯數妗╂墽琛�");
- }
- }).start();
+// new Thread(new Runnable() {
+// @Override
+// public void run() {
+// SpringContextHolder.getBean(C3ChargingService.class).setCacheData();
+// countDownLatchUtil.countDown(str);
+// System.out.println("鍏呯數妗╂墽琛�");
+// }
+// }).start();
new Thread(new Runnable() {
@Override
public void run() {
--
Gitblit v1.9.3