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;
+// @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 * 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);
}
- bgtsService.timerCollect();
- }*/
+ }
/**
* 增量同步程序
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