新增docus-archivefile,docus-stater-log

segment2.0
linrf 2 years ago
parent 9eac5df983
commit 0709e8c6f8

@ -0,0 +1,25 @@
<!-- 报告接收 webservice 需要的数据对应下载服务,标签内有 xpath 路径,则取 接收xml中的数据否则取 标签 value值 -->
<REPORT>
<!--住院号-->
<INPATIENT_NO>/Request/Msg/INHOSP_INDEX_NO</INPATIENT_NO>
<!--住院流水号-->
<JZH>/Request/Msg/INHOSP_NO</JZH>
<!--住院次数-->
<ADMISS_TIMES>/Request/Msg/INHOSP_NUM</ADMISS_TIMES>
<!--采集流水号/报告唯一单号-->
<SERIALNUM>/Request/Msg/UNIQUE_FILE</SERIALNUM>
<!--文件标题-->
<FILE_TITLE>/Request/Msg/FILE_NAME</FILE_TITLE>
<!--下载地址-->
<DOWNURL>/Request/Msg/PDF_PATH</DOWNURL>
<!--表单类型 -->
<TABLE_TYPE>/Request/Msg/TABLE_TYPE</TABLE_TYPE>
<!--文件分类 无则取 TABLE_TYPE 在js-table-type中 取文件分类-->
<ASSORT_ID value="123456"> </ASSORT_ID>
<!--采集系统 文件表的source-->
<SYSTEM_FLAG>/Request/Msg/TABLE_TYPE</SYSTEM_FLAG>
<!--采集类型(文件来源 1:采集器2扫描生产软件)-->
<FILESOURCE value="1"> </FILESOURCE>
<!--文件保存位置类型 1:服务器本地2ftp服务器3共享文件夹-->
<FILE_STORAGE_TYPE value="1"> </FILE_STORAGE_TYPE>
</REPORT>

@ -0,0 +1,5 @@
{
"icu": "重症文件分段id",
"sa": "手麻文件分段id",
"other": "其他文件分段id"
}

@ -0,0 +1,25 @@
<!--嘉时软件webservice接收模板-->
<Request>
<Msg>
<!-- 消息ID号-->
<ID>123456</ID>
<!--住院号-->
<INHOSP_INDEX_NO>012345</INHOSP_INDEX_NO>
<!--住院流水号-->
<INHOSP_NO>012345</INHOSP_NO>
<!--住院次数-->
<INHOSP_NUM>2</INHOSP_NUM>
<!--表单类型-->
<TABLE_TYPE>icu</TABLE_TYPE>
<!--提交时间-->
<SUBMIT_TIME>20220303111800</SUBMIT_TIME>
<!--审核时间-->
<PROOF_TIME>20220303111801</PROOF_TIME>
<!-- 文件路径-->
<PDF_PATH>http://192.168.1.108:9012/file/0123_01.pdf</PDF_PATH>
<!--文件名-->
<FILE_NAME>0123_01</FILE_NAME>
<!--文件唯一值-->
<UNIQUE_FILE>AESHASHMD5DEFIND</UNIQUE_FILE>
</Msg>
</Request>

@ -0,0 +1,11 @@
<!--嘉时软件webservice响应模板-->
<Response>
<Result>
<!--响应状态码 0代表成功 500 代表失败-->
<Code>0</Code>
<!--消息id 请求的 /Request/Msg/ID-->
<MsgId>123456</MsgId>
<!--成功消息 / 失败异常消息-->
<Msg>成功!</Msg>
</Result>
</Response>

@ -8,13 +8,29 @@ import java.util.Map;
@Component("wsReportResultImpl") @Component("wsReportResultImpl")
public class WsReportResultImpl implements IWsResult { public class WsReportResultImpl implements IWsResult {
private static final String SUCCESS_TEMPLATE = "<Response>" +
"<Result>" +
"<Code>0</Code>" +
"<MsgId>%s</MsgId>" +
"<Msg>成功!</Msg>" +
"</Result>" +
"</Response>";
private static final String FAILED_TEMPLATE = "<Response>" +
"<Result>" +
"<Code>500</Code>" +
"<MsgId>%s</MsgId>" +
"<Msg>%s</Msg>" +
"</Result>" +
"</Response>";
@Override @Override
public String ok(Map<String, Object> params) { public String ok(Map<String, Object> params) {
return null; return String.format(SUCCESS_TEMPLATE, params.get("msgId"));
} }
@Override @Override
public String fail(Map<String, Object> params) { public String fail(Map<String, Object> params) {
return null; return String.format(FAILED_TEMPLATE, params.get("msgId"), params.get("msg"));
} }
} }

@ -12,21 +12,21 @@ spring:
datasource: datasource:
master: master:
url: jdbc:log4jdbc:mysql://db.docus.cn:3306/docus_archivefile?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai url: jdbc:log4jdbc:mysql://db.docus.cn:3306/docus_archivefile?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root username: docus
password: root password: docus702
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
his: his:
url: jdbc:log4jdbc:mysql://db.docus.cn:3306/his?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai url: jdbc:log4jdbc:mysql://db.docus.cn:3306/his?autoReconnect=true&allowMultiQueries=true&useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
username: root username: docus
password: root password: docus702
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
type: com.alibaba.druid.pool.DruidDataSource type: com.alibaba.druid.pool.DruidDataSource
redis: redis:
host: redis.docus.cn host: redis.docus.cn
# password: JSdocus@702 password: JSdocus@702
cloud: cloud:
nacos: nacos:
discovery: discovery:
@ -39,12 +39,12 @@ spring:
shared-configs: shared-configs:
- comm.${spring.cloud.nacos.config.file-extension} - comm.${spring.cloud.nacos.config.file-extension}
docus: docus:
dbtype: mysql dbtype: mysql
user: user:
# 用户默认密码 # 用户默认密码
defpwd: fd29cd53ec12616e5f36b77d4afffbff defpwd: fd29cd53ec12616e5f36b77d4afffbff
mybatis-plus: mybatis-plus:
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true

@ -11,6 +11,11 @@
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<dependencies> <dependencies>
<dependency>
<groupId>com.docus</groupId>
<artifactId>docus-archivefile</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency> <dependency>
<groupId>com.docus</groupId> <groupId>com.docus</groupId>
<artifactId>docus-medical-record</artifactId> <artifactId>docus-medical-record</artifactId>

