From bfce748e37a753c729e15dd233600379f504d019 Mon Sep 17 00:00:00 2001
From: zhanzhiqin <895896009@qq.com>
Date: 星期四, 28 四月 2022 13:59:28 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java | 168 +++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 149 insertions(+), 19 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
index f64b1b9..21791b3 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/VnnoxService.java
@@ -2,23 +2,27 @@
import com.sandu.common.execption.BusinessException;
import com.sandu.ximon.admin.config.VnnoxConstant;
+import com.sandu.ximon.admin.dto.nova.AirDataProgram;
+import com.sandu.ximon.admin.dto.nova.PlayerLayout;
+import com.sandu.ximon.admin.dto.nova.PlayerPage;
+import com.sandu.ximon.admin.dto.nova.PlayerWidget;
+import com.sandu.ximon.admin.manager.iot.frame.inner.report.A5AtmosphereHeartbeatReportInnerFrame;
import com.sandu.ximon.admin.utils.RedisUtils;
import com.sandu.ximon.admin.utils.VnnoxAPIUtil;
+import com.sandu.ximon.admin.utils.VnnoxProgramAPIUtil;
import com.sandu.ximon.admin.utils.request.VnnoxScreenStatusType;
import com.sandu.ximon.admin.utils.response.VnnoxPlayerListResponse;
import com.sandu.ximon.admin.utils.response.VnnoxPlayerResponse;
import com.sandu.ximon.admin.utils.response.VnnoxResult;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
+import com.sandu.ximon.dao.domain.LedPlayerInfoEntity;
import com.sandu.ximon.dao.domain.LedV2RegisterResultEntity;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.net.URISyntaxException;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -30,12 +34,14 @@
@AllArgsConstructor
public class VnnoxService {
- // @Autowired
+ // @Autowired
private VnnoxAPIUtil vnnoxAPIUtil;
- // @Autowired
+ // @Autowired
private RedisUtils redisUtils;
- // @Autowired
+ // @Autowired
private LedPlayerEntityService ledPlayerEntityService;
+ // @Autowired
+ private VnnoxProgramAPIUtil vnnoxProgramAPIUtil;
/**
* 璁惧鏍¢獙娉ㄥ唽
@@ -44,7 +50,7 @@
* @return
*/
@Transactional(rollbackFor = Exception.class)
- public LedV2RegisterResultEntity validateSN(String name,String sn) throws URISyntaxException {
+ public LedV2RegisterResultEntity validateSN(String name, String sn) throws URISyntaxException {
LedV2RegisterResultEntity ledV2RegisterResultEntity = new LedV2RegisterResultEntity();
// 鍒ゆ柇鏁版嵁搴撴槸鍚﹀瓨鍦紝鑻ヤ笉瀛樺湪锛屽垽鏂槸鍚﹀凡缁忔敞鍐屽埌Vnnox鏈嶅姟鍣�
@@ -61,13 +67,13 @@
Integer limit = 100;
List<VnnoxPlayerResponse> playerList;
// 鑾峰彇Vnnox鏈嶅姟鍣ㄥ垪琛�
- VnnoxPlayerListResponse response = vnnoxAPIUtil.getPlayerList(limit, page,name);
+ VnnoxPlayerListResponse response = vnnoxAPIUtil.getPlayerList(limit, page, name);
playerList = response.getRows();
Integer total = response.getTotal() - limit;
while (total > 0) {
page = page + 1;
total = total - limit;
- response = vnnoxAPIUtil.getPlayerList(limit, page,name);
+ response = vnnoxAPIUtil.getPlayerList(limit, page, name);
playerList.addAll(response.getRows());
}
ledPlayerEntity = new LedPlayerEntity();
@@ -141,6 +147,7 @@
}
+ //鎴睆
public Map<String, String> getScreenShotUrl(Integer id) {
Map<String, String> map = new HashMap();
@@ -182,25 +189,148 @@
return map;
}
+// //閲嶅惎
+// public VnnoxResult reboot(List<LedPlayerEntity> playerList) {
+// return vnnoxAPIUtil.reboot(
+// playerList.stream().map(
+// item -> item.getPlayerId()
+// ).collect(Collectors.toList())
+// );
+// }
- public VnnoxResult reboot(List<LedPlayerEntity> playerList) {
- return vnnoxAPIUtil.reboot(
- playerList.stream().map(
- item -> item.getPlayerId()
- ).collect(Collectors.toList())
- );
+ //閲嶅惎
+ public VnnoxResult reboot(List<String> playerList) {
+ return vnnoxAPIUtil.reboot(playerList);
}
- public boolean updateDataName(Long id, String name){
+ /**
+ * 鍚屾鎾斁
+ *
+ * @param
+ * @return
+ */
+ public VnnoxResult syncPlay(List<String> playerList, Integer option) {
+ return vnnoxAPIUtil.syncPlay(playerList, option);
+ }
+
+ /**
+ * 瀵规椂
+ *
+ * @param
+ * @return
+ */
+ public VnnoxResult ntpSync(List<String> playerList, boolean enable) {
+ return vnnoxAPIUtil.ntpSync(playerList, enable);
+ }
+
+
+ public boolean updateDataName(Long id, String name) {
LedPlayerEntity byId = ledPlayerEntityService.getById(id);
- if(byId==null){
+ if (byId == null) {
throw new BusinessException("鏈壘鍒拌璁惧");
}
- LedPlayerEntity led=new LedPlayerEntity();
+ LedPlayerEntity led = new LedPlayerEntity();
led.setId(id);
led.setName(name);
return ledPlayerEntityService.updateById(led);
}
+ /**
+ * 鑾峰彇缂撳瓨鏁版嵁
+ *
+ * @param list
+ * @return
+ */
+ public List<LedPlayerEntity> setCacheInfo(List<LedPlayerEntity> list) {
+ for (LedPlayerEntity playerEntity : list) {
+ String playerId = playerEntity.getPlayerId();
+ LedPlayerInfoEntity cache = new LedPlayerInfoEntity();
+ // 璁剧疆灞忓箷鐘舵��
+ String result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_STATUS + playerId);
+ Integer screenStatus = 1;
+ if (null != result) {
+ screenStatus = Integer.parseInt(result);
+ }
+ cache.setScreenStatus(screenStatus);
+ // 璁剧疆灞忓箷闊抽噺
+ result = redisUtils.get(VnnoxConstant.REDIS_VOL + playerId);
+ Integer vol = 0;
+ if (null != result) {
+ vol = Integer.parseInt(result);
+ }
+ cache.setVol(vol);
+ // 璁剧疆灞忓箷浜害
+ result = redisUtils.get(VnnoxConstant.REDIS_BRIGHTNESS + playerId);
+ Integer brightness = 0;
+ if (null != result) {
+ brightness = Integer.parseInt(result);
+ }
+ cache.setBrightness(brightness);
+
+ // 璁剧疆缂╃暐鍥捐闂矾寰�
+ result = redisUtils.get(VnnoxConstant.REDIS_SCREEN_SHOT + playerId);
+ System.out.println(playerId + "鐨勮矾寰勭粨鏋�:-----------------------------" + result);
+ if (null != result) {
+ playerEntity.setScreenShotUrl(result);
+ } else {
+ playerEntity.setScreenShotUrl("");
+ }
+
+ playerEntity.setPlayerInfo(cache);
+ }
+ return list;
+ }
+
+
+ public VnnoxResult publishWaterData(String playerId, A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
+ List<String> playerIds = new ArrayList<>();
+ playerIds.add(playerId);
+ AirDataProgram playerProgram = new AirDataProgram();
+ playerProgram.setPlayerIds(playerIds);
+ PlayerPage playerPage = new PlayerPage();
+ playerPage.setName("AirData page");
+ List<PlayerWidget> widgetList = generateWaterAndSensorWidget(poleSensorEntity);
+ playerPage.setWidgets(widgetList);
+ List<PlayerPage> list = new ArrayList<>();
+ list.add(playerPage);
+ playerProgram.setPages(list);
+ playerProgram.setNoticeUrl(VnnoxConstant.NOTIFY_URL);
+
+ return vnnoxProgramAPIUtil.normalProgram(playerProgram).getData();
+ }
+
+
+ private List<PlayerWidget> generateWaterAndSensorWidget(A5AtmosphereHeartbeatReportInnerFrame.HeartBeatDataPackage poleSensorEntity) {
+ List widgetList = new ArrayList<>();
+ List<String> list = new ArrayList<>();
+// if (Objects.nonNull(waterDataEntity)) {
+// list.add("姘磋川鐜鐩戞祴瀹炴椂鏁版嵁锛�");
+// list.add("ph锛�"+waterDataEntity.getPh());
+// list.add("婧惰В姘э細"+waterDataEntity.getDoData() + "(mg/L)");
+// list.add("鐢靛鐜囷細"+waterDataEntity.getEc() + "(10^(-6)S)");
+// list.add("娴婂害锛�"+waterDataEntity.getNtu() + "NTU");
+// }
+ if (Objects.nonNull(poleSensorEntity)) {
+// list.add("鐜鐩戞祴锛�");
+ list.add("娓╁害锛�" + poleSensorEntity.getTemperature() + "掳");
+ list.add("婀垮害锛�" + poleSensorEntity.getHumidity() + "%");
+ list.add("pm25锛�" + poleSensorEntity.getPm25() + "渭g/m鲁");
+ list.add("pm10锛�" + poleSensorEntity.getPm10() + "渭g/m鲁");
+ list.add("鐢查啗锛�" + poleSensorEntity.getEch2o() + "渭g/m鲁");
+ list.add("CO2锛�" + poleSensorEntity.getCo2() + "ppm");
+ }
+
+ widgetList.add(new PlayerWidget().generateScrollUpTextWidget(
+ "water",
+ 1,
+ 100000L,
+ list,
+ "#FFFFFF",
+ 15,
+ new PlayerLayout("0%", "5%", "100%", "100%")
+ ));
+
+ return widgetList;
+ }
}
--
Gitblit v1.9.3