You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					
					
						
							180 lines
						
					
					
						
							7.1 KiB
						
					
					
				
			
		
		
	
	
							180 lines
						
					
					
						
							7.1 KiB
						
					
					
				package com.ynxbd.common.helper.common;
 | 
						|
 | 
						|
import com.ynxbd.wx.config.WeChatConfig;
 | 
						|
import com.ynxbd.common.dao.his.HisRecipeDao;
 | 
						|
import lombok.extern.slf4j.Slf4j;
 | 
						|
import org.apache.commons.lang3.StringUtils;
 | 
						|
import org.slf4j.Logger;
 | 
						|
import org.slf4j.LoggerFactory;
 | 
						|
 | 
						|
 | 
						|
/**
 | 
						|
 * 快速发药
 | 
						|
 *
 | 
						|
 * @Author wsq
 | 
						|
 * @Date 2020/11/20 11:53
 | 
						|
 * @Copyright @ 2020 云南新八达科技有限公司 All rights reserved.
 | 
						|
 */
 | 
						|
@Slf4j
 | 
						|
public class QuickDrugDispenseHelper {
 | 
						|
 | 
						|
    /**
 | 
						|
     * 快速发药
 | 
						|
     *
 | 
						|
     * @param drugInfo       药瓶号
 | 
						|
     * @param invoiceTransNo 发票号(作为交易流水号传递)
 | 
						|
     * @return 是否成功
 | 
						|
     */
 | 
						|
    public static boolean quickDrug(String drugInfo, String invoiceTransNo) {
 | 
						|
        if (StringUtils.isEmpty(drugInfo) || StringUtils.isEmpty(invoiceTransNo)) {
 | 
						|
            return false;
 | 
						|
        }
 | 
						|
        try {
 | 
						|
            log.info("[快速发药]开始执行");
 | 
						|
            String appId = WeChatConfig.APP_ID;
 | 
						|
 | 
						|
            drugInfo = convertFromXml(drugInfo.trim());
 | 
						|
            drugInfo = drugInfo.replace("GB2312", "utf8");
 | 
						|
 | 
						|
            String soapUrl, soapAction, soapXML;
 | 
						|
            switch (appId) {
 | 
						|
                case "wxd503671f502bd89d": // 红河州医院
 | 
						|
                    soapUrl = "http://10.255.248.21:8735/DispensingIntegration?singleWsdl";
 | 
						|
                    soapAction = "BD.BDIEService/IRDIS/TaskAdmit";
 | 
						|
                    soapXML =
 | 
						|
                            "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:bd=\"BD.BDIEService\"><soapenv:Header/><soapenv:Body>"
 | 
						|
                                    + "<bd:TaskAdmit><bd:WindowNo></bd:WindowNo><bd:Priority>1</bd:Priority><bd:PrescriptionInfoList>"
 | 
						|
                                    + "<![CDATA[" + drugInfo + "]]></bd:PrescriptionInfoList></bd:TaskAdmit>"
 | 
						|
                                    + "</soapenv:Body></soapenv:Envelope>";
 | 
						|
                    break;
 | 
						|
 | 
						|
                case "wx64cc4b42bbed4090":  // 蒙自市医院
 | 
						|
                    soapUrl = "http://200.200.200.173:8788/axis2/services/DIHPMPFWebService?wsdl";
 | 
						|
                    soapAction = "urn:outpOrderDispense";
 | 
						|
                    soapXML =
 | 
						|
                            "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:web=\"http://webservice.pmpf.dih.com\"><soapenv:Header/><soapenv:Body>"
 | 
						|
                                    + "<web:outpOrderDispense><web:xml>"
 | 
						|
                                    + "<![CDATA[" + drugInfo + "]]></web:xml></web:outpOrderDispense>"
 | 
						|
                                    + "</soapenv:Body></soapenv:Envelope>";
 | 
						|
                    break;
 | 
						|
 | 
						|
                case "wx1f1e9d29f9b44c36":
 | 
						|
                    soapUrl = "http://172.16.24.51:8000/ConsisWebService/ServiceHis.svc?singleWsdl";
 | 
						|
                    soapAction = "http://tempuri.org/IHisService/HisTransData";
 | 
						|
                    soapXML =
 | 
						|
                            "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:tem=\"http://tempuri.org/\"><soapenv:Header/> <soapenv:Body><tem:HisTransData><tem:value>"
 | 
						|
                                    + "<![CDATA[" + drugInfo
 | 
						|
                                    + "]]></tem:value></tem:HisTransData></soapenv:Body></soapenv:Envelope>";
 | 
						|
                    break;
 | 
						|
 | 
						|
                default:
 | 
						|
                    return false;
 | 
						|
            }
 | 
						|
 | 
						|
            log.info("[快速发药]发送请求:" + soapXML);
 | 
						|
            String respData = SoapHelper.post("快速发药", soapUrl, soapAction, soapXML);
 | 
						|
            if (respData == null) {
 | 
						|
                log.info("[快速发药]创建连接失败");
 | 
						|
                return false;
 | 
						|
            }
 | 
						|
 | 
						|
            log.info("[快速发药]执行返回:{}", respData);
 | 
						|
 | 
						|
            if ("wx64cc4b42bbed4090".equals(appId)) {
 | 
						|
                if (!respData.contains("status code=\"0\"")) {
 | 
						|
                    return false;
 | 
						|
                }
 | 
						|
 | 
						|
                String windowNo = subString(respData, "windowNo>", "</windowNo>");
 | 
						|
                String groupNo = subString(respData, "groupNo>", "</groupNo>");
 | 
						|
 | 
						|
                if (StringUtils.isEmpty(windowNo) || StringUtils.isEmpty(groupNo)) {
 | 
						|
                    return false;
 | 
						|
                }
 | 
						|
 | 
						|
                String responseXml = new HisRecipeDao().hisQuickDrug(windowNo, groupNo, invoiceTransNo);
 | 
						|
                log.info("蒙自 HIS发药返回 " + responseXml);
 | 
						|
                return true;
 | 
						|
            }
 | 
						|
 | 
						|
            if ("wx1f1e9d29f9b44c36".equals(appId)) { // 玉龙县人民医院
 | 
						|
                if (!respData.contains("RETVAL>1</RETVAL")) {
 | 
						|
                    return false;
 | 
						|
                }
 | 
						|
 | 
						|
                String windowNo = subString(respData, "RETMSG>", "</RETMSG");
 | 
						|
                String groupNo = "";
 | 
						|
 | 
						|
                if (StringUtils.isEmpty(windowNo)) {
 | 
						|
                    return false;
 | 
						|
                }
 | 
						|
 | 
						|
                String responseXml = new HisRecipeDao().hisQuickDrug(windowNo, groupNo, invoiceTransNo);
 | 
						|
                log.info("玉龙 HIS发药返回 " + responseXml);
 | 
						|
 | 
						|
            }
 | 
						|
        } catch (Exception e) {
 | 
						|
            log.info("[快速发药]调用失败:" + e.getMessage());
 | 
						|
            ErrorHelper.println(e);
 | 
						|
        }
 | 
						|
        return true;
 | 
						|
    }
 | 
						|
 | 
						|
 | 
						|
    private static String convertFromXml(String str) {
 | 
						|
        boolean flag = true;
 | 
						|
        boolean quotesFlag = true;
 | 
						|
        StringBuilder ans = new StringBuilder();
 | 
						|
        String tmp = "";
 | 
						|
        for (int i = 0; i < str.length(); i++) {
 | 
						|
            if ('"' == str.charAt(i)) {
 | 
						|
                ans.append(str.charAt(i));
 | 
						|
                quotesFlag = !quotesFlag;
 | 
						|
            } else if ('<' == str.charAt(i)) {
 | 
						|
                tmp = tmp.trim();
 | 
						|
                ans.append(tmp);
 | 
						|
                flag = true;
 | 
						|
                ans.append(str.charAt(i));
 | 
						|
            } else if ('>' == str.charAt(i)) {
 | 
						|
                if (quotesFlag) {
 | 
						|
                    flag = false;
 | 
						|
                    ans.append(str.charAt(i));
 | 
						|
                    tmp = "";
 | 
						|
                } else {
 | 
						|
                    ans.append(">");
 | 
						|
                }
 | 
						|
            } else if (flag) {
 | 
						|
                ans.append(str.charAt(i));
 | 
						|
            } else {
 | 
						|
                tmp += str.charAt(i);
 | 
						|
            }
 | 
						|
        }
 | 
						|
        return ans.toString();
 | 
						|
    }
 | 
						|
 | 
						|
    /**
 | 
						|
     * 截取字符串str中指定字符 strStart、strEnd之间的字符串
 | 
						|
     *
 | 
						|
     * @param str      被截取字符串
 | 
						|
     * @param strStart 开始截取字符串
 | 
						|
     * @param strEnd   结束截取的字符串
 | 
						|
     * @return 截取后的字符串
 | 
						|
     */
 | 
						|
    private static String subString(String str, String strStart, String strEnd) {
 | 
						|
 | 
						|
        /* 找出指定的2个字符在 该字符串里面的 位置 */
 | 
						|
        int strStartIndex = str.indexOf(strStart);
 | 
						|
        int strEndIndex = str.indexOf(strEnd);
 | 
						|
 | 
						|
        /* index 为负数 即表示该字符串中 没有该字符 */
 | 
						|
        if (strStartIndex < 0) {
 | 
						|
            return "";
 | 
						|
        }
 | 
						|
        if (strEndIndex < 0) {
 | 
						|
            return "";
 | 
						|
        }
 | 
						|
        /* 开始截取 */
 | 
						|
        return str.substring(strStartIndex, strEndIndex).substring(strStart.length());
 | 
						|
    }
 | 
						|
 | 
						|
}
 | 
						|
 |