新增手麻采集器需求

docus-active-query-service_1.3
lzy 4 years ago
parent 9c565e505d
commit 11768ae318

@ -10,9 +10,9 @@
//
"downurl":"IMAGE_URL",
//id
"assortid":"63E20FC9AAB74C5FB6446083EBA5607D",
"assortid":"15E7FE7803F545CB81390BC88E725240",
//id
"collectorid":"3",
"collectorid":"5",
//( 1:2)
"filesource":1,
//(1:2ftp3)
@ -36,6 +36,10 @@
//
"bgtsDetailParam":["Request","Msg","EXAM_NO"],
//
"bgtsDetailRespon":["MsgInfo","Msg","ReportInfo"]
"bgtsDetailRespon":["MsgInfo","Msg","ReportInfo"],
//
"startCollectTime":"2016-04-11",
// 1: 0 :
"isStartCollect":"0"
}

@ -0,0 +1,38 @@
package com.docus.bgts.config;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.utils.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
@Component
public class MyConstruct {
@Autowired
IBgtsService bgtsService;
/**
*
*/
@PostConstruct
public void startCollectAll(){
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
String startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime"));
String isStartCollect = String.valueOf(FileUtils.getJsonByName("isStartCollect"));
if(collectorid.equals("5")&& StringUtils.isNotBlank(startCollectTime)&&isStartCollect!=null&&isStartCollect.equals("1")){
bgtsService.collectAll();
}
}
//在spring容器关闭时释放
@PreDestroy
public void destroy() {
//系统运行结束
}
}

@ -1,14 +1,14 @@
package com.docus.bgts.config;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;
@ -17,22 +17,41 @@ public class MyScheduling {
@Value("${beat.url}")
private String beatUrl;
@Autowired
IBgtsService bgtsService;
private Logger logger = LogManager.getLogger(MyScheduling.class);
//5分钟执行一次
@Scheduled(fixedRate = 1000 * 60 * 5)
public void beat() {
logger.info("------------心跳开始---------------");
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
if(collectorid.equals("5")){
return;
}
Map<String, String> params = new HashMap<>();
params.put("code", String.valueOf(FileUtils.getJsonByName("collectorid")));
try {
HttpUtils.get(beatUrl, params);
} catch (URISyntaxException e) {
} catch (Exception e) {
e.printStackTrace();
logger.info("心跳推送出错,可能是住院服务没有开启");
} finally {
logger.info("-------------心跳结束---------------");
}
}
/**
*
* 10
*/
@Scheduled(fixedRate = 1000 * 60 * 10)
public void collect(){
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
if(!collectorid.equals("5")){
return;
}
bgtsService.timerCollect();
}
}

@ -0,0 +1,21 @@
package com.docus.bgts.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@ApiModel("采集日志")
@Data
public class AfCollectAdd {
@ApiModelProperty("id")
@TableId(value = "id",type = IdType.ASSIGN_ID)
private Long id;
@ApiModelProperty("上次更新时间")
private Date beginStageDate;
@ApiModelProperty("分类")
private Integer classify;
}

@ -0,0 +1,23 @@
package com.docus.bgts.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel("错误日志表")
public class MrReportError {
@ApiModelProperty(value = "id")
@TableId(value = "id", type = IdType.ASSIGN_ID)
private Long id;
@ApiModelProperty("上报信息")
private String xml;
@ApiModelProperty("上报类型")
private Integer reportType;
@ApiModelProperty("上报时间")
private Date createTime;
}

@ -1,4 +1,16 @@
package com.docus.bgts.entity;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import java.util.Date;
@Data
@ApiModel("手麻采集器")
public class VDocumentPdf {
private String ;
private String ;
private String WEB_ADDRESS;
private String PATIENT_ID;
private Date ARCHIVE_DATE_TIME;
}

@ -1,8 +1,4 @@
package com.docus.bgts.facade;
import java.io.UnsupportedEncodingException;
import java.rmi.RemoteException;
public interface IBgtsService {
/**
*
@ -16,4 +12,14 @@ public interface IBgtsService {
* @param empId
*/
void collectByExamNo(String emamNo, String empId) throws Exception;
/**
*
*/
void collectAll();
/**
*
*/
void timerCollect();
}

