Files
gzh-server/src/main/java/com/guahao/common/util/XmlUtil.java
2026-01-28 16:41:44 +08:00

2242 lines
83 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.guahao.common.util;
import cn.hutool.extra.qrcode.QrCodeUtil;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
import com.guahao.h5.hsjc.vo.HsjcVo;
import com.guahao.h5.hsjc.vo.PacsVo;
import com.guahao.h5.reserve.mapper.Reserve8Mapper;
import com.guahao.h5.reserve.vo.BingAnVO;
import com.guahao.h5.reserve.vo.HisRefundVo;
import com.guahao.h5.reserve.vo.Reserve8Vo;
import com.guahao.h5.reserve.vo.WxPayVo;
import com.guahao.h5.user.model.UserCardVo;
import com.guahao.h5.user.model.UserOrder;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringEscapeUtils;
import org.dom4j.*;
import org.dom4j.io.SAXReader;
import org.springframework.util.DigestUtils;
import org.springframework.util.ResourceUtils;
import javax.annotation.Resource;
import javax.imageio.ImageIO;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import cn.hutool.extra.qrcode.QrConfig;
@Slf4j
public class XmlUtil {
private static final XmlMapper xmlMapper = new XmlMapper();
public static void main(String[] args) {
Reserve8Vo vo = new Reserve8Vo();
System.out.println(getOpAppAppoint(vo));
try {
List<Map<Object, Object>> maps = parseQueryGH("11");
} catch (DocumentException e) {
throw new RuntimeException(e);
}
}
/**
* 解析嵌套的递归的xml
* @param xml
* @return
* @throws Exception
*/
public static Map<String, Object> parseDigui(String xml) throws Exception {
// 注意:根节点必须是对象,不能是数组
// 如果 XML 有多层结构,可能需要包装类
return xmlMapper.readValue(xml, Map.class);
}
/**
* 生成二维码
*
* @param content 内容
* @param logourl logo
*/
public static void createQrCodeN(String content, String logourl, int width, int height, HttpServletResponse response) {
QrConfig config = new QrConfig(width, height);
// File file = null;
// try {
// file = ResourceUtils.getFile(logourl);
// } catch (FileNotFoundException e) {
// e.printStackTrace();
// }
// //附带logo
// config.setImg(file);
// 设置边距,既二维码和背景之间的边距
config.setMargin(3);
// 高纠错级别
config.setErrorCorrection(ErrorCorrectionLevel.H);
// 设置前景色,既二维码颜色(青色)
config.setForeColor(new Color(0, 60, 130).getRGB());
// 设置背景色(灰色)
config.setBackColor(new Color(242, 242, 242).getRGB());
/* try {
OutputStream out = new FileOutputStream("");
} catch (FileNotFoundException e) {
e.printStackTrace();
}*/
BufferedImage bufferedImage = QrCodeUtil.generate(//
content, //二维码内容
config
);
try {
//以JPEG格式向客户端发送
ServletOutputStream os = response.getOutputStream();
ImageIO.write(bufferedImage, "PNG", os);
os.flush();
os.close();
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 省份证的正则表达式^(\d{15}|\d{17}[\dx])$
*
* @param id 省份证号
* @return 生日yyyy-MM-dd
*/
public static String extractYearMonthDayOfIdCard(String id) {
String year = null;
String month = null;
String day = null;
//正则匹配身份证号是否是正确的15位或者17位数字+数字/x/X
if (id.matches("^\\d{15}|\\d{17}[\\dxX]$")) {
year = id.substring(6, 10);
month = id.substring(10, 12);
day = id.substring(12, 14);
} else {
System.out.println("身份证号码不匹配!");
return null;
}
return year + "-" + month + "-" + day;
}
/**
* 挂号记录查询 xml封装
*/
public static String getRegisterListQuery(String PatientId, Integer SearchType, String StartTime, String EndTime) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpRegisterListQuery");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PatientId>");
str.append(PatientId);
str.append("</PatientId>");
str.append("<SearchType>");
str.append(SearchType);
str.append("</SearchType>");
str.append("<InsuranceType>");
str.append("11");
str.append("</InsuranceType>");
str.append("<StartTime>");
str.append(StartTime);
str.append("</StartTime>");
str.append("<EndTime>");
str.append(EndTime);
str.append("</EndTime>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpRegisterListQuery>");
return getRequestXMl(str);
}
/**
* 查询缴费状态 xml封装
*/
public static String getBillsStateQuery(String PowerTranID) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpBillsStateQuery");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PowerTranID>");
str.append(PowerTranID);
str.append("</PowerTranID>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpBillsStateQuery>");
return getRequestXMl(str);
}
/**
* 退费查询 xml封装
*/
public static String getBillsPayedRefundQuery(String PatientId, String FlowNo) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpBillsPayedRefundQuery");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PatientId>");
str.append(PatientId);
str.append("</PatientId>");
str.append("<FlowNo>");
str.append(FlowNo);
str.append("</FlowNo>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpBillsPayedRefundQuery>");
return getRequestXMl(str);
}
/**
* 退费 xml封装
*/
public static String getBillsPayedRefund(HisRefundVo vo) {
StringBuffer str = new StringBuffer();
String yboutmsg = "";
str.append("<tem:MOP_OutpBillsPayedRefund");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PatientId>");
str.append(vo.getPatientid());
str.append("</PatientId>");
str.append("<BillsMsg>");
str.append(vo.getBillsmsg());
str.append("</BillsMsg>");
str.append("<RCPT_NO_ZJL>");
str.append(vo.getBillsmsg());
str.append("</RCPT_NO_ZJL>");
str.append("<PayNature>");
str.append(vo.getPaynature());
str.append("</PayNature>");
str.append("<PayType>");
str.append(vo.getPaytype());
str.append("</PayType>");
str.append("<PowerTranID>");
str.append(vo.getPowertranid());
str.append("</PowerTranID>");
str.append("<ZFAmount>");
str.append(vo.getZfamount());
str.append("</ZFAmount>");
str.append("<YBZHAmount>");
str.append(vo.getYbzhamount());
str.append("</YBZHAmount>");
str.append("<YBTCAmount>");
str.append(vo.getYbtcamount());
str.append("</YBTCAmount>");
if (vo.getYboutmsg() != null && !vo.getYboutmsg().isEmpty()) {
str.append("<YBOutMsg>");
str.append(vo.getYboutmsg());
str.append("</YBOutMsg>");
}
str.append("<HisOperNum>");
str.append(vo.getHisopernum());
str.append("</HisOperNum>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpBillsPayedRefund>");
return getRequestXMl(str);
}
/**
* 查询患者信息 xml封装
*/
public static String getCardReqXml(String PatientID, int iQueryType, int iQueryBusiness) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpPatInfoQuery");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<QueryCode>");
str.append(PatientID);
str.append("</QueryCode>");
str.append("<QueryType>");
str.append(iQueryType);
str.append("</QueryType>");
str.append("<QueryBusiness>");
str.append(iQueryBusiness);
str.append("</QueryBusiness>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpPatInfoQuery>");
return getRequestXMl(str);
}
/**
* 根据就诊卡号修改证件号码及联系电话地址
*/
public static String getUpdatePhoneNumberXml(String PatientID, String phoneNumber) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpPatInfoQueryXG");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PatientId>");
str.append(PatientID);
str.append("</PatientId>");
str.append("<Address>");
str.append("</Address>");
str.append("<IDCardNO>");
str.append("</IDCardNO>");
str.append("<PhoneNum>");
str.append(phoneNumber);
str.append("</PhoneNum>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpPatInfoQueryXG>");
return getRequestXMl(str);
}
/**
* 患者建档 xml封装
*/
public static String getCardCreateXml(UserCardVo vo) {
//birthday get from idno
String idno = vo.getIdNo();
String birthday = extractYearMonthDayOfIdCard(idno);
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpPatInfoCreate");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PatientName>");
str.append(vo.getName());
str.append("</PatientName>");
str.append("<PatientSex>");
str.append(vo.getSex());
str.append("</PatientSex>");
str.append("<Birthday>");
str.append(birthday);
str.append("</Birthday>");
str.append("<IDType>");
str.append(vo.getCardType());
str.append("</IDType>");
str.append("<IDCardNum>");
str.append(vo.getIdNo());
str.append("</IDCardNum>");
str.append("<Address>");
str.append(vo.getAddress());
str.append("</Address>");
str.append("<Nation>");
str.append(vo.getNation());
str.append("</Nation>");
str.append("<PhoneNum>");
str.append(vo.getPhone());
str.append("</PhoneNum>");
str.append("<HisOper>");
// str.append(vo.getHisoper());
str.append("000000");
str.append("</HisOper>");
str.append("<ChargeType>");
// str.append(vo.getChargtype());
str.append("自费");
str.append("</ChargeType>");
str.append("<Occupation>");
str.append(vo.getOccupation());
str.append("</Occupation>");
str.append("<Employetitle>");
str.append(vo.getEmployetitle());
str.append("</Employetitle>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpPatInfoCreate>");
return getRequestXMl(str);
}
/**
* 包八 预约挂号 xml封装
*/
// public static String getOpAppAppoint1(Reserve8Vo vo) {
// StringBuffer str = new StringBuffer();
// str.append("<tem:MOP_OutpReserveLock>");
// str.append("<tem:xml>");
// str.append("<![CDATA[");
// str.append("<request>");
//
// str.append("<SubHospitalID>");
// str.append(vo.getSubHospitalID());
// str.append("</SubHospitalID>");
// str.append("<LockType>");
// str.append(vo.getLockType());
// str.append("</LockType>");
// str.append("<HisOrderNO>");
// str.append(vo.getHisOrderNo());
// str.append("</HisOrderNO>");
// str.append("<ScheduleId>");
// str.append(vo.getScheduleId());
// str.append("</ScheduleId>");
// str.append("<DoctorCode>");
// str.append(vo.getDoctorCode());
// str.append("</DoctorCode>");
// str.append("<DepartCode>");
// str.append(vo.getDepartCode());
// str.append("</DepartCode>");
// str.append("<ParTimeId>");
// str.append(vo.getParTimeId());
// str.append("</ParTimeId>");
// str.append("<LockTime>");
// str.append(vo.getLockTime());
// str.append("</LockTime>");
// str.append("<PatientId>");
// str.append(vo.getPatientId());
// str.append("</PatientId>");
// str.append("<Mobile>");
// str.append(vo.getMobile());
// str.append("</Mobile>");
//
// str.append("</request>");
// str.append("]]>");
// str.append("</tem:xml>");
// str.append("</tem:MOP_OutpReserveLock>");
// return getRequestXMl(str);
// }
/**
* 锁号 消号 xml封装
*/
public static String getOpAppAppoint(Reserve8Vo vo) {
String s = "";
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpReserveLock>");
str.append("<tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
//院区 ID
str.append("<SubHospitalID>");
s = vo.getSubhospitalid();
if (s == null || "".equals(s)) {
s = "";
}
str.append(s);
str.append("</SubHospitalID>");
//操作类型
str.append("<LockType>");
str.append(vo.getLocktype());
str.append("</LockType>");
//订单 ID
str.append("<HisOrderNO>");
str.append(vo.getHisorderno());
str.append("</HisOrderNO>");
//排班 ID
str.append("<ScheduleId>");
str.append(vo.getScheduleid());
str.append("</ScheduleId>");
//医生编码
str.append("<DoctorCode>");
str.append(vo.getDoctorcode());
str.append("</DoctorCode>");
//科室编码
str.append("<DepartCode>");
str.append(vo.getDepartcode());
str.append("</DepartCode>");
//分时 ID
str.append("<ParTimeId>");
s = vo.getPartimeid();
if (s == null || "".equals(s)) {
s = "";
}
str.append(s);
str.append("</ParTimeId>");
//锁号时间
str.append("<LockTime>");
str.append(vo.getLocktime());
str.append("</LockTime>");
//患者 ID
str.append("<PatientId>");
str.append(vo.getPatientid());
str.append("</PatientId>");
//手机号码
str.append("<Mobile>");
str.append(vo.getMobile());
str.append("</Mobile>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpReserveLock>");
return getRequestXMl(str);
}
/**
* 挂号确认 xml封装
*
* @param vo
* @return
*/
public static String confirmOpAppRegist(Reserve8Vo vo) {
String s = "";
Double fee = 0.00;
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpReserveConfirm>");
str.append("<tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
//院区 ID
str.append("<SubHospitalID>");
s = vo.getSubhospitalid();
if (s == null || "".equals(s)) {
s = "";
}
str.append(s);
str.append("</SubHospitalID>");
//订单 ID
str.append("<OrderNo>");
str.append(vo.getOrderno());
str.append("</OrderNo>");
//HIS 号 ID
str.append("<HisOrderNO>");
str.append(vo.getHisorderno());
str.append("</HisOrderNO>");
//患者 ID
str.append("<PatientID>");
str.append(vo.getPatientid());
str.append("</PatientID>");
//医生编码
str.append("<DoctorCode>");
str.append(vo.getDoctorcode());
str.append("</DoctorCode>");
//科室编码
str.append("<DepartCode>");
str.append(vo.getDepartcode());
str.append("</DepartCode>");
//时间段
str.append("<TimeInterval>");
str.append(vo.getTimeinterval());
str.append("</TimeInterval>");
//出诊日期
str.append("<Registerdate>");
str.append(vo.getRegisterdate());
str.append("</Registerdate>");
//诊查费
str.append("<ClinicFee>");
str.append(vo.getClinicfee());
str.append("</ClinicFee>");
//挂号费
str.append("<RegistrationFee>");
if (vo.getRegistrationfee() == null) {
s = "0.00";
} else {
s = vo.getRegistrationfee().toString();
}
str.append(s);
str.append("</RegistrationFee>");
//排班 ID
str.append("<ScheduleId>");
str.append(vo.getScheduleid());
str.append("</ScheduleId>");
//分时 ID
str.append("<ParTimeId>");
s = vo.getPartimeid();
if (s == null || "".equals(s)) {
s = "";
}
str.append(s);
str.append("</ParTimeId>");
//自费支付金额
str.append("<ZFAmount>");
str.append(vo.getZfamount());
str.append("</ZFAmount>");
String clinicType = "普通号";
if (vo.getZfamount().compareTo(BigDecimal.valueOf(8)) >= 0){
clinicType = "专家号";
}
str.append("<ClinicType>");
str.append(clinicType);
str.append("</ClinicType>");
// //充值金额
// str.append("<ChargAmount >");
// str.append(vo.getZfamount());
// str.append("</ChargAmount >");
//收费性质
str.append("<PayNature>");
str.append(vo.getPaynature());
str.append("</PayNature>");
//支付方式
str.append("<PayType>");
str.append(vo.getPaytype());
str.append("</PayType>");
//交易 ID
str.append("<PowerTranID>");
str.append(vo.getPowertranid());
str.append("</PowerTranID>");
//支付信息
str.append("<PayInfo>");
str.append(vo.getPowertranid());
str.append("</PayInfo>");
//交易 卡号
// str.append("<PowerTranCARD>");
// s = vo.getPowertrancard();
// if (s == null || "".equals(s)) {
// s = "";
// }
// str.append(s);
// str.append("</PowerTranCARD>");
// //MISPOS终端号
// str.append("<TerminalId>");
// s = vo.getTerminalid();
// if (s == null || "".equals(s)) {
// s = "0001";
// }
// str.append(s);
// str.append("</TerminalId>");
// //交易检索号
// str.append("<ReferNo>");
// s = vo.getReferno();
// if (s == null || "".equals(s)) {
// s = "";
// }
// str.append(s);
// str.append("</ReferNo>");
//
// //医保账户金额
// str.append("<YBZHAmount>");
// if (vo.getYbzhamount() == null) {
// s = "0.00";
// } else {
// s = vo.getYbzhamount().toString();
// }
// str.append(s);
// str.append("</YBZHAmount>");
// //医保统筹金额
// str.append("<YBTCAmount>");
// if (vo.getYbtcamount() == null) {
// s = "0.00";
// } else {
// s = vo.getYbtcamount().toString();
// }
// str.append(s);
// str.append("</YBTCAmount>");
//医保结算信息
if (vo.getYboutmsg() == null || "".equals(vo.getYboutmsg())){
s = "";
}else {
s = vo.getYboutmsg();
}
str.append("<YBOutMsg>");
str.append(s);
str.append("</YBOutMsg>");
//HIS 工号
str.append("<HisOperNum>");
str.append("WX");
str.append("</HisOperNum>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpReserveConfirm>");
// log.info("挂号确认支付:{}",str);
return getRequestXMl(str);
}
/**
* 缴费确认支付
*/
public static String confirmOpAppPayed(Reserve8Vo vo) {
String s = "";
BigDecimal fee = BigDecimal.valueOf(0.00);
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpBillsPayedConfirm>");
str.append("<tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PatientId>");
str.append(vo.getPatientid());
str.append("</PatientId>");
str.append("<BillsMsg>");
str.append(vo.getBillsMsg());
str.append("</BillsMsg>");
str.append("<PayNature>");
str.append(vo.getPaynature());
str.append("</PayNature>");
// 当vo.getYbzhamount和ybtcamount都是0的时候且zfamount>=0则此处用微信其他情况用医保
// if ((vo.getYbzhamount() == null || vo.getYbzhamount().compareTo(BigDecimal.valueOf(0.00)) == 0) &&
// (vo.getYbtcamount() == null || vo.getYbtcamount().compareTo(BigDecimal.valueOf(0.00)) == 0) &&
// vo.getZfamount().compareTo(BigDecimal.valueOf(0.00)) >= 0) {
// str.append("<PayType>");
// str.append("微信");
// str.append("</PayType>");
// } else {
// str.append("<PayType>");
// str.append("医保");
// str.append("</PayType>");
// }
str.append("<PayType>");
str.append("微信");
str.append("</PayType>");
str.append("<PowerTranID>");
str.append(vo.getPowertranid());
str.append("</PowerTranID>");
str.append("<TerminalId>");
str.append(vo.getTerminalid());
str.append("</TerminalId>");
str.append("<ReferNo>");
if (vo.getReferno() == null){
s="";
}else {
s = vo.getReferno();
}
str.append(s);
str.append("</ReferNo>");
str.append("<ZFAmount>");
str.append(vo.getZfamount());
str.append("</ZFAmount>");
str.append("<YBZHAmount>");
if (vo.getYbzhamount() != null && vo.getYbzhamount().compareTo(BigDecimal.valueOf(0.00)) > 0) {
str.append(vo.getYbzhamount());
} else {
str.append(BigDecimal.valueOf(0.00));
}
str.append("</YBZHAmount>");
str.append("<YBTCAmount>");
if (vo.getYbtcamount() != null && vo.getYbtcamount().compareTo(BigDecimal.valueOf(0.00)) > 0) {
str.append(vo.getYbtcamount());
} else {
str.append(BigDecimal.valueOf(0.00));
}
str.append("</YBTCAmount>");
str.append("<JbAmount>");
str.append("0");
str.append("</JbAmount>");
if (vo.getYboutmsg() != null){
s = vo.getYboutmsg();
}
// str.append("<YBRegInMsg>");
// str.append();
// str.append("</YBRegInMsg>");
str.append("<YBOutMsg>");
str.append(s);
str.append("</YBOutMsg>");
//线上缴费医保接口,和自助机区分
if (vo.getRootObject() != null && !"".equals(vo.getRootObject())){
str.append("<RootObject>");
str.append(vo.getRootObject());
str.append("</RootObject>");
}else {
str.append("<RootObject>");
str.append("</RootObject>");
}
str.append("<HisOperNum>");
str.append(vo.getHisopernum());
str.append("</HisOperNum>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpBillsPayedConfirm>");
return getRequestXMl(str);
}
/**
* 定时预约查询请求
*/
public static String getTaskTodayXML(String patientId) {
StringBuffer str = new StringBuffer();
str.append("<tem:queryAppRegistRecordsNew>");
str.append("<tem:InMsg>");
str.append("<![CDATA[");
str.append("<Request>");
str.append("<PATIENT_ID>");
str.append(patientId);
str.append("</PATIENT_ID>");
str.append("<STARTTIME>");
str.append(VeDate.getSevenDaysAgo()); // 七天前日期
str.append("</STARTTIME>");
str.append("<ENDTIME>");
str.append(VeDate.getStringDateShort()); //现在日期
str.append("</ENDTIME>");
str.append("</Request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:queryAppRegistRecordsNew>");
return getRequestXMl(str);
}
/**
* 给支付平台发送报文,记录账单情况
*/
public static String getCallXML(Reserve8Vo reserve8Vo, String orderid) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String time = formatter.format(calendar.getTime());
//APP_CODE=HNWJZFPT&CARD_NO=null&COST=15.80&HOSPITAL_NO=TL20230504130957487403&ID_NO=&MOBILE_PHONE=18837528837&OPERATOR=GZH&OPERATOR_NAME=公众号&ORDER_STATE=2&ORG_CODE=3301001&OTHER_INFO=&PATIENT_ID=10130223&PAY_SOURCE=1&PAY_WAY=5&PLATFORM_NO=GZH&SERVER_CHANNEL=3&SICK_NAME=张顺&TERMINAL_CODE=Jojugzh&TIME_STAMP=04052023131004&VISIT_NO=&KEY=099A00C5C7FE432AAC4B3F012B740A00
String str_md5 = "APP_CODE=HNWJZFPT&CARD_NO=" + reserve8Vo.getCardId() + "&COST=" + reserve8Vo.getZfamount() + "&HOSPITAL_NO=" + reserve8Vo.getOrderno() + "&ID_NO=&MOBILE_PHONE=" + reserve8Vo.getMobile() + "&OPERATOR=" + reserve8Vo.getHisopernum() + "&OPERATOR_NAME=公众号&ORDER_STATE=2&ORG_CODE=3301001&OTHER_INFO=&PATIENT_ID=" + reserve8Vo.getPatientid() + "&PAY_SOURCE=1&PAY_WAY=5&PLATFORM_NO=" + orderid + "&SERVER_CHANNEL=3&SICK_NAME=" + reserve8Vo.getName() + "&TERMINAL_CODE=Jojugzh&TIME_STAMP=" + time + "&VISIT_NO=&KEY=099A00C5C7FE432AAC4B3F012B740A00";
log.info("打印加密前的数据:" + str_md5);
String s_md5 = DigestUtils.md5DigestAsHex(str_md5.getBytes()).toUpperCase();
log.info("打印加密前的数据:" + s_md5);
StringBuffer str = new StringBuffer();
str.append("<tem:callInterface>");
str.append("<tem:msgHeader>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<INTERFACE>");
str.append("upay.trade.gzhNotify");
str.append("</INTERFACE>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgHeader>");
str.append("<tem:msgBody>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<ORG_CODE>");
str.append("3301001");
str.append("</ORG_CODE>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<TIME_STAMP>");
str.append(time);
str.append("</TIME_STAMP>");
str.append("<PAY_SOURCE>");
str.append("1");
str.append("</PAY_SOURCE>");
str.append("<SERVER_CHANNEL>");
str.append("3");
str.append("</SERVER_CHANNEL>");
str.append("<PATIENT_ID>");
str.append(reserve8Vo.getPatientid());
str.append("</PATIENT_ID>");
str.append("<SICK_NAME>");
str.append(reserve8Vo.getName());
str.append("</SICK_NAME>");
str.append("<MOBILE_PHONE>");
str.append(reserve8Vo.getMobile());
str.append("</MOBILE_PHONE>");
str.append("<CARD_NO>");
str.append(reserve8Vo.getCardId());
str.append("</CARD_NO>");
str.append("<ID_NO>");
// str.append("");
str.append("</ID_NO>");
str.append("<VISIT_NO>");
// str.append(reserve8Vo.getPatientid());
str.append("</VISIT_NO>");
str.append("<COST>");
str.append(reserve8Vo.getZfamount());
str.append("</COST>");
str.append("<HOSPITAL_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</HOSPITAL_NO>");
str.append("<OPERATOR>");
str.append("WX");
str.append("</OPERATOR>");
str.append("<OPERATOR_NAME>");
str.append("公众号");
str.append("</OPERATOR_NAME>");
str.append("<ORDER_STATE>");
str.append("2");
str.append("</ORDER_STATE>");
str.append("<PLATFORM_NO>");
str.append(orderid);
str.append("</PLATFORM_NO>");
str.append("<PAY_WAY>");
str.append("5");
str.append("</PAY_WAY>");
str.append("<OTHER_INFO>");
// str.append("5");
str.append("</OTHER_INFO>");
str.append("<SIGN>");
str.append(s_md5);
str.append("</SIGN>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgBody>");
str.append("</tem:callInterface>");
return getRequestXMl(str);
}
public static String getCallXML(UserOrder reserve8Vo, String name, String phone, String orderid) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String time = formatter.format(calendar.getTime());
//APP_CODE=HNWJZFPT&CARD_NO=null&COST=15.80&HOSPITAL_NO=TL20230504130957487403&ID_NO=&MOBILE_PHONE=18837528837&OPERATOR=GZH&OPERATOR_NAME=公众号&ORDER_STATE=2&ORG_CODE=3301001&OTHER_INFO=&PATIENT_ID=10130223&PAY_SOURCE=1&PAY_WAY=5&PLATFORM_NO=GZH&SERVER_CHANNEL=3&SICK_NAME=张顺&TERMINAL_CODE=Jojugzh&TIME_STAMP=04052023131004&VISIT_NO=&KEY=099A00C5C7FE432AAC4B3F012B740A00
String str_md5 = "APP_CODE=HNWJZFPT&CARD_NO=" + reserve8Vo.getCard_no() + "&COST=" + reserve8Vo.getMoney() + "&HOSPITAL_NO=" + reserve8Vo.getCode() + "&ID_NO=&MOBILE_PHONE=" + phone + "&OPERATOR=GZH&OPERATOR_NAME=公众号&ORDER_STATE=2&ORG_CODE=3301001&OTHER_INFO=&PATIENT_ID=" + reserve8Vo.getCard_no() + "&PAY_SOURCE=1&PAY_WAY=5&PLATFORM_NO=" + orderid + "&SERVER_CHANNEL=3&SICK_NAME=" + name + "&TERMINAL_CODE=Jojugzh&TIME_STAMP=" + time + "&VISIT_NO=&KEY=099A00C5C7FE432AAC4B3F012B740A00";
log.info("打印加密前的数据:" + str_md5);
String s_md5 = DigestUtils.md5DigestAsHex(str_md5.getBytes()).toUpperCase();
log.info("打印加密前的数据:" + s_md5);
StringBuffer str = new StringBuffer();
str.append("<tem:callInterface>");
str.append("<tem:msgHeader>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<INTERFACE>");
str.append("upay.trade.gzhNotify");
str.append("</INTERFACE>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgHeader>");
str.append("<tem:msgBody>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<ORG_CODE>");
str.append("3301001");
str.append("</ORG_CODE>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<TIME_STAMP>");
str.append(time);
str.append("</TIME_STAMP>");
str.append("<PAY_SOURCE>");
str.append("1");
str.append("</PAY_SOURCE>");
str.append("<SERVER_CHANNEL>");
str.append("3");
str.append("</SERVER_CHANNEL>");
str.append("<PATIENT_ID>");
str.append(reserve8Vo.getCard_no());
str.append("</PATIENT_ID>");
str.append("<SICK_NAME>");
str.append(name);
str.append("</SICK_NAME>");
str.append("<MOBILE_PHONE>");
str.append(phone);
str.append("</MOBILE_PHONE>");
str.append("<CARD_NO>");
str.append(reserve8Vo.getCard_no());
str.append("</CARD_NO>");
str.append("<ID_NO>");
// str.append("");
str.append("</ID_NO>");
str.append("<VISIT_NO>");
// str.append(reserve8Vo.getPatientid());
str.append("</VISIT_NO>");
str.append("<COST>");
str.append(reserve8Vo.getMoney());
str.append("</COST>");
str.append("<HOSPITAL_NO>");
str.append(reserve8Vo.getCode());
str.append("</HOSPITAL_NO>");
str.append("<OPERATOR>");
str.append("GZH");
str.append("</OPERATOR>");
str.append("<OPERATOR_NAME>");
str.append("公众号");
str.append("</OPERATOR_NAME>");
str.append("<ORDER_STATE>");
str.append("2");
str.append("</ORDER_STATE>");
str.append("<PLATFORM_NO>");
str.append(orderid);
str.append("</PLATFORM_NO>");
str.append("<PAY_WAY>");
str.append("5");
str.append("</PAY_WAY>");
str.append("<OTHER_INFO>");
// str.append("5");
str.append("</OTHER_INFO>");
str.append("<SIGN>");
str.append(s_md5);
str.append("</SIGN>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgBody>");
str.append("</tem:callInterface>");
return getRequestXMl(str);
}
public static String getCallXML(HsjcVo reserve8Vo, String orderid, String userName, String phone) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String time = formatter.format(calendar.getTime());
//APP_CODE=HNWJZFPT&CARD_NO=null&COST=15.80&HOSPITAL_NO=TL20230504130957487403&ID_NO=&MOBILE_PHONE=18837528837&OPERATOR=GZH&OPERATOR_NAME=公众号&ORDER_STATE=2&ORG_CODE=3301001&OTHER_INFO=&PATIENT_ID=10130223&PAY_SOURCE=1&PAY_WAY=5&PLATFORM_NO=GZH&SERVER_CHANNEL=3&SICK_NAME=张顺&TERMINAL_CODE=Jojugzh&TIME_STAMP=04052023131004&VISIT_NO=&KEY=099A00C5C7FE432AAC4B3F012B740A00
String str_md5 = "APP_CODE=HNWJZFPT&CARD_NO=" + reserve8Vo.getCardId() + "&COST=" + reserve8Vo.getZfamount() + "&HOSPITAL_NO=" + reserve8Vo.getOrderno() + "&ID_NO=&MOBILE_PHONE=" + phone + "&OPERATOR=" + reserve8Vo.getHisopernum() + "&OPERATOR_NAME=公众号&ORDER_STATE=2&ORG_CODE=3301001&OTHER_INFO=&PATIENT_ID=" + reserve8Vo.getPatientid() + "&PAY_SOURCE=1&PAY_WAY=5&PLATFORM_NO=" + orderid + "&SERVER_CHANNEL=3&SICK_NAME=" + userName + "&TERMINAL_CODE=Jojugzh&TIME_STAMP=" + time + "&VISIT_NO=&KEY=099A00C5C7FE432AAC4B3F012B740A00";
log.info("打印加密前的数据:" + str_md5);
String s_md5 = DigestUtils.md5DigestAsHex(str_md5.getBytes()).toUpperCase();
log.info("打印加密前的数据:" + s_md5);
StringBuffer str = new StringBuffer();
str.append("<tem:callInterface>");
str.append("<tem:msgHeader>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<INTERFACE>");
str.append("upay.trade.gzhNotify");
str.append("</INTERFACE>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgHeader>");
str.append("<tem:msgBody>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<ORG_CODE>");
str.append("3301001");
str.append("</ORG_CODE>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<TIME_STAMP>");
str.append(time);
str.append("</TIME_STAMP>");
str.append("<PAY_SOURCE>");
str.append("1");
str.append("</PAY_SOURCE>");
str.append("<SERVER_CHANNEL>");
str.append("3");
str.append("</SERVER_CHANNEL>");
str.append("<PATIENT_ID>");
str.append(reserve8Vo.getPatientid());
str.append("</PATIENT_ID>");
str.append("<SICK_NAME>");
str.append(userName);
str.append("</SICK_NAME>");
str.append("<MOBILE_PHONE>");
str.append(phone);
str.append("</MOBILE_PHONE>");
str.append("<CARD_NO>");
str.append(reserve8Vo.getCardId());
str.append("</CARD_NO>");
str.append("<ID_NO>");
// str.append("");
str.append("</ID_NO>");
str.append("<VISIT_NO>");
// str.append(reserve8Vo.getPatientid());
str.append("</VISIT_NO>");
str.append("<COST>");
str.append(reserve8Vo.getZfamount());
str.append("</COST>");
str.append("<HOSPITAL_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</HOSPITAL_NO>");
str.append("<OPERATOR>");
str.append("GZH");
str.append("</OPERATOR>");
str.append("<OPERATOR_NAME>");
str.append("公众号");
str.append("</OPERATOR_NAME>");
str.append("<ORDER_STATE>");
str.append("2");
str.append("</ORDER_STATE>");
str.append("<PLATFORM_NO>");
str.append(orderid);
str.append("</PLATFORM_NO>");
str.append("<PAY_WAY>");
str.append("5");
str.append("</PAY_WAY>");
str.append("<OTHER_INFO>");
// str.append("5");
str.append("</OTHER_INFO>");
str.append("<SIGN>");
str.append(s_md5);
str.append("</SIGN>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgBody>");
str.append("</tem:callInterface>");
return getRequestXMl(str);
}
/**
* 调用支付平台的退款接口
*/
public static String getRefundXML(Reserve8Vo reserve8Vo, String orderid) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String time = formatter.format(calendar.getTime());
String str_md5 = "APP_CODE=HNWJZFPT&CARD_NO=" + reserve8Vo.getCardId() + "&HOSPITAL_NO=" + reserve8Vo.getOrderno() + "&OLD_CHANNEL_NO=" + reserve8Vo.getOrderno() + "&OLD_PLATFORM_NO=" + reserve8Vo.getOrderno() + "&OPERATOR=GZH&OPERATOR_NAME=公众号&ORG_CODE=3301001&PAY_SOURCE=1&PAY_WAY=5&REFUND_COST=" + reserve8Vo.getZfamount() + "&SERVER_CHANNEL=3&SICK_NAME=" + reserve8Vo.getName() + "&TERMINAL_CODE=Jojugzh&TIME_STAMP=" + time + "&KEY=099A00C5C7FE432AAC4B3F012B740A00";
log.info("打印加密前的数据:" + str_md5);
String s_md5 = DigestUtils.md5DigestAsHex(str_md5.getBytes()).toUpperCase();
log.info("打印加密前的数据:" + s_md5);
StringBuffer str = new StringBuffer();
str.append("<tem:callInterface>");
str.append("<tem:msgHeader>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<INTERFACE>");
str.append("upay.trade.refund");
str.append("</INTERFACE>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgHeader>");
str.append("<tem:msgBody>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<ORG_CODE>");
str.append("3301001");
str.append("</ORG_CODE>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<TIME_STAMP>");
str.append(time);
str.append("</TIME_STAMP>");
str.append("<SERVER_CHANNEL>");
str.append("3");
str.append("</SERVER_CHANNEL>");
str.append("<HOSPITAL_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</HOSPITAL_NO>");
str.append("<OLD_PLATFORM_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</OLD_PLATFORM_NO>");
str.append("<OLD_CHANNEL_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</OLD_CHANNEL_NO>");
str.append("<REFUND_COST>");
str.append(reserve8Vo.getZfamount());
str.append("</REFUND_COST>");
str.append("<OPERATOR>");
str.append("GZH");
str.append("</OPERATOR>");
str.append("<OPERATOR_NAME>");
str.append("公众号");
str.append("</OPERATOR_NAME>");
str.append("<PAY_WAY>");
str.append("5");
str.append("</PAY_WAY>");
str.append("<PAY_SOURCE>");
str.append("1");
str.append("</PAY_SOURCE>");
str.append("<SICK_NAME>");
str.append(reserve8Vo.getName());
str.append("</SICK_NAME>");
str.append("<CARD_NO>");
str.append(reserve8Vo.getCardId());
str.append("</CARD_NO>");
str.append("<SIGN>");
str.append(s_md5);
str.append("</SIGN>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgBody>");
str.append("</tem:callInterface>");
return getRequestXMl(str);
}
public static String getRefundXML(HisRefundVo reserve8Vo) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String time = formatter.format(calendar.getTime());
String str_md5 = "APP_CODE=HNWJZFPT&CARD_NO=&HOSPITAL_NO=" + reserve8Vo.getPowertranid() + "&OLD_CHANNEL_NO=" + reserve8Vo.getPowertranid() + "&OLD_PLATFORM_NO=" + reserve8Vo.getPowertranid() + "&OPERATOR=GZH&OPERATOR_NAME=公众号&ORG_CODE=3301001&PAY_SOURCE=1&PAY_WAY=5&REFUND_COST=" + reserve8Vo.getZfamount() + "&SERVER_CHANNEL=3&SICK_NAME=&TERMINAL_CODE=Jojugzh&TIME_STAMP=" + time + "&KEY=099A00C5C7FE432AAC4B3F012B740A00";
log.info("打印加密前的数据:" + str_md5);
String s_md5 = DigestUtils.md5DigestAsHex(str_md5.getBytes()).toUpperCase();
log.info("打印加密前的数据:" + s_md5);
StringBuffer str = new StringBuffer();
str.append("<tem:callInterface>");
str.append("<tem:msgHeader>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<INTERFACE>");
str.append("upay.trade.refund");
str.append("</INTERFACE>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgHeader>");
str.append("<tem:msgBody>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<ORG_CODE>");
str.append("3301001");
str.append("</ORG_CODE>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<TIME_STAMP>");
str.append(time);
str.append("</TIME_STAMP>");
str.append("<SERVER_CHANNEL>");
str.append("3");
str.append("</SERVER_CHANNEL>");
str.append("<HOSPITAL_NO>");
str.append(reserve8Vo.getPowertranid());
str.append("</HOSPITAL_NO>");
str.append("<OLD_PLATFORM_NO>");
str.append(reserve8Vo.getPowertranid());
str.append("</OLD_PLATFORM_NO>");
str.append("<OLD_CHANNEL_NO>");
str.append(reserve8Vo.getPowertranid());
str.append("</OLD_CHANNEL_NO>");
str.append("<REFUND_COST>");
str.append(reserve8Vo.getZfamount());
str.append("</REFUND_COST>");
str.append("<OPERATOR>");
str.append("GZH");
str.append("</OPERATOR>");
str.append("<OPERATOR_NAME>");
str.append("公众号");
str.append("</OPERATOR_NAME>");
str.append("<PAY_WAY>");
str.append("5");
str.append("</PAY_WAY>");
str.append("<PAY_SOURCE>");
str.append("1");
str.append("</PAY_SOURCE>");
str.append("<SICK_NAME>");
// str.append(reserve8Vo.getName());
str.append("</SICK_NAME>");
str.append("<CARD_NO>");
// str.append(reserve8Vo.getCardId());
str.append("</CARD_NO>");
str.append("<SIGN>");
str.append(s_md5);
str.append("</SIGN>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgBody>");
str.append("</tem:callInterface>");
return getRequestXMl(str);
}
public static String getRefundXML(HsjcVo reserve8Vo, String userName, String orderid) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String time = formatter.format(calendar.getTime());
String str_md5 = "APP_CODE=HNWJZFPT&CARD_NO=" + reserve8Vo.getCardId() + "&HOSPITAL_NO=" + reserve8Vo.getOrderno() + "&OLD_CHANNEL_NO=" + reserve8Vo.getOrderno() + "&OLD_PLATFORM_NO=" + reserve8Vo.getOrderno() + "&OPERATOR=GZH&OPERATOR_NAME=公众号&ORG_CODE=3301001&PAY_SOURCE=1&PAY_WAY=5&REFUND_COST=" + reserve8Vo.getZfamount() + "&SERVER_CHANNEL=3&SICK_NAME=" + userName + "&TERMINAL_CODE=Jojugzh&TIME_STAMP=" + time + "&KEY=099A00C5C7FE432AAC4B3F012B740A00";
log.info("打印加密前的数据:" + str_md5);
String s_md5 = DigestUtils.md5DigestAsHex(str_md5.getBytes()).toUpperCase();
log.info("打印加密前的数据:" + s_md5);
StringBuffer str = new StringBuffer();
str.append("<tem:callInterface>");
str.append("<tem:msgHeader>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<INTERFACE>");
str.append("upay.trade.refund");
str.append("</INTERFACE>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgHeader>");
str.append("<tem:msgBody>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<ORG_CODE>");
str.append("3301001");
str.append("</ORG_CODE>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<TIME_STAMP>");
str.append(time);
str.append("</TIME_STAMP>");
str.append("<SERVER_CHANNEL>");
str.append("3");
str.append("</SERVER_CHANNEL>");
str.append("<HOSPITAL_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</HOSPITAL_NO>");
str.append("<OLD_PLATFORM_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</OLD_PLATFORM_NO>");
str.append("<OLD_CHANNEL_NO>");
str.append(reserve8Vo.getOrderno());
str.append("</OLD_CHANNEL_NO>");
str.append("<REFUND_COST>");
str.append(reserve8Vo.getZfamount());
str.append("</REFUND_COST>");
str.append("<OPERATOR>");
str.append("GZH");
str.append("</OPERATOR>");
str.append("<OPERATOR_NAME>");
str.append("公众号");
str.append("</OPERATOR_NAME>");
str.append("<PAY_WAY>");
str.append("5");
str.append("</PAY_WAY>");
str.append("<PAY_SOURCE>");
str.append("1");
str.append("</PAY_SOURCE>");
str.append("<SICK_NAME>");
str.append(userName);
str.append("</SICK_NAME>");
str.append("<CARD_NO>");
str.append(reserve8Vo.getCardId());
str.append("</CARD_NO>");
str.append("<SIGN>");
str.append(s_md5);
str.append("</SIGN>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgBody>");
str.append("</tem:callInterface>");
return getRequestXMl(str);
}
public static String getRefundXML(UserOrder reserve8Vo, String userName, String orderid) {
Calendar calendar = Calendar.getInstance();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String time = formatter.format(calendar.getTime());
String str_md5 = "APP_CODE=HNWJZFPT&CARD_NO=" + reserve8Vo.getCard_no() + "&HOSPITAL_NO=" + orderid + "&OLD_CHANNEL_NO=" + orderid + "&OLD_PLATFORM_NO=" + orderid + "&OPERATOR=GZH&OPERATOR_NAME=公众号&ORG_CODE=3301001&PAY_SOURCE=1&PAY_WAY=5&REFUND_COST=" + reserve8Vo.getMoney() + "&SERVER_CHANNEL=3&SICK_NAME=" + userName + "&TERMINAL_CODE=Jojugzh&TIME_STAMP=" + time + "&KEY=099A00C5C7FE432AAC4B3F012B740A00";
log.info("打印加密前的数据:" + str_md5);
String s_md5 = DigestUtils.md5DigestAsHex(str_md5.getBytes()).toUpperCase();
log.info("打印加密前的数据:" + s_md5);
StringBuffer str = new StringBuffer();
str.append("<tem:callInterface>");
str.append("<tem:msgHeader>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<INTERFACE>");
str.append("upay.trade.refund");
str.append("</INTERFACE>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgHeader>");
str.append("<tem:msgBody>");
str.append("<![CDATA[");
str.append("<?xml version=\"1.0\" encoding=\"utf-8\"?>");
str.append("<ROOT>");
str.append("<ORG_CODE>");
str.append("3301001");
str.append("</ORG_CODE>");
str.append("<APP_CODE>");
str.append("HNWJZFPT");
str.append("</APP_CODE>");
str.append("<TERMINAL_CODE>");
str.append("Jojugzh");
str.append("</TERMINAL_CODE>");
str.append("<TIME_STAMP>");
str.append(time);
str.append("</TIME_STAMP>");
str.append("<SERVER_CHANNEL>");
str.append("3");
str.append("</SERVER_CHANNEL>");
str.append("<HOSPITAL_NO>");
str.append(orderid);
str.append("</HOSPITAL_NO>");
str.append("<OLD_PLATFORM_NO>");
str.append(orderid);
str.append("</OLD_PLATFORM_NO>");
str.append("<OLD_CHANNEL_NO>");
str.append(orderid);
str.append("</OLD_CHANNEL_NO>");
str.append("<REFUND_COST>");
str.append(reserve8Vo.getMoney());
str.append("</REFUND_COST>");
str.append("<OPERATOR>");
str.append("GZH");
str.append("</OPERATOR>");
str.append("<OPERATOR_NAME>");
str.append("公众号");
str.append("</OPERATOR_NAME>");
str.append("<PAY_WAY>");
str.append("5");
str.append("</PAY_WAY>");
str.append("<PAY_SOURCE>");
str.append("1");
str.append("</PAY_SOURCE>");
str.append("<SICK_NAME>");
str.append(userName);
str.append("</SICK_NAME>");
str.append("<CARD_NO>");
str.append(reserve8Vo.getCard_no());
str.append("</CARD_NO>");
str.append("<SIGN>");
str.append(s_md5);
str.append("</SIGN>");
str.append("</ROOT>");
str.append("]]>");
str.append("</tem:msgBody>");
str.append("</tem:callInterface>");
return getRequestXMl(str);
}
/**
* 获取his时间
*/
public static String getHisTime() {
StringBuffer str = new StringBuffer();
str.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">");
str.append("<soapenv:Header/>");
str.append("<soapenv:Body>");
str.append("<tem:MOP_BaseQueryDBServerTime/>");
str.append("</soapenv:Body>");
str.append("</soapenv:Envelope>");
return str.toString();
}
/**
* xml上下封装
*/
public static String getRequestXMl(StringBuffer strXML) {
StringBuffer str = new StringBuffer();
str.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\">");
str.append("<soapenv:Header/>");
str.append("<soapenv:Body>");
str.append(strXML.toString());
str.append("</soapenv:Body>");
str.append("</soapenv:Envelope>");
return str.toString();
}
// 获取返回的报文统一处理
// public static Map<String, Object> map = new HashMap<String, Object>();
public static Map<String, Object> parse(String soap) throws DocumentException {
//map.clear();
String soapWeb = StringEscapeUtils.unescapeXml(soap);
soapWeb = soapWeb.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
Document doc = DocumentHelper.parseText(soapWeb);// 报文 转成 xml
Element root = doc.getRootElement();//获取根元素准备递归解析这个XML树
Map<String, Object> map = getCodeNC(root);
return map;
}
public static List<Map<Object, Object>> parseQueryGH(String xml) throws DocumentException {
String soapWeb = StringEscapeUtils.unescapeXml(xml);
soapWeb = soapWeb.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
Document doc = DocumentHelper.parseText(soapWeb);// 报文 转成 xml
Element root = doc.getRootElement();//获取根元素准备递归解析这个XML树
System.out.println("root is :" + root.getName());
Element body = root.element("Body");
Element mopOutpRegisterListQueryResponse = body.element("MOP_OutpRegisterListQueryResponse");
Element mopOutpRegisterListQueryResult = mopOutpRegisterListQueryResponse.element("MOP_OutpRegisterListQueryResult");
Element response = mopOutpRegisterListQueryResult.element("response");
Element data = response.element("data");
Iterator iterator = data.elementIterator("data_row");
ArrayList<Map<Object, Object>> result = new ArrayList<>();
while (iterator.hasNext()) {
Map<Object, Object> res = new HashMap<>();
Element itemEle = (Element) iterator.next();
// res.put("DOCTORCODE", itemEle.elementTextTrim("DOCTORCODE"));
// res.put("DEPARTCODE", itemEle.elementTextTrim("DEPARTCODE"));
res.put("ORDERNO", itemEle.elementTextTrim("ORDERNO"));
result.add(res);
}
return result;
}
// 非递归遍历所有的 节点 和 数据
public static Map<String, Object> getCodeNC(Element root) {
Map<String, Object> map = new HashMap<String, Object>();
Stack a = null;
a = new Stack<>();
a.push(root);
if (root.elements().size() == 0 || root.elements() == null) {
return map;
}
//top 是栈顶元素
Element top = null;
while (!a.empty()) {
top = (Element) a.peek();
a.pop();
//如果当前跟节点有子节点,找到子节点
List<Element> list = top.elements();
int size = top.elements().size();
for (Element e : list) {
//遍历每个节点
if (e.elements().size() > 0) {
//对栈顶元素进行反向遍历,入栈
a.push((Element) e);
}
if (e.elements().size() == 0) {
map.put(e.getName(), e.getTextTrim());
}//如果为叶子节点那么直接把名称和值放入map
}
}
return map;
}
public static List<Map<Object, Object>> CardListQuery(String xml) {
try {
// 1. 清理XML字符串
String cleanXml = StringEscapeUtils.unescapeXml(xml);
cleanXml = cleanXml.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
// 2. 解析XML
Document doc = DocumentHelper.parseText(cleanXml);
Element root = doc.getRootElement();
// 3. 使用简单的方法查找元素避免XPath
Element body = findElementByName(root, "Body");
if (body == null) return new ArrayList<>();
Element responseRoot = findElementByName(body, "MOP_OutpPatInfoQueryResponse");
if (responseRoot == null) return new ArrayList<>();
Element request1 = findElementByName(responseRoot, "request");
if (request1 == null) return new ArrayList<>();
Element request2 = findElementByName(request1, "request");
if (request2 == null) return new ArrayList<>();
// 4. 遍历所有data元素
List<Map<Object, Object>> resultList = new ArrayList<>();
List<Element> dataElements = request2.elements("data");
for (Element dataEle : dataElements) {
Map<Object, Object> itemMap = new HashMap<>();
// 解析所有字段
itemMap.put("PatientId", getElementText(dataEle, "PatientId"));
itemMap.put("PatientName", getElementText(dataEle, "PatientName"));
itemMap.put("PatientSex", getElementText(dataEle, "PatientSex"));
itemMap.put("Birthday", getElementText(dataEle, "Birthday"));
itemMap.put("IDType", getElementText(dataEle, "IDType"));
itemMap.put("IDCardNO", getElementText(dataEle, "IDCardNO"));
itemMap.put("Address", getElementText(dataEle, "Address"));
itemMap.put("Nation", getElementText(dataEle, "Nation"));
itemMap.put("PhoneNum", getElementText(dataEle, "PhoneNum"));
itemMap.put("Identity", getElementText(dataEle, "Identity"));
itemMap.put("ChargeType", getElementText(dataEle, "ChargeType"));
itemMap.put("Balance", getElementText(dataEle, "Balance"));
itemMap.put("CardState", getElementText(dataEle, "CardState"));
resultList.add(itemMap);
}
return resultList;
} catch (Exception e) {
// 安全返回空列表(绝不抛出异常)
e.printStackTrace(); // 添加日志以便调试
return new ArrayList<>();
}
}
/**
* 通过元素名查找子元素(忽略命名空间)
* @param parent 父元素
* @param elementName 元素名
* @return 找到的元素或null
*/
private static Element findElementByName(Element parent, String elementName) {
if (parent == null) return null;
// 遍历所有子元素
for (Iterator<Element> it = parent.elementIterator(); it.hasNext();) {
Element element = it.next();
if (elementName.equals(element.getName())) {
return element;
}
// 递归查找
Element found = findElementByName(element, elementName);
if (found != null) {
return found;
}
}
return null;
}
/**
* 获取元素的文本内容
*/
private static String getElementText(Element parent, String elementName) {
Element element = parent.element(elementName);
return element != null ? element.getTextTrim() : "";
}
public static List<Map<Object, Object>> MOP_OutpBillsDetailQuery(String xml) {
try {
// 1. 解析SOAP XML (启用命名空间支持)
SAXReader reader = new SAXReader();
// reader.setNamespaceAware(true);
Document doc = reader.read(new java.io.StringReader(xml));
Element root = doc.getRootElement();
// 2. 创建命名空间对象 (关键修复)
Namespace soapNs = Namespace.get("soap", "http://schemas.xmlsoap.org/soap/envelope/");
Namespace tempNs = Namespace.get("", "http://tempuri.org/"); // 默认命名空间
// 3. 查找soap:Body元素 (使用命名空间)
Element body = findElement(root, "Body", soapNs);
if (body == null) return new ArrayList<>();
// 4. 查找MOP_OutpBillsDetailQueryResponse (使用默认命名空间)
Element responseElement = findElement(body, "MOP_OutpBillsDetailQueryResponse", tempNs);
if (responseElement == null) return new ArrayList<>();
// 5. 获取MOP_OutpBillsDetailQueryResult元素
Element resultElement = findElement(responseElement, "MOP_OutpBillsDetailQueryResult", tempNs);
if (resultElement == null) return new ArrayList<>();
// 6. 解析结果XML字符串
String resultXmlString = StringEscapeUtils.unescapeXml(resultElement.getText());
Document resultDoc = DocumentHelper.parseText(resultXmlString);
Element resultRoot = resultDoc.getRootElement();
// 7. 查找data元素
Element dataElement = resultRoot.element("data");
if (dataElement == null) return new ArrayList<>();
// 8. 获取所有data_row元素
List<Element> dataRows = dataElement.elements("data_row");
if (dataRows.isEmpty()) return new ArrayList<>();
// 9. 解析每个data_row
List<Map<Object, Object>> resultList = new ArrayList<>();
for (Element dataRow : dataRows) {
Map<Object, Object> itemMap = new HashMap<>();
itemMap.put("COSTTYPE", getText(dataRow, "COSTTYPE"));
itemMap.put("COSTNAME", getText(dataRow, "COSTNAME"));
itemMap.put("COSTAMOUNT", getText(dataRow, "COSTAMOUNT"));
itemMap.put("COSTSUM", getText(dataRow, "COSTSUM"));
itemMap.put("UNIT", getText(dataRow, "UNIT"));
itemMap.put("AMOUNT", getText(dataRow, "AMOUNT"));
itemMap.put("ITEMNUM", getText(dataRow, "ITEMNUM"));
itemMap.put("PRESCRIPTIONNUM", getText(dataRow, "PRESCRIPTIONNUM"));
itemMap.put("AGENTTYPE", getText(dataRow, "AGENTTYPE"));
itemMap.put("SPEC", getText(dataRow, "SPEC"));
itemMap.put("HISCOSTCODE", getText(dataRow, "HISCOSTCODE"));
itemMap.put("YBCOSTCODE", getText(dataRow, "YBCOSTCODE"));
itemMap.put("YBCOSTNAME", getText(dataRow, "YBCOSTNAME"));
itemMap.put("YBINMSG", getText(dataRow, "YBINMSG"));
itemMap.put("RCPTNO", getText(dataRow, "RCPTNO"));
itemMap.put("PATIENTID", getText(dataRow, "PATIENTID"));
itemMap.put("FLOWNO", getText(dataRow, "FLOWNO"));
itemMap.put("KSBM", getText(dataRow, "KSBM"));
itemMap.put("KSMC", getText(dataRow, "KSMC"));
itemMap.put("KB", getText(dataRow, "KB"));
itemMap.put("YSBM", getText(dataRow, "YSBM"));
itemMap.put("YSMC", getText(dataRow, "YSMC"));
resultList.add(itemMap);
}
return resultList;
} catch (DocumentException e) {
e.printStackTrace();
return new ArrayList<>();
}
}
private static Element findElement(Element parent, String name, Namespace ns) {
for (Element child : parent.elements()) {
if (name.equals(child.getName()) && ns.equals(child.getNamespace())) {
return child;
}
}
return null;
}
private static String getText(Element parent, String childName) {
Element child = parent.element(childName);
return (child != null) ? child.getTextTrim() : null;
}
public static List<Map<String, Object>> getPacsRes(String soap, String name) throws DocumentException {
String res1 = name + "Response";
String res2 = name + "Result";
String soapWeb = org.apache.commons.lang.StringEscapeUtils.unescapeXml(soap);
soapWeb = soapWeb.replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
// 字符串转xml
Document doc = DocumentHelper.parseText(soapWeb);
//获取根节点
Element root = doc.getRootElement();
Element body = root.element("Body").element(res1).element(res2).element("response");
Element elresult = body.element("returnresult");
Element eldata = body.element("data");
System.out.println("根节点 为 : " + elresult.element("returncode").getText());
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
//判断返回值
String soapcode = elresult.element("returncode").getText();
if (soapcode.equals("1")) {
// 获取Body下的所有子节点
List<?> bodyChild = eldata.elements();
for (Iterator<?> it = bodyChild.iterator(); it.hasNext(); ) {
Map<String, Object> soapMap = new HashMap<String, Object>();
soapMap.put("returncode", soapcode);
Element elm1 = (Element) it.next();
List<?> responseChild = elm1.elements();
for (Iterator<?> it1 = responseChild.iterator(); it1.hasNext(); ) {
Element elm2 = (Element) it1.next();
soapMap.put(elm2.getName(), elm2.getTextTrim());
}
list.add(soapMap);
}
} else {
Map<String, Object> soapMap = new HashMap<String, Object>();
soapMap.put("returncode", soapcode);
soapMap.put("errormsg", elresult.element("errormsg").getText());
list.add(soapMap);
}
return list;
}
/**
* 定时任务解析 xml
*/
public static List<Map<String, String>> getTasks(String soap) throws DocumentException {
String soapWeb = StringEscapeUtils.unescapeXml(soap);
soapWeb = soapWeb.replace("<?xml version=\"1.0\"?>", "");
Document doc = DocumentHelper.parseText(soapWeb); // 字符串转xml
Element root = doc.getRootElement();//获取根节点
Element body = root.element("Body"); // 获取所需节点
Element response = body.element("queryAppRegistRecordsNewResponse");
Element result = response.element("queryAppRegistRecordsNewResult");
Element Response = result.element("Response");
String Result_Code = Response.elementTextTrim("Result_Code");
List<Map<String, String>> list = new ArrayList<Map<String, String>>();
if (Result_Code.equals("0000")) {
Element resultData = Response.element("Result_Data");
Element recordList = resultData.element("Record_List");
List<Element> elements = recordList.elements();
Iterator<Element> iterator = elements.iterator();
while (iterator.hasNext()) {
Element element = iterator.next();
Map<String, String> soapMap = new HashMap<String, String>();
soapMap.put("Result_Code", "0000");
soapMap.put("HIS_ORDER_NO", element.elementTextTrim("HIS_ORDER_NO")); // 交易流水号
soapMap.put("REGIST_TYPE", element.elementTextTrim("REGIST_TYPE")); // 预约单状态 1 已退费 0 正常
soapMap.put("ALLOWREFUNDFLAG", element.elementTextTrim("ALLOWREFUNDFLAG")); // 允许退号标志 N 不允许 Y 允许
list.add(soapMap);
}
} else {
Map<String, String> soapMap = new HashMap<String, String>();
soapMap.put("Result_Code", Result_Code);
soapMap.put("Error_Msg", Response.elementTextTrim("Error_Msg"));
list.add(soapMap);
}
return list;
}
/**
* 查询解析xml
*/
public static List<Map<String, Object>> getDeptQueryXml(String resp1, String resp2, String soap) throws DocumentException {
String soapWeb = StringEscapeUtils.unescapeXml(soap);
soapWeb = soapWeb.replace("<?xml version=\"1.0\"?>", "");
Document doc = DocumentHelper.parseText(soapWeb); // 字符串转xml
Element root = doc.getRootElement();//获取根节点
Element body = root.element("Body"); // 获取所需节点
Element response = body.element(resp1);
Element result = response.element(resp2);
Element Response = result.element("Response");
String Result_Code = Response.elementTextTrim("Result_Code");
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (Result_Code.equals("0000")) {
Element resultData = Response.element("Result_Data");
Element recordList = resultData.element("Record_List");
List<Element> elements = recordList.elements();
Iterator<Element> iterator = elements.iterator();
while (iterator.hasNext()) {
Element element = iterator.next();
Map<String, Object> soapMap = new HashMap<String, Object>();
soapMap.put("Result_Code", "0000");
soapMap.put("DEPT_CODE", element.elementTextTrim("DEPT_CODE"));
soapMap.put("DEPT_NAME", element.elementTextTrim("DEPT_NAME"));
soapMap.put("IS_ONLINE", element.elementTextTrim("IS_ONLINE"));
list.add(soapMap);
}
} else {
Map<String, Object> soapMap = new HashMap<String, Object>();
soapMap.put("Result_Code", Result_Code);
soapMap.put("Error_Msg", Response.elementTextTrim("Error_Msg"));
list.add(soapMap);
}
return list;
}
public static List<Map<String, Object>> getHidsQueryXml(String resp1, String resp2, String soap) throws DocumentException {
String soapWeb = StringEscapeUtils.unescapeXml(soap);
soapWeb = soapWeb.replace("<?xml version=\"1.0\"?>", "");
Document doc = DocumentHelper.parseText(soapWeb); // 字符串转xml
Element root = doc.getRootElement();//获取根节点
Element body = root.element("Body"); // 获取所需节点
Element response = body.element(resp1);
Element result = response.element(resp2);
Element Response = result.element("Response");
String Result_Code = Response.elementTextTrim("Result_Code");
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (Result_Code.equals("0000")) {
Element resultData = Response.element("Result_Data");
Element recordList = resultData.element("Record_List");
List<Element> elements = recordList.elements();
Iterator<Element> iterator = elements.iterator();
while (iterator.hasNext()) {
Element element = iterator.next();
Map<String, Object> soapMap = new HashMap<String, Object>();
soapMap.put("Result_Code", "0000");
soapMap.put("HID", element.elementTextTrim("HID"));
soapMap.put("DEPT_CODE", element.elementTextTrim("DEPT_CODE"));
soapMap.put("DOCTOR_CODE", element.elementTextTrim("DOCTOR_CODE"));
soapMap.put("DOCTOR_NAME", element.elementTextTrim("DOCTOR_NAME"));
soapMap.put("CLINIC_DATE", element.elementTextTrim("CLINIC_DATE"));
soapMap.put("HB_TIME", element.elementTextTrim("HB_TIME"));
soapMap.put("CLINIC_DURATION", element.elementTextTrim("CLINIC_DURATION"));
soapMap.put("REGISTERED_FEE", element.elementTextTrim("REGISTERED_FEE"));
soapMap.put("PHARMACY_FEE", element.elementTextTrim("PHARMACY_FEE"));
soapMap.put("DIAG_FEE", element.elementTextTrim("DIAG_FEE"));
soapMap.put("IS_ONLINE", element.elementTextTrim("IS_ONLINE"));
soapMap.put("HB_TYPE", element.elementTextTrim("HB_TYPE"));
list.add(soapMap);
}
} else {
Map<String, Object> soapMap = new HashMap<String, Object>();
soapMap.put("Result_Code", Result_Code);
soapMap.put("Error_Msg", Response.elementTextTrim("Error_Msg"));
list.add(soapMap);
}
return list;
}
public static String getRegistRefund(HisRefundVo vo) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_RegistRefund");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<SubHospitalID/>");
str.append("<PatientId>");
str.append(vo.getPatientid());
str.append("</PatientId>");
str.append("<HisOrderNO>");
str.append(vo.getBillsmsg());
str.append("</HisOrderNO>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_RegistRefund>");
return getRequestXMl(str);
}
/**
* 获取检查、报告信息
* @return
*/
public static String getPacsQuery(PacsVo vo) {
// 创建完整的SOAP信封
StringBuffer soapEnvelope = new StringBuffer();
soapEnvelope.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://server.webservice.nxwjzy.neusoft.com/\">");
soapEnvelope.append("<soapenv:Header/>");
soapEnvelope.append("<soapenv:Body>");
// 修改方法名:从 eRAD_StudiesReports 改为 StudiesReports
soapEnvelope.append("<ser:StudiesReports>");
soapEnvelope.append("<xmlRequest><![CDATA[<RequestParams>");
// 添加参数处理null值
appendParam(soapEnvelope, "PatientsName", vo.getPatientsName());
appendParam(soapEnvelope, "PatientsID", vo.getPatientsID());
appendParam(soapEnvelope, "RequestElectronic", vo.getRequestElectronic());
appendParam(soapEnvelope, "AccessionNumber", vo.getAccessionNumber());
appendParam(soapEnvelope, "PatientsCertificate", vo.getPatientsCertificate());
appendParam(soapEnvelope, "StudiesModalities", vo.getStudiesModalities());
appendParam(soapEnvelope, "AdmissionSource", vo.getAdmissionSource());
appendParam(soapEnvelope, "AdmissionID", vo.getAdmissionID());
appendParam(soapEnvelope, "RegisterDateTime", vo.getRegisterDateTime());
appendParam(soapEnvelope, "StudiesDateTime", vo.getStudiesDateTime());
appendParam(soapEnvelope, "ReportsDateTime", vo.getReportsDateTime());
appendParam(soapEnvelope, "ApproveDateTime", vo.getApproveDateTime());
soapEnvelope.append("</RequestParams>]]></xmlRequest>");
soapEnvelope.append("</ser:StudiesReports>"); // 修改闭合标签
soapEnvelope.append("</soapenv:Body>");
soapEnvelope.append("</soapenv:Envelope>");
return soapEnvelope.toString();
}
// 辅助方法:处理参数值(避免输出"null"字符串)
private static void appendParam(StringBuffer buffer, String paramName, String paramValue) {
buffer.append("<").append(paramName).append(">");
if (paramValue != null && !"null".equals(paramValue)) {
buffer.append(paramValue);
}
buffer.append("</").append(paramName).append(">");
}
public static String priceQuert(String classify, String iteminputcode) {
StringBuffer str = new StringBuffer();
String s = "";
str.append("<tem:PRICE_QUERY");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
if (classify != null){
s = classify;
}else {
s= "";
}
str.append("<CLASSIFY>");
str.append(s);
str.append("</CLASSIFY>");
if (iteminputcode != null){
s = iteminputcode;
}else {
s= "";
}
str.append("<ITEMINPUTCODE>");
str.append(s);
str.append("</ITEMINPUTCODE>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:PRICE_QUERY>");
return getRequestXMl(str);
}
public static String InHosFeeDetailQuery(String queryNum, String queryType, String searchType, String startTime,String endTime) {
StringBuffer str = new StringBuffer();
String s = "";
str.append("<tem:MOP_InHosFeeDetailQuery");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<SubHospitalID/>");
str.append("<QueryNum>");
str.append(queryNum);
str.append("</QueryNum>");
str.append("<QueryType>");
str.append(queryType);
str.append("</QueryType>");
str.append("<SearchType>");
str.append(searchType);
str.append("</SearchType>");
str.append("<StartTime>");
str.append(startTime);
str.append("</StartTime>");
str.append("<EndTime>");
str.append(endTime);
str.append("</EndTime>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_InHosFeeDetailQuery>");
return getRequestXMl(str);
}
/**
* 获取检查、报告信息
* @return
*/
public static String getPdfReports(String patientsID, String studiesDateTime, String requestElectronic, String accessionNumber, String studiesModalities, String admissionSource) {
// 创建完整的SOAP信封
StringBuffer soapEnvelope = new StringBuffer();
soapEnvelope.append("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:ser=\"http://server.webservice.nxwjzy.neusoft.com/\">");
soapEnvelope.append("<soapenv:Header/>");
soapEnvelope.append("<soapenv:Body>");
// 修改方法名:从 eRAD_StudiesReports 改为 GetPdfReportsAddress
soapEnvelope.append("<ser:GetPdfReportsAddress>");
soapEnvelope.append("<xmlRequest><![CDATA[<RequestParams>");
// 添加参数处理null值
appendParam(soapEnvelope, "PatientsName", "");
appendParam(soapEnvelope, "PatientsID", patientsID);
appendParam(soapEnvelope, "RequestElectronic", requestElectronic);
appendParam(soapEnvelope, "AccessionNumber", accessionNumber);
appendParam(soapEnvelope, "PatientsCertificate", "");
appendParam(soapEnvelope, "StudiesModalities", studiesModalities);
appendParam(soapEnvelope, "AdmissionSource", admissionSource);
appendParam(soapEnvelope, "AdmissionID", "");
appendParam(soapEnvelope, "RegisterDateTime", "");
appendParam(soapEnvelope, "StudiesDateTime", studiesDateTime);
appendParam(soapEnvelope, "ReportsDateTime", "");
appendParam(soapEnvelope, "ApproveDateTime", "");
soapEnvelope.append("</RequestParams>]]></xmlRequest>");
soapEnvelope.append("</ser:GetPdfReportsAddress>"); // 修改闭合标签
soapEnvelope.append("</soapenv:Body>");
soapEnvelope.append("</soapenv:Envelope>");
return soapEnvelope.toString();
}
/**
* 获取分时信息xml
* @param startTime
* @param endTime
* @param departCode
* @param doctorCode
* @return
*/
public static String getPartimeQueryXML(String startTime, String endTime, String departCode, String doctorCode) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpSchedulePartimeQuery");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<StartTime>");
str.append(startTime);
str.append("</StartTime>");
str.append("<EndTime>");
str.append(endTime);
str.append("</EndTime>");
str.append("<DepartCode>");
str.append(departCode);
str.append("</DepartCode>");
str.append("<DoctorCode>");
str.append(doctorCode);
str.append("</DoctorCode>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpSchedulePartimeQuery>");
return getRequestXMl(str);
}
public static String OutpBAPayedConfirm(BingAnVO vo) {
StringBuffer str = new StringBuffer();
str.append("<tem:MOP_OutpBAPayedConfirm");
str.append("><tem:InMsg>");
str.append("<![CDATA[");
str.append("<request>");
str.append("<PatientId>");
str.append(vo.getPatientId());
str.append("</PatientId>");
str.append("<PowerTranID>");
str.append(vo.getOrderno());
str.append("</PowerTranID>");
str.append("<Pages>");
str.append(vo.getPages()*vo.getCopies());
str.append("</Pages>");
str.append("<ZFamount>");
// 安全的数值减法运算,处理可能的空值和精度问题
BigDecimal amount = vo.getAmount();
BigDecimal selectAmount = vo.getSelectAmount();
BigDecimal result = BigDecimal.ZERO;
if (amount != null && selectAmount != null) {
result = amount.subtract(selectAmount);
} else if (amount != null) {
result = amount;
} else if (selectAmount != null) {
result = selectAmount.negate();
}
str.append(result);
str.append("</ZFamount>");
str.append("</request>");
str.append("]]>");
str.append("</tem:InMsg>");
str.append("</tem:MOP_OutpBAPayedConfirm>");
return getRequestXMl(str);
}
}