diff --git a/collect-sdry/data-config/js-report-config.xml b/collect-sdry/data-config/js-report-config.xml new file mode 100644 index 0000000..d74c2a3 --- /dev/null +++ b/collect-sdry/data-config/js-report-config.xml @@ -0,0 +1,25 @@ + + + + /Request/Msg/INHOSP_INDEX_NO + + /Request/Msg/INHOSP_NO + + /Request/Msg/INHOSP_NUM + + /Request/Msg/UNIQUE_FILE + + /Request/Msg/FILE_NAME + + /Request/Msg/PDF_PATH + + /Request/Msg/TABLE_TYPE + + + + /Request/Msg/TABLE_TYPE + + + + + \ No newline at end of file diff --git a/collect-sdry/data-config/js-table-type.json b/collect-sdry/data-config/js-table-type.json new file mode 100644 index 0000000..3a7fd45 --- /dev/null +++ b/collect-sdry/data-config/js-table-type.json @@ -0,0 +1,5 @@ +{ + "icu": "重症文件分段id", + "sa": "手麻文件分段id", + "other": "其他文件分段id" +} \ No newline at end of file diff --git a/collect-sdry/data-config/js-webservice-template-request.xml b/collect-sdry/data-config/js-webservice-template-request.xml new file mode 100644 index 0000000..0d32ef2 --- /dev/null +++ b/collect-sdry/data-config/js-webservice-template-request.xml @@ -0,0 +1,25 @@ + + + + + 123456 + + 012345 + + 012345 + + 2 + + icu + + 20220303111800 + + 20220303111801 + + http://192.168.1.108:9012/file/0123_01.pdf + + 0123_01 + + AESHASHMD5DEFIND + + diff --git a/collect-sdry/data-config/js-webservice-template-response.xml b/collect-sdry/data-config/js-webservice-template-response.xml new file mode 100644 index 0000000..8ceb826 --- /dev/null +++ b/collect-sdry/data-config/js-webservice-template-response.xml @@ -0,0 +1,11 @@ + + + + + 0 + + 123456 + + 成功! + + \ No newline at end of file diff --git a/collect-sdry/src/main/java/com/docus/server/collect/report/WsReportResultImpl.java b/collect-sdry/src/main/java/com/docus/server/collect/report/WsReportResultImpl.java index fa830c6..d7b2ea5 100644 --- a/collect-sdry/src/main/java/com/docus/server/collect/report/WsReportResultImpl.java +++ b/collect-sdry/src/main/java/com/docus/server/collect/report/WsReportResultImpl.java @@ -8,13 +8,29 @@ import java.util.Map; @Component("wsReportResultImpl") public class WsReportResultImpl implements IWsResult { + private static final String SUCCESS_TEMPLATE = "" + + "" + + "0" + + "%s" + + "成功!" + + "" + + ""; + + private static final String FAILED_TEMPLATE = "" + + "" + + "500" + + "%s" + + "%s" + + "" + + ""; + @Override public String ok(Map params) { - return null; + return String.format(SUCCESS_TEMPLATE, params.get("msgId")); } @Override public String fail(Map params) { - return null; + return String.format(FAILED_TEMPLATE, params.get("msgId"), params.get("msg")); } } diff --git a/collect-sdry/src/main/resources/bootstrap.yml b/collect-sdry/src/main/resources/bootstrap.yml index 11b0e85..e625b8c 100644 --- a/collect-sdry/src/main/resources/bootstrap.yml +++ b/collect-sdry/src/main/resources/bootstrap.yml @@ -12,21 +12,21 @@ spring: datasource: 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 - username: root - password: root + username: docus + password: docus702 driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy type: com.alibaba.druid.pool.DruidDataSource his: 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 - password: root + username: docus + password: docus702 driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy type: com.alibaba.druid.pool.DruidDataSource redis: host: redis.docus.cn - # password: JSdocus@702 + password: JSdocus@702 cloud: nacos: discovery: @@ -39,12 +39,12 @@ spring: shared-configs: - comm.${spring.cloud.nacos.config.file-extension} - docus: dbtype: mysql user: # 用户默认密码 defpwd: fd29cd53ec12616e5f36b77d4afffbff + mybatis-plus: configuration: map-underscore-to-camel-case: true @@ -80,4 +80,4 @@ xxl: # replica: # queueManager: MqManager02 # channel: chl_server02 -# connName: 10.222.23.131(1414) +# connName: 10.222.23.131(1414) \ No newline at end of file diff --git a/common-collect/pom.xml b/common-collect/pom.xml index 2ef9011..d433381 100644 --- a/common-collect/pom.xml +++ b/common-collect/pom.xml @@ -11,6 +11,11 @@ http://maven.apache.org + + com.docus + docus-archivefile + 1.0-SNAPSHOT + com.docus docus-medical-record diff --git a/common-collect/src/main/java/com/docus/server/collect/infrastructure/dao/CollectTypeEnum.java b/common-collect/src/main/java/com/docus/server/collect/infrastructure/dao/CollectTypeEnum.java index cfae13f..9d76e4c 100644 --- a/common-collect/src/main/java/com/docus/server/collect/infrastructure/dao/CollectTypeEnum.java +++ b/common-collect/src/main/java/com/docus/server/collect/infrastructure/dao/CollectTypeEnum.java @@ -7,7 +7,7 @@ public enum CollectTypeEnum implements IIntegerEnum { WEBSERVICE_XML_DEPT(0, "WEBSERVICE_XML_DEPT"), WEBSERVICE_XML_USER(1, "WEBSERVICE_XML_USER"), 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_INSERT_INSPECTION_REPORT(5, "WEBSERVICE_XML_INSERT_INSPECTION_REPORT"), WEBSERVICE_XML_UPDATE_INSPECTION_REPORT(6, "WEBSERVICE_XML_UPDATE_INSPECTION_REPORT"); diff --git a/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownDTO.java b/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownDTO.java new file mode 100644 index 0000000..07dc1f9 --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownDTO.java @@ -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 scanfiles; + + @ApiModelProperty(value = "扫描用户代码") + private String scanusercode; + @ApiModelProperty(value = "扫描用户名称") + private String scanusername; +} \ No newline at end of file diff --git a/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownPatientDTO.java b/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownPatientDTO.java new file mode 100644 index 0000000..a14c9ea --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownPatientDTO.java @@ -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(); + } +} diff --git a/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownScanFileDTO.java b/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownScanFileDTO.java new file mode 100644 index 0000000..a267716 --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/collect/infrastructure/pojo/dto/ReportDownScanFileDTO.java @@ -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:服务器本地;2:ftp服务器;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(); + } +} diff --git a/common-collect/src/main/java/com/docus/server/collect/service/CollectService.java b/common-collect/src/main/java/com/docus/server/collect/service/CollectService.java index 571f43f..ff2263c 100644 --- a/common-collect/src/main/java/com/docus/server/collect/service/CollectService.java +++ b/common-collect/src/main/java/com/docus/server/collect/service/CollectService.java @@ -1,17 +1,18 @@ 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.UserDTO; import com.docus.server.sys.service.IPowerDeptService; import com.docus.server.sys.service.IPowerUserService; -import com.docus.server.ws.impl.BaseCollectService; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @Service -public class CollectService extends BaseCollectService { +public class CollectService { + protected final static String DEL_TYPE = "D"; @Resource private IPowerDeptService deptService; @Resource @@ -25,7 +26,7 @@ public class CollectService extends BaseCollectService { @Transactional public void insertOrUpdateDept(DeptDTO deptDTO) { //异步写入归档系统,失败自动重试。 - if (checkType(deptDTO.getOperateType(), delType)) { + if (checkType(deptDTO.getOperateType(), DEL_TYPE)) { deptService.delDeptByDeptCode(deptDTO.getDeptCode()); } else { deptService.saveOrUpdatePowerDept(deptDTO); @@ -35,10 +36,16 @@ public class CollectService extends BaseCollectService { @Transactional public void insertOrUpdateUser(UserDTO userDTO) { // 判断操作类型 - if (super.checkType(userDTO.getOperateType(), delType)) { + if (checkType(userDTO.getOperateType(), DEL_TYPE)) { userService.delUserByUserName(userDTO.getUserName()); } else { userService.saveOrUpdatePowerUser(userDTO); } } + + + protected boolean checkType(String operateType, String delType) { + return Func.isNotEmpty(operateType) + && operateType.contains(delType); + } } diff --git a/common-collect/src/main/java/com/docus/server/visitor/VisitorProcessor.java b/common-collect/src/main/java/com/docus/server/visitor/VisitorProcessor.java index 903157f..5fa79d0 100644 --- a/common-collect/src/main/java/com/docus/server/visitor/VisitorProcessor.java +++ b/common-collect/src/main/java/com/docus/server/visitor/VisitorProcessor.java @@ -11,6 +11,7 @@ import com.docus.server.tool.SpringUtils; import com.docus.server.ws.ITaskOriginalMessageService; import com.docus.server.ws.IWsResult; import com.docus.server.ws.convert.IConverter; +import com.fasterxml.jackson.core.type.TypeReference; import lombok.extern.slf4j.Slf4j; import java.util.Map; @@ -43,49 +44,38 @@ public class VisitorProcessor extends AbstractProcessor { 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) { - Map params = context.getParams(); - Long taskId = (Long) params.get("taskId"); - 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()); + @Override + public Object doProcess(TrackContext context) { Map params = context.getParams(); try { + Long taskId = (Long) params.get("taskId"); + String afterReturnResult = (String) params.get("jsonStr"); params.put("msg", context.getExMessageResult()); - Map beforeResult = context.getParams(); - Long taskId = (Long) beforeResult.get("taskId"); - String afterReturnResult = (String) beforeResult.get("jsonStr"); - messageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.FAIL); - params.putAll(JSON.fromJSON(afterReturnResult, Map.class)); - return wsResult.fail(params); + + if (!context.isError()) { + log.info("=== AOP 后置通知 ==="); + params.putAll(JSON.fromJSONWithGeneric(afterReturnResult, new TypeReference>() { + })); + params.put("msg", "操作成功!"); + return wsResult.ok(params); + } else { + log.info("=== AOP 异常通知 ==="); + messageService.updateTaskOriginalMessage(taskId, afterReturnResult, StateEnum.FAIL); + params.putAll(JSON.fromJSONWithGeneric(afterReturnResult, new TypeReference>() { + })); + return wsResult.fail(params); + } } catch (Exception e) { return wsResult.fail(params); } } + /** + * 初始化bean + */ private void initBeans(String[] beanNames) { this.converter = (IConverter) SpringUtils.getBean(beanNames[0]); this.wsResult = (IWsResult) SpringUtils.getBean(beanNames[1]); diff --git a/common-collect/src/main/java/com/docus/server/ws/IReportService.java b/common-collect/src/main/java/com/docus/server/ws/IReportService.java new file mode 100644 index 0000000..15585ff --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/ws/IReportService.java @@ -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 taskIds) throws Exception; +} diff --git a/common-collect/src/main/java/com/docus/server/ws/event/TaskConsumptionReportDownEvent.java b/common-collect/src/main/java/com/docus/server/ws/event/TaskConsumptionReportDownEvent.java new file mode 100644 index 0000000..54520f7 --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/ws/event/TaskConsumptionReportDownEvent.java @@ -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; + } + + +} diff --git a/common-collect/src/main/java/com/docus/server/ws/event/ThreePartyPushReportDownEvent.java b/common-collect/src/main/java/com/docus/server/ws/event/ThreePartyPushReportDownEvent.java new file mode 100644 index 0000000..40a371b --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/ws/event/ThreePartyPushReportDownEvent.java @@ -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; + } + + +} diff --git a/common-collect/src/main/java/com/docus/server/ws/impl/BaseCollectService.java b/common-collect/src/main/java/com/docus/server/ws/impl/BaseCollectService.java deleted file mode 100644 index f46347f..0000000 --- a/common-collect/src/main/java/com/docus/server/ws/impl/BaseCollectService.java +++ /dev/null @@ -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); - } - - -} diff --git a/common-collect/src/main/java/com/docus/server/ws/impl/DeptServerImpl.java b/common-collect/src/main/java/com/docus/server/ws/impl/DeptServerImpl.java index ed06b8c..1379c85 100644 --- a/common-collect/src/main/java/com/docus/server/ws/impl/DeptServerImpl.java +++ b/common-collect/src/main/java/com/docus/server/ws/impl/DeptServerImpl.java @@ -30,8 +30,7 @@ public class DeptServerImpl implements IDeptServer { * @see VisitorProcessor 通用处理器 */ @Override - @TrackGroup(group = "WEBSERVICE_XML_DEPT", - beanNames = {"powerDeptConverter", "wsDeptResultImpl"}, processor = VisitorProcessor.class) + @TrackGroup(group = "WEBSERVICE_XML_DEPT", beanNames = {"powerDeptConverter", "wsDeptResultImpl"}, processor = VisitorProcessor.class) public String deptModify(String message) { log.info("新增/修改科室数据:{}", message); collectService.insertOrUpdateDept(JSON.fromJSON((String) TrackHelper.getValue("jsonStr"), DeptDTO.class)); diff --git a/common-collect/src/main/java/com/docus/server/ws/impl/ReportServerImpl.java b/common-collect/src/main/java/com/docus/server/ws/impl/ReportServerImpl.java index fc88b45..cfa2935 100644 --- a/common-collect/src/main/java/com/docus/server/ws/impl/ReportServerImpl.java +++ b/common-collect/src/main/java/com/docus/server/ws/impl/ReportServerImpl.java @@ -1,9 +1,17 @@ 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.IReportService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; +import javax.annotation.Resource; + /** * @author wyb * @date 2023年3月3日13:42:36 @@ -11,8 +19,24 @@ import org.springframework.stereotype.Service; @Service @Slf4j 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 - 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; } @@ -30,520 +54,4 @@ public class ReportServerImpl implements IReportServer { public String pushUpdateInspectionReport(String inspectionReportMessage) { 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 "\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\t\n" + -// " \n" + -// "\t\t\n" + -// "\t\n" + -// "\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 "\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\t\n" + -// " \n" + -// "\t\t\n" + -// "\t\n" + -// "\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 "\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\t\n" + -// " \n" + -// "\t\t\n" + -// "\t\n" + -// "\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 "\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\n" + -// "\t\n" + -// "\t\t\n" + -// "\t\t\t\n" + -// "\t\t\n" + -// "\t\t\n" + -// " \n" + -// "\t\t\n" + -// "\t\n" + -// "\n"; -// } } diff --git a/common-collect/src/main/java/com/docus/server/ws/impl/ReportServiceImpl.java b/common-collect/src/main/java/com/docus/server/ws/impl/ReportServiceImpl.java new file mode 100644 index 0000000..652cc83 --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/ws/impl/ReportServiceImpl.java @@ -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 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 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); + } +} diff --git a/common-collect/src/main/java/com/docus/server/ws/impl/UserServerImpl.java b/common-collect/src/main/java/com/docus/server/ws/impl/UserServerImpl.java index ffa1474..bc974c4 100644 --- a/common-collect/src/main/java/com/docus/server/ws/impl/UserServerImpl.java +++ b/common-collect/src/main/java/com/docus/server/ws/impl/UserServerImpl.java @@ -31,7 +31,7 @@ public class UserServerImpl implements IUserServer { */ @Override @TrackGroup(group = "WEBSERVICE_XML_USER", - beanNames = {"powerUserConverter", "wsUserResultImpl"}, processor = VisitorProcessor.class) + beanNames = {"powerUserConverter", "wsUserResultImpl"}, processor = VisitorProcessor.class) public String userModify(String message) { log.debug("新增/修改用户数据:{}", message); collectService.insertOrUpdateUser(JSON.fromJSON((String) TrackHelper.getValue("jsonStr"), UserDTO.class)); diff --git a/common-collect/src/main/java/com/docus/server/ws/listener/ReportDownListener.java b/common-collect/src/main/java/com/docus/server/ws/listener/ReportDownListener.java new file mode 100644 index 0000000..d1b7e04 --- /dev/null +++ b/common-collect/src/main/java/com/docus/server/ws/listener/ReportDownListener.java @@ -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 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 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(); + } + } +} diff --git a/docus-archivefile/pom.xml b/docus-archivefile/pom.xml new file mode 100644 index 0000000..60484a7 --- /dev/null +++ b/docus-archivefile/pom.xml @@ -0,0 +1,26 @@ + + + docus-collector-server + com.docus + 1.0-SNAPSHOT + + 4.0.0 + docus-archivefile + Archetype - docus-archivefile + http://maven.apache.org + + + + + src/main/java + + **/*.xml + + + + src/main/resources + + + + diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/RecordExceptionEnum.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/RecordExceptionEnum.java new file mode 100644 index 0000000..2b98c78 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/RecordExceptionEnum.java @@ -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; + } + +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/Package.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/Package.java new file mode 100644 index 0000000..65a1b37 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/Package.java @@ -0,0 +1,5 @@ +package com.docus.server.record.controller; + +public class Package { + +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/param/Package.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/param/Package.java new file mode 100644 index 0000000..aceed35 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/param/Package.java @@ -0,0 +1,4 @@ +package com.docus.server.record.controller.param; + +public class Package { +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/vo/Package.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/vo/Package.java new file mode 100644 index 0000000..0b5b3fd --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/controller/vo/Package.java @@ -0,0 +1,4 @@ +package com.docus.server.record.controller.vo; + +public class Package { +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfCollectTaskMapper.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfCollectTaskMapper.java new file mode 100644 index 0000000..fb7f695 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfCollectTaskMapper.java @@ -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); +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfJobTimeMapper.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfJobTimeMapper.java new file mode 100644 index 0000000..46a55cb --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfJobTimeMapper.java @@ -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); +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfReportRecordMapper.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfReportRecordMapper.java new file mode 100644 index 0000000..6b39769 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/mapper/AfReportRecordMapper.java @@ -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); + + /** + * 根据任务id查询有patientId数据的任务id + * + * @param taskIds 任务id集合 + * @return 数据有patientId的任务id集合 + */ + List getHasPatientIdTaskIdsByTaskIds(@Param("taskIds") List taskIds); + + /** + * 获取未开始的报告记录 + * + * @param page 分页页码 + * @param pageSize 一页条数 + * @return 未开始的报告记录 + */ + List 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); +} \ No newline at end of file diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/IdType.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/IdType.java new file mode 100644 index 0000000..50e424c --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/IdType.java @@ -0,0 +1,13 @@ +package com.docus.server.record.pojo.dto; + +public enum IdType { + /** + * 记账号 + */ + JZH, + + /** + * 病案号 + */ + INPATIENT_NO +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/InpatientNo.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/InpatientNo.java new file mode 100644 index 0000000..e702407 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/InpatientNo.java @@ -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); + } +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/TBasicDTO.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/TBasicDTO.java new file mode 100644 index 0000000..98cc98c --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/dto/TBasicDTO.java @@ -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 params; +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfCollectTask.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfCollectTask.java new file mode 100644 index 0000000..410604b --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfCollectTask.java @@ -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; + +/** + *

