血透初始化

master
linjj 1 month ago
parent 43c6b6376a
commit 3fc8062317

@ -8,7 +8,7 @@
<version>2.1.1.RELEASE</version>
</parent>
<groupId>com.example</groupId>
<artifactId>consumables_zj</artifactId>
<artifactId>HD_Collect_ZJ</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>springbootDemo</name>

@ -11,14 +11,14 @@ import org.springframework.web.bind.annotation.*;
/**
* @ClassName MedRecordController
* @Description
* @Description
* @Author linjj
* @Date 2025/3/25 16:45
* @Version 1.0
*/
@RestController
@RequestMapping("/task")
@Api(value = "重耗材任务接口", tags = "重耗材任务对外接口")
@Api(value = "血透采集器接口", tags = "血透采集器接口")
@Slf4j
public class MedRecordController {
@ -31,5 +31,13 @@ public class MedRecordController {
medicaRecordService.gatherMedicaRecord();
return CommonResult.success("完成");
}
@PostMapping("/CompensateByTime")
@ApiOperation("根据时间范围补偿")
@ResponseBody
public CommonResult<?> CompensateByTime(@RequestParam @ApiParam(required = false, name = "sTime", value = "开始时间") String sTime,
@RequestParam @ApiParam(required = false, name = "eTime", value = "结束时间") String eTime){
medicaRecordService.CompensateByTime(sTime,eTime);
return CommonResult.success("完成");
}
}

@ -16,12 +16,13 @@ import java.util.List;
*/
@Mapper
public interface ArchiveMasterDao {
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/3/27 17:03
* @Params:
* @Description:
* @DateTime: 2025/10/21 13:01
* @Params: [patientId, visitId]
* @Return java.util.List<java.lang.String>
*/
List<String> getMasterId(@Param("patientId")String patientId, @Param("visitId")String visitId);
List<String> getMasterIdByInpNOAndVisitId(@Param("inpNo")String inpNo, @Param("visitId")String visitId);
}

@ -1,7 +1,9 @@
package com.example.db2.dao;
import com.example.vo.CompensateVo;
import com.example.vo.MedicaRecordVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -20,5 +22,13 @@ public interface MedicaRecordDao {
* @DateTime: 2025/3/25 12:36
* @Return java.util.List<com.example.vo.MedicaRecordVo>
*/
List<MedicaRecordVo> getMedicaRecord();
List<CompensateVo> getMedicaRecord();
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/10/21 12:49
* @Params:
* @Return
*/
List<CompensateVo> CompensateByTime(@Param("sTime") String sTime, @Param("eTime") String eTime);
}

@ -44,6 +44,8 @@ public class ArchiveOtherExtDto {
private String C1;
//平台唯一id
private String C2;
//住院号
private String zyh;
}

@ -2,6 +2,7 @@ package com.example.quartz;
import com.example.service.MedicaRecordService;
import org.quartz.JobExecutionContext;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.quartz.QuartzJobBean;
import javax.annotation.Resource;
@ -16,10 +17,15 @@ public class ConsumablesQuartz extends QuartzJobBean {
@Resource
private MedicaRecordService medicaRecordService;
@Value("${flag}")
private String flag;
@Override
protected void executeInternal(JobExecutionContext jobExecutionContext) {
//根据试图中时间采集患者高耗材数据
if (flag.equals("0")){
return;
}
medicaRecordService.gatherMedicaRecord();
}
}

@ -15,4 +15,12 @@ public interface MedicaRecordService {
* @DateTime: 2025/3/25 12:58
*/
void gatherMedicaRecord();
/**
* @Author: linjj
* @Description:
* @DateTime: 2025/10/21 12:38
* @Params: [sTime,eTime]
* @Return void
*/
void CompensateByTime(String sTime,String eTime);
}

