From 727a69f859060093e685582fa10e5de82dcc138a Mon Sep 17 00:00:00 2001
From: Van333 <van666666@foxmail.com>
Date: 星期四, 29 十二月 2022 15:37:49 +0800
Subject: [PATCH] 放假备份。完成集中控制器对接。
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/PoleService.java | 145 ++++++++++++++++++++++++++++--------------------
1 files changed, 84 insertions(+), 61 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 fd3dbab..56a361b 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
@@ -22,6 +22,7 @@
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.A7PlcResetReqInnerFrame;
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;
@@ -45,6 +46,7 @@
import com.sandu.ximon.dao.domain.*;
import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.PoleMapper;
+import eu.bitwalker.useragentutils.DeviceType;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.RandomStringUtils;
@@ -129,24 +131,26 @@
/**
* 鍒犻櫎鐏潌
*/
- public boolean deletePole(Long poleId) {
- Pole pole = getById(poleId);
- if (pole == null) {
+ public boolean deletePole(List<Long> poleIds) {
+ List<Pole> poles = listByIds(poleIds);
+ if (poles.isEmpty()) {
throw new BusinessException("鏈壘鍒拌鐏潌");
}
// 鍒犻櫎鐏潌缁戝畾鍏崇郴
- poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().eq(PoleBinding::getPoleId, poleId));
+ poleBindingService.remove(Wrappers.<PoleBinding>lambdaQuery().in(PoleBinding::getPoleId, poleIds));
+ SpringContextHolder.getBean(LightTaskPoleRelationService.class)
+ .remove(Wrappers.lambdaQuery(LightTaskPoleRelation.class).in(LightTaskPoleRelation::getPoleId, poleIds));
/**
* 鍒犻櫎鐏潌鏃ュ織璁板綍寮�濮�
*/
- String content = "{鐏潌Code锛�" + pole.getDeviceCode() + "锛� 鐏潌鍚嶇О锛�" + pole.getPoleName() + " }";
+ String content = "{鐏潌id锛�" + poles + " }";
StoreOperationRecordsUtils.storeOperationData(null, null, "鍒犻櫎鐏潌", content);
/**
* 鍒犻櫎鐏潌鏃ュ織璁板綍缁撴潫
*/
- return removeById(poleId);
+ return removeByIds(poleIds);
}
@@ -369,9 +373,9 @@
BaseConditionVO baseConditionVO = new BaseConditionVO();
baseConditionVO.setPageNo(1);
baseConditionVO.setPageSize(999);
- System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: "+ LocalDateTime.now());
+ System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: " + LocalDateTime.now());
CommonPage commonPage = SpringContextHolder.getBean(LightReportErrorService.class).queryErrorCode(baseConditionVO);
- System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: "+ LocalDateTime.now());
+ System.out.println("鍗曠伅鏁呴殰缁熻鏃堕棿: " + LocalDateTime.now());
new Thread(new Runnable() {
@Override
public void run() {
@@ -379,7 +383,6 @@
AtomicInteger onLine = new AtomicInteger(0);
AtomicInteger offLine = new AtomicInteger(0);
AtomicInteger error = new AtomicInteger(commonPage.getList().size());
-
DeviceOnLineCountVO light = new DeviceOnLineCountVO();
@@ -426,20 +429,19 @@
DeviceOnLineCountVO c3m = new DeviceOnLineCountVO();
c3mChargings.forEach(
device -> {
-// RedisUtils.getBean().set(C3mRedisConstant.C3_STATUS.getCode() + heartbeatReportInnerFrame.getHeartBeatDataPackage().getC3Mac()
-// , heartbeatReportInnerFrame.getHeartBeatDataPackage(), 300L);
String s = redisUtils.get(C3mRedisConstant.C3_STATUS.getCode() + device.getC3Mac());
RedisDeviceStatus redisDeviceStatus = new RedisDeviceStatus();
redisDeviceStatus.setDeviceId(device.getC3Id().toString());
if (s != null) {
A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
+ // 鍏呯數妗╁彛鐘舵�佷綅 1.绌洪棽 2.鍏呯數涓� 3.鍏呯數涓柇锛岀瓑寰呮湇鍔″櫒纭 4.鍏呯數缁撴潫锛岀瓑寰呮湇鍔″櫒纭 5.鏈夋晠闅� 6.涓庡厖鐢垫々瀵规帴涓�
if ("5".equals(heartBeatDataPackage.getStatusBit())) {
- //鍦ㄧ嚎
- onLine.getAndIncrement();
- } else {
//鏁呴殰
onLine.getAndIncrement();
error.getAndIncrement();
+ } else {
+ //鍦ㄧ嚎
+ onLine.getAndIncrement();
}
} else {
//绂荤嚎
@@ -473,7 +475,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) {
@@ -729,25 +731,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<>();
@@ -866,8 +867,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);
}
@@ -884,13 +885,23 @@
}
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();
+ Integer deviceType = byId.getDeviceType();
+
+ IRequestFrame build = null;
+ if (deviceType < 2){
+ build = FrameBuilder.builderA5().orderType(A5OrderEnum.REQUEST_LIGHT_DATA.getCode()).innerFrame(new A5LightResetReqInnerFrame()).build();
+ }
+ else if (deviceType == 2){
+ build = FrameBuilder.builderA7().orderType(A7OrderEnum.REQUEST_PLC_DATA.getCode()).innerFrame(new A7PlcResetReqInnerFrame()).build();
+
+ }
+
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, build);
+
StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "鐏潌鎭㈠鍑哄巶璁剧疆", build, commonFrame);
- System.out.println(commonFrame.toString());
IRequestFrame iRequestFrame = FrameBuilder.builderA2().innerFrame(new EmptyRequestInnerFrame()).orderType(A2OrderEnum.REQUEST_MAIN_BOARD_RESET.getCode()).build();
CommonFrame rebootFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, iRequestFrame);
StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "鐏潌閲嶅惎", iRequestFrame, commonFrame);
@@ -1002,6 +1013,8 @@
pole.setDeviceType(0);
} else if ("01".equals(a1DeviceMacRespInnerFrame.getType())) {
pole.setDeviceType(1);
+ } else if ("02".equals(a1DeviceMacRespInnerFrame.getType())) {
+ pole.setDeviceType(2);
}
pole.setPoleCode(generatePoleCode());
@@ -1009,12 +1022,24 @@
boolean result = saveOrUpdate(pole);
if (result) {
- Light light = SpringContextHolder.getBean(LightService.class).getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1"));
- if (light == null) {
- light = new Light();
- light.setDeviceCode(uniqueMac);
- light.setLightCount(2);
- SpringContextHolder.getBean(LightService.class).save(light);
+ if (pole.getDeviceType() < 2) {
+ Light light = SpringContextHolder.getBean(LightService.class).
+ getOne(Wrappers.lambdaQuery(Light.class).eq(Light::getDeviceCode, pole.getDeviceCode()).last("limit 1"));
+ if (light == null) {
+ light = new Light();
+ light.setDeviceCode(uniqueMac);
+ light.setLightCount(2);
+ SpringContextHolder.getBean(LightService.class).save(light);
+ }
+ } else if (pole.getDeviceType() == 2) {
+ Plc plc = SpringContextHolder.getBean(PlcService.class).
+ getOne(Wrappers.lambdaQuery(Plc.class).eq(Plc::getDeviceCode,pole.getDeviceCode()).last("limit 1"));
+ if (plc == null){
+ plc = new Plc();
+ plc.setDeviceCode(uniqueMac);
+ plc.setPlcCount(3);
+ SpringContextHolder.getBean(PlcService.class).save(plc);
+ }
}
}
@@ -1111,7 +1136,11 @@
if (pole == null) {
throw new BusinessException("鐏潌涓嶅瓨鍦�");
}
+
+ //涓�绾у鎴� -1 userId
+ //浜岀骇瀹㈡埛 涓婄骇瀹㈡埛id userId
pole.setClientId(-1L);
+ pole.setUserId(-1L);
r = updateById(pole);
if (!r) {
@@ -1125,22 +1154,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);
@@ -1148,6 +1170,7 @@
deviceCode.like(Pole::getDeviceCode, keyword);
});
}
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
List<Pole> list;
list = list(eq);
setCount(list);
@@ -1307,16 +1330,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);
@@ -1339,7 +1362,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浣嶉殢鏈烘暟
@@ -1422,4 +1445,4 @@
}
-}
\ No newline at end of file
+}
--
Gitblit v1.9.3