From 37588688b84ac4d68285703345d143ffa086ce0c Mon Sep 17 00:00:00 2001 From: liaodeyun Date: Thu, 4 Dec 2025 15:21:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=B6=B2=E9=9D=A2=E6=B7=B1?= =?UTF-8?q?=E5=BA=A6=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/application-druid.yml | 2 +- .../main/resources/application-plugins.yml | 2 +- .../ruoyi/caltools/controller/FormatUtil.java | 2 +- .../caltools/controller/GasController.java | 20 +---- .../controller/WaterDeepCalController.java | 23 ++++-- .../caltools/model/WaterDeepCalResult.java | 20 +++++ ry.sh | 74 +++++++++++++++++-- 7 files changed, 110 insertions(+), 33 deletions(-) diff --git a/ruoyi-admin/src/main/resources/application-druid.yml b/ruoyi-admin/src/main/resources/application-druid.yml index c403e67..40700fc 100644 --- a/ruoyi-admin/src/main/resources/application-druid.yml +++ b/ruoyi-admin/src/main/resources/application-druid.yml @@ -10,7 +10,7 @@ spring: datasource: # 主库数据源 MASTER: - url: jdbc:mysql://192.168.3.246/ruoyi-geek?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true + url: jdbc:mysql://ngtools.cn:3306/ruoyi-geek?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&nullCatalogMeansCurrent=true # url: jdbc:mariadb://192.168.3.154:3306/ruoyi-geek?useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai username: root password: 4877017Ldy. diff --git a/ruoyi-admin/src/main/resources/application-plugins.yml b/ruoyi-admin/src/main/resources/application-plugins.yml index 0d0c1f8..3c654c0 100644 --- a/ruoyi-admin/src/main/resources/application-plugins.yml +++ b/ruoyi-admin/src/main/resources/application-plugins.yml @@ -3,7 +3,7 @@ spring: # redis 配置 redis: # 地址 - host: 192.168.3.246 + host: localhost # 端口,默认为6379 port: 6379 # 数据库索引 diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/FormatUtil.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/FormatUtil.java index ba297ae..2647200 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/FormatUtil.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/FormatUtil.java @@ -10,7 +10,7 @@ public class FormatUtil { private static final DecimalFormat df4 = new DecimalFormat("#0.0000"); private static final DecimalFormat df5 = new DecimalFormat("#0.00000"); - public static double format(double value, Optional weishu ) { + public static double format(double value, Optional weishu) { double result; Integer weishudefault=weishu.orElse(4); diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/GasController.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/GasController.java index 7719a43..cd38033 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/GasController.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/GasController.java @@ -123,27 +123,15 @@ public class GasController { public static double Crit(GasProps gasProps, double dPlenumVelocity) { + thermService = new ThermService(); + detailService = new DetailService(); + gbt11062Service = new GBT11062Service(); //variables local to function double DH, DDH, S, H; double tolerance = 1.0; double R, P, T, Z; - int i; - - //check objects for readiness; try to initialize if not - if (null == detailService || null == thermService) - { - NG_Cal_UnInit(); - - if (GasConstants.NG_Cal_INITIALIZED != NG_Cal_Init()) - { - - gasProps.lStatus =GasConstants. MEMORY_ALLOCATION_ERROR; return 0.0; - - } - } - - //begin by calculating densities and thermodynamic properties + //begin by calculating densities and thermodynamic properties thermService.Run(gasProps, detailService); //DH is enthalpy change from plenum to throat; this is our initial guess diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/WaterDeepCalController.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/WaterDeepCalController.java index 7562480..e267b05 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/WaterDeepCalController.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/controller/WaterDeepCalController.java @@ -9,6 +9,7 @@ import com.ruoyi.caltools.service.GBT11062Service; import com.ruoyi.caltools.service.ThermService; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.system.controller.UnitConvert; +import org.apache.juli.logging.Log; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -17,6 +18,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.ArrayList; import java.util.List; +import java.util.Optional; import static com.ruoyi.caltools.controller.GasController.Crit; @@ -160,7 +162,7 @@ public class WaterDeepCalController { /** * 计算给定深度的理论传播时间 */ - private Double calculateTheoreticalTime(Double depth, WaterDeepCalParams request) { + private Double calculateTheoreticalTime(Double depth, WaterDeepCalParams request,WaterDeepCalResult response) { if (depth <= 0) return 0.0; int segments = Math.max(50, (int)(depth / 10)); // 根据深度调整分段数 @@ -172,6 +174,8 @@ public class WaterDeepCalController { // 克隆GasProps以避免修改原始对象 GasProps tempGasProps = cloneGasProps(request.getGasProps()); + List tempSegmentsData=new ArrayList<>(); + for (int i = 0; i < segments; i++) { Double currentDepth = i * dz + dz/2; // 中点 @@ -180,9 +184,10 @@ public class WaterDeepCalController { request.getTemperatureGradient(), request.getConstantLayerDepth()); // 计算中点压力 - Double pressure = pressureAtDepth(currentDepth, request.getSurfacePressure(), - request.getSurfaceTemperature(), request.getTemperatureGradient(), - request.getConstantLayerDepth(), tempGasProps); +// Double pressure = pressureAtDepth(currentDepth, request.getSurfacePressure(), +// request.getSurfaceTemperature(), request.getTemperatureGradient(), +// request.getConstantLayerDepth(), tempGasProps); + Double pressure = request.getSurfacePressure(); // 设置气体参数 tempGasProps.dTf = temp; @@ -191,15 +196,17 @@ public class WaterDeepCalController { // 计算声速 Crit(tempGasProps, 0); Double soundVelocity = tempGasProps.dSOS; - // 检查声速有效性 if (soundVelocity <= 0 || Double.isNaN(soundVelocity)) { soundVelocity = 300.0; // 默认声速 } totalTime += dz / soundVelocity; + String tempStr= ( "总段数:"+segments+",段序号:"+ Integer.toString(i + 1)+",段长度:"+ FormatUtil.format(dz, Optional.of(2))+",该段声速:"+ FormatUtil.format(tempGasProps.dSOS,Optional.of(2))+",该段时间"+FormatUtil.format(dz/soundVelocity,Optional.of(2))+",该段温度:"+FormatUtil.format(temp-273.15,Optional.of(2))+",总深度:"+FormatUtil.format( currentDepth,Optional.of(2))+",总时间:"+FormatUtil.format(totalTime,Optional.of(2))+"\n"); + tempSegmentsData.add(tempStr); +// System.out.printf(tempStr); } - + response.setDataSegment(tempSegmentsData); return 2 * totalTime; // 往返时间 } @@ -250,9 +257,8 @@ public class WaterDeepCalController { // 二分法迭代 while (iterations < request.getMaxIterations()) { iterationHistory.add(currentDepth); - // 计算理论时间 - Double theoreticalTime = calculateTheoreticalTime(currentDepth, request); + Double theoreticalTime = calculateTheoreticalTime(currentDepth, request,response); Double error = theoreticalTime - request.getMeasuredTime(); // 检查收敛 @@ -296,6 +302,7 @@ public class WaterDeepCalController { response.setCorrectionFactor(correctionFactor); response.setIterations(iterations); response.setIterationHistory(iterationHistory); + response.setInitialSOS(surfaceSoundVelocity); if (iterations < request.getMaxIterations()) { response.setStatus("CONVERGED"); diff --git a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/model/WaterDeepCalResult.java b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/model/WaterDeepCalResult.java index e864e3e..6ecddfb 100644 --- a/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/model/WaterDeepCalResult.java +++ b/ruoyi-models/ruoyi-ngtools/src/main/java/com/ruoyi/caltools/model/WaterDeepCalResult.java @@ -30,9 +30,29 @@ public class WaterDeepCalResult { } public Double initialEstimate; // 初始估计深度(m) + + public Double getInitialSOS() { + return initialSOS; + } + + public void setInitialSOS(Double initialSOS) { + this.initialSOS = initialSOS; + } + + public Double initialSOS; // 初始声速 public Double correctionFactor; // 修正因子 public Integer iterations; // 迭代次数 public String status; // 计算状态 public List iterationHistory; // 迭代历史 + public List getDataSegment() { + return dataSegment; + } + + public void setDataSegment(List dataSegment) { + this.dataSegment = dataSegment; + } + + public List dataSegment; // 分段数据 + } \ No newline at end of file diff --git a/ry.sh b/ry.sh index d6a9cf3..e954e5e 100644 --- a/ry.sh +++ b/ry.sh @@ -1,10 +1,16 @@ #!/bin/sh # ./ry.sh start 启动 stop 停止 restart 重启 status 状态 + +# 定义JAR包所在目录 +APP_HOME=/home/yjly/www/API/ruoyi AppName=ruoyi-admin.jar +# JAR包完整路径 +JAR_PATH=$APP_HOME/$AppName # JVM参数 JVM_OPTS="-Dname=$AppName -Duser.timezone=Asia/Shanghai -Xms512m -Xmx1024m -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=512m -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDateStamps -XX:+PrintGCDetails -XX:NewRatio=1 -XX:SurvivorRatio=30 -XX:+UseParallelGC -XX:+UseParallelOldGC" -APP_HOME=`pwd` + +# 日志文件路径 LOG_PATH=$APP_HOME/logs/$AppName.log if [ "$1" = "" ]; @@ -13,9 +19,10 @@ then exit 1 fi -if [ "$AppName" = "" ]; +# 检查JAR包是否存在 +if [ ! -f "$JAR_PATH" ]; then - echo -e "\033[0;31m 未输入应用名 \033[0m" + echo -e "\033[0;31m 应用JAR包不存在: $JAR_PATH \033[0m" exit 1 fi @@ -26,8 +33,17 @@ function start() if [ x"$PID" != x"" ]; then echo "$AppName is running..." else - nohup java $JVM_OPTS -jar $AppName > /dev/null 2>&1 & + # 进入应用目录 + cd $APP_HOME + # 创建logs目录如果不存在 + if [ ! -d "$APP_HOME/logs" ]; then + mkdir -p $APP_HOME/logs + fi + nohup java $JVM_OPTS -jar $JAR_PATH > /dev/null 2>&1 & echo "Start $AppName success..." + # 显示启动日志 + sleep 2 + echo "查看启动日志: tail -f $LOG_PATH" fi } @@ -67,11 +83,49 @@ function status() PID=`ps -ef |grep java|grep $AppName|grep -v grep|wc -l` if [ $PID != 0 ];then echo "$AppName is running..." + # 显示运行进程详情 + ps -ef |grep java|grep $AppName|grep -v grep else echo "$AppName is not running..." fi } +# 新增查看日志函数 +function log() +{ + if [ ! -f "$LOG_PATH" ]; then + echo "日志文件不存在: $LOG_PATH" + else + tail -f $LOG_PATH + fi +} + +# 新增查看端口函数 +function port() +{ + PID=`ps -ef |grep java|grep $AppName|grep -v grep|awk '{print $2}'` + if [ x"$PID" != x"" ]; then + echo "应用进程ID: $PID" + # 获取端口号 + netstat -tlnp 2>/dev/null | grep $PID + else + echo "$AppName 未运行" + fi +} + +# 新增备份函数 +function backup() +{ + DATE=`date +%Y%m%d%H%M%S` + BACKUP_DIR="$APP_HOME/backup" + if [ ! -d "$BACKUP_DIR" ]; then + mkdir -p $BACKUP_DIR + fi + BACKUP_FILE="$BACKUP_DIR/$AppName.$DATE" + cp $JAR_PATH $BACKUP_FILE + echo "已备份到: $BACKUP_FILE" +} + case $1 in start) start;; @@ -81,6 +135,14 @@ case $1 in restart;; status) status;; + log) + log;; + port) + port;; + backup) + backup;; *) - -esac + echo -e "\033[0;31m 无效的操作名 \033[0m" + echo "用法: $0 {start|stop|restart|status|log|port|backup}" + exit 1 +esac \ No newline at end of file