解档推送
parent
89a45ea24e
commit
552b705e76
@ -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<CqcPushConfig> {
|
||||
|
||||
/**
|
||||
* @description 根据业务类型查询推送配置
|
||||
*/
|
||||
List<CqcPushConfig> getCqcPushConfigByBusinessTypes(@Param("ids") List<Long> ids);
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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<Long> ids=new ArrayList<>();
|
||||
for(String str:split){
|
||||
long l = Long.parseLong(str);
|
||||
ids.add(l);
|
||||
}
|
||||
if(Func.isEmpty(ids)){
|
||||
log.info("推送配置id为空");
|
||||
return;
|
||||
}
|
||||
List<CqcPushConfig> 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<Map<String, Object>> parameterList = new ArrayList<>();
|
||||
|
||||
parameterList = JSON.parseObject(parameterListStr, new TypeReference<List<Map<String, Object>>>() {
|
||||
});
|
||||
|
||||
List<Object> 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<Map<String,Object>> 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<String,Object> paramMap:parameterList){
|
||||
call.addParameter((String) paramMap.get("parameterName"), XMLType.XSD_STRING, ParameterMode.IN);
|
||||
}
|
||||
List<Object> 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<Object> 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;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.docus.server.collection.mapper.CqcPushConfigMapper">
|
||||
|
||||
<select id="getCqcPushConfigByBusinessTypes" resultType="com.docus.server.collection.entity.CqcPushConfig">
|
||||
SELECT
|
||||
id,
|
||||
business_type,
|
||||
protocol_type,
|
||||
namespace,
|
||||
url,
|
||||
method,
|
||||
effective,
|
||||
title,
|
||||
create_user,
|
||||
create_time,
|
||||
update_user,
|
||||
update_time,
|
||||
parameter_list
|
||||
FROM
|
||||
cqc_push_config
|
||||
WHERE id in
|
||||
<foreach collection="ids" open="(" close=")" item="id" separator=",">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND effective=1
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue