工作常用
2025/7/10大约 7 分钟
工作常用
工作常用记录
文件传输命令 (SCP)
# 传输 Java 相关文件
scp -r -P 10022 sunri@10.6.221.209:/home/sunri/V1.00_2024/binary/java/jar/x64/dist /home/sunri/PRS7950/binary/java/jar/x64
scp -r -P 10022 sunri@10.6.220.209:/home/sunri/V1.00_2024/resource/conf/dbmanager /home/sunri/PRS7950/resource/conf/
scp -r -P 10022 sunri@10.6.220.223:/home/sunri/docker/mavenRepository/com/sunri /home/sunri/.m2/repository/com
scp -r -P 10022 sunri@10.6.221.38:/home/sunri/V1.00_2024/packagemake/PRS-7950-IPS-V2.00-Beta-NewStart6-241212.tar.gz /home/sunri/Desktop/
scp -r -P 10022 sunri@10.6.221.120:/home/sunri/PRS-7950/V1.00_2024/packagemake/PRS-7950-IPS-V2.00-Beta-NewStart6-241212.tar.gz /home/sunri/Desktop/
scp -r -P 10022 sunri@10.6.213.128:/home/sunri/Desktop/sh/cygstart.xml /home/sunri/PRS7950/resource/conf
scp -r -P 10022 sunri@10.6.220.107:/home/sunri/docker/mavenRepository/com/sunri /root/.m2/repository/com/SVN 合并命令
2024 合并到 V1.00_2024
svn merge -c 239816 http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V1.00_2024/src_java/platapp
svn merge -c 239600 http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V1.00_2024/resource/conf/dbmanager
svn merge -c 241108 https://10.1.0.101/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V1.00_2024/src_java/platappV2.00 合并到 V1.00_2024
svn merge -c 240928 http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V2.00/src_java/platapp
svn merge -c 238665 https://10.1.0.101/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V2.00/src_java/platapp
svn merge -c 237503 http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V2.00/src_java/platformSVN 仓库地址
PRS-7950 在线巡视
- V1.00_2024
- http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V1.00_2024/src_java
- https://10.1.0.101/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V1.00_2024/src_java
- https://10.1.0.101/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V1.00
- https://10.1.0.101/svn/houtai/001_后台软件/PRS-7950在线巡视/01_开发库/V1.00_2024/src_java/platapp
- V2.00
PRS-7050 场站智慧管控
- V1.00
- http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7050场站智慧管控/01_开发库/V1.00
- http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7050场站智慧管控/01_开发库/V1.00/binary/java
- http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7050场站智慧管控/01_开发库/V1.00/src_java/platapp
- http://10.6.220.216:8080/svn/houtai/001_后台软件/PRS-7050场站智慧管控/01_开发库/V1.00/src_web/prw
- https://10.1.0.101/svn/houtai/001_后台软件/PRS-7050场站智慧管控/01_开发库/V1.00
- https://10.1.0.101/svn/houtai/001_后台软件/PRS-7050场站智慧管控/01_开发库/V1.00/src_java/platapp
- https://10.1.0.101/svn/houtai/001_后台软件/PRS-7050场站智慧管控/01_开发库/V1.00/src_web/prw
Docker 命令
docker exec -it -e TERM=xterm jenkins-stand /bin/bash常用命令与配置
# 禁用 IntelliJ IDEA 依赖跟踪
-Djps.track.ap.dependencies=false
# 启动 IntelliJ IDEA
nohup /home/sunri/.jdks/idea/bin/idea.sh &
nohup /home/sunri/.jdks/java/idea/bin/idea.sh &
nohup /home/sunri/.mydata/idea/bin/idea.sh & # 10.6.221.46
nohup /home/sunri/Desktop/idea/bin/idea.sh & # 10.6.213.128
# 运行算法仿真并输出日志
nohup ./AlgoSimulation > output.log 2>&1 &
# 查看特定进程(避免 grep 自身出现在结果中)
pgrep -fl tcptester
# 杀死 Java 进程
pkill -15 -f java
pgrep java | grep -v -E '1001|2002' | xargs kill -15 # 排除指定 PID
pkill -9 -f java
# 杀死所有 ExternalJavacProcess 进程
jps -l | grep ExternalJavacProcess | awk '{print $1}' | xargs kill -9
# C++ 编译
cd src_cxx
CLEAN
qmake-qt4 CONFIG+=release
make -j8
cd /home/sunri/CygLog/logspatrolcenter
# 运行 JAR 文件
./xjar java -jar -Dplainload.dir.path=../../lib/common cyggridb.jar认证信息
登录凭据
- 10.6.220.50
- 用户名: administrator@vsphere.local
- 密码: Prs7950.sunri
- 10.6.223.50
- 用户名: liujing2@vsphere.local
- 密码: Aaaa@1234
- 其他凭据
- 用户名: tgy
- 密码: Prs7950.sunri
- 用户名: prs7000.sunri
- 密码: Yzzx@220901
- 用户名: liujing2
- 密码: sunri@20230620*#& / sunri2015.. / sunri@2021*#&
- 用户名: tgy
配置文件
[auth]
password-stores =
store-plaintext-passwords = yes环境变量
export CYGWEBMODE=DEV
export file:/home/sunri/PRS7950/binary/java/jar/x64/dist/网络配置
- NVR: 10.6.220.5
- 主站: 10.6.221.179
- 子站: 10.6.221.211
- Win10 SSH 异常修复:
ssh -o MACs=hmac-sha1 -p 10022 sunri@10.6.221.106
日志与监控
161550,OnlineMonitor#/udprecv/10.6.220.46/test.jpg,1;
161739,OnlineMonitor#/udprecv/10.6.220.46/test.jpg,2;
161950,OnlineMonitor#/udprecv/10.6.220.46/test.jpg,2问题记录
主机名与 IP 检查
检查 cygrunset 的主机名和 IP,或修改 jkcfghostnode 的主机名和 IP 保持一致。
\documentclass{article}
\begin{document}
检查 cygrunset 的主机名和 IP,或修改 jkcfghostnode 的主机名和 IP 保持一致。
\end{document}杀死win10进程
Stop-Process -Id 5668 -Force权限图

