diff --git a/src/main/java/com/docus/server/archive/dto/PatientState.java b/src/main/java/com/docus/server/archive/dto/PatientState.java new file mode 100644 index 0000000..c0602b3 --- /dev/null +++ b/src/main/java/com/docus/server/archive/dto/PatientState.java @@ -0,0 +1,34 @@ +package com.docus.server.archive.dto; + +import lombok.Data; + +/** + * 患者状态 + * + * @author YongBin Wen + * @date 2025/8/21 0021 14:27 + */ + +@Data +public class PatientState { + /** + * 患者主键 + */ + private String patientId; + /** + * 归档状态 + */ + private Integer isArchive; + /** + * 打印状态 + */ + private Integer isPrint; + /** + * 锁定状态 + */ + private Integer isLock; + /** + * 封存状态 + */ + private Integer isSeal; +} diff --git a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java index 18fe00c..177def3 100644 --- a/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java +++ b/src/main/java/com/docus/server/archive/mapper/TBasicMapper.java @@ -1,6 +1,7 @@ package com.docus.server.archive.mapper; +import com.docus.server.archive.dto.PatientState; import com.docus.server.archive.entity.AfCollectTask; import com.docus.server.archive.entity.BasicExtend; import com.docus.server.archive.entity.TBasic; @@ -43,4 +44,6 @@ public interface TBasicMapper { List getNoTaskPatientByDisDate(@Param("startDateTime") String startDateTime,@Param("collectorId") String collectorId); int cancelTask(@Param("patientId") String patientId, @Param("sysflag") String collectorId); + + PatientState getPatientState(@Param("patientId") String patientId); } diff --git a/src/main/java/com/docus/server/mzzyy/job/MzZyyReportCollectJob.java b/src/main/java/com/docus/server/mzzyy/job/MzZyyReportCollectJob.java index b5e7cbc..e2efd33 100644 --- a/src/main/java/com/docus/server/mzzyy/job/MzZyyReportCollectJob.java +++ b/src/main/java/com/docus/server/mzzyy/job/MzZyyReportCollectJob.java @@ -4,8 +4,10 @@ import cn.hutool.core.io.FileUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.docus.core.util.Func; +import com.docus.infrastructure.core.exception.BaseException; import com.docus.infrastructure.web.api.CommonResult; import com.docus.infrastructure.web.api.ResultCode; +import com.docus.server.archive.dto.PatientState; import com.docus.server.archive.entity.TBasic; import com.docus.server.archive.mapper.TBasicMapper; import com.docus.server.mzzyy.entity.MzZyyXinDianView; @@ -33,12 +35,14 @@ import com.xxl.job.core.context.XxlJobHelper; import com.xxl.job.core.handler.annotation.XxlJob; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Component; import java.io.File; import java.time.LocalDateTime; import java.time.ZoneId; import java.util.ArrayList; +import java.util.Arrays; import java.util.Base64; import java.util.Collections; import java.util.Date; @@ -67,6 +71,8 @@ public class MzZyyReportCollectJob { private TBasicMapper tBasicMapper; @Autowired private MzZyyXinDianViewMapper xinDianViewMapper; + @Value("${docus.prevent-invalid-file:}") + private String preventInvalidFile; @XxlJob("MzZyyLisCollectJob") public void lisCollectJob() { @@ -135,9 +141,9 @@ public class MzZyyReportCollectJob { } } log.info("住院号:{},住院流水号:{},采集了 {} 份文件。", inpatientNo, jzh, count); - - tBasicMapper.invalidFileBySource(patientId, collectorId); - + if (!isPreventInvalidFile(patientId)) { + tBasicMapper.invalidFileBySource(patientId, collectorId); + } ReportDownPatientDto patient = new ReportDownPatientDto(); patient.setPatientid(patientId); @@ -168,6 +174,7 @@ public class MzZyyReportCollectJob { } } + @XxlJob("MzZyyShouMaCollectJob") public void shouMaCollectJob() { String configPath = "data-config"; @@ -254,7 +261,9 @@ public class MzZyyReportCollectJob { reportDownDto.setCollectorid(collectorId); reportDownDto.setIp("java-shouma-job"); reportDownDto.setPatient(patient); - tBasicMapper.invalidFileBySource(patientId, collectorId); + if (!isPreventInvalidFile(patientId)) { + tBasicMapper.invalidFileBySource(patientId, collectorId); + } for (ReportDownScanFileDto scanFile : scanFiles) { List scanFileDtos = Collections.singletonList(scanFile); String assortId = getShouMaAssortId(scanFile.getFiletitle()); @@ -300,7 +309,9 @@ public class MzZyyReportCollectJob { determineAndCancelTask(patientId, collectorId); return; } - tBasicMapper.invalidFileBySource(patientId, collectorId); + if (!isPreventInvalidFile(patientId)) { + tBasicMapper.invalidFileBySource(patientId, collectorId); + } ReportDownPatientDto patient = new ReportDownPatientDto(); patient.setPatientid(patientId); @@ -402,6 +413,38 @@ public class MzZyyReportCollectJob { return defaultAssort; } + private boolean isPreventInvalidFile(String patientId) { + PatientState state = tBasicMapper.getPatientState(patientId); + if (Func.isNull(state)) { + throw new BaseException("患者不存在"); + } + if (Func.isBlank(preventInvalidFile)) { + return false; + } + // 封存、锁定、归档 符合阻止作废条件则返回true + String[] prevents = preventInvalidFile.toLowerCase().split(","); + List preventList = Arrays.asList(prevents); + if (preventList.contains("seal")) { + Integer isSeal = 1; + if (isSeal.equals(state.getIsSeal())) { + return true; + } + } + if (preventList.contains("lock")) { + Integer isLock = 3; + if (isLock.equals(state.getIsLock())) { + return true; + } + } + if (preventList.contains("archive")) { + Integer isArchive = 1; + if (isArchive.equals(state.getIsArchive())) { + return true; + } + } + return false; + } + public static void main(String[] args) { System.out.println(new MzZyyReportCollectJob().getShouMaAssortId("手术登记")); } diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index 1f92d24..4f44cc5 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -140,6 +140,7 @@ spring: docus: + prevent-invalid-file: SEAL,LOCK,ARCHIVE sync-service-prefix: ZqDyRy default-user-pwd: fd29cd53ec12616e5f36b77d4afffbff url: diff --git a/src/main/resources/mapper/TBasicMapper.xml b/src/main/resources/mapper/TBasicMapper.xml index 9ffcdc9..e86e09b 100644 --- a/src/main/resources/mapper/TBasicMapper.xml +++ b/src/main/resources/mapper/TBasicMapper.xml @@ -35,7 +35,7 @@ delete from docus_archivefile.af_collect_task where id=#{id} - update docus_archivefile.af_collect_task set state='4' where patient_id=#{patientId} and sysflag=#{sysflag} + update docus_archivefile.af_collect_task set state='4',end_time=now() where patient_id=#{patientId} and sysflag=#{sysflag} +