diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..5e41eeb5f --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,75 @@ +name: release-ubuntu + +on: + push: + tags: + - "v*.*.*" # 触发条件是推送标签 如git tag v2.7.4 git push origin v2.7.4 + +jobs: + build-ubuntu: + runs-on: ubuntu-latest + strategy: + matrix: + arch: [amd64] + max-parallel: 1 # 最大并行数 + steps: + - name: Checkout + uses: actions/checkout@v4 # github action运行环境 + + - name: Create release # 创建文件夹 + run: | + rm -rf release + mkdir release + echo ${{ github.sha }} > Release.txt + cp Release.txt LICENSE release/ + cat Release.txt + + - name: Set up JDK 1.8 + uses: actions/setup-java@v4 + with: + # Eclipse基金会维护的开源Java发行版 因为github action参考java的用这个 所以用这个 + # 还有microsoft(微软维护的openjdk发行版) oracle(商用SDK)等 + distribution: 'temurin' + java-version: '8' + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20.x' # Node.js版本 20系列的最新稳定版 + + - name: Compile backend + run: | + mvn package + mvn package -P war + + - name: Compile frontend + run: | + cd ./web + npm install + npm run build:prod + cd ../ + + - name: Package Files + run: | + cp -r ./src/main/resources/static release/ # 复制前端文件 + cp ./target/*.jar release/ # 复制 JAR 文件 + cp ./src/main/resources/application-dev.yml release/application.yml + + BRANCH=${{ github.event.base_ref }} + BRANCH_NAME=$(echo "$BRANCH" | grep -oP 'refs/heads/\K.*') + echo "BRANCH_NAME= ${BRANCH_NAME}" + # 如果无法获取,使用默认分支 + if [[ -z "BRANCH_NAME" ]]; then + BRANCH_NAME="${{ github.event.repository.default_branch }}" + fi + + TAG_NAME="${GITHUB_REF#refs/tags/}" + ZIP_FILE_NAME="${BRANCH_NAME}-${TAG_NAME}.zip" + zip -r "$ZIP_FILE_NAME" release + echo "ZIP_FILE_NAME=$ZIP_FILE_NAME" >> $GITHUB_ENV + + - name: Release + uses: softprops/action-gh-release@v2 + if: startsWith(github.ref, 'refs/tags/') + with: + files: ${{ env.ZIP_FILE_NAME }} \ No newline at end of file diff --git a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java index 37a3307e5..3fa12e869 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/security/JwtUtils.java @@ -231,7 +231,7 @@ public class JwtUtils implements InitializingBean { if (expirationTime != null) { // 判断是否即将过期, 默认剩余时间小于5分钟未即将过期 // 剩余时间 (秒) - long timeRemaining = LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)) - expirationTime.getValue(); + long timeRemaining = expirationTime.getValue() - LocalDateTime.now().toEpochSecond(ZoneOffset.ofHours(8)); if (timeRemaining < 5 * 60) { jwtUser.setStatus(JwtUser.TokenStatus.EXPIRING_SOON); } else { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java index 4159c8ca7..037d9332e 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderForPlatform.java @@ -243,7 +243,7 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform { if (sendAfterResponse) { // 默认按照收到200回复后发送下一条, 如果超时收不到回复,就以30毫秒的间隔直接发送。 sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, eventResult -> { - if (eventResult.type.equals(SipSubscribe.EventResultType.timeout)) { + if (eventResult.statusCode == -1024) { // 消息发送超时, 以30毫秒的间隔直接发送 int indexNext = index + parentPlatform.getCatalogGroup(); try { @@ -266,8 +266,7 @@ public class SIPCommanderForPlatform implements ISIPCommanderForPlatform { }); }else { sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, eventResult -> { - log.error("[目录推送失败] 国标级联 platform : {}, code: {}, msg: {}, 停止发送", parentPlatform.getServerGBId(), eventResult.statusCode, eventResult.msg); - dynamicTask.stop(timeoutTaskKey); + log.error("[目录推送失败] 国标级联 platform : {}, code: {}, msg: {}", parentPlatform.getServerGBId(), eventResult.statusCode, eventResult.msg); }, null); dynamicTask.startDelay(timeoutTaskKey, ()->{ int indexNext = index + parentPlatform.getCatalogGroup();