feat: Kotlin+Solon 重构医院前置机(业务+被控端+Agent+升级流程)

主程序(com.hospital.front):
- Kotlin 2.0.21 + Solon 3.10.7 + MyBatis-Plus + HikariCP + Logback
- HospitalAdapter 策略模式:5 家医院(xinglongyuan/qingyang/ningxia/yanan/jinghe)+ dev Mock
- 三方言 Mapper:bsm(Oracle)/ nx / ya(SqlServer),存储过程参数原样迁移
- 20 个业务接口(/order/*)+ 11 个被控端接口(/api/admin/*,Token 鉴权+脱敏+防穿越)
- 全局异常处理、Result 统一响应、业务开关热更新

Agent(com.hospital.agent,独立进程,单 jar 双 main):
- WebSocket 主动出站连 B 端(指数退避重连),心跳转发主程序健康
- ProcessGuard 看门狗:3 次探测失败自动拉起主程序
- UpgradeCommand:下载→SHA256 校验→备份→替换→拉起→健康检查→失败自动回滚
- 命令分发:PING/日志/配置/重启等 10 类命令

部署(pac/):
- Windows Server 脚本(start.bat/agent.bat/WinSW 服务),纯 ASCII 注释防 GBK 错乱
- 5 家医院配置模板 + agent.properties

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-08-21 12:35:05 +08:00
co-authored by Claude
parent b6c6b436c3
commit 535162e63a
49 changed files with 4893 additions and 25 deletions
+235
View File
@@ -0,0 +1,235 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<!--
Solon 版本说明:
- Maven Central 上 solon-parent 最新是 4.0.6(短横线命名)
- 但 mybatis-solon-plugin 4.0.6 与 solon 4.0.6 存在 ABI 不兼容(NoSuchMethodError
- 退回 solon-parent 3.10.7(点号命名,生态完整稳定,已实测可启动)
-->
<parent>
<groupId>org.noear</groupId>
<artifactId>solon-parent</artifactId>
<version>3.10.7</version>
<relativePath/>
</parent>
<groupId>com.hospital</groupId>
<artifactId>hospital-front</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>
<name>hospital-front</name>
<description>医院前置机程序(Kotlin + Solon 3.10.7</description>
<properties>
<!-- JDK 与 Kotlin(覆盖 solon-parent 的 java.version=1.8 -->
<java.version>17</java.version>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<kotlin.version>2.0.21</kotlin.version>
<kotlin.jvmTarget>17</kotlin.jvmTarget>
<!-- 数据库驱动(solon-parent 不管理) -->
<ojdbc.version>23.3.0.23.09</ojdbc.version>
<mssql-jdbc.version>12.6.1.jre11</mssql-jdbc.version>
<sqlite-jdbc.version>3.46.1.0</sqlite-jdbc.version>
<!-- 鉴权 -->
<sa-token.version>1.39.0</sa-token.version>
</properties>
<dependencies>
<!-- ========== Solon 核心 ========== -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon</artifactId>
</dependency>
<!-- Solon Web 服务器(smart-http 异步) -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-server-smarthttp</artifactId>
</dependency>
<!-- Solon YAML 配置支持 -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-config-yaml</artifactId>
</dependency>
<!-- Solon Logback 日志桥接 -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-logging-logback-jakarta</artifactId>
</dependency>
<!-- Solon 调度(@Scheduled 注解) -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>solon-scheduling</artifactId>
</dependency>
<!-- ========== MyBatis-Plus 集成 ========== -->
<!-- Solon 官方插件(与 Solon 3.10.x ABI 兼容) -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>mybatis-plus-solon-plugin</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.5.9</version>
</dependency>
<!-- ========== 数据库驱动 ========== -->
<!-- 连接池(Solon 数据源类型) -->
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>5.1.0</version>
</dependency>
<!-- Oracle -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc11</artifactId>
<version>${ojdbc.version}</version>
</dependency>
<!-- SqlServer -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${mssql-jdbc.version}</version>
</dependency>
<!-- SQLiteB 端 Agent 用) -->
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite-jdbc.version}</version>
</dependency>
<!-- H2(开发 Mock 数据源) -->
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<version>2.3.232</version>
<scope>runtime</scope>
</dependency>
<!-- ========== HTTP / WebSocketAgent 用) ========== -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</dependency>
<!-- ========== 鉴权(可选,按需启用) ========== -->
<dependency>
<groupId>cn.dev33</groupId>
<artifactId>sa-token-solon-plugin</artifactId>
<version>${sa-token.version}</version>
<optional>true</optional>
</dependency>
<!-- ========== Kotlin 标准库 ========== -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin.version}</version>
</dependency>
<!-- ========== JSON 解析(Solon 生态标准库) ========== -->
<dependency>
<groupId>org.noear</groupId>
<artifactId>snack3</artifactId>
</dependency>
<!-- ========== 测试 ========== -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test-junit5</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<finalName>hospital-front-${project.version}</finalName>
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory>
<plugins>
<!-- Kotlin 编译 -->
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<compilerPlugins>
<plugin>spring</plugin>
</compilerPlugins>
<jvmTarget>${kotlin.jvmTarget}</jvmTarget>
</configuration>
<executions>
<execution>
<id>compile</id>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-allopen</artifactId>
<version>${kotlin.version}</version>
</dependency>
</dependencies>
</plugin>
<!-- 打 fat jar(包含所有依赖) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.5.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.hospital.front.HospitalFrontAppKt</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
<finalName>hospital-front-${project.version}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>