@ -7,7 +7,7 @@ public enum CollectTypeEnum implements IIntegerEnum {
WEBSERVICE_XML_DEPT(0, "WEBSERVICE_XML_DEPT"), WEBSERVICE_XML_DEPT(0, "WEBSERVICE_XML_DEPT"),
WEBSERVICE_XML_USER(1, "WEBSERVICE_XML_USER"), WEBSERVICE_XML_USER(1, "WEBSERVICE_XML_USER"),
WEBSERVICE_XML_BASIC(2, "WEBSERVICE_XML_BASIC"), WEBSERVICE_XML_BASIC(2, "WEBSERVICE_XML_BASIC"),
WEBSERVICE_XML_REPORT(3, "WEBSERVICE_XML_REPORT"), WEBSERVICE_XML_SA_REPORT(3, "WEBSERVICE_XML_SA_REPORT"),
WEBSERVICE_XML_ICU_REPORT(4, "WEBSERVICE_XML_ICU_REPORT"), WEBSERVICE_XML_ICU_REPORT(4, "WEBSERVICE_XML_ICU_REPORT"),
WEBSERVICE_XML_INSERT_INSPECTION_REPORT(5, "WEBSERVICE_XML_INSERT_INSPECTION_REPORT"), WEBSERVICE_XML_INSERT_INSPECTION_REPORT(5, "WEBSERVICE_XML_INSERT_INSPECTION_REPORT"),
WEBSERVICE_XML_UPDATE_INSPECTION_REPORT(6, "WEBSERVICE_XML_UPDATE_INSPECTION_REPORT"); WEBSERVICE_XML_UPDATE_INSPECTION_REPORT(6, "WEBSERVICE_XML_UPDATE_INSPECTION_REPORT");

@ -0,0 +1,30 @@
package com.docus.server.collect.infrastructure.pojo.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class ReportDownDTO {
@ApiModelProperty(value = "采集器id")
private String collectorid;
@ApiModelProperty(value = "采集器ip")
private String ip;
@ApiModelProperty(value = "分类id")
private String assortid;
@ApiModelProperty(value = "患者信息")
private ReportDownPatientDTO patient;
@ApiModelProperty(value = "文件信息")
private List<ReportDownScanFileDTO> scanfiles;
@ApiModelProperty(value = "扫描用户代码")
private String scanusercode;
@ApiModelProperty(value = "扫描用户名称")
private String scanusername;
}

@ -0,0 +1,34 @@
package com.docus.server.collect.infrastructure.pojo.dto;
import com.docus.server.archivefile.pojo.entity.AfReportRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ReportDownPatientDTO {
@ApiModelProperty(value = "记帐号")
private String jzh;
@ApiModelProperty(value = "住院次数,记帐号重复则加这个参数无则Null")
private Integer admisstimes;
@ApiModelProperty(value = "病案主键如有传则使用无则使用jzh")
private String patientid;
@ApiModelProperty(value = "病案号")
private String inpatientno;
@ApiModelProperty(value = "物理存储位置,有则传")
private String storagelocation;
public ReportDownPatientDTO(AfReportRecord reportRecord) {
this.patientid = reportRecord.getPatientId();
this.jzh = reportRecord.getJzh();
this.admisstimes = reportRecord.getAdmissTimes();
this.inpatientno = reportRecord.getInpatientNo();
}
public ReportDownPatientDTO(ReportDTO reportDTO) {
this.patientid = reportDTO.getPatientId();
this.jzh = reportDTO.getJzh();
this.admisstimes = reportDTO.getAdmisstimes();
this.inpatientno = reportDTO.getInpatientNo();
}
}

@ -0,0 +1,51 @@
package com.docus.server.collect.infrastructure.pojo.dto;
import com.docus.server.archivefile.pojo.entity.AfReportRecord;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ReportDownScanFileDTO {
@ApiModelProperty(value = "任务id(如无效任务id则不更新任务表数据)")
private Long taskid;
@ApiModelProperty(value = "文件标题")
private String filetitle;
@ApiModelProperty(value = "采集类型(文件来源 1:采集器2扫描生产软件)")
private int filesource;
@ApiModelProperty(value = "下载类型(1:服务器本地2ftp服务器3共享文件夹)")
private int filestoragetype;
@ApiModelProperty(value = "文件类型(1:url,2:base64,3:url base64,4:共享文件5本地文件base64)")
private int filetype = 1;
@ApiModelProperty(value = "下载地址")
private String downurl;
// @ApiModelProperty(value = "档案信息")
// private String recordid;
@ApiModelProperty(value = "采集流水号")
private String serialnum;
@ApiModelProperty(value = "排序日期")
private String sortdate;
@ApiModelProperty(value = "是否作废 0否 不作废1是 作废")
private int cancel = 0;
public ReportDownScanFileDTO(AfReportRecord reportRecord) {
this.taskid = reportRecord.getTaskId();
this.filetitle = reportRecord.getFileName();
this.filesource = 1;
this.filestoragetype = 1;
this.filetype = reportRecord.getDownType();
this.downurl = reportRecord.getDownUrl();
this.serialnum = reportRecord.getSerialnum();
}
public ReportDownScanFileDTO(ReportDTO reportDto) {
this.taskid = reportDto.getTaskId();
this.filetitle = reportDto.getFileTitle();
this.filesource = 1;
this.filestoragetype = 1;
this.filetype = reportDto.getDowntype();
this.downurl = reportDto.getDownUrl();
this.serialnum = reportDto.getSerialnum();
}
}

@ -1,17 +1,18 @@
package com.docus.server.collect.service; package com.docus.server.collect.service;
import com.docus.core.util.Func;
import com.docus.server.sys.common.pojo.dto.DeptDTO; import com.docus.server.sys.common.pojo.dto.DeptDTO;
import com.docus.server.sys.common.pojo.dto.UserDTO; import com.docus.server.sys.common.pojo.dto.UserDTO;
import com.docus.server.sys.service.IPowerDeptService; import com.docus.server.sys.service.IPowerDeptService;
import com.docus.server.sys.service.IPowerUserService; import com.docus.server.sys.service.IPowerUserService;
import com.docus.server.ws.impl.BaseCollectService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
@Service @Service
public class CollectService extends BaseCollectService { public class CollectService {
protected final static String DEL_TYPE = "D";
@Resource @Resource
private IPowerDeptService deptService; private IPowerDeptService deptService;
@Resource @Resource
@ -25,7 +26,7 @@ public class CollectService extends BaseCollectService {
@Transactional @Transactional
public void insertOrUpdateDept(DeptDTO deptDTO) { public void insertOrUpdateDept(DeptDTO deptDTO) {
//异步写入归档系统,失败自动重试。 //异步写入归档系统,失败自动重试。
if (checkType(deptDTO.getOperateType(), delType)) { if (checkType(deptDTO.getOperateType(), DEL_TYPE)) {
deptService.delDeptByDeptCode(deptDTO.getDeptCode()); deptService.delDeptByDeptCode(deptDTO.getDeptCode());
} else { } else {
deptService.saveOrUpdatePowerDept(deptDTO); deptService.saveOrUpdatePowerDept(deptDTO);
@ -35,10 +36,16 @@ public class CollectService extends BaseCollectService {
@Transactional @Transactional
public void insertOrUpdateUser(UserDTO userDTO) { public void insertOrUpdateUser(UserDTO userDTO) {
// 判断操作类型 // 判断操作类型
if (super.checkType(userDTO.getOperateType(), delType)) { if (checkType(userDTO.getOperateType(), DEL_TYPE)) {
userService.delUserByUserName(userDTO.getUserName()); userService.delUserByUserName(userDTO.getUserName());
} else { } else {
userService.saveOrUpdatePowerUser(userDTO); userService.saveOrUpdatePowerUser(userDTO);
} }
} }
protected boolean checkType(String operateType, String delType) {
return Func.isNotEmpty(operateType)
&& operateType.contains(delType);
}
} }

@ -11,6 +11,7 @@ import com.docus.server.tool.SpringUtils;
import com.docus.server.ws.ITaskOriginalMessageService; import com.docus.server.ws.ITaskOriginalMessageService;
import com.docus.server.ws.IWsResult; import com.docus.server.ws.IWsResult;
import com.docus.server.ws.convert.IConverter; import com.docus.server.ws.convert.IConverter;
import com.fasterxml.jackson.core.type.TypeReference;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import java.util.Map; import java.util.Map;
@ -43,49 +44,38 @@ public class VisitorProcessor extends AbstractProcessor {
return null; return null;
} }
@Override
public Object doProcess(TrackContext context) {
if (context.isError()) {
log.debug("=== AOP 异常通知 ===");
return afterThrowingProcess(context);
} else {
log.debug("=== AOP 后置通知 ===");
return afterReturnProcess(context);
}
}
/** /**
* *
*/ */
public Object afterReturnProcess(TrackContext context) { @Override
public Object doProcess(TrackContext context) {
Map<String, Object> params = context.getParams(); Map<String, Object> params = context.getParams();
try {
Long taskId = (Long) params.get("taskId"); Long taskId = (Long) params.get("taskId");
String afterReturnResult = (String) params.get("jsonStr"); String afterReturnResult = (String) params.get("jsonStr");
messageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.OK);
Map map = JSON.fromJSON(afterReturnResult, Map.class);
map.put("msg", "操作成功!");
return wsResult.ok(map);
}
/**
*
*/
public Object afterThrowingProcess(TrackContext context) {
log.error(context.getExMessageResult());
Map<String, Object> params = context.getParams();
try {
params.put("msg", context.getExMessageResult()); params.put("msg", context.getExMessageResult());
Map<String, Object> beforeResult = context.getParams();
Long taskId = (Long) beforeResult.get("taskId"); if (!context.isError()) {
String afterReturnResult = (String) beforeResult.get("jsonStr"); log.info("=== AOP 后置通知 ===");
params.putAll(JSON.fromJSONWithGeneric(afterReturnResult, new TypeReference<Map<? extends String, ?>>() {
}));
params.put("msg", "操作成功!");
return wsResult.ok(params);
} else {
log.info("=== AOP 异常通知 ===");
messageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.FAIL); messageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.FAIL);
params.putAll(JSON.fromJSON(afterReturnResult, Map.class)); params.putAll(JSON.fromJSONWithGeneric(afterReturnResult, new TypeReference<Map<? extends String, ?>>() {
}));
return wsResult.fail(params); return wsResult.fail(params);
}
} catch (Exception e) { } catch (Exception e) {
return wsResult.fail(params); return wsResult.fail(params);
} }
} }
/**
* bean
*/
private void initBeans(String[] beanNames) { private void initBeans(String[] beanNames) {
this.converter = (IConverter) SpringUtils.getBean(beanNames[0]); this.converter = (IConverter) SpringUtils.getBean(beanNames[0]);
this.wsResult = (IWsResult) SpringUtils.getBean(beanNames[1]); this.wsResult = (IWsResult) SpringUtils.getBean(beanNames[1]);

@ -0,0 +1,28 @@
package com.docus.server.ws;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDTO;
import java.util.List;
/**
*
*
* @author wyb
*/
public interface IReportService {
/**
*
*
* @param reportDTO
*/
void report(ReportDTO reportDTO);
/**
* id
*
* @param taskIds id
*/
void makeupThreePartyPushReportByTaskIds(List<Long> taskIds) throws Exception;
}

@ -0,0 +1,29 @@
package com.docus.server.ws.event;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDTO;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
/**
*
*
* @author wyb
*/
@Getter
public class TaskConsumptionReportDownEvent extends ApplicationEvent {
/**
* id ,
*/
private final ReportDTO reportDTO;
/**
* @param source
* @param reportDTO
*/
public TaskConsumptionReportDownEvent(Object source, ReportDTO reportDTO) {
super(source);
this.reportDTO = reportDTO;
}
}

@ -0,0 +1,28 @@
package com.docus.server.ws.event;
import lombok.Getter;
import org.springframework.context.ApplicationEvent;
/**
*
* @author wyb
*/
@Getter
public class ThreePartyPushReportDownEvent extends ApplicationEvent {
/**
* id ,
*/
private final Long taskId;
/**
*
* @param source
* @param taskId
*/
public ThreePartyPushReportDownEvent(Object source, Long taskId) {
super(source);
this.taskId=taskId;
}
}

@ -1,16 +0,0 @@
package com.docus.server.ws.impl;
import com.docus.core.util.Func;
public class BaseCollectService {
protected String delType = "D";
protected boolean checkType(String operateType, String delType) {
return Func.isNotEmpty(operateType)
&& operateType.contains(delType);
}
}

@ -30,8 +30,7 @@ public class DeptServerImpl implements IDeptServer {
* @see VisitorProcessor * @see VisitorProcessor
*/ */
@Override @Override
@TrackGroup(group = "WEBSERVICE_XML_DEPT", @TrackGroup(group = "WEBSERVICE_XML_DEPT", beanNames = {"powerDeptConverter", "wsDeptResultImpl"}, processor = VisitorProcessor.class)
beanNames = {"powerDeptConverter", "wsDeptResultImpl"}, processor = VisitorProcessor.class)
public String deptModify(String message) { public String deptModify(String message) {
log.info("新增/修改科室数据:{}", message); log.info("新增/修改科室数据:{}", message);
collectService.insertOrUpdateDept(JSON.fromJSON((String) TrackHelper.getValue("jsonStr"), DeptDTO.class)); collectService.insertOrUpdateDept(JSON.fromJSON((String) TrackHelper.getValue("jsonStr"), DeptDTO.class));

@ -1,9 +1,17 @@
package com.docus.server.ws.impl; package com.docus.server.ws.impl;
import com.docus.core.util.json.JSON;
import com.docus.log.annotation.TrackGroup;
import com.docus.log.context.TrackHelper;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDTO;
import com.docus.server.visitor.VisitorProcessor;
import com.docus.server.ws.IReportServer; import com.docus.server.ws.IReportServer;
import com.docus.server.ws.IReportService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/** /**
* @author wyb * @author wyb
* @date 20233313:42:36 * @date 20233313:42:36
@ -11,8 +19,24 @@ import org.springframework.stereotype.Service;
@Service @Service
@Slf4j @Slf4j
public class ReportServerImpl implements IReportServer { public class ReportServerImpl implements IReportServer {
@Resource
private IReportService reportService;
/**
* @param message
* @see com.docus.server.collect.infrastructure.dao.CollectTypeEnum
* @see com.docus.server.ws.convert.IConverter
* @see com.docus.server.ws.IWsResult
* @see VisitorProcessor
*/
@Override @Override
public String pushSAReport(String saReportMessage) { @TrackGroup(
group = "WEBSERVICE_XML_SA_REPORT", desc = "接收手麻报告信息",
beanNames = {"reportConverter", "wsReportResultImpl"},
processor = VisitorProcessor.class)
public String pushSAReport(String message) {
log.info("收到手麻消息:{}", message);
reportService.report(JSON.fromJSON((String) TrackHelper.getValue("jsonStr"), ReportDTO.class));
return null; return null;
} }
@ -30,520 +54,4 @@ public class ReportServerImpl implements IReportServer {
public String pushUpdateInspectionReport(String inspectionReportMessage) { public String pushUpdateInspectionReport(String inspectionReportMessage) {
return null; return null;
} }
// @Resource(name = "wsReportResultImpl")
// private IWsResult wsResult;
// @Resource(name = "reportConverter")
// private IConverter converter;
// @Resource
// private CollectService collectService;
// @Resource
// private ITaskOriginalMessageService taskOriginalMessageService;
// @Resource
// private ReportService reportService;
//
// @Override
// public String pushSAReport(String message) {
// log.info("收到手麻消息:{}", message);
// ReportDTO reportDTO = new ReportDTO();
// long id = 0;
// try {
// id = taskOriginalMessageService.insertTaskOriginalMessage(message, CollectTypeEnum.WS_XML_SA_REPORT);
// reportDTO = (ReportDTO) converter.convert(message, FlagEnum.INSERT);
// medicalRecordService.receive(medicalRecord);
// return wsResult.ok(reportDTO.getParams());
// } catch (Exception e) {
// log.error(e.getMessage(), e);
// taskOriginalMessageService.updateTaskOriginalMessage(id);
// reportDTO.getParams().put("msg", e.getMessage());
// return wsResult.fail(reportDTO.getParams());
// }
//
//
// // 待做
// log.info("收到手麻消息:{}", saReportMessage);
// String msgId = "";
// try {
// XmlUtil xmlUtil = XmlUtil.of(saReportMessage);
// Node msgNode = xmlUtil.getNode("/Request/Msg/ID");
// msgId = msgNode.getTextContent();
// ReportDto reportDto = getReportDtoByJSXML(xmlUtil);
// verifyReportDto(reportDto);
// reportService.report(reportDto);
// return JSXMLResult.success(msgId);
// } catch (BaseException baseException) {
// log.error(baseException.getMessage(), baseException);
// return JSXMLResult.failed(msgId, baseException.getMessage());
// } catch (Exception ex) {
// log.error(ex.getMessage(), ex);
// return JSXMLResult.failed(msgId, "系统故障!");
// }
// }
//
//
// /**
// * 嘉时自定义接收接口使用从xml工具读取返回文件上报需要的数据
// *
// * @param xmlUtil xml消息工具封装
// * @return 文件上报数据
// */
// public ReportDto getReportDtoByJSXML(XmlUtil xmlUtil) {
// TableJsonRead jsonRead = new TableJsonRead();
// JSONObject tableTypeJson = jsonRead.Read("data-config", "js-table-type.json", JSONObject.class);
// String jsReportConfigXml = jsonRead.ReadContent("data-config", "js-report-config.xml");
// XmlUtil configXmlUtil = XmlUtil.of(jsReportConfigXml);
//
// Node inpatientNoXpathNode = configXmlUtil.getNode("/REPORT/INPATIENT_NO");
// String inpatientNoXpath = inpatientNoXpathNode.getTextContent();
// Node inpatientNoNode = xmlUtil.getNode(inpatientNoXpath);
// String inpatientNo = inpatientNoNode.getTextContent();
//
// Node jzhXpathNode = configXmlUtil.getNode("/REPORT/JZH");
// String jzhXpath = jzhXpathNode.getTextContent();
// Node jzhNode = xmlUtil.getNode(jzhXpath);
// String jzh = jzhNode.getTextContent();
//
// Node admissTimesXpathNode = configXmlUtil.getNode("/REPORT/ADMISS_TIMES");
// String admissTimesXpath = admissTimesXpathNode.getTextContent();
// Node admissTimesNode = xmlUtil.getNode(admissTimesXpath);
// Integer admissTimes = Integer.valueOf(admissTimesNode.getTextContent());
//
// Node serialnumXpathNode = configXmlUtil.getNode("/REPORT/SERIALNUM");
// String serialnumXpath = serialnumXpathNode.getTextContent();
// Node serialnumNode = xmlUtil.getNode(serialnumXpath);
// String serialnum = serialnumNode.getTextContent();
//
// Node fileTitleXpathNode = configXmlUtil.getNode("/REPORT/FILE_TITLE");
// String fileTitleXpath = fileTitleXpathNode.getTextContent();
// Node fileTitleNode = xmlUtil.getNode(fileTitleXpath);
// String fileTitle = fileTitleNode.getTextContent();
//
// Node downUrlXpathNode = configXmlUtil.getNode("/REPORT/DOWNURL");
// String downUrlXpath = downUrlXpathNode.getTextContent();
// Node downUrlNode = xmlUtil.getNode(downUrlXpath);
// String downUrl = downUrlNode.getTextContent();
//
// Node tableTypeXpathNode = configXmlUtil.getNode("/REPORT/TABLE_TYPE");
// String tableTypeXpath = tableTypeXpathNode.getTextContent();
// Node tableTypeNode = xmlUtil.getNode(tableTypeXpath);
// String tableType = tableTypeNode.getTextContent();
//
//
// Node assortIdXpathNode = configXmlUtil.getNode("/REPORT/ASSORT_ID");
// String assortIdXpath = assortIdXpathNode.getTextContent();
// String assortId;
// if (Func.isBlank(assortIdXpath)) {
// // 如果没有配置 取value 属性如果value也未配置 取 tableType 对应的json配置最终方案默认 other 分段
// Node assortIdValueNode = assortIdXpathNode.getAttributes().getNamedItem("value");
// if (Func.isEmpty(assortIdValueNode)) {
// assortId = assortIdValueNode.getNodeValue();
// } else {
// assortId = tableTypeJson.getString(tableType);
// }
// if (Func.isBlank(assortId)) {
// assortId = tableTypeJson.getString("other");
// }
// } else {
// Node assortIdNode = xmlUtil.getNode(assortIdXpath);
// assortId = assortIdNode.getTextContent();
// }
//
// Node sysFlagXpathNode = configXmlUtil.getNode("/REPORT/SYSTEM_FLAG");
// String sysFlagXpath = sysFlagXpathNode.getTextContent();
// Node sysFlagNode = xmlUtil.getNode(sysFlagXpath);
// String sysFlag = sysFlagNode.getTextContent();
//
// Node fileSourceXpathNode = configXmlUtil.getNode("/REPORT/FILESOURCE");
// String fileSourceXpath = fileSourceXpathNode.getTextContent();
// String fileSource;
// if (Func.isBlank(fileSourceXpath)) {
// Node fileSourceValueNode = fileSourceXpathNode.getAttributes().getNamedItem("value");
// if (Func.isEmpty(fileSourceValueNode)) {
// fileSource = null;
// } else {
// fileSource = fileSourceValueNode.getNodeValue();
// }
//
// } else {
// Node fileSourceNode = xmlUtil.getNode(fileSourceXpath);
// fileSource = fileSourceNode.getTextContent();
// }
//
//
// Node fileStorageTypeXpathNode = configXmlUtil.getNode("/REPORT/FILE_STORAGE_TYPE");
// String fileStorageTypeXpath = fileStorageTypeXpathNode.getTextContent();
// String fileStorageType;
// if (Func.isBlank(fileStorageTypeXpath)) {
// Node filestoragetypeValueNode = fileStorageTypeXpathNode.getAttributes().getNamedItem("value");
// if (Func.isEmpty(filestoragetypeValueNode)) {
// fileStorageType = "1";
// } else {
// fileStorageType = filestoragetypeValueNode.getNodeValue();
// }
//
// } else {
// Node filestoragetypeNode = xmlUtil.getNode(fileStorageTypeXpath);
// fileStorageType = filestoragetypeNode.getTextContent();
// }
//
// ReportDto reportDto = new ReportDto();
// reportDto.setAdmisstimes(admissTimes);
// reportDto.setInpatientNo(inpatientNo);
// reportDto.setJzh(jzh);
// reportDto.setSerialnum(serialnum);
// reportDto.setFileTitle(fileTitle);
// reportDto.setDownUrl(downUrl);
// reportDto.setAssortId(assortId);
// reportDto.setSysFlag(sysFlag);
// reportDto.setFileSource(fileSource);
// reportDto.setFilestoragetype(fileStorageType);
// return reportDto;
// }
//
// @Override
// public String pushICUReport(String icuReportMessage) {
// log.info("收到重症消息:{}", icuReportMessage);
// String msgId = "";
// try {
// XmlUtil xmlUtil = XmlUtil.of(icuReportMessage);
// Node msgNode = xmlUtil.getNode("/Request/Msg/ID");
// msgId = msgNode.getTextContent();
// ReportDto reportDto = getReportDtoByJSXML(xmlUtil);
// verifyReportDto(reportDto);
// reportService.report(reportDto);
// return JSXMLResult.success(msgId);
// } catch (BaseException baseException) {
// log.error(baseException.getMessage(), baseException);
// return JSXMLResult.failed(msgId, baseException.getMessage());
// } catch (Exception ex) {
// log.error(ex.getMessage(), ex);
// return JSXMLResult.failed(msgId, "系统故障!");
// }
// }
//
// @Override
// public String pushAddInspectionReport(String inspectionReportMessage) {
// log.info("收到检查报告新增消息:{}", inspectionReportMessage);
// String msgId = "";
// String sender = "";
// String receiver = "";
// try {
// XmlUtil xmlUtil = XmlUtil.of(inspectionReportMessage);
// msgId = xmlUtil.getNode("/POOR_HIP1008/id/@extension").getNodeValue();
// sender = xmlUtil.getNode("/POOR_HIP1008/sender/device/id/item/@extension").getNodeValue();
// receiver = xmlUtil.getNode("/POOR_HIP1008/receiver/device/id/item/@extension").getNodeValue();
//
// ReportDto reportDto = getReportDtoByInspectionInsert(xmlUtil);
// verifyReportDto(reportDto);
// reportService.report(reportDto);
// return insertSuccess(msgId, sender, receiver);
// } catch (BaseException baseException) {
// log.error(baseException.getMessage(), baseException);
// return insertFailed(msgId, sender, receiver, baseException.getMessage());
// } catch (Exception ex) {
// log.error(ex.getMessage(), ex);
// return insertFailed(msgId, sender, receiver, "系统错误!");
// }
// }
//
//
// @Override
// public String pushUpdateInspectionReport(String inspectionReportMessage) {
// log.info("收到检查报告更新消息{}", inspectionReportMessage);
// String msgId = "";
// String sender = "";
// String receiver = "";
// try {
// XmlUtil xmlUtil = XmlUtil.of(inspectionReportMessage);
// msgId = xmlUtil.getNode("/POOR_HIP1009/id/@extension").getNodeValue();
// sender = xmlUtil.getNode("/POOR_HIP1009/sender/device/id/item/@extension").getNodeValue();
// receiver = xmlUtil.getNode("/POOR_HIP1009/receiver/device/id/item/@extension").getNodeValue();
//
// ReportDto reportDto = getReportDtoByInspectionUpdate(xmlUtil);
// verifyReportDto(reportDto);
// reportService.report(reportDto);
// return updateSuccess(msgId, sender, receiver);
// } catch (BaseException baseException) {
// log.error(baseException.getMessage(), baseException);
// return updateFailed(msgId, sender, receiver, baseException.getMessage());
// } catch (Exception ex) {
// log.error(ex.getMessage(), ex);
// return updateFailed(msgId, sender, receiver, "系统错误");
// }
//
// }
//
// /**
// * 验证上报文件的信息
// *
// * @param reportDto 上报文件的信息
// * @throws BaseException 验证不通过抛出业务异常
// */
// private void verifyReportDto(ReportDto reportDto) throws BaseException {
//
// if (Func.isBlank(reportDto.getInpatientNo())) {
// throw new BaseException("住院号不能为空!");
// }
//
// if (Func.isEmpty(reportDto.getAdmisstimes()) && Func.isBlank(reportDto.getJzh())) {
// throw new BaseException("当住院号与住院次数都为空时,住院流水号/记账号不能为空!");
// }
//
// if (Func.isBlank(reportDto.getFileTitle())) {
// throw new BaseException("文件名不能为空!");
// }
// if (Func.isBlank(reportDto.getDownUrl())) {
// throw new BaseException("文件下载路径不能为空!");
// }
// }
//
// public ReportDto getReportDtoByInspectionInsert(XmlUtil inspectionInsertXmlUtil) {
//
// Node inpatientNoNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.12']/@extension");
// String inpatientNo = inpatientNoNode.getNodeValue();
//
// Node admissTimesNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/recordTarget/patientRole/item[@root='1.2.156.112635.1.2.1.7']/@extension");
// Integer admissTimes = Integer.valueOf(admissTimesNode.getNodeValue());
//
// // 检查报告单号标识
// Node reportFlagNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.32']/@extension");
// String reportFlag = reportFlagNode.getNodeValue();
// //电子申请单编号
// Node eafNoNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.24']/@extension");
// String eafNo = eafNoNode.getNodeValue();
// String serialnum = reportFlag + "@" + eafNo;
//
// Node assortIdNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告']/section/entry[@displayName='检查类型']/observation/code/@displayName");
// String assortId = assortIdNode.getNodeValue();
//
// Node sysFlagNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告']/section/entry[@displayName='检查类型']/observation/code/@displayName");
// String sysFlag = sysFlagNode.getNodeValue();
//
// Node fileTitleNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告']/section/entry[@displayName='检查报告类型']/observation/code/@displayName");
// String fileTitle = fileTitleNode.getNodeValue();
//
// Node downUrlNode = inspectionInsertXmlUtil.getNode("/POOR_HIP1008/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告图像']/report/entry[@displayName='检查报告图像URL地址']/observation/value");
// String downUrl = downUrlNode.getTextContent();
//
// ReportDto reportDto = new ReportDto();
// reportDto.setAdmisstimes(admissTimes);
// reportDto.setInpatientNo(inpatientNo);
// reportDto.setSerialnum(serialnum);
// reportDto.setFileTitle(fileTitle);
// reportDto.setDownUrl(downUrl);
// reportDto.setAssortId(assortId);
// reportDto.setSysFlag(sysFlag);
// reportDto.setFileSource("1");
// reportDto.setFilestoragetype("1");
// return reportDto;
// }
//
// public ReportDto getReportDtoByInspectionUpdate(XmlUtil inspectionUpdateXmlUtil) {
// Node inpatientNoNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.12']/@extension");
// String inpatientNo = inpatientNoNode.getNodeValue();
//
// Node admissTimesNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/item[@root='1.2.156.112635.1.2.1.7']/@extension");
// Integer admissTimes = Integer.valueOf(admissTimesNode.getNodeValue());
//
// // 检查报告单号标识
// Node reportFlagNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.32']/@extension");
// String reportFlag = reportFlagNode.getNodeValue();
// //电子申请单编号
// Node eafNoNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/recordTarget/patientRole/id[@root='2.16.156.10011.1.24']/@extension");
// String eafNo = eafNoNode.getNodeValue();
// String serialnum = reportFlag + "@" + eafNo;
//
// Node assortIdNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告']/section/entry[@displayName='检查类型']/observation/code/@displayName");
// String assortId = assortIdNode.getNodeValue();
//
// Node sysFlagNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告']/section/entry[@displayName='检查类型']/observation/code/@displayName");
// String sysFlag = sysFlagNode.getNodeValue();
//
// Node fileTitleNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告']/section/entry[@displayName='检查报告类型']/observation/code/@displayName");
// String fileTitle = fileTitleNode.getNodeValue();
//
// Node downUrlNode = inspectionUpdateXmlUtil.getNode("/POOR_HIP1009/controlActProcess/subject/component/structuredBody/component[@displayName='检查报告图像']/report/entry[@displayName='检查报告图像URL地址']/observation/value");
// String downUrl = downUrlNode.getTextContent();
//
//
// ReportDto reportDto = new ReportDto();
// reportDto.setAdmisstimes(admissTimes);
// reportDto.setInpatientNo(inpatientNo);
// reportDto.setSerialnum(serialnum);
// reportDto.setFileTitle(fileTitle);
// reportDto.setDownUrl(downUrl);
// reportDto.setAssortId(assortId);
// reportDto.setSysFlag(sysFlag);
// reportDto.setFileSource("1");
// reportDto.setFilestoragetype("1");
// return reportDto;
// }
//
// /**
// * 返回检查报告新增成功消息
// *
// * @param msgId 消息id
// * @param sender 发送路由
// * @param receiver 接收路由
// * @return 新增成功消息响应
// */
// public String insertSuccess(String msgId, String sender, String receiver) {
// String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
// return "<MCCI_IN000002UV01 ITSVersion=\"XML_1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:hl7-org:v3 ../multicacheschemas/MCCI_IN000002UV01.xsd\" xmlns=\"urn:hl7-org:v3\">\n" +
// "\t<id root=\"2.16.156.10011.0\" extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
// "\t<creationTime value=\"" + createTime + "\"/>\n" +
// "\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/>\n" +
// "\t<processingCode code=\"P\"/>\n" +
// "\t<processingModeCode/>\n" +
// "\t<acceptAckCode code=\"AL\"/>\n" +
// "\t<receiver typeCode=\"RCV\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.1\" extension=\"" + receiver + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</receiver>\n" +
// "\t<sender typeCode=\"SND\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.2\" extension=\"" + sender + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</sender>\n" +
// "\t<acknowledgement typeCode=\"AA\">\n" +
// "\t\t<targetMessage>\n" +
// "\t\t\t<id root=\"2.16.156.10011.0\" extension=\"" + msgId + "\"/>\n" +
// "\t\t</targetMessage>\n" +
// "\t\t<acknowledgementDetail typeCode=\"I\">\n" +
// " <text value=\"成功!\"/> \n" +
// "\t\t</acknowledgementDetail>\n" +
// "\t</acknowledgement>\n" +
// "</MCCI_IN000002UV01>\n";
// }
//
// /**
// * 返回检查报告插入失败响应消息
// *
// * @param msgId 消息id
// * @param sender 发送路由
// * @param receiver 接收路由
// * @return 检查报告新增失败响应消息
// */
// public String insertFailed(String msgId, String sender, String receiver, String failedMessage) {
// String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
// return "<MCCI_IN000002UV01 ITSVersion=\"XML_1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:hl7-org:v3 ../multicacheschemas/MCCI_IN000002UV01.xsd\" xmlns=\"urn:hl7-org:v3\">\n" +
// "\t<id root=\"2.16.156.10011.0\" extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
// "\t<creationTime value=\"" + createTime + "\"/>\n" +
// "\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/>\n" +
// "\t<processingCode code=\"P\"/>\n" +
// "\t<processingModeCode/>\n" +
// "\t<acceptAckCode code=\"AL\"/>\n" +
// "\t<receiver typeCode=\"RCV\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.1\" extension=\"" + receiver + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</receiver>\n" +
// "\t<sender typeCode=\"SND\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.2\" extension=\"" + sender + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</sender>\n" +
// "\t<acknowledgement typeCode=\"AE\">\n" +
// "\t\t<targetMessage>\n" +
// "\t\t\t<id root=\"2.16.156.10011.0\" extension=\"" + msgId + "\"/>\n" +
// "\t\t</targetMessage>\n" +
// "\t\t<acknowledgementDetail typeCode=\"I\">\n" +
// " <text value=\"" + failedMessage + "\"/> \n" +
// "\t\t</acknowledgementDetail>\n" +
// "\t</acknowledgement>\n" +
// "</MCCI_IN000002UV01>\n";
// }
//
// /**
// * 返回检查报告更新成功响应消息
// *
// * @param msgId 消息id
// * @param sender 发送路由
// * @param receiver 接收路由
// * @return 更新成功响应消息
// */
// public String updateSuccess(String msgId, String sender, String receiver) {
// String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
// return "<MCCI_IN000002UV01 ITSVersion=\"XML_1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:hl7-org:v3 ../multicacheschemas/MCCI_IN000002UV01.xsd\" xmlns=\"urn:hl7-org:v3\">\n" +
// "\t<id root=\"2.16.156.10011.0\" extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
// "\t<creationTime value=\"" + createTime + "\"/>\n" +
// "\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/>\n" +
// "\t<processingCode code=\"P\"/>\n" +
// "\t<processingModeCode/>\n" +
// "\t<acceptAckCode code=\"AL\"/>\n" +
// "\t<receiver typeCode=\"RCV\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.1\" extension=\"" + receiver + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</receiver>\n" +
// "\t<sender typeCode=\"SND\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.2\" extension=\"" + sender + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</sender>\n" +
// "\t<acknowledgement typeCode=\"AA\">\n" +
// "\t\t<targetMessage>\n" +
// "\t\t\t<id root=\"2.16.156.10011.0\" extension=\"" + msgId + "\"/>\n" +
// "\t\t</targetMessage>\n" +
// "\t\t<acknowledgementDetail typeCode=\"I\">\n" +
// " <text value=\"成功!\"/> \n" +
// "\t\t</acknowledgementDetail>\n" +
// "\t</acknowledgement>\n" +
// "</MCCI_IN000002UV01>\n";
// }
//
// /**
// * 检查报告更新失败响应
// *
// * @param msgId 消息id
// * @param sender 发送路由
// * @param receiver 接收路由
// * @param failedMessage 失败信息
// * @return 更新失败响应信息
// */
// public String updateFailed(String msgId, String sender, String receiver, String failedMessage) {
// String createTime = Func.format(new Date(), DateUtil.PATTERN_DATETIME_MINI);
// return "<MCCI_IN000002UV01 ITSVersion=\"XML_1.0\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:hl7-org:v3 ../multicacheschemas/MCCI_IN000002UV01.xsd\" xmlns=\"urn:hl7-org:v3\">\n" +
// "\t<id root=\"2.16.156.10011.0\" extension=\"" + IdUtil.standardUUID() + "\"/>\n" +
// "\t<creationTime value=\"" + createTime + "\"/>\n" +
// "\t<interactionId root=\"2.16.840.1.113883.1.6\" extension=\"MCCI_IN000002UV01\" displayable=\"true\"/>\n" +
// "\t<processingCode code=\"P\"/>\n" +
// "\t<processingModeCode/>\n" +
// "\t<acceptAckCode code=\"AL\"/>\n" +
// "\t<receiver typeCode=\"RCV\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.1\" extension=\"" + receiver + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</receiver>\n" +
// "\t<sender typeCode=\"SND\">\n" +
// "\t\t<device classCode=\"DEV\" determinerCode=\"INSTANCE\">\n" +
// "\t\t\t<id>\n" +
// "\t\t\t\t<item root=\"2.16.156.10011.0.1.2\" extension=\"" + sender + "\"/>\n" +
// "\t\t\t</id>\n" +
// "\t\t</device>\n" +
// "\t</sender>\n" +
// "\t<acknowledgement typeCode=\"AE\">\n" +
// "\t\t<targetMessage>\n" +
// "\t\t\t<id root=\"2.16.156.10011.0\" extension=\"" + msgId + "\"/>\n" +
// "\t\t</targetMessage>\n" +
// "\t\t<acknowledgementDetail typeCode=\"I\">\n" +
// " <text value=\"" + failedMessage + "\"/> \n" +
// "\t\t</acknowledgementDetail>\n" +
// "\t</acknowledgement>\n" +
// "</MCCI_IN000002UV01>\n";
// }
} }

@ -0,0 +1,146 @@
package com.docus.server.ws.impl;
import com.docus.core.util.Func;
import com.docus.infrastructure.redis.service.IdService;
import com.docus.server.archivefile.mapper.AfCollectTaskMapper;
import com.docus.server.archivefile.mapper.AfReportRecordMapper;
import com.docus.server.archivefile.pojo.entity.AfCollectTask;
import com.docus.server.archivefile.pojo.entity.AfReportRecord;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDTO;
import com.docus.server.record.mapper.TBasicMapper;
import com.docus.server.ws.IReportService;
import com.docus.server.ws.event.TaskConsumptionReportDownEvent;
import com.docus.server.ws.event.ThreePartyPushReportDownEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;
/**
*
*
* @author wyb
*/
@Slf4j
@Service
public class ReportServiceImpl implements IReportService {
@Resource
private ApplicationContext applicationContext;
@Resource
private AfCollectTaskMapper collectTaskMapper;
@Resource
private AfReportRecordMapper afReportRecordMapper;
@Resource
private TBasicMapper tBasicMapper;
@Resource
private IdService idService;
@Override
public void report(ReportDTO reportDTO) {
// 系统无视图生成的任务,消费查询的报告
if (reportDTO.getTaskId() != null) {
taskConsumptionReport(reportDTO);
}
// 第三方推送的报告,任务后生成的
threePartyPushReports(reportDTO);
}
private void taskConsumptionReport(ReportDTO reportDTO) {
applicationContext.publishEvent(new TaskConsumptionReportDownEvent(this, reportDTO));
try {
TimeUnit.MILLISECONDS.sleep(50);
} catch (InterruptedException ex) {
log.error(ex.getMessage(), ex);
}
}
private void threePartyPushReports(ReportDTO reportDto) {
String patientId = null;
try {
// 如果出现多条出错的情况,还是得保存收到的信息,人工干预处理
patientId = tBasicMapper.getPatientIdByInpatientNoAndAdminssTimes(reportDto.getInpatientNo(), reportDto.getAdmisstimes());
} catch (Exception ex) {
log.error("查询病案主键出错了", ex);
}
// 不验证数据,始终保存收到的信息
AfReportRecord afReportRecord = afReportRecordMapper.getRecordBySerialnumAndInpatientNoAndSysFlag(reportDto.getSerialnum(), reportDto.getInpatientNo(), reportDto.getAdmisstimes(), reportDto.getSysFlag());
if (afReportRecord == null) {
long id = idService.getDateSeq();
afReportRecord = new AfReportRecord(reportDto);
afReportRecord.setTaskId(id);
afReportRecord.setPatientId(patientId);
afReportRecordMapper.saveRecord(afReportRecord);
} else {
// 更新 主要更新 url
afReportRecord.setDownUrl(reportDto.getDownUrl());
afReportRecord.setDownType(reportDto.getDowntype());
afReportRecord.setFileName(reportDto.getFileTitle());
afReportRecord.setPatientId(patientId);
afReportRecordMapper.updateRecordByTaskId(afReportRecord);
}
// 不使用事务,不需要回滚上面的保存
// 根据记录中的任务id查询是否需要新增任务
if (Func.isBlank(patientId)) {
log.warn("病案号:{},住院次数:{} 未找到病案基础数据,暂不进行下载任务!", reportDto.getInpatientNo(), reportDto.getAdmisstimes());
return;
}
// 判断是否需要保存任务
AfCollectTask afCollectTask = collectTaskMapper.getTaskById(afReportRecord.getTaskId());
if (afCollectTask == null) {
afCollectTask = new AfCollectTask();
afCollectTask.setId(afReportRecord.getTaskId());
afCollectTask.setC1(reportDto.getSerialnum());
afCollectTask.setC2(reportDto.getFileTitle());
afCollectTask.setC3(reportDto.getJzh());
afCollectTask.setPatientId(patientId);
afCollectTask.setSysflag(reportDto.getSysFlag());
afCollectTask.setState("0");
afCollectTask.setPatientId(patientId);
collectTaskMapper.saveTask(afCollectTask);
}
// 都成功后发布下载事件
applicationContext.publishEvent(new ThreePartyPushReportDownEvent(this, afReportRecord.getTaskId()));
try {
TimeUnit.MILLISECONDS.sleep(50);
} catch (InterruptedException ex) {
log.error(ex.getMessage(), ex);
}
}
@Override
public void makeupThreePartyPushReportByTaskIds(List<Long> taskIds) throws Exception {
if (taskIds == null || taskIds.isEmpty()) {
return;
}
// 定义一批200查询分批次
final int oneBatchCount = 200;
int startIndex = 0;
int toIndex = oneBatchCount;
boolean loop = true;
do {
// 获取截取下标
if (taskIds.size() <= oneBatchCount) {
toIndex = taskIds.size();
// 最后一批截取
loop = false;
}
// 截取每一批
List<Long> makeupTaskIds = taskIds.subList(startIndex, toIndex);
makeupTaskIds = afReportRecordMapper.getHasPatientIdTaskIdsByTaskIds(makeupTaskIds);
if (Func.isNotEmpty(makeupTaskIds)) {
for (Long taskId : makeupTaskIds) {
// 发布下载事件
applicationContext.publishEvent(new ThreePartyPushReportDownEvent(this, taskId));
// 等待防止过快
TimeUnit.MILLISECONDS.sleep(50);
}
}
// 当截取长度小于集合长度,可以进行下次循环截取
} while (loop);
}
}

@ -0,0 +1,127 @@
package com.docus.server.ws.listener;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil;
import com.docus.core.util.Func;
import com.docus.infrastructure.web.api.CommonResult;
import com.docus.infrastructure.web.api.ResultCode;
import com.docus.server.archivefile.mapper.AfReportRecordMapper;
import com.docus.server.archivefile.pojo.entity.AfReportRecord;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDTO;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDownDTO;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDownPatientDTO;
import com.docus.server.collect.infrastructure.pojo.dto.ReportDownScanFileDTO;
import com.docus.server.ws.event.TaskConsumptionReportDownEvent;
import com.docus.server.ws.event.ThreePartyPushReportDownEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
*
*
* @author wyb
*/
@Component
@Slf4j
public class ReportDownListener {
@Resource
private AfReportRecordMapper afReportRecordMapper;
@EventListener
@Async("threadPoolExecutor")
public void threePartyPushReportDown(ThreePartyPushReportDownEvent threePartyPushReportDownEvent) {
// 根据任务id获取上报记录信息
AfReportRecord afReportRecord = afReportRecordMapper.getReportRecordInfoByTaskId(threePartyPushReportDownEvent.getTaskId());
// 组织基础信息数据
ReportDownPatientDTO reportDownPatientDto = new ReportDownPatientDTO(afReportRecord);
// 组织文件数据
List<ReportDownScanFileDTO> reportDownScanFileDtos = new ArrayList<>(5);
ReportDownScanFileDTO reportDownScanFileDto = new ReportDownScanFileDTO(afReportRecord);
reportDownScanFileDtos.add(reportDownScanFileDto);
// 组织下载数据,基础信息和文件数据
ReportDownDTO reportDownDto = new ReportDownDTO();
reportDownDto.setAssortid(afReportRecord.getZdAssortId());
reportDownDto.setCollectorid(afReportRecord.getSysflag());
reportDownDto.setScanusercode("admin");
reportDownDto.setScanusername("admin");
reportDownDto.setPatient(reportDownPatientDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
// 下面是调用下载服务
String requestParam = Func.toJson(reportDownDto);
try {
log.info("调用下载服务,地址:{} ,参数:{}", applicationBusinessConfig.getDownUrl(), requestParam);
String respBody = post(applicationBusinessConfig.getDownUrl(), requestParam);
log.info("调用下载服务成功,响应参数:{}", respBody);
CommonResult commonResult = Func.readJson(respBody, CommonResult.class);
if (ResultCode.SUCCESS.getCode().equals(commonResult.getCode())) {
// 下载返回了成功更新状态
afReportRecordMapper.updateStateByTaskId(threePartyPushReportDownEvent.getTaskId());
}
} catch (Exception e) {
log.error("调用下载服务失败", e);
}
}
@EventListener
@Async("threadPoolExecutor")
public void taskConsumptionReporDown(TaskConsumptionReportDownEvent taskConsumptionReportDownEvent) {
ReportDTO reportDto = taskConsumptionReportDownEvent.ReportDTO();
// 组织基础信息数据
ReportDownPatientDTO reportDownPatientDto = new ReportDownPatientDTO(reportDto);
// 组织文件数据
List<ReportDownScanFileDTO> reportDownScanFileDtos = new ArrayList<>(5);
ReportDownScanFileDTO reportDownScanFileDto = new ReportDownScanFileDTO(reportDto);
reportDownScanFileDtos.add(reportDownScanFileDto);
// 组织下载数据,基础信息和文件数据
ReportDownDTO reportDownDto = new ReportDownDTO();
reportDownDto.setAssortid(reportDto.getAssortId());
reportDownDto.setCollectorid(reportDto.getSysFlag());
reportDownDto.setScanusercode("admin");
reportDownDto.setScanusername("admin");
reportDownDto.setPatient(reportDownPatientDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
// 下面是调用下载服务
String requestParam = Func.toJson(reportDownDto);
try {
log.info("调用下载服务,地址:{} ,参数:{}", applicationBusinessConfig.getDownUrl(), requestParam);
String respBody = post(applicationBusinessConfig.getDownUrl(), requestParam);
log.info("调用下载服务成功,响应参数:{}", respBody);
} catch (Exception e) {
log.error("调用下载服务失败", e);
}
}
private final static Lock HTTP_POST_LOCK = new ReentrantLock();
public String post(String url, String body) {
HTTP_POST_LOCK.lock();
try {
HttpRequest post = HttpUtil.createPost(url);
post.timeout(5 * 1000);
post.header("Content-Type", "application/json; charset=utf-8");
post.body(body);
HttpResponse response = post.execute();
return response.body();
} finally {
HTTP_POST_LOCK.unlock();
}
}
}

@ -0,0 +1,26 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
<artifactId>docus-collector-server</artifactId>
<groupId>com.docus</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>docus-archivefile</artifactId>
<name>Archetype - docus-archivefile</name>
<url>http://maven.apache.org</url>
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
</build>
</project>

@ -0,0 +1,40 @@
package com.docus.server.record;
import com.docus.infrastructure.core.exception.IErrorCode;
public enum RecordExceptionEnum implements IErrorCode {
/**
*
*/
NOT_NULL("1001", "参数不能为空!"),
;
private String msgCode;
private String msg;
/**
* , WX
*/
private String moduleCode = "MR";
RecordExceptionEnum(String msgCode, String msg) {
this.msgCode = msgCode;
this.msg = msg;
}
@Override
public String getCode() {
return moduleCode + this.msgCode;
}
@Override
public String getMessage() {
return msg;
}
}

@ -0,0 +1,5 @@
package com.docus.server.record.controller;
public class Package {
}

@ -0,0 +1,4 @@
package com.docus.server.record.controller.param;
public class Package {
}

@ -0,0 +1,4 @@
package com.docus.server.record.controller.vo;
public class Package {
}

@ -0,0 +1,29 @@
package com.docus.server.archivefile.mapper;
import com.docus.server.archivefile.pojo.entity.AfCollectTask;
import org.apache.ibatis.annotations.Param;
/**
* mapper
*
* @author wyb
*/
public interface AfCollectTaskMapper {
/**
*
*
* @param afCollectTask
* @return
*/
int saveTask(@Param("task") AfCollectTask afCollectTask);
/**
*
*
* @param taskId
* @return
*/
AfCollectTask getTaskById(@Param("id") Long taskId);
}

@ -0,0 +1,32 @@
package com.docus.server.archivefile.mapper;
import com.docus.server.archivefile.pojo.entity.AfJobTime;
import org.apache.ibatis.annotations.Param;
/**
* job
* @author wyb
*/
public interface AfJobTimeMapper {
/**
*
* @param jobType
* @return
*/
AfJobTime getAfJobTimeByJobType(@Param("jobType") String jobType);
/**
* job
* @param afJobTime job
* @return
*/
int insert(@Param("afJobTime") AfJobTime afJobTime);
/**
* job
* @param afJobTime job
* @return
*/
int updateById(@Param("afJobTime") AfJobTime afJobTime);
}

@ -0,0 +1,76 @@
package com.docus.server.archivefile.mapper;
import com.docus.server.archivefile.pojo.entity.AfReportRecord;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
*
* @author wyb
*/
public interface AfReportRecordMapper {
/**
*
*
* @param afReportRecord
* @return
*/
int saveRecord(@Param("reportRecord") AfReportRecord afReportRecord);
/**
*
*
* @param serialnum
* @param inpatientNo
* @param admisstimes
* @param sysFlag
* @return
*/
AfReportRecord getRecordBySerialnumAndInpatientNoAndSysFlag(@Param("serialnum") String serialnum, @Param("inpatientNo") String inpatientNo, @Param("admisstimes") Integer admisstimes, @Param("sysFlag") String sysFlag);
/**
*
*
* @param afReportRecord
* @return
*/
int updateRecordByTaskId(@Param("reportRecord") AfReportRecord afReportRecord);
/**
*
*
* @param taskId id
* @return
*/
int updateStateByTaskId(@Param("taskId") Long taskId);
AfReportRecord getReportRecordInfoByTaskId(@Param("taskId") Long taskId);
/**
* idpatientIdid
*
* @param taskIds id
* @return patientIdid
*/
List<Long> getHasPatientIdTaskIdsByTaskIds(@Param("taskIds") List<Long> taskIds);
/**
*
*
* @param page
* @param pageSize
* @return
*/
List<AfReportRecord> getStartStateReportRecord(@Param("page") int page, @Param("pageSize") int pageSize);
/**
* id
*
* @param patientId
* @param taskId id
* @return
*/
int updateReportRecordPatientId(@Param("patientId") String patientId, @Param("taskId") Long taskId);
}

@ -0,0 +1,13 @@
package com.docus.server.record.pojo.dto;
public enum IdType {
/**
*
*/
JZH,
/**
*
*/
INPATIENT_NO
}

@ -0,0 +1,30 @@
package com.docus.server.record.pojo.dto;
import com.docus.infrastructure.core.exception.BaseException;
import com.docus.server.record.RecordExceptionEnum;
/**
*
*/
public class InpatientNo {
private String inpatientNo;
public InpatientNo(String inpatientNo) {
this.inpatientNo = inpatientNo;
this.vaid();
}
public void vaid() {
if (inpatientNo == null) {
throw new BaseException(RecordExceptionEnum.NOT_NULL, "inpatientNo不能为空");
}
}
public static InpatientNo of(String inpatientNo) {
return new InpatientNo(inpatientNo);
}
}

@ -0,0 +1,48 @@
package com.docus.server.record.pojo.dto;
import lombok.Data;
import java.util.Map;
/**
* @BelongsProject: docus-webservice-sdry
* @BelongsPackage: com.docus.server.collection.webservice
* @Author: chierhao
* @CreateTime: 2023-02-25 14:44
* @Description: TODO
* @Version: 1.0
*/
@Data
public class TBasicDTO {
private String serialId;
private String receive;
private String send;
private String jzh;
private String inpatientNo;
private String admissTimes;
private String name;
private String admissDate;
private String disDate;
private String admissDeptName;
private String disDeptName;
private String attending;
private String attendingName;
private String dutyNurse;
private String admissDept;
private String age;
private String sex;
private String idCard;
private String disDept;
private String sexName;
private String bedNum;
private String isDead;
private String admissDays;
private String wardCode;
private String wardName;
private String sdryIndex;
/**
*
*/
private Map<String, Object> params;
}

@ -0,0 +1,79 @@
package com.docus.server.archivefile.pojo.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
/**
* <p>
*
* </p>
*
* @author
* @since 2021-05-07
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "AfCollectTask对象", description = "病案采集任务")
public class AfCollectTask implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "id 主键")
@TableId(value = "id", type = IdType.INPUT)
private Long id;
@ApiModelProperty(value = "病案主键")
private String patientId;
@ApiModelProperty(value = "来源 1护理文书2 电子病历3 Pacs检查4心电图5手麻系统6 Lis检验7病案首页8长临医嘱")
private String sysflag;
@ApiModelProperty(value = "开始时间")
private Date startTime;
@ApiModelProperty(value = "结束时间")
private Date endTime;
@ApiModelProperty(value = "任务耗时(毫秒)")
private Long consumingTime;
@ApiModelProperty(value = "-1 等待采集0未开始1:正在采集2采集错误3采集完成")
private String state;
@ApiModelProperty(value = "同步时间")
private Date syncTime;
@ApiModelProperty(value = "最新重新采集时间")
private Date recollectTime;
@ApiModelProperty(value = "最新重新采集人")
private String recollectName;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "报告唯一单号")
private String C1;
@ApiModelProperty(value = "c2")
private String C2;
@ApiModelProperty(value = "记账号")
private String C3;
@ApiModelProperty(value = "c4")
private String C4;
@ApiModelProperty(value = "c6")
private String C6;
@ApiModelProperty(value = "c9")
private String C9;
}

@ -0,0 +1,42 @@
package com.docus.server.archivefile.pojo.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
/**
* <p>
*
* </p>
*
* @author
* @since 2021-05-08
*/
@Data
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="AfJobTime对象", description="")
public class AfJobTime implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键id")
private Long id;
@ApiModelProperty(value = "最新刷新时间 格式 yyyy-MM-dd HH:mm:ss")
private String updateTime;
@ApiModelProperty(value = "调度类型。")
private String jobType;
public AfJobTime() {
}
public AfJobTime(Long id, String updateTime, String jobType) {
this.id = id;
this.updateTime = updateTime;
this.jobType = jobType;
}
}

@ -0,0 +1,101 @@
package com.docus.server.archivefile.pojo.entity;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
*
*/
@Data
public class AfReportRecord implements Serializable {
private static final long serialVersionUID = 1L;
/**
* af_collect_task id
*/
private Long taskId;
/**
*
*/
private String inpatientNo;
/**
*
*/
private String jzh;
/**
*
*/
private Integer admissTimes;
/**
* 使 |
*/
private String downUrl;
/**
* 1:url2:base643:url base644:5base64
*/
private Integer downType;
/**
* 0 1
*/
private Integer state;
/**
* id
*/
private String serialnum;
/**
*
*/
private String sysflag;
/**
* id
*/
private String zdAssortId;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*
*/
private String fileName;
/**
*
*/
private String patientId;
public AfReportRecord() {
}
public AfReportRecord(ReportDto reportDto) {
this.jzh = reportDto.getJzh();
this.admissTimes = reportDto.getAdmisstimes();
this.inpatientNo = reportDto.getInpatientNo();
this.downUrl = reportDto.getDownUrl();
this.sysflag = reportDto.getSysFlag();
this.zdAssortId = reportDto.getAssortId();
this.serialnum = reportDto.getSerialnum();
this.fileName = reportDto.getFileTitle();
this.downType = reportDto.getDowntype();
}
}

@ -0,0 +1,7 @@
package com.docus.server.record.service;
import com.docus.server.record.pojo.entity.MedicalRecord;
public interface IMedicalRecordService {
void receive(MedicalRecord medicalRecord);
}

@ -0,0 +1,54 @@
package com.docus.server.record.service.impl;
import com.docus.server.record.pojo.dto.IdType;
import com.docus.server.record.pojo.entity.MedicalRecord;
import com.docus.server.record.service.IMedicalRecordService;
import org.springframework.stereotype.Service;
@Service
public class MedicalRecordServiceImpl implements IMedicalRecordService {
@Override
public void receive(MedicalRecord medicalRecord) {
//判断幂等,不要重复提交。 //判断业务是否正确,
if (isExist(medicalRecord)) {
return;
}
//保存数据内容到数据库。
this.saveMedicalRecord(medicalRecord);
//发起下载任务
}
public void createDownloadTask(MedicalRecord medicalRecord) {
//创建下载任务,改造文件服务,
//确保下载任务成功。
//完成任务,保存对应信息到病案系统。
}
public void saveFileInfo() {
}
public void saveMedicalRecord(MedicalRecord medicalRecord) {
}
public Boolean isExist(MedicalRecord medicalRecord) {
if (medicalRecord.getIdType() == IdType.JZH) {
//根据记账号查询
return true;
} else {
//根据住院号+住院次数
return true;
}
}
}

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.server.archivefile.mapper.AfCollectTaskMapper">
<insert id="saveTask">
INSERT INTO `docus_archivefile`.`af_collect_task`(`id`, `patient_id`, `sysflag`,
`state`, `C1`,`C2`, `C3`)
VALUES (#{task.id}, #{task.patientId}, #{task.sysflag}, '0', #{task.C1}, #{task.C2}, #{task.C3});
</insert>
<select id="getTaskById" resultType="com.docus.server.archivefile.pojo.entity.AfCollectTask">
select *
from `docus_archivefile`.`af_collect_task`
where `id` = #{id}
</select>
</mapper>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.server.archivefile.mapper.AfJobTimeMapper">
<insert id="insert">
INSERT INTO `docus_archivefile`.`af_job_time`(`id`, `update_time`, `job_type`)
VALUES (#{afJobTime.id}, #{afJobTime.updateTime}, #{afJobTime.jobType});
</insert>
<update id="updateById">
UPDATE `docus_archivefile`.`af_job_time`
SET `update_time` = #{afJobTime.updateTime},
WHERE `id` = #{afJobTime.id};
</update>
<select id="getAfJobTimeByJobType" resultType="com.docus.server.archivefile.pojo.entity.AfJobTime">
select id, DATE_FORMAT(update_time,'%Y-%m-%d %H:%i:%s') as updateTime,job_type as jobType
from `docus_archivefile`.`af_job_time`
where job_type= #{jobType}
</select>
</mapper>

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.server.archivefile.mapper.AfReportRecordMapper">
<insert id="saveRecord">
INSERT INTO `docus_archivefile`.`af_report_record`(`task_id`, `inpatient_no`, `jzh`, `admiss_times`, `down_url`,
`down_type`, `state`, `serialnum`, `sysflag`, `zd_assort_id`,
`create_time`, `update_time`, `file_name`, `patient_id`)
VALUES (#{reportRecord.taskId}, #{reportRecord.inpatientNo}, #{reportRecord.jzh}, #{reportRecord.admissTimes},
#{reportRecord.downUrl}, #{reportRecord.downType}, 0, #{reportRecord.serialnum},
#{reportRecord.sysflag}, #{reportRecord.zdAssortId}, now(), now(), #{reportRecord.fileName},
#{reportRecord.patientId});
</insert>
<update id="updateRecordByTaskId">
update `docus_archivefile`.`af_report_record`
set `down_url`=#{reportRecord.downUrl},
`down_type`=#{reportRecord.downType},
`state`=0,
`file_name`=#{reportRecord.fileName},
`patient_id`=#{reportRecord.patientId},
`update_time`=now()
where `task_id` = #{reportRecord.taskId}
</update>
<update id="updateStateByTaskId">
update `docus_archivefile`.`af_report_record`
set `state`= 1,
`update_time`=now()
where `task_id` = #{taskId}
</update>
<update id="updateReportRecordPatientId">
update `docus_archivefile`.`af_report_record`
set `patient_id`= #{patientId}
where `task_id` = #{taskId}
</update>
<select id="getRecordBySerialnumAndInpatientNoAndSysFlag"
resultType="com.docus.server.archivefile.pojo.entity.AfReportRecord">
select *
from `docus_archivefile`.`af_report_record`
where `inpatient_no` = #{inpatientNo}
and `serialnum` = #{serialnum}
and `sysflag` = #{sysFlag}
and admiss_times = #{admisstimes}
</select>
<select id="getReportRecordInfoByTaskId" resultType="com.docus.server.archivefile.pojo.entity.AfReportRecord">
select *
from `docus_archivefile`.`af_report_record`
where `task_id` = #{taskId}
</select>
<select id="getHasPatientIdTaskIdsByTaskIds" resultType="java.lang.Long">
SELECT `task_id`
FROM `docus_archivefile`.`af_report_record`
WHERE `patient_id` IS NOT NULL
AND `patient_id` != ''
AND `task_id` IN
<foreach collection="taskIds" separator="," open="(" close=")" item="taskId">
#{taskId}
</foreach>
</select>
<select id="getStartStateReportRecord" resultType="com.docus.server.archivefile.pojo.entity.AfReportRecord">
SELECT `task_id`, `inpatient_no`, `admiss_times`, `patient_id`
FROM `docus_archivefile`.`af_report_record`
WHERE `state` = 0
LIMIT ${(page-1)*pageSize}
, ${pageSize}
</select>
</mapper>

@ -10,7 +10,7 @@
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</parent> </parent>
<artifactId>starter-log</artifactId> <artifactId>docus-starter-log</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
<dependencies> <dependencies>
@ -18,17 +18,5 @@
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId> <artifactId>spring-boot-starter-aop</artifactId>
</dependency> </dependency>
<!-- <dependency>-->
<!-- <groupId>org.aspectj</groupId>-->
<!-- <artifactId>aspectjrt</artifactId>-->
<!-- <version>1.7.1</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.aspectj</groupId>-->
<!-- <artifactId>aspectjweaver</artifactId>-->
<!-- <version>1.7.1</version>-->
<!-- </dependency>-->
</dependencies> </dependencies>
</project> </project>

@ -30,7 +30,7 @@ public class TrackGroupAspect {
*/ */
@Around("@annotation(trackGroup)") @Around("@annotation(trackGroup)")
public Object execute(final ProceedingJoinPoint joinPoint, TrackGroup trackGroup) throws Throwable { public Object execute(final ProceedingJoinPoint joinPoint, TrackGroup trackGroup) throws Throwable {
log.debug("=== AOP @TrackGroup 切面启动器监听处理事件开始 ==="); log.info("=== AOP @TrackGroup 切面启动器监听处理事件开始 ===");
TrackContext context = getContext(joinPoint, trackGroup); TrackContext context = getContext(joinPoint, trackGroup);
ITrackProcessor processor = applicationContext.getAutowireCapableBeanFactory().createBean(trackGroup.processor()); ITrackProcessor processor = applicationContext.getAutowireCapableBeanFactory().createBean(trackGroup.processor());
@ -49,7 +49,7 @@ public class TrackGroupAspect {
} finally { } finally {
processor.afterProcess(context); processor.afterProcess(context);
TrackContext.clear(); TrackContext.clear();
log.debug("=== AOP @TrackGroup 切面启动器监听处理事件结束 ==="); log.info("=== AOP @TrackGroup 切面启动器监听处理事件结束 ===");
} }
} }
@ -58,7 +58,7 @@ public class TrackGroupAspect {
*/ */
@Around("@annotation(logTrackGroup)") @Around("@annotation(logTrackGroup)")
public Object execute(final ProceedingJoinPoint joinPoint, LogTrackGroup logTrackGroup) throws Throwable { public Object execute(final ProceedingJoinPoint joinPoint, LogTrackGroup logTrackGroup) throws Throwable {
log.debug("=== AOP @LogTrackGroup 切面启动器监听处理事件开始 ==="); log.info("=== AOP @LogTrackGroup 切面启动器监听处理事件开始 ===");
final Object result; final Object result;
TrackContext context = getContext(joinPoint, logTrackGroup); TrackContext context = getContext(joinPoint, logTrackGroup);
ITrackProcessor processor = applicationContext.getAutowireCapableBeanFactory().createBean(logTrackGroup.processor()); ITrackProcessor processor = applicationContext.getAutowireCapableBeanFactory().createBean(logTrackGroup.processor());
@ -72,7 +72,7 @@ public class TrackGroupAspect {
processor.process(context); processor.process(context);
throw new RuntimeException(ex.getMessage()); throw new RuntimeException(ex.getMessage());
} }
log.debug("=== AOP @LogTrackGroup 切面启动器监听处理事件结束 ==="); log.info("=== AOP @LogTrackGroup 切面启动器监听处理事件结束 ===");
return result; return result;
} }

@ -7,7 +7,7 @@ import java.util.Map;
@Data @Data
public class TrackContext { public class TrackContext {
private static final ThreadLocal<TrackContext> THREAD_LOCAL = new ThreadLocal<>(); private static final ThreadLocal<TrackContext> CONTEXT_HOLDER = new ThreadLocal<>();
private Class classType; private Class classType;
private String className; private String className;
@ -28,18 +28,18 @@ public class TrackContext {
//初始化 //初始化
public static void init(Map<String, Object> params) { public static void init(Map<String, Object> params) {
THREAD_LOCAL.remove(); CONTEXT_HOLDER.remove();
TrackContext context = new TrackContext(); TrackContext context = new TrackContext();
context.setParams(params); context.setParams(params);
THREAD_LOCAL.set(context); CONTEXT_HOLDER.set(context);
} }
public static TrackContext get() { public static TrackContext get() {
return THREAD_LOCAL.get(); return CONTEXT_HOLDER.get();
} }
//清除线程变量 //清除线程变量
public static void clear() { public static void clear() {
THREAD_LOCAL.remove(); CONTEXT_HOLDER.remove();
} }
} }

@ -20,7 +20,7 @@ public abstract class AbstractProcessor implements ITrackProcessor {
*/ */
@Override @Override
public Object beforeProcess(TrackContext context) { public Object beforeProcess(TrackContext context) {
logger.debug("=== AOP 前置通知 ==="); logger.info("=== AOP 前置通知 ===");
return null; return null;
} }
@ -44,7 +44,7 @@ public abstract class AbstractProcessor implements ITrackProcessor {
*/ */
@Override @Override
public Object afterProcess(TrackContext context) { public Object afterProcess(TrackContext context) {
logger.debug("=== AOP 最后通知 ==="); logger.info("=== AOP 最后通知 ===");
return null; return null;
} }

@ -200,7 +200,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.docus</groupId> <groupId>com.docus</groupId>
<artifactId>starter-log</artifactId> <artifactId>docus-starter-log</artifactId>
<version>1.0-SNAPSHOT</version> <version>1.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>

Loading…
Cancel
Save