|
|
|
@ -1,33 +1,42 @@
|
|
|
|
|
package com.docus.bgts.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
import com.docus.bgts.entity.*;
|
|
|
|
|
import com.docus.bgts.enums.Codes;
|
|
|
|
|
import com.docus.bgts.facade.IAfCollectTaskService;
|
|
|
|
|
import com.docus.bgts.facade.IBgtsService;
|
|
|
|
|
import com.docus.bgts.mapper.dbmysql.AfCollectAddMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbmysql.AfCollectTaskMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectSubMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbmysql.MrReportErrorMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dboracle.VDocumentPdfMapper;
|
|
|
|
|
import com.docus.bgts.utils.*;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
|
|
import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory;
|
|
|
|
|
import org.apache.cxf.transport.http.HTTPConduit;
|
|
|
|
|
import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
import org.dom4j.Document;
|
|
|
|
|
import org.dom4j.DocumentHelper;
|
|
|
|
|
import org.dom4j.Element;
|
|
|
|
|
import org.dom4j.*;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDate;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.CountDownLatch;
|
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
@ -35,6 +44,8 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
private String wsUrl;
|
|
|
|
|
@Value("${ws.localMethod}")
|
|
|
|
|
private String wsLocalMethod;
|
|
|
|
|
@Value("${ws.LocalMethodNj:null}")
|
|
|
|
|
private String wsLocalMethodNj;
|
|
|
|
|
|
|
|
|
|
private Logger logger = LogManager.getLogger(BgtsServiceImpl.class);
|
|
|
|
|
|
|
|
|
@ -53,18 +64,76 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
@Autowired
|
|
|
|
|
AfCollectAddMapper afCollectAddMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
AfCollectTaskMapper afCollectTaskMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ThreadPoolExecutor threadPoolExecutor;
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collect(String empId) throws Exception {
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
//通过empId获取报告单号集合
|
|
|
|
|
if (collectorid.equals("14")){
|
|
|
|
|
exams = getExamNoNj(empId);
|
|
|
|
|
}else {
|
|
|
|
|
exams = getExamNo(empId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
|
|
|
|
|
//插入文件af_collect_task表数据
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
//通过报告单号集合采集
|
|
|
|
|
collectExams(exams, empId, reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectPacs(String empId, String admissDate, String disDate, String times) throws Exception {
|
|
|
|
|
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Date ad = sim.parse(admissDate);
|
|
|
|
|
Date di = sim.parse(disDate);
|
|
|
|
|
String admiss = sim.format(ad);
|
|
|
|
|
String dis = sim.format(di);
|
|
|
|
|
//通过empId获取报告单号集合
|
|
|
|
|
List<String[]> exams = getExamNo(empId, admiss, dis);
|
|
|
|
|
String jzh = afCollectTaskService.getJzhByInpatientNo(empId,times);
|
|
|
|
|
if (null == jzh) {
|
|
|
|
|
logger.info("通过住院号与住院次数未匹配到患者");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, jzh);
|
|
|
|
|
//插入文件af_collect_task表数据
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
//通过报告单号集合采集
|
|
|
|
|
collectExams(exams, empId, reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectEcg(String empId, String admissDate, String disDate, String times) throws Exception {
|
|
|
|
|
Map<String, String> smCollectionTime = getSmCollectionTimeEcg(admissDate, disDate);
|
|
|
|
|
//通过empId获取报告单号集合
|
|
|
|
|
List<String[]> exams = getExamNo(empId);
|
|
|
|
|
List<String[]> exams = getExamNoEcg(empId, smCollectionTime.get("admissDate"), smCollectionTime.get("disDate"));
|
|
|
|
|
String jzh = afCollectTaskService.getpatientIdByEmpId(empId);
|
|
|
|
|
if (null == jzh) {
|
|
|
|
|
logger.info(empId+" 通过jzh未匹配到患者");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
|
|
|
|
|
//插入文件af_collect_task表数据
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
//通过报告单号集合采集
|
|
|
|
|
collectExams(exams, empId,reportDownDto);
|
|
|
|
|
collectExams(exams, empId, reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectByExamNo(String emamNo, String empId) throws Exception {
|
|
|
|
|
String[] strings = new String[2];
|
|
|
|
@ -77,7 +146,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
exams.add(strings);
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
|
|
|
|
|
collectExams(exams, empId,reportDownDto);
|
|
|
|
|
collectExams(exams, empId, reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -99,7 +168,161 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间到采集任务
|
|
|
|
|
* 根据时间到采集任务 手麻
|
|
|
|
|
*
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param endDate
|
|
|
|
|
*/
|
|
|
|
|
// private void collectByDates(String startDate, String endDate) {
|
|
|
|
|
// //页码
|
|
|
|
|
// int current;
|
|
|
|
|
// //每页10条数据
|
|
|
|
|
// int size;
|
|
|
|
|
// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
// String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
|
|
|
|
|
// int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
|
|
|
|
|
// int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
|
|
|
|
|
// Map<String, Object> headMap = new HashMap<>();
|
|
|
|
|
// headMap.put("Content-Type", "application/json");
|
|
|
|
|
// SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
|
|
|
|
|
// String indexFlag = String.valueOf(FileUtils.getJsonByName("indexFlag"));
|
|
|
|
|
// String serialnum = String.valueOf(FileUtils.getJsonByName("serialnum"));
|
|
|
|
|
// String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle"));
|
|
|
|
|
// String downurl = String.valueOf(FileUtils.getJsonByName("downurl"));
|
|
|
|
|
// List<String> fieldArr = new ArrayList<>();
|
|
|
|
|
// fieldArr.add(indexFlag);
|
|
|
|
|
// fieldArr.add(serialnum);
|
|
|
|
|
// if (StringUtils.isNotBlank(filetitle)) {
|
|
|
|
|
// fieldArr.add(filetitle);
|
|
|
|
|
// }
|
|
|
|
|
// fieldArr.add(downurl);
|
|
|
|
|
// String namespace = String.valueOf(FileUtils.getJsonByName("namespace"));
|
|
|
|
|
// String tableName = String.valueOf(FileUtils.getJsonByName("tableName"));
|
|
|
|
|
// String collectTimeName = String.valueOf(FileUtils.getJsonByName("collectTimeName"));
|
|
|
|
|
// List<Map> maps;
|
|
|
|
|
// //2.获取第一页10条数据开始采集
|
|
|
|
|
// for (current = 1; ; current++) {
|
|
|
|
|
// size = 10 * current;
|
|
|
|
|
// maps = vDocumentPdfMapper.listCollectPage(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
|
|
|
|
|
// logger.info("处理采集数据:" + maps);
|
|
|
|
|
// if (null == maps || maps.size() <= 0) {
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// maps:
|
|
|
|
|
// for (Map map : maps) {
|
|
|
|
|
// //获取过滤报告单
|
|
|
|
|
// String[] filterReports = String.valueOf(FileUtils.getJsonByName("filterReport")).split(",");
|
|
|
|
|
// if (filterReports.length > 0) {
|
|
|
|
|
// for (String filterReport : filterReports) {
|
|
|
|
|
// //需要过滤的报告单存在则不采集
|
|
|
|
|
// if (String.valueOf(map.get(filetitle)).equals(filterReport)) {
|
|
|
|
|
// continue maps;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
// reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
// reportDownDto.setAssortid(assortid);
|
|
|
|
|
// ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
// reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag)));
|
|
|
|
|
// reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
//
|
|
|
|
|
// List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
// ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
// reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl)));
|
|
|
|
|
// reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
// reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
// reportDownScanFileDto.setFiletitle(map.get(filetitle) == null ? "重症" + (System.currentTimeMillis()) : String.valueOf(map.get(filetitle)));
|
|
|
|
|
// reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId()));
|
|
|
|
|
// reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
// reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
// String post;
|
|
|
|
|
// try {
|
|
|
|
|
// afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
// //String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector"));
|
|
|
|
|
// //调用下载接口
|
|
|
|
|
// post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
|
|
|
|
|
// Map resMap = JSON.parseObject(post, Map.class);
|
|
|
|
|
// logger.info(reportDownDto);
|
|
|
|
|
// if (String.valueOf(resMap.get("code")).equals("500")) {
|
|
|
|
|
// throw new RuntimeException(String.valueOf(resMap.get("msg")));
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// //打印错误日志
|
|
|
|
|
// logger.info("采集出错:" + reportDownDto);
|
|
|
|
|
// logger.info(e);
|
|
|
|
|
// String stackTrace = ExceptionUtils.getStackTrace(e);
|
|
|
|
|
// logger.info("错误信息----------" + stackTrace);
|
|
|
|
|
// addMrReportErrorLog(reportDownDto);
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// 时间
|
|
|
|
|
private static List<String> date = new ArrayList<>();
|
|
|
|
|
// 上次任务执行时间
|
|
|
|
|
private static int currentIndex = 0;
|
|
|
|
|
|
|
|
|
|
private static void initDate() throws Exception {
|
|
|
|
|
String configStart = String.valueOf(FileUtils.getJsonByName("collectStartDate"));
|
|
|
|
|
String configEnd = String.valueOf(FileUtils.getJsonByName("collectEndDate"));
|
|
|
|
|
if (StrUtil.isBlank(configStart) || StrUtil.isBlank(configEnd)) {
|
|
|
|
|
throw new RuntimeException("check homeQualitySet.json collectStartDate AND collectEndDate confg!");
|
|
|
|
|
}
|
|
|
|
|
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
LocalDate localDate = LocalDate.parse(configStart, dtf);
|
|
|
|
|
LocalDate end = LocalDate.parse(configEnd);
|
|
|
|
|
while (!localDate.isAfter(end)) {
|
|
|
|
|
date.add(localDate.toString());
|
|
|
|
|
localDate = localDate.plusDays(1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void collectPacss(){
|
|
|
|
|
logger.info("按需采集任务执行----");
|
|
|
|
|
// if (CollUtil.isEmpty(date)) {
|
|
|
|
|
// try {
|
|
|
|
|
// initDate();
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// logger.error(e.getMessage());
|
|
|
|
|
// return;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// if (currentIndex >= date.size()) {
|
|
|
|
|
// currentIndex = 0;
|
|
|
|
|
// }
|
|
|
|
|
logger.info("index:{},Thread {}", currentIndex, Thread.currentThread().getName());
|
|
|
|
|
// String collectStartDate = date.get(currentIndex);
|
|
|
|
|
// String collectEndDate = collectStartDate + "\t23:59:59";
|
|
|
|
|
String collectStartDate = String.valueOf(FileUtils.getJsonByName("collectStartDate"))+"\t00:00:00";
|
|
|
|
|
String collectEndDate = String.valueOf(FileUtils.getJsonByName("collectEndDate"))+"\t23:59:59";
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
CountDownLatch countDownLatch = new CountDownLatch(1);
|
|
|
|
|
threadPoolExecutor.execute(() -> {
|
|
|
|
|
try {
|
|
|
|
|
collectByDate(collectStartDate, collectEndDate, collectorid);
|
|
|
|
|
}catch (Exception e) {
|
|
|
|
|
logger.info("按需采集出错{}",e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
countDownLatch.countDown();
|
|
|
|
|
});
|
|
|
|
|
try {
|
|
|
|
|
countDownLatch.await();
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("JUC countDownLatch error {}", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
logger.info("{},采集结束----", collectStartDate);
|
|
|
|
|
// currentIndex++;
|
|
|
|
|
System.gc();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间到采集任务 重症
|
|
|
|
|
*
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param endDate
|
|
|
|
@ -118,24 +341,32 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
SnowflakeIdWorker idWorker = new SnowflakeIdWorker(0, 0);
|
|
|
|
|
String indexFlag = String.valueOf(FileUtils.getJsonByName("indexFlag"));
|
|
|
|
|
String serialnum = String.valueOf(FileUtils.getJsonByName("serialnum"));
|
|
|
|
|
String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle"));
|
|
|
|
|
//String filetitle = String.valueOf(FileUtils.getJsonByName("filetitle"));
|
|
|
|
|
String downurl = String.valueOf(FileUtils.getJsonByName("downurl"));
|
|
|
|
|
List<String> fieldArr=new ArrayList<>();
|
|
|
|
|
String inPatientNo = String.valueOf(FileUtils.getJsonByName("inPatientNo"));
|
|
|
|
|
String visitId = String.valueOf(FileUtils.getJsonByName("visitId"));
|
|
|
|
|
String inJzh = String.valueOf(FileUtils.getJsonByName("jzh"));
|
|
|
|
|
|
|
|
|
|
List<String> fieldArr = new ArrayList<>();
|
|
|
|
|
fieldArr.add(indexFlag);
|
|
|
|
|
fieldArr.add(serialnum);
|
|
|
|
|
if(StringUtils.isNotBlank(filetitle)){
|
|
|
|
|
fieldArr.add(filetitle);
|
|
|
|
|
}
|
|
|
|
|
fieldArr.add(inPatientNo);
|
|
|
|
|
fieldArr.add(visitId);
|
|
|
|
|
fieldArr.add(inJzh);
|
|
|
|
|
// if(StringUtils.isNotBlank(filetitle)){
|
|
|
|
|
// fieldArr.add(filetitle);
|
|
|
|
|
// }
|
|
|
|
|
fieldArr.add(downurl);
|
|
|
|
|
String namespace = String.valueOf(FileUtils.getJsonByName("namespace"));
|
|
|
|
|
String tableName = String.valueOf(FileUtils.getJsonByName("tableName"));
|
|
|
|
|
String collectTimeName = String.valueOf(FileUtils.getJsonByName("collectTimeName"));
|
|
|
|
|
List<Map> maps;
|
|
|
|
|
//2.获取第一页10条数据开始采集
|
|
|
|
|
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
|
|
|
|
|
for (current = 1; ; current++) {
|
|
|
|
|
size = 10 * current;
|
|
|
|
|
maps = vDocumentPdfMapper.listCollectPage(current, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
|
|
|
|
|
logger.info("处理采集数据:"+maps);
|
|
|
|
|
maps = vDocumentPdfMapper.listCollectPage(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
|
|
|
|
|
logger.info("处理采集数据:" + maps);
|
|
|
|
|
if (null == maps || maps.size() <= 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
@ -143,30 +374,49 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(assortid);
|
|
|
|
|
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag)));
|
|
|
|
|
if (collectorid.equals("15")){
|
|
|
|
|
reportDownPatientDto.setJzh(String.valueOf(map.get(inJzh)));
|
|
|
|
|
}else {
|
|
|
|
|
reportDownPatientDto.setInPatientNo(String.valueOf(map.get(inPatientNo)));
|
|
|
|
|
reportDownPatientDto.setVisitId(String.valueOf(map.get(visitId)));
|
|
|
|
|
}
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
|
|
|
|
|
// reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag)));
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl)));
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(System.currentTimeMillis()):String.valueOf(map.get(filetitle)));
|
|
|
|
|
reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum)))?String.valueOf(map.get(serialnum)):String.valueOf(idWorker.nextId()));
|
|
|
|
|
//reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(System.currentTimeMillis()):String.valueOf(map.get(filetitle)));
|
|
|
|
|
reportDownScanFileDto.setFiletitle(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId()));
|
|
|
|
|
reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum))) ? String.valueOf(map.get(serialnum)) : String.valueOf(idWorker.nextId()));
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
String post;
|
|
|
|
|
try {
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
|
|
|
|
|
Map resMap = JSON.parseObject(post, Map.class);
|
|
|
|
|
if (String.valueOf(resMap.get("code")).equals("500")) {
|
|
|
|
|
throw new RuntimeException(String.valueOf(resMap.get("msg")));
|
|
|
|
|
afCollectTaskService.insertServer(reportDownDto);
|
|
|
|
|
//String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector"));
|
|
|
|
|
String jzh = afCollectTaskService.getJzhByJzh(reportDownDto.getPatient().getJzh());
|
|
|
|
|
if (null != jzh && !("").equals(jzh)) {
|
|
|
|
|
reportDownPatientDto.setJzh(jzh);
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
|
|
|
|
|
Map resMap = JSON.parseObject(post, Map.class);
|
|
|
|
|
logger.info(reportDownDto.getPatient().getJzh()+" 调用下载参数:--\n"+JSON.parseObject(JSON.toJSONString(reportDownDto)));
|
|
|
|
|
if (String.valueOf(resMap.get("code")).equals("500")) {
|
|
|
|
|
logger.info(reportDownDto.getPatient().getJzh()+" 下载失败!");
|
|
|
|
|
throw new RuntimeException(String.valueOf(resMap.get("msg")));
|
|
|
|
|
}else {
|
|
|
|
|
logger.info(reportDownDto.getPatient().getJzh()+" 下载成功!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info("采集出错:"+reportDownDto);
|
|
|
|
|
//打印错误日志
|
|
|
|
|
logger.info(reportDownDto.getPatient().getJzh()+" 采集出错:" + reportDownDto +e.getMessage());
|
|
|
|
|
// String stackTrace = ExceptionUtils.getStackTrace(e);
|
|
|
|
|
// logger.info("错误信息----------"+stackTrace);
|
|
|
|
|
addMrReportErrorLog(reportDownDto);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -177,8 +427,14 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
@Override
|
|
|
|
|
public void timerCollect() {
|
|
|
|
|
logger.info("------采集器开始采集---------");
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
//1.获取上次采集时间
|
|
|
|
|
Date time = afCollectAddMapper.getTimeByAdd();
|
|
|
|
|
Date time;
|
|
|
|
|
if (collectorid.equals("5")) {
|
|
|
|
|
time = afCollectAddMapper.getTimeByAdd(5);
|
|
|
|
|
} else {
|
|
|
|
|
time = afCollectAddMapper.getTimeByAdd(15);
|
|
|
|
|
}
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String startDate = simpleDateFormat.format(time);
|
|
|
|
|
//当前日期
|
|
|
|
@ -190,13 +446,6 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
logger.info("--------采集器结束采集------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public String test(String collectSubId) {
|
|
|
|
|
AfInterfaceCollectSub x = afInterfaceCollectSubMapper.selectById(collectSubId);
|
|
|
|
|
System.out.println(x);
|
|
|
|
|
return x.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新采集时间
|
|
|
|
|
*/
|
|
|
|
@ -204,7 +453,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
AfCollectAdd afCollectAdd = new AfCollectAdd();
|
|
|
|
|
afCollectAdd.setBeginStageDate(date);
|
|
|
|
|
afCollectAddMapper.update(afCollectAdd,new QueryWrapper<AfCollectAdd>().eq("classify",collectorid));
|
|
|
|
|
afCollectAddMapper.update(afCollectAdd, new QueryWrapper<AfCollectAdd>().eq("classify", collectorid));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -227,14 +476,15 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
* @param exams
|
|
|
|
|
* @param empId
|
|
|
|
|
*/
|
|
|
|
|
private void collectExams(List<String[]> exams, String empId,ReportDownDto reportDownDto) throws Exception {
|
|
|
|
|
private void collectExams(List<String[]> exams, String empId, ReportDownDto reportDownDto) throws Exception {
|
|
|
|
|
//调用上传接口
|
|
|
|
|
Map<String, Object> headMap = new HashMap<>();
|
|
|
|
|
headMap.put("Content-Type", "application/json");
|
|
|
|
|
String post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
|
|
|
|
|
Map resMap = JSON.parseObject(post, Map.class);
|
|
|
|
|
System.out.println(resMap);
|
|
|
|
|
logger.info(empId+": 调用下载Map参数{}",JSON.toJSONString(reportDownDto));
|
|
|
|
|
if (String.valueOf(resMap.get("code")).equals("500")) {
|
|
|
|
|
logger.info(empId+"调用下载服务错误: "+(resMap.get("msg")));
|
|
|
|
|
throw new RuntimeException(String.valueOf(resMap.get("msg")));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -260,15 +510,29 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
|
|
|
|
|
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
|
|
|
|
|
for (String[] exam : exams) {
|
|
|
|
|
reportDownScanFileDto = getScanByExam(exam);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
try {
|
|
|
|
|
reportDownScanFileDto = getScanByExam(exam);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
//过滤pacs中病理报告
|
|
|
|
|
if (collectorid.equals("3")) {
|
|
|
|
|
if (!reportDownScanFileDto.getDownurl().contains("病理")
|
|
|
|
|
&& !reportDownScanFileDto.getDownurl().contains("胃肠镜")
|
|
|
|
|
&& !reportDownScanFileDto.getDownurl().contains("心电")) {
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
logger.error(exam[0]+"调用明细错误信息-----"+e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
return reportDownDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建ReportDownScanFileDto对象 通过报告单号
|
|
|
|
|
*
|
|
|
|
@ -276,19 +540,26 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private ReportDownScanFileDto getScanByExam(String[] exam) throws Exception {
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setSerialnum(exam[0]);
|
|
|
|
|
reportDownScanFileDto.setSerialnum(exam[0]);
|
|
|
|
|
reportDownScanFileDto.setFiletitle(exam[1]);
|
|
|
|
|
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlDetailsPath());
|
|
|
|
|
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlDetailsPath());
|
|
|
|
|
Element esbEntry = reqXmlUtils.getMsgElement();
|
|
|
|
|
esbEntry.element("EXAM_NO").setText(exam[0]);
|
|
|
|
|
String resXml = invokeWs(reqXmlUtils.getDocument().asXML());
|
|
|
|
|
String resXml;
|
|
|
|
|
logger.info("明细入参------------" + reqXmlUtils.getDocument().asXML());
|
|
|
|
|
if (collectorid.equals("14")) {
|
|
|
|
|
resXml = invokeWsNj(reqXmlUtils.getDocument().asXML());
|
|
|
|
|
} else {
|
|
|
|
|
resXml = invokeWs(reqXmlUtils.getDocument().asXML());
|
|
|
|
|
}
|
|
|
|
|
//解析XML
|
|
|
|
|
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
|
|
|
|
|
String success = xmlUtils.isSuccess();
|
|
|
|
|
if(!success.equals("ok")){
|
|
|
|
|
logger.info("发送错误:"+success);
|
|
|
|
|
throw new RuntimeException(success);
|
|
|
|
|
if (!success.equals("ok")) {
|
|
|
|
|
logger.info("发送错误:" + success);
|
|
|
|
|
throw new RuntimeException("发送错误:" + success);
|
|
|
|
|
}
|
|
|
|
|
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsDetailRespon");
|
|
|
|
|
//数据所在节点
|
|
|
|
@ -297,6 +568,8 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
return reportDownScanFileDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过empId获取报告单号集合
|
|
|
|
|
*
|
|
|
|
@ -305,10 +578,64 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
*/
|
|
|
|
|
private List<String[]> getExamNo(String empId) throws Exception {
|
|
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath());
|
|
|
|
|
Element reqElement = reqXmlUtils.getMsgElement();
|
|
|
|
|
Map<String, Date> map = afCollectAddMapper.selectDate(empId);
|
|
|
|
|
reqElement.element("INHOSP_NO").setText(empId);
|
|
|
|
|
reqElement.element("BEGIN_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("admiss_date")));
|
|
|
|
|
reqElement.element("END_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("dis_date")));
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
|
|
|
|
|
String xml = reqXmlUtils.getDocument().asXML();
|
|
|
|
|
logger.info("---------------------------");
|
|
|
|
|
logger.info(xml);
|
|
|
|
|
logger.info("----------------------------");
|
|
|
|
|
String resXml = invokeWs(xml);
|
|
|
|
|
logger.info("---------返回值-------------");
|
|
|
|
|
logger.info(resXml);
|
|
|
|
|
logger.info("-----------------------------");
|
|
|
|
|
//解析XML
|
|
|
|
|
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
|
|
|
|
|
String success = xmlUtils.isSuccess();
|
|
|
|
|
if (!success.equals("ok")) {
|
|
|
|
|
logger.info("发送错误:" + success);
|
|
|
|
|
throw new RuntimeException(success);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlPath());
|
|
|
|
|
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsRespon");
|
|
|
|
|
//数据所在节点
|
|
|
|
|
Element element = xmlUtils.getElement(dis);
|
|
|
|
|
List<Element> examInfos = element.elements("ExamInfo");
|
|
|
|
|
Element examNo;
|
|
|
|
|
String[] key;
|
|
|
|
|
for (Element examInfo : examInfos) {
|
|
|
|
|
key = new String[2];
|
|
|
|
|
examNo = examInfo.element(String.valueOf(FileUtils.getJsonByName("examNo")));
|
|
|
|
|
if (examNo != null) {
|
|
|
|
|
key[0] = examNo.getText();
|
|
|
|
|
}
|
|
|
|
|
Element examItemInfo = examInfo.element("ExamItemInfo");
|
|
|
|
|
if (examItemInfo != null) {
|
|
|
|
|
key[1] = examItemInfo.element(String.valueOf(FileUtils.getJsonByName("examItemName"))).getText();
|
|
|
|
|
}
|
|
|
|
|
exams.add(key);
|
|
|
|
|
}
|
|
|
|
|
return exams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过empId获取报告单号集合
|
|
|
|
|
*
|
|
|
|
|
* @param empId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<String[]> getExamNoNj(String empId) throws Exception {
|
|
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath());
|
|
|
|
|
Element reqElement = reqXmlUtils.getMsgElement();
|
|
|
|
|
Map<String, Date> map = afCollectAddMapper.selectDate(empId);
|
|
|
|
|
reqElement.element("INHOSP_NO").setText(empId);
|
|
|
|
|
reqElement.element("BEGIN_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("admiss_date")));
|
|
|
|
|
reqElement.element("END_DATE").setText(new SimpleDateFormat(FileUtils.getJsonByName("dateFormat").toString()).format(map.get("dis_date")));
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
|
|
|
|
|
String xml = reqXmlUtils.getDocument().asXML();
|
|
|
|
|
logger.info("---------------------------");
|
|
|
|
@ -321,8 +648,167 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
//解析XML
|
|
|
|
|
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
|
|
|
|
|
String success = xmlUtils.isSuccess();
|
|
|
|
|
if(!success.equals("ok")){
|
|
|
|
|
logger.info("发送错误:"+success);
|
|
|
|
|
if (!success.equals("ok")) {
|
|
|
|
|
logger.info("发送错误:" + success);
|
|
|
|
|
throw new RuntimeException(success);
|
|
|
|
|
}
|
|
|
|
|
String examNo;
|
|
|
|
|
String[] key;
|
|
|
|
|
String examName;
|
|
|
|
|
|
|
|
|
|
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsRespon");
|
|
|
|
|
//数据所在节点
|
|
|
|
|
Element element = xmlUtils.getElement(dis);
|
|
|
|
|
List<Element> elements = element.elements("Msg");
|
|
|
|
|
for (int i = 0; i < elements.size(); i++) {
|
|
|
|
|
List<Element> examInfo = elements.get(i).elements("ExamInfo");
|
|
|
|
|
for (int j = 0; j < examInfo.size(); j++) {
|
|
|
|
|
examNo = examInfo.get(j).element(String.valueOf(FileUtils.getJsonByName("examNo"))).getText();
|
|
|
|
|
key = new String[2];
|
|
|
|
|
if (examNo != null) {
|
|
|
|
|
key[0] = examNo;
|
|
|
|
|
}
|
|
|
|
|
Element examItemInfo = examInfo.get(j).element("ExamItemInfo");
|
|
|
|
|
if (examItemInfo != null) {
|
|
|
|
|
key[1] = examItemInfo.element(String.valueOf(FileUtils.getJsonByName("examItemName"))).getText();
|
|
|
|
|
}
|
|
|
|
|
exams.add(key);
|
|
|
|
|
logger.info("报告单号---{}",examNo);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return exams;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, String> getSmCollectionTime(String admissDate, String disDate) {
|
|
|
|
|
Date dBefore;
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); //得到日历
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(admissDate));//把当前时间赋给日历
|
|
|
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR, -6); //设置为前6小时
|
|
|
|
|
dBefore = calendar.getTime(); //得到前一天的时间
|
|
|
|
|
Calendar calendar1 = Calendar.getInstance(); //得到日历
|
|
|
|
|
calendar1.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(disDate));//把当前时间赋给日历
|
|
|
|
|
|
|
|
|
|
calendar1.add(Calendar.HOUR, 6); //设置为后6小时
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置时间格式
|
|
|
|
|
String defaultStartDate = sdf.format(dBefore); //格式化前6小时
|
|
|
|
|
String defaultEndDate = sdf.format(calendar1.getTime()); //格式化前6小时
|
|
|
|
|
map.put("admissDate", defaultStartDate);
|
|
|
|
|
map.put("disDate", defaultEndDate);
|
|
|
|
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Map<String, String> getSmCollectionTimeEcg(String admissDate, String disDate) {
|
|
|
|
|
Date dBefore;
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); //得到日历
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
calendar.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(admissDate));//把当前时间赋给日历
|
|
|
|
|
|
|
|
|
|
calendar.add(Calendar.HOUR, -6); //设置为前6小时
|
|
|
|
|
dBefore = calendar.getTime(); //得到前一天的时间
|
|
|
|
|
Calendar calendar1 = Calendar.getInstance(); //得到日历
|
|
|
|
|
calendar1.setTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(disDate));//把当前时间赋给日历
|
|
|
|
|
|
|
|
|
|
calendar1.add(Calendar.HOUR, 30); //设置为后30小时
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); //设置时间格式
|
|
|
|
|
String defaultStartDate = sdf.format(dBefore); //格式化前6小时
|
|
|
|
|
String defaultEndDate = sdf.format(calendar1.getTime()); //格式化前6小时
|
|
|
|
|
map.put("admissDate", defaultStartDate);
|
|
|
|
|
map.put("disDate", defaultEndDate);
|
|
|
|
|
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 通过empId获取报告单号集合 pacs
|
|
|
|
|
*
|
|
|
|
|
* @param empId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<String[]> getExamNo(String empId, String admissDate, String disDate) throws Exception {
|
|
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
// Map<String, String> Time = getSmCollectionTime(admissDate, disDate);
|
|
|
|
|
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath());
|
|
|
|
|
Element reqElement = reqXmlUtils.getMsgElement();
|
|
|
|
|
reqElement.element("INHOSP_INDEX_NO").setText(empId);
|
|
|
|
|
reqElement.element("BEGIN_DATE").setText(String.valueOf(admissDate));
|
|
|
|
|
reqElement.element("END_DATE").setText(String.valueOf(disDate));
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
|
|
|
|
|
String xml = reqXmlUtils.getDocument().asXML();
|
|
|
|
|
logger.info("---------------------------");
|
|
|
|
|
logger.info(xml);
|
|
|
|
|
logger.info("----------------------------");
|
|
|
|
|
String resXml = invokeWs(xml);
|
|
|
|
|
logger.info("---------返回值-------------");
|
|
|
|
|
logger.info(resXml);
|
|
|
|
|
logger.info("-----------------------------");
|
|
|
|
|
//解析XML
|
|
|
|
|
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
|
|
|
|
|
String success = xmlUtils.isSuccess();
|
|
|
|
|
if (!success.equals("ok")) {
|
|
|
|
|
logger.info("发送错误:" + success);
|
|
|
|
|
throw new RuntimeException(success);
|
|
|
|
|
}
|
|
|
|
|
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsRespon");
|
|
|
|
|
//数据所在节点
|
|
|
|
|
Element element = xmlUtils.getElement(dis);
|
|
|
|
|
List<Element> examInfos = element.elements("ExamInfo");
|
|
|
|
|
Element examNo;
|
|
|
|
|
String[] key;
|
|
|
|
|
for (Element examInfo : examInfos) {
|
|
|
|
|
key = new String[2];
|
|
|
|
|
examNo = examInfo.element(String.valueOf(FileUtils.getJsonByName("examNo")));
|
|
|
|
|
List<Element> examItemInfo = examInfo.elements("ExamItemInfo");
|
|
|
|
|
for (Element element1 : examItemInfo) {
|
|
|
|
|
if (examNo != null) {
|
|
|
|
|
key[0] = examNo.getText();
|
|
|
|
|
}
|
|
|
|
|
key[1] = element1.element(String.valueOf(FileUtils.getJsonByName("examItemName"))).getText();
|
|
|
|
|
}
|
|
|
|
|
exams.add(key);
|
|
|
|
|
}
|
|
|
|
|
return exams;
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 通过empId获取报告单号集合 动态心电
|
|
|
|
|
*
|
|
|
|
|
* @param empId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<String[]> getExamNoEcg(String empId, String admissDate, String disDate) throws Exception {
|
|
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
XmlUtils reqXmlUtils = new XmlUtils(FileUtils.getXmlPath());
|
|
|
|
|
Element reqElement = reqXmlUtils.getMsgElement();
|
|
|
|
|
reqElement.element("INHOSP_NO").setText(empId);
|
|
|
|
|
reqElement.element("BEGIN_DATE").setText(String.valueOf(admissDate));
|
|
|
|
|
reqElement.element("END_DATE").setText(String.valueOf(disDate));
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
|
|
|
|
|
String xml = reqXmlUtils.getDocument().asXML();
|
|
|
|
|
logger.info("---------------------------");
|
|
|
|
|
logger.info(xml);
|
|
|
|
|
logger.info("----------------------------");
|
|
|
|
|
String resXml = invokeWs(xml);
|
|
|
|
|
logger.info("---------返回值-------------");
|
|
|
|
|
logger.info(resXml);
|
|
|
|
|
logger.info("-----------------------------");
|
|
|
|
|
//解析XML
|
|
|
|
|
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
|
|
|
|
|
String success = xmlUtils.isSuccess();
|
|
|
|
|
if (!success.equals("ok")) {
|
|
|
|
|
logger.info("发送错误:" + success);
|
|
|
|
|
throw new RuntimeException(success);
|
|
|
|
|
}
|
|
|
|
|
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsRespon");
|
|
|
|
@ -347,6 +833,73 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间批量按需采集
|
|
|
|
|
*
|
|
|
|
|
* @param startDate 开始时间
|
|
|
|
|
* @param endDate 结束时间
|
|
|
|
|
* @param collectorId 采集器编号
|
|
|
|
|
*/
|
|
|
|
|
public void collectByDate(String startDate, String endDate, String collectorId) {
|
|
|
|
|
logger.info("按需采集开始----------开始时间---" + startDate + "------结束时间---" + endDate);
|
|
|
|
|
//页码
|
|
|
|
|
int startrow;
|
|
|
|
|
//每页10条数据
|
|
|
|
|
int endrow = 10;
|
|
|
|
|
//2.获取第一页10条数据开始采集
|
|
|
|
|
try{
|
|
|
|
|
List<Map> patientIds;
|
|
|
|
|
for (startrow = 0; ; startrow += 10) {
|
|
|
|
|
patientIds = afCollectTaskService.getjzhByDate(startDate, endDate, startrow, endrow);
|
|
|
|
|
|
|
|
|
|
if (null == patientIds || patientIds.size() <= 0) {
|
|
|
|
|
logger.info("未查询到按需采集患者!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
for (Map patientId : patientIds) {
|
|
|
|
|
if (patientId != null) {
|
|
|
|
|
try {
|
|
|
|
|
logger.info("按需采集------患者" + patientId.get("inpatient_no"));
|
|
|
|
|
logger.info("处理按需采集第" + startrow + "条数据----");
|
|
|
|
|
if (collectorId.equals("3")) {
|
|
|
|
|
collectPacs(String.valueOf(patientId.get("inpatient_no")), String.valueOf(patientId.get("admiss_date"))
|
|
|
|
|
, String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times")));
|
|
|
|
|
} else if (collectorId.equals("4") || collectorId.equals("23")) {
|
|
|
|
|
collectEcg(String.valueOf(patientId.get("jzh")), String.valueOf(patientId.get("admiss_date"))
|
|
|
|
|
, String.valueOf(patientId.get("dis_date")), String.valueOf(patientId.get("admiss_times")));
|
|
|
|
|
} else {
|
|
|
|
|
collect(String.valueOf(patientId.get("jzh")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error("按需采集-患者inpatient_no:{},collectPacs() Error:{}", patientId.get("inpatient_no"), e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
patientIds.clear();
|
|
|
|
|
}
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
}catch (Throwable t) {
|
|
|
|
|
t.printStackTrace();
|
|
|
|
|
logger.error("throwable,{}", t.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static JaxWsDynamicClientFactory wsDynamicClientFactory = JaxWsDynamicClientFactory.newInstance();
|
|
|
|
|
private static volatile Client client = null;
|
|
|
|
|
|
|
|
|
|
private Client getClient() {
|
|
|
|
|
if (client == null) {
|
|
|
|
|
synchronized (this.getClass()) {
|
|
|
|
|
client = wsDynamicClientFactory.createClient(wsUrl);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return client;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调用web service
|
|
|
|
|
*
|
|
|
|
@ -356,14 +909,60 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
*/
|
|
|
|
|
public String invokeWs(String xml) throws Exception {
|
|
|
|
|
logger.info("-----\n客户端调用服务端:" + wsUrl + "方法:" + wsLocalMethod + "\n------------");
|
|
|
|
|
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
|
|
|
|
|
Client client = dcf.createClient(wsUrl);
|
|
|
|
|
// JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
|
|
|
|
|
// Client client = dcf.createClient(wsUrl);
|
|
|
|
|
// LocalBusFactory.printTHREAD_BUSSES();
|
|
|
|
|
// JaxWsDynamicClientFactory wsDynamicClientFactory = JaxWsDynamicClientFactory.newInstance();
|
|
|
|
|
// logger.info("JaxWsDynamicClientFactory object created!");
|
|
|
|
|
// Client client = wsDynamicClientFactory.createClient(wsUrl);
|
|
|
|
|
Client client = this.getClient();
|
|
|
|
|
|
|
|
|
|
HTTPConduit conduit = (HTTPConduit) client.getConduit();
|
|
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
|
|
policy.setConnectionTimeout(10000);
|
|
|
|
|
policy.setReceiveTimeout(10000);
|
|
|
|
|
conduit.setClient(policy);
|
|
|
|
|
logger.info("Client started!");
|
|
|
|
|
Object[] objects = client.invoke(wsLocalMethod, xml);
|
|
|
|
|
logger.info("Client invoke after!");
|
|
|
|
|
String str = objects[0].toString();
|
|
|
|
|
logger.info("----------结果---------");
|
|
|
|
|
logger.info(str);
|
|
|
|
|
// client.destroy();
|
|
|
|
|
logger.info("----------结果---------\n{}", str);
|
|
|
|
|
// logger.info(str);
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调用web service
|
|
|
|
|
*
|
|
|
|
|
* @param xml
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
|
*/
|
|
|
|
|
public String invokeWsNj(String xml) throws Exception {
|
|
|
|
|
logger.info("-----\n客户端调用服务端:" + wsUrl + "方法:" + wsLocalMethodNj + "\n------------");
|
|
|
|
|
// JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
|
|
|
|
|
// Client client = dcf.createClient(wsUrl);
|
|
|
|
|
// LocalBusFactory.printTHREAD_BUSSES();
|
|
|
|
|
// JaxWsDynamicClientFactory wsDynamicClientFactory = JaxWsDynamicClientFactory.newInstance();
|
|
|
|
|
// logger.info("JaxWsDynamicClientFactory object created!");
|
|
|
|
|
// Client client = wsDynamicClientFactory.createClient(wsUrl);
|
|
|
|
|
Client client = this.getClient();
|
|
|
|
|
|
|
|
|
|
HTTPConduit conduit = (HTTPConduit) client.getConduit();
|
|
|
|
|
HTTPClientPolicy policy = new HTTPClientPolicy();
|
|
|
|
|
policy.setConnectionTimeout(10000);
|
|
|
|
|
policy.setReceiveTimeout(10000);
|
|
|
|
|
conduit.setClient(policy);
|
|
|
|
|
logger.info("Client started!");
|
|
|
|
|
Object[] objects = client.invoke(wsLocalMethodNj, xml);
|
|
|
|
|
logger.info("Client invoke after!");
|
|
|
|
|
String str = objects[0].toString();
|
|
|
|
|
// client.destroy();
|
|
|
|
|
logger.info("----------结果---------\n{}", str);
|
|
|
|
|
// logger.info(str);
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|