diff --git a/dataConfig/homeQualitySet.json b/dataConfig/homeQualitySet.json index ae4520c..d69edc8 100644 --- a/dataConfig/homeQualitySet.json +++ b/dataConfig/homeQualitySet.json @@ -22,9 +22,9 @@ //下载地址,&代表多个选其一 "downurl":"BASE64&ORIGINAL_URL", //分类id - "assortid":"", + "assortid":"Wiw213woq412awqe41", //系统id - "collectorid":"2", + "collectorid":"22", //获取分类id参数 "assortidParamKey":"DOCUMENT_TOPIC", //采集类型(文件来源 1:采集器;2:扫描生产软件) @@ -32,7 +32,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":[""], //可能存在存储基本数据不同情况的标签 @@ -53,6 +53,17 @@ //采集流水号名 "repealSerialnum":"UNIQUE_ID", //撤销接口 - "repoalConnector":"http://192.168.1.107:9291/api/down/cancel" + "repoalConnector":"http://192.9.100.171:9291/api/down/cancel", + + //---------住院接口配置部分----------- + "zyUrl":"http://192.9.100.32:9022/ktin/api/webservice/ChasWebService?wsdl", +// "zyUrl":"http://localhost:9000/services/api?wsdl", + "zyMethod":"ChasMessageServer", +// "zyMethod":"getPdfId", + "zyNamespance":"http://webservice.http.plugins.api.his.karrytech.com/", +// "zyNamespance":"http://server.webservice.example.com", + "zyDirectory":["PDF_DETAIL_INFO"], + "pdfUrl":"http://192.9.100.32:9022/ktin/api/flow/flow-mra-getpdffile?PDF_ID=", + "zysj":"2022-01-28" } \ No newline at end of file diff --git a/dataConfig/广东省中医院住院获取PDF-homeQualitySet.json b/dataConfig/广东省中医院住院获取PDF-homeQualitySet.json new file mode 100644 index 0000000..d69edc8 --- /dev/null +++ b/dataConfig/广东省中医院住院获取PDF-homeQualitySet.json @@ -0,0 +1,69 @@ +{ + //----------响应标签------------- + //外部结构,多层,隔开 + "ResHead":"Response,Result", + //响应代码 + "ResCode":"Code", + //响应消息 + "ResMsg":"Msg", + //成功编码 + "successCode":"1", + //失败编码 + "errorCode":"0", + + //唯一键目录结构数组,最高层为前面,最后一层为数据采集层,根节点不填 + "directory":[], + //患者主索引号 + "indexFlag":"VISITING_SERIAL_NUMBER", + //采集流水号 + "serialnum":"UNIQUE_ID", + //文件标题 + "filetitle":"DOCUMENT_TITLE", + //下载地址,&代表多个选其一 + "downurl":"BASE64&ORIGINAL_URL", + //分类id + "assortid":"Wiw213woq412awqe41", + //系统id + "collectorid":"22", + //获取分类id参数 + "assortidParamKey":"DOCUMENT_TOPIC", + //采集类型(文件来源 1:采集器;2:扫描生产软件) + "filesource":1, + //下载类型(1:服务器本地;2:ftp服务器;3:共享文件夹) + "filestoragetype":1, + //上传接口 + "uploadConnector":"http://192.9.100.171:9291/api/downplatform/report", + //基本数据存放处,根节点不填,最后一层为基本信息存放标签与doubleBasic配合 + "basicDirectory":[""], + //可能存在存储基本数据不同情况的标签 + "doubleBasic":["TestItemInfo","BioTestInfo"], + + //--------------采集操作判断撤销/新增--------------- + //是否开启采集操作判断撤销/新增 0:不开启,1:开启 默认不开启 + "isJudge":"0", + //判断标签存在目录,首个标签不填 + "judgeDirectory":[""], + //判定标签,值0-新增;1-撤回;2-修改 + "judgeIndex":"", + + + //--------撤销配置部分------------ + //采集流水号所在位置,根目录不填 + "repealDirectory":[""], + //采集流水号名 + "repealSerialnum":"UNIQUE_ID", + //撤销接口 + "repoalConnector":"http://192.9.100.171:9291/api/down/cancel", + + //---------住院接口配置部分----------- + "zyUrl":"http://192.9.100.32:9022/ktin/api/webservice/ChasWebService?wsdl", +// "zyUrl":"http://localhost:9000/services/api?wsdl", + "zyMethod":"ChasMessageServer", +// "zyMethod":"getPdfId", + "zyNamespance":"http://webservice.http.plugins.api.his.karrytech.com/", +// "zyNamespance":"http://server.webservice.example.com", + "zyDirectory":["PDF_DETAIL_INFO"], + "pdfUrl":"http://192.9.100.32:9022/ktin/api/flow/flow-mra-getpdffile?PDF_ID=", + "zysj":"2022-01-28" + +} \ No newline at end of file diff --git a/pom.xml b/pom.xml index 05bcd65..0795ca7 100644 --- a/pom.xml +++ b/pom.xml @@ -118,6 +118,27 @@ wsdl4j 1.6.2 + + org.apache.axis + axis + 1.4 + + + commons-discovery + commons-discovery + 0.2 + + + commons-logging + commons-logging + + + + + org.apache.axis + axis-jaxrpc + 1.4 + diff --git a/src/main/java/com/docus/bgts/config/MyScheduling.java b/src/main/java/com/docus/bgts/config/MyScheduling.java index bb10218..054b9b4 100644 --- a/src/main/java/com/docus/bgts/config/MyScheduling.java +++ b/src/main/java/com/docus/bgts/config/MyScheduling.java @@ -1,21 +1,68 @@ package com.docus.bgts.config; +import com.alibaba.fastjson.JSON; +import com.docus.bgts.entity.ReportDownDto; +import com.docus.bgts.entity.ReportDownPatientDto; +import com.docus.bgts.entity.ReportDownScanFileDto; +import com.docus.bgts.enums.Codes; +import com.docus.bgts.facade.IAfCollectTaskService; +import com.docus.bgts.facade.IMrReportErrorService; import com.docus.bgts.utils.FileUtils; import com.docus.bgts.utils.HttpUtils; +import com.docus.bgts.utils.XmlUtils; +import lombok.extern.slf4j.Slf4j; +import org.apache.axis.client.Call; +import org.apache.axis.encoding.XMLType; +import org.apache.axis.utils.ByteArrayOutputStream; +import org.apache.commons.lang3.StringUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; + +import org.dom4j.Element; +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 javax.xml.namespace.QName; +import javax.xml.rpc.ParameterMode; +import java.io.ByteArrayInputStream; +import java.io.PrintStream; import java.net.URISyntaxException; -import java.util.HashMap; -import java.util.Map; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +@Slf4j @Component public class MyScheduling { + public static Date oneDate; + public static String namespance = ""; + private static String methodName = ""; + private static String url; + private static String pdfUrl; + + static { + url = String.valueOf(FileUtils.getJsonByName("zyUrl")); + methodName = String.valueOf(FileUtils.getJsonByName("zyMethod")); + pdfUrl = String.valueOf(FileUtils.getJsonByName("pdfUrl")); + namespance = String.valueOf(FileUtils.getJsonByName("zyNamespance")); + SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd"); + try { + oneDate = fmt.parse(String.valueOf(FileUtils.getJsonByName("zysj"))); + } catch (ParseException e) { + e.printStackTrace(); + } + } + + @Autowired + private IMrReportErrorService mrReportErrorService; + + @Autowired + private IAfCollectTaskService afCollectTaskService; + @Value("${beat.url}") private String beatUrl; @@ -37,4 +84,141 @@ public class MyScheduling { } } + //10分钟执行一次 + @Scheduled(fixedRate = 1000 * 60 * 30) + public void ruyuan() { + log.info("----------开始采集------------"); + log.info("-----采集时间:"+oneDate); + Date twoDate = new Date(); + //获取jzh列表 + List jzhs = afCollectTaskService.listJZHByDate(oneDate, twoDate); + int size = jzhs.size(); + log.info("-------本次采集数:" + size); + if(size==0){ + oneDate=twoDate; + log.info("------------采集结束-----------------"); + return; + } + Object[] params; + List keys = new ArrayList<>(); + keys.add("action"); + keys.add("message"); + XmlUtils xmlUtils; + List zyDirectory = (List) FileUtils.getJsonByName("zyDirectory"); + String assortid = String.valueOf(FileUtils.getJsonByName("assortid")); + String collectorid = String.valueOf(FileUtils.getJsonByName("collectorid")); + String filesource = String.valueOf(FileUtils.getJsonByName("filesource")); + String filestoragetype = String.valueOf(FileUtils.getJsonByName("filestoragetype")); + String res; + Element element; + Map headMap = new HashMap<>(); + headMap.put("Content-Type", "application/json"); + for (String jzh : jzhs) { + try { + params = new Object[]{"flow-mra-queryencounterpdf", "\n" + + "\n" + + "" + jzh + "\n" + + "\n" + + ""}; + res = requestFunctionWebService(params, url, methodName, namespance, keys); + log.info("返回值:" + res); + xmlUtils = new XmlUtils(new ByteArrayInputStream(res.getBytes("UTF-8"))); + element = xmlUtils.getElement(zyDirectory); + List items = element.elements("ITEM"); + if (items == null || items.size() <= 0) { + throw new RuntimeException("查询到的信息不存在"); + } + ReportDownDto reportDownDto = new ReportDownDto(); + reportDownDto.setCollectorid(collectorid); + reportDownDto.setAssortid(assortid); + + ReportDownPatientDto reportDownPatientDto = new ReportDownPatientDto(); + reportDownPatientDto.setJzh(jzh); + reportDownDto.setPatient(reportDownPatientDto); + List scanFileDtos = new ArrayList<>(); + ReportDownScanFileDto reportDownScanFileDto; + + for (Element item : items) { + Element pdfId = item.element("PDF_ID"); + if (pdfId != null && StringUtils.isNotBlank(pdfId.getText())) { + //采集流水号 + String pdfIdText = pdfId.getText(); + //文件标题 + String fileTitle = item.element("MED_REC_CAT_NAME").getText(); + //url地址 + String pdf = pdfUrl + pdfIdText; + + reportDownScanFileDto = new ReportDownScanFileDto(); + reportDownScanFileDto.setFiletitle(fileTitle); + reportDownScanFileDto.setFilesource(Integer.parseInt(filesource)); + reportDownScanFileDto.setFilestoragetype(Integer.parseInt(filestoragetype)); + reportDownScanFileDto.setSerialnum(pdfIdText); + reportDownScanFileDto.setDownurl(pdf); + scanFileDtos.add(reportDownScanFileDto); + } else { + log.info("记账号:", jzh + "不存在pdfId"); + size--; + throw new RuntimeException("记账号:" + jzh + "不存在pdfId"); + } + } + log.info("文件信息:" + scanFileDtos); + reportDownDto.setScanfiles(scanFileDtos); + afCollectTaskService.insert(reportDownDto); + String post = ""; + logger.info("--------执行上传功能----------"); + Map paramMap = JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class); + logger.info("上传参数:" + paramMap); + post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, paramMap); +// String post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), map, headMap); + if (StringUtils.isBlank(post)) { + logger.info("--------上传时出现错误,可能是文件服务没有启动----------"); + throw new RuntimeException("上传时出现错误,可能是文件服务没有启动"); + } + Map resMap = JSON.parseObject(post, Map.class); + if (String.valueOf(resMap.get("code")).equals("500")) { + throw new RuntimeException(String.valueOf(resMap.get("msg"))); + } else { + logger.info("----------执行成功,当前最后更新日期" + twoDate + "-----------"); + } + + } catch (Exception e) { + log.info(e.getMessage()); + e.printStackTrace(); + size--; + mrReportErrorService.insert(jzh); + } + } + log.info("-------本次成功采集数:" + size); + oneDate = twoDate; + } + + private String requestFunctionWebService(Object[] params, + String url, + String methodName, + String namespance, + List parameterNames) { + String result = ""; + if (null != params) { + try { + org.apache.axis.client.Service service = new org.apache.axis.client.Service(); + Call call = (Call) service.createCall(); + call.setTargetEndpointAddress(url); + call.setOperationName(new QName(namespance, methodName)); + for (int i = 0; i < parameterNames.size(); i++) { + call.addParameter(parameterNames.get(i), XMLType.XSD_STRING, ParameterMode.IN);//接口的参数 + } + call.setReturnType(XMLType.XSD_STRING);//设置返回类型 + result = (String) call.invoke(params); + } catch (Exception e) { + e.printStackTrace(); + //方法名 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + e.printStackTrace(new PrintStream(baos)); + String exception = baos.toString(); + log.error("requestFunctionWebService请求接口异常:" + exception); + } + } + return result; + } + } diff --git a/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java index 4e708f3..0d05667 100644 --- a/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java +++ b/src/main/java/com/docus/bgts/facade/IAfCollectTaskService.java @@ -7,6 +7,9 @@ import com.docus.bgts.entity.CanlcelDto; import com.docus.bgts.entity.ReportDownDto; import com.docus.bgts.entity.ZdAssort; +import java.util.Date; +import java.util.List; + /** *

