docs(release-notes): 添加住院护士站划价功能说明和发版记录

- 新增住院护士站划价服务流程说明文档,详细描述了从参数预处理到结果响应的五大阶段流程
- 包含耗材类医嘱和诊疗活动类医嘱的差异化处理逻辑
- 添加完整的发版内容记录,涵盖新增菜单功能和各模块优化点
- 记录了住院相关功能的新增和门诊业务流程的修复
```
This commit is contained in:
2025-12-25 14:13:14 +08:00
parent 85fcb7c2e2
commit abc0674531
920 changed files with 107068 additions and 14495 deletions

View File

@@ -0,0 +1,236 @@
package com.openhis.web.ybmanage.controller;
import javax.servlet.http.HttpServletRequest;
import com.core.common.annotation.Anonymous;
import com.openhis.web.ybmanage.dto.PerinfoParamDto;
import com.openhis.yb.dto.*;
import com.openhis.yb.service.YbDao;
import com.openhis.yb.service.YbHttpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.core.common.core.domain.R;
import com.openhis.web.inhospitalcharge.appservice.IInHospitalRegisterAppService;
import com.openhis.web.ybmanage.dto.Yb2401InputInpatientParamDto;
import com.openhis.web.ybmanage.dto.Yb2403InputInpatientParamDto;
import com.openhis.web.ybmanage.dto.YbInHospitalRegisterQueryDto;
import com.openhis.web.ybmanage.service.IYbService;
/**
* 医保接口
*
* @author SunJQ
* @date 2025-04-11
*/
@RestController
@RequestMapping("/yb-inpatient-request")
public class YbInpatientController {
@Autowired
private IInHospitalRegisterAppService iInHospitalRegisterAppService;
@Autowired
private IYbService ybService;
@Autowired
private YbDao ybDao;
@Autowired
private YbHttpUtils ybHttpUtils;
/**
* 查询住院登记信息
*
* @param inHospitalRegisterQueryDto 查询dto
* @param searchKey 模糊查询关键字
* @param pageNo 当前页
* @param pageSize 每页多少条
* @param request 请求
* @return 住院登记信息
*/
@GetMapping(value = "/register-info")
public R<?> getRegisterInfo(YbInHospitalRegisterQueryDto inHospitalRegisterQueryDto,
@RequestParam(value = "searchKey", defaultValue = "") String searchKey,
@RequestParam(value = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize, HttpServletRequest request) {
IPage<YbInHospitalRegisterQueryDto> iPage =
ybService.getRegisterInfo(inHospitalRegisterQueryDto, searchKey, pageNo, pageSize, request);
return R.ok(iPage);
}
/**
* 【1101】
*
* @param perinfoParamDto 医保信息
* @return 结果
*/
@PostMapping("/inpatient-per-info")
public R<?> getInpatPerInfo(@RequestBody PerinfoParamDto perinfoParamDto) {
Info1101ReadcardParam readcard = ybDao.getReadCard(perinfoParamDto.getCertType(), perinfoParamDto.getCertNo());
Info1101Output perInfo = ybHttpUtils.getPerInfo(readcard);
if (perInfo != null) {
ybDao.saveReadcardAndPerinfo(readcard, perInfo);
//创建医保Account
ybService.createYbAccount(perInfo,perinfoParamDto.getEncounterId(),perinfoParamDto.getCertType(),perinfoParamDto.getCertNo());
return R.ok(ybService.getInpatPerInfo(perInfo, perinfoParamDto.getEncounterId()));
} else {
return R.fail("医保端未查询到患者信息");
}
}
/**
* 查询住院就诊信息
*
* @param encounterId 住院就诊id
* @return 住院就诊信息
*/
@GetMapping(value = "/in-hospital-info")
public R<?> getInHospitalInfo(@RequestParam Long encounterId) {
return R.ok(ybService.getInHospitalInfo(encounterId));
}
/**
* 医保入院办理
*
* @param yb2401InputInpatientParamDto 住院就诊信息
* @return 医保就诊id
*/
@PostMapping(value = "/inpatient-reg")
public R<?> inpatientReg(@RequestBody Yb2401InputInpatientParamDto yb2401InputInpatientParamDto) {
return ybService.inpatientReg(yb2401InputInpatientParamDto);
}
/**
* 医保入院办理
*
* @param mdtrtId 住院就诊id
* @return 医保就诊id
*/
@GetMapping(value = "/cancel-inpatient-reg")
public R<?> cancelInpatientReg(@RequestParam(name = "mdtrtId" ,required = false) String mdtrtId) {
return ybService.cancelInpatientReg(mdtrtId);
}
/**
* 查询住院就诊信息(已上传过医保的)
*
* @param mdtrtId 住院就诊id
* @return 住院就诊信息
*/
@GetMapping(value = "/inpatient-reg-info")
public R<?> getInPatientRegInfo(@RequestParam("mdtrtId") String mdtrtId) {
return ybService.getInpatientRegInfo(mdtrtId);
}
/**
* 医保入院信息变更
*
* @param yb2403InputInpatientParamDto 住院就诊信息
* @return 医保就诊id
*/
@PostMapping(value = "/update-inpatient-reg")
public R<?> updateInpatientReg(@RequestBody Yb2403InputInpatientParamDto yb2403InputInpatientParamDto) {
return ybService.updateInpatientRegInfo(yb2403InputInpatientParamDto);
}
/**
* 医保出院信息获取(暂时该方法和上面/inpatient-reg-info接口的内容是一致的
*
* @param mdtrtId 住院就诊id
* @return 医保就诊id
*/
@PostMapping(value = "/inpatient-check-info")
public R<?> getInpatientCheckInfo(@RequestParam("mdtrtId") String mdtrtId) {
return ybService.getInpatientCheckInfo(mdtrtId);
}
/**
* 医保出院
*
* @param yb2402InputParam 出院信息
* @return 结果
*/
@PostMapping(value = "/inpatient-check-out")
public R<?> inpatientCheckOut(@RequestBody Yb2402InputParam yb2402InputParam) {
return ybService.inpatientCheckOut(yb2402InputParam);
}
/**
* 医保出院
*
* @param mdtrtId 出院信息
* @return 结果
*/
@PostMapping(value = "/cancel-inpatient-check-out")
public R<?> cancelInpatientCheckOut(@RequestParam("mdtrtId") String mdtrtId) {
return ybService.cancelInpatientCheckOut(mdtrtId);
}
/**
* 病案首页上传
*
* @param mdtrtId 出院信息
* @return 结果
*/
@PostMapping(value = "/emr-up")
public R<?> emrUp(@RequestParam("mdtrtId") String mdtrtId) {
return ybService.emrUp(mdtrtId);
}
/**
* 结算上传
*
* @param encounterId 就诊信息
* @return 结果
*/
@PostMapping(value = "/setl-up")
public R<?> settleUp(@RequestParam("encounterId") Long encounterId) {
return ybService.settleUp(encounterId);
}
/**
* 结算上传
*
* @param encounterId 就诊信息
* @return 结果
*/
@PostMapping(value = "/setl-status-up")
public R<?> settleStatusUp(@RequestParam("encounterId") Long encounterId,@RequestParam("stasType") String stasType) {
return ybService.settleStatusUp(encounterId,stasType);
}
/**
* 护士预结算
*
* @param prePaymentDto 就诊信息
* @return 结果
*/
@PostMapping(value = "/pre-setl")
public R<?> preSettle(@RequestBody PrePaymentDto prePaymentDto) {
return ybService.preSettle(prePaymentDto);
}
/**
* 取消医保入院
*
* @param mdtrtId 就诊id
* @return 结果
*/
@GetMapping(value = "/cancel-yb-reg")
@Anonymous
public R<?> cancelInpatientYbReg(@RequestParam(name = "psnNo" ,required = false) String psnNo,
@RequestParam(name = "mdtrtId" ,required = false) String mdtrtId,
@RequestParam(name = "insuplcAdmdvs" ,required = false) String insuplcAdmdvs,
@RequestParam(name = "contractNo" ,required = false) String contractNo) {
Yb2404InputInpatient yb2404InputInpatient = new Yb2404InputInpatient();
yb2404InputInpatient.setMdtrtId(mdtrtId).setPsnNo(psnNo).setInsuplcAdmdvs(insuplcAdmdvs);
// 发送请求
ybHttpUtils.cancelInpatientReg(yb2404InputInpatient, contractNo);
return R.ok("医保入院办理撤销成功!");
}
}

View File

@@ -0,0 +1,72 @@
package com.openhis.web.ybmanage.dto;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import lombok.Data;
import lombok.experimental.Accessors;
@Data
@Accessors(chain = true)
public class EncounterDiagnosisDto {
/** ID */
@TableId(type = IdType.ASSIGN_ID)
private Long id;
/** 就诊id */
private Long encounterId;
/** 诊断_id */
private Long conditionId;
/** 住院患者疾病诊 */
private Integer iptDiseCrsp;
/** 住院患者疾病诊断类型代码 */
private Integer iptDiseTypeCode;
/** 入院疾病病情代码 */
private Integer admDiseCondCode;
/** 医疗类型 */
private String medTypeCode;// 2025/05/23 该字段改为med_type 与医保同步
/** 主诊断标记 */
private Integer maindiseFlag;
/** 最高诊断依据标记 */
private Integer highDiseEvidFlag;
/** 诊断排序医保文档要求数值型字符长度为2 */
private Integer diagSrtNo;
/**
* 中医证候组号
*/
private String syndromeGroupNo;
/**
* 中医标识
*/
private Integer tcmFlag;
/**
* 诊断描述
*/
private String diagnosisDesc;
/**
* 诊断类别
*/
private String typeCode;
/**
* 医保码
*/
private String ybNo;
/**
* 名称
*/
private String name;
}

View File

@@ -0,0 +1,11 @@
package com.openhis.web.ybmanage.dto;
import lombok.Data;
@Data
public class PerinfoParamDto {
private String certType;
private String certNo;
private String psnCertType;
private Long encounterId;
}

View File

@@ -94,5 +94,7 @@ public class VeriPrescriptionDetailInfoDto {
/* --诊断信息-- */
/** 诊断名 */
private String conditionName;
/** 慢病诊断名 */
private String specialConditionName;
}

View File

@@ -8,6 +8,8 @@ import java.util.Date;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -52,4 +54,15 @@ public class VeriPrescriptionInfoDto {
/** 医保处方编号 */
private String hiRxno;
/**
* 参与者id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long practitionerId;
/**
* 参与者
*/
private String practitionerName;
}

View File

@@ -3,7 +3,8 @@
*/
package com.openhis.web.ybmanage.dto;
import java.util.Date;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
@@ -20,4 +21,15 @@ public class VeriPrescriptionParam {
/** 门诊号/姓名 */
private String name;
/**
* 参与者id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long practitionerId;
/**
* 参与者
*/
private String practitionerName;
}

View File

@@ -1,31 +0,0 @@
package com.openhis.web.ybmanage.dto;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Yb2302InpatientParam {
/**
* 费用明细流水号
* 单次就诊内唯一
*/
@JsonProperty("feedetl_sn")
private String feedetlSn;
/**
* 人员编号
* 退单时传入被退单的费用明细流水号
*/
@JsonProperty("psn_no")
private String psnNo;
/**
* 就诊ID
*/
@JsonProperty("mdtrt_id")
private String mdtrtId;
/**
* 字段扩展
*/
@JsonProperty("exp_content")
private String expContent;
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.ybmanage.dto;
import com.alibaba.fastjson2.annotation.JSONField;
import com.openhis.administration.domain.Patient;
import com.openhis.yb.dto.PatientInfoDto;
import com.openhis.yb.dto.Yb2401InputInpatientDiseInfo;
import com.openhis.yb.dto.Yb2401InputInpatientMdtrtInfo;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* 【2401】
*
* @author SunJQ
* @date 2025-11-12
*/
@Data
@Accessors(chain = true)
public class Yb2401InputInpatientParamDto {
private Patient patient;
private PatientInfoDto patientInfoDto;
/**
* 就诊信息
*/
private Yb2401InputInpatientMdtrtInfo mdtrtinfo;
/**
* 诊断信息
*/
private List<Yb2401InputInpatientDiseInfo> diseinfo;
/**
* 诊断信息(出院)
*/
private List<Yb2401InputInpatientDiseInfo> outDiseinfo;
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright ©2023 CJB-CNIT Team. All rights reserved
*/
package com.openhis.web.ybmanage.dto;
import com.alibaba.fastjson2.annotation.JSONField;
import com.openhis.yb.dto.Yb2401InputInpatientDiseInfo;
import com.openhis.yb.dto.Yb2403InputAdmInfo;
import com.openhis.yb.dto.Yb2403InputDiseInfo;
import com.openhis.yb.dto.Yb2403InputMdtrtGrpContent;
import lombok.Data;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* 【2403】
*
* @author SunJQ
* @date 2025-11-12
*/
@Data
@Accessors(chain = true)
public class Yb2403InputInpatientParamDto {
/**
* 登记信息
*/
private Yb2403InputAdmInfo admInfo;
/**
* 拓展信息
*/
private Yb2403InputMdtrtGrpContent grpContent;
/**
* 诊断信息
*/
@NotBlank
private List<Yb2403InputDiseInfo> diseinfo;
}

View File

@@ -0,0 +1,95 @@
package com.openhis.web.ybmanage.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 住院登记查询 dto
*/
@Data
@Accessors(chain = true)
public class YbInHospitalRegisterQueryDto {
/** 患者id */
@JsonSerialize(using = ToStringSerializer.class)
private Long patientId;
/**
* 住院就诊id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long encounterId;
/**
* 门诊就诊id
*/
@JsonSerialize(using = ToStringSerializer.class)
private Long ambEncounterId;
/**
* 申请时间
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date requestTime;
/**
* 记录员
*/
private String registrar;
/**
* 挂号科室(来源)
*/
private String sourceName;
/**
* 患者
*/
private String patientName;
/**
* 性别编码
*/
private Integer genderEnum;
private String genderEnum_enumText;
/**
* 生日
*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date birthDate;
/**
* 年龄
*/
private String age;
/**
* 病区
*/
private String wardName;
/**
* 医保挂号
*/
private String mdtrtId;
/**
* 医保状态
*/
private Integer status;
/**
* 医保状态
*/
private String statusText;
}

View File

@@ -2,6 +2,13 @@ package com.openhis.web.ybmanage.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.openhis.web.inhospitalcharge.dto.InHospitalRegisterQueryDto;
import com.openhis.web.ybmanage.dto.EncounterDiagnosisDto;
import com.openhis.web.ybmanage.dto.YbInHospitalRegisterQueryDto;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -69,4 +76,23 @@ public interface YbMapper {
*/
List<Yb4101AInputOpspdiseinfo> yb4101aSelectOpspdiseinfo(@Param("paymentId") Long paymentId);
/**
* 分页查询
* @param page 分页对象
* @param encounterClass 类型
* @param encounterStatus 状态
* @param registeredFlag 登记标志
* @param formEnum 参数
* @param queryWrapper 条件
* @return 查询条件
*/
IPage<YbInHospitalRegisterQueryDto> getInHospitalRegisterInfo(@Param("page") Page<InHospitalRegisterQueryDto> page,
@Param("encounterClass") Integer encounterClass, @Param("encounterStatus") Integer encounterStatus,
@Param("formEnum") Integer formEnum,
@Param(Constants.WRAPPER) QueryWrapper<InHospitalRegisterQueryDto> queryWrapper);
List<EncounterDiagnosisDto> getDiagnosisList(@Param("encounterId")Long encounterId);
}

View File

@@ -1,6 +1,15 @@
package com.openhis.web.ybmanage.service;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.core.common.core.domain.R;
import com.openhis.web.ybmanage.dto.Yb2401InputInpatientParamDto;
import com.openhis.web.ybmanage.dto.Yb2403InputInpatientParamDto;
import com.openhis.web.ybmanage.dto.YbInHospitalRegisterQueryDto;
import com.openhis.yb.dto.Info1101Output;
import com.openhis.yb.dto.PrePaymentDto;
import com.openhis.yb.dto.Yb2402InputParam;
/**
* 医保Service
@@ -35,4 +44,133 @@ public interface IYbService {
* @return 结果
*/
R<?> yb4101aUploadFundSettle(Long paymentId);
/**
* 醫保住院登記列表
*
* @param inHospitalRegisterQueryDto 参数
* @param searchKey 参数
* @param pageNo 页码
* @param pageSize 页码
* @param request 请求体
* @return 查询结果
*/
IPage<YbInHospitalRegisterQueryDto> getRegisterInfo(YbInHospitalRegisterQueryDto inHospitalRegisterQueryDto,
String searchKey, Integer pageNo, Integer pageSize, HttpServletRequest request);
/**
* 查询住院就诊信息
*
* @param encounterId 就诊id
* @return 查询结果
*/
Yb2401InputInpatientParamDto getInHospitalInfo(Long encounterId);
/**
* 查询住院就诊信息
*
* @param encounterId 就诊id
* @param perInfo 患者信息
* @return 查询结果
*/
Yb2401InputInpatientParamDto getInpatPerInfo(Info1101Output perInfo, Long encounterId);
/**
* 上传医保办理
*
* @param yb2401InputInpatientParamDto 参数
* @return 结果
*/
R<?> inpatientReg(Yb2401InputInpatientParamDto yb2401InputInpatientParamDto);
/**
* 取消医保入院
*
* @param mdtrtId 就诊id
* @return 结果
*/
R<?> cancelInpatientReg(String mdtrtId);
/**
* 获取【医保住院】信息
*
* @param mdtrtId
* @return
*/
R<?> getInpatientRegInfo(String mdtrtId);
/**
* 【住院办理信息更新】
*
* @param yb2403InputInpatientParamDto
* @return
*/
R<?> updateInpatientRegInfo(Yb2403InputInpatientParamDto yb2403InputInpatientParamDto);
/**
* 获取【医保出院】基础信息
*
* @param mdtrtId
* @return
*/
R<?> getInpatientCheckInfo(String mdtrtId);
/**
* 医保出院办理
*
* @param yb2402InputParam 参数
* @return 结果
*/
R<?> inpatientCheckOut(Yb2402InputParam yb2402InputParam);
/**
* 取消医保出院
*
* @param mdtrtId 医保就诊id
* @return 操作结果
*/
R<?> cancelInpatientCheckOut(String mdtrtId);
/**
* 病案首页上传
*
* @param mdtrtId 医保就诊id
* @return 结果
*/
R<?> emrUp(String mdtrtId);
/**
* 目录下载
* @param address 接口编号
* @param version 版本号
*/
R<?> queryCatalog(String address, String version);
/**
* 结算上传
* @param encounterId 就诊id
* @return 结果
*/
R<?> settleUp(Long encounterId);
/**
* 创建医保Account
* @param perInfo 患者信息
*/
void createYbAccount(Info1101Output perInfo,Long encounterId,String certType,String certNo);
/**
* 结算状态上传
* @param encounterId 就诊id
* @param stasType 结算状态
* @return 结果
*/
R<?> settleStatusUp(Long encounterId, String stasType);
/**
* 预结算
* @param prePaymentDto 就诊信息
* @return 结果
*/
R<?> preSettle(PrePaymentDto prePaymentDto);
}

View File

@@ -10,6 +10,7 @@ import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import com.openhis.common.enums.ybenums.YbMedType;
import com.openhis.ybcatalog.service.ICatalogSpecialInsuranceDiseaseService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -75,6 +76,8 @@ public class YbElepBaseServiceImpl implements IYbEleBaseService {
@Autowired
ICatalogSpecialDiseaseService catalogSpecialDiseaseService;
@Autowired
ICatalogSpecialInsuranceDiseaseService catalogSpecialInsuranceDiseaseService;
@Autowired
IConditionDefinitionService conditionDefinitionService;
@Autowired
IPerinfoService perinfoService;
@@ -730,7 +733,7 @@ public class YbElepBaseServiceImpl implements IYbEleBaseService {
// 查询慢病目录
CatalogSpecialInsuranceDisease catalogSpecialInsuranceDisease =
catalogSpecialDiseaseService.getOne(new LambdaQueryWrapper<CatalogSpecialInsuranceDisease>()
catalogSpecialInsuranceDiseaseService.getOne(new LambdaQueryWrapper<CatalogSpecialInsuranceDisease>()
.eq(CatalogSpecialInsuranceDisease::getDiseaseCode, medicationRequest.getOpspDiseCode()));
if (catalogSpecialInsuranceDisease == null) {
return;

View File

@@ -0,0 +1,146 @@
package com.openhis.web.ybmanage.util;
import com.opencsv.bean.CsvToBean;
import com.opencsv.bean.CsvToBeanBuilder;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
public class CsvHelperZipProcessor {
/**
* 处理ZIP文件并返回实体列表
* @param zipFilePath ZIP文件路径
* @param entityClass 目标实体类
* @return 实体对象列表
*/
public static <T> List<T> processZipFile(String zipFilePath, Class<T> entityClass) throws IOException {
return processZipFileInternal(zipFilePath, entityClass, null);
}
/**
* 流式处理ZIP文件
* @param zipFilePath ZIP文件路径
* @param entityClass 目标实体类
* @param recordProcessor 记录处理器
*/
public static <T> void processZipFileStreaming(String zipFilePath, Class<T> entityClass,
Consumer<T> recordProcessor) throws IOException {
processZipFileInternal(zipFilePath, entityClass, recordProcessor);
}
/**
* 内部实现处理ZIP文件
*/
private static <T> List<T> processZipFileInternal(String zipFilePath, Class<T> entityClass,
Consumer<T> recordProcessor) throws IOException {
List<T> allRecords = new ArrayList<>();
File zipFile = new File(zipFilePath);
if (!zipFile.exists()) {
throw new FileNotFoundException("ZIP文件不存在: " + zipFilePath);
}
System.out.println("开始处理ZIP文件: " + zipFilePath);
System.out.println("目标实体类: " + entityClass.getSimpleName());
try (FileInputStream fis = new FileInputStream(zipFile);
ZipInputStream zis = new ZipInputStream(fis, StandardCharsets.UTF_8)) {
ZipEntry entry;
int totalFiles = 0;
int totalRecords = 0;
while ((entry = zis.getNextEntry()) != null) {
if (!entry.isDirectory() && entry.getName().toLowerCase().endsWith(".txt")) {
totalFiles++;
System.out.println("处理文件[" + totalFiles + "]: " + entry.getName());
// 关键修复将ZIP条目内容读取到内存中
byte[] fileContent = readZipEntryContent(zis);
List<T> fileRecords = processTxtFile(fileContent, entityClass, recordProcessor);
allRecords.addAll(fileRecords);
totalRecords += fileRecords.size();
System.out.println("文件 " + entry.getName() + " 解析了 " + fileRecords.size() + " 条记录");
}
// 不需要手动调用 zis.closeEntry()try-with-resources会自动处理
}
System.out.println("处理完成: " + totalFiles + " 个文件, 总共 " + totalRecords + " 条记录");
} // 这里会自动关闭 fis 和 zis
// ==================== try-with-resources结束 ====================
return allRecords;
}
/**
* 读取ZIP条目内容到字节数组
*/
private static byte[] readZipEntryContent(InputStream inputStream) throws IOException {
// ==================== 内部的try-with-resources ====================
try (ByteArrayOutputStream buffer = new ByteArrayOutputStream()) {
byte[] data = new byte[4096];
int bytesRead;
while ((bytesRead = inputStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, bytesRead);
}
return buffer.toByteArray();
} // 这里会自动关闭 buffer
// ==================== try-with-resources结束 ====================
}
/**
* 处理单个TXT文件
*/
private static <T> List<T> processTxtFile(byte[] fileContent, Class<T> entityClass,
Consumer<T> recordProcessor) throws IOException {
List<T> records = new ArrayList<>();
// ==================== 内部的try-with-resources ====================
try (ByteArrayInputStream bais = new ByteArrayInputStream(fileContent);
InputStreamReader reader = new InputStreamReader(bais, StandardCharsets.UTF_8)) {
// 配置CSV解析器
CsvToBean<T> csvToBean = new CsvToBeanBuilder<T>(reader)
.withType(entityClass)
.withSeparator('\t')
.withIgnoreLeadingWhiteSpace(true)
.withIgnoreEmptyLine(true)
.withStrictQuotes(false)
.withIgnoreQuotations(true) // 忽略引号
.build();
if (recordProcessor != null) {
// 流式处理
int recordCount = 0;
for (T record : csvToBean) {
recordProcessor.accept(record);
recordCount++;
if (recordCount % 1000 == 0) {
System.out.println("已处理 " + recordCount + "");
}
}
System.out.println("文件处理完成,共 " + recordCount + "");
} else {
// 批量处理
records = csvToBean.parse();
}
} // 这里会自动关闭 bais 和 reader
// ==================== try-with-resources结束 ====================
return records;
}
}

View File

@@ -290,7 +290,7 @@ public class YbEleParamBuilderUtil {
// .eq(EncounterDiagnosis::getEncounterId, medicationRequest.getEncounterId())
// .eq(EncounterDiagnosis::getTenantId, tenantId)
// .eq(EncounterDiagnosis::getConditionId, medicationRequest.getConditionId())
// .eq(EncounterDiagnosis::getDeleteFlag, DeleteFlag.NOT_DELETED.getCode()));
// .eq(EncounterDiagnosis::getDeleteFlag, DelFlag.NO.getCode()));
EncounterDiagnosis encDiagObjs = encounterDiagnosisService.getEncounterDiagnosisByEncounterConDefId(
medicationRequest.getEncounterId(), medicationRequest.getConditionDefId(), tenantId);
// 就诊管理