|
|
|
@ -25,7 +25,6 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
@ -78,7 +77,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void collectAll() {
|
|
|
|
|
public void collectAll() {
|
|
|
|
|
logger.info("----------全量采集开始-----------");
|
|
|
|
|
//1.获取最早采集日期
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
@ -106,7 +105,6 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
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")));
|
|
|
|
@ -114,42 +112,55 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
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);
|
|
|
|
|
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;
|
|
|
|
|
vDocumentPdfs = vDocumentPdfMapper.listCollectPage(current, size, startDate, endDate);
|
|
|
|
|
logger.info("处理采集数据:"+vDocumentPdfs);
|
|
|
|
|
if (null == vDocumentPdfs || vDocumentPdfs.size() <= 0) {
|
|
|
|
|
maps = vDocumentPdfMapper.listCollectPage(current, size, startDate, endDate, namespace, tableName, fieldArr, collectTimeName);
|
|
|
|
|
logger.info("处理采集数据:"+maps);
|
|
|
|
|
if (null == maps || maps.size() <= 0) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
vDocumentPdfs.stream().forEach(vDocumentPdf -> {
|
|
|
|
|
maps.stream().forEach(map -> {
|
|
|
|
|
ReportDownDto reportDownDto = new ReportDownDto();
|
|
|
|
|
reportDownDto.setCollectorid(collectorid);
|
|
|
|
|
reportDownDto.setAssortid(assortid);
|
|
|
|
|
|
|
|
|
|
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
|
|
|
|
|
reportDownPatientDto.setJzh(vDocumentPdf.getPATIENT_ID());
|
|
|
|
|
reportDownPatientDto.setJzh(String.valueOf(map.get(indexFlag)));
|
|
|
|
|
reportDownDto.setPatient(reportDownPatientDto);
|
|
|
|
|
|
|
|
|
|
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
|
|
|
|
|
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
|
|
|
|
|
reportDownScanFileDto.setDownurl(vDocumentPdf.getWEB_ADDRESS());
|
|
|
|
|
reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl)));
|
|
|
|
|
reportDownScanFileDto.setFilestoragetype(filestoragetype);
|
|
|
|
|
reportDownScanFileDto.setFilesource(filesource);
|
|
|
|
|
reportDownScanFileDto.setFiletitle(vDocumentPdf.get文书名());
|
|
|
|
|
reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(vDocumentPdf.get手术申请单号())?vDocumentPdf.get手术申请单号():String.valueOf(idWorker.nextId()));
|
|
|
|
|
reportDownScanFileDto.setFiletitle(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);
|
|
|
|
|
afCollectTaskService.insert(reportDownDto);
|
|
|
|
|
String post = null;
|
|
|
|
|
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")));
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
logger.info("手麻采集出错:"+reportDownDto);
|
|
|
|
|
logger.info("采集出错:"+reportDownDto);
|
|
|
|
|
addMrReportErrorLog(reportDownDto);
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
}
|
|
|
|
@ -159,7 +170,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void timerCollect() {
|
|
|
|
|
logger.info("------手麻采集器开始采集---------");
|
|
|
|
|
logger.info("------采集器开始采集---------");
|
|
|
|
|
//1.获取上次采集时间
|
|
|
|
|
Date time = afCollectAddMapper.getTimeByAdd();
|
|
|
|
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
|
|
@ -170,7 +181,7 @@ public class BgtsServiceImpl implements IBgtsService {
|
|
|
|
|
collectByDates(startDate, endDate);
|
|
|
|
|
//更新采集时间
|
|
|
|
|
addAfCollectAdd(date);
|
|
|
|
|
logger.info("--------手麻采集器结束采集------");
|
|
|
|
|
logger.info("--------采集器结束采集------");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|