版本1 http采集器

docus-active-query-service_1.3
lzy 4 years ago
parent fd86f80e5b
commit 9ad4a9eb07

@ -0,0 +1,45 @@
<ESBEntry>
<AccessControl>
<SysFlag>1</SysFlag>
<UserName>WZHBAGL</UserName>
<Password>WZHBAGL_1127</Password>
<Fid>BS07002</Fid>
<OrderNo>BS07002S51001</OrderNo>
<SUBOR_HOSPITAL_DISTRICT>GZ</SUBOR_HOSPITAL_DISTRICT>
</AccessControl>
<MessageHeader>
<Fid>BS07002</Fid>
<OrderNo>BS07002S51001</OrderNo>
<SourceSysCode>S51</SourceSysCode>
<TargetSysCode>S00</TargetSysCode>
<MsgDate>2021-12-23 09:34:31</MsgDate>
</MessageHeader>
<RequestOption>
<triggerData>0</triggerData>
<dataAmount>500</dataAmount>
</RequestOption>
<MsgInfo flag="1">
<Msg/>
<distinct value="0"/>
<query item="WS_INPUT" compy=" = " value=" 1 " splice="AND"/>
<query_ws action="Q_WS_JCBGLBCX">
<content>
<Request>
<Msg>
<VUID/>
<OUTHOSP_INDEX_NO/>
<OUTHOSP_NO/>
<INHOSP_INDEX_NO></INHOSP_INDEX_NO>
<INHOSP_NO>1123</INHOSP_NO>
<EMPI_ID></EMPI_ID>
<BEGIN_DATE>20211213</BEGIN_DATE>
<END_DATE>20211222</END_DATE>
</Msg>
</Request>
</content>
</query_ws>
</MsgInfo>
<GroupInfo flag="0">
<AS ID="" linkField=""/>
</GroupInfo>
</ESBEntry>

@ -47,5 +47,4 @@
"tableName":"V_DOCUMENT_PDF",
//oracle
"collectTimeName":"ARCHIVE_DATE_TIME"
}

