From f3bc1e2b0edf3cd2e08bd6c5817dd390d2457ee0 Mon Sep 17 00:00:00 2001 From: tanzherong <985006933@qq.com> Date: Sat, 16 Apr 2022 11:08:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=89=B9=E9=87=8F=E6=8C=89?= =?UTF-8?q?=E9=9C=80=E9=87=87=E9=9B=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dataConfig/homeQualitySet.json | 8 +- pom.xml | 12 +++ .../com/docus/bgts/config/MyScheduling.java | 87 +++++++++++-------- .../bgts/facade/IAfCollectTaskService.java | 32 +++++++ .../com/docus/bgts/facade/IBgtsService.java | 7 ++ .../mapper/dbmysql/AfCollectTaskMapper.java | 32 +++++++ .../service/AfCollectTaskServiceImpl.java | 59 +++++++++++++ .../docus/bgts/service/BgtsServiceImpl.java | 52 ++++++++++- .../mapper/dbmysql/AfCollectTaskMapper.xml | 36 +++++++- 9 files changed, 287 insertions(+), 38 deletions(-) diff --git a/dataConfig/homeQualitySet.json b/dataConfig/homeQualitySet.json index 16ff05d..a2aebe1 100644 --- a/dataConfig/homeQualitySet.json +++ b/dataConfig/homeQualitySet.json @@ -18,7 +18,7 @@ //下载类型(1:服务器本地;2:ftp服务器;3:共享文件夹) "filestoragetype":1, //上传接口 - "uploadConnector":"http://192.168.1.107:9291/api/downplatform/report", + "uploadConnector":"http://192.9.100.171:9291/api/downplatform/report", //基本数据存放处,根节点不填,最后一层为基本信息存放标签与doubleBasic配合 "basicDirectory":["Msg","ReportInfo"], //可能存在存储基本数据不同情况的标签 @@ -47,6 +47,12 @@ "tableName":"V_DOCUMENT_PDF", //oracle时间配置 "collectTimeName":"ARCHIVE_DATE_TIME", + //批量按需采集开始时间 + "collectStartDate": "2021-01-01", + //批量按需采集结束时间 + "collectEndDate": "2022-04-01", + //批量按需采集开关 1:开启 0:关闭 + "collectOpen": "1", //----以下是梅州完整性检验同步配置------ //开关0:关闭 1:开启 diff --git a/pom.xml b/pom.xml index 1943a5f..3718787 100644 --- a/pom.xml +++ b/pom.xml @@ -147,6 +147,18 @@ xercesImpl 2.11.0 + + junit + junit + test + + + + org.apache.commons + commons-collections4 + 4.4 + + diff --git a/src/main/java/com/docus/bgts/config/MyScheduling.java b/src/main/java/com/docus/bgts/config/MyScheduling.java index a287785..b5c526b 100644 --- a/src/main/java/com/docus/bgts/config/MyScheduling.java +++ b/src/main/java/com/docus/bgts/config/MyScheduling.java @@ -5,6 +5,7 @@ import com.docus.bgts.facade.IBgtsService; import com.docus.bgts.facade.IMzSyncService; import com.docus.bgts.utils.FileUtils; import com.docus.bgts.utils.HttpUtils; +import javafx.scene.effect.ImageInput; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; @@ -12,6 +13,7 @@ import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; + import java.util.HashMap; import java.util.Map; @@ -22,9 +24,9 @@ public class MyScheduling { public static String syncFlag; - static { - syncFlag=FileUtils.getJsonByName("syncFlag").toString(); - } +// static { +// syncFlag=FileUtils.getJsonByName("syncFlag").toString(); +// } @Autowired IBgtsService bgtsService; @@ -34,47 +36,62 @@ public class MyScheduling { private Logger logger = LogManager.getLogger(MyScheduling.class); - //5分钟执行一次 - @Scheduled(fixedRate = 1000 * 60 * 5) - public void beat() { - Map params = new HashMap<>(); - params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid"))); - try { - HttpUtils.get(beatUrl, params); - } catch (Exception e) { - e.printStackTrace(); - logger.info("心跳推送出错,可能是住院服务没有开启"); - } - } + //5分钟执行一次心跳 +// @Scheduled(fixedRate = 1000 * 60 * 5) +// public void beat() { +// Map params = new HashMap<>(); +// params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid"))); +// try { +// HttpUtils.get(beatUrl, params); +// } catch (Exception e) { +// e.printStackTrace(); +// logger.info("心跳推送出错,可能是住院服务没有开启"); +// } +// } + /** * 手麻采集器 * 10分钟执行一次 */ - @Scheduled(fixedRate = 1000 * 60 * 10) - public void collect() { - String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); - String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect")); - if (isStartCollect.equals("0")) { - return; - } - if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) { - return; - } - bgtsService.timerCollect(); - } +// @Scheduled(fixedRate = 1000 * 60 * 10) +// public void collect() { +// String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); +// String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect")); +// if (isStartCollect.equals("0")) { +// return; +// } +// if ((!collectorid.equals(Codes.SMCODE.getCode())) && (!collectorid.equals(Codes.ZZCODE.getCode()))) { +// return; +// } +// bgtsService.timerCollect(); +// } /** - * 增量同步程序 + * 批量按需采集 + * 5分钟执行一次 */ - @Scheduled(fixedRate = 1000 * 60 * 30) - public void syncIntegrality() { - if (null == syncFlag || "0".equals(syncFlag)) { - - } else { - mzSyncService.addSyncIntegrality(); + @Scheduled(fixedRate = 1000 * 5 ) + public void collectByExamNo(){ + String collectOpen = String.valueOf(FileUtils.getJsonByName("collectOpen")); + if (collectOpen.equals("1")){ + logger.info("按需采集开始----------"); + String collectStartDate = String.valueOf(FileUtils.getJsonByName("collectStartDate")); + String collectEndDate = String.valueOf(FileUtils.getJsonByName("collectEndDate")); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + bgtsService.collectByDate(collectStartDate,collectEndDate,collectorid); } } - + /** + * 增量同步程序 + */ +// @Scheduled(fixedRate = 1000 * 60 * 30) +// public void syncIntegrality() { +// if (null == syncFlag || "0".equals(syncFlag)) { +// +// } else { +// mzSyncService.addSyncIntegrality(); +// } +// } } diff --git a/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java index 2ee8f97..cfdc822 100644 --- a/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java +++ b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java @@ -4,6 +4,9 @@ package com.docus.bgts.facade; import com.baomidou.mybatisplus.extension.service.IService; import com.docus.bgts.entity.AfCollectTask; import com.docus.bgts.entity.ReportDownDto; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** *

