|
|
|
@ -3,13 +3,14 @@ package com.docus.bgts.service;
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.docus.bgts.entity.AfCollectTask;
|
|
|
|
|
import com.docus.bgts.entity.ReportDownDto;
|
|
|
|
|
import com.docus.bgts.entity.ReportDownPatientDto;
|
|
|
|
|
import com.docus.bgts.entity.ReportDownScanFileDto;
|
|
|
|
|
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.MrReportErrorMapper;
|
|
|
|
|
import com.docus.bgts.mapper.dboracle.VDocumentPdfMapper;
|
|
|
|
|
import com.docus.bgts.utils.FileUtils;
|
|
|
|
|
import com.docus.bgts.utils.HttpUtils;
|
|
|
|
|
import com.docus.bgts.utils.JAXDynamicClientFactory;
|
|
|
|
@ -24,11 +25,11 @@ 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.util.ArrayList;
|
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
@ -37,17 +38,30 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
@Value("${ws.localMethod}")
|
|
|
|
|
private String wsLocalMethod;
|
|
|
|
|
|
|
|
|
|
private Logger logger= LogManager.getLogger(BgtsServiceImpl.class);
|
|
|
|
|
private Logger logger = LogManager.getLogger(BgtsServiceImpl.class);
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
IAfCollectTaskService afCollectTaskService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
VDocumentPdfMapper vDocumentPdfMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
MrReportErrorMapper mrReportErrorMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
AfCollectAddMapper afCollectAddMapper;
|
|
|
|
|
|
|
|
|
|
@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);
|
|
|
|
|
collectExams(exams, empId,reportDownDto);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@ -60,7 +74,126 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
strings[1] = afCollectTask.getC2();
|
|
|
|
|
List<String[]> exams = new ArrayList<>();
|
|
|
|
|
exams.add(strings);
|
|
|
|
|
collectExams(exams, empId);
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
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;
|
|
|
|
|
List<VDocumentPdf> vDocumentPdfs;
|
|
|
|
|
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");
|
|
|
|
|
//2.获取第一页10条数据开始采集
|
|
|
|
|
for (current = 1; ; current++) {
|
|
|
|
|
size = 10 * current;
|
|
|
|
|
vDocumentPdfs = vDocumentPdfMapper.listCollectPage(current, size, startDate, endDate);
|
|
|
|
|
if (null == vDocumentPdfs || vDocumentPdfs.size() <= 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
vDocumentPdfs.stream().forEach(vDocumentPdf -> {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(assortid);
|
|
|
|
|
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
reportDownPatientDto.setJzh(vDocumentPdf.getPATIENT_ID());
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setDownurl(vDocumentPdf.getWEB_ADDRESS());
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDto.setFiletitle(vDocumentPdf.get文书名());
|
|
|
|
|
reportDownScanFileDto.setSerialnum(vDocumentPdf.get手术申请单号());
|
|
|
|
|
reportDownScanFileDtos.add(reportDownScanFileDto);
|
|
|
|
|
reportDownDto.setScanfiles(reportDownScanFileDtos);
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
String post = null;
|
|
|
|
|
try {
|
|
|
|
|
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")));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -69,11 +202,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
* @param exams
|
|
|
|
|
* @param empId
|
|
|
|
|
*/
|
|
|
|
|
private void collectExams(List<String[]> exams, String empId) throws Exception {
|
|
|
|
|
//获取插入表数据
|
|
|
|
|
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
|
|
|
|
|
//插入文件af_collect_task表数据
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
private void collectExams(List<String[]> exams, String empId,ReportDownDto reportDownDto) throws Exception {
|
|
|
|
|
// reportDownDto.setTaskid(id);
|
|
|
|
|
//调用上传接口
|
|
|
|
|
Map<String, Object> headMap = new HashMap<>();
|
|
|
|
@ -141,7 +270,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
Element esbEntry = document.addElement("ESBEntry");
|
|
|
|
|
Element request = HttpUtils.reqElement(esbEntry,0);
|
|
|
|
|
Element request = HttpUtils.reqElement(esbEntry, 0);
|
|
|
|
|
request.addElement("EXAM_NO").setText(exam[0]);
|
|
|
|
|
String resXml = invokeWs(esbEntry.asXML());
|
|
|
|
|
//解析XML
|
|
|
|
@ -180,9 +309,9 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
Element esbEntry = document.addElement("ESBEntry");
|
|
|
|
|
Element reqElement = HttpUtils.reqElement(esbEntry,1);
|
|
|
|
|
Element reqElement = HttpUtils.reqElement(esbEntry, 1);
|
|
|
|
|
reqElement.addElement("EMPI_ID").setText(empId);
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:"+wsUrl+",方法:"+wsLocalMethod+"---------");
|
|
|
|
|
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
|
|
|
|
|
String xml = esbEntry.asXML();
|
|
|
|
|
logger.info("---------------------------");
|
|
|
|
|
logger.info(xml);
|
|
|
|
@ -220,6 +349,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 调用web service
|
|
|
|
|
*
|
|
|
|
|
* @param xml
|
|
|
|
|
* @return
|
|
|
|
|
* @throws Exception
|
|
|
|
@ -239,11 +369,11 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
// call.setTimeout(100000);//超时
|
|
|
|
|
// String result = (String) call.invoke(object);// 远程调用
|
|
|
|
|
// System.out.println(result);
|
|
|
|
|
logger.info("-----\n客户端调用服务端:"+wsUrl+"方法:"+wsLocalMethod+"\n------------");
|
|
|
|
|
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();
|
|
|
|
|
Object[] objects = client.invoke(wsLocalMethod, xml);
|
|
|
|
|
String str = objects[0].toString();
|
|
|
|
|
logger.info("----------结果---------");
|
|
|
|
|
logger.info(str);
|
|
|
|
|
return str;
|
|
|
|
|