优化下载his任务查询

master
zengwh 2 years ago
parent c7945897b2
commit 89c152fbc8

@ -8,7 +8,7 @@ import org.springframework.data.jpa.repository.Query;
import java.util.List;
public interface InterfaceHisCacheDtoRepository extends JpaRepository<InterfaceHisCacheDto,String> {
@Query(value = "select id,inp_no,visit_id,pdf_path,type from Interface_His_Cache where state = 0 and pdf_path is not null",nativeQuery = true)
@Query(value = "select top 10 id,inp_no,visit_id,pdf_path,type from Interface_His_Cache where state = 0 and pdf_path is not null",nativeQuery = true)
public List<InterfaceHisCacheDto> findAllByStateAndPdfPathIsNotNullDto();
}

@ -19,6 +19,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.io.File;
import java.util.Date;
@ -382,8 +383,21 @@ public class QueueService {
public void doSomethingByHIS() {
try {
while (true) {
//循环开始处理 所有未处理的
List<InterfaceHisCacheDto> interfaceHisCaches = interfaceHisCacheService.findInterfaceHisCacheByState();
if(CollectionUtils.isEmpty(interfaceHisCaches)){
break;
}
doSomethingByHISMethod(interfaceHisCaches);
}
}catch (Exception e){
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]);
}
}
private void doSomethingByHISMethod(List<InterfaceHisCacheDto> interfaceHisCaches){
for (InterfaceHisCacheDto interfaceHisCacheDto: interfaceHisCaches) {
InterfaceHisCache interfaceHisCache = new InterfaceHisCache();
BeanUtils.copyProperties(interfaceHisCacheDto,interfaceHisCache);
@ -448,17 +462,17 @@ public class QueueService {
if(remark != null){
// 报错删掉患者报告详情信息
if (archiveDetail != null) {
try {
archiveDetailService.delete(archiveDetail.getId());
} catch (Exception e) {
e.printStackTrace();
}
}
}
//赋值
interfaceHisCache.setValue(state,remark,new Date());
interfaceHisCacheService.save(interfaceHisCache);
}
}catch (Exception e){
logger.error("出错咯!错误信息为{},以及错误行数为:{}" ,e,e.getStackTrace()[0]);
}
}
public boolean isInteger(String str) {

Loading…
Cancel
Save