|
|
|
@ -1,36 +1,45 @@
|
|
|
|
|
package com.docus.bgts.service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import ch.qos.logback.core.util.FileUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
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.dbmysql.*;
|
|
|
|
|
import com.docus.bgts.mapper.dboracle.VDocumentPdfMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbsqlserver.PatientBLMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbsqlserver.PatientBRMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbsqlserver.ScanningMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dbsqlserver.TestttMapper;
|
|
|
|
|
import com.docus.bgts.utils.*;
|
|
|
|
|
import org.apache.commons.codec.digest.MurmurHash2;
|
|
|
|
|
import org.apache.commons.codec.digest.MurmurHash3;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.commons.lang3.exception.ExceptionUtils;
|
|
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
|
|
import org.apache.cxf.helpers.IOUtils;
|
|
|
|
|
import org.apache.http.client.utils.DateUtils;
|
|
|
|
|
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.Text;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.context.ApplicationContext;
|
|
|
|
|
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
@ -61,6 +70,22 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
@Autowired
|
|
|
|
|
AfCollectTaskMapper afCollectTaskMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TestttMapper testMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
PatientBRMapper patientBRMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
PatientBLMapper patientBLMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TBasicOutMapper tBasicOutMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
ScanningMapper scanningMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collect(String empId) throws Exception {
|
|
|
|
|
//通过empId获取报告单号集合
|
|
|
|
@ -73,6 +98,22 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
collectExams(exams, empId, reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectPacs(String empId, String admissDate, String disDate, String times) throws Exception {
|
|
|
|
|
//通过empId获取报告单号集合
|
|
|
|
|
List<String[]> exams = getExamNo(empId, admissDate, disDate);
|
|
|
|
|
String jzh = afCollectTaskService.getJzhByInpatientNo(empId, times);
|
|
|
|
|
if (null == jzh) {
|
|
|
|
|
throw new RuntimeException("通过住院号与住院次数未匹配到患者");
|
|
|
|
|
}
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, jzh);
|
|
|
|
|
//插入文件af_collect_task表数据
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
//通过报告单号集合采集
|
|
|
|
|
collectExams(exams, empId, reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectByExamNo(String emamNo, String empId) throws Exception {
|
|
|
|
|
String[] strings = new String[2];
|
|
|
|
@ -100,111 +141,36 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
//当前日期
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
String dateStr = simpleDateFormat.format(date);
|
|
|
|
|
collectByDates(startCollectTime, dateStr);
|
|
|
|
|
collectByDateJz(startCollectTime, dateStr);
|
|
|
|
|
//更新采集时间
|
|
|
|
|
addAfCollectAdd(date);
|
|
|
|
|
// addAfCollectAdd(date);
|
|
|
|
|
logger.info("--------------全量采集结束------------------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间到采集任务 手麻
|
|
|
|
|
*
|
|
|
|
|
* @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);
|
|
|
|
|
@Override
|
|
|
|
|
public void collectxx() {
|
|
|
|
|
logger.info("----------全量采集开始-----------");
|
|
|
|
|
//1.获取最早采集日期
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String startCollectTime = null;
|
|
|
|
|
startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime"));
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
logger.info("----------采集初始时间:" + startCollectTime + " -------------------");
|
|
|
|
|
//当前日期
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
String dateStr = simpleDateFormat.format(date);
|
|
|
|
|
collectByDateTest(startCollectTime, dateStr);
|
|
|
|
|
//更新采集时间
|
|
|
|
|
// addAfCollectAdd(date);
|
|
|
|
|
logger.info("--------------全量采集结束------------------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间到采集任务 重症
|
|
|
|
|
*
|
|
|
|
|
* @param startDate
|
|
|
|
|
* @param endDate
|
|
|
|
|
*/
|
|
|
|
|
// /**
|
|
|
|
|
// * 根据时间到采集任务 手麻
|
|
|
|
|
// *
|
|
|
|
|
// * @param startDate
|
|
|
|
|
// * @param endDate
|
|
|
|
|
// */
|
|
|
|
|
// private void collectByDates(String startDate, String endDate) {
|
|
|
|
|
// //页码
|
|
|
|
|
// int current;
|
|
|
|
@ -219,33 +185,42 @@ 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<>();
|
|
|
|
|
// List<String> fieldArr = new ArrayList<>();
|
|
|
|
|
// fieldArr.add(indexFlag);
|
|
|
|
|
// fieldArr.add(serialnum);
|
|
|
|
|
//// if(StringUtils.isNotBlank(filetitle)){
|
|
|
|
|
//// fieldArr.add(filetitle);
|
|
|
|
|
//// }
|
|
|
|
|
// 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(size-10, 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;
|
|
|
|
|
// }
|
|
|
|
|
// maps.stream().forEach(map -> {
|
|
|
|
|
// 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);
|
|
|
|
@ -255,15 +230,15 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
// 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.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()));
|
|
|
|
|
// 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);
|
|
|
|
@ -272,16 +247,182 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
// }
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// //打印错误日志
|
|
|
|
|
// logger.info("采集出错:"+reportDownDto);
|
|
|
|
|
// logger.info("采集出错:" + reportDownDto);
|
|
|
|
|
// logger.info(e);
|
|
|
|
|
// String stackTrace = ExceptionUtils.getStackTrace(e);
|
|
|
|
|
// logger.info("错误信息----------"+stackTrace);
|
|
|
|
|
// logger.info("错误信息----------" + stackTrace);
|
|
|
|
|
// addMrReportErrorLog(reportDownDto);
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间到采集任务 重症
|
|
|
|
|
*
|
|
|
|
|
* @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"));
|
|
|
|
|
String inPatientNo = String.valueOf(FileUtils.getJsonByName("inPatientNo"));
|
|
|
|
|
String visitId = String.valueOf(FileUtils.getJsonByName("visitId"));
|
|
|
|
|
|
|
|
|
|
List<String> fieldArr = new ArrayList<>();
|
|
|
|
|
fieldArr.add(indexFlag);
|
|
|
|
|
fieldArr.add(serialnum);
|
|
|
|
|
fieldArr.add(inPatientNo);
|
|
|
|
|
fieldArr.add(visitId);
|
|
|
|
|
// 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(size - 10, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
|
|
|
|
|
logger.info("处理采集数据:" + maps);
|
|
|
|
|
if (null == maps || maps.size() <= 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
maps.stream().forEach(map -> {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(assortid);
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
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.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.insertServer(reportDownDto);
|
|
|
|
|
//String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector"));
|
|
|
|
|
String jzh = afCollectTaskService.getJzhByInpatientNo(reportDownDto.getPatient().getInPatientNo(), reportDownDto.getPatient().getVisitId());
|
|
|
|
|
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);
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void timerCollectSmDay() {
|
|
|
|
|
logger.info("------采集器开始采集---------");
|
|
|
|
|
//获取前一天开始结束时间
|
|
|
|
|
Map<String, String> time = getSmCollectionTime(new Date());
|
|
|
|
|
collectByDateSm(time.get("startDate"), time.get("endDate"));
|
|
|
|
|
//更新采集时间
|
|
|
|
|
logger.info("--------采集器结束采集------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void SmCollect(String inPatientId,String vistId) {
|
|
|
|
|
List<Map> maps = scanningMapper.selectByInPatientId(inPatientId,vistId);
|
|
|
|
|
int i = scanningMapper.selectRow(inPatientId,vistId);
|
|
|
|
|
logger.info(inPatientId+"患者扫描病历共"+i+"条----");
|
|
|
|
|
Map<String, Object> headMap = new HashMap<>();
|
|
|
|
|
headMap.put("Content-Type", "application/json");
|
|
|
|
|
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
|
|
|
|
|
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
|
|
|
|
|
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
|
|
|
|
|
int i1 =0;
|
|
|
|
|
for (Map map : maps) {
|
|
|
|
|
try {
|
|
|
|
|
i1++;
|
|
|
|
|
logger.info("当前第"+i1+"条------");
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
|
|
|
|
|
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
|
|
|
|
|
String patientId = afCollectTaskService.getPatientIdByInpatientNo(String.valueOf(map.get("住院号")), String.valueOf(map.get("次数")));
|
|
|
|
|
if (null != patientId) {
|
|
|
|
|
reportDownPatientDto.setPatientid(patientId);
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setFiletype(filetype);
|
|
|
|
|
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
|
|
|
|
|
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf(".")));
|
|
|
|
|
//处理下载地址为唯一值
|
|
|
|
|
String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名"));
|
|
|
|
|
reportDownScanFileDto.setSerialnum(ser);
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
afCollectTaskService.insertServer(reportDownDto);
|
|
|
|
|
String post;
|
|
|
|
|
logger.info("上传下载参数-----" + 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")) {
|
|
|
|
|
logger.info("下载服务-------" + String.valueOf(resMap.get("msg")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(String.valueOf(map.get("住院号")) + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void timerCollect() {
|
|
|
|
|
logger.info("------采集器开始采集---------");
|
|
|
|
@ -289,9 +430,11 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
//1.获取上次采集时间
|
|
|
|
|
Date time;
|
|
|
|
|
if (collectorid.equals("5")) {
|
|
|
|
|
time = afCollectAddMapper.getTimeByAdd(5);
|
|
|
|
|
}else {
|
|
|
|
|
time = afCollectAddMapper.getTimeByAdd(5);
|
|
|
|
|
} else if (collectorid.equals("15")) {
|
|
|
|
|
time = afCollectAddMapper.getTimeByAdd(15);
|
|
|
|
|
} else {
|
|
|
|
|
time = afCollectAddMapper.getTimeByAdd(24);
|
|
|
|
|
}
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String startDate = simpleDateFormat.format(time);
|
|
|
|
@ -304,6 +447,308 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
logger.info("--------采集器结束采集------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void timerCollectSmIncrement() {
|
|
|
|
|
logger.info("------采集器开始采集---------");
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
//1.获取上次采集时间
|
|
|
|
|
Date time;
|
|
|
|
|
time = afCollectAddMapper.getTimeByAdd(25);
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
String startDate = simpleDateFormat.format(time);
|
|
|
|
|
//当前日期
|
|
|
|
|
Date date = new Date();
|
|
|
|
|
String endDate = simpleDateFormat.format(date);
|
|
|
|
|
logger.info("增量采集开始----采集扫描日期区间为"+startDate+"-----"+endDate);
|
|
|
|
|
collectByDateSm(startDate, endDate);
|
|
|
|
|
//更新采集时间
|
|
|
|
|
addAfCollectAdd(date);
|
|
|
|
|
logger.info("--------采集器结束采集------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 获取前一天开始与结束时间
|
|
|
|
|
*
|
|
|
|
|
* @param date
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
public static Map<String, String> getSmCollectionTime(Date date) {
|
|
|
|
|
Date dBefore;
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); //得到日历
|
|
|
|
|
calendar.setTime(date);//把当前时间赋给日历
|
|
|
|
|
calendar.add(Calendar.DAY_OF_MONTH, -1); //设置为前一天
|
|
|
|
|
dBefore = calendar.getTime(); //得到前一天的时间
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); //设置时间格式
|
|
|
|
|
String defaultStartDate = sdf.format(dBefore); //格式化前一天
|
|
|
|
|
defaultStartDate = defaultStartDate + " 00:00:00";
|
|
|
|
|
String defaultEndDate = defaultStartDate.substring(0, 10) + " 23:59:59";
|
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
|
map.put("startDate", defaultStartDate);
|
|
|
|
|
map.put("endDate", defaultEndDate);
|
|
|
|
|
return map;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间采集扫描电子病历
|
|
|
|
|
*/
|
|
|
|
|
private void collectByDateJz(String startDate, String endDate) {
|
|
|
|
|
//页码
|
|
|
|
|
int startrow;
|
|
|
|
|
//每页10条数据
|
|
|
|
|
int endrow;
|
|
|
|
|
//2.获取第一页10条数据开始采集
|
|
|
|
|
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
|
|
|
|
|
Map<String, Object> headMap = new HashMap<>();
|
|
|
|
|
headMap.put("Content-Type", "application/json");
|
|
|
|
|
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
|
|
|
|
|
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
|
|
|
|
|
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
|
|
|
|
|
List<Map> maps;
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
String format;
|
|
|
|
|
for (startrow = 1; ; startrow += 10) {
|
|
|
|
|
endrow = 10 + startrow;
|
|
|
|
|
maps = scanningMapper.selectAllByDisDate(startrow, endrow - 1, startDate, endDate);
|
|
|
|
|
logger.info("处理采集数据" + maps);
|
|
|
|
|
// List<Map> maps = patientBRMapper.selectAll(1,1,startDate,endDate);
|
|
|
|
|
if (null == maps || maps.size() <= 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
try {
|
|
|
|
|
for (Map map : maps) {
|
|
|
|
|
try {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
|
|
|
|
|
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
|
|
|
|
|
Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期")));
|
|
|
|
|
format = simpleDateFormat.format(parse);
|
|
|
|
|
String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")),format);
|
|
|
|
|
if (null != patientId) {
|
|
|
|
|
reportDownPatientDto.setPatientid(patientId);
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setFiletype(filetype);
|
|
|
|
|
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
|
|
|
|
|
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf(".")));
|
|
|
|
|
//处理下载地址为唯一值
|
|
|
|
|
String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名"));
|
|
|
|
|
logger.info("唯一值++++++" + ser);
|
|
|
|
|
reportDownScanFileDto.setSerialnum(ser);
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
afCollectTaskService.insertServer(reportDownDto);
|
|
|
|
|
String post;
|
|
|
|
|
logger.info("上传下载参数-----" + 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")) {
|
|
|
|
|
logger.info("下载服务-------" + String.valueOf(resMap.get("msg")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(String.valueOf(map.get("住院号")) + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
logger.error("throwable{}", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
// System.err.println(startrow+"---------------"+(endrow-1));
|
|
|
|
|
// System.err.println("处理数据---"+maps);
|
|
|
|
|
maps.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间采集扫描电子病历
|
|
|
|
|
*/
|
|
|
|
|
private void collectByDateTest(String startDate, String endDate) {
|
|
|
|
|
//页码
|
|
|
|
|
int startrow;
|
|
|
|
|
//每页10条数据
|
|
|
|
|
int endrow;
|
|
|
|
|
//2.获取第一页10条数据开始采集
|
|
|
|
|
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
|
|
|
|
|
Map<String, Object> headMap = new HashMap<>();
|
|
|
|
|
headMap.put("Content-Type", "application/json");
|
|
|
|
|
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
|
|
|
|
|
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
|
|
|
|
|
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
|
|
|
|
|
List<Map> maps;
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
String format;
|
|
|
|
|
for (startrow = 1; ; startrow += 10) {
|
|
|
|
|
endrow = 10 + startrow;
|
|
|
|
|
maps = scanningMapper.selectAllByDisDate(startrow, endrow - 1, startDate, endDate);
|
|
|
|
|
logger.info("处理采集数据" + maps);
|
|
|
|
|
// List<Map> maps = patientBRMapper.selectAll(1,1,startDate,endDate);
|
|
|
|
|
if (null == maps || maps.size() <= 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
for (Map map : maps) {
|
|
|
|
|
try {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
|
|
|
|
|
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
|
|
|
|
|
Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期")));
|
|
|
|
|
format = simpleDateFormat.format(parse);
|
|
|
|
|
String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")), format);
|
|
|
|
|
if (null != patientId) {
|
|
|
|
|
reportDownPatientDto.setPatientid(patientId);
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setFiletype(filetype);
|
|
|
|
|
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
|
|
|
|
|
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")));
|
|
|
|
|
//处理下载地址为唯一值
|
|
|
|
|
String ser = String.valueOf(map.get("图像路径").hashCode()) + "/" + String.valueOf(map.get("文件名").hashCode());
|
|
|
|
|
int i1 = MurmurHash2.hash32(ser);
|
|
|
|
|
reportDownScanFileDto.setSerialnum(Integer.toBinaryString(i1).toString());
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
afCollectTaskService.insertServer(reportDownDto);
|
|
|
|
|
String post;
|
|
|
|
|
logger.info("上传下载参数-----" + 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")) {
|
|
|
|
|
logger.info("下载服务-------" + String.valueOf(resMap.get("msg")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
logger.info(String.valueOf(map.get("住院号")) + "患者基础信息不存在!");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(String.valueOf(map.get("住院号")) + e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
logger.error(e.getMessage());
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
logger.error("throwable{}", e.getMessage());
|
|
|
|
|
}
|
|
|
|
|
// System.err.println(startrow+"---------------"+(endrow-1));
|
|
|
|
|
// System.err.println("处理数据---"+maps);
|
|
|
|
|
maps.clear();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据时间采集扫描电子病历
|
|
|
|
|
*/
|
|
|
|
|
private void collectByDateSm(String startDate, String endDate) {
|
|
|
|
|
//页码
|
|
|
|
|
int startrow;
|
|
|
|
|
//每页10条数据
|
|
|
|
|
int endrow;
|
|
|
|
|
//2.获取第一页10条数据开始采集
|
|
|
|
|
logger.info("开始时间-----" + startDate + "结束时间-----" + "\n" + endDate);
|
|
|
|
|
Map<String, Object> headMap = new HashMap<>();
|
|
|
|
|
headMap.put("Content-Type", "application/json");
|
|
|
|
|
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
|
|
|
|
|
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
|
|
|
|
|
int filetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filetype")));
|
|
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
|
|
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
|
|
|
|
|
List<Map> maps;
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
String format;
|
|
|
|
|
for (startrow = 1; ; startrow += 10) {
|
|
|
|
|
endrow = 10 + startrow;
|
|
|
|
|
maps = scanningMapper.selectAll(startrow, endrow - 1, startDate, endDate);
|
|
|
|
|
// List<Map> maps = patientBRMapper.selectAll(1,1,startDate,endDate);
|
|
|
|
|
if (null == maps || maps.size() <= 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
logger.info("处理采集数据" + maps);
|
|
|
|
|
|
|
|
|
|
for (Map map : maps) {
|
|
|
|
|
try {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(String.valueOf(map.get("分类id")));
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
|
|
|
|
|
// reportDownPatientDto.setInPatientNo(String.valueOf(map.get("住院号")));
|
|
|
|
|
// reportDownPatientDto.setVisitId(String.valueOf(map.get("次数")));
|
|
|
|
|
Date parse = simpleDateFormat.parse(String.valueOf(map.get("出院日期")));
|
|
|
|
|
format = simpleDateFormat.format(parse);
|
|
|
|
|
String patientId = afCollectTaskService.getPatientIdByInpatientNoAndDate(String.valueOf(map.get("住院号")), format);
|
|
|
|
|
reportDownPatientDto.setPatientid(patientId);
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setFiletype(filetype);
|
|
|
|
|
reportDownScanFileDto.setDownurl(String.valueOf(map.get("图像路径")) + "/" + String.valueOf(map.get("文件名")));
|
|
|
|
|
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")).substring(0,map.get("文件名").toString().indexOf(".")));
|
|
|
|
|
//处理下载地址为唯一值
|
|
|
|
|
String ser = String.valueOf(map.get("主键")) + String.valueOf(map.get("分段名称")) + String.valueOf(map.get("文件名"));
|
|
|
|
|
reportDownScanFileDto.setFiletitle(String.valueOf(map.get("文件名")));
|
|
|
|
|
reportDownScanFileDto.setSerialnum(ser);
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
afCollectTaskService.insertServer(reportDownDto);
|
|
|
|
|
String post;
|
|
|
|
|
logger.info("上传下载参数-----" + 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")) {
|
|
|
|
|
logger.info("下载服务{}", String.valueOf(resMap.get("msg")));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.error(String.valueOf(map.get("住院号") + "错误信息" + e.getMessage()));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
} catch (Throwable t) {
|
|
|
|
|
logger.error("throwable,{}", t.getMessage());
|
|
|
|
|
}
|
|
|
|
|
maps.clear();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 更新采集时间
|
|
|
|
|
*/
|
|
|
|
@ -376,6 +821,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
return reportDownDto;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 创建ReportDownScanFileDto对象 通过报告单号
|
|
|
|
|
*
|
|
|
|
@ -416,7 +862,62 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
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获取报告单号集合 pacs
|
|
|
|
|
*
|
|
|
|
|
* @param empId
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
private List<String[]> getExamNo(String empId, String admissDate, String disDate) 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_INDEX_NO").setText(empId);
|
|
|
|
|
reqElement.element("BEGIN_DATE").setText(admissDate);
|
|
|
|
|
reqElement.element("END_DATE").setText(disDate);
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
|
|
|
|
|
String xml = reqXmlUtils.getDocument().asXML();
|
|
|
|
|
logger.info("---------------------------");
|
|
|
|
@ -489,8 +990,8 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
// }
|
|
|
|
|
try {
|
|
|
|
|
for (String patientId : patientIds) {
|
|
|
|
|
if (patientId!=null){
|
|
|
|
|
logger.info("按需采集------患者"+patientId);
|
|
|
|
|
if (patientId != null) {
|
|
|
|
|
logger.info("按需采集------患者" + patientId);
|
|
|
|
|
collect(patientId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -506,6 +1007,10 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map> test(int size, int current) {
|
|
|
|
|
return testMapper.selectAll(size, current);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调用web service
|
|
|
|
|
*
|
|
|
|
@ -524,5 +1029,6 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|