fix: 作废文件,添加状态阻止

master
wyb 3 months ago
parent d6cb37802d
commit b34efdb327

@ -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;
}

@ -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<TBasic> 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);
}

@ -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<ReportDownScanFileDto> 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<String> 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("手术登记"));
}

@ -140,6 +140,7 @@ spring:
docus:
prevent-invalid-file: SEAL,LOCK,ARCHIVE
sync-service-prefix: ZqDyRy
default-user-pwd: fd29cd53ec12616e5f36b77d4afffbff
url:

@ -35,7 +35,7 @@
delete from docus_archivefile.af_collect_task where id=#{id}
</delete>
<update id="cancelTask">
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}
</update>
<select id="getTbasicByReportTimeAndInpNoOrIdCard" resultType="com.docus.server.archive.entity.TBasic">
select
@ -130,5 +130,15 @@ and patient_id not in(
where sysflag = #{collectorId}
)
</select>
<select id="getPatientState" resultType="com.docus.server.archive.dto.PatientState">
select tb.patient_id as patientId,
tb.is_print as isPrint,
tb.is_archive as isArchive,
state.is_seal as isSeal,
state.is_lock as isLock
from docus_medicalrecord.t_basic tb
left join docus_medicalrecord.sm_storage_state state on state.patient_id = tb.patient_id
where tb.patient_id = #{patientId}
</select>
</mapper>

Loading…
Cancel
Save