From 28f1086fd40ef730837690e1346cc968b880cccd Mon Sep 17 00:00:00 2001
From: liuhaonan <31457034@qq.com>
Date: 星期一, 23 五月 2022 17:11:50 +0800
Subject: [PATCH] 单灯任务
---
ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java | 59 +++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
index 908e53a..ca03876 100644
--- a/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
+++ b/ximon-admin/src/main/java/com/sandu/ximon/admin/service/LightTaskService.java
@@ -16,12 +16,10 @@
import com.sandu.common.util.SpringContextHolder;
import com.sandu.ximon.admin.dto.LightTaskDto;
import com.sandu.ximon.admin.dto.SingleLightOrderDto;
-import com.sandu.ximon.admin.manager.iot.frame.A5Frame;
import com.sandu.ximon.admin.manager.iot.frame.FrameBuilder;
import com.sandu.ximon.admin.manager.iot.frame.IRequestFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.request.A5LightTimerReqInnerFrame;
import com.sandu.ximon.admin.manager.iot.frame.inner.response.A5LightTimerRespInnerFrame;
-import com.sandu.ximon.admin.manager.iot.rrpc.dto.CommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.dto.WrapResponseCommonFrame;
import com.sandu.ximon.admin.manager.iot.rrpc.enums.A5OrderEnum;
import com.sandu.ximon.admin.manager.iot.rrpc.mainboard.MainBoardInvokeSyncService;
@@ -139,7 +137,7 @@
}
@Transactional(rollbackFor = Exception.class)
- public boolean updateLightTask(Long taskId, LightTaskParam param) {
+ public int updateLightTask(Long taskId, LightTaskParam param) {
if (StrUtil.length(param.getControlOrder()) % LightTaskParam.REQUEST_ORDER_LENGTH != 0) {
throw new BusinessException("鐏帶鍛戒护鏍煎紡涓嶆纭�");
}
@@ -185,12 +183,16 @@
List<LightTaskPoleRelation> newPoleAll = new ArrayList<>();
+ List<LightTaskPoleRelation> newPoleSuccess = new ArrayList<>();
+ List<LightTaskPoleRelation> newPoleFail = new ArrayList<>();
if (CollectionUtil.isNotEmpty(newPoleIdList)) {
//鏂扮伅鏉嗕笅鍙戞柊浠诲姟
Map<String, List<LightTaskPoleRelation>> newPoleMap = sendControllerFrame(newPoleIdList, lightTask.getFramePayload(), param.getLightAddress());
//newPoleAll闆嗗悎鍚庨潰鐢ㄤ簬瀛樺偍鍏崇郴琛�
newPoleAll = newPoleMap.getOrDefault("all", new ArrayList<>());
+ newPoleSuccess = newPoleMap.getOrDefault("success", new ArrayList<>());
+ newPoleFail = newPoleMap.getOrDefault("fail", new ArrayList<>());
}
List<LightTaskPoleRelation> oldPoleFail = new ArrayList<>();
@@ -203,12 +205,14 @@
}
List<LightTaskPoleRelation> closePoleFail = new ArrayList<>();
+ List<LightTaskPoleRelation> closePoleSuccess = new ArrayList<>();
if (CollectionUtil.isNotEmpty(closeLight)) {
//鎵ц鍏崇伅鍐呭抚
String framePayloadClose = "7f0000007f173b00";
//瑕嗙洊鎿嶄綔鐏潌
Map<String, List<LightTaskPoleRelation>> closePoleMap = sendControllerFrame(closeLight, framePayloadClose, param.getLightAddress());
closePoleFail = closePoleMap.getOrDefault("fail", new ArrayList<>());
+ closePoleSuccess = closePoleMap.getOrDefault("success", new ArrayList<>());
}
//鏈夊け鏁楃殑闇�瑕佷繚瀛樻棫鐨勪换鍕�
@@ -229,12 +233,7 @@
poleCodeList = poleList.stream().map(Pole::getDeviceCode).collect(Collectors.toList());
}
}
- String content = "{浠诲姟ID锛�" + newLightTask.getTaskId()
- + "锛� 浠诲姟鍚嶏細" + newLightTask.getTaskName()
- + "}锛寋鍐呭抚鎸囦护" + newLightTask.getFramePayload()
- + "锛� 鐏潌ID锛�" + param.getPoleIdList().toString()
- + "锛� 鎺у埗鐨勭伅澶村湴鍧�锛�" + param.getLightAddress()
- + " }";
+ String content = "{浠诲姟ID锛�" + newLightTask.getTaskId() + "锛� 浠诲姟鍚嶏細" + newLightTask.getTaskName() + "}锛寋鍐呭抚鎸囦护" + newLightTask.getFramePayload() + "锛� 鐏潌ID锛�" + param.getPoleIdList().toString() + "锛� 鎺у埗鐨勭伅澶村湴鍧�锛�" + param.getLightAddress() + " }";
StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "缂栬緫璺伅浠诲姟", content);
/**
* 缂栬緫璺伅浠诲姟鏃ュ織璁板綍缁撴潫
@@ -264,6 +263,9 @@
all.addAll(closePoleFail);
+
+
+
List<Long> allPoleId = new ArrayList<>();
allPoleId.addAll(poleIdList);
allPoleId.addAll(oldList);
@@ -274,16 +276,45 @@
/**
* 涓嬪彂璺伅浠诲姟鏃ュ織璁板綍寮�濮�
*/
- String content1 = "{浠诲姟ID锛�" + newLightTask.getTaskId()
- + "锛� 浠诲姟鍚嶏細" + newLightTask.getTaskName()
- + "}," + " 鐏潌ID锛�" + param.getPoleIdList().toString()
- + " }";
+ String content1 = "{浠诲姟ID锛�" + newLightTask.getTaskId() + "锛� 浠诲姟鍚嶏細" + newLightTask.getTaskName() + "}," + " 鐏潌ID锛�" + param.getPoleIdList().toString() + " }";
StoreOperationRecordsUtils.storeOperationData(poleCodeList, null, "涓嬪彂璺伅浠诲姟", content1);
/**
* 涓嬪彂璺伅浠诲姟鏃ュ織璁板綍缁撴潫
*/
- return true;
+// if (oldPoleFail.isEmpty() && closePoleFail.isEmpty()) {
+// //鍏ㄩ儴鎴愬姛
+// return 0;
+// } else if (!closeLight.isEmpty() || !oldPoleFail.isEmpty()) {
+// //鍏崇伅澶辫触 鎴栬�呰鐩栦换鍔″け璐�
+// return 1;
+// } else if (newPoleSuccess.isEmpty() && oldPoleSuccess.isEmpty() && closeSuccess.isEmpty()) {
+// //缂栬緫鍏ㄩ儴澶辫触
+// return 2;
+// } else {
+// //鍏朵粬鎯呭喌
+// return -1;
+// }
+
+// if (newPoleFail.isEmpty() && oldPoleFail.isEmpty() && closePoleFail.isEmpty()) {
+// //缂栬緫鎴愬姛
+// return 0;
+// } else if (newPoleSuccess.isEmpty() && oldPoleSuccess.isEmpty() && closePoleSuccess.isEmpty()) {
+// //缂栬緫澶辫触, 鏂版棫浠诲姟閮芥湁
+// return 1;
+// } else if ((newPoleSuccess.isEmpty() && newPoleFail.isEmpty())) {
+// if (oldPoleSuccess.isEmpty() && closePoleSuccess.isEmpty()) {
+// //缂栬緫澶辫触,淇濈暀鍘熷厛浠诲姟娌℃湁鏀瑰彉,鍙湁鏃т换鍔�
+// return 2;
+// } else {
+// //缂栬緫閮ㄥ垎鎴愬姛閮ㄥ垎澶辫触,鏂版棫浠诲姟鍚屾椂瀛樺湪
+// return 3;
+// }
+// } else {
+// return -1;
+// }
+
+ return 0;
}
--
Gitblit v1.9.3