From d9a9d8a2dad1d1e57b184bf8f972a03d654d883a Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期五, 22 七月 2022 15:07:01 +0800
Subject: [PATCH] 优化
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightPoleHeelingService.java | 270 ++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 243 insertions(+), 27 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightPoleHeelingService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightPoleHeelingService.java
index e076b29..19b713c 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightPoleHeelingService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightPoleHeelingService.java
@@ -1,11 +1,26 @@
package com.sandu.ximon.admin.service;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.github.pagehelper.PageHelper;
+import com.sandu.common.execption.BusinessException;
+import com.sandu.common.object.BaseConditionVO;
import com.sandu.common.service.impl.BaseServiceImpl;
-import com.sandu.ximon.dao.domain.AirData;
-import com.sandu.ximon.dao.domain.ForHelp;
+import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightPoleHeelingHeartbeatReportInnerFrame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightPoleHeelingOperationReportInnerFrame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5LightPoleHeelingQueryReportInnerFrame;
+import com.sandu.ximon.admin.manager.iot.frame.inner.request.*;
+import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
+import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
+import com.sandu.ximon.admin.manager.iot.rrpc.enums.LightPoleHeelingEnum;
+import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
+import com.sandu.ximon.admin.param.LightPoleHeelingListParam;
+import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.RedisUtils;
+import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
+import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.dao.domain.LightPoleHeeling;
+import com.sandu.ximon.dao.domain.LightPoleHeelingEquipment;
import com.sandu.ximon.dao.mapper.LightPoleHeelingMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -15,34 +30,235 @@
@Service
@AllArgsConstructor
public class LightPoleHeelingService extends BaseServiceImpl<LightPoleHeelingMapper, LightPoleHeeling> {
- /**
- * 鏌ヨ鍏ㄩ儴鐏潌鍊句晶鍛婅
- */
- public List<LightPoleHeeling> listLightPoleHeeling() {
- LambdaQueryWrapper<LightPoleHeeling> wrapper = Wrappers.lambdaQuery(LightPoleHeeling.class);
- List<LightPoleHeeling> list = list(wrapper);
-
- return list;
- }
+ private LightPoleHeelingMapper lightPoleHeelingMapper;
+ private LightPoleHeelingEquipmentService lightPoleHeelingEquipmentService;
/**
* 妯$硦鏌ヨ
*/
- public List<LightPoleHeeling> listLightPoleHeelingByKeyword(String keyword) {
-
- LambdaQueryWrapper<LightPoleHeeling> wrapper = Wrappers.lambdaQuery(LightPoleHeeling.class);
- if (keyword != null) {
- wrapper.like(LightPoleHeeling::getLightPoleName, keyword).or(
- lambdaQueryWrapper -> {
- lambdaQueryWrapper.like(LightPoleHeeling::getLightPoleId, keyword);
- }
- ).or(
- lambdaQueryWrapper -> {
- lambdaQueryWrapper.like(LightPoleHeeling::getWarningNumber, keyword);
- }
- );
+ public List<LightPoleHeeling> listLightPoleHeelingByKeyword(BaseConditionVO baseConditionVO, LightPoleHeelingListParam lightPoleHeelingListParam) {
+ if (baseConditionVO != null) {
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
}
- List<LightPoleHeeling> forHelpList = list(wrapper);
- return forHelpList;
+ if (lightPoleHeelingListParam == null) {
+ lightPoleHeelingListParam = new LightPoleHeelingListParam();
+ }
+
+ //鍏抽敭瀛楀幓闄ょ┖鏍�
+ if (lightPoleHeelingListParam.getKeyword() != null) {
+ lightPoleHeelingListParam.setKeyword(lightPoleHeelingListParam.getKeyword().trim());
+ }
+
+ List<LightPoleHeeling> lightPoleHeelings;
+ if (SecurityUtils.getClientId() == null) {
+ lightPoleHeelings = lightPoleHeelingMapper.listLightPoleHeeling(lightPoleHeelingListParam.getKeyword()
+ , lightPoleHeelingListParam.getProcessingState(), null);
+ } else {
+ lightPoleHeelings = lightPoleHeelingMapper.listLightPoleHeeling(lightPoleHeelingListParam.getKeyword()
+ , lightPoleHeelingListParam.getProcessingState(), SecurityUtils.getUserId());
+ }
+
+ return lightPoleHeelings;
+ }
+
+ /**
+ * 鏍规嵁Mac鑾峰彇鏈�鏂版暟鎹�
+ */
+ public EquipmentInfomation getLightPoleHeelingByMac(String mac) {
+ EquipmentInfomation equipmentInfo = new EquipmentInfomation();
+ equipmentInfo.setEquipmentType("鏉嗕綋鍊炬祴");
+ if (mac == null || mac.trim().length() == 0) {
+ return equipmentInfo;
+ }
+
+ LightPoleHeeling one = getOne(Wrappers.lambdaQuery(LightPoleHeeling.class).eq(LightPoleHeeling::getMac, mac));
+ if (one != null) {
+ equipmentInfo.setEquipmentCreateTime(one.getCreateTime());
+ equipmentInfo.setEquipmentMac(one.getMac());
+
+ }
+ //瀛樺偍璁惧鐘舵�佸埌缂撳瓨
+ String s = RedisUtils.getBean().get(LightPoleHeelingEnum.LIGHT_POLE_HEELING_STATE.getCode() + mac);
+ if (s == null) {
+ equipmentInfo.setEquipmentState("绂荤嚎");
+ } else {
+ equipmentInfo.setEquipmentState("鍦ㄧ嚎");
+ }
+ return equipmentInfo;
+ }
+
+ /**
+ * 鐏潌鍊炬枩蹇冭烦鍖�
+ *
+ * @param deviceName
+ */
+ public A5LightPoleHeelingHeartbeatReportInnerFrame.HeartBeatDataPackage LightPoleHeelingHeartbeatPackage(String deviceName) {
+ LightPoleHeelingHeartbeatPackageReqInnerFrame lightPoleHeelingHeartbeatPackageReqInnerFrame = new LightPoleHeelingHeartbeatPackageReqInnerFrame();
+
+ A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(), lightPoleHeelingHeartbeatPackageReqInnerFrame);
+ System.out.println(a5Frame + " -----a5Frame");
+
+ CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "鏉嗕綋鍊炬枩-蹇冭烦鍖�", a5Frame, commonFrame);
+ System.out.println(commonFrame + " -----commonFrame");
+
+
+ A5LightPoleHeelingHeartbeatReportInnerFrame heartbeatReportInnerFrame
+ = new A5LightPoleHeelingHeartbeatReportInnerFrame().transformFrame(commonFrame.getPayload());
+
+ if (heartbeatReportInnerFrame.isValidate()) {
+
+ //鐏潌鍊炬枩蹇冭烦鍖呬繚瀛樻暟鎹簱
+ saveLightPoleHeelingHeartbeat(deviceName, heartbeatReportInnerFrame.getHeartBeatDataPackage());
+
+ return heartbeatReportInnerFrame.getHeartBeatDataPackage();
+ } else {
+ throw new BusinessException("鏁版嵁鏍¢獙閿欒锛岃閲嶆柊璇锋眰");
+ }
+ }
+
+ /**
+ * 鏌ヨ蹇冭烦鍖呴棿闅旀椂闂�
+ *
+ * @param deviceName
+ */
+ public String QueryIntervalTime(String deviceName) {
+ LightPoleHeelingQueryIntervalTimeReqInnerFrame queryIntervalTimeReqInnerFrame
+ = new LightPoleHeelingQueryIntervalTimeReqInnerFrame();
+
+ A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(), queryIntervalTimeReqInnerFrame);
+ System.out.println(a5Frame + " -----a5Frame");
+
+ CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "鏉嗕綋鍊炬枩-鏌ヨ蹇冭烦鍖呴棿闅旀椂闂�", a5Frame, commonFrame);
+ System.out.println(commonFrame + " -----commonFrame");
+
+
+ A5LightPoleHeelingQueryReportInnerFrame queryReportInnerFrame = new A5LightPoleHeelingQueryReportInnerFrame().transformFrame(commonFrame.getPayload());
+ if (queryReportInnerFrame.isValidate()) {
+ return queryReportInnerFrame.getIntervalTime();
+ } else {
+ throw new BusinessException("鏁版嵁鏍¢獙閿欒锛岃閲嶆柊璇锋眰");
+ }
+ }
+
+ /**
+ * 杞噸鍚�
+ *
+ * @param deviceName
+ */
+ public String RestartLightPoleHeeling(String deviceName) {
+ LightPoleHeelingRestartReqInnerFrame restartReqInnerFrame
+ = new LightPoleHeelingRestartReqInnerFrame();
+
+ A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(), restartReqInnerFrame);
+ System.out.println(a5Frame + " -----a5Frame");
+
+ CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(deviceName, a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(deviceName, "鏉嗕綋鍊炬枩-杞噸鍚�", a5Frame, commonFrame);
+ System.out.println(commonFrame + " -----commonFrame");
+
+
+ A5LightPoleHeelingOperationReportInnerFrame operationReportInnerFrame
+ = new A5LightPoleHeelingOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
+ if (operationReportInnerFrame.isValidate()) {
+ return operationReportInnerFrame.getState();
+ } else {
+ throw new BusinessException("鏁版嵁鏍¢獙閿欒锛岃閲嶆柊璇锋眰");
+ }
+ }
+
+ /**
+ * 璁剧疆蹇冭烦鍖呴棿闅旀椂闂�(绉掞級
+ *
+ * @param devicesName
+ * @param setTime
+ * @return
+ */
+ public String SetHeartbeatPacketTime(String devicesName, int setTime) {
+ if (setTime <= 0) {
+ throw new BusinessException("璁剧疆鐨勫績璺冲寘闂撮殧鏃堕棿閿欒锛�");
+ }
+ LightPoleHeelingSetHeartbeatPacketTimeReqInnerFrame setHeartbeatPacketTimeReqInnerFrame =
+ new LightPoleHeelingSetHeartbeatPacketTimeReqInnerFrame(setTime);
+
+ A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(), setHeartbeatPacketTimeReqInnerFrame);
+ System.out.println(a5Frame + " -----a5Frame");
+
+ CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(devicesName, a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(devicesName, "鏉嗕綋鍊炬枩-璁剧疆蹇冭烦鍖呴棿闅旀椂闂�", a5Frame, commonFrame);
+ System.out.println(commonFrame + " -----commonFrame");
+
+ A5LightPoleHeelingOperationReportInnerFrame operationReportInnerFrame
+ = new A5LightPoleHeelingOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
+ if (operationReportInnerFrame.isValidate()) {
+ return operationReportInnerFrame.getState();
+ } else {
+ throw new BusinessException("鏁版嵁鏍¢獙閿欒锛岃閲嶆柊璇锋眰");
+ }
+ }
+
+ /**
+ * 璁剧疆浼犳劅鍣ㄤ负鍒濆鐘舵��
+ *
+ * @return
+ */
+ public String SetSensorState(String devicesName) {
+ LightPoleHeelingSetSensorStateReqInnerFrame setSensorStateReqInnerFrame =
+ new LightPoleHeelingSetSensorStateReqInnerFrame();
+
+ A5Frame a5Frame = new A5Frame(A5OrderEnum.REQUEST_POLE_MONITOR_DATA.getCode(), setSensorStateReqInnerFrame);
+ System.out.println(a5Frame + " -----a5Frame");
+
+ CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(devicesName, a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(devicesName, "鏉嗕綋鍊炬枩-璁剧疆浼犳劅鍣ㄤ负鍒濆鐘舵��", a5Frame, commonFrame);
+
+ System.out.println(commonFrame + " -----commonFrame");
+
+ A5LightPoleHeelingOperationReportInnerFrame operationReportInnerFrame
+ = new A5LightPoleHeelingOperationReportInnerFrame().transformFrame(commonFrame.getPayload());
+ if (operationReportInnerFrame.isValidate()) {
+ return operationReportInnerFrame.getState();
+ } else {
+ throw new BusinessException("鏁版嵁鏍¢獙閿欒锛岃閲嶆柊璇锋眰");
+ }
+ }
+
+ /**
+ * 淇濆瓨蹇冭烦鍖呮暟鎹�
+ *
+ * @param deviceName
+ * @param heartBeatDataPackage
+ * @return
+ */
+ public boolean saveLightPoleHeelingHeartbeat(String deviceName, A5LightPoleHeelingHeartbeatReportInnerFrame.HeartBeatDataPackage heartBeatDataPackage) {
+
+ LightPoleHeeling lightPoleHeeling = new LightPoleHeeling();
+ lightPoleHeeling.setMac(deviceName);
+ lightPoleHeeling.setTheXAxis(heartBeatDataPackage.getTheXAxis());
+ lightPoleHeeling.setTheYAxis(heartBeatDataPackage.getTheYAxis());
+ lightPoleHeeling.setTheZAxis(heartBeatDataPackage.getTheZAxis());
+ if (Math.abs(heartBeatDataPackage.getTheXAxis()) >= 10 || Math.abs(heartBeatDataPackage.getTheYAxis()) >= 10) {
+ lightPoleHeeling.setWarningLevel(1);//涓�绾ц鍛�
+ } else if ((Math.abs(heartBeatDataPackage.getTheXAxis()) >= 5 && Math.abs(heartBeatDataPackage.getTheXAxis()) < 10)
+ || (Math.abs(heartBeatDataPackage.getTheYAxis()) >= 5 && Math.abs(heartBeatDataPackage.getTheYAxis()) < 10)) {
+ lightPoleHeeling.setWarningLevel(2);//浜岀骇璀﹀憡
+ } else {
+ lightPoleHeeling.setWarningLevel(0);//姝e父
+ }
+
+ //瀛樺偍璁惧鐘舵�佸埌缂撳瓨
+ RedisUtils.getBean().set(LightPoleHeelingEnum.LIGHT_POLE_HEELING_STATE.getCode() + deviceName
+ , heartBeatDataPackage, 300L);
+ /**
+ * 灏嗙伅鏉嗗�炬枩纭欢娣诲姞鍒扮‖浠惰〃
+ */
+ LightPoleHeelingEquipment one = lightPoleHeelingEquipmentService.getOne(Wrappers.lambdaQuery(LightPoleHeelingEquipment.class).eq(LightPoleHeelingEquipment::getMac, deviceName));
+ if (one == null) {
+ LightPoleHeelingEquipment equipment = new LightPoleHeelingEquipment();
+ equipment.setMac(deviceName);
+ }
+
+ return save(lightPoleHeeling);
}
}
--
Gitblit v1.9.3