Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/DatasyncConstant.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/DatasyncConstant.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/DatasyncConstant.java (revision 41083) @@ -0,0 +1,44 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.qifuyy; + +/** + * 与东软his人员科室、患者信息接口开发 + * QIFUYY-18 + */ +public class DatasyncConstant { + + /** + * 诊疗号接口地址 + */ + public final static String TreatmentNumHttpServiceAddress = "http://10.161.211.101:7801/roc/patient-service/api/v1/register/patient/getFinOprRegList"; + + /** + * 住院号接口地址 + */ + public final static String HospitalNumHttpServiceAddress = "http://10.161.211.101:7801/roc/order-service/api/v1/order/operation/apply/get"; + + /** + * 科室同步接口地址 + */ + public final static String OrgUnitServiceAddress = "http://10.161.211.101:7801/roc/curr-web/api/v1/common/dept/query"; + + /** + * 用户同步接口地址 + */ + public final static String UserServiceAddress = "http://10.161.211.101:7801/roc/curr-web/api/v1/common/employee/query"; + + /** + * domain + */ + public final static String domain = "XDGY"; + + /** + * key + */ + public final static String key = "8cc6fba6-a73f-4870-ab99-246864ef0853"; + + /** + * 成功的相应码 + */ + public static final String RESULT_OK = "200"; + +} Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/FindPatientInfoByTreatmentNumDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/FindPatientInfoByTreatmentNumDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/FindPatientInfoByTreatmentNumDaoImpl.java (revision 41083) @@ -0,0 +1,138 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.qifuyy; + +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 net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.springframework.beans.factory.annotation.Autowired; + +import com.forgon.disinfectsystem.datasynchronization.dao.FindPatientInfoByTreatmentNumDao; +import com.forgon.disinfectsystem.datasynchronization.model.PatientInfoVO; +import com.forgon.exception.SystemException; +import com.forgon.tools.hibernate.ObjectDao; + +/** + * 与东软his人员科室、患者信息接口开发 + * QIFUYY-18 + */ +public class FindPatientInfoByTreatmentNumDaoImpl implements FindPatientInfoByTreatmentNumDao { + + Logger logger = Logger.getLogger(FindPatientInfoByTreatmentNumDaoImpl.class); + + @Autowired + private ObjectDao objectDao; + + @Override + public PatientInfoVO[] findPatientInfoByTreatmentNum(String treatmentNum) { + try { + logger.debug("门诊病人信息同步接口地址:" + DatasyncConstant.TreatmentNumHttpServiceAddress); + String request = buildTreatmentNumPatientInfoRequest(treatmentNum); + logger.debug("门诊病人信息同步接口请求信息:" + request); + String responce = HttpInterfaceHelper.doPost(DatasyncConstant.TreatmentNumHttpServiceAddress, request); + //String responce = "{'code': 200,'msg': '操作成功!','data': [{'cardNo':'诊疗号','departCoding':'4001','depart':'手术室','docName':'医生姓名','idNo':'111111111111111111','name':'患者姓名01','operDate':'2025-10-15 14:50:00','sexCode':'2'},{'cardNo':'诊疗号','departCoding':'4001','depart':'手术室','docName':'医生姓名','idNo':'111111111111111111','name':'患者姓名01','operDate':'2025-10-11 14:50:00','sexCode':'2'}]}"; + logger.debug("门诊病人信息同步接口返回信息:" + responce); + if(StringUtils.isBlank(responce)){ + return null; + } + JSONObject responceJson = JSONObject.fromObject(responce); + JSONArray patientJSONArray = responceJson.optJSONArray("data"); + if(patientJSONArray == null || patientJSONArray.size() == 0){ + return null; + } + List patientInfoVOList = new ArrayList(); + for(int i=0; i() { + @Override + public int compare(PatientInfoVO o1, PatientInfoVO o2) { + if (StringUtils.isBlank(o1.getVisitDate()) && StringUtils.isNotBlank(o2.getVisitDate())) { + return -1; + } + if (StringUtils.isBlank(o2.getVisitDate()) && StringUtils.isNotBlank(o1.getVisitDate())) { + return 1; + } + if (StringUtils.isBlank(o1.getVisitDate()) && StringUtils.isBlank(o2.getVisitDate())) { + return 0; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date date1 = sdf.parse(o1.getVisitDate()); + Date date2 = sdf.parse(o2.getVisitDate()); + return date2.compareTo(date1); + } catch (ParseException e) { + logger.error("门诊病人信息排序出错(挂号时间【operDate】字段格式错误)!"); + e.printStackTrace(); + } + return 0; + } + }); + PatientInfoVO[] patientInfoArray = new PatientInfoVO[patientInfoVOList.size()]; + for (int i=0;i patientInfoVOList = new ArrayList(); + for(int i=0; i() { + @Override + public int compare(PatientInfoVO o1, PatientInfoVO o2) { + if (StringUtils.isBlank(o1.getVisitDate()) && StringUtils.isNotBlank(o2.getVisitDate())) { + return -1; + } + if (StringUtils.isBlank(o2.getVisitDate()) && StringUtils.isNotBlank(o1.getVisitDate())) { + return 1; + } + if (StringUtils.isBlank(o1.getVisitDate()) && StringUtils.isBlank(o2.getVisitDate())) { + return 0; + } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + try { + Date date1 = sdf.parse(o1.getVisitDate()); + Date date2 = sdf.parse(o2.getVisitDate()); + return date2.compareTo(date1); + } catch (ParseException e) { + logger.info("住院号病人信息排序出错(挂号时间【operationTime】字段格式错误)!"); + e.printStackTrace(); + } + return 0; + } + }); + PatientInfoVO[] patientInfoArray = new PatientInfoVO[patientInfoVOList.size()]; + for (int i=0;i"); + } + // 释放资源 + 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-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/SyncOrgUnitAndUserDaoImpl.java =================================================================== diff -u --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/SyncOrgUnitAndUserDaoImpl.java (revision 0) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/dao/qifuyy/SyncOrgUnitAndUserDaoImpl.java (revision 41083) @@ -0,0 +1,230 @@ +package com.forgon.disinfectsystem.datasynchronization.dao.qifuyy; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.net.URL; +import java.net.URLConnection; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Logger; + +import net.sf.json.JSONArray; +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.Constants; + +/** + * 与东软his人员科室、患者信息接口开发 + * QIFUYY-18 + */ +public class SyncOrgUnitAndUserDaoImpl implements SyncOrgUnitAndUserDao { + + Logger logger = Logger.getLogger(SyncOrgUnitAndUserDaoImpl.class); + + /** + * 查询his系统人员信息 + */ + @Override + public UserVo[] getAllUser() { + UserVo[] userVoArray = null; + List userVoList = new ArrayList(); + try{ + logger.info("人员同步接口地址:" + DatasyncConstant.UserServiceAddress); + JSONObject responceJson = sendGetRequest(DatasyncConstant.UserServiceAddress, "", Constants.CHARSET_UTF8); + //String responceStr = "{'code': '200','data': [{'deptCode': '2025021701','emplCode': '2025021701','emplName': '花都院区用户2025021701'}],'msg': ''}"; + //JSONObject responceJson = JSONObject.fromObject(responceStr); + logger.info("人员同步接口返回消息:" + responceJson); + int amount = 0; + if(responceJson != null){ + String code = responceJson.optString("code"); + if(DatasyncConstant.RESULT_OK.equals(code)){ + Object dataTableObj = responceJson.opt("data"); + if(dataTableObj == null){ + return null; + } + JSONArray userJsonArray = new JSONArray(); + if(dataTableObj instanceof JSONObject){ + JSONObject userInfo = (JSONObject)dataTableObj; + userJsonArray.add(userInfo); + }else if(dataTableObj instanceof JSONArray){ + userJsonArray = (JSONArray)dataTableObj; + } + if(userJsonArray.size() > 0){ + for (int i = 0; i < userJsonArray.size(); i++) { + Object coding = userJsonArray.optJSONObject(i).opt("emplCode"); + Object name = userJsonArray.optJSONObject(i).opt("emplName"); + Object orgUnitCoding = userJsonArray.optJSONObject(i).opt("deptCode"); + UserVo userVo = new UserVo(); + userVo.setCoding(coding instanceof String ? (String)coding : ""); + userVo.setName(name instanceof String ? (String)name : ""); + userVo.setOrgUnitCoding(orgUnitCoding instanceof String ? (String)orgUnitCoding : ""); + userVoList.add(userVo); + } + amount = userVoList.size(); + logger.info("人员同步接口返回人员数量:" + amount); + if(CollectionUtils.isNotEmpty(userVoList)){ + if(CollectionUtils.isNotEmpty(userVoList)){ + userVoArray = new UserVo[userVoList.size()]; + userVoList.toArray(userVoArray); + } + } + } + }else{ + throw new RuntimeException(String.format("人员信息同步失败,code = %s,msg = %s", code, responceJson.optString("msg"))); + } + } + }catch(Exception e){ + logger.info("人员信息同步失败:" + e); + } + + return userVoArray; + } + + /** + * 查询his系统科室信息 + */ + @Override + public OrgUnitVo[] getAllOrgUnit() { + OrgUnitVo[] orgUnitVoArray = null; + List orgUnitVoList = new ArrayList(); + try{ + logger.info("组织机构同步接口地址:" + DatasyncConstant.OrgUnitServiceAddress); + String param = ""; + JSONObject responceJson = sendGetRequest(DatasyncConstant.OrgUnitServiceAddress, param, Constants.CHARSET_UTF8); + //String responceStr = "{ 'code': '200', 'data': [{'branchCode': '花都院区编码','deptCode': '2025021701','deptName': '花都院区2025021701','subBranchCode':'004'} ], 'msg': ''}"; + //JSONObject responceJson = JSONObject.fromObject(responceStr); + logger.info("组织机构同步接口返回消息:" + responceJson); + if(responceJson == null){ + throw new RuntimeException("接口返回参数为空"); + } + String code = responceJson.optString("code"); + int amount = 0; + if(DatasyncConstant.RESULT_OK.equals(code)){ + Object dataTableObj = responceJson.opt("data"); + if(dataTableObj == null){ + return null; + } + JSONArray orgJsonArray = new JSONArray(); + if(dataTableObj instanceof JSONObject){ + JSONObject userInfo = (JSONObject)dataTableObj; + orgJsonArray.add(userInfo); + }else if(dataTableObj instanceof JSONArray){ + orgJsonArray = (JSONArray)dataTableObj; + } + if(orgJsonArray.size() > 0){ + for (int i = 0; i < orgJsonArray.size(); i++) { + Object coding = orgJsonArray.optJSONObject(i).opt("deptCode"); + Object name = orgJsonArray.optJSONObject(i).opt("deptName"); + OrgUnitVo orgVo = new OrgUnitVo(); + orgVo.setCoding(coding instanceof String ? (String)coding : ""); + orgVo.setName(name instanceof String ? (String)name : ""); + //现场科室不存在上级科室编码 + //orgVo.setParentCoding(defaultParentOrgUnitCode); + orgUnitVoList.add(orgVo); + } + orgUnitVoArray = new OrgUnitVo[orgJsonArray.size()]; + orgUnitVoList.toArray(orgUnitVoArray); + amount = orgUnitVoList.size(); + } + }else{ + throw new RuntimeException(String.format("组织机构同步失败,code = %s,msg = %s", code, responceJson.optString("msg"))); + } + logger.info("组织机构同步接口返回组织机构数量:" + amount); + }catch(Exception e){ + logger.error("组织机构同步失败" + e); + } + + return orgUnitVoArray; + } + + /** + * 向指定URL发送GET方法的请求 + * + * @param url + * 发送请求的URL + * @param param + * 请求参数,请求参数应该是 name1=value1&name2=value2 的形式。 + * @param charset + * 字符编码集 + * @return URL 所代表远程资源的响应结果 + */ + public JSONObject sendGetRequest(String url, String param , String charset) { + logger.debug("sendGetRequest:url="+ url +",param="+ param +",charset="+ charset); + JSONObject result = null; + BufferedReader in = null; + try { + String urlNameString = url; + if(StringUtils.isNotBlank(param)){ + if(url.indexOf("?") == -1 && param.indexOf("?") == -1){ + urlNameString = url + "?" + param; + }else if(url.indexOf("&") == -1 && param.indexOf("&") == -1){ + urlNameString = url + "&" + param; + } + } + URL realUrl = new URL(urlNameString); + // 打开和URL之间的连接 + URLConnection connection = realUrl.openConnection(); + // 设置通用的请求属性 + connection.setRequestProperty("accept", "*/*"); + connection.setRequestProperty("connection", "Keep-Alive"); + connection.setRequestProperty("user-agent", + "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)"); + connection.setRequestProperty("key", DatasyncConstant.key); + connection.setRequestProperty("domain", DatasyncConstant.domain); + // 建立实际的连接 + connection.connect(); + // 获取所有响应头字段 + /*Map> map = connection.getHeaderFields(); + // 遍历所有的响应头字段 + for (String key : map.keySet()) { + logger.debug(key + "--->" + map.get(key)); + }*/ + // 定义 BufferedReader输入流来读取URL的响应 + in = new BufferedReader(new InputStreamReader( + connection.getInputStream() ,charset)); + String responceStr = ""; + String line; + while ((line = in.readLine()) != null) { + responceStr += line; + } + logger.debug("result="+ responceStr); + result = JSONObject.fromObject(responceStr); + } catch (Exception e) { + logger.error("发送GET请求出现异常!" + e); + e.printStackTrace(); + } + // 使用finally块来关闭输入流 + finally { + try { + if (in != null) { + in.close(); + } + } catch (Exception e2) { + e2.printStackTrace(); + } + } + return result; + } + + @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-web/src/main/webapp/disinfectsystem/config/qifuyy/spring/HIS.xml =================================================================== diff -u -r40797 -r41083 --- ssts-web/src/main/webapp/disinfectsystem/config/qifuyy/spring/HIS.xml (.../HIS.xml) (revision 40797) +++ ssts-web/src/main/webapp/disinfectsystem/config/qifuyy/spring/HIS.xml (.../HIS.xml) (revision 41083) @@ -47,7 +47,7 @@ - + @@ -59,7 +59,10 @@ - + + + + @@ -71,7 +74,10 @@ - + + + + @@ -82,5 +88,8 @@ + + + \ No newline at end of file Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManagerImpl.java =================================================================== diff -u -r40543 -r41083 --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManagerImpl.java (.../DataSynchronizationManagerImpl.java) (revision 40543) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/datasynchronization/service/DataSynchronizationManagerImpl.java (.../DataSynchronizationManagerImpl.java) (revision 41083) @@ -118,6 +118,8 @@ //默认用户组织机构数据源 private SyncOrgUnitAndUserDao syncOrgUnitAndUserDao; + private SyncOrgUnitAndUserDao syncOrgUnitAndUserDao2; + //用户组织机构多个数据源 private SyncOrgUnitAndUserSource2Dao syncOrgUnitAndUserSource2Dao; @@ -184,6 +186,10 @@ private ForeignTousseInfoPushDao foreignTousseInfoPushDao; + public void setSyncOrgUnitAndUserDao2(SyncOrgUnitAndUserDao syncOrgUnitAndUserDao2) { + this.syncOrgUnitAndUserDao2 = syncOrgUnitAndUserDao2; + } + public void setFindPatientInfoByPatientIdDao( FindPatientInfoByPatientIdDao findPatientInfoByPatientIdDao) { this.findPatientInfoByPatientIdDao = findPatientInfoByPatientIdDao; @@ -945,6 +951,12 @@ //syncOrgUnitAndUserDao = null; if (syncOrgUnitAndUserDao != null) { allVos = syncOrgUnitAndUserDao.getAllOrgUnit(); + if(allVos == null || allVos.length == 0){ + if(syncOrgUnitAndUserDao2 != null){ + //第一个接口同步不到数据,再从第二个接口同步 + allVos = syncOrgUnitAndUserDao2.getAllOrgUnit(); + } + } } else if (baseDataDao != null) { allVos = baseDataDao.getAllOrgUnitVoData(); } @@ -1294,6 +1306,12 @@ UserVo[] allVos = null; if (syncOrgUnitAndUserDao != null) { allVos = syncOrgUnitAndUserDao.getAllUser(); + if(allVos == null || allVos.length == 0){ + if(syncOrgUnitAndUserDao2 != null){ + //第一个接口同步不到数据,再从第二个接口同步 + allVos = syncOrgUnitAndUserDao2.getAllUser(); + } + } } else if (baseDataDao != null) { allVos = baseDataDao.getAllUserVoData(); }