添加批量按需采集

docus-active-query-service_1.3
谭哲荣 3 years ago
parent c9d5000e2c
commit f3bc1e2b0e

@ -18,7 +18,7 @@
//(1:2ftp3)
"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

@ -147,6 +147,18 @@
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-collections4</artifactId>
<version>4.4</version>
</dependency>
</dependencies>
<build>

@ -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<String, String> 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<String, String> 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();
// }
// }
}

@ -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;
/**
* <p>
@ -22,4 +25,33 @@ public interface IAfCollectTaskService extends IService<AfCollectTask> {
void insert(ReportDownDto reportDownDto);
void updateInterfaceCollect(String collectSubId, int state);
/**
* jzh
* @param startDate
* @param endDate
* @return
*/
List<String> getjzhByDate(String startDate,String endDate);
/**
*
* @param patientIds
* @return
*/
List<String> getC1ByPatientId(List<String> patientIds,String collectorId);
/**
* patient_id
* @param C1s
* @return
*/
List<String> getPatientIdByC1(List<String> C1s);
/**
* jzh
* @param patientIds
* @return
*/
List<String> getJzhByPatientId(List<String> patientIds);
}

@ -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);
/**
*
*/

@ -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;
/**
* <p>
* Mapper
@ -20,4 +22,34 @@ public interface AfCollectTaskMapper extends BaseMapper<AfCollectTask> {
* @return
*/
String getpatientIdByEmpId(@Param("jzh") String empId);
/**
* jzh
* @param startDate
* @param endDate
* @return
*/
List<String> getjzhByDate(@Param("startDate") String startDate,@Param("endDate") String endDate);
/**
*
* @param patientIds
* @param collectorId
* @return
*/
List<String> getC1ByPatientId(@Param("patientIds") List<String> patientIds,@Param("collectorId") String collectorId);
/**
* patient_id
* @param C1s
* @return
*/
List<String> getPatientIdByC1(@Param("C1s") List<String> C1s);
/**
* jzh
* @param patientIds
* @return
*/
List<String> getJzhByPatientId(@Param("patientIds") List<String> patientIds);
}

@ -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<AfCollectTaskMapper, AfCollectTask> implements IAfCollectTaskService {
public static int MAX_SIZE_PER_TIME = 10;
@Autowired
TestMapper testMapper;
@ -119,4 +123,59 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
}
@Override
public List<String> getjzhByDate(String startDate, String endDate) {
List<String> patientIds = afCollectTaskMapper.getjzhByDate(startDate, endDate);
return patientIds;
}
@Override
public List<String> getC1ByPatientId(List<String> patientIds, String collectorId) {
List<List<String>> batchPatientIds = Lists.partition(patientIds, MAX_SIZE_PER_TIME);
List<String> c1s = new ArrayList<>();
for (List<String> batchPatientId : batchPatientIds) {
List<String> c1 = afCollectTaskMapper.getC1ByPatientId(batchPatientId, collectorId);
if (c1 != null && c1.size() != 0 ) {
for (String s : c1) {
c1s.add(s);
}
}
}
return c1s;
}
@Override
public List<String> getPatientIdByC1(List<String> C1s) {
List<List<String>> batchPatientIds = Lists.partition(C1s, MAX_SIZE_PER_TIME);
List<String> patientIds = new ArrayList<>();
for (List<String> batchC1s : batchPatientIds) {
List<String> patientId = afCollectTaskMapper.getPatientIdByC1(batchC1s);
if (patientId != null && patientId.size() != 0 ) {
for (String s : patientId) {
patientIds.add(s);
}
}
}
return patientIds;
}
@Override
public List<String> getJzhByPatientId(List<String> patientIds) {
List<String> jzhs = new ArrayList<>();
List<List<String>> batchPatientIds = Lists.partition(patientIds, MAX_SIZE_PER_TIME);
for (List<String> batchPatientId : batchPatientIds) {
List<String> jzh = afCollectTaskMapper.getJzhByPatientId(batchPatientId);
if (jzh != null && jzh.size() !=0 ) {
for (String s : jzh) {
jzhs.add(s);
}
}
}
return jzhs;
}
}

@ -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<String> patientIds = afCollectTaskService.getjzhByDate(startDate,endDate);
//通过patientId集合与采集器编号查询报告单号
//List<String> c1s = afCollectTaskMapper.getC1ByPatientId(patientIds,collectorId);
List<String> c1s = afCollectTaskService.getC1ByPatientId(patientIds, collectorId);
//通过唯一报告单号查询patient_id
List<String> patientIdByC1 = afCollectTaskService.getPatientIdByC1(c1s);
//通过patientId集合查询jzh
//List<String> jzhs = afCollectTaskMapper.getJzhByPatientId(patientIds);
List<String> jzhs = afCollectTaskService.getJzhByPatientId(patientIdByC1);
int i = -1;
//循环jzh与报告单号c1调用按需采集
for (String c1 : c1s) {
try {
if (i<c1s.size()) {
i++;
//System.err.println(c1s.get(i) + "--------" + jzhs.get(i));
//HttpUtils.get("127.0.0.1:"+port+"/collectByExamNo?emamNo="+c1+"&empId="+jzh);
collectByExamNo(c1s.get(i), jzhs.get(i));
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
/**
* web service
*
@ -365,5 +415,5 @@ public class BgtsServiceImpl implements IBgtsService {
return str;
}
}

@ -6,6 +6,40 @@
<select id="getpatientIdByEmpId" resultType="string">
select patient_id
from docus_medicalrecord.t_basic
where jzh=#{jzh}
where jzh = #{jzh}
</select>
<select id="getjzhByDate" resultType="string">
select patient_id
from docus_medicalrecord.t_basic
where dis_date between #{startDate} and #{endDate}
</select>
<select id="getC1ByPatientId" resultType="string">
select C1
from af_collect_task
where
patient_id in
<foreach collection="patientIds" open="(" close=")" item="patientId" separator=",">
#{patientId}
</foreach>
and sysflag=#{collectorId}
</select>
<select id="getJzhByPatientId" resultType="String">
select jzh
from docus_medicalrecord.t_basic
where
patient_id in
<foreach collection="patientIds" open="(" close=")" item="patientId" separator=",">
#{patientId}
</foreach>
</select>
<select id="getPatientIdByC1" resultType="String">
select patient_id
from af_collect_task
where
C1 in
<foreach collection="C1s" open="(" close=")" item="c1" separator=",">
#{c1}
</foreach>
</select>
</mapper>
Loading…
Cancel
Save