问题截图

脚本:杀死所有 Java 进程(排除 Main)
#!/bin/bash
# 获取当前用户的所有 Java 进程的 PID,同时排除名为 Main 的进程
pids=$(ps -u $USER -o pid,cmd | grep java | grep -v 'Main' | awk '{print $1}')
# 检查是否获取到 PID
if [ -z "$pids" ]; then
echo "没有找到需要杀掉的 Java 进程。"
exit 0
fi
# 杀掉所有非 Main 的 Java 进程
for pid in $pids; do
kill -9 $pid
echo "杀掉进程 $pid"
done
echo "所有非 Main 的 Java 进程已被杀掉。"多光谱测试代码:
//测试用
@Override
public void run(String... args) throws Exception {
//查询数据
List<PatrolCameraDevice> cameraDeviceList = cameraDeviceMapper.queryByCameraUsage(3);
List<Integer> belongDeviceIDList = cameraDeviceList.stream().map(PatrolCameraDevice::getBelongDeviceId).distinct().collect(Collectors.toList());
List<PatrolCameraDevice> collect = cameraDeviceList
.stream()
.filter(item -> DeviceProtocol.VideoProtocol.VIDEO_PROTOCOL_MOLE_WEI_WEI_SHI.equals(item.getDeviceProtocol())).collect(Collectors.toList());
List<AlarmDto> alarmDtoList = Collections.emptyList();
if (!collect.isEmpty()) {
alarmDtoList = collect.stream().map(item -> {
AlarmDto alarmDto = new AlarmDto();
alarmDto.setBelongDeviceID(item.getBelongDeviceId());
alarmDto.setDeviceID(item.getId());
alarmDto.setDeviceName(item.getDeviceName());
return alarmDto;
}).collect(Collectors.toList());
}
scheduler = Executors.newScheduledThreadPool(1);
deviceIDList = belongDeviceIDList;
alarmDto = alarmDtoList;
startScheduledTask();
}
private ScheduledExecutorService scheduler;
private List<Integer> deviceIDList;
private List<AlarmDto> alarmDto;
/**
* 启动定时任务
*/
public void startScheduledTask() {
System.out.println("定时任务已启动,每5秒随机执行一个方法...");
scheduler.scheduleAtFixedRate(() -> {
try {
// 随机选择执行哪个方法 (0或1)
int randomChoice = (int) (Math.random() * 2);
if (randomChoice == 0) {
// 执行 generateRandomDeviceData
String deviceData = generateRandomDeviceData(deviceIDList);
System.out.println(" 结果: " + JSONUtil.toJsonStr(deviceData));
mqBusService.sendCygCommonMessage(
JSONUtil.toJsonStr(deviceData),
StateTopicEnum.RUN.getIndex(),
"/patrolsys/webfront/notify",
MqBusClientInitConfig.appName,
"multispectral");
} else {
// 执行 generateRandomAlarm
AlarmDto alarm = AlarmGenerator.generateRandomAlarm(alarmDto);
System.out.println(" 结果: " + JSONUtil.toJsonStr(alarm));
mqBusService.sendCygCommonMessage(
JSONUtil.toJsonStr(alarm),
StateTopicEnum.RUN.getIndex(),
"/patrolsys/webfront/notify",
MqBusClientInitConfig.appName,
"multispectral");
}
System.out.println("----------------------------------------");
} catch (Exception e) {
System.err.println("定时任务执行出错: " + e.getMessage());
}
}, 0, 5, TimeUnit.SECONDS); // 立即开始,每5秒执行一次
}
/**
* 从设备ID列表中随机选择一个设备ID,并生成随机曲线数据
*
* @param belongDeviceIDList 设备ID列表
* @return JSON格式的设备数据对象
*/
public static String generateRandomDeviceData(List<Integer> belongDeviceIDList) {
if (belongDeviceIDList == null || belongDeviceIDList.isEmpty()) {
throw new IllegalArgumentException("设备ID列表不能为空");
}
// 使用Math.random()随机选择一个设备ID
int randomIndex = (int) (Math.random() * belongDeviceIDList.size());
int belongDeviceID = belongDeviceIDList.get(randomIndex);
// 生成1-1000范围内的随机曲线数据
int curveData = (int) (Math.random() * 1000) + 1;
// 使用JSONUtil生成更安全的JSON(自动处理特殊字符)
JSONObject json = new JSONObject();
json.set("belongDeviceID", belongDeviceID);
json.set("curveData", curveData);
json.set("msgType", "real-time-curve");
return json.toString();
}
// 使用示例
public static void main(String[] args) {
List<Integer> deviceIds = Arrays.asList(101, 102, 103, 104, 105);
String result = generateRandomDeviceData(deviceIds);
System.out.println(result);
// 输出示例: {"belongDeviceID":103,"curveData":756}
}
/**
* 告警数据传输对象
*/
@Data
static class AlarmDto {
private int belongDeviceID; // 所属设备id
private int deviceID; // 紫外设备id
private String deviceName; // 紫外设备名称
private int alarmTimestamp; // 告警时间戳(s)
private String alarmMessage; // 告警信息
private String msgType;
// 构造函数
public AlarmDto() {
}
public AlarmDto(int belongDeviceID, int deviceID, String deviceName) {
this.belongDeviceID = belongDeviceID;
this.deviceID = deviceID;
this.deviceName = deviceName;
}
public AlarmDto(int belongDeviceID, int deviceID, String deviceName,
int alarmTimestamp, String alarmMessage) {
this.belongDeviceID = belongDeviceID;
this.deviceID = deviceID;
this.deviceName = deviceName;
this.alarmTimestamp = alarmTimestamp;
this.alarmMessage = alarmMessage;
}
@Override
public String toString() {
return String.format("AlarmDto{belongDeviceID=%d, deviceID=%d, deviceName='%s', " +
"alarmTimestamp=%d, alarmMessage='%s'}",
belongDeviceID, deviceID, deviceName, alarmTimestamp, alarmMessage);
}
}
/**
* 告警数据生成器
*/
static class AlarmGenerator {
// 预定义的中文告警信息
private static final String[] ALARM_MESSAGES = {
"设备温度过高,请检查散热系统",
"紫外灯管老化,建议更换",
"设备电压异常,请检查供电线路",
"传感器读数异常,需要校准",
"设备运行时间过长,建议停机检修",
"紫外强度不足,检查灯管状态",
"设备过载保护触发",
"通信连接中断,请检查网络",
"设备内部湿度过高",
"风扇转速异常,请检查风扇",
"电流过大,触发保护机制",
"设备门未关闭,请检查安全门",
"滤网堵塞,需要清洁维护",
"设备震动异常,请检查固定",
"控制板故障,需要技术支持"
};
/**
* 从AlarmDto列表中随机选择一个,设置当前时间戳和随机告警信息
*
* @param alarmDtoList 包含基础信息的AlarmDto列表
* @return 完整的AlarmDto对象
*/
public static AlarmDto generateRandomAlarm(List<AlarmDto> alarmDtoList) {
if (alarmDtoList == null || alarmDtoList.isEmpty()) {
throw new IllegalArgumentException("AlarmDto列表不能为空");
}
// 随机选择一个AlarmDto
int randomIndex = (int) (Math.random() * alarmDtoList.size());
AlarmDto selectedAlarm = alarmDtoList.get(randomIndex);
// 创建新的AlarmDto对象,复制基础信息
AlarmDto result = new AlarmDto(
selectedAlarm.getBelongDeviceID(),
selectedAlarm.getDeviceID(),
selectedAlarm.getDeviceName()
);
result.setMsgType("alarm-message");
// 设置当前时间戳(秒)
result.setAlarmTimestamp((int) (System.currentTimeMillis() / 1000));
// 随机选择告警信息
int messageIndex = (int) (Math.random() * ALARM_MESSAGES.length);
result.setAlarmMessage(ALARM_MESSAGES[messageIndex]);
return result;
}
// 使用示例
public static void main(String[] args) {
// 创建测试数据
List<AlarmDto> alarmList = Arrays.asList(
new AlarmDto(1001, 2001, "紫外消毒设备A"),
new AlarmDto(1002, 2002, "紫外消毒设备B"),
new AlarmDto(1003, 2003, "紫外消毒设备C"),
new AlarmDto(1004, 2004, "紫外消毒设备D")
);
// 生成随机告警
AlarmDto randomAlarm = generateRandomAlarm(alarmList);
System.out.println("生成的随机告警:");
System.out.println(randomAlarm);
// 多次生成示例
System.out.println("\n连续生成3个随机告警:");
for (int i = 0; i < 3; i++) {
AlarmDto alarm = generateRandomAlarm(alarmList);
System.out.println((i + 1) + ". " + alarm);
}
}
}