|
|
package com.docus.bgts.service;
|
|
|
|
|
|
|
|
|
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.commons.lang3.exception.ExceptionUtils;
|
|
|
import org.apache.cxf.endpoint.Client;
|
|
|
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.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.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
public class BgtsServiceImpl implements IBgtsService {
|
|
|
@Value("${ws.url}")
|
|
|
private String wsUrl;
|
|
|
@Value("${ws.localMethod}")
|
|
|
private String wsLocalMethod;
|
|
|
|
|
|
private Logger logger = LogManager.getLogger(BgtsServiceImpl.class);
|
|
|
|
|
|
@Autowired
|
|
|
IAfCollectTaskService afCollectTaskService;
|
|
|
|
|
|
@Autowired
|
|
|
VDocumentPdfMapper vDocumentPdfMapper;
|
|
|
|
|
|
@Autowired
|
|
|
AfInterfaceCollectSubMapper afInterfaceCollectSubMapper;
|
|
|
|
|
|
@Autowired
|
|
|
MrReportErrorMapper mrReportErrorMapper;
|
|
|
|
|
|
@Autowired
|
|
|
AfCollectAddMapper afCollectAddMapper;
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
AfCollectTaskMapper afCollectTaskMapper;
|
|
|
|
|
|
@Override
|
|
|
public void collect(String empId) throws Exception {
|
|
|
//通过empId获取报告单号集合
|
|
|
List<String[]> exams = getExamNo(empId);
|
|
|
//获取插入表数据
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
|
|
|
//插入文件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];
|
|
|
//通过报告单号和系统id查询任务表
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
AfCollectTask afCollectTask = afCollectTaskService.getOne(new QueryWrapper<AfCollectTask>().eq("C1", emamNo).eq("sysflag", collectorid));
|
|
|
strings[0] = emamNo;
|
|
|
strings[1] = afCollectTask.getC2();
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
exams.add(strings);
|
|
|
//获取插入表数据
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
|
|
|
collectExams(exams, empId,reportDownDto);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void collectAll() {
|
|
|
logger.info("----------全量采集开始-----------");
|
|
|
//1.获取最早采集日期
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String startCollectTime = null;
|
|
|
startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime"));
|
|
|
|
|
|
logger.info("----------采集初始时间:" + startCollectTime + " -------------------");
|
|
|
//当前日期
|
|
|
Date date = new Date();
|
|
|
String dateStr = simpleDateFormat.format(date);
|
|
|
collectByDates(startCollectTime, dateStr);
|
|
|
//更新采集时间
|
|
|
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.stream().forEach(map -> {
|
|
|
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();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}*/
|
|
|
/**
|
|
|
* 根据时间到采集任务 重症
|
|
|
*
|
|
|
* @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条数据开始采集
|
|
|
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.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.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);
|
|
|
//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();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void timerCollect() {
|
|
|
logger.info("------采集器开始采集---------");
|
|
|
//1.获取上次采集时间
|
|
|
Date time = afCollectAddMapper.getTimeByAdd();
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
String startDate = simpleDateFormat.format(time);
|
|
|
//当前日期
|
|
|
Date date = new Date();
|
|
|
String endDate = simpleDateFormat.format(date);
|
|
|
collectByDates(startDate, endDate);
|
|
|
//更新采集时间
|
|
|
addAfCollectAdd(date);
|
|
|
logger.info("--------采集器结束采集------");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 更新采集时间
|
|
|
*/
|
|
|
private void addAfCollectAdd(Date date) {
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
AfCollectAdd afCollectAdd = new AfCollectAdd();
|
|
|
afCollectAdd.setBeginStageDate(date);
|
|
|
afCollectAddMapper.update(afCollectAdd,new QueryWrapper<AfCollectAdd>().eq("classify",collectorid));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 全量采集错误记录日志
|
|
|
*
|
|
|
* @param reportDownDto
|
|
|
*/
|
|
|
private void addMrReportErrorLog(ReportDownDto reportDownDto) {
|
|
|
MrReportError mrReportError = new MrReportError();
|
|
|
mrReportError.setCreateTime(new Date());
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
mrReportError.setReportType(Integer.parseInt(collectorid));
|
|
|
mrReportError.setXml(JSON.toJSONString(reportDownDto));
|
|
|
mrReportErrorMapper.insert(mrReportError);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过报告单号集合采集数据
|
|
|
*
|
|
|
* @param exams
|
|
|
* @param empId
|
|
|
*/
|
|
|
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);
|
|
|
if (String.valueOf(resMap.get("code")).equals("500")) {
|
|
|
throw new RuntimeException(String.valueOf(resMap.get("msg")));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取图片url,病返回插入表对象
|
|
|
*
|
|
|
* @param exams
|
|
|
* @param empId
|
|
|
* @return
|
|
|
*/
|
|
|
private ReportDownDto getUrlCreateReportDto(List<String[]> exams, String empId) throws Exception {
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
reportDownPatientDto.setJzh(empId);
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
|
|
|
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
|
|
|
reportDownDto.setAssortid(assortid);
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
ReportDownScanFileDto reportDownScanFileDto;
|
|
|
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);
|
|
|
}
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
return reportDownDto;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 创建ReportDownScanFileDto对象 通过报告单号
|
|
|
*
|
|
|
* @param exam
|
|
|
* @return
|
|
|
*/
|
|
|
private ReportDownScanFileDto getScanByExam(String[] exam) throws Exception {
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
reportDownScanFileDto.setSerialnum(exam[0]);
|
|
|
reportDownScanFileDto.setFiletitle(exam[1]);
|
|
|
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlDetailsPath());
|
|
|
Element esbEntry = reqXmlUtils.getMsgElement();
|
|
|
esbEntry.element("EXAM_NO").setText(exam[0]);
|
|
|
String resXml = invokeWs(reqXmlUtils.getDocument().asXML());
|
|
|
logger.info("明细入参------------"+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);
|
|
|
}
|
|
|
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsDetailRespon");
|
|
|
//数据所在节点
|
|
|
Element element = xmlUtils.getElement(dis);
|
|
|
reportDownScanFileDto.setDownurl(element.element(String.valueOf(FileUtils.getJsonByName("pdfUrl"))) == null ? "" : element.element(String.valueOf(FileUtils.getJsonByName("pdfUrl"))).getText());
|
|
|
return reportDownScanFileDto;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 通过empId获取报告单号集合
|
|
|
*
|
|
|
* @param empId
|
|
|
* @return
|
|
|
*/
|
|
|
private List<String[]> getExamNo(String empId) throws Exception {
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
|
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlPath());
|
|
|
Element reqElement = reqXmlUtils.getMsgElement();
|
|
|
reqElement.element("INHOSP_NO").setText(empId);
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
|
|
|
/**
|
|
|
* 根据时间批量按需采集
|
|
|
* @param startDate 开始时间
|
|
|
* @param endDate 结束时间
|
|
|
* @param collectorId 采集器编号
|
|
|
*/
|
|
|
public void collectByDate(String startDate,String endDate,String collectorId){
|
|
|
//通过日期查询patientId集合
|
|
|
List<String> patientIds = afCollectTaskService.getjzhByDate(startDate,endDate);
|
|
|
//通过patientId集合与采集器编号查询报告单号
|
|
|
//List<String> c1s = afCollectTaskService.getC1ByPatientId(patientIds, collectorId);
|
|
|
//通过唯一报告单号查询patient_id
|
|
|
//List<String> patientIdByC1 = afCollectTaskService.getPatientIdByC1(c1s);
|
|
|
//通过patientId集合查询jzh
|
|
|
List<String> jzhs = afCollectTaskService.getJzhByPatientId(patientIds);
|
|
|
//int i = -1;
|
|
|
//循环jzh与报告单号c1调用按需采集
|
|
|
// for (String c1 : c1s) {
|
|
|
// try {
|
|
|
// if (i<c1s.size()) {
|
|
|
// i++;
|
|
|
// //System.err.println(c1s.get(i) + "--------" + jzhs.get(i));
|
|
|
// //HttpUtils.get("127.0.0.1:"+port+"/collectByExamNo?emamNo="+c1+"&empId="+jzh);
|
|
|
// collectByExamNo(c1s.get(i), jzhs.get(i));
|
|
|
// }
|
|
|
//
|
|
|
//
|
|
|
// } catch (Exception e) {
|
|
|
// e.printStackTrace();
|
|
|
// }
|
|
|
// }
|
|
|
try {
|
|
|
for (String jzh : jzhs) {
|
|
|
collect(jzh);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 调用web service
|
|
|
*
|
|
|
* @param xml
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public String invokeWs(String xml) throws Exception {
|
|
|
logger.info("-----\n客户端调用服务端:" + wsUrl + "方法:" + wsLocalMethod + "\n------------");
|
|
|
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
|
|
|
Client client = dcf.createClient(wsUrl);
|
|
|
Object[] objects = client.invoke(wsLocalMethod, xml);
|
|
|
String str = objects[0].toString();
|
|
|
logger.info("----------结果---------");
|
|
|
logger.info(str);
|
|
|
return str;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|