From 552b705e76d939c3fdf1139e56c5834cdaf1e870 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=AE=99=E7=9A=AE=E7=9A=AE=E5=A8=83?= <2964346877@qq.com> Date: Fri, 22 Dec 2023 15:02:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E6=A1=A3=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 12 + .../server/collection/dto/BacklPushDto.java | 63 +++++ .../collection/entity/CqcPushConfig.java | 67 ++++++ .../mapper/CqcPushConfigMapper.java | 17 ++ .../service/impl/TBasicServiceImpl.java | 7 + .../collection/util/BackPushEventEntity.java | 28 +++ .../server/collection/util/BackPushUtil.java | 99 ++++++++ .../collection/util/CqcPushListenerUtil.java | 216 ++++++++++++++++++ src/main/resources/bootstrap.yml | 7 + .../resources/mapper/CqcPushConfigMapper.xml | 30 +++ 10 files changed, 546 insertions(+) create mode 100644 src/main/java/com/docus/server/collection/dto/BacklPushDto.java create mode 100644 src/main/java/com/docus/server/collection/entity/CqcPushConfig.java create mode 100644 src/main/java/com/docus/server/collection/mapper/CqcPushConfigMapper.java create mode 100644 src/main/java/com/docus/server/collection/util/BackPushEventEntity.java create mode 100644 src/main/java/com/docus/server/collection/util/BackPushUtil.java create mode 100644 src/main/java/com/docus/server/collection/util/CqcPushListenerUtil.java create mode 100644 src/main/resources/mapper/CqcPushConfigMapper.xml diff --git a/pom.xml b/pom.xml index fe7391c..0352241 100644 --- a/pom.xml +++ b/pom.xml @@ -129,6 +129,18 @@ docus-shiro-starter + + org.apache.axis + axis + 1.4 + + + + org.apache.axis + axis-jaxrpc + 1.4 + + com.docus docus-base-starter diff --git a/src/main/java/com/docus/server/collection/dto/BacklPushDto.java b/src/main/java/com/docus/server/collection/dto/BacklPushDto.java new file mode 100644 index 0000000..60ca45d --- /dev/null +++ b/src/main/java/com/docus/server/collection/dto/BacklPushDto.java @@ -0,0 +1,63 @@ +package com.docus.server.collection.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +/** + * @BelongsProject: docus_medicalrecord_starter + * @BelongsPackage: com.docus.services.clinicqualitycontrol.dto + * @Author: jiashi1 + * @CreateTime: 2023-02-14 14:56 + * @Description: TODO + * @Version: 1.0 + */ +@Data +@ApiModel("质控和退回推送dto") +public class BacklPushDto { + + @ApiModelProperty(value = "病案主键") + private String patientId; + + @ApiModelProperty(value = "住院号(病案号)") + private String inpatientNo; + + @ApiModelProperty(value = "住院次数") + private Integer admissTimes; + + @ApiModelProperty(value = "住院就诊流水号(记账号)") + private String jzh; + + @ApiModelProperty(value = "姓名") + private String name; + + @ApiModelProperty(value = "出院科室代码") + private String disDept; + + @ApiModelProperty(value = "出院科室") + private String disDeptName; + + @ApiModelProperty(value = "申请人工号") + private String applyUserName; + + @ApiModelProperty(value = "申请人") + private String applyName; + + @ApiModelProperty(value = "操作人工号") + private String controlUserName; + + @ApiModelProperty(value = "操作人") + private String controlName; + + @ApiModelProperty(value = "解档时间(召回审批时间开始)") + private String auditTime; + + @ApiModelProperty(value = "解档天数(召回天数(默认7天))") + private String day; + + @ApiModelProperty(value = "解档\\归档状态( 未归档状态\\归档状态) ") + private Integer isArchive; + + @ApiModelProperty(value = "解档\\归档文书类型( 召回修改分类对应的采集器id,逗号隔开的字符串)") + private String collectIds; +} diff --git a/src/main/java/com/docus/server/collection/entity/CqcPushConfig.java b/src/main/java/com/docus/server/collection/entity/CqcPushConfig.java new file mode 100644 index 0000000..e069d8f --- /dev/null +++ b/src/main/java/com/docus/server/collection/entity/CqcPushConfig.java @@ -0,0 +1,67 @@ +package com.docus.server.collection.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 jiashi + * @since 2023-02-14 + */ +@Data +@EqualsAndHashCode(callSuper = false) +@ApiModel(value="CqcPushConfig对象", description="推送配置表") +public class CqcPushConfig implements Serializable { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty(value = "ID") + @TableId(value = "id", type = IdType.ID_WORKER_STR) + private Long id; + + @ApiModelProperty(value = "业务类型(1退回医生,2退回护理,3退回手麻,4退回重症,5召回推送,6归档推送,7病案室纸质签收推送,8电子病例解档,9护理解档,10电子病历归档,11护理归档)") + private String businessType; + + @ApiModelProperty(value = "协议类型(1webservice,2http)") + private String protocolType; + + @ApiModelProperty(value = "命名空间") + private String namespace; + + @ApiModelProperty(value = "接口地址") + private String url; + + @ApiModelProperty(value = "方法名") + private String method; + + @ApiModelProperty(value = "是否启用(0否,1是)") + private Integer effective; + + @ApiModelProperty(value = "标题") + private String title; + + @ApiModelProperty(value = "创建人") + private String createUser; + + @ApiModelProperty(value = "创建时间") + private Date createTime; + + @ApiModelProperty(value = "修改人") + private String updateUser; + + @ApiModelProperty(value = "修改时间") + private Date updateTime; + + @ApiModelProperty(value = "参数json") + private String parameterList; +} diff --git a/src/main/java/com/docus/server/collection/mapper/CqcPushConfigMapper.java b/src/main/java/com/docus/server/collection/mapper/CqcPushConfigMapper.java new file mode 100644 index 0000000..8bd2640 --- /dev/null +++ b/src/main/java/com/docus/server/collection/mapper/CqcPushConfigMapper.java @@ -0,0 +1,17 @@ +package com.docus.server.collection.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.docus.server.collection.entity.CqcPushConfig; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +public interface CqcPushConfigMapper extends BaseMapper { + + /** + * @description 根据业务类型查询推送配置 + */ + List getCqcPushConfigByBusinessTypes(@Param("ids") List ids); + + +} diff --git a/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java b/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java index fe2b1cd..d5f17e6 100644 --- a/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java +++ b/src/main/java/com/docus/server/collection/service/impl/TBasicServiceImpl.java @@ -10,9 +10,12 @@ import com.docus.server.collection.entity.TBasic; import com.docus.server.collection.entity.TBasicExtend; import com.docus.server.collection.mapper.TBasicMapper; import com.docus.server.collection.service.ITBasicService; +import com.docus.server.collection.util.BackPushEventEntity; import com.docus.server.report.entity.MaternalInfantRelationship; import com.docus.server.rpc.SdRyHospitalRpc; import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.ApplicationEventPublisher; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -46,6 +49,9 @@ public class TBasicServiceImpl implements ITBasicService { @Resource private ThreadPoolExecutor threadPoolExecutor; + @Autowired + private ApplicationEventPublisher applicationEventPublisher; + @Override @Transactional public void setTBasic(TBasicDto tBasicDto) throws Exception { @@ -220,6 +226,7 @@ public class TBasicServiceImpl implements ITBasicService { } //是否取消住院 if ("2".equals(tBasicDto.getStatu())) { + applicationEventPublisher.publishEvent(new BackPushEventEntity(this, tBasic)); tBasic.setDisDate(null); } String sdryIndex = tBasicDto.getSdryIndex(); diff --git a/src/main/java/com/docus/server/collection/util/BackPushEventEntity.java b/src/main/java/com/docus/server/collection/util/BackPushEventEntity.java new file mode 100644 index 0000000..6898d07 --- /dev/null +++ b/src/main/java/com/docus/server/collection/util/BackPushEventEntity.java @@ -0,0 +1,28 @@ +package com.docus.server.collection.util; + +import com.docus.server.collection.entity.TBasic; +import org.springframework.context.ApplicationEvent; + +/** + * @description 退回推送event + * @author chierhao + * @date 2023-02-14 15:12 + */ +public class BackPushEventEntity extends ApplicationEvent{ + private static final long serialVersionUID = 1L; + + private TBasic tBasic ; + + public BackPushEventEntity(Object source, TBasic tBasic ) { + super(source); + this.tBasic = tBasic; + } + + public TBasic getTBasic() { + return tBasic; + } + + public void setTBasic( TBasic tBasic ) { + this.tBasic = tBasic; + } +} diff --git a/src/main/java/com/docus/server/collection/util/BackPushUtil.java b/src/main/java/com/docus/server/collection/util/BackPushUtil.java new file mode 100644 index 0000000..0663166 --- /dev/null +++ b/src/main/java/com/docus/server/collection/util/BackPushUtil.java @@ -0,0 +1,99 @@ +package com.docus.server.collection.util; + + +import com.docus.core.util.DateUtil; +import com.docus.server.collection.dto.BacklPushDto; + +import java.util.Date; +import java.util.UUID; + +/** + * @BelongsProject: docus_medicalrecord_starter + * @BelongsPackage: com.docus.services.statistical.util + * @Author: jiashi + * @CreateTime: 2022-12-27 15:33 + * @Description: TODO + * @Version: 1.0 + */ +public class BackPushUtil { + + + /** + * @description 将推送对象转为xml字符串 + * @author jiashi + * @date 2023-07-12 14:14 + * @param dto + * @return: java.lang.String + */ + public static String getXml(BacklPushDto dto) { + String result= + "\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\n" + + "\t\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\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\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" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\t\n" + + "\t\n" + + ""; + return result; + } +} diff --git a/src/main/java/com/docus/server/collection/util/CqcPushListenerUtil.java b/src/main/java/com/docus/server/collection/util/CqcPushListenerUtil.java new file mode 100644 index 0000000..8f45c87 --- /dev/null +++ b/src/main/java/com/docus/server/collection/util/CqcPushListenerUtil.java @@ -0,0 +1,216 @@ +package com.docus.server.collection.util; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.TypeReference; +import com.docus.core.util.DateUtil; +import com.docus.core.util.Func; +import com.docus.infrastructure.core.exception.BaseException; +import com.docus.server.collection.dto.BacklPushDto; +import com.docus.server.collection.entity.CqcPushConfig; +import com.docus.server.collection.entity.TBasic; +import com.docus.server.collection.mapper.CqcPushConfigMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.axis.encoding.XMLType; +import org.apache.cxf.endpoint.Client; +import org.apache.cxf.jaxws.endpoint.dynamic.JaxWsDynamicClientFactory; +import org.apache.shiro.util.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.event.EventListener; +import org.springframework.scheduling.annotation.Async; +import org.springframework.stereotype.Component; + +import javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; +import java.util.*; +import java.util.stream.Collectors; +import org.apache.axis.client.Call; +import org.apache.axis.client.Service; + + + +/** + * @author chierhao + * @description 退回消息推送监听 + * @date 2023-02-14 14:38 + */ +@Component +@Slf4j +@Async +public class CqcPushListenerUtil { + + @Autowired + private CqcPushConfigMapper cqcPushConfigMapper; + + @Value("${docus.basic.pushconfig:}") + private String pushConfigId; + + @Value("${docus.basic.pushusername:}") + private String userName; + + @Value("${docus.basic.pushname:}") + private String name; + + @Value("${docus.basic.day:}") + private String day; + + /* + * @description 质控退回推送 + * @author jiashi + * @date 2023-07-13 15:20 + * @param event + */ + @Async + @EventListener + public void backPushListener(BackPushEventEntity event) { + TBasic tBasic= event.getTBasic(); + String[] split = pushConfigId.split(","); + List ids=new ArrayList<>(); + for(String str:split){ + long l = Long.parseLong(str); + ids.add(l); + } + if(Func.isEmpty(ids)){ + log.info("推送配置id为空"); + return; + } + List configs = cqcPushConfigMapper.getCqcPushConfigByBusinessTypes(ids); + if(Func.isEmpty(configs)){ + log.info("推送配置查询为空"); + return; + } + for(CqcPushConfig config:configs){ + //顺德人医解档推送 + liberationMethod(tBasic,config); + } + } + + + /** + * @description 顺德人医解档webservice推送 + * @author jiashi + * @date 2023-07-12 10:51 + * @param cqcPushConfig + */ + public void liberationMethod(TBasic tBasic, CqcPushConfig cqcPushConfig) { + //解档推送消息 + if (Func.isNotEmpty(tBasic)) { + String archiveType = ""; + if (cqcPushConfig.getBusinessType().equals("8")) { + archiveType = "0"; + } + if (cqcPushConfig.getBusinessType().equals("9")) { + archiveType = "1"; + } + if (cqcPushConfig.getBusinessType().equals("12")) { + archiveType = "2"; + } + //组装参数 + BacklPushDto dto = new BacklPushDto(); + dto.setPatientId(tBasic.getPatientId()); + dto.setInpatientNo(tBasic.getInpatientNo()); + dto.setAdmissTimes(tBasic.getAdmissTimes()); + dto.setJzh(tBasic.getInpatientNo() + "_" + tBasic.getAdmissTimes()); + dto.setName(tBasic.getName()); + dto.setDisDept(tBasic.getDisDept()); + dto.setDisDeptName(tBasic.getDisDeptName()); + dto.setApplyUserName(userName); + dto.setApplyName(name); + dto.setControlUserName(userName); + dto.setControlName(name); + dto.setAuditTime(DateUtil.format(new Date(), DateUtil.PATTERN_DATETIME)); + dto.setDay(day); + dto.setIsArchive(0); + dto.setCollectIds(archiveType); + + String wsParam = BackPushUtil.getXml(dto); + //发送消息 + //请求地址 + String wsUrl = cqcPushConfig.getUrl(); + //命名空间 + String namespance = cqcPushConfig.getNamespace(); + // 推送方法名 + String wsMethod = cqcPushConfig.getMethod(); + //参数 + String parameterListStr = cqcPushConfig.getParameterList(); + parameterListStr = String.format(parameterListStr, JSON.toJSONString(wsParam)); + + List> parameterList = new ArrayList<>(); + + parameterList = JSON.parseObject(parameterListStr, new TypeReference>>() { + }); + + List parameters = parameterList.stream().map(e -> e.get("parameter")).collect(Collectors.toList()); + log.info("推送入参: parameterList:{}", JSON.toJSONString(parameterList)); + + + //回调值 + String result = ""; + for (int i = 0; i < 3; i++) { + try { + Thread.sleep(i * 5 * 100); + } catch (InterruptedException e) { + log.error(e.getMessage(), e); + } + if (wsUrl.contains("?wsdl")) { + result = requestFunctionWebServiceCXF(wsUrl, namespance, wsMethod, parameters); + } else { + result = requestFunctionWebService(wsUrl, namespance, wsMethod, parameterList); + } + log.info("得到的结果:" + result); + if (result.contains("成功") || result.contains("success")) { + break; + } + } + } else { + throw new BaseException("病案基础信息为空,推送消息失败"); + } + } + + /** + * @param url wsdl文件地址 + * @param namespace 命名空间 + * @param method 方法名 + */ + public String requestFunctionWebService(String url, String namespace, String method, List> parameterList) { + String result = null; + try { + Service service = new Service(); + Call call = (Call) service.createCall(); + call.setTargetEndpointAddress(url); + call.setOperationName(new QName(namespace, method)); + for (Map paramMap:parameterList){ + call.addParameter((String) paramMap.get("parameterName"), XMLType.XSD_STRING, ParameterMode.IN); + } + List parameter = parameterList.stream().map(e -> e.get("parameter")).collect(Collectors.toList()); + Object[] opAddEntryArgs = parameter.toArray(); + call.setReturnType(XMLType.XSD_STRING);//设置返回类型 + result = (String) call.invoke(opAddEntryArgs); + } catch (Exception e) { + log.error(e.getMessage(),e); + result = e.getMessage(); + } + return result; + } + public String requestFunctionWebServiceCXF(String url, String namespace, String method, List params) { + String result; + try { + //创建动态客户端工厂 创建客户端 + JaxWsDynamicClientFactory dcf = JaxWsDynamicClientFactory.newInstance(); + Client client = dcf.createClient(url); + //命名空间和方法 + QName name = new QName(namespace, method); + //调用,省中医ChasMessageServer方法特殊处理 + Object[] opAddEntryArgs; + opAddEntryArgs = params.toArray(); + Object[] objects = client.invoke(name, opAddEntryArgs); + result = objects[0].toString(); + } catch (Exception e) { + log.error(e.getMessage(),e); + result = e.getMessage(); + } + return result; + } + + +} diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index 38be6f4..a021cfb 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -112,6 +112,13 @@ docus: nisApproveUrl: http://192.168.16.85:9102/qc/tBasicCqc/cqcAudit?hp=token1 # 确认重症状态并更新 confirmAndUpdIcuRecordStateUrl: http://127.0.0.1:9314/hospital/sdRy/confirmAndupdIcuRecordState + # 电子病例,护理,重症护理解档配置id + pushconfig: 8,9,12 + #推送操作人工号,姓名 + pushusername: 05908 + pushname: 可信病案归档 + #解档天数 + day: 90 mybatis-plus: configuration: map-underscore-to-camel-case: true diff --git a/src/main/resources/mapper/CqcPushConfigMapper.xml b/src/main/resources/mapper/CqcPushConfigMapper.xml new file mode 100644 index 0000000..819cfd3 --- /dev/null +++ b/src/main/resources/mapper/CqcPushConfigMapper.xml @@ -0,0 +1,30 @@ + + + + + +