Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/FindPatientInfoByHospitalNumDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/FindPatientInfoByHospitalNumDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/FindPatientInfoByHospitalNumDaoImpl.java (revision 41546) @@ -0,0 +1,303 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.gd2zyy; + +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.Date; +import java.util.List; + +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Node; +import org.dom4j.XPath; + +import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByHospitalNumDao; +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; + +/** + * 广东省第二中医院住院病人信息查询接口 + */ +public class FindPatientInfoByHospitalNumDaoImpl implements FindPatientInfoByHospitalNumDao { + + Logger logger = Logger.getLogger(FindPatientInfoByHospitalNumDaoImpl.class); + + /** + * 根据住院号查询病人信息 + */ + @Override + public PatientInfoVO[] findPatientInfoByHospitalNum(String hospitalNum) { + List patientInfoVOList = new ArrayList(); + try { + patientInfoVOList = findPatientInfoByHospitalNumPage(hospitalNum); + } catch (Exception e) { + logger.debug("住院号接口查询异常:" + e.getMessage()); + e.printStackTrace(); + } + if(CollectionUtils.isEmpty(patientInfoVOList)){ + return null; + } + PatientInfoVO[] patientInfoVOArray = new PatientInfoVO[patientInfoVOList.size()]; + patientInfoVOList.toArray(patientInfoVOArray); + return patientInfoVOArray; + } + + /** + * 分页循环查询住院号病人信息,最多查询1000次 + * @param hospitalNum + * @return + * @throws Exception + */ + private List findPatientInfoByHospitalNumPage(String hospitalNum) throws Exception { + + List patientInfoVOList = new ArrayList(); + for(int pageIndex =1; pageIndex <= DatasyncConstant.MAX_PAGE_NUM; pageIndex++){ + List patientInfoVOPageList = new ArrayList(); + String inputXml = WebServiceClientHelper.buildInputXml(DatasyncConstant.MethodName_HospitalNumber, pageIndex, hospitalNum); + //测试数据,建议代码保留往后可以本地调试 + //String xmlResult = " AA成功12440000455861931E164101362214刘明伟210101198508010101521985-08-0120000198100111029905外二肛肠护理单元2025-11-12 16:27:552025-11-12 16:27:55zy0728蒋亚平489梁小丹1020406002肛肠科病区2在科0新入077S自费A71.900沙眼440000000000152554455451就诊卡30000231133住院2021-01-25-00:00:0052511111105860440104001000广东省广州市越秀区洪桥街道@440104001000广东省广州市越秀区洪桥街道@刘明伟0123456123451701]]>"; + String xmlResult = WebServiceClientHelper.doPostSoap1_2(DatasyncConstant.WebServiceAddress, inputXml); + logger.debug("住院病人接口查询页码:" + pageIndex + ",每页最大行数:" + DatasyncConstant.PageSize); + logger.debug("住院病人接口请求信息:" + inputXml); + logger.debug("住院病人接口返回信息:" + xmlResult); + if(StringUtils.isBlank(xmlResult)){ + logger.debug("根据住院号查询病人信息失败,接口返回信息为空!"); + break; + } + + int startIndex = xmlResult.indexOf(""); + int endIndex = xmlResult.indexOf(""); + + if(startIndex == -1 || endIndex == -1 || endIndex < startIndex){ + logger.debug("根据住院号查询病人信息失败,接口返回信息没有节点!"); + break; + } + + xmlResult = xmlResult.substring(startIndex, endIndex + "".length()); + + Document document = DocumentHelper.parseText(xmlResult); + + if(document == null){ + break; + } + + if(document != null){ + //响应码 + String processResultCodeXpath = "/root/processResultCode"; + String processResultCode = WebServiceClientHelper.processDataByXpath(document, processResultCodeXpath); + //响应信息 + String processResultXpath = "/root/processResult"; + String processResult = WebServiceClientHelper.processDataByXpath(document, processResultXpath); + if(StringUtils.equals(DatasyncConstant.FAIL_CODE, processResultCode)){ + if(StringUtils.isBlank(processResult)){ + processResult = "processResultCode = AE"; + } + logger.debug("根据住院号查询病人信息失败,接口返回信息:" + processResult); + break; + } + + String itemXpath = "/root/returnContents/returnContent"; + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isEmpty(nodeList)){ + break; + } + for(int i=1; i <= nodeList.size(); i++){ + + String returnContentXpath = itemXpath + "[" + i + "]"; + + //住院号 + String eventNoXpath = returnContentXpath + "/visitNo"; + //姓名 + String patientNameXpath = returnContentXpath + "/patientName"; + //年龄 + String patientAgeXpath = returnContentXpath + "/patientAge"; + //性别名称 + String sexNameXpath = returnContentXpath + "/patientSexName"; + + //身份证号码 + String identityNoXpath = returnContentXpath + "/identityNo"; + //床号 + String bedNoXpath = returnContentXpath + "/bedNo"; + //病区名称 + String patientAreaXpath = returnContentXpath + "/wardRoomName"; + + hospitalNum = WebServiceClientHelper.processDataByXpath(document, eventNoXpath); + String patientName = WebServiceClientHelper.processDataByXpath(document, patientNameXpath); + String patientAge = WebServiceClientHelper.processDataByXpath(document, patientAgeXpath); + String patientSex = WebServiceClientHelper.processDataByXpath(document, sexNameXpath); + + String patientIDCard = WebServiceClientHelper.processDataByXpath(document, identityNoXpath); + String bedNumber = WebServiceClientHelper.processDataByXpath(document, bedNoXpath); + String patientArea = WebServiceClientHelper.processDataByXpath(document, patientAreaXpath); + + //查询住院号关联的手术信息 + List patientOperationInfoList = findPatientOperationInfoByHospitalNumPage(hospitalNum); + if(CollectionUtils.isEmpty(patientOperationInfoList)){ + PatientInfoVO patientInfoVO = new PatientInfoVO(); + patientInfoVO.setHospitalNumber(hospitalNum); + patientInfoVO.setPatientName(patientName); + patientInfoVO.setPatientAge(patientAge); + patientInfoVO.setPatientSex(patientSex); + + patientInfoVO.setPatientIDCard(patientIDCard); + patientInfoVO.setBedNumber(bedNumber); + patientInfoVO.setPatientArea(patientArea); + patientInfoVOPageList.add(patientInfoVO); + }else{ + for (PatientInfoVO patientInfoVO : patientOperationInfoList) { + patientInfoVO.setHospitalNumber(hospitalNum); + patientInfoVO.setPatientName(patientName); + patientInfoVO.setPatientAge(patientAge); + patientInfoVO.setPatientSex(patientSex); + + patientInfoVO.setPatientIDCard(patientIDCard); + patientInfoVO.setBedNumber(bedNumber); + patientInfoVO.setPatientArea(patientArea); + patientInfoVOPageList.add(patientInfoVO); + } + } + } + logger.debug("住院病人接口返回记录行数:" + patientInfoVOPageList.size()); + if(CollectionUtils.isEmpty(patientInfoVOPageList)){ + break; + } + patientInfoVOList.addAll(patientInfoVOPageList); + if(patientInfoVOPageList.size() < DatasyncConstant.PageSize){ + break; + } + } + } + + if(CollectionUtils.isNotEmpty(patientInfoVOList)){ + patientInfoVOList.sort(new Comparator() { + @Override + public int compare(PatientInfoVO o1, PatientInfoVO o2) { + if (StringUtils.isBlank(o1.getOperationTime()) && StringUtils.isBlank(o2.getOperationTime())) { + return 0; + } + if (StringUtils.isBlank(o1.getOperationTime()) && StringUtils.isNotBlank(o2.getOperationTime())) { + return -1; + } + if (StringUtils.isBlank(o2.getOperationTime()) && StringUtils.isNotBlank(o1.getOperationTime())) { + return 1; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date date1 = sdf.parse(o1.getOperationTime()); + Date date2 = sdf.parse(o2.getOperationTime()); + return date2.compareTo(date1); + } catch (ParseException e) { + logger.debug("病人信息排序出错(手术时间【OPERATIONTIME】字段格式错误)!"); + e.printStackTrace(); + } + return 0; + } + }); + } + + return patientInfoVOList; + } + + /** + * 分页查询住院信息的手术信息 + * @param hospitalNum 住院号 + * @return + * @throws Exception + */ + private List findPatientOperationInfoByHospitalNumPage(String hospitalNum) throws Exception { + + List patientInfoVOList = new ArrayList(); + for(int pageIndex =1; pageIndex <= DatasyncConstant.MAX_PAGE_NUM; pageIndex++){ + List patientInfoVOPageList = new ArrayList(); + String inputXml = WebServiceClientHelper.buildInputXml(DatasyncConstant.MethodName_PatientOperation, pageIndex, hospitalNum); + //测试数据,建议代码保留往后可以本地调试 + //String xmlResult = " AA成功2023-02-14 18:33:0093137颈椎骨折切开复位内固定术李世豪]]>"; + String xmlResult = WebServiceClientHelper.doPostSoap1_2(DatasyncConstant.WebServiceAddress, inputXml); + logger.debug("获取病人手术信息接口查询页码:" + pageIndex + ",每页最大行数:" + DatasyncConstant.PageSize); + logger.debug("获取病人手术信息接口请求信息:" + inputXml); + logger.debug("获取病人手术信息接口返回信息:" + xmlResult); + if(StringUtils.isBlank(xmlResult)){ + logger.debug("根据住院号查询病人手术信息失败,接口返回信息为空!"); + break; + } + + int startIndex = xmlResult.indexOf(""); + int endIndex = xmlResult.indexOf(""); + + if(startIndex == -1 || endIndex == -1 || endIndex < startIndex){ + logger.debug("根据住院号查询病人手术信息失败,接口返回信息没有节点!"); + break; + } + + xmlResult = xmlResult.substring(startIndex, endIndex + "".length()); + + Document document = DocumentHelper.parseText(xmlResult); + + if(document == null){ + break; + } + + if(document != null){ + //响应码 + String processResultCodeXpath = "/root/processResultCode"; + String processResultCode = WebServiceClientHelper.processDataByXpath(document, processResultCodeXpath); + //响应信息 + String processResultXpath = "/root/processResult"; + String processResult = WebServiceClientHelper.processDataByXpath(document, processResultXpath); + if(StringUtils.equals(DatasyncConstant.FAIL_CODE, processResultCode)){ + if(StringUtils.isBlank(processResult)){ + processResult = "processResultCode = AE"; + } + logger.debug("根据住院号查询病人手术信息失败,接口返回信息:" + processResult); + break; + } + + String itemXpath = "/root/returnContents/returnContent"; + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isEmpty(nodeList)){ + break; + } + for(int i=1; i <= nodeList.size(); i++){ + String returnContentXpath = itemXpath + "[" + i + "]"; + String operationXpath = returnContentXpath + "/operationName"; + String doctorNameXpath = returnContentXpath + "/operationOperatorName"; + String operationTimeXpath = returnContentXpath + "/operationTime"; + + String operation = WebServiceClientHelper.processDataByXpath(document, operationXpath); + String doctorName = WebServiceClientHelper.processDataByXpath(document, doctorNameXpath); + String operationTime = WebServiceClientHelper.processDataByXpath(document, operationTimeXpath); + + PatientInfoVO patientInfoVO = new PatientInfoVO(); + patientInfoVO.setOperation(operation); + patientInfoVO.setDoctorName(doctorName); + patientInfoVO.setOperationTime(operationTime); + + patientInfoVOPageList.add(patientInfoVO); + } + logger.debug("病人手术信息接口返回记录行数:" + patientInfoVOPageList.size()); + if(CollectionUtils.isEmpty(patientInfoVOPageList)){ + break; + } + patientInfoVOList.addAll(patientInfoVOPageList); + if(patientInfoVOPageList.size() < DatasyncConstant.PageSize){ + break; + } + } + } + + return patientInfoVOList; + } + + @Override + public PatientInfoVO[] findPatientInfoByHospitalNumBeforeOperation(String hospitalNum) { + return findPatientInfoByHospitalNum(hospitalNum); + } + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/DatasyncConstant.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/DatasyncConstant.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/DatasyncConstant.java (revision 41546) @@ -0,0 +1,72 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.gd2zyy; + +/** + * 广东省第二中医院接口相关常量 + */ +public class DatasyncConstant { + /** + * 平台查询测试业务入口 + */ + public final static String WebServiceAddress = "http://192.168.3.111:8693/Select-Service"; + + /** + * 授权码 + */ + public final static String AccessKey = "xgHLez5LWCN7m4r6oEm6ss9Hm/6hmF1SELsb+erIB/nn83CvNdAyZQ=="; + + /** + * 接口方法名:住院病人(作为输入参数) + */ + public final static String MethodName_HospitalNumber = "getResiVisitInfo"; + + /** + * 接口方法名:获取病人手术信息(作为输入参数) + */ + public final static String MethodName_PatientOperation = "getPatientOperation"; + + /** + * 接口方法名:获取科室字典(作为输入参数) + */ + public final static String MethodName_OrgUnit = "getDeptDict"; + + /** + * 接口方法名:获取员工字典(作为输入参数) + */ + public final static String MethodName_User = "getStaffDict"; + + /** + * 科室人员同步的入参:机构代码,必填 + */ + public final static String orgCode = ""; + + /** + * 院区代码 + */ + public final static String districtCode = ""; + + /** + * 每页行数(不超过1000)必填 + */ + public final static Integer PageSize = 1000; + + /** + * 最多查询的页数,防止代码死循环,每页最多1000条记录,总共1000*1000条记录 + */ + public final static Integer MAX_PAGE_NUM = 1000; + + /** + * 页码 + */ + public final static Integer PageIndex = 1; + + /** + * 处理结果代码(AA成功AE失败) + */ + public final static String SUCC_CODE = "AA"; + + /** + * 处理结果代码(AA成功AE失败) + */ + public final static String FAIL_CODE = "AE"; + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/SyncOrgUnitAndUserDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/SyncOrgUnitAndUserDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/SyncOrgUnitAndUserDaoImpl.java (revision 41546) @@ -0,0 +1,295 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.gd2zyy; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.collections.MapUtils; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.dom4j.DocumentHelper; +import org.dom4j.Node; +import org.dom4j.XPath; + +import net.sf.json.JSONObject; + +import com.forgon.disinfectsystem.datasynchronization.dao.SyncOrgUnitAndUserDao; +import com.forgon.disinfectsystem.datasynchronization.model.OrgUnitVo; +import com.forgon.disinfectsystem.datasynchronization.model.UserVo; +import com.forgon.tools.string.StringTools; + +/** + * 广东省第二中医院人员及科室信息同步接口 + */ +public class SyncOrgUnitAndUserDaoImpl implements SyncOrgUnitAndUserDao { + + Logger logger = Logger.getLogger(SyncOrgUnitAndUserDaoImpl.class); + + @Override + public UserVo[] getAllUser() { + UserVo[] userVoArray = null; + try { + List userVoList = getAllUserByPage(); + if(CollectionUtils.isNotEmpty(userVoList)){ + userVoArray = new UserVo[userVoList.size()]; + userVoList.toArray(userVoArray); + } + } catch (Exception e) { + e.printStackTrace(); + logger.debug("人员同步接口查询异常:" + e.getMessage()); + } + return userVoArray; + } + + /** + * 分页查询用户信息 + * @return + */ + private List getAllUserByPage(){ + List allUserVoList = new ArrayList(); + for(int pageIndex = 1; pageIndex <= DatasyncConstant.MAX_PAGE_NUM; pageIndex++){ + List userVoList = new ArrayList(); + try{ + logger.debug(String.format("分页查询用户信息,页码=%s,每页行数=%s", pageIndex, DatasyncConstant.PageSize)); + String inputXml = WebServiceClientHelper.buildInputXml(DatasyncConstant.MethodName_User, pageIndex, ""); + logger.debug("用户信息接口请求信息:" + inputXml); + String xmlResult = WebServiceClientHelper.doPostSoap1_2(DatasyncConstant.WebServiceAddress, inputXml); + /*String xmlResult = "" + + "" + + "" + + "Z1032" + + "诸莉敏1" + + "21409" + + "外二科护理单元" + + "" + + "" + + "Z1037" + + "吴嘉琪1" + + "24109" + + "重症医学科护理单元" + + "" + + "" + + "]]>";*/ + logger.debug("用户信息接口返回信息:" + xmlResult); + + if(StringUtils.isBlank(xmlResult)){ + logger.debug("用户信息接口同步失败,接口返回为空!"); + break; + } + + int startIndex = xmlResult.indexOf(""); + int endIndex = xmlResult.indexOf(""); + + if(startIndex == -1 || endIndex == -1 || endIndex < startIndex){ + logger.debug("同步用户信息失败,接口返回信息没有节点!"); + break; + } + + xmlResult = xmlResult.substring(startIndex, endIndex + "".length()); + Document document = DocumentHelper.parseText(xmlResult); + String itemXpath = "/returnContents/returnContent"; + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isNotEmpty(nodeList)){ + Map> userCodingOrgUnitCodingMap = new HashMap>(); + for(int i=1;i<=nodeList.size();i++){ + String msgXpath = "/returnContents/returnContent[" + i + "]"; + // 用户编码 + String codingXpath = msgXpath + "/staffCode"; + // 用户名称 + String nameXpath = msgXpath + "/staffName"; + // 用户所属科室编码 + String orgUnitCodingXpath = msgXpath + "/adminDeptCode"; + + String coding = WebServiceClientHelper.processDataByXpath(document, codingXpath); + String name = WebServiceClientHelper.processDataByXpath(document, nameXpath); + String orgUnitCoding = WebServiceClientHelper.processDataByXpath(document, orgUnitCodingXpath); + UserVo userVo = new UserVo(); + userVo.setCoding(coding); + userVo.setName(name); + userVo.setOrgUnitCoding(orgUnitCoding); + //如果人员工号或名称为空,则忽略该条数据 + if(StringUtils.isBlank(userVo.getName()) || StringUtils.isBlank(userVo.getCoding())){ + continue; + } + if(StringUtils.isNotBlank(orgUnitCoding)){ + Set orgUnitCodingSet = userCodingOrgUnitCodingMap.get(userVo.getCoding()); + if(orgUnitCodingSet == null){ + orgUnitCodingSet = new LinkedHashSet(); + } + orgUnitCodingSet.add(orgUnitCoding); + userCodingOrgUnitCodingMap.put(userVo.getCoding(), orgUnitCodingSet); + } + userVoList.add(userVo); + } + if(MapUtils.isNotEmpty(userCodingOrgUnitCodingMap) && CollectionUtils.isNotEmpty(userVoList)){ + for (UserVo userVo : userVoList) { + Set orgUnitCodingSet = userCodingOrgUnitCodingMap.get(userVo.getCoding()); + if(CollectionUtils.isEmpty(orgUnitCodingSet)){ + continue; + } + userVo.setOrgUnitCoding(StringTools.join(orgUnitCodingSet, ";")); + } + } + } + }catch(Exception e){ + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(baos)); + String exception = baos.toString(); + logger.error("同步人员信息失败:" + exception); + e.printStackTrace(); + } + if(CollectionUtils.isEmpty(userVoList)){ + break; + } + allUserVoList.addAll(userVoList); + } + + return allUserVoList; + } + + @Override + public OrgUnitVo[] getAllOrgUnit() { + OrgUnitVo[] orgUnitVoArray = null; + try { + List orgUnitVoList = getAllOrgUnitByPage(); + if(CollectionUtils.isNotEmpty(orgUnitVoList)){ + orgUnitVoArray = new OrgUnitVo[orgUnitVoList.size()]; + orgUnitVoList.toArray(orgUnitVoArray); + } + } catch (Exception e) { + e.printStackTrace(); + logger.debug("科室同步接口查询异常:" + e.getMessage()); + } + return orgUnitVoArray; + } + + /** + * 分页查询科室 + * @return + */ + private List getAllOrgUnitByPage() { + List allOrgUnitVoList = new ArrayList(); + for(int pageIndex = 1; pageIndex <= DatasyncConstant.MAX_PAGE_NUM; pageIndex++){ + List orgUnitVoList = new ArrayList(); + try { + String inputXml = WebServiceClientHelper.buildInputXml(DatasyncConstant.MethodName_OrgUnit, pageIndex, ""); + logger.debug("科室信息接口请求信息:" + inputXml); + String xmlResult = WebServiceClientHelper.doPostSoap1_2(DatasyncConstant.WebServiceAddress, inputXml); + /*String xmlResult = "" + + "" + + "AA" + + "查询返回" + + "" + + "" + + "45726533-2" + + "01" + + "21409" + + "外二科护理单元2" + + "" + + "" + + "" + + "" + + "45726533-2" + + "01" + + "24109" + + "重症医学科护理单元2" + + "" + + "" + + "" + + "" + + "]]>";*/ + logger.debug("科室信息接口返回信息:" + xmlResult); + if(StringUtils.isBlank(xmlResult)){ + logger.debug("科室信息接口返回信息为空!"); + break; + } + + int startIndex = xmlResult.indexOf(""); + if(startIndex == -1){ + logger.debug("科室信息接口返回信息没有标签!"); + break; + } + int endIndex = xmlResult.indexOf(""); + if(endIndex == -1 || endIndex < startIndex){ + logger.debug("科室信息接口返回信息没有标签"); + break; + } + String xmlString = xmlResult.substring(startIndex, endIndex + "".length()); + if(StringUtils.isBlank(xmlString)){ + logger.debug("科室信息接口返回信息为空!" + xmlString); + break; + } + + Document document = DocumentHelper.parseText(xmlString); + String itemXpath = "/returnContents/returnContent"; // 返回结果可能存在多条住院病人信息 + XPath xpath = document.createXPath(itemXpath); + @SuppressWarnings("unchecked") + List nodeList = xpath.selectNodes(document, xpath); + if(CollectionUtils.isNotEmpty(nodeList)){ + for(int i=1;i<=nodeList.size();i++){ + String msgXpath = "/returnContents/returnContent[" + i + "]"; + // 科室编码 + String codingXpath = msgXpath + "/deptCode"; + // 科室名称 + String nameXpath = msgXpath + "/deptName"; + // 上级科室代码 + String parentCodingXpath = msgXpath + "/upperDeptCode"; + + String coding = WebServiceClientHelper.processDataByXpath(document, codingXpath); + String name = WebServiceClientHelper.processDataByXpath(document, nameXpath); + String parentCoding = WebServiceClientHelper.processDataByXpath(document, parentCodingXpath); + OrgUnitVo orgVo = new OrgUnitVo(); + orgVo.setCoding(coding); + orgVo.setName(name); + orgVo.setParentCoding(parentCoding); + + //科室编码与上级科室编码相同时,默认其上级科室编码为空 + if(StringUtils.equals(orgVo.getCoding(), orgVo.getParentCoding())){ + orgVo.setParentCoding(null); + } + //如果科室编码或名称为空,则忽略该条数据 + if(StringUtils.isBlank(orgVo.getCoding()) || StringUtils.isBlank(orgVo.getName())){ + continue; + } + orgUnitVoList.add(orgVo); + } + } + } catch (Exception e) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(baos)); + String exception = baos.toString(); + logger.error("获取科室信息失败," + exception); + } + if(CollectionUtils.isEmpty(orgUnitVoList)){ + break; + } + allOrgUnitVoList.addAll(orgUnitVoList); + } + return allOrgUnitVoList; + } + + @Override + public OrgUnitVo[] paramToOrgUnitVos(String param) { + return null; + } + + @Override + public UserVo[] paramToUserVos(String param) { + return null; + } + + @Override + public JSONObject buttjoinResponse(Boolean success, String message, String param) { + return null; + } + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/WebServiceClientHelper.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/WebServiceClientHelper.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/gd2zyy/WebServiceClientHelper.java (revision 41546) @@ -0,0 +1,168 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.gd2zyy; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.nio.charset.Charset; + +import org.apache.commons.lang.StringUtils; +import org.apache.http.HttpEntity; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.CloseableHttpResponse; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.StringEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.apache.log4j.Logger; +import org.dom4j.Document; +import org.dom4j.Node; +import org.dom4j.XPath; + +/** + * 广东省第二中医院接口帮助类 + */ +public class WebServiceClientHelper { + + public static Logger logger = Logger.getLogger(WebServiceClientHelper.class); + + /** + * 构造接口输入参数 + * @param methodName + * @param arg + * @return + */ + public static String buildInputXml(String methodName, int pageIndex, String... args){ + String param = ""; + if(pageIndex <= 0){ + pageIndex = DatasyncConstant.PageIndex; + } + if (DatasyncConstant.MethodName_HospitalNumber.equals(methodName)) { + // 根据住院号查询病人信息 + param = "" + + "" + DatasyncConstant.orgCode + "" + + "" + DatasyncConstant.districtCode + "" + + "" + + "" + + "" + + "" + + "" + args[0] + "" + + "" + DatasyncConstant.PageSize + "" + + "" + pageIndex + "" + + "]]>"; + } else if (DatasyncConstant.MethodName_PatientOperation.equals(methodName)) { + // 根据住院号查询病人手术信息 + param = "" + + "" + DatasyncConstant.orgCode + "" + + "" + DatasyncConstant.districtCode + "" + + "" + args[0] + "" + + "" + DatasyncConstant.PageSize + "" + + "" + pageIndex + "" + + "]]>"; + } else if(DatasyncConstant.MethodName_OrgUnit.equals(methodName)){ + // 查询所有科室 + // 科室代码、科室名称为空返回所有 + param = "" + + "" + DatasyncConstant.orgCode + "" + + "" + DatasyncConstant.districtCode + "" + + "" + + "" + + "" + + "" + DatasyncConstant.PageSize + "" + + "" + pageIndex + "" + + "]]>"; + } else if(DatasyncConstant.MethodName_User.equals(methodName)){ + // 查询所有人员 + // 科室代码、员工姓名、员工代码、工作类别编码为空显示所有 + param = "" + + "" + DatasyncConstant.orgCode + "" + + "" + DatasyncConstant.districtCode + "" + + "" + + "" + + "" + + "" + + "" + + "" + DatasyncConstant.PageSize + "" + + "" + pageIndex + "" + + "]]>"; + } else { + throw new RuntimeException("不存在此methodName:" + methodName); + } + String inputXml = "" + + "" + + "" + + "" + + "" + + "" + methodName + "XML" + DatasyncConstant.AccessKey + "]]>" + + "" + + "" + + param + + "" + + "" + +"" + +""; + return inputXml; + } + + /** + * 根据document和Xpath表达式解析数据 + * @param document + * @param nameSpaceURIMap + * @param xpathExp + * @return + */ + public static String processDataByXpath(Document document, String xpathExp) { + if ((StringUtils.isNotBlank(xpathExp)) && (document != null)) { + XPath xpath = document.createXPath(xpathExp); + Node node = xpath.selectSingleNode(document); + if (node != null) { + return node.getStringValue(); + } + } + return null; + } + + /** + * 使用SOAP1.2发送消息 + * + * @param postUrl + * @param soapXml + * @param soapAction + * @return + */ + public static String doPostSoap1_2(String postUrl, String soapXml) { + String retStr = ""; + // 创建HttpClientBuilder + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); + HttpPost httpPost = new HttpPost(postUrl); + // 设置请求和传输超时时间 + RequestConfig requestConfig = RequestConfig.custom() + .setSocketTimeout(100000) + .setConnectTimeout(100000).build(); + httpPost.setConfig(requestConfig); + try { + httpPost.setHeader("Content-Type", "text/xml; charset=utf-8"); + httpPost.setHeader("SOAPAction", ""); + StringEntity data = new StringEntity(soapXml,Charset.forName("UTF-8")); + httpPost.setEntity(data); + CloseableHttpResponse response = closeableHttpClient.execute(httpPost); + HttpEntity httpEntity = response.getEntity(); + if (httpEntity != null) { + // 打印响应内容 + retStr = EntityUtils.toString(httpEntity, "UTF-8"); + retStr = retStr.replaceAll("<", "<"); + retStr = retStr.replaceAll(">", ">"); + } + // 释放资源 + closeableHttpClient.close(); + } catch (Exception e) { + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(baos)); + String exception = baos.toString(); + logger.info("exception in doPostSoap1_2:" + exception); + } + return retStr; + } + +} Index: ssts-web/src/main/webapp/disinfectsystem/config/gd2zyy/spring/HIS.xml =================================================================== diff -u -r38194 -r41546 --- ssts-web/src/main/webapp/disinfectsystem/config/gd2zyy/spring/HIS.xml (.../HIS.xml) (revision 38194) +++ ssts-web/src/main/webapp/disinfectsystem/config/gd2zyy/spring/HIS.xml (.../HIS.xml) (revision 41546) @@ -46,32 +46,10 @@ + + - - - - - - - - - - - + + - - - - - - - - - - - - - \ No newline at end of file