refactor(video): P1 类型规范化 — varchar 数值转 int / Integer 布尔转 Boolean
SQL 类型修正(数值语义列不再用 varchar): - video_platform: device_port / expires / keep_timeout varchar(50) → int - video_platform_channel: custom_cert_num / custom_end_time varchar(50) → int DO 布尔语义字段 Integer → Boolean(SQL 早已是 tinyint(1),DO 对齐语义): - AiAlgorithm.isActive - AiRoi.enabled - AiRoiAlgoBind.enabled 同步修复 ~20 处调用点的布尔判断,setEnabled(1) → setEnabled(true), getEnabled() == 1 → Boolean.TRUE.equals(getEnabled()) MediaServer.hookAliveInterval Float → Integer(SQL 是 int,Float 精度丢失) 同步修复 MediaConfig、ABL/ZLM 两个 StatusManager 的 10F → 10 字面量 编译通过(mvn compile BUILD SUCCESS)。 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -363,11 +363,11 @@ CREATE TABLE `video_platform` (
|
||||
`server_port` int NULL COMMENT '上级平台注册端口',
|
||||
`device_gb_id` varchar(50) NULL COMMENT '本平台向上注册的国标编码',
|
||||
`device_ip` varchar(50) NULL COMMENT '本平台信令IP',
|
||||
`device_port` varchar(50) NULL COMMENT '本平台信令端口',
|
||||
`device_port` int NULL COMMENT '本平台信令端口',
|
||||
`username` varchar(255) NULL COMMENT '注册用户名',
|
||||
`password` varchar(50) NULL COMMENT '注册密码',
|
||||
`expires` varchar(50) NULL COMMENT '注册有效期',
|
||||
`keep_timeout` varchar(50) NULL COMMENT '心跳超时时间',
|
||||
`expires` int NULL COMMENT '注册有效期(秒)',
|
||||
`keep_timeout` int NULL COMMENT '心跳超时时间(秒)',
|
||||
`transport` varchar(50) NULL COMMENT '传输协议(UDP/TCP)',
|
||||
`civil_code` varchar(50) NULL COMMENT '行政区划代码',
|
||||
`manufacturer` varchar(255) NULL COMMENT '厂商',
|
||||
@@ -422,10 +422,10 @@ CREATE TABLE `video_platform_channel` (
|
||||
`custom_parent_id` varchar(50) NULL COMMENT '自定义父节点',
|
||||
`custom_safety_way` int NULL COMMENT '自定义安全防范',
|
||||
`custom_register_way` int NULL COMMENT '自定义注册方式',
|
||||
`custom_cert_num` varchar(50) NULL COMMENT '自定义证书编号',
|
||||
`custom_cert_num` int NULL COMMENT '自定义证书编号',
|
||||
`custom_certifiable` int NULL COMMENT '自定义可认证标志',
|
||||
`custom_err_code` int NULL COMMENT '自定义错误码',
|
||||
`custom_end_time` varchar(50) NULL COMMENT '自定义截止时间',
|
||||
`custom_end_time` int NULL COMMENT '自定义终止时间',
|
||||
`custom_secrecy` int NULL COMMENT '自定义保密级别',
|
||||
`custom_ip_address` varchar(50) NULL COMMENT '自定义IP',
|
||||
`custom_port` int NULL COMMENT '自定义端口',
|
||||
|
||||
@@ -34,7 +34,7 @@ public class AiAlgorithm extends TenantBaseDO {
|
||||
private String description;
|
||||
|
||||
@Schema(description = "是否可用")
|
||||
private Integer isActive;
|
||||
private Boolean isActive;
|
||||
|
||||
@Schema(description = "全局参数JSON(整个算法的默认参数)")
|
||||
private String globalParams;
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AiRoi extends ProjectBaseDO {
|
||||
private Integer priority;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Integer enabled;
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "扩展参数JSON")
|
||||
private String extraParams;
|
||||
|
||||
@@ -34,7 +34,7 @@ public class AiRoiAlgoBind extends ProjectBaseDO {
|
||||
private Integer priority;
|
||||
|
||||
@Schema(description = "启用状态")
|
||||
private Integer enabled;
|
||||
private Boolean enabled;
|
||||
|
||||
@Schema(description = "引用的模板ID,NULL表示独立参数")
|
||||
private String templateId;
|
||||
|
||||
@@ -18,7 +18,7 @@ public interface AiAlgorithmMapper extends BaseMapperX<AiAlgorithm> {
|
||||
|
||||
default List<AiAlgorithm> queryActive() {
|
||||
return selectList(new LambdaQueryWrapper<AiAlgorithm>()
|
||||
.eq(AiAlgorithm::getIsActive, 1)
|
||||
.eq(AiAlgorithm::getIsActive, true)
|
||||
.orderByAsc(AiAlgorithm::getId));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
algo.setTargetClass(vals[1]);
|
||||
algo.setDescription(vals[2]);
|
||||
algo.setParamSchema(vals[3]);
|
||||
algo.setIsActive(1);
|
||||
algo.setIsActive(true);
|
||||
algorithmMapper.add(algo);
|
||||
log.info("[AI算法] 初始化预置算法: {}", code);
|
||||
} else {
|
||||
@@ -135,7 +135,7 @@ public class AiAlgorithmServiceImpl implements IAiAlgorithmService {
|
||||
algo.setTargetClass((String) remote.get("target_class"));
|
||||
algo.setParamSchema(remote.get("param_schema") != null ? remote.get("param_schema").toString() : null);
|
||||
algo.setDescription((String) remote.get("description"));
|
||||
algo.setIsActive(1);
|
||||
algo.setIsActive(true);
|
||||
algo.setSyncTime(now);
|
||||
algorithmMapper.add(algo);
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public class AiConfigServiceImpl implements IAiConfigService {
|
||||
roiMap.put("roi_id", roi.getRoiId());
|
||||
roiMap.put("roi_type", roi.getRoiType());
|
||||
roiMap.put("name", roi.getName());
|
||||
roiMap.put("enabled", roi.getEnabled() == 1);
|
||||
roiMap.put("enabled", Boolean.TRUE.equals(roi.getEnabled()));
|
||||
roiMap.put("priority", roi.getPriority());
|
||||
|
||||
try {
|
||||
@@ -182,7 +182,7 @@ public class AiConfigServiceImpl implements IAiConfigService {
|
||||
Map<String, Object> algoMap = new LinkedHashMap<>();
|
||||
algoMap.put("bind_id", bind.getBindId());
|
||||
algoMap.put("algo_code", bind.getAlgoCode());
|
||||
algoMap.put("enabled", bind.getEnabled() == 1);
|
||||
algoMap.put("enabled", Boolean.TRUE.equals(bind.getEnabled()));
|
||||
algoMap.put("priority", bind.getPriority());
|
||||
algoMap.put("template_id", bind.getTemplateId());
|
||||
algoMap.put("param_override", bind.getParamOverride());
|
||||
@@ -333,7 +333,7 @@ public class AiConfigServiceImpl implements IAiConfigService {
|
||||
} catch (Exception e) {
|
||||
roiOut.put("coordinates", roi.getCoordinates());
|
||||
}
|
||||
roiOut.put("enabled", roi.getEnabled() == 1);
|
||||
roiOut.put("enabled", Boolean.TRUE.equals(roi.getEnabled()));
|
||||
roiOut.put("priority", roi.getPriority());
|
||||
roiList.add(roiOut);
|
||||
}
|
||||
@@ -343,7 +343,7 @@ public class AiConfigServiceImpl implements IAiConfigService {
|
||||
bindOut.put("bind_id", bind.getBindId());
|
||||
bindOut.put("roi_id", bind.getRoiId());
|
||||
bindOut.put("algo_code", bind.getAlgoCode());
|
||||
bindOut.put("enabled", bind.getEnabled() == 1);
|
||||
bindOut.put("enabled", Boolean.TRUE.equals(bind.getEnabled()));
|
||||
bindOut.put("priority", bind.getPriority());
|
||||
try {
|
||||
bindOut.put("params", objectMapper.readValue(bind.getParams(), Object.class));
|
||||
|
||||
@@ -109,7 +109,7 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
roi.setName(roiJson.getString("name"));
|
||||
roi.setCoordinates(roiJson.containsKey("coordinates") ?
|
||||
JSON.toJSONString(roiJson.get("coordinates")) : null);
|
||||
roi.setEnabled(roiJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
roi.setEnabled(roiJson.getBooleanValue("enabled"));
|
||||
roi.setPriority(roiJson.getIntValue("priority"));
|
||||
roiMapper.add(roi);
|
||||
|
||||
@@ -124,7 +124,7 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
bind.setAlgoCode(algoJson.getString("algo_code"));
|
||||
bind.setParams(algoJson.containsKey("params") ?
|
||||
JSON.toJSONString(algoJson.get("params")) : null);
|
||||
bind.setEnabled(algoJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
bind.setEnabled(algoJson.getBooleanValue("enabled"));
|
||||
bind.setPriority(algoJson.getIntValue("priority"));
|
||||
bind.setTemplateId(algoJson.getString("template_id"));
|
||||
bind.setParamOverride(algoJson.getString("param_override"));
|
||||
@@ -181,7 +181,7 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
roi.setName(roiJson.getString("name"));
|
||||
roi.setCoordinates(roiJson.containsKey("coordinates") ?
|
||||
JSON.toJSONString(roiJson.get("coordinates")) : null);
|
||||
roi.setEnabled(roiJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
roi.setEnabled(roiJson.getBooleanValue("enabled"));
|
||||
roi.setPriority(roiJson.getIntValue("priority"));
|
||||
|
||||
if (roi.getId() != null) {
|
||||
@@ -202,7 +202,7 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
bind.setAlgoCode(algoJson.getString("algo_code"));
|
||||
bind.setParams(algoJson.containsKey("params") ?
|
||||
JSON.toJSONString(algoJson.get("params")) : null);
|
||||
bind.setEnabled(algoJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
bind.setEnabled(algoJson.getBooleanValue("enabled"));
|
||||
bind.setPriority(algoJson.getIntValue("priority"));
|
||||
bind.setTemplateId(algoJson.getString("template_id"));
|
||||
bind.setParamOverride(algoJson.getString("param_override"));
|
||||
@@ -248,7 +248,7 @@ public class AiConfigSnapshotServiceImpl implements IAiConfigSnapshotService {
|
||||
bind.setAlgoCode(bindJson.getString("algo_code"));
|
||||
}
|
||||
bind.setParams(bindJson.containsKey("params") ? JSON.toJSONString(bindJson.get("params")) : null);
|
||||
bind.setEnabled(bindJson.getBooleanValue("enabled") ? 1 : 0);
|
||||
bind.setEnabled(bindJson.getBooleanValue("enabled"));
|
||||
bind.setPriority(bindJson.getIntValue("priority"));
|
||||
bind.setTemplateId(bindJson.getString("template_id"));
|
||||
bind.setParamOverride(bindJson.getString("param_override"));
|
||||
|
||||
@@ -69,7 +69,7 @@ public class AiRedisConfigServiceImpl implements IAiRedisConfigService {
|
||||
hash.put("roi_type", roi.getRoiType() != null ? roi.getRoiType() : "polygon");
|
||||
// coordinates: 转为Python list格式字符串(ai_edge用eval解析)
|
||||
hash.put("coordinates", toPythonListStr(roi.getCoordinates()));
|
||||
hash.put("enabled", roi.getEnabled() != null && roi.getEnabled() == 1 ? "True" : "False");
|
||||
hash.put("enabled", Boolean.TRUE.equals(roi.getEnabled()) ? "True" : "False");
|
||||
hash.put("priority", String.valueOf(roi.getPriority() != null ? roi.getPriority() : 0));
|
||||
|
||||
stringRedisTemplate.opsForHash().putAll(key, hash);
|
||||
@@ -87,7 +87,7 @@ public class AiRedisConfigServiceImpl implements IAiRedisConfigService {
|
||||
// params: 转为Python dict格式字符串(ai_edge用eval解析)
|
||||
hash.put("params", toPythonDictStr(effectiveParams));
|
||||
hash.put("priority", String.valueOf(bind.getPriority() != null ? bind.getPriority() : 0));
|
||||
hash.put("enabled", bind.getEnabled() != null && bind.getEnabled() == 1 ? "True" : "False");
|
||||
hash.put("enabled", Boolean.TRUE.equals(bind.getEnabled()) ? "True" : "False");
|
||||
hash.put("algo_name", algoName != null ? algoName : "");
|
||||
hash.put("target_class", targetClass != null ? targetClass : "person");
|
||||
|
||||
@@ -560,7 +560,7 @@ public class AiRedisConfigServiceImpl implements IAiRedisConfigService {
|
||||
roiMap.put("roi_id", roi.getRoiId());
|
||||
roiMap.put("camera_id", roi.getCameraId());
|
||||
roiMap.put("roi_type", roi.getRoiType() != null ? roi.getRoiType() : "polygon");
|
||||
roiMap.put("enabled", roi.getEnabled() != null && roi.getEnabled() == 1);
|
||||
roiMap.put("enabled", Boolean.TRUE.equals(roi.getEnabled()));
|
||||
roiMap.put("priority", roi.getPriority() != null ? roi.getPriority() : 0);
|
||||
|
||||
// coordinates: 解析为标准数组格式 [[x,y], ...]
|
||||
@@ -597,7 +597,7 @@ public class AiRedisConfigServiceImpl implements IAiRedisConfigService {
|
||||
bindMap.put("bind_id", bind.getBindId());
|
||||
bindMap.put("roi_id", bind.getRoiId());
|
||||
bindMap.put("algo_code", bind.getAlgoCode());
|
||||
bindMap.put("enabled", bind.getEnabled() != null && bind.getEnabled() == 1);
|
||||
bindMap.put("enabled", Boolean.TRUE.equals(bind.getEnabled()));
|
||||
bindMap.put("priority", bind.getPriority() != null ? bind.getPriority() : 0);
|
||||
|
||||
// params: 解析为标准 JSON 对象(非 Python eval 字符串)
|
||||
|
||||
@@ -64,7 +64,7 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
roi.setRoiId(UUID.randomUUID().toString());
|
||||
}
|
||||
if (roi.getEnabled() == null) {
|
||||
roi.setEnabled(1);
|
||||
roi.setEnabled(true);
|
||||
}
|
||||
if (roi.getPriority() == null) {
|
||||
roi.setPriority(0);
|
||||
@@ -154,7 +154,7 @@ public class AiRoiServiceImpl implements IAiRoiService {
|
||||
bind.setBindId(UUID.randomUUID().toString());
|
||||
}
|
||||
if (bind.getEnabled() == null) {
|
||||
bind.setEnabled(1);
|
||||
bind.setEnabled(true);
|
||||
}
|
||||
if (bind.getPriority() == null) {
|
||||
bind.setPriority(0);
|
||||
|
||||
@@ -114,7 +114,7 @@ public class MediaConfig{
|
||||
mediaServer.setRtpPortRange(rtpPortRange);
|
||||
mediaServer.setSendRtpPortRange(rtpSendPortRange);
|
||||
mediaServer.setRecordAssistPort(recordAssistPort);
|
||||
mediaServer.setHookAliveInterval(10f);
|
||||
mediaServer.setHookAliveInterval(10);
|
||||
mediaServer.setRecordDay(recordDay);
|
||||
mediaServer.setStatus(false);
|
||||
mediaServer.setType(type);
|
||||
|
||||
@@ -192,7 +192,7 @@ public class ABLMediaServerStatusManger {
|
||||
offlineAblTimeMap.remove(mediaServer.getId());
|
||||
log.info("[ABL-连接成功] ID:{}, 地址: {}:{}", mediaServer.getId(), mediaServer.getIp(), mediaServer.getHttpPort());
|
||||
mediaServer.setStatus(true);
|
||||
mediaServer.setHookAliveInterval(10F);
|
||||
mediaServer.setHookAliveInterval(10);
|
||||
initPort(mediaServer, config);
|
||||
// 发送上线通知
|
||||
eventPublisher.mediaServerOnlineEventPublish(mediaServer);
|
||||
@@ -231,7 +231,7 @@ public class ABLMediaServerStatusManger {
|
||||
if (ablServerConfig.getJtt1078RecvPort() != null && mediaServer.getRtpProxyPort() != ablServerConfig.getJtt1078RecvPort()) {
|
||||
mediaServer.setJttProxyPort(ablServerConfig.getJtt1078RecvPort());
|
||||
}
|
||||
mediaServer.setHookAliveInterval(10F);
|
||||
mediaServer.setHookAliveInterval(10);
|
||||
}
|
||||
|
||||
public void setAblConfig(MediaServer mediaServerItem, boolean restart, AblServerConfig config) {
|
||||
|
||||
@@ -77,7 +77,7 @@ public class MediaServer extends BaseDO {
|
||||
private String secret;
|
||||
|
||||
@Schema(description = "keepalive hook触发间隔,单位秒")
|
||||
private Float hookAliveInterval;
|
||||
private Integer hookAliveInterval;
|
||||
|
||||
@Schema(description = "是否使用多端口模式")
|
||||
private boolean rtpEnable;
|
||||
@@ -132,7 +132,9 @@ public class MediaServer extends BaseDO {
|
||||
rtspSSLPort = zlmServerConfig.getRtspSSlport();
|
||||
autoConfig = true; // 默认值true;
|
||||
secret = zlmServerConfig.getApiSecret();
|
||||
hookAliveInterval = zlmServerConfig.getHookAliveInterval();
|
||||
hookAliveInterval = zlmServerConfig.getHookAliveInterval() != null
|
||||
? zlmServerConfig.getHookAliveInterval().intValue()
|
||||
: null;
|
||||
rtpEnable = false; // 默认使用单端口;直到用户自己设置开启多端口
|
||||
rtpPortRange = zlmServerConfig.getPortRange().replace("_",","); // 默认使用30000,30500作为级联时发送流的端口号
|
||||
recordAssistPort = 0; // 默认关闭
|
||||
|
||||
@@ -480,8 +480,8 @@ public class MediaServerServiceImpl implements IMediaServerService {
|
||||
public void add(MediaServer mediaServer) {
|
||||
mediaServer.setCreateTime(LocalDateTime.now());
|
||||
mediaServer.setUpdateTime(LocalDateTime.now());
|
||||
if (mediaServer.getHookAliveInterval() == null || mediaServer.getHookAliveInterval() == 0F) {
|
||||
mediaServer.setHookAliveInterval(10F);
|
||||
if (mediaServer.getHookAliveInterval() == null || mediaServer.getHookAliveInterval() == 0) {
|
||||
mediaServer.setHookAliveInterval(10);
|
||||
}
|
||||
if (mediaServer.getType() == null) {
|
||||
log.info("[添加媒体节点] 失败, mediaServer的类型:为空");
|
||||
|
||||
@@ -197,7 +197,8 @@ public class ZLMMediaServerStatusManager {
|
||||
eventPublisher.mediaServerOnlineEventPublish(mediaServer);
|
||||
mediaServer.setStatus(true);
|
||||
mediaServer.setServerId(userSetting.getServerId());
|
||||
mediaServer.setHookAliveInterval(config.getHookAliveInterval());
|
||||
mediaServer.setHookAliveInterval(config.getHookAliveInterval() != null
|
||||
? config.getHookAliveInterval().intValue() : null);
|
||||
initPort(mediaServer, config);
|
||||
mediaServerService.update(mediaServer);
|
||||
setZLMConfig(mediaServer, false);
|
||||
@@ -233,7 +234,8 @@ public class ZLMMediaServerStatusManager {
|
||||
mediaServerItem.setTranscodeSuffix(zlmServerConfig.getTranscodeSuffix());
|
||||
}
|
||||
mediaServerItem.setRtpProxyPort(zlmServerConfig.getRtpProxyPort());
|
||||
mediaServerItem.setHookAliveInterval(zlmServerConfig.getHookAliveInterval());
|
||||
mediaServerItem.setHookAliveInterval(zlmServerConfig.getHookAliveInterval() != null
|
||||
? zlmServerConfig.getHookAliveInterval().intValue() : null);
|
||||
}
|
||||
|
||||
public void setZLMConfig(MediaServer mediaServerItem, boolean restart) {
|
||||
|
||||
Reference in New Issue
Block a user