From 0201c32312f6478b2bde706607c8c6338e9e1d06 Mon Sep 17 00:00:00 2001
From: doum <doum>
Date: 星期三, 27 五月 2026 17:05:29 +0800
Subject: [PATCH] 新增智能电表、空调管理
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalWarningServiceImpl.java | 40 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 1 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalWarningServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalWarningServiceImpl.java
index d499d3b..8a06b32 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalWarningServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwElectricalWarningServiceImpl.java
@@ -35,9 +35,11 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
+import java.util.Set;
import java.util.stream.Collectors;
/**
@@ -98,6 +100,7 @@
}
Map<String, YwElectrical> addressMap = buildElectricalAddressMap();
Map<String, YwElectrical> didMap = buildElectricalDidMap();
+ Set<Integer> affectedElectricalIds = new LinkedHashSet<>();
Date now = new Date();
int addCount = 0;
int updateCount = 0;
@@ -129,6 +132,9 @@
entity.setMsg(item.getMsg());
entity.setEditDate(now);
resolveElectricalId(entity, addressMap, didMap);
+ if (entity.getElectricalId() != null) {
+ affectedElectricalIds.add(entity.getElectricalId());
+ }
if (isNew) {
ywElectricalWarningMapper.insert(entity);
addCount++;
@@ -137,7 +143,8 @@
updateCount++;
}
}
- return "鍚屾瀹屾垚锛氭柊澧炪��" + addCount + "銆戞潯锛屾洿鏂般��" + updateCount + "銆戞潯";
+ int electricalUpdateCount = updateElectricalWarnTypes(affectedElectricalIds, now);
+ return "鍚屾瀹屾垚锛氭柊澧炪��" + addCount + "銆戞潯锛屾洿鏂般��" + updateCount + "銆戞潯锛屽洖鍐欑數琛ㄩ璀︺��" + electricalUpdateCount + "銆戝彴";
} finally {
Constants.DEALING_ELECTRICAL_WARNING_SYNC = false;
}
@@ -285,6 +292,37 @@
}
}
+ /** 鎸夌數琛ㄦ眹鎬诲叏閮ㄦ姤璀︾被鍨嬶紝閫楀彿鍒嗛殧鍥炲啓 warn_type */
+ private int updateElectricalWarnTypes(Set<Integer> affectedElectricalIds, Date editDate) {
+ if (CollectionUtils.isEmpty(affectedElectricalIds)) {
+ return 0;
+ }
+ for (Integer electricalId : affectedElectricalIds) {
+ refreshElectricalWarnType(electricalId, editDate);
+ }
+ return affectedElectricalIds.size();
+ }
+
+ private void refreshElectricalWarnType(Integer electricalId, Date editDate) {
+ List<YwElectricalWarning> warnings = ywElectricalWarningMapper.selectList(new QueryWrapper<YwElectricalWarning>().lambda()
+ .eq(YwElectricalWarning::getElectricalId, electricalId)
+ .eq(YwElectricalWarning::getIsdeleted, Constants.ZERO));
+ LinkedHashSet<Integer> defIds = new LinkedHashSet<>();
+ if (!CollectionUtils.isEmpty(warnings)) {
+ for (YwElectricalWarning warning : warnings) {
+ if (warning.getWarningDefId() != null) {
+ defIds.add(warning.getWarningDefId());
+ }
+ }
+ }
+ String warnType = defIds.stream().map(String::valueOf).collect(Collectors.joining(","));
+ YwElectrical upd = new YwElectrical();
+ upd.setId(electricalId);
+ upd.setWarnType(StringUtils.isBlank(warnType) ? null : warnType);
+ upd.setEditDate(editDate);
+ ywElectricalMapper.updateById(upd);
+ }
+
private YwElectricalWarning findExisting(String deviceAddress, Integer warningDefId, Date startTime) {
return ywElectricalWarningMapper.selectOne(new QueryWrapper<YwElectricalWarning>().lambda()
.eq(YwElectricalWarning::getDeviceAddress, deviceAddress)
--
Gitblit v1.9.3