@ -9,6 +9,7 @@ import com.example.dto.ArchiveDetailDto;
import com.example.dto.ArchiveOtherExtDto;
import com.example.dto.UpdateOtherDao;
import com.example.service.MedicaRecordService;
import com.example.vo.CompensateVo;
import com.example.vo.MedicaRecordVo;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
@ -57,14 +58,103 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
@Override
public void gatherMedicaRecord() {
//根据时间段查询当前时间需要采集的患者信息
List<MedicaRecordVo> patientInfos = medicaRecordDao.getMedicaRecord();
if (CollectionUtils.isEmpty(patientInfos)) {
List<CompensateVo> compensateVos = medicaRecordDao.getMedicaRecord();
if (CollectionUtils.isEmpty(compensateVos)) {
log.info("当前时间段内无需要采集的数据");
return;
}
log.info("当前时间需要采集:" + patientInfos.size() + "份重耗材");
PollingGather(patientInfos);
log.info("当前时间需要采集:" + compensateVos.size() + "份重耗材");
PollingGather(compensateVos);
}
@Override
public void CompensateByTime(String sTime, String eTime) {
//根据时间段查询当前时间需要采集的患者信息
List<CompensateVo> compensateVos = medicaRecordDao.CompensateByTime(sTime, eTime);
if (CollectionUtils.isEmpty(compensateVos)) {
log.info("当前时间段内无需要采集的数据");
return;
}
log.info("当前时间需要采集:" + compensateVos.size() + "份");
//循环补偿
for (CompensateVo compensateVo : compensateVos){
//更新任务表
UpdateOtherDao updateOtherDao=new UpdateOtherDao();
try {
//住院号
String inpNo = compensateVo.getInpNo();
//住院次数
String visitId = compensateVo.getVisitId();
String topic = compensateVo.getTOPIC();
//唯一id作为任务id文件id使用
String id = compensateVo.getId();
//下载地址
String url = compensateVo.getUrl();
//文件表
ArchiveDetailDto archiveDetailDto = new ArchiveDetailDto();
//任务表
ArchiveOtherExtDto archiveOtherExtDto = new ArchiveOtherExtDto();
//使用yyyyMMddHHmmssSSS格式作为文件名
Date date = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String newDate = format.format(date);
//生成保存地址路径
String newSavePath = GenerateSavePath(inpNo, visitId,newDate);
//根据住院号住院次数查询归档中患者
List<String> masterIds = archiveMasterDao.getMasterIdByInpNOAndVisitId(inpNo, visitId);
if (CollectionUtils.isEmpty(masterIds)) {
log.info("当前采集患者基础信息不存在归档数据库中采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
continue;
}
//将任务同步到任务表中
archiveOtherExtDto.setId(newDate);
archiveOtherExtDto.setSycTime(compensateVo.getExportTime());
archiveOtherExtDto.setSycObj(compensateVo.getUrl());
archiveOtherExtDto.setOtherID(BigInteger.valueOf(0));
archiveOtherExtDto.setZyh(inpNo);
archiveOtherExtDto.setSysFlag(BigInteger.valueOf(15));
archiveOtherExtDto.setSysUpdateTime(new Date());
archiveOtherExtDto.setStime(new Date());
archiveOtherExtDto.setETime(new Date());
archiveOtherExtDto.setStatusFlag(BigInteger.valueOf(0));
archiveOtherExtDto.setPResult("未开始");
archiveOtherExtDto.setMID(masterIds.get(0));
archiveOtherExtDto.setC2(id);
archiveOtherDao.addArchiveOtherExt(archiveOtherExtDto);
//同步文件
//下载图像
if (!DownloadFile(url, newSavePath)){
log.info("当前文件下载失败住院号为:"+inpNo+",住院次数为:"+visitId);
failOther(updateOtherDao, compensateVo);
continue;
}
//下载成功保存文件表信息
archiveDetailDto.setId(newDate);
archiveDetailDto.setPdfPath(newSavePath);
archiveDetailDto.setMasterId(masterIds.get(0));
archiveDetailDto.setUpLoadDateTime(new Date());
archiveDetailDto.setAssortId("119");
archiveDetailDto.setSource("血透采集服务");
archiveDetailDto.setFlag("0");
archiveDetailDto.setSys("1");
archiveDetailDto.setTitle(topic);
archiveDetailDto.setC1(id);
//插入到文件表中
if (!archiveDetailDao.addArchiveDetail(archiveDetailDto)){
log.info("插入文件表失败,采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
}
log.info("插入文件表成功,采集成功住院号为:"+inpNo+",住院次数为:"+visitId);
succeedOther(updateOtherDao, compensateVo, newDate);
} catch (Exception e) {
//下载失败更新任务表中任务状态
failOther(updateOtherDao, compensateVo);
log.error("系统异常,下载失败住院号为:"+compensateVo.getInpNo()+",住院次数为:"+compensateVo.getVisitId()+"异常信息为:"+e.getMessage(),e);
}
}
}
/**
* @Author: linjj
* @Description:
@ -72,18 +162,21 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
* @Params: [patientInfos]
* @Return void
*/
private void PollingGather(List<MedicaRecordVo> patientInfos) {
private void PollingGather(List<CompensateVo> compensateVos) {
//更新任务表
UpdateOtherDao updateOtherDao=new UpdateOtherDao();
//轮询采集
for (MedicaRecordVo patientInfo : patientInfos) {
for (CompensateVo compensateVo : compensateVos) {
try {
//记帐
String medicaRecord = patientInfo.getMedicaRecord();
//住院
String inpNo = compensateVo.getInpNo();
//住院次数
String visitId = patientInfo.getVisitId();
//http下载地址
String pdfPath = patientInfo.getPdfPath();
String visitId = compensateVo.getVisitId();
String topic = compensateVo.getTOPIC();
//唯一id作为任务id文件id使用
String id = compensateVo.getId();
//下载地址
String url = compensateVo.getUrl();
//文件表
ArchiveDetailDto archiveDetailDto = new ArchiveDetailDto();
//任务表
@ -93,43 +186,43 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
String newDate = format.format(date);
//生成保存地址路径
String newSavePath = GenerateSavePath(medicaRecord, visitId,newDate);
log.info("当前采集患者记帐号为:"+medicaRecord+",住院次数为:"+visitId);
String newSavePath = GenerateSavePath(inpNo, visitId,newDate);
log.info("当前采集患者住院号为:"+inpNo+",住院次数为:"+visitId);
//根据记帐号住院次数查询患者是否存在归档数据库中
List<String> masterIds = archiveMasterDao.getMasterId(medicaRecord, visitId);
List<String> masterIds = archiveMasterDao.getMasterIdByInpNOAndVisitId(inpNo, visitId);
if (CollectionUtils.isEmpty(masterIds)) {
log.info("当前采集患者基础信息不存在归档数据库中采集失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
log.info("当前采集患者基础信息不存在归档数据库中采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
continue;
}
//查询任务表中C2字段跟时间是否都一致一致不需要重新采集
List<String> archiveOtherExtAndTime = archiveOtherDao.getArchiveOtherExtAndTime(patientInfo.getId(), patientInfo.getExportTime());
List<String> archiveOtherExtAndTime = archiveOtherDao.getArchiveOtherExtAndTime(id, compensateVo.getExportTime());
if (!CollectionUtils.isEmpty(archiveOtherExtAndTime)){
log.info("已经存在文件表跳过采集:"+medicaRecord+",住院次数为:"+visitId);
log.info("已经存在文件表跳过采集:"+inpNo+",住院次数为:"+visitId);
continue;
}
//查询任务表中c2字段是否已经存在存在直接下载文件不存在新增任务
List<String> archiveOtherExt = archiveOtherDao.getArchiveOtherExt(patientInfo.getId());
List<String> archiveOtherExt = archiveOtherDao.getArchiveOtherExt(id);
if (CollectionUtils.isEmpty(archiveOtherExt)) {
archiveOtherExtDto.setId(newDate);
archiveOtherExtDto.setSycTime(patientInfo.getExportTime());
archiveOtherExtDto.setSycObj(patientInfo.getPdfPath());
archiveOtherExtDto.setSycTime(compensateVo.getExportTime());
archiveOtherExtDto.setSycObj(compensateVo.getUrl());
archiveOtherExtDto.setOtherID(BigInteger.valueOf(0));
archiveOtherExtDto.setSysFlag(BigInteger.valueOf(21));
archiveOtherExtDto.setZyh(inpNo);
archiveOtherExtDto.setSysFlag(BigInteger.valueOf(15));
archiveOtherExtDto.setSysUpdateTime(new Date());
archiveOtherExtDto.setJzh(medicaRecord);
archiveOtherExtDto.setStime(new Date());
archiveOtherExtDto.setETime(new Date());
archiveOtherExtDto.setStatusFlag(BigInteger.valueOf(0));
archiveOtherExtDto.setPResult("未开始");
archiveOtherExtDto.setMID(masterIds.get(0));
archiveOtherExtDto.setC2(patientInfo.getId());
archiveOtherExtDto.setC2(id);
archiveOtherDao.addArchiveOtherExt(archiveOtherExtDto);
}
updateDetail(patientInfo);
updateDetail(compensateVo);
//下载图像
if (!DownloadFile(pdfPath, newSavePath)){
log.info("当前文件下载失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
failOther(updateOtherDao, patientInfo);
if (!DownloadFile(url, newSavePath)){
log.info("当前文件下载失败住院号为:"+inpNo+",住院次数为:"+visitId);
failOther(updateOtherDao, compensateVo);
continue;
}
//下载成功保存文件表信息
@ -137,32 +230,32 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
archiveDetailDto.setPdfPath(newSavePath);
archiveDetailDto.setMasterId(masterIds.get(0));
archiveDetailDto.setUpLoadDateTime(new Date());
archiveDetailDto.setAssortId("61");
archiveDetailDto.setSource("重耗材采集服务");
archiveDetailDto.setAssortId("119");
archiveDetailDto.setSource("血透采集服务");
archiveDetailDto.setFlag("0");
archiveDetailDto.setSys("1");
archiveDetailDto.setTitle("高价值耗材清单");
archiveDetailDto.setC1(patientInfo.getId());
archiveDetailDto.setTitle(topic);
archiveDetailDto.setC1(id);
//插入到文件表中
if (!archiveDetailDao.addArchiveDetail(archiveDetailDto)){
log.info("插入文件表失败,采集失败记帐号为:"+medicaRecord+",住院次数为:"+visitId);
log.info("插入文件表失败,采集失败住院号为:"+inpNo+",住院次数为:"+visitId);
}
log.info("插入文件表成功,采集成功记帐号为:"+medicaRecord+",住院次数为:"+visitId);
succeedOther(updateOtherDao, patientInfo, newDate);
log.info("插入文件表成功,采集成功住院号为:"+inpNo+",住院次数为:"+visitId);
succeedOther(updateOtherDao, compensateVo, newDate);
} catch (Exception e) {
//下载失败更新任务表中任务状态
failOther(updateOtherDao, patientInfo);
log.error("系统异常,下载失败记帐号为:"+patientInfo.getMedicaRecord()+",住院次数为:"+patientInfo.getVisitId()+"异常信息为:"+e.getMessage(),e);
failOther(updateOtherDao, compensateVo);
log.error("系统异常,下载失败住院号为:"+compensateVo.getInpNo()+",住院次数为:"+compensateVo.getVisitId()+"异常信息为:"+e.getMessage(),e);
}
}
}
private void updateDetail(MedicaRecordVo patientInfo) {
private void updateDetail( CompensateVo compensateVo) {
//判断文件表是否有记录,有记录先删除后更新
List<String> pdfPathS = archiveDetailDao.getPdfPath(patientInfo.getId());
List<String> pdfPathS = archiveDetailDao.getPdfPath(compensateVo.getId());
if (!CollectionUtils.isEmpty(pdfPathS)) {
//不为空删除对应记录
if (archiveDetailDao.delPdfPath(patientInfo.getId())){
if (archiveDetailDao.delPdfPath(compensateVo.getId())){
//删除对应文件
for (String path:pdfPathS){
File file1 = new File(path);
@ -183,7 +276,7 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
* @Params: [updateOtherDao, patientInfo, newDate]
* @Return void
*/
private void succeedOther(UpdateOtherDao updateOtherDao, MedicaRecordVo patientInfo, String newDate) {
private void succeedOther(UpdateOtherDao updateOtherDao, CompensateVo compensateVo, String newDate) {
//下载成功更新任务表中任务状态
updateOtherDao.setSysUpdateTime(new Date());
updateOtherDao.setStime(new Date());
@ -192,7 +285,7 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
updateOtherDao.setPResult("Done");
updateOtherDao.setDID(newDate);
updateOtherDao.setC1(newDate +".pdf");
updateOtherDao.setC2(patientInfo.getId());
updateOtherDao.setC2(compensateVo.getId());
archiveOtherDao.updateArchiveOtherExt(updateOtherDao);
}
@ -203,14 +296,14 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
* @Params: [updateOtherDao, patientInfo]
* @Return void
*/
private void failOther(UpdateOtherDao updateOtherDao, MedicaRecordVo patientInfo) {
private void failOther(UpdateOtherDao updateOtherDao, CompensateVo compensateVo) {
//下载失败更新任务表中任务状态
updateOtherDao.setSysUpdateTime(new Date());
updateOtherDao.setStime(new Date());
updateOtherDao.setETime(new Date());
updateOtherDao.setStatusFlag(BigInteger.valueOf(2));
updateOtherDao.setPResult("文件下载失败");
updateOtherDao.setC2(patientInfo.getId());
updateOtherDao.setC2(compensateVo.getId());
archiveOtherDao.updateArchiveOtherExt(updateOtherDao);
}
@ -232,7 +325,7 @@ public class MedicaRecordServiceImpl implements MedicaRecordService {
boolean isCreated = directory.mkdirs(); // 创建所有必需的父目录
if (!isCreated) {
// 处理创建目录失败的情况
log.info("目录创建失败,下载失败记帐号为:"+inpNo+",住院次数为:"+visitId);
log.info("目录创建失败,下载失败住院号为:"+inpNo+",住院次数为:"+visitId);
}
}
return newSavePath;

@ -0,0 +1,30 @@
package com.example.vo;
import lombok.Data;
import java.util.Date;
/**
* @ClassName CompensateVo
* @Description
* @Author linjj
* @Date 2025/10/21 12:55
* @Version 1.0
*/
@Data
public class CompensateVo {
//文件唯一id
private String id;
//文件名
private String TOPIC;
//w文件名
private String InpNo;
//w文件名
private String VisitId;
//w文件名
private Date exportTime;
//w文件名
private String url;
}

@ -1,4 +1,4 @@
server.port=3397
server.port=1812
# SQL Server ?????
spring.datasource.hikari.db1.jdbc-url=jdbc:sqlserver://127.0.0.1:1433;DatabaseName=DB_PrivilegeManagement_GYFY
@ -7,9 +7,9 @@ spring.datasource.hikari.db1.password=docus@702
spring.datasource.hikari.db1.driver-class-name=com.microsoft.sqlserver.jdbc.SQLServerDriver
# MySQL??
spring.datasource.hikari.db2.jdbc-url=jdbc:mysql://10.6.3.80:3306/gzykd_spd
spring.datasource.hikari.db2.username=baxt
spring.datasource.hikari.db2.password=123456
spring.datasource.hikari.db2.jdbc-url=jdbc:mysql://10.6.5.41:3306/kd
spring.datasource.hikari.db2.username=re
spring.datasource.hikari.db2.password=wuzhihua@123
spring.datasource.hikari.db2.driver-class-name=com.mysql.cj.jdbc.Driver
# MyBatis-Plus ??

@ -1,4 +1,6 @@
#文件保存路径
savePath: Z:\Consumables\reload
savePath: Z:\HD\reload
#定时补偿任务时间
quartzTime: 0 0/30 * * * ?
quartzTime: 0 0/50 * * * ?
#补偿开启状态
flag: 1

@ -14,7 +14,7 @@
<Prudent>true</Prudent>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<FileNamePattern>
consumables_zj/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
HD_Collect_ZJ/%d{yyyy-MM-dd}/%d{yyyy-MM-dd}.log
</FileNamePattern>
</rollingPolicy>
<layout class="ch.qos.logback.classic.PatternLayout">

@ -22,10 +22,10 @@
</insert>
<delete id="delPdfPath">
delete from archive_detail
where c1 = #{C1} AND AssortID='61'
where c1 = #{C1} AND AssortID='119'
</delete>
<select id="getPdfPath" resultType="java.lang.String">
select PDF_PATH FROM Archive_Detail WHERE c1=#{C1} AND AssortID='61'
select PDF_PATH FROM Archive_Detail WHERE c1=#{C1} AND AssortID='119'
</select>
</mapper>

@ -4,8 +4,8 @@
<mapper namespace="com.example.db1.dao.ArchiveMasterDao">
<select id="getMasterId" resultType="java.lang.String">
select ID from Archive_Master where patient_id=#{patientId} and visit_id=#{visitId} AND ArchiveState !='作废'
<select id="getMasterIdByInpNOAndVisitId" resultType="java.lang.String">
select ID from Archive_Master where inp_no=#{inpNo} and visit_id=#{visitId} AND ArchiveState !='作废'
</select>
</mapper>

@ -4,9 +4,9 @@
<mapper namespace="com.example.db1.dao.ArchiveOtherDao">
<insert id="addArchiveOtherExt">
insert into archive_other_ext(ID, SycTime, SycObj, otherID, sysFlag, sysUpdateTime, jzh, stime, eTime,statusFlag,pResult,MID,C2)
insert into archive_other_ext(ID, SycTime, SycObj, otherID, sysFlag, sysUpdateTime,stime, eTime,statusFlag,pResult,MID,C2,zyh)
values (#{id}, #{SycTime}, #{SycObj}, #{otherID}, #{sysFlag},
#{sysUpdateTime},#{jzh}, #{stime}, #{eTime}, #{statusFlag}, #{pResult}, #{MID}, #{C2})
#{sysUpdateTime}, #{stime}, #{eTime}, #{statusFlag}, #{pResult}, #{MID}, #{C2},#{zyh})
</insert>
<update id="updateArchiveOtherExt">
update archive_other_ext

@ -5,12 +5,20 @@
<mapper namespace="com.example.db2.dao.MedicaRecordDao">
<select id="getMedicaRecord" resultType="com.example.vo.MedicaRecordVo">
SELECT id,medica_record as medicaRecord,Visit_id as visitId,patient_name as patientName,exportTime,pdfpath as pdfPath
FROM `v_select_medica_record`
WHERE medica_record is not null
AND visit_id is not null
AND exporttime >= DATE_ADD(NOW(), INTERVAL -6 HOUR)
AND exporttime &lt;= NOW()
<select id="getMedicaRecord" resultType="com.example.vo.CompensateVo">
SELECT id,TOPIC,Inp_no as InpNo,Visit_id as VisitId,exportTime,url
FROM v_hisviewrecord
WHERE Inp_no is not null
AND Visit_id is not null
AND exportTime >= DATE_ADD(NOW(), INTERVAL -6 HOUR)
AND exportTime &lt;= NOW()
</select>
<select id="CompensateByTime" resultType="com.example.vo.CompensateVo">
SELECT id,TOPIC,Inp_no as InpNo,Visit_id as VisitId,exportTime,url
FROM v_hisviewrecord
WHERE Inp_no is not null
AND Visit_id is not null
AND exportTime >=#{sTime}
AND exportTime &lt;=#{eTime}
</select>
</mapper>
Loading…
Cancel
Save