feat: 新增 输出通道2

This commit is contained in:
yarnom 2025-10-29 18:02:05 +08:00
parent 678bf7697d
commit 54a9696bbf
4 changed files with 37 additions and 5 deletions

View File

@ -44,6 +44,10 @@ public class RtkrcvGroup {
@TableField("outstr1_format")
private String outstr1Format;
@TableField("outstr1_type")
private String outstr1Type;
@TableField("outstr1_path")
private String outstr1Path;
@TableField("outstr2_type")
private String outstr2Type;

View File

@ -24,6 +24,8 @@ public class RtkrcvProfile {
private String inpstr3Path;
@TableField("outstr1_path")
private String outstr1Path;
@TableField("outstr2_path")
private String outstr2Path;
@TableField("out_height")
private Integer outHeight;
@TableField("updated_at")

View File

@ -6,6 +6,8 @@ import com.imdroid.secapi.dto.RtkrcvProfileMapper;
import com.imdroid.secapi.dto.RtkrcvSession;
import com.imdroid.secapi.dto.RtkrcvSessionMapper;
import com.imdroid.sideslope.bd.RtcmGgaUtil;
import com.imdroid.secapi.dto.RtkrcvGroup;
import com.imdroid.secapi.dto.RtkrcvGroupMapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -40,6 +42,8 @@ public class RtkClusterService implements ApplicationRunner {
@Value("${rtkrcv.workdir:/opt/rtk}")
private String rtkWorkDir;
@Value("${rtkrcv.bin:rtkrcv}")
private String rtkBinary;
@Autowired
private RtkrcvProfileMapper profileMapper;
@ -47,6 +51,8 @@ public class RtkClusterService implements ApplicationRunner {
private RtkrcvSessionMapper sessionMapper;
@Autowired
private RtkrcvConfigService configService;
@Autowired(required = false)
private RtkrcvGroupMapper groupMapper;
private final Map<String, DeviceEndpoint> endpoints = new ConcurrentHashMap<>();
private final Map<String, Process> processes = new ConcurrentHashMap<>();
@ -89,6 +95,15 @@ public class RtkClusterService implements ApplicationRunner {
String localPath = "127.0.0.1:" + workPort;
profile.setInpstr1Path(localPath);
profile.setOutstr1Path(localPath);
// Also write outstr2_path from group if present
try {
if (profile.getGroupId() != null && groupMapper != null) {
RtkrcvGroup group = groupMapper.selectById(profile.getGroupId());
if (group != null && group.getOutstr2Path() != null && !group.getOutstr2Path().trim().isEmpty()) {
profile.setOutstr2Path(group.getOutstr2Path().trim());
}
}
} catch (Exception ignore) {}
profileMapper.updateById(profile);
// 3) Generate config and start rtkrcv
@ -120,7 +135,7 @@ public class RtkClusterService implements ApplicationRunner {
}
worker.submit(() -> {
try {
ProcessBuilder builder = new ProcessBuilder("/opt/rtk/bin/rtkrcv", "-nc", "-o", confPath);
ProcessBuilder builder = new ProcessBuilder(rtkBinary, "-nc", "-o", confPath);
builder.directory(new File(workDir));
builder.redirectErrorStream(true);
LOGGER.info("Starting rtkrcv for {} with {}", deviceId, confPath);

View File

@ -65,10 +65,12 @@ public class RtkrcvConfigService {
replaced = replaceValueLine(replaced, e.getKey(), e.getValue());
}
}
replaced = replaceValueLine(replaced, "inpstr1-path", nz(profile.getInpstr1Path()));
replaced = replaceValueLine(replaced, "inpstr2-path", nz(profile.getInpstr2Path()));
replaced = replaceValueLine(replaced, "inpstr3-path", nz(profile.getInpstr3Path()));
replaced = replaceValueLine(replaced, "outstr1-path", nz(profile.getOutstr1Path()));
// Apply device-level paths if present (do not override group when blank)
replaced = replaceIfNotBlank(replaced, "inpstr1-path", profile.getInpstr1Path());
replaced = replaceIfNotBlank(replaced, "inpstr2-path", profile.getInpstr2Path());
replaced = replaceIfNotBlank(replaced, "inpstr3-path", profile.getInpstr3Path());
replaced = replaceIfNotBlank(replaced, "outstr1-path", profile.getOutstr1Path());
replaced = replaceIfNotBlank(replaced, "outstr2-path", profile.getOutstr2Path());
// If local tcp endpoints are used (e.g., 127.0.0.1:port), force type to tcpcli
if (looksLikeTcpEndpoint(profile.getInpstr1Path())) {
replaced = replaceValueLine(replaced, "inpstr1-type", "tcpcli");
@ -115,6 +117,8 @@ public class RtkrcvConfigService {
putIfNotNull(map, "inpstr3-path", group.getInpstr3Path());
putIfNotNull(map, "inpstr3-format", group.getInpstr3Format());
putIfNotNull(map, "outstr1-format", group.getOutstr1Format());
putIfNotNull(map, "outstr1-type", group.getOutstr1Type());
putIfNotNull(map, "outstr1-path", group.getOutstr1Path());
putIfNotNull(map, "outstr2-type", group.getOutstr2Type());
putIfNotNull(map, "outstr2-format", group.getOutstr2Format());
putIfNotNull(map, "outstr2-path", group.getOutstr2Path());
@ -147,6 +151,13 @@ public class RtkrcvConfigService {
return s == null ? "" : s;
}
private String replaceIfNotBlank(String line, String key, String value) {
if (value == null) return line;
String v = value.trim();
if (v.isEmpty()) return line;
return replaceValueLine(line, key, v);
}
private boolean looksLikeTcpEndpoint(String path) {
if (path == null) return false;
String p = path.trim();