fix: 优化逻辑
This commit is contained in:
parent
40ceffcfd6
commit
5188d526ec
@ -54,6 +54,7 @@ public class MsOperationLogServiceImpl extends ServiceImpl<MsOperationLogMapper,
|
|||||||
TABLE_NAME_CONFIG_MAP.put("SD_HYDROBASE", new TableNameConfig("BASEID", "BASENAME"));
|
TABLE_NAME_CONFIG_MAP.put("SD_HYDROBASE", new TableNameConfig("BASEID", "BASENAME"));
|
||||||
// Fish Dictionary: 需确认结构后配置
|
// Fish Dictionary: 需确认结构后配置
|
||||||
TABLE_NAME_CONFIG_MAP.put("SD_FISHDICTORY_B", new TableNameConfig("ID", "NAME"));
|
TABLE_NAME_CONFIG_MAP.put("SD_FISHDICTORY_B", new TableNameConfig("ID", "NAME"));
|
||||||
|
TABLE_NAME_CONFIG_MAP.put("SD_QEC_R", new TableNameConfig("ID", "STCD"));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Map<String, String> ENG_FIELD_MEANING_MAP = new LinkedHashMap<>();
|
private static final Map<String, String> ENG_FIELD_MEANING_MAP = new LinkedHashMap<>();
|
||||||
|
|||||||
@ -6796,7 +6796,36 @@ public class EngEqDataServiceImpl implements EngEqDataService {
|
|||||||
String sql = "SELECT " + buildQecHourLogSelectColumns() +
|
String sql = "SELECT " + buildQecHourLogSelectColumns() +
|
||||||
" FROM SD_QEC_R WHERE STCD = ? AND TM = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')";
|
" FROM SD_QEC_R WHERE STCD = ? AND TM = TO_DATE(?, 'YYYY-MM-DD HH24:MI:SS')";
|
||||||
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql, stcd, tm);
|
List<Map<String, Object>> rows = jdbcTemplate.queryForList(sql, stcd, tm);
|
||||||
return rows.isEmpty() ? new HashMap<>() : normalizeLogRow(rows.get(0));
|
if (rows.isEmpty()) {
|
||||||
|
return new HashMap<>();
|
||||||
|
}
|
||||||
|
// 数据库返回的列名默认全大写,转成驼峰 key 与前端参数保持一致
|
||||||
|
return convertKeysToCamel(rows.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Map<String, Object> convertKeysToCamel(Map<String, Object> row) {
|
||||||
|
Map<String, Object> camel = new LinkedHashMap<>();
|
||||||
|
if (row == null || row.isEmpty()) {
|
||||||
|
return camel;
|
||||||
|
}
|
||||||
|
for (Map.Entry<String, Object> entry : row.entrySet()) {
|
||||||
|
camel.put(toCamelCase(entry.getKey()), entry.getValue());
|
||||||
|
}
|
||||||
|
return camel;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String toCamelCase(String columnName) {
|
||||||
|
if (StrUtil.isBlank(columnName)) {
|
||||||
|
return columnName;
|
||||||
|
}
|
||||||
|
String[] parts = columnName.toLowerCase().split("_");
|
||||||
|
StringBuilder sb = new StringBuilder(parts[0]);
|
||||||
|
for (int i = 1; i < parts.length; i++) {
|
||||||
|
if (!parts[i].isEmpty()) {
|
||||||
|
sb.append(Character.toUpperCase(parts[i].charAt(0))).append(parts[i].substring(1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void recordQecUpdateLog(Map<String, Object> beforeHour,
|
private void recordQecUpdateLog(Map<String, Object> beforeHour,
|
||||||
@ -6812,9 +6841,11 @@ public class EngEqDataServiceImpl implements EngEqDataService {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
String column = entry.getValue();
|
String column = entry.getValue();
|
||||||
Object oldValue = beforeHour == null ? null : beforeHour.get(column);
|
// beforeHour 已转为驼峰 key,与前端参数统一按驼峰取旧值
|
||||||
|
Object oldValue = beforeHour == null ? null : beforeHour.get(entry.getKey());
|
||||||
Object newValue = updateData.get(entry.getKey());
|
Object newValue = updateData.get(entry.getKey());
|
||||||
if (StrUtil.equals(formatLogValue(oldValue), formatLogValue(newValue))) {
|
// 数值类型按数值大小比较,忽略精度差异(133.0000 == 133.00)
|
||||||
|
if (sameLogValue(oldValue, newValue)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
details.add(buildQecDetail(null, QEC_HOUR_TABLE_NAME, stcd, column,
|
details.add(buildQecDetail(null, QEC_HOUR_TABLE_NAME, stcd, column,
|
||||||
@ -6825,7 +6856,7 @@ public class EngEqDataServiceImpl implements EngEqDataService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String recordId = beforeHour != null && !beforeHour.isEmpty()
|
String recordId = beforeHour != null && !beforeHour.isEmpty()
|
||||||
&& beforeHour.get("ID") != null ? beforeHour.get("ID").toString() : null;
|
&& beforeHour.get("id") != null ? beforeHour.get("id").toString() : null;
|
||||||
MsOperationLog mainLog = buildQecMainLog(recordId, "修改生态流量小时数据", source,"02");
|
MsOperationLog mainLog = buildQecMainLog(recordId, "修改生态流量小时数据", source,"02");
|
||||||
msOperationLogMapper.insert(mainLog);
|
msOperationLogMapper.insert(mainLog);
|
||||||
for (MsOperationLogDetail detail : details) {
|
for (MsOperationLogDetail detail : details) {
|
||||||
@ -6834,6 +6865,24 @@ public class EngEqDataServiceImpl implements EngEqDataService {
|
|||||||
batchInsertQecLogDetails(details);
|
batchInsertQecLogDetails(details);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean sameLogValue(Object oldValue, Object newValue) {
|
||||||
|
if (oldValue == null && newValue == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (oldValue == null || newValue == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// BigDecimal/Double 等数值类型按数值大小比较,忽略精度差异(133.0000 == 133.00)
|
||||||
|
if (oldValue instanceof Number && newValue instanceof Number) {
|
||||||
|
try {
|
||||||
|
return new BigDecimal(oldValue.toString()).compareTo(new BigDecimal(newValue.toString())) == 0;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StrUtil.equals(formatLogValue(oldValue), formatLogValue(newValue));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public boolean removeKendoByIds(BatchDeleteAo batchDeleteAo) {
|
public boolean removeKendoByIds(BatchDeleteAo batchDeleteAo) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user