Index: ssts-web/src/main/webapp/disinfectsystem/config/gdsy/spring/timer.xml =================================================================== diff -u -r27961 -r37264 --- ssts-web/src/main/webapp/disinfectsystem/config/gdsy/spring/timer.xml (.../timer.xml) (revision 27961) +++ ssts-web/src/main/webapp/disinfectsystem/config/gdsy/spring/timer.xml (.../timer.xml) (revision 37264) @@ -61,6 +61,26 @@ 0 0 0 * * ? + + + + + + + + syncMqPatientInfo + + + + + + + + + 0 0 0/2 * * ? + + @@ -70,6 +90,8 @@ + + Index: ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/mq/dao/gdsy/MQDataDaoImpl.java =================================================================== diff -u -r37254 -r37264 --- ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/mq/dao/gdsy/MQDataDaoImpl.java (.../MQDataDaoImpl.java) (revision 37254) +++ ssts-datasync-default-impl/src/main/java/com/forgon/disinfectsystem/mq/dao/gdsy/MQDataDaoImpl.java (.../MQDataDaoImpl.java) (revision 37264) @@ -3,7 +3,9 @@ import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Base64; +import java.util.HashSet; import java.util.List; +import java.util.Set; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -41,6 +43,11 @@ @Autowired private ObjectDao objectDao; + /** + * 一次调用最多获取的消息数量 + */ + private static final int maxMessageCount = 1000; + @Override public Object[] getAllBaseData() { return null; @@ -59,10 +66,38 @@ logger.debug("开始调用患者信息同步接口:"); String address = DatasyncConstant.getHospitalNumPatientInfoSyncAddress(); logger.debug("患者信息同步接口地址:" + address); - String result = doPostSoap1_2(address, ""); - //String result = "{'status':1,'error_code':'','error_info':'','data':{'header': {'service_id': 'BS007','date_time': '20231121110528','hospital_id': '医疗机构编码','apply_unit_id': '申请科室编码','exec_unit_id': '执行科室编码','visit_type': '03','send_sys_id': '发送系统编码','extend_sub_id': '扩展码','order_exec_id': '医嘱执行分类编码','msg_id': ''},'body': {'newUpFlag': 'new','triggerEventTime': '20231121110303','sender': 'S062','requestNo': '202311210000000394','orderNo': '202311210000000394','dayvisitNo': '','reservationOrder': '','descript': '','requestDate': '20231121110251','operationKind': '2','operationKindName': '择期','anesthesiaCode': '','operationTypeCode': '','operationTypeName': '','anesthesiaName': '','domainID': '01','patientLid': '8947244','visitNo': '8947244','visitOrdNo': '1206314520','visitTimes': 36,'visitType': '01','visitTypeName': '门诊','wardsName': 'sss','wardsId': '','roomNo': '','bedNo': '床位','identityCard': '441722196903253604','medicareCard': '','patientName': '赖连芳','telNum': '13266046677','genderCode': '2','birthday': '19690325000000','age': '54岁','address': '广东省阳江市阳春市','linkmanName': '','linkmanPhone': '','deptCode': '1055','visitDeptName': '聚焦刀护理单元','organizationCode': '45586199-0','organizationName': '广东省人民医院','surgicalTime': '20231121110236','userTime': null,'execTimeUnit': '','directorCode': '','directorName': '','assistantList': [{'assistantCode': '','assistantTypeName': '朱珍','assistantName': '朱珍'}],'executeDeptNo': '837004','executeDeptName': '日间手术中心','operatoerDeptNo': null,'operatoerDeptName': null,'requestPersonId': '19879','requestPersonName': '杨梅','requestDeptNo': '1055','requestDeptName': '东川乳腺门诊','verifyTime': '','verifyPersonID': '','verifyPersonName': '','relationMedicationList': [{'medicationOrderLid': '','medicationOrderNo': '1'}],'operationOrderList': [{'orderLid': '2311210096551','operationNameCode': '86.0500x008','operationName': '皮下植入装置取出术','operationText': '','setNum': '-1','positionCode': '','positionName': '','siteCode': '','siteName': '','siteOtherCode': '04','siteOtherName': '其他','operationLevel': '1','operationLevelName': '一级','operatorCode': '19879','operatorName': '杨梅','operatorRoom': '-1','inVitorDeptId': '','inVitorDeptName': '','anaesthesiaDeptId': '','anaesthesiaDeptName': '','secondReason': '','skinTestFlag': 'false','urgency': '','isSecond': '','planFlag': '','noPlanReason': '','influenceFlag': null,'paymentTypeCode': '','paymentTypeName': '','payFlag': '','hisStatus': null,'hisStatusName': '未执行','createDate': '','clinicalPathwayCode': '0','clinicalPathwayNumber': '','aboBlood': '','rhBlood': '','height': '','weight': '','notchedType': '','notchedTypeName': null,'operationTimes': '','stageSequence': ''}],'noticeItems': '','infectiousHistory': '','deviceRequire': '','visitDate': '20231121000000','patientType': '','patientTypeName': '','diagnosisList': [{'diagnosisType': '12','diagnosisTypeName': '主要诊断','diseaseCode': 'C50.900x011','diseaseName': '乳腺恶性肿瘤','originalText': null}]}}}"; - logger.debug("患者同步接口返回信息:" + result); - List patientInfoVOList = parsePatientInfoVO(result); + List patientInfoVOList = new ArrayList(); + int messageCount = 0; + while(true){ + String result = doPostSoap1_2(address, ""); + //String result = "{'status':1,'error_code':'','error_info':'','data':{'header': {'service_id': 'BS007','date_time': '20231121110528','hospital_id': '医疗机构编码','apply_unit_id': '申请科室编码','exec_unit_id': '执行科室编码','visit_type': '03','send_sys_id': '发送系统编码','extend_sub_id': '扩展码','order_exec_id': '医嘱执行分类编码','msg_id': ''},'body': {'newUpFlag': 'new','triggerEventTime': '20231121110303','sender': 'S062','requestNo': '202311210000000394','orderNo': '202311210000000394','dayvisitNo': '','reservationOrder': '','descript': '','requestDate': '20231121110251','operationKind': '2','operationKindName': '择期','anesthesiaCode': '','operationTypeCode': '','operationTypeName': '','anesthesiaName': '','domainID': '01','patientLid': '8947244','visitNo': '8947244','visitOrdNo': '1206314520','visitTimes': 36,'visitType': '01','visitTypeName': '门诊','wardsName': 'sss','wardsId': '','roomNo': '','bedNo': '床位','identityCard': '441722196903253604','medicareCard': '','patientName': '赖连芳','telNum': '13266046677','genderCode': '2','birthday': '19690325000000','age': '54岁','address': '广东省阳江市阳春市','linkmanName': '','linkmanPhone': '','deptCode': '1055','visitDeptName': '聚焦刀护理单元','organizationCode': '45586199-0','organizationName': '广东省人民医院','surgicalTime': '20231121110236','userTime': null,'execTimeUnit': '','directorCode': '','directorName': '','assistantList': [{'assistantCode': '','assistantTypeName': '朱珍','assistantName': '朱珍'}],'executeDeptNo': '837004','executeDeptName': '日间手术中心','operatoerDeptNo': null,'operatoerDeptName': null,'requestPersonId': '19879','requestPersonName': '杨梅','requestDeptNo': '1055','requestDeptName': '东川乳腺门诊','verifyTime': '','verifyPersonID': '','verifyPersonName': '','relationMedicationList': [{'medicationOrderLid': '','medicationOrderNo': '1'}],'operationOrderList': [{'orderLid': '2311210096551','operationNameCode': '86.0500x008','operationName': '皮下植入装置取出术','operationText': '','setNum': '-1','positionCode': '','positionName': '','siteCode': '','siteName': '','siteOtherCode': '04','siteOtherName': '其他','operationLevel': '1','operationLevelName': '一级','operatorCode': '19879','operatorName': '杨梅','operatorRoom': '-1','inVitorDeptId': '','inVitorDeptName': '','anaesthesiaDeptId': '','anaesthesiaDeptName': '','secondReason': '','skinTestFlag': 'false','urgency': '','isSecond': '','planFlag': '','noPlanReason': '','influenceFlag': null,'paymentTypeCode': '','paymentTypeName': '','payFlag': '','hisStatus': null,'hisStatusName': '未执行','createDate': '','clinicalPathwayCode': '0','clinicalPathwayNumber': '','aboBlood': '','rhBlood': '','height': '','weight': '','notchedType': '','notchedTypeName': null,'operationTimes': '','stageSequence': ''}],'noticeItems': '','infectiousHistory': '','deviceRequire': '','visitDate': '20231121000000','patientType': '','patientTypeName': '','diagnosisList': [{'diagnosisType': '12','diagnosisTypeName': '主要诊断','diseaseCode': 'C50.900x011','diseaseName': '乳腺恶性肿瘤','originalText': null}]}}}"; + logger.debug("患者同步接口返回信息:" + result); + if(StringUtils.isBlank(result)){ + logger.debug("患者同步接口返回信息为空!"); + break; + } + String status = getStatus(result); + if(StringUtils.equals(status, "0")){ + logger.debug("患者同步接口无消息"); + break; + } + if(!StringUtils.equals(status, "1")){ + logger.debug("患者同步接口调用失败:status = " + status); + break; + } + List voList = parsePatientInfoVO(result); + if(CollectionUtils.isEmpty(voList)){ + break; + } + patientInfoVOList.addAll(voList); + messageCount++; + if(messageCount >= maxMessageCount){ + logger.debug("患者同步接口消息总数达到最大调用次数" + maxMessageCount + ",需要分批次同步"); + break; + } + } + logger.debug("患者同步接口返回信息总数:" + messageCount); + if(CollectionUtils.isEmpty(patientInfoVOList)){ return null; } @@ -81,6 +116,26 @@ } /** + * 返回status + * @param result + * @return + */ + private String getStatus(String result) { + JSONObject json = null; + try { + json = JSONObject.fromObject(result); + } catch (Exception e) { + e.printStackTrace(); + logger.debug("患者同步接口返回的信息格式异常!"); + } + if(json == null){ + logger.debug("患者同步接口返回的信息为空!"); + return null; + } + return json.optString("status"); + } + + /** * 根据医嘱号删除旧数据 * @param patientInfoVOList */ @@ -89,16 +144,16 @@ return; } - List hospitalSerialNumberList = new ArrayList(); + Set hospitalSerialNumberSet = new HashSet(); for (PatientInfoVO patientInfoVO : patientInfoVOList) { if(StringUtils.isNotBlank(patientInfoVO.getPatientNumber())){ - hospitalSerialNumberList.add(patientInfoVO.getPatientNumber()); + hospitalSerialNumberSet.add(patientInfoVO.getPatientNumber()); } } - if(CollectionUtils.isEmpty(hospitalSerialNumberList)){ + if(CollectionUtils.isEmpty(hospitalSerialNumberSet)){ return; } - String deleteSql = String.format("delete from %s where %s", PatientAdmissionInfo.class.getSimpleName(), SqlUtils.getStringFieldInLargeCollectionsPredicate("hospitalSerialNumber", hospitalSerialNumberList)); + String deleteSql = String.format("delete from %s where %s", PatientAdmissionInfo.class.getSimpleName(), SqlUtils.getStringFieldInLargeCollectionsPredicate("hospitalSerialNumber", hospitalSerialNumberSet)); objectDao.excuteSQL(deleteSql); }