From 6d7e2217f943c9f3786436cdd08176e8e79567a4 Mon Sep 17 00:00:00 2001 From: wyb <1977763549@qq.com> Date: Tue, 18 Apr 2023 17:37:10 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=B0=83=E7=94=A8=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E9=97=B4=E9=9A=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../report/config/SdRyReportQueryConfig.java | 6 ++ .../docus/server/report/job/ReportJob.java | 73 ++++++++++++++----- src/main/resources/bootstrap.yml | 3 + 3 files changed, 64 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/docus/server/report/config/SdRyReportQueryConfig.java b/src/main/java/com/docus/server/report/config/SdRyReportQueryConfig.java index 0c69b6a..0820ea8 100644 --- a/src/main/java/com/docus/server/report/config/SdRyReportQueryConfig.java +++ b/src/main/java/com/docus/server/report/config/SdRyReportQueryConfig.java @@ -19,6 +19,8 @@ public class SdRyReportQueryConfig { private String queryReportIndexWsdlNamespaceUri; @Value("${sdry.report-index-query.operationName:}") private String queryReportIndexWsdlOperationName; + @Value("${sdry.report-index-query.interval:1000}") + private int queryReportIndexInterval; @Value("${sdry.report-query-url.lis.url:}") private String reportQueryLisUrl; @@ -28,6 +30,8 @@ public class SdRyReportQueryConfig { private String reportQueryLisAction; @Value("${sdry.report-query-url.lis.accessKey:}") private String reportQueryLisAccessKey; + @Value("${sdry.report-query-url.lis.interval:1000}") + private int reportQueryLisInterval; @Value("${sdry.report-query-url.inspect.url:}") private String reportQueryInspectUrl; @@ -37,4 +41,6 @@ public class SdRyReportQueryConfig { private String reportQueryInspectAction; @Value("${sdry.report-query-url.inspect.accessKey:}") private String reportQueryInspectAccessKey; + @Value("${sdry.report-query-url.inspect.interval:1000}") + private int reportQueryInspectInterval; } diff --git a/src/main/java/com/docus/server/report/job/ReportJob.java b/src/main/java/com/docus/server/report/job/ReportJob.java index 6cbd938..64b49d5 100644 --- a/src/main/java/com/docus/server/report/job/ReportJob.java +++ b/src/main/java/com/docus/server/report/job/ReportJob.java @@ -35,6 +35,9 @@ import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.Lock; +import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; /** @@ -67,7 +70,7 @@ public class ReportJob { final String jobType = "SdRyLisReport"; LocalDateTime now = LocalDateTime.now(); // 等待基础数据入库时间 - now=now.plusMinutes(-10); + now = now.plusMinutes(-10); log.info("LIS检验报告报告查询 任务开始了"); // 定义查基础数据 根据基础数据的创建时间 AfJobTime afJobTime = getJobTimeByJobType(jobType); @@ -122,7 +125,7 @@ public class ReportJob { final String jobType = "SdRyInspectReport"; LocalDateTime now = LocalDateTime.now(); // 等待基础数据入库时间 - now=now.plusMinutes(-10); + now = now.plusMinutes(-10); log.info("检查报告报告查询 任务开始了"); // 定义查基础数据 更新时间 开始结束 AfJobTime afJobTime = getJobTimeByJobType(jobType); @@ -166,6 +169,8 @@ public class ReportJob { } } + private static Lock inspectReportLock = new ReentrantLock(); + private List getInspectReportList(TBasic tBasic) { // 根据基础信息查顺德报告业务系统索引,查 交叉索引 List sdRyReportPatientIds = getSdRyReportPatientIds(tBasic.getPatientId()); @@ -192,7 +197,16 @@ public class ReportJob { String requestParam = organizationQuerySdRyInspectReportParam(sdRyReportPatientId, tBasic, pageNum, pageSize); String url = organizationQuerySdRyInspectReportUrl(sdRyReportQueryConfig.getReportQueryInspectUrl()); log.info("查询检查报告请求地址:{} ,请求body参数:{}", url, requestParam); - String respBody = this.sendPost(url, requestParam); + String respBody = ""; + inspectReportLock.lock(); + try { + respBody = this.sendPost(url, requestParam); + TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getReportQueryInspectInterval()); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + } finally { + inspectReportLock.unlock(); + } log.info("查询检查报告请求成功,响应参数:{}", respBody); List reportDtoList = parseQuerySdRyInspectReport(respBody, tBasic); if (reportDtoList.isEmpty()) { @@ -345,6 +359,8 @@ public class ReportJob { return reportDtoList; } + private static Lock lisReportLock = new ReentrantLock(); + private List getLisReportDtoListBySdRyReportPatientId(String sdRyReportPatientId, TBasic tBasic) { try { List reportDtos = new ArrayList<>(); @@ -360,7 +376,17 @@ public class ReportJob { post.header("Content-Type", "application/json; charset=utf-8"); post.body(requestParam); HttpResponse response = post.execute(); - String respBody = response.body(); + String respBody = ""; + lisReportLock.lock(); + try { + respBody = response.body(); + TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getReportQueryLisInterval()); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + } finally { + lisReportLock.unlock(); + } + log.info("查询Lis报告请求成功,响应参数:{}", respBody); List reportDtoList = parseQuerySdRyLisReport(respBody, tBasic); if (reportDtoList.isEmpty()) { @@ -466,6 +492,8 @@ public class ReportJob { return Func.toJson(map); } + private static Lock indexQueryLock = new ReentrantLock(); + /** * 根据归档病案主键查询报告交叉索引 * @@ -473,22 +501,31 @@ public class ReportJob { * @return 报告交叉索引 */ private List getSdRyReportPatientIds(String patientId) { - String sDryIndex = tBasicMapper.getSdRyIndexByPatientId(patientId); - if (Func.isBlank(sDryIndex)) { - log.warn("patientId:{} 未关联到第三方索引", patientId); - return new ArrayList<>(); - } - String param = organizationQuerySdRyReportIndexParam(sDryIndex); - String[] params={"HIP1179",param}; - String namespaceUri = sdRyReportQueryConfig.getQueryReportIndexWsdlNamespaceUri(); - String wsdlAddr = sdRyReportQueryConfig.getQueryReportIndexWsdlAddr(); - String operationName = sdRyReportQueryConfig.getQueryReportIndexWsdlOperationName(); - String result = JaxWsDynamicClient.send(wsdlAddr, namespaceUri, operationName, params); - log.info("查询顺德人医患者交叉索引数据,返回值:{}", result); - if (result == null) { + indexQueryLock.lock(); + try { + String sDryIndex = tBasicMapper.getSdRyIndexByPatientId(patientId); + if (Func.isBlank(sDryIndex)) { + log.warn("patientId:{} 未关联到第三方索引", patientId); + return new ArrayList<>(); + } + String param = organizationQuerySdRyReportIndexParam(sDryIndex); + String[] params = {"HIP1179", param}; + String namespaceUri = sdRyReportQueryConfig.getQueryReportIndexWsdlNamespaceUri(); + String wsdlAddr = sdRyReportQueryConfig.getQueryReportIndexWsdlAddr(); + String operationName = sdRyReportQueryConfig.getQueryReportIndexWsdlOperationName(); + String result = JaxWsDynamicClient.send(wsdlAddr, namespaceUri, operationName, params); + log.info("查询顺德人医患者交叉索引数据,返回值:{}", result); + if (result == null) { + return new ArrayList<>(); + } + TimeUnit.MILLISECONDS.sleep(sdRyReportQueryConfig.getQueryReportIndexInterval()); + return parseQuerySdRyReportIndex(result); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); return new ArrayList<>(); + } finally { + indexQueryLock.unlock(); } - return parseQuerySdRyReportIndex(result); } /** diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml index 122e47d..759067f 100644 --- a/src/main/resources/bootstrap.yml +++ b/src/main/resources/bootstrap.yml @@ -49,6 +49,7 @@ sdry: wsdl-addr: http://127.0.0.1:9311/webservice/api?wsdl namespace-uri: http://impl.webservice.collection.server.docus.com/ operationName: querySdJxIndexTest + interval: 1000 # operationName: querySdJxIndexNoResultTest # 顺德人医查询检查、检验报告的地址配置 report-query-url: @@ -58,12 +59,14 @@ sdry: assortId: lis action: lisac accessKey: lisaskey + interval: 1000 # 检查报告地址 inspect: url: http://127.0.0.1:9311/report/makeup/inspectTest assortId: inspect action: inspectac accessKey: inspectaskey + interval: 1000