|
|
|
@ -19,6 +19,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
@ -55,40 +56,51 @@ public class SubordinateServiceImpl implements SubordinateService {
|
|
|
|
|
return CommonResult.success("当前没有需要补偿的数据");
|
|
|
|
|
}
|
|
|
|
|
for (MessageSubordinateVo messageSubordinate : list) {
|
|
|
|
|
//判断消息中是否包含甲亢核医学PET-CT门诊不包含直接跳过不需要采集
|
|
|
|
|
if (!messageSubordinate.getContentJson().contains("甲亢核医学PET-CT门诊")) {
|
|
|
|
|
log.info("消息id为:" + messageSubordinate.getId() + "不包含甲亢核医学PET-CT门诊");
|
|
|
|
|
//不是甲亢核医学PET-CT门诊的报告将状态改为5
|
|
|
|
|
messageSubordinateDao.updateStatus(4, messageSubordinate.getId());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//解析json返回患者基础信息
|
|
|
|
|
MessageDto messageDto = parseMessage(messageSubordinate);
|
|
|
|
|
if (messageDto == null) {
|
|
|
|
|
//不存在数据时,将该记录状态改为4
|
|
|
|
|
messageSubordinateDao.updateStatus(4, messageSubordinate.getMessageId());
|
|
|
|
|
//解释json信息失败将状态改为4
|
|
|
|
|
messageSubordinateDao.updateStatus(4, messageSubordinate.getId());
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//采集失败将状态该为2,成功将状态改为1
|
|
|
|
|
if (!compensate(messageDto)){
|
|
|
|
|
log.info("采集失败:"+messageSubordinate.getMessageId());
|
|
|
|
|
messageSubordinateDao.updateStatus(2, messageSubordinate.getMessageId());
|
|
|
|
|
}else {
|
|
|
|
|
log.info("采集成功:"+messageSubordinate.getMessageId());
|
|
|
|
|
messageSubordinateDao.updateStatus(1, messageSubordinate.getMessageId());
|
|
|
|
|
if (!compensate(messageDto)) {
|
|
|
|
|
log.info("采集失败:" + messageSubordinate.getId());
|
|
|
|
|
messageSubordinateDao.updateStatus(2, messageSubordinate.getId());
|
|
|
|
|
} else {
|
|
|
|
|
log.info("采集成功:" + messageSubordinate.getId());
|
|
|
|
|
messageSubordinateDao.updateStatus(1, messageSubordinate.getId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return CommonResult.success("采集完成");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Boolean compensate(MessageDto messageDto) {
|
|
|
|
|
//获取下载地址
|
|
|
|
|
String reportAddress = messageDto.getReportAddress();
|
|
|
|
|
//查询该患者主键id
|
|
|
|
|
List<String> ids = archiveMasterDao.getMasterIdByInpNoAndVisitId(messageDto.getInpNo(), messageDto.getVisitId());
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//根据患者id查询文件表该文件的保存路径
|
|
|
|
|
List<String> pdfPaths = archiveDetailDao.getPdfPath(ids.get(0), messageDto.getApplyId());
|
|
|
|
|
//删除原地址文件
|
|
|
|
|
if (!delPdf(pdfPaths)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
if (!DownloadFile(reportAddress, pdfPaths.get(0))) {
|
|
|
|
|
try {
|
|
|
|
|
//获取下载地址
|
|
|
|
|
String reportAddress = messageDto.getReportAddress();
|
|
|
|
|
//查询该患者主键id
|
|
|
|
|
List<String> ids = archiveMasterDao.getMasterIdByInpNoAndVisitId(messageDto.getInpNo(), messageDto.getVisitId());
|
|
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//根据患者id查询文件表该文件的保存路径
|
|
|
|
|
List<String> pdfPaths = archiveDetailDao.getPdfPath(ids.get(0), messageDto.getApplyId());
|
|
|
|
|
//删除原地址文件
|
|
|
|
|
if (!delPdf(pdfPaths)) {
|
|
|
|
|
log.info("删除源文件失败:" + pdfPaths.get(0));
|
|
|
|
|
}
|
|
|
|
|
if (!DownloadFile(reportAddress, pdfPaths.get(0))) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
@ -102,9 +114,9 @@ public class SubordinateServiceImpl implements SubordinateService {
|
|
|
|
|
* @Return java.lang.Boolean
|
|
|
|
|
*/
|
|
|
|
|
private Boolean delPdf(List<String> pdfPaths) {
|
|
|
|
|
//删除原地址文件
|
|
|
|
|
File file = new File(pdfPaths.get(0));
|
|
|
|
|
try {
|
|
|
|
|
//删除原地址文件
|
|
|
|
|
File file = new File(pdfPaths.get(0));
|
|
|
|
|
file.delete(); // 删除照片
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
log.error("删除图像失败地址:" + pdfPaths.get(0) + e.getMessage(), e);
|
|
|
|
@ -123,11 +135,6 @@ public class SubordinateServiceImpl implements SubordinateService {
|
|
|
|
|
private MessageDto parseMessage(MessageSubordinateVo messageSubordinate) {
|
|
|
|
|
MessageDto messageDto = null;
|
|
|
|
|
String id = messageSubordinate.getId();
|
|
|
|
|
//判断消息中是否包含甲亢核医学PET-CT门诊不包含直接跳过不需要采集
|
|
|
|
|
if (!messageSubordinate.getContentJson().contains("甲亢核医学PET-CT门诊")) {
|
|
|
|
|
log.info("消息id为:" + id + "不包含甲亢核医学PET-CT门诊");
|
|
|
|
|
return messageDto;
|
|
|
|
|
}
|
|
|
|
|
// 解析内容
|
|
|
|
|
MessageLog messageLog = JSON.parseObject(messageSubordinate.getContentJson(), MessageLog.class);
|
|
|
|
|
if (messageLog == null) {
|
|
|
|
@ -137,7 +144,7 @@ public class SubordinateServiceImpl implements SubordinateService {
|
|
|
|
|
//获取患者基本信息
|
|
|
|
|
String outJson = messageLog.getOutJson();
|
|
|
|
|
if (outJson == null) {
|
|
|
|
|
log.info("消息id为:" + id + "outJson");
|
|
|
|
|
log.info("消息id为:" + id + "outJson为空");
|
|
|
|
|
return messageDto;
|
|
|
|
|
}
|
|
|
|
|
messageDto = JSON.parseObject(outJson, MessageDto.class);
|
|
|
|
|