* 病案采集任务 服务类 @@ -25,6 +28,8 @@ public interface IAfCollectTaskService extends IService { void updateInterfaceCollect(String collectSubId, int state); + List listJZHByDate(Date date1,Date date2); + /** * 撤销文件功能 * @param canlcelDto diff --git a/src/main/java/com/docus/bgts/mapper/AfCollectTaskMapper.java b/src/main/java/com/docus/bgts/mapper/AfCollectTaskMapper.java index 6680342..e451ca1 100644 --- a/src/main/java/com/docus/bgts/mapper/AfCollectTaskMapper.java +++ b/src/main/java/com/docus/bgts/mapper/AfCollectTaskMapper.java @@ -6,6 +6,9 @@ import com.docus.bgts.entity.AfCollectTask; import com.docus.bgts.entity.ZdAssort; import org.apache.ibatis.annotations.Param; +import java.util.Date; +import java.util.List; + /** *

* 病案采集任务 Mapper 接口 @@ -15,6 +18,8 @@ import org.apache.ibatis.annotations.Param; * @since 2021-05-07 */ public interface AfCollectTaskMapper extends BaseMapper { + + List listJZHByDate(@Param("date1") Date date1, @Param("date2") Date date2); /** * 获取病案id通过报告唯一单号 * @param empId diff --git a/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectSubMapper.java b/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectSubMapper.java index 016177b..4976f09 100644 --- a/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectSubMapper.java +++ b/src/main/java/com/docus/bgts/mapper/AfInterfaceCollectSubMapper.java @@ -2,6 +2,11 @@ package com.docus.bgts.mapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.docus.bgts.entity.AfInterfaceCollectSub; +import org.apache.ibatis.annotations.Param; + +import java.util.Date; +import java.util.List; public interface AfInterfaceCollectSubMapper extends BaseMapper { + } diff --git a/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java index b3bb279..779490b 100644 --- a/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java +++ b/src/main/java/com/docus/bgts/service/AfCollectTaskServiceImpl.java @@ -123,6 +123,11 @@ public class AfCollectTaskServiceImpl extends ServiceImpl listJZHByDate(Date date1, Date date2) { + return afCollectTaskMapper.listJZHByDate(date1, date2); + } + @Override public void invokeRepoalFile(CanlcelDto canlcelDto) throws Exception { //上传接口地址 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 8ea2999..7045fe6 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,5 +1,5 @@ server: - port: 9701 + port: 9205 # http mybatis-plus: @@ -16,7 +16,7 @@ beat: system: code: "EmrDocAr" - prop: 9801 + prop: 9805 # web service diff --git a/src/main/resources/config/application-广东省中医院住院获取PDF.yml b/src/main/resources/config/application-广东省中医院住院获取PDF.yml new file mode 100644 index 0000000..7045fe6 --- /dev/null +++ b/src/main/resources/config/application-广东省中医院住院获取PDF.yml @@ -0,0 +1,28 @@ +server: + port: 9205 +# http + +mybatis-plus: + configuration: + map-underscore-to-camel-case: true + call-setters-on-nulls: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + field-strategy: NOT_EMPTY + db-type: MYSQL +beat: + url: http://localhost:9399/beat + +system: + code: "EmrDocAr" + prop: 9805 +# web service + + +spring: + datasource: + 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 \ No newline at end of file diff --git a/src/main/resources/mapper/AfCollectTaskMapper.xml b/src/main/resources/mapper/AfCollectTaskMapper.xml index fcb1c3f..caa87a4 100644 --- a/src/main/resources/mapper/AfCollectTaskMapper.xml +++ b/src/main/resources/mapper/AfCollectTaskMapper.xml @@ -3,6 +3,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> + + +