一、环境准备
1. 操作系统:CentOS 7.9 64位,最小化安装
2. 必装依赖及命令(直接复制执行):
- 关闭防火墙:systemctl stop firewalld && systemctl disable firewalld
- 安装基础工具:yum install -y wget git java-1.8.0-openjdk-devel mysql-server maven
- 启动并设置MySQL:systemctl start mysqld && systemctl enable mysqld;执行
mysql_secure_installation按提示设置root密码为Test@123456
- 创建系统数据库:登录MySQL后执行
CREATE DATABASE archive_db DEFAULT CHARACTER SET utf8mb4;
二、档案管理系统部署
2.1 拉取系统代码
使用Git克隆开源档案系统代码到指定目录:
```bash
git clone https://github.com/openedms/openedms.git /opt/archive-system
cd /opt/archive-system
```
2.2 配置数据库连接
编辑配置文件src/main/resources/application.properties,替换为完整内容:
```properties
spring.datasource.url=jdbc:mysql://localhost:3306/archive_db?useUnicode=true&characterEncoding=utf8&serverTimezone=Asia/Shanghai&useSSL=false
spring.datasource.username=root
spring.datasource.password=Test@123456
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
server.port=8080
```
2.3 编译打包系统
执行Maven编译,跳过测试加速打包:
```bash
mvn clean package -DskipTests
```
打包成功后,jar包路径为/opt/archive-system/target/archive-system-1.0.0.jar
2.4 启动系统
后台启动系统,日志输出到指定文件:
```bash
nohup java -jar /opt/archive-system/target/archive-system-1.0.0.jar > /var/log/archive.log 2>&1 &
```
验证启动:访问http://服务器IP:8080,初始账号密码:admin / admin123
三、医保数据对接核心实操
本案例对接某市医保局标准接口(遵循《全国医疗保障经办政务服务事项清单2023版》),接口地址为http://10.20.30.40:8080/medical-insurance/api/insured/query
3.1 医保接口配置
新增配置文件src/main/resources/medical-api.properties,内容如下:
```properties
医保接口基础配置
insurance.api.base-url=http://10.20.30.40:8080/medical-insurance/api
insurance.api.client-id=INS_20240501_001
insurance.api.client-secret=7a1f9b3d4c8e2f5a6b7c8d9e0f1a2b3c
insurance.api.timeout=5000
```
注意:生产环境需将client-id和client-secret替换为当地医保局正式分配值,不可使用示例值
3.2 实体类与依赖配置

1. 在实体类InsuredPerson.java中添加医保字段映射注解(路径src/main/java/com/archive/entity/InsuredPerson.java):
```java
package com.archive.entity;
import com.alibaba.fastjson.annotation.JSONField;
public class InsuredPerson {
@JSONField(name = "personId")
private String id;
@JSONField(name = "personName")
private String name;
@JSONField(name = "idCardNo")
private String idCard;
@JSONField(name = "medicalInsuranceNo")
private String insuranceNo;
// 请补充getter和setter方法
}
```
2. 在pom.xml的中添加接口请求依赖:
```xml
com.squareup.okhttp3
okhttp
4.10.0
com.alibaba
fastjson
1.2.83
```
3.3 同步服务代码实现
新增医保同步服务类(路径src/main/java/com/archive/service/InsuranceSyncService.java),直接复制代码:
```java
package com.archive.service;
import com.alibaba.fastjson.JSON;
import com.archive.entity.InsuredPerson;
import com.archive.config.MedicalApiConfig;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
@Service
public class InsuranceSyncService {
@Autowired
private MedicalApiConfig medicalApiConfig;
private final OkHttpClient client = new OkHttpClient.Builder()
.connectTimeout(5, TimeUnit.SECONDS)
.readTimeout(5, TimeUnit.SECONDS).build();
public InsuredPerson syncByCard(String idCard) throws IOException {
String url = medicalApiConfig.getBaseUrl() + "/insured/query?idCard=" + idCard;
Request request = new Request.Builder()
.url(url)
.addHeader("Client-Id", medicalApiConfig.getClientId())
.addHeader("Client-Secret", medicalApiConfig.getClientSecret())
.build();
try (Response response = client.newCall(request).execute()) {
if (!response.isSuccessful()) throw new IOException("接口调用失败,状态码:" + response.code());
return JSON.parseObject(response.body().string(), InsuredPerson.class);
}
}
}
```
四、测试与验证
4.1 本地接口测试
使用Postman发送请求,验证接口连通性:
- 请求方法:GET
- 地址:
http://localhost:8080/api/insurance/sync?idCard=110101199001011234
- 请求头:Client-Id: INS_20240501_001,Client-Secret: 7a1f9b3d4c8e2f5a6b7c8d9e0f1a2b3c
- 预期结果:返回完整医保人员信息,系统档案表写入对应数据
4.2 业务场景测试
1. 录入10条测试人员的身份证号到系统档案页
2. 点击“同步医保档案”按钮,逐一验证是否获取到完整的姓名、身份证号、医保编号
3. 检查系统表archive_info,确认医保字段数据无缺失
五、上线注意事项
1. 接口地址替换:上线后将medical-api.properties中的base-url改为当地医保局正式接口地址
2. 密钥管理:将client-secret存入Spring Cloud Config密钥服务,不可提交到代码仓库
3. 网络配置:医保接口位于政务内网,需配置系统服务器接入政务内网VPN
4. 日志留存:配置ELK监控同步日志,异常日志留存不少于30天,供医保部门核查