@ -4,6 +4,8 @@ package com.docus.bgts.controller;
import com.docus.bgts.entity.CommonResult;
import com.docus.bgts.facade.IAfCollectTaskService;
import com.docus.bgts.facade.IBgtsService;
import com.docus.bgts.utils.FileUtils;
import com.docus.bgts.utils.XmlUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@ -11,11 +13,15 @@ import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
@Api(value = "采集接口", tags = "采集接口")
@RestController
@ -29,10 +35,6 @@ public class BgtsController {
@Autowired
IAfCollectTaskService afCollectTaskService;
@GetMapping("/test1")
public String test1(){
return afCollectTaskService.getA();
}
@ApiOperation("采集接口")
@ApiImplicitParams({
@ -50,7 +52,7 @@ public class BgtsController {
e.printStackTrace();
try {
afCollectTaskService.updateInterfaceCollect(collectSubId, 0);
}catch (Exception e1){
}catch (Exception e1) {
return CommonResult.failed(e1.getMessage());
}
return CommonResult.failed(e.getMessage());

@ -28,6 +28,8 @@ public enum Codes {
UPLOAD("0","uploadConnector"),
SMCODE ("5","手麻代码"),
ZZCODE ("15","重症代码"),
//xml地址
REQUEST_XML("0","\\dataConfig\\RequestParams.xml"),
//患者主索引号
EMP_ID("0","indexFlag"),
//错误日志编号

@ -22,6 +22,4 @@ public interface IAfCollectTaskService extends IService<AfCollectTask> {
void insert(ReportDownDto reportDownDto);
void updateInterfaceCollect(String collectSubId, int state);
String getA();
}

@ -112,12 +112,5 @@ public class AfCollectTaskServiceImpl extends ServiceImpl<AfCollectTaskMapper, A
}
@Override
public String getA() {
System.out.println(afCollectTaskMapper.getpatientIdByEmpId("5555566666"));
System.out.println(afCollectTaskMapper.selectList(new QueryWrapper<>()));
List<String> a = testMapper.getA();
return Arrays.asList(a).toString();
}
}

@ -149,7 +149,7 @@ public class BgtsServiceImpl implements IBgtsService {
reportDownScanFileDto.setDownurl(String.valueOf(map.get(downurl)));
reportDownScanFileDto.setFilestoragetype(filestoragetype);
reportDownScanFileDto.setFilesource(filesource);
reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(new Date().getTime()):String.valueOf(map.get(filetitle)));
reportDownScanFileDto.setFiletitle(map.get(filetitle)==null?"重症"+(System.currentTimeMillis()):String.valueOf(map.get(filetitle)));
reportDownScanFileDto.setSerialnum(StringUtils.isNotBlank(String.valueOf(map.get(serialnum)))?String.valueOf(map.get(serialnum)):String.valueOf(idWorker.nextId()));
reportDownScanFileDtos.add(reportDownScanFileDto);
reportDownDto.setScanfiles(reportDownScanFileDtos);
@ -217,7 +217,6 @@ public class BgtsServiceImpl implements IBgtsService {
* @param empId
*/
private void collectExams(List<String[]> exams, String empId,ReportDownDto reportDownDto) throws Exception {
// reportDownDto.setTaskid(id);
//调用上传接口
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
@ -269,30 +268,12 @@ public class BgtsServiceImpl implements IBgtsService {
ReportDownScanFileDto reportDownScanFileDto = new ReportDownScanFileDto();
reportDownScanFileDto.setSerialnum(exam[0]);
reportDownScanFileDto.setFiletitle(exam[1]);
// 1、创建document对象
Document document = DocumentHelper.createDocument();
// Element request = document.addElement("Request");
// Element msg = request.addElement("Msg");
// msg.addElement("EXAM_NO").setText(exam[0]);
// List<String> bgtsDetailParam = (List<String>) FileUtils.getJsonByName("bgtsDetailParam");
// Element request = null;
// for (int i = 0; i < bgtsDetailParam.size(); i++) {
// if (i == 0) {
// request = document.addElement(bgtsDetailParam.get(i));
// } else {
// request = request.addElement(bgtsDetailParam.get(i));
// }
// }
Element esbEntry = document.addElement("ESBEntry");
Element request = HttpUtils.reqElement(esbEntry, 0);
request.addElement("EXAM_NO").setText(exam[0]);
String resXml = invokeWs(esbEntry.asXML());
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlPath());
Element esbEntry = reqXmlUtils.getMsgElement();
esbEntry.element("EXAM_NO").setText(exam[0]);
String resXml = invokeWs(reqXmlUtils.getDocument().asXML());
//解析XML
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
// List<String> dis = new ArrayList<>();
// dis.add("MsgInfo");
// dis.add("Msg");
// dis.add("ReportInfo");
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsDetailRespon");
//数据所在节点
Element element = xmlUtils.getElement(dis);
@ -308,25 +289,12 @@ public class BgtsServiceImpl implements IBgtsService {
*/
private List<String[]> getExamNo(String empId) throws Exception {
List<String[]> exams = new ArrayList<>();
// 1、创建document对象
Document document = DocumentHelper.createDocument();
// Element request = document.addElement("Request");
// Element msg = request.addElement("Msg");
// msg.addElement("EMPI_ID").setText(empId);
// List<String> bgtsParam = (List<String>) FileUtils.getJsonByName("bgtsParam");
// Element request = null;
// for (int i = 0; i < bgtsParam.size(); i++) {
// if (i == 0) {
// request = document.addElement(bgtsParam.get(i));
// } else {
// request = request.addElement(bgtsParam.get(i));
// }
// }
Element esbEntry = document.addElement("ESBEntry");
Element reqElement = HttpUtils.reqElement(esbEntry, 1);
reqElement.addElement("EMPI_ID").setText(empId);
XmlUtils reqXmlUtils=new XmlUtils(FileUtils.getXmlPath());
Element reqElement = reqXmlUtils.getMsgElement();
reqElement.element("INHOSP_NO").setText(empId);
logger.info("-------根据患者主索引号查询多个报告单号,地址:" + wsUrl + ",方法:" + wsLocalMethod + "---------");
String xml = esbEntry.asXML();
String xml = reqXmlUtils.getDocument().asXML();
logger.info("---------------------------");
logger.info(xml);
logger.info("----------------------------");
@ -336,9 +304,6 @@ public class BgtsServiceImpl implements IBgtsService {
logger.info("-----------------------------");
//解析XML
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(resXml.getBytes("UTF-8")));
// List<String> dis = new ArrayList<>();
// dis.add("MsgInfo");
// dis.add("Msg");
List<String> dis = (List<String>) FileUtils.getJsonByName("bgtsRespon");
//数据所在节点
Element element = xmlUtils.getElement(dis);
@ -369,20 +334,6 @@ public class BgtsServiceImpl implements IBgtsService {
* @throws Exception
*/
public String invokeWs(String xml) throws Exception {
// Object[] object = new Object[]{xml};//请求参数
// org.apache.axis.client.Service service = new org.apache.axis.client.Service();
// Call call = (Call) service.createCall();
// call.setTargetEndpointAddress(wsUrl);// 远程调用路径
// // 调用的命名空间和方法名
//// call.setOperationName(new QName(wsNamespaceUrl, wsLocalMethod));
// call.setOperationName(wsLocalMethod);
// call.setUseSOAPAction(true);
//// call.setSOAPActionURI(wsNamespaceUrl + "pushSurveyReport");
// call.addParameter("arg0", XMLType.XSD_STRING, ParameterMode.IN);
// call.setReturnType(XMLType.XSD_STRING);// 返回值类型String
// call.setTimeout(100000);//超时
// String result = (String) call.invoke(object);// 远程调用
// System.out.println(result);
logger.info("-----\n客户端调用服务端" + wsUrl + "方法:" + wsLocalMethod + "\n------------");
JAXDynamicClientFactory dcf = JAXDynamicClientFactory.newInstance();
Client client = dcf.createClient(wsUrl);

@ -24,12 +24,24 @@ public class FileUtils {
return currentpath;
}
/**
* xml
*
* @return
*/
public static String getXmlPath() {
//获取目录结构
String path = FileUtils.currentPath();
return path + Codes.REQUEST_XML.getMessage();
}
/**
*
*
* @param name
* @return
*/
public static Object getJsonByName(String name){
public static Object getJsonByName(String name) {
//获取目录结构
String path = FileUtils.currentPath();
//解析json映射文件
@ -39,5 +51,4 @@ public class FileUtils {
}
}

@ -18,6 +18,10 @@ public class XmlUtils {
private SAXReader saxReader;
private Document document;
public Element getDocument(){
return document.getRootElement();
}
public XmlUtils(String path) {
//获取解析器
saxReader = new SAXReader();
@ -30,6 +34,7 @@ public class XmlUtils {
}
}
public XmlUtils(InputStream path) {
//获取解析器
saxReader = new SAXReader();
@ -61,6 +66,21 @@ public class XmlUtils {
return current.element(name)==null?"":current.element(name).getText();
}
/**
*
* @return
*/
public Element getMsgElement(){
List<String> argsArr = new ArrayList<>();
argsArr.add("MsgInfo");
argsArr.add("query_ws");
argsArr.add("content");
argsArr.add("Request");
argsArr.add("Msg");
Element element = this.getElement(argsArr);
return element;
}
/**
*
* @return

Loading…
Cancel
Save