@ -0,0 +1,13 @@
package com.docus.bgts.mapper.dbmysql;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.docus.bgts.entity.AfCollectAdd;
import java.util.Date;
public interface AfCollectAddMapper extends BaseMapper<AfCollectAdd> {
/**
*
*/
Date getTimeByAdd();
}

@ -0,0 +1,8 @@
package com.docus.bgts.mapper.dbmysql;
import com.docus.bgts.entity.MrReportError;
import org.apache.ibatis.annotations.Param;
public interface MrReportErrorMapper {
void insert(@Param("mrReportError") MrReportError mrReportError);
}

@ -0,0 +1,23 @@
package com.docus.bgts.mapper.dboracle;
import com.docus.bgts.entity.VDocumentPdf;
import org.apache.ibatis.annotations.Param;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;
public interface VDocumentPdfMapper {
/**
*
* @param current
* @param size
* @param startCollectTime
* @param date
* @return
*/
List<VDocumentPdf> listCollectPage(@Param("current") int current,
@Param("size") int size,
@Param("startTime") String startCollectTime,
@Param("endTime") String date);
}

@ -47,7 +47,6 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
return patientId;
}
@Transactional
@Override
public void insert(ReportDownDto reportDownDto) {
AfCollectTask afCollectTask;
@ -77,13 +76,13 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
}
} else {
//存在就修改
// afCollectTask.setPatientId(patientId);
// afCollectTask.setSysflag(reportDownDto.getCollectorid());
// afCollectTask.setState("0");
// afCollectTask.setSyncTime(date);
// afCollectTask.setC1(scanfile.getSerialnum());
// afCollectTask.setC2(scanfile.getFiletitle());
// save = afCollectTaskMapper.updateById(afCollectTask);
afCollectTask.setPatientId(patientId);
afCollectTask.setSysflag(reportDownDto.getCollectorid());
afCollectTask.setState("0");
afCollectTask.setSyncTime(date);
afCollectTask.setC1(scanfile.getSerialnum());
afCollectTask.setC2(scanfile.getFiletitle());
save = afCollectTaskMapper.updateById(afCollectTask);
}
scanfile.setTaskid(afCollectTask.getId());
}

