From 7422bec2e357f10a3c8032e1ce670496b92dd49b Mon Sep 17 00:00:00 2001 From: my_ong <429426262@qq.com> Date: Wed, 19 Mar 2025 16:42:03 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20=E7=BC=96=E7=A0=81=E4=BD=8D=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- springboot.sh | 70 +++++++++++++++++++ .../platform/material/MaterialController.java | 3 +- 2 files changed, 72 insertions(+), 1 deletion(-) create mode 100644 springboot.sh diff --git a/springboot.sh b/springboot.sh new file mode 100644 index 0000000..35f64a7 --- /dev/null +++ b/springboot.sh @@ -0,0 +1,70 @@ +#!/bin/bash + +# 定义变量 +APP_NAME="ims" +APP_JAR="/ims/app/ims.jar" # 替换为你的 JAR 包路径 +CONFIG_FILE="/ims/app/application.yml" # 替换为你的配置文件路径 +LOG_FILE="/ims/app/ims.log" # 日志文件路径 +PID_FILE="/ims/app/ims.pid" # 保存进程 ID 的文件 + +# 启动函数 +start() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if ps -p "$PID" > /dev/null; then + echo "Application $APP_NAME is already running with PID $PID." + exit 1 + else + rm -f "$PID_FILE" + fi + fi + + echo "Starting $APP_NAME..." + nohup java -jar "$APP_JAR" --spring.config.location="$CONFIG_FILE" > "$LOG_FILE" 2>&1 & + echo $! > "$PID_FILE" + echo "Application $APP_NAME started with PID $!." +} + +# 停止函数 +stop() { + if [ -f "$PID_FILE" ]; then + PID=$(cat "$PID_FILE") + if ps -p "$PID" > /dev/null; then + echo "Stopping $APP_NAME with PID $PID..." + kill "$PID" + rm -f "$PID_FILE" + echo "Application $APP_NAME stopped." + else + echo "Application $APP_NAME is not running." + rm -f "$PID_FILE" + fi + else + echo "PID file not found. Application $APP_NAME may not be running." + fi +} + +# 重启函数 +restart() { + stop + sleep 2 + start +} + +# 脚本入口 +case "$1" in + start) + start + ;; + stop) + stop + ;; + restart) + restart + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/src/main/java/tech/riemann/ims/controller/platform/material/MaterialController.java b/src/main/java/tech/riemann/ims/controller/platform/material/MaterialController.java index 0365345..c6e028c 100644 --- a/src/main/java/tech/riemann/ims/controller/platform/material/MaterialController.java +++ b/src/main/java/tech/riemann/ims/controller/platform/material/MaterialController.java @@ -140,7 +140,8 @@ public class MaterialController { private String getCode() { String code; while (true) { - code = String.valueOf(R.random(1000, 9999)); + code = String.valueOf(R.random(10000, 99999)); + // 需要和前端scan-form.vue中的autoInsertOneRow方法的切割联动修改 try { // 如果代码已经存在,继续循环 if (Strings.isBlank(cache.get(code))) {