@@ -22,4 +25,33 @@ public interface IAfCollectTaskService extends IService { void insert(ReportDownDto reportDownDto); void updateInterfaceCollect(String collectSubId, int state); + + /** + * 通过出院日期获取患者jzh + * @param startDate 开始日期 + * @param endDate 结束日期 + * @return + */ + List getjzhByDate(String startDate,String endDate); + + /** + * 通过记帐号获取唯一报告单号 + * @param patientIds + * @return + */ + List getC1ByPatientId(List patientIds,String collectorId); + + /** + * 通过唯一报告单号获取patient_id + * @param C1s + * @return + */ + List getPatientIdByC1(List C1s); + + /** + * 通过记帐号获取jzh + * @param patientIds + * @return + */ + List getJzhByPatientId(List patientIds); } diff --git a/src/main/java/com/docus/bgts/facade/IBgtsService.java b/src/main/java/com/docus/bgts/facade/IBgtsService.java index f8badc0..f2e4d60 100644 --- a/src/main/java/com/docus/bgts/facade/IBgtsService.java +++ b/src/main/java/com/docus/bgts/facade/IBgtsService.java @@ -13,6 +13,13 @@ public interface IBgtsService { */ void collectByExamNo(String emamNo, String empId) throws Exception; + /** + * 根据时间批量按需采集 + * @param startDate + * @param endDate + */ + void collectByDate(String startDate,String endDate,String collectorId); + /** * 全量采集 */ diff --git a/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java b/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java index 4619bb5..8550bae 100644 --- a/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java +++ b/src/main/java/com/docus/bgts/mapper/dbmysql/AfCollectTaskMapper.java @@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.docus.bgts.entity.AfCollectTask; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** *

* 病案采集任务 Mapper 接口 @@ -20,4 +22,34 @@ public interface AfCollectTaskMapper extends BaseMapper { * @return */ String getpatientIdByEmpId(@Param("jzh") String empId); + + + /** + * 通过出院日期获取患者jzh + * @param startDate 开始日期 + * @param endDate 结束日期 + * @return + */ + List getjzhByDate(@Param("startDate") String startDate,@Param("endDate") String endDate); + + /** + * 通过记帐号与采集器编号获取唯一报告单号 + * @param patientIds 记帐号集合 + * @param collectorId 采集器编号 + * @return + */ + List getC1ByPatientId(@Param("patientIds") List patientIds,@Param("collectorId") String collectorId); + + /** + * 通过唯一报告单号获取patient_id + * @param C1s + * @return + */ + List getPatientIdByC1(@Param("C1s") List C1s); + /** + * 通过记帐号获取jzh + * @param patientIds 记帐号集合 + * @return + */ + List getJzhByPatientId(@Param("patientIds") List patientIds); } diff --git a/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java index 447bb87..6144d35 100644 --- a/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java +++ b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java @@ -9,11 +9,13 @@ import com.docus.bgts.mapper.dbmysql.AfCollectTaskMapper; import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectMapper; import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectSubMapper; import com.docus.bgts.mapper.dboracle.TestMapper; +import com.google.common.collect.Lists; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.List; @@ -29,6 +31,8 @@ import java.util.List; @Service public class AfCollectTaskServiceImpl extends ServiceImpl implements IAfCollectTaskService { + public static int MAX_SIZE_PER_TIME = 10; + @Autowired TestMapper testMapper; @@ -119,4 +123,59 @@ public class AfCollectTaskServiceImpl extends ServiceImpl getjzhByDate(String startDate, String endDate) { + List patientIds = afCollectTaskMapper.getjzhByDate(startDate, endDate); + return patientIds; + } + + @Override + public List getC1ByPatientId(List patientIds, String collectorId) { + List> batchPatientIds = Lists.partition(patientIds, MAX_SIZE_PER_TIME); + List c1s = new ArrayList<>(); + for (List batchPatientId : batchPatientIds) { + List c1 = afCollectTaskMapper.getC1ByPatientId(batchPatientId, collectorId); + if (c1 != null && c1.size() != 0 ) { + for (String s : c1) { + c1s.add(s); + } + } + } + return c1s; + } + + @Override + public List getPatientIdByC1(List C1s) { + List> batchPatientIds = Lists.partition(C1s, MAX_SIZE_PER_TIME); + List patientIds = new ArrayList<>(); + for (List batchC1s : batchPatientIds) { + List patientId = afCollectTaskMapper.getPatientIdByC1(batchC1s); + if (patientId != null && patientId.size() != 0 ) { + for (String s : patientId) { + patientIds.add(s); + } + } + } + return patientIds; + + } + + + @Override + public List getJzhByPatientId(List patientIds) { + List jzhs = new ArrayList<>(); + List> batchPatientIds = Lists.partition(patientIds, MAX_SIZE_PER_TIME); + for (List batchPatientId : batchPatientIds) { + List jzh = afCollectTaskMapper.getJzhByPatientId(batchPatientId); + if (jzh != null && jzh.size() !=0 ) { + for (String s : jzh) { + jzhs.add(s); + } + } + } + return jzhs; + } + + + } diff --git a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java index ced9cf4..6e3ba4d 100644 --- a/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java +++ b/src/main/java/com/docus/bgts/service/BgtsServiceImpl.java @@ -9,11 +9,13 @@ import com.docus.bgts.enums.Codes; import com.docus.bgts.facade.IAfCollectTaskService; import com.docus.bgts.facade.IBgtsService; import com.docus.bgts.mapper.dbmysql.AfCollectAddMapper; +import com.docus.bgts.mapper.dbmysql.AfCollectTaskMapper; import com.docus.bgts.mapper.dbmysql.AfInterfaceCollectSubMapper; import com.docus.bgts.mapper.dbmysql.MrReportErrorMapper; import com.docus.bgts.mapper.dboracle.VDocumentPdfMapper; import com.docus.bgts.utils.*; import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.cxf.endpoint.Client; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -22,6 +24,8 @@ import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.ApplicationContext; +import org.springframework.context.support.ClassPathXmlApplicationContext; import org.springframework.stereotype.Service; @@ -53,6 +57,10 @@ public class BgtsServiceImpl implements IBgtsService { @Autowired AfCollectAddMapper afCollectAddMapper; + + @Autowired + AfCollectTaskMapper afCollectTaskMapper; + @Override public void collect(String empId) throws Exception { //通过empId获取报告单号集合 @@ -160,13 +168,19 @@ public class BgtsServiceImpl implements IBgtsService { String post; try { afCollectTaskService.insert(reportDownDto); + //String uploadConnector = String.valueOf(FileUtils.getJsonByName("uploadConnector")); post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class)); Map resMap = JSON.parseObject(post, Map.class); + logger.info(reportDownDto); if (String.valueOf(resMap.get("code")).equals("500")) { throw new RuntimeException(String.valueOf(resMap.get("msg"))); } } catch (Exception e) { + //打印错误日志 logger.info("采集出错:"+reportDownDto); + logger.info(e); + String stackTrace = ExceptionUtils.getStackTrace(e); + logger.info("错误信息----------"+stackTrace); addMrReportErrorLog(reportDownDto); e.printStackTrace(); } @@ -347,6 +361,42 @@ public class BgtsServiceImpl implements IBgtsService { } + /** + * 根据时间批量按需采集 + * @param startDate 开始时间 + * @param endDate 结束时间 + * @param collectorId 采集器编号 + */ + public void collectByDate(String startDate,String endDate,String collectorId){ + //通过日期查询patientId集合 + List patientIds = afCollectTaskService.getjzhByDate(startDate,endDate); + //通过patientId集合与采集器编号查询报告单号 + //List c1s = afCollectTaskMapper.getC1ByPatientId(patientIds,collectorId); + List c1s = afCollectTaskService.getC1ByPatientId(patientIds, collectorId); + //通过唯一报告单号查询patient_id + List patientIdByC1 = afCollectTaskService.getPatientIdByC1(c1s); + //通过patientId集合查询jzh + //List jzhs = afCollectTaskMapper.getJzhByPatientId(patientIds); + List jzhs = afCollectTaskService.getJzhByPatientId(patientIdByC1); + int i = -1; + //循环jzh与报告单号c1调用按需采集 + for (String c1 : c1s) { + try { + if (i select patient_id from docus_medicalrecord.t_basic - where jzh=#{jzh} + where jzh = #{jzh} + + + + + \ No newline at end of file