From 19d542ddaa4a2d5a737912505e3195948ffa9ebe Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期四, 04 八月 2022 10:48:34 +0800
Subject: [PATCH] changes
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java | 149 ++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 134 insertions(+), 15 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
index 0716675..3c19b5d 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LedPlayerEntityService.java
@@ -2,13 +2,16 @@
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.common.util.SpringContextHolder;
import com.sandu.ximon.admin.security.SecurityUtils;
+import com.sandu.ximon.admin.utils.StoreOperationRecordsUtils;
import com.sandu.ximon.admin.utils.VnnoxAPIUtil;
+import com.sandu.ximon.admin.vo.EquipmentInfomation;
import com.sandu.ximon.dao.domain.LedPlayerEntity;
-import com.sandu.ximon.dao.domain.PoleBinding;
+import com.sandu.ximon.dao.enums.OrderByEnums;
import com.sandu.ximon.dao.mapper.LedPlayerEntityMapper;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
@@ -37,8 +40,29 @@
return getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getPlayerId, playerId));
}
+ /**
+ * 璇虹摝璁惧鏂板
+ *
+ * @param ledPlayerEntity
+ * @return
+ */
public boolean saveLed(LedPlayerEntity ledPlayerEntity) {
- return ledPlayerEntityMapper.saveLed(ledPlayerEntity);
+ boolean b = ledPlayerEntityMapper.saveLed(ledPlayerEntity);
+ /**
+ * 璇虹摝璁惧鏂板 鏃ュ織璁板綍寮�濮�
+ */
+ List<String> listCode = new ArrayList<>(1);
+ listCode.add(ledPlayerEntity.getSn());
+ String content = "{ 璁惧id:" + ledPlayerEntity.getId() + "璁惧code锛�" + ledPlayerEntity.getSn()
+ + "璇虹摝playId:" + ledPlayerEntity.getPlayerId()
+ + "璇虹摝璁惧鍚嶇О:" + ledPlayerEntity.getName() +
+ "}";
+
+ StoreOperationRecordsUtils.storeOperationData(listCode, null, "璇虹摝璁惧鏂板", content);
+ /**
+ * 璇虹摝璁惧鏂板 鏃ュ織璁板綍缁撴潫
+ */
+ return b;
}
@@ -48,7 +72,7 @@
public LedPlayerEntity getBySnAndPlayerSn(String sn) {
LedPlayerEntity one = getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, sn));
if (one == null) {
- throw new RuntimeException("璇虹摝璁惧涓嶅瓨鍦�");
+ throw new BusinessException("璇虹摝璁惧涓嶅瓨鍦�");
}
List list = new ArrayList();
list.add(one);
@@ -62,10 +86,81 @@
return one;
}
+ /**
+ * 棣栭〉鐏潌缁戝畾淇℃伅
+ */
+ public EquipmentInfomation getBySnAndPlayerSnInfo(String sn) {
+ EquipmentInfomation equipmentInfo = new EquipmentInfomation();
+ equipmentInfo.setEquipmentType("璇虹摝LED");
+ if (sn == null || sn.trim().length() == 0) {
+ return equipmentInfo;
+ }
- public List<LedPlayerEntity> ledPlayerEntityList(BaseConditionVO baseConditionVO, String keyword) {
+ LedPlayerEntity one = getOne(Wrappers.lambdaQuery(LedPlayerEntity.class).eq(LedPlayerEntity::getSn, sn));
+ if (one == null) {
+ return equipmentInfo;
+ }
+ List<LedPlayerEntity> list = new ArrayList<>();
+ list.add(one);
+ List<LedPlayerEntity> ledPlayerEntities = vnnoxAPIUtil.syncCurrentInfo(list);
+ Integer onlineStatus = ledPlayerEntities.get(0).getOnlineStatus();
+ if (one != null) {
+ equipmentInfo.setEquipmentMac(one.getSn());
+ equipmentInfo.setEquipmentName(one.getName());
+ if (onlineStatus == 0) {
+ equipmentInfo.setEquipmentState("鍦ㄧ嚎");
+ } else {
+ equipmentInfo.setEquipmentState("绂荤嚎");
+ }
+ }
+
+ return equipmentInfo;
+ }
+
+
+ /**
+ * 璇虹摝鍒楄〃
+ *
+ * @param baseConditionVO
+ * @param keyword
+ * @param order
+ * @param seq
+ * @return
+ */
+ public List<LedPlayerEntity> ledPlayerEntityList(BaseConditionVO baseConditionVO, String keyword, Integer order, Integer seq) {
+ //鎺掑簭瀛楁
+ String orderByResult = OrderByEnums.VNNOX_ID.getCode();
+ //姝e簭銆佸�掑彊
+ String orderBySeq = OrderByEnums.ASC.getCode();
+ if (order != null) {
+ switch (order) {
+ case 1:
+ orderByResult = OrderByEnums.VNNOX_POLE_NAME.getCode();
+ break;
+ case 2:
+ orderByResult = OrderByEnums.VNNOX_CREATE_TIMESTAMP.getCode();
+ break;
+ default:
+ }
+ }
+ if (seq != null) {
+ switch (seq) {
+ case 1:
+ orderBySeq = OrderByEnums.ASC.getCode();
+ break;
+ case 2:
+ orderBySeq = OrderByEnums.DESC.getCode();
+ break;
+ default:
+ break;
+ }
+ }
+ //鎺掑簭鏂瑰紡
+ String orderBy = orderByResult + " " + orderBySeq;
+
+
if (baseConditionVO != null) {
- PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize());
+ PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize(), orderBy);
}
List<LedPlayerEntity> list;
//瓒呯
@@ -77,14 +172,38 @@
return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
}
-// public List<LedPlayerEntity> ledPlayerEntityList() {
-// List<LedPlayerEntity> list;
-// //瓒呯
-// if (SecurityUtils.getClientId() == null) {
-// list = ledPlayerEntityMapper.ledPlayerEntityList(null, null);
-// } else {
-// list = ledPlayerEntityMapper.ledPlayerEntityList(null, SecurityUtils.getUserId());
-// }
-// return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
-// }
+ /**
+ * 璇虹摝鍒楄〃锛堢敤浜庨椤垫暟鎹粺璁★級
+ *
+ * @return
+ */
+ public List<LedPlayerEntity> ledPlayerEntityListOnHome() {
+ List<LedPlayerEntity> list;
+ //瓒呯
+ if (SecurityUtils.getClientId() == null) {
+ list = ledPlayerEntityMapper.ledPlayerEntityList(null, null);
+ } else {
+ list = ledPlayerEntityMapper.ledPlayerEntityList(null, SecurityUtils.getUserId());
+ }
+ return list == null ? new ArrayList<>() : list;
+ }
+
+ /**
+ * 璇虹摝鍒楄〃锛堢敤浜庣粦瀹氾級
+ *
+ * @param keyword
+ * @return
+ */
+ public List<LedPlayerEntity> ledPlayerEntityListOnBinding(String keyword) {
+
+ List<LedPlayerEntity> list;
+ //瓒呯
+ if (SecurityUtils.getClientId() == null) {
+ list = ledPlayerEntityMapper.ledPlayerEntityListOnBinding(keyword, null);
+ } else {
+ list = ledPlayerEntityMapper.ledPlayerEntityListOnBinding(keyword, SecurityUtils.getUserId());
+ }
+ return SpringContextHolder.getBean(VnnoxService.class).setCacheInfo(vnnoxAPIUtil.syncCurrentInfo(list));
+ }
+
}
--
Gitblit v1.9.3