@ -3,13 +3,14 @@ package com.docus.bgts.service;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.docus.bgts.entity.AfCollectTask;
import com.docus.bgts.entity.ReportDownDto;
import com.docus.bgts.entity.ReportDownPatientDto;
import com.docus.bgts.entity.ReportDownScanFileDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.docus.bgts.entity.*;
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.MrReportErrorMapper;
import com.docus.bgts.mapper.dboracle.VDocumentPdfMapper;
import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
import com.docus.bgts.utils.JAXDynamicClientFactory;
@ -24,11 +25,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.io.ByteArrayInputStream;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@Service
public class BgtsServiceImpl implements IBgtsService {
@ -37,17 +38,30 @@ public class BgtsServiceImpl implements IBgtsService {
@Value("${ws.localMethod}")
private String wsLocalMethod;
private Logger logger= LogManager.getLogger(BgtsServiceImpl.class);
private Logger logger = LogManager.getLogger(BgtsServiceImpl.class);
@Autowired
IAfCollectTaskService afCollectTaskService;
@Autowired
VDocumentPdfMapper vDocumentPdfMapper;
@Autowired
MrReportErrorMapper mrReportErrorMapper;
@Autowired
AfCollectAddMapper afCollectAddMapper;
@Override
public void collect(String empId) throws Exception {
//通过empId获取报告单号集合
List<String[]> exams = getExamNo(empId);
//获取插入表数据
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
//插入文件af_collect_task表数据
afCollectTaskService.insert(reportDownDto);
//通过报告单号集合采集
collectExams(exams, empId);
collectExams(exams, empId,reportDownDto);
}
@Override
@ -60,7 +74,126 @@ public class BgtsServiceImpl implements IBgtsService {
strings[1] = afCollectTask.getC2();
List<String[]> exams = new ArrayList<>();
exams.add(strings);
collectExams(exams, empId);
//获取插入表数据
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
collectExams(exams, empId,reportDownDto);
}
@Override
public void collectAll() {
logger.info("----------全量采集开始-----------");
//1.获取最早采集日期
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startCollectTime = null;
startCollectTime = String.valueOf(FileUtils.getJsonByName("startCollectTime"));
logger.info("----------采集初始时间:" + startCollectTime + " -------------------");
//当前日期
Date date = new Date();
String dateStr = simpleDateFormat.format(date);
collectByDates(startCollectTime, dateStr);
//更新采集时间
addAfCollectAdd(date);
logger.info("--------------全量采集结束------------------");
}
/**
*
*
* @param startDate
* @param endDate
*/
private void collectByDates(String startDate, String endDate) {
//页码
int current;
//每页10条数据
int size;
List<VDocumentPdf> vDocumentPdfs;
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
String assortid = String.valueOf(FileUtils.getJsonByName("assortid"));
int filesource = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource")));
int filestoragetype = Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype")));
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
//2.获取第一页10条数据开始采集
for (current = 1; ; current++) {
size = 10 * current;
vDocumentPdfs = vDocumentPdfMapper.listCollectPage(current, size, startDate, endDate);
if (null == vDocumentPdfs || vDocumentPdfs.size() <= 0) {
break;
}
vDocumentPdfs.stream().forEach(vDocumentPdf -> {
ReportDownDto reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorid);
reportDownDto.setAssortid(assortid);
ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto();
reportDownPatientDto.setJzh(vDocumentPdf.getPATIENT_ID());
reportDownDto.setPatient(reportDownPatientDto);
List<ReportDownScanFileDto> reportDownScanFileDtos = new ArrayList<>();
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setDownurl(vDocumentPdf.getWEB_ADDRESS());
reportDownScanFileDto.setFilestoragetype(filestoragetype);
reportDownScanFileDto.setFilesource(filesource);
reportDownScanFileDto.setFiletitle(vDocumentPdf.get());
reportDownScanFileDto.setSerialnum(vDocumentPdf.get());
reportDownScanFileDtos.add(reportDownScanFileDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
afCollectTaskService.insert(reportDownDto);
String post = null;
try {
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);
if (String.valueOf(resMap.get("code")).equals("500")) {
throw new RuntimeException(String.valueOf(resMap.get("msg")));
}
} catch (Exception e) {
addMrReportErrorLog(reportDownDto);
e.printStackTrace();
}
});
}
}
@Override
public void timerCollect() {
logger.info("------手麻采集器开始采集---------");
//1.获取上次采集时间
Date time = afCollectAddMapper.getTimeByAdd();
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startDate = simpleDateFormat.format(time);
//当前日期
Date date = new Date();
String endDate = simpleDateFormat.format(date);
collectByDates(startDate, endDate);
//更新采集时间
addAfCollectAdd(date);
logger.info("--------手麻采集器结束采集------");
}
/**
*
*/
private void addAfCollectAdd(Date date) {
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
AfCollectAdd afCollectAdd = new AfCollectAdd();
afCollectAdd.setBeginStageDate(date);
afCollectAddMapper.update(afCollectAdd,new QueryWrapper<AfCollectAdd>().eq("classify",collectorid));
}
/**
*
*
* @param reportDownDto
*/
private void addMrReportErrorLog(ReportDownDto reportDownDto) {
MrReportError mrReportError = new MrReportError();
mrReportError.setCreateTime(new Date());
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
mrReportError.setReportType(Integer.parseInt(collectorid));
mrReportError.setXml(JSON.toJSONString(reportDownDto));
mrReportErrorMapper.insert(mrReportError);
}
/**
@ -69,11 +202,7 @@ public class BgtsServiceImpl implements IBgtsService {
* @param exams
* @param empId
*/
private void collectExams(List<String[]> exams, String empId) throws Exception {
//获取插入表数据
ReportDownDto reportDownDto = getUrlCreateReportDto(exams, empId);
//插入文件af_collect_task表数据
afCollectTaskService.insert(reportDownDto);
private void collectExams(List<String[]> exams, String empId,ReportDownDto reportDownDto) throws Exception {
// reportDownDto.setTaskid(id);
//调用上传接口
Map<String, Object> headMap = new HashMap<>();
@ -141,7 +270,7 @@ public class BgtsServiceImpl implements IBgtsService {
// }
// }
Element esbEntry = document.addElement("ESBEntry");
Element request = HttpUtils.reqElement(esbEntry,0);
Element request = HttpUtils.reqElement(esbEntry, 0);
request.addElement("EXAM_NO").setText(exam[0]);
String resXml = invokeWs(esbEntry.asXML());
//解析XML
@ -180,9 +309,9 @@ public class BgtsServiceImpl implements IBgtsService {
// }
// }
Element esbEntry = document.addElement("ESBEntry");
Element reqElement = HttpUtils.reqElement(esbEntry,1);
Element reqElement = HttpUtils.reqElement(esbEntry, 1);
reqElement.addElement("EMPI_ID").setText(empId);
logger.info("-------根据患者主索引号查询多个报告单号,地址:"+wsUrl+",方法:"+wsLocalMethod+"---------");
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
String xml = esbEntry.asXML();
logger.info("---------------------------");
logger.info(xml);
@ -220,6 +349,7 @@ public class BgtsServiceImpl implements IBgtsService {
/**
* web service
*
* @param xml
* @return
* @throws Exception
@ -239,11 +369,11 @@ public class BgtsServiceImpl implements IBgtsService {
// call.setTimeout(100000);//超时
// String result = (String) call.invoke(object);// 远程调用
// System.out.println(result);
logger.info("-----\n客户端调用服务端"+wsUrl+"方法:"+wsLocalMethod+"\n------------");
logger.info("-----\n客户端调用服务端" + wsUrl + "方法:" + wsLocalMethod + "\n------------");
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
Client client = dcf.createClient(wsUrl);
Object[] objects = client.invoke(wsLocalMethod,xml);
String str = objects[0].toString();
Object[] objects = client.invoke(wsLocalMethod, xml);
String str = objects[0].toString();
logger.info("----------结果---------");
logger.info(str);
return str;

@ -0,0 +1,16 @@
package com.docus.bgts.web;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class FilterConfig {
@Bean
public FilterRegistrationBean getFilter(){
FilterRegistrationBean bean=new FilterRegistrationBean(new MyFilter());
return bean;
}
}

@ -0,0 +1,33 @@
package com.docus.bgts.web;
import com.docus.bgts.utils.FileUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
@WebFilter(filterName = "myFilter",urlPatterns = {"/*"})
public class MyFilter implements Filter {
private Logger logger= LogManager.getLogger();
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
logger.info("拦截开始");
String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid"));
if(collectorid.equals("5")){
logger.info("当前请求已被拦截...");
}else {
filterChain.doFilter(servletRequest,servletResponse);
}
}
@Override
public void destroy() {
}
}

@ -24,7 +24,7 @@ spring:
driver-class-name: com.mysql.cj.jdbc.Driver
username: docus
password: docus702
url: jdbc:mysql://db.docus.cn:3306/docus_archivefile?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
url: jdbc:mysql://db.docus.cn:3306/docus_archivefile?characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
oracle-docus:
driver-class-name: oracle.jdbc.driver.OracleDriver
url: jdbc:oracle:thin:@192.168.117.100:1521:helowin

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.bgts.mapper.dbmysql.AfCollectAddMapper">
<select id="getTimeByAdd" resultType="date">
select begin_stage_date from af_collect_add where classify=5 limit 0,1
</select>
</mapper>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.bgts.mapper.dbmysql.MrReportErrorMapper">
<insert id="insert">
insert into docus_medicalrecord.mr_report_error(xml,report_type,create_time)
values(#{mrReportError.xml},#{mrReportError.reportType},#{mrReportError.createTime})
</insert>
</mapper>

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.docus.bgts.mapper.dboracle.VDocumentPdfMapper">
<select id="listCollectPage" resultType="com.docus.bgts.entity.VDocumentPdf">
SELECT
*
FROM
(
SELECT
"NAVICAT_TABLE".*,
ROWNUM "NAVICAT_ROWNUM"
FROM
(
SELECT
"DOCUS"."v_document_pdf"."手术申请单号",
"DOCUS"."v_document_pdf"."文书名",
"DOCUS"."v_document_pdf"."WEB_ADDRESS",
"DOCUS"."v_document_pdf"."PATIENT_ID",
"DOCUS"."v_document_pdf"."ARCHIVE_DATE_TIME",
ROWID "NAVICAT_ROWID"
FROM
"DOCUS"."v_document_pdf"
WHERE
"ARCHIVE_DATE_TIME" BETWEEN TO_DATE ( #{startTime}, 'YYYY-MM-DD HH24:MI:SS' )
AND TO_DATE ( #{endTime}, 'YYYY-MM-DD HH24:MI:SS' )
) "NAVICAT_TABLE"
WHERE
ROWNUM &lt;= ${size} ) WHERE "NAVICAT_ROWNUM" &gt;= ${current}
</select>
</mapper>
Loading…
Cancel
Save