+ * 病案采集任务 + *

+ * + * @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; +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfJobTime.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfJobTime.java new file mode 100644 index 0000000..bac4d5d --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfJobTime.java @@ -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; + +/** + *

+ * + *

+ * + * @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; + } +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfReportRecord.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfReportRecord.java new file mode 100644 index 0000000..8d43488 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/pojo/entity/AfReportRecord.java @@ -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:url,2:base64,3:url base64,4:共享文件,5:本地文件base64 + */ + 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(); + } +} \ No newline at end of file diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/service/IMedicalRecordService.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/service/IMedicalRecordService.java new file mode 100644 index 0000000..1749f1e --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/service/IMedicalRecordService.java @@ -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); +} diff --git a/docus-archivefile/src/main/java/com/docus/server/archivefile/service/impl/MedicalRecordServiceImpl.java b/docus-archivefile/src/main/java/com/docus/server/archivefile/service/impl/MedicalRecordServiceImpl.java new file mode 100644 index 0000000..c5e0600 --- /dev/null +++ b/docus-archivefile/src/main/java/com/docus/server/archivefile/service/impl/MedicalRecordServiceImpl.java @@ -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; + } + } + + +} diff --git a/docus-archivefile/src/main/resources/mapper/AfCollectTaskMapper.xml b/docus-archivefile/src/main/resources/mapper/AfCollectTaskMapper.xml new file mode 100644 index 0000000..7356aa5 --- /dev/null +++ b/docus-archivefile/src/main/resources/mapper/AfCollectTaskMapper.xml @@ -0,0 +1,17 @@ + + + + + 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}); + + + + diff --git a/docus-archivefile/src/main/resources/mapper/AfJobTimeMapper.xml b/docus-archivefile/src/main/resources/mapper/AfJobTimeMapper.xml new file mode 100644 index 0000000..44b99fc --- /dev/null +++ b/docus-archivefile/src/main/resources/mapper/AfJobTimeMapper.xml @@ -0,0 +1,22 @@ + + + + + INSERT INTO `docus_archivefile`.`af_job_time`(`id`, `update_time`, `job_type`) + VALUES (#{afJobTime.id}, #{afJobTime.updateTime}, #{afJobTime.jobType}); + + + + UPDATE `docus_archivefile`.`af_job_time` + SET `update_time` = #{afJobTime.updateTime}, + WHERE `id` = #{afJobTime.id}; + + + + diff --git a/docus-archivefile/src/main/resources/mapper/AfReportRecordMapper.xml b/docus-archivefile/src/main/resources/mapper/AfReportRecordMapper.xml new file mode 100644 index 0000000..da2483d --- /dev/null +++ b/docus-archivefile/src/main/resources/mapper/AfReportRecordMapper.xml @@ -0,0 +1,68 @@ + + + + + + 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}); + + + 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 `docus_archivefile`.`af_report_record` + set `state`= 1, + `update_time`=now() + where `task_id` = #{taskId} + + + update `docus_archivefile`.`af_report_record` + set `patient_id`= #{patientId} + where `task_id` = #{taskId} + + + + + + diff --git a/starter-log/.gitignore b/docus-starter-log/.gitignore similarity index 100% rename from starter-log/.gitignore rename to docus-starter-log/.gitignore diff --git a/starter-log/pom.xml b/docus-starter-log/pom.xml similarity index 56% rename from starter-log/pom.xml rename to docus-starter-log/pom.xml index 07a2e5d..7ab85f1 100644 --- a/starter-log/pom.xml +++ b/docus-starter-log/pom.xml @@ -10,7 +10,7 @@ 1.0-SNAPSHOT - starter-log + docus-starter-log 1.0-SNAPSHOT @@ -18,17 +18,5 @@ org.springframework.boot spring-boot-starter-aop
- - - - - - - - - - - -
diff --git a/starter-log/src/main/java/com/docus/log/EnableTrackGroup.java b/docus-starter-log/src/main/java/com/docus/log/EnableTrackGroup.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/EnableTrackGroup.java rename to docus-starter-log/src/main/java/com/docus/log/EnableTrackGroup.java diff --git a/starter-log/src/main/java/com/docus/log/EnableTrackGroupConfiguration.java b/docus-starter-log/src/main/java/com/docus/log/EnableTrackGroupConfiguration.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/EnableTrackGroupConfiguration.java rename to docus-starter-log/src/main/java/com/docus/log/EnableTrackGroupConfiguration.java diff --git a/starter-log/src/main/java/com/docus/log/EnableTrackGroupSelector.java b/docus-starter-log/src/main/java/com/docus/log/EnableTrackGroupSelector.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/EnableTrackGroupSelector.java rename to docus-starter-log/src/main/java/com/docus/log/EnableTrackGroupSelector.java diff --git a/starter-log/src/main/java/com/docus/log/EnableTrackGroupSettings.java b/docus-starter-log/src/main/java/com/docus/log/EnableTrackGroupSettings.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/EnableTrackGroupSettings.java rename to docus-starter-log/src/main/java/com/docus/log/EnableTrackGroupSettings.java diff --git a/starter-log/src/main/java/com/docus/log/annotation/LogTrackGroup.java b/docus-starter-log/src/main/java/com/docus/log/annotation/LogTrackGroup.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/annotation/LogTrackGroup.java rename to docus-starter-log/src/main/java/com/docus/log/annotation/LogTrackGroup.java diff --git a/starter-log/src/main/java/com/docus/log/annotation/TrackGroup.java b/docus-starter-log/src/main/java/com/docus/log/annotation/TrackGroup.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/annotation/TrackGroup.java rename to docus-starter-log/src/main/java/com/docus/log/annotation/TrackGroup.java diff --git a/starter-log/src/main/java/com/docus/log/aspect/TrackGroupAspect.java b/docus-starter-log/src/main/java/com/docus/log/aspect/TrackGroupAspect.java similarity index 92% rename from starter-log/src/main/java/com/docus/log/aspect/TrackGroupAspect.java rename to docus-starter-log/src/main/java/com/docus/log/aspect/TrackGroupAspect.java index 6bdda90..8a68f6e 100644 --- a/starter-log/src/main/java/com/docus/log/aspect/TrackGroupAspect.java +++ b/docus-starter-log/src/main/java/com/docus/log/aspect/TrackGroupAspect.java @@ -30,7 +30,7 @@ public class TrackGroupAspect { */ @Around("@annotation(trackGroup)") public Object execute(final ProceedingJoinPoint joinPoint, TrackGroup trackGroup) throws Throwable { - log.debug("=== AOP @TrackGroup 切面启动器监听处理事件开始 ==="); + log.info("=== AOP @TrackGroup 切面启动器监听处理事件开始 ==="); TrackContext context = getContext(joinPoint, trackGroup); ITrackProcessor processor = applicationContext.getAutowireCapableBeanFactory().createBean(trackGroup.processor()); @@ -49,7 +49,7 @@ public class TrackGroupAspect { } finally { processor.afterProcess(context); TrackContext.clear(); - log.debug("=== AOP @TrackGroup 切面启动器监听处理事件结束 ==="); + log.info("=== AOP @TrackGroup 切面启动器监听处理事件结束 ==="); } } @@ -58,7 +58,7 @@ public class TrackGroupAspect { */ @Around("@annotation(logTrackGroup)") public Object execute(final ProceedingJoinPoint joinPoint, LogTrackGroup logTrackGroup) throws Throwable { - log.debug("=== AOP @LogTrackGroup 切面启动器监听处理事件开始 ==="); + log.info("=== AOP @LogTrackGroup 切面启动器监听处理事件开始 ==="); final Object result; TrackContext context = getContext(joinPoint, logTrackGroup); ITrackProcessor processor = applicationContext.getAutowireCapableBeanFactory().createBean(logTrackGroup.processor()); @@ -72,7 +72,7 @@ public class TrackGroupAspect { processor.process(context); throw new RuntimeException(ex.getMessage()); } - log.debug("=== AOP @LogTrackGroup 切面启动器监听处理事件结束 ==="); + log.info("=== AOP @LogTrackGroup 切面启动器监听处理事件结束 ==="); return result; } diff --git a/starter-log/src/main/java/com/docus/log/context/TrackContext.java b/docus-starter-log/src/main/java/com/docus/log/context/TrackContext.java similarity index 79% rename from starter-log/src/main/java/com/docus/log/context/TrackContext.java rename to docus-starter-log/src/main/java/com/docus/log/context/TrackContext.java index 166b472..9aa4d7b 100644 --- a/starter-log/src/main/java/com/docus/log/context/TrackContext.java +++ b/docus-starter-log/src/main/java/com/docus/log/context/TrackContext.java @@ -7,7 +7,7 @@ import java.util.Map; @Data public class TrackContext { - private static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>(); + private static final ThreadLocal CONTEXT_HOLDER = new ThreadLocal<>(); private Class classType; private String className; @@ -28,18 +28,18 @@ public class TrackContext { //初始化 public static void init(Map params) { - THREAD_LOCAL.remove(); + CONTEXT_HOLDER.remove(); TrackContext context = new TrackContext(); context.setParams(params); - THREAD_LOCAL.set(context); + CONTEXT_HOLDER.set(context); } public static TrackContext get() { - return THREAD_LOCAL.get(); + return CONTEXT_HOLDER.get(); } //清除线程变量 public static void clear() { - THREAD_LOCAL.remove(); + CONTEXT_HOLDER.remove(); } } diff --git a/starter-log/src/main/java/com/docus/log/context/TrackHelper.java b/docus-starter-log/src/main/java/com/docus/log/context/TrackHelper.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/context/TrackHelper.java rename to docus-starter-log/src/main/java/com/docus/log/context/TrackHelper.java diff --git a/starter-log/src/main/java/com/docus/log/processor/AbstractProcessor.java b/docus-starter-log/src/main/java/com/docus/log/processor/AbstractProcessor.java similarity index 84% rename from starter-log/src/main/java/com/docus/log/processor/AbstractProcessor.java rename to docus-starter-log/src/main/java/com/docus/log/processor/AbstractProcessor.java index 7644488..70ef448 100644 --- a/starter-log/src/main/java/com/docus/log/processor/AbstractProcessor.java +++ b/docus-starter-log/src/main/java/com/docus/log/processor/AbstractProcessor.java @@ -11,8 +11,8 @@ public abstract class AbstractProcessor implements ITrackProcessor { public boolean validate(TrackContext context) { return context != null - && context.getGroup() != null - && context.getProcessor() != null; + && context.getGroup() != null + && context.getProcessor() != null; } /** @@ -20,7 +20,7 @@ public abstract class AbstractProcessor implements ITrackProcessor { */ @Override public Object beforeProcess(TrackContext context) { - logger.debug("=== AOP 前置通知 ==="); + logger.info("=== AOP 前置通知 ==="); return null; } @@ -44,7 +44,7 @@ public abstract class AbstractProcessor implements ITrackProcessor { */ @Override public Object afterProcess(TrackContext context) { - logger.debug("=== AOP 最后通知 ==="); + logger.info("=== AOP 最后通知 ==="); return null; } diff --git a/starter-log/src/main/java/com/docus/log/processor/ITrackProcessor.java b/docus-starter-log/src/main/java/com/docus/log/processor/ITrackProcessor.java similarity index 100% rename from starter-log/src/main/java/com/docus/log/processor/ITrackProcessor.java rename to docus-starter-log/src/main/java/com/docus/log/processor/ITrackProcessor.java diff --git a/pom.xml b/pom.xml index 537c77f..cdd4282 100644 --- a/pom.xml +++ b/pom.xml @@ -200,7 +200,7 @@ com.docus - starter-log + docus-starter-log 1.0-SNAPSHOT