diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/IMsOperationLogService.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/IMsOperationLogService.java
index 62dd1b07..85c9882a 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/IMsOperationLogService.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/IMsOperationLogService.java
@@ -18,4 +18,18 @@ public interface IMsOperationLogService {
* @param source 操作来源
*/
void recordOperationLog(String tableName, String recordId, String operation, String source);
+
+ /**
+ * 通用修改操作详情日志(含字段级变更详情)
+ *
+ * 通过反射遍历实体所有字段,对比修改前后的值差异,
+ * 将每个变更字段记录为一条操作日志详情。
+ *
+ * @param tableName 表名
+ * @param before 修改前的实体
+ * @param after 修改后的实体
+ * @param source 操作来源
+ * @param 实体类型
+ */
+ void recordModifyDetailLog(String tableName, T before, T after, String source);
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/MsOperationLogServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/MsOperationLogServiceImpl.java
index b10e282b..b4854359 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/MsOperationLogServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/MsOperationLogServiceImpl.java
@@ -399,6 +399,45 @@ public class MsOperationLogServiceImpl implements IMsOperationLogService {
msOperationLogMapper.insert(log);
}
+ @Override
+ public void recordModifyDetailLog(String tableName, T before, T after, String source) {
+ if (before == null || after == null) {
+ return;
+ }
+ String recordId = getStcd(before);
+ MsOperationLog mainLog = buildMainLog(tableName, recordId, "修改", source);
+ msOperationLogMapper.insert(mainLog);
+
+ List details = new ArrayList<>();
+ Set processedColumns = new HashSet<>();
+ Class> entityClass = before.getClass();
+
+ for (Field field : entityClass.getDeclaredFields()) {
+ if (shouldSkipField(field)) {
+ continue;
+ }
+ field.setAccessible(true);
+ String columnName = resolveColumnName(field);
+ if (processedColumns.contains(columnName)) {
+ continue;
+ }
+ Object oldValue = getFieldValue(field, before);
+ Object newValue = getFieldValue(field, after);
+
+ //如果新值是null,则不记录
+ if(newValue == null){
+ continue;
+ }
+ if (equalsValue(oldValue, newValue)) {
+ continue;
+ }
+ details.add(buildGenericDetail(mainLog.getId(), tableName, recordId, columnName,
+ oldValue, newValue, "修改字段值"));
+ processedColumns.add(columnName);
+ }
+ batchInsertDetails(details);
+ }
+
private MsOperationLogDetail buildDetail(String mainId,
String stationCode,
String fieldCode,
@@ -422,9 +461,41 @@ public class MsOperationLogServiceImpl implements IMsOperationLogService {
}
private void batchInsertDetails(List details) {
+ if (details == null || details.isEmpty()) {
+ return;
+ }
msOperationLogDetailMapper.insert(details);
}
+ /**
+ * 通过反射获取实体的 stcd(记录ID)
+ */
+ private String getStcd(T entity) {
+ try {
+ return (String) entity.getClass().getMethod("getStcd").invoke(entity);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ /**
+ * 构建通用的操作日志详情(不含字典名称解析)
+ */
+ private MsOperationLogDetail buildGenericDetail(String mainId, String tableName,
+ String stationCode, String fieldCode,
+ Object oldValue, Object newValue, String remark) {
+ MsOperationLogDetail detail = new MsOperationLogDetail();
+ detail.setMainId(mainId);
+ detail.setTableName(tableName);
+ detail.setStationCode(stationCode);
+ detail.setFieldCode(fieldCode);
+ detail.setFieldMeaning(fieldCode);
+ detail.setOldValueCode(formatValue(oldValue));
+ detail.setNewValueCode(formatValue(newValue));
+ detail.setRemark(remark);
+ return detail;
+ }
+
private boolean shouldSkipField(Field field) {
if (Modifier.isStatic(field.getModifiers())) {
return true;
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdAiboxBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdAiboxBHServiceImpl.java
index 525f718f..b456b322 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdAiboxBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdAiboxBHServiceImpl.java
@@ -80,7 +80,7 @@ public class SdAiboxBHServiceImpl extends ServiceImpl impleme
SdDwBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdEqBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdEqBHServiceImpl.java
index 91e4793e..e800a289 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdEqBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdEqBHServiceImpl.java
@@ -79,7 +79,7 @@ public class SdEqBHServiceImpl extends ServiceImpl impleme
SdEqBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFbrdBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFbrdBHServiceImpl.java
index fe3134c8..f288fb96 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFbrdBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFbrdBHServiceImpl.java
@@ -76,7 +76,7 @@ public class SdFbrdBHServiceImpl extends ServiceImpl i
SdFbrdBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFhbtBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFhbtBHServiceImpl.java
index 2d6f26fa..92f4b4ae 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFhbtBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdFhbtBHServiceImpl.java
@@ -79,7 +79,7 @@ public class SdFhbtBHServiceImpl extends ServiceImpl i
SdFhbtBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOpinfoBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOpinfoBHServiceImpl.java
index fb3e0d02..b996374a 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOpinfoBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOpinfoBHServiceImpl.java
@@ -79,7 +79,7 @@ public class SdOpinfoBHServiceImpl extends ServiceImpl i
SdOtteBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOtweBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOtweBHServiceImpl.java
index 94deb103..c03ad298 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOtweBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdOtweBHServiceImpl.java
@@ -75,7 +75,7 @@ public class SdOtweBHServiceImpl extends ServiceImpl i
SdOtweBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdSonarBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdSonarBHServiceImpl.java
index 80827689..deb8bc2c 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdSonarBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdSonarBHServiceImpl.java
@@ -79,7 +79,7 @@ public class SdSonarBHServiceImpl extends ServiceImpl impleme
SdTeBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVaBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVaBHServiceImpl.java
index b7868d86..52690f51 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVaBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVaBHServiceImpl.java
@@ -78,7 +78,7 @@ public class SdVaBHServiceImpl extends ServiceImpl impleme
SdVaBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVpBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVpBHServiceImpl.java
index f52dee58..b06d79c2 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVpBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdVpBHServiceImpl.java
@@ -78,7 +78,7 @@ public class SdVpBHServiceImpl extends ServiceImpl impleme
SdVpBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWeBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWeBHServiceImpl.java
index abb7d382..36044706 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWeBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWeBHServiceImpl.java
@@ -77,7 +77,7 @@ public class SdWeBHServiceImpl extends ServiceImpl impleme
SdWeBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWqBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWqBHServiceImpl.java
index d52e2640..c0cc1e55 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWqBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWqBHServiceImpl.java
@@ -80,7 +80,7 @@ public class SdWqBHServiceImpl extends ServiceImpl impleme
SdWqBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWtBHServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWtBHServiceImpl.java
index c112084a..1578e43c 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWtBHServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_base/service/impl/SdWtBHServiceImpl.java
@@ -83,7 +83,7 @@ public class SdWtBHServiceImpl extends ServiceImpl impleme
SdWtBH before = this.getById(entity.getStcd());
boolean result = this.updateById(entity);
if (result && before != null) {
- msOperationLogService.recordOperationLog(TABLE_NAME, entity.getStcd(), "修改", source);
+ msOperationLogService.recordModifyDetailLog(TABLE_NAME, before, entity, source);
}
return result;
}
diff --git a/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java b/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java
index d9b6f10a..c8faf6af 100644
--- a/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java
+++ b/backend/src/main/java/com/yfd/platform/qgc_env/wte/service/impl/WeFishServiceImpl.java
@@ -626,6 +626,13 @@ public class WeFishServiceImpl implements WeFishService {
queryWeEnvmAutoMonitorCount(buildWeEnvmZjWqSql(baseId, rstcds)),
3, "WQ", "ENV,ENVM,WQ,", "水质监测"
));
+ if (showIds.isEmpty() || showIds.contains("4")) {
+ // 气象监测
+ rows.add(buildWeEnvmAutoMonitorVo(
+ queryWeEnvmAutoMonitorCount(buildWeEnvmMmSql(baseId, hbrvcds)),
+ 4, "MM", "MM,", "气象监测"
+ ));
+ }
rows.add(buildWeEnvmAutoMonitorVo(
queryWeEnvmAutoMonitorCount(buildWeEnvmStGjSql(baseId)),
5, null, "ST,ZQ-ST,ZZ", "国家水文站"
@@ -5346,6 +5353,19 @@ public class WeFishServiceImpl implements WeFishService {
return new SqlAndParams(sql.toString(), paramMap);
}
+ private SqlAndParams buildWeEnvmMmSql(String baseId, List hbrvcds) {
+ StringBuilder sql = new StringBuilder();
+ Map paramMap = new HashMap<>();
+ sql.append("SELECT COUNT(1) AS cnt FROM SD_MM_B_H mm ")
+ .append("LEFT JOIN SD_ENGINFO_B_H eng ON eng.STCD = mm.RSTCD AND NVL(eng.IS_DELETED, 0) = 0 ")
+ .append("WHERE NVL(mm.IS_DELETED, 0) = 0 ")
+ .append("AND mm.STTP = 'MM' ")
+ .append("AND NVL(mm.MWAY, 0) = 2 ");
+ appendWeEnvmBaseIdCondition(sql, paramMap, "eng.BASE_ID", baseId);
+ appendWeEnvmExactInCondition(sql, paramMap, "eng.HBRVCD", "hbrvcd", hbrvcds);
+ return new SqlAndParams(sql.toString(), paramMap);
+ }
+
private void appendWeEnvmBaseIdCondition(StringBuilder sql, Map paramMap, String column, String baseId) {
if (StrUtil.isBlank(baseId)) {
return;