From c2e93e1d046878fab50eb5379470baff822b493e Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期一, 16 五月 2022 16:35:41 +0800
Subject: [PATCH] 日志
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java | 150 +++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 123 insertions(+), 27 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
index 5f5ad5a..949e42e 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/C3ChargingService.java
@@ -18,13 +18,14 @@
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
import com.sandu.ximon.admin.param.C3ChargingAddParam;
import com.sandu.ximon.admin.param.C3ChargingParam;
-import com.sandu.ximon.admin.param.PoleBindingParam;
+import com.sandu.ximon.admin.security.SecurityUtils;
import com.sandu.ximon.admin.utils.LogUtils;
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.bo.C3ChargingBo;
import com.sandu.ximon.dao.domain.C3mCharging;
import com.sandu.ximon.dao.domain.C3mChargingCharge;
-import com.sandu.ximon.dao.domain.Pole;
import com.sandu.ximon.dao.domain.PoleBinding;
import com.sandu.ximon.dao.mapper.C3mChargingMapper;
import lombok.AllArgsConstructor;
@@ -56,7 +57,7 @@
* @return 鏄惁鎴愬姛
*/
public boolean updateReportState(String deviceName, String c3Mac, String statusBit, String deviceTemperature) {
- C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getPoleDevicesCode, deviceName));
+ C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, c3Mac));
if (one != null) {
// one.setStatusBit(Integer.valueOf(statusBit));
one.setDeviceTemperature(deviceTemperature);
@@ -107,23 +108,23 @@
c3mChargingChargeService.initCharge((c3mCharging1.getC3Id()).intValue());
}
}
- /**
- * 娣诲姞缁戝畾鍏崇郴寮�濮�
- */
- Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName));
- if (pole == null) {
- Pole pole1 = new Pole();
- pole1.setDeviceCode(deviceName);
- pole1.setPoleName(deviceName);
- pole1.setPoleCode(poleService.generatePoleCode());
- poleService.save(pole1);
- }
-
- Long poleId = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName)).getId();
- PoleBindingParam poleBindingParam = new PoleBindingParam();
- poleBindingParam.setDeviceType(2);
- poleBindingParam.setDeviceCode(mcuUdid);
- bindingService.bindPole(poleId, poleBindingParam);
+// /**
+// * 娣诲姞缁戝畾鍏崇郴寮�濮�
+// */
+// Pole pole = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName));
+// if (pole == null) {
+// Pole pole1 = new Pole();
+// pole1.setDeviceCode(deviceName);
+// pole1.setPoleName(deviceName);
+// pole1.setPoleCode(poleService.generatePoleCode());
+// poleService.save(pole1);
+// }
+//
+// Long poleId = poleService.getOne(Wrappers.lambdaQuery(Pole.class).eq(Pole::getDeviceCode, deviceName)).getId();
+// PoleBindingParam poleBindingParam = new PoleBindingParam();
+// poleBindingParam.setDeviceType(2);
+// poleBindingParam.setDeviceCode(mcuUdid);
+// bindingService.bindPole(poleId, poleBindingParam);
/**
* 娣诲姞缁戝畾鍏崇郴缁撴潫
@@ -183,7 +184,9 @@
* @return
*/
public List<C3ChargingBo> getC3ChargingListByKeyword(BaseConditionVO baseConditionVO, C3ChargingParam c3ChargingParam) {
- PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+ if (baseConditionVO != null) {
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+ }
if (c3ChargingParam == null) {
c3ChargingParam = new C3ChargingParam();
}
@@ -193,11 +196,21 @@
c3ChargingParam.setKeyword(c3ChargingParam.getKeyword().trim());
}
- List<C3ChargingBo> c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword());
+ List<C3ChargingBo> c3ChargingBoList;
+ if (SecurityUtils.getClientId() == null) {
+ c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword(), null);
+ } else {
+ c3ChargingBoList = c3mChargingMapper.listC3mChargingDto(c3ChargingParam.getKeyword(), SecurityUtils.getUserId());
+ }
for (C3ChargingBo one : c3ChargingBoList) {
String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac());
if (s != null) {
- one.setStatusBit(1);
+ try {
+ A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
+ one.setStatusBit((Integer.valueOf(beatDataPackage.getStatusBit())));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
} else {
one.setStatusBit(0);
}
@@ -215,11 +228,68 @@
C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, udid));
String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac());
if (s != null) {
- one.setStatusBit(1);
+ try {
+ A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
+ one.setStatusBit((Integer.valueOf(beatDataPackage.getStatusBit())));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
} else {
one.setStatusBit(0);
}
return one;
+ }
+
+ /**
+ * 棣栭〉鐏潌缁戝畾淇℃伅
+ *
+ * @return
+ */
+ public EquipmentInfomation getByC3MacInfo(String udid) {
+ EquipmentInfomation equipmentInfo = new EquipmentInfomation();
+ equipmentInfo.setEquipmentType("C3鍏呯數妗�");
+ if (udid == null || udid.trim().length() == 0) {
+ return equipmentInfo;
+ }
+ C3mCharging one = getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, udid));
+ if (one != null) {
+ String s = RedisUtils.getBean().get(C3mRedisConstant.C3_STATUS.getCode() + one.getC3Mac());
+ if (s != null) {
+ try {
+ A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage beatDataPackage = JSON.parseObject(s, A5C3HeartbeatReportInnerFrame.HeartBeatDataPackage.class);
+ switch (beatDataPackage.getStatusBit()) {
+ case "1":
+ equipmentInfo.setEquipmentState("绌洪棽");
+ break;
+ case "2":
+ equipmentInfo.setEquipmentState("鍏呯數涓�");
+ break;
+ case "3":
+ equipmentInfo.setEquipmentState("鍏呯數涓柇锛岀瓑寰呮湇鍔″櫒纭");
+ break;
+ case "4":
+ equipmentInfo.setEquipmentState("鍏呯數缁撴潫锛岀瓑寰呮湇鍔″櫒纭");
+ break;
+ case "5":
+ equipmentInfo.setEquipmentState("鏈夋晠闅�");
+ break;
+ case "6":
+ equipmentInfo.setEquipmentState("涓庡厖鐢垫々瀵规帴涓�");
+ break;
+ default:
+ equipmentInfo.setEquipmentState("鏈煡");
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } else {
+ equipmentInfo.setEquipmentState("绂荤嚎");
+ }
+ equipmentInfo.setEquipmentCreateTime(one.getUpdateTime());
+ equipmentInfo.setEquipmentMac(one.getMcuUdid());
+ equipmentInfo.setEquipmentName(one.getC3Name());
+ }
+ return equipmentInfo;
}
@@ -242,6 +312,7 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-蹇冭烦鍖�", a5Frame, commonFrame);
System.out.println(commonFrame + " -----commonFrame");
@@ -275,7 +346,7 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
-
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-蹇冭烦鍖�", a5Frame, commonFrame);
System.out.println(commonFrame + " -----commonFrame");
A5C3OperationReportInnerFrame operationReportInnerFrame = new A5C3OperationReportInnerFrame().transformFrame(commonFrame.getPayload());
@@ -305,6 +376,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-鍚屾缁撴潫", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -333,6 +406,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-浜岀淮鐮�", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -362,6 +437,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-鐗堟湰鏌ヨ", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -391,6 +468,7 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-鏌ヨ蹇冭烦鍖呴棿闅旀椂闂�", a5Frame, commonFrame);
System.out.println(commonFrame + " -----commonFrame");
@@ -420,6 +498,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-鏌ヨ鐢靛帇/鐢垫祦甯告暟", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -449,6 +529,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-鏌ヨ鍦板潃", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -478,6 +560,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-鏌ヨ鏁呴殰鐮�", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -507,6 +591,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-璇诲彇蹇冭烦鍖�", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -540,6 +626,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-璁剧疆蹇冭烦鍖呴棿闅旀椂闂�", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -571,6 +659,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-璁剧疆鐢靛帇/鐢垫祦甯告暟", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -611,6 +701,8 @@
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-璁剧疆鍦板潃", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -648,6 +740,7 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-璁剧疆鏃ュ巻", a5Frame, commonFrame);
System.out.println(commonFrame + " -----commonFrame");
@@ -679,6 +772,7 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-娓呴櫎鏁呴殰鐮佷笂鎶�", a5Frame, commonFrame);
System.out.println(commonFrame + " -----commonFrame");
@@ -710,6 +804,7 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-鎭㈠鍑哄巶璁剧疆", a5Frame, commonFrame);
System.out.println(commonFrame + " -----commonFrame");
@@ -738,7 +833,8 @@
throw new BusinessException("C3鍏呯數妗╃‖浠秏cu_udid涓嶅瓨鍦�");
}
CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC(c3mCharging.getPoleDevicesCode(), a5Frame);
-// CommonFrame commonFrame = MainBoardInvokeSyncService.getInstance().sendRRPC("32313243305008ff1a06ffff", a5Frame);
+ StoreOperationRecordsUtils.storeInnerFrameData(c3Mac, "C3甯�-杞噸鍚�", a5Frame, commonFrame);
+
System.out.println(commonFrame + " -----commonFrame");
@@ -789,7 +885,7 @@
if (one == null) {
throw new BusinessException("鏈壘鍒扮粦瀹氬叧绯�");
}
- return getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getC3Mac, one.getDeviceCode()));
+ return getOne(Wrappers.lambdaQuery(C3mCharging.class).eq(C3mCharging::getMcuUdid, one.getDeviceCode()));
}
--
Gitblit v1.9.3