You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
4.4 KiB
Java

package com.docus.bgts.handler;
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.utils.FileUtils;
import com.docus.bgts.utils.HttpUtils;
import com.docus.bgts.utils.ResultUtils;
import com.docus.bgts.utils.XmlUtils;
import org.apache.bcel.classfile.Code;
import org.dom4j.Element;
import javax.jws.WebService;
import java.io.ByteArrayInputStream;
import java.util.*;
@WebService
public class TBasicWebService implements ITBasicWebService {
@Override
public String pushSurveyReport(String xml) {
StringBuffer mesBuffer=new StringBuffer();
try {
//解析XML
XmlUtils xmlUtils = new XmlUtils(new ByteArrayInputStream(xml.getBytes("UTF-8")));
// 获取患者主索引号
String empId = String.valueOf(FileUtils.getJsonByName(Codes.EMP_ID.getMessage()));
Map<String, Object> headMap = new HashMap<>();
headMap.put("Content-Type", "application/json");
ReportDownDto reportDownDto;
//获取根节点
List<Element> elementList = xmlUtils.getJsonByName();
//key
String serialnmnKey=String.valueOf(FileUtils.getJsonByName("serialnum"));
String filetitleKey=String.valueOf(FileUtils.getJsonByName("filetitle"));
String downurlKey=String.valueOf(FileUtils.getJsonByName("downurl"));
ReportDownScanFileDto reportDownScanFileDto;
ReportDownPatientDto reportDownPatientDto;
//临时资料存储
String serialnum;
String filetitle;
String downurl;
String collectorid=String.valueOf(FileUtils.getJsonByName("collectorid"));
String assortid=String.valueOf(FileUtils.getJsonByName("assortid"));
reportDownDto = new ReportDownDto();
reportDownDto.setCollectorid(collectorid);
reportDownDto.setIp("string");
//获取基本数据信息
List<ReportDownScanFileDto> reportDownDtoArr=new ArrayList<>();
reportDownPatientDto=new ReportDownPatientDto();
reportDownPatientDto.setJzh(elementList.get(0).element(empId).getText());
reportDownDto.setPatient(reportDownPatientDto);
for (Element element : elementList) {
serialnum=element.element(serialnmnKey).getText();
filetitle=element.element(filetitleKey).getText();
downurl=element.element(downurlKey).getText();
reportDownScanFileDto=new ReportDownScanFileDto();
reportDownScanFileDto.setDownurl(downurl);
reportDownScanFileDto.setFiletitle(filetitle);
reportDownScanFileDto.setSerialnum(serialnum);
reportDownScanFileDto.setAssortid(assortid);
reportDownScanFileDto.setFilesource(Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filesource"))));
reportDownScanFileDto.setFilestoragetype(Integer.parseInt(String.valueOf(FileUtils.getJsonByName("filestoragetype"))));
reportDownScanFileDto.setRecordid("临时医嘱");
reportDownDtoArr.add(reportDownScanFileDto);
}
if(reportDownDtoArr.size()<=0){
throw new RuntimeException("不存在必要的基本信息");
}else {
reportDownDto.setScanfiles(reportDownDtoArr);
}
String post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), headMap, JSON.parseObject(JSON.toJSONString(reportDownDto), Map.class));
// String post = HttpUtils.post(String.valueOf(FileUtils.getJsonByName(Codes.UPLOAD.getMessage())), map, headMap);
Map resMap = JSON.parseObject(post, Map.class);
System.out.println(resMap);
if (String.valueOf(resMap.get("code")).equals("500")) {
return ResultUtils.fail(String.valueOf(resMap.get("msg")));
} else {
return ResultUtils.success().asXML();
}
}
catch (RuntimeException e){
return ResultUtils.fail(e.getMessage());
}
catch (Exception e) {
e.printStackTrace();
}
return ResultUtils.fail();
}
}