8 小时以前 bfcc71f500625a26886b43c43a8fdf2ea1152844
环境检测排序,仓库绑定物联设备
已添加2个文件
已修改3个文件
144 ■■■■■ 文件已修改
bin/sshpass.exe 补丁 | 查看 | 原始文档 | blame | 历史
deploy.bat 104 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/http/service/controller/JclyController.java 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/mapper/stock/StockInventoryMapper.xml 3 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
bin/sshpass.exe
Binary files differ
deploy.bat
¶Ô±ÈÐÂÎļþ
@@ -0,0 +1,104 @@
@echo off
chcp 65001 >nul
setlocal enabledelayedexpansion
:: ================= Config =================
set "USER=dell"
set "PASS=xd123456@.."
set "IP=1.15.17.182"
set "PORT=10000"
set "JAR_FILE=target/ruoyi.jar"
set "REMOTE_DIR=/home/service/dlsmlspro-product"
set "SSH_OPTS=-o StrictHostKeyChecking=no -o ConnectTimeout=10"
:: ===========================================
echo ==========================================
echo        RuoYi Auto Deploy Script
echo ==========================================
echo.
:: Check if sshpass is available, download if not
where sshpass >nul 2>&1
if %errorlevel% neq 0 (
    echo [WARN] sshpass not found, trying to install...
    echo.
    :: Check if running in Git Bash environment
    where bash >nul 2>&1
    if %errorlevel% equ 0 (
        echo [INFO] Git Bash detected, trying pacman install...
        bash -c "pacman -S --noconfirm sshpass" 2>nul
        if !errorlevel! equ 0 (
            echo [OK] sshpass installed via pacman!
            goto :check_jar
        )
    )
    :: Download standalone sshpass
    echo [INFO] Downloading sshpass...
    :: Get script directory
    set "SSHPASS_DIR=%~dp0bin"
    if not exist "!SSHPASS_DIR!" mkdir "!SSHPASS_DIR!"
    :: Download using PowerShell with escaped variables
    powershell -NoProfile -Command "$url='https://github.com/xhcoding/sshpass-win32/releases/download/v1.0.3/sshpass.exe'; $out='!SSHPASS_DIR!\sshpass.exe'; Write-Host \"Downloading to: $out\"; try { Invoke-WebRequest -Uri $url -OutFile $out -UseBasicParsing; exit 0 } catch { Write-Host $_.Exception.Message; exit 1 }"
    if !errorlevel! neq 0 (
        echo [ERROR] Failed to download sshpass!
        echo [HINT] Please install sshpass manually or use Git Bash: pacman -S sshpass
        goto :error_exit
    )
    :: Add bin dir to PATH temporarily
    set "PATH=!SSHPASS_DIR!;%PATH%"
    echo [OK] sshpass downloaded to: !SSHPASS_DIR!
    echo.
)
:check_jar
:: Check if JAR file exists
if not exist "%JAR_FILE%" (
    echo [ERROR] JAR file not found: %JAR_FILE%
    goto :error_exit
)
:: Display file size
for %%F in ("%JAR_FILE%") do set "JAR_SIZE=%%~zF"
set /a "JAR_SIZE_MB=JAR_SIZE/1024/1024"
echo [INFO] JAR size: %JAR_SIZE_MB% MB
echo [INFO] Target: %USER%@%IP%:%PORT%
echo [INFO] Remote dir: %REMOTE_DIR%
echo.
:: Upload JAR file
echo [STEP 1/2] Uploading %JAR_FILE%...
sshpass -p "%PASS%" scp -P %PORT% %SSH_OPTS% "%JAR_FILE%" %USER%@%IP%:%REMOTE_DIR%/
if %errorlevel% neq 0 (
    echo [ERROR] Upload failed! Check network or credentials.
    goto :error_exit
)
echo [OK] Upload completed!
echo.
:: Execute remote deploy script
echo [STEP 2/2] Running publish.sh...
sshpass -p "%PASS%" ssh -p %PORT% %SSH_OPTS% %USER%@%IP% "cd '%REMOTE_DIR%' && chmod +x publish.sh && ./publish.sh"
if %errorlevel% neq 0 (
    echo [ERROR] publish.sh execution failed!
    goto :error_exit
)
echo.
echo ==========================================
echo [SUCCESS] Deploy completed!
echo ==========================================
goto :end
:error_exit
echo.
echo ==========================================
echo [FAILED] Deploy failed!
echo ==========================================
:end
pause
src/main/java/com/ruoyi/http/service/controller/JclyController.java
@@ -67,6 +67,14 @@
                }
            }
        }
        // æŒ‰ deviceName ç¬¬ä¸€ä¸ªå­—符(数字)排序
        maps.sort((a, b) -> {
            String nameA = a.getOrDefault("deviceName", "");
            String nameB = b.getOrDefault("deviceName", "");
            int firstNumA = extractFirstNumber(nameA);
            int firstNumB = extractFirstNumber(nameB);
            return Integer.compare(firstNumA, firstNumB);
        });
        return AjaxResult.success(maps);
    }
@@ -81,4 +89,26 @@
        return AjaxResult.success(maps);
    }
    /**
     * æå–字符串开头的数字
     */
    private int extractFirstNumber(String str) {
        if (str == null || str.isEmpty()) {
            return Integer.MAX_VALUE;
        }
        StringBuilder numStr = new StringBuilder();
        for (int i = 0; i < str.length(); i++) {
            char c = str.charAt(i);
            if (Character.isDigit(c)) {
                numStr.append(c);
            } else {
                break;
            }
        }
        if (numStr.length() == 0) {
            return Integer.MAX_VALUE;
        }
        return Integer.parseInt(numStr.toString());
    }
}
src/main/java/com/ruoyi/stock/service/impl/StockInventoryServiceImpl.java
@@ -83,6 +83,12 @@
        }
        stockInventoryDto.setBatchNo(batchNo);
        // å¤„理仓库字段:空字符串或null时取消绑定
        String warehouse = stockInventoryDto.getWarehouse();
        if (StringUtils.isEmpty(warehouse)) {
            stockInventoryDto.setWarehouse(null);
        }
        LambdaQueryWrapper<StockInventory> eq = new QueryWrapper<StockInventory>().lambda()
                .eq(StockInventory::getProductModelId, stockInventoryDto.getProductModelId());
        eq.eq(StockInventory::getBatchNo, stockInventoryDto.getBatchNo());
@@ -108,6 +114,7 @@
            newStockInventory.setBatchNo(stockInventoryDto.getBatchNo());
            newStockInventory.setLockedQuantity(stockInventoryDto.getLockedQuantity());
            newStockInventory.setWarnNum(stockInventoryDto.getWarnNum());
            newStockInventory.setWarehouse(stockInventoryDto.getWarehouse());
            stockInventoryMapper.insert(newStockInventory);
        } else {
            stockInventoryMapper.updateAddStockInventory(stockInventoryDto);
src/main/resources/mapper/stock/StockInventoryMapper.xml
@@ -34,6 +34,9 @@
            <if test="ew.warehouse != null and ew.warehouse !=''">
                warehouse = #{ew.warehouse},
            </if>
            <if test="ew.warehouse == null or ew.warehouse ==''">
                warehouse = null,
            </if>
            update_time = now()
        </set>
        where product_model_id = #{ew.productModelId}