Selaa lähdekoodia

银医通与余额查询接口合并

zdm 5 vuotta sitten
vanhempi
commit
6791fdc717

+ 30 - 0
business/base-service/pom.xml

@ -93,6 +93,36 @@
            <version>2.4</version>
        </dependency>
        <!-- mq消息 end -->
        <!-- webService start -->
        <dependency>
            <groupId>org.apache.axis</groupId>
            <artifactId>axis</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>javax.xml.rpc</groupId>
            <artifactId>javax.xml.rpc-api</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>wsdl4j</groupId>
            <artifactId>wsdl4j</artifactId>
            <version>1.6.2</version>
        </dependency>
        <dependency>
            <groupId>commons-discovery</groupId>
            <artifactId>commons-discovery</artifactId>
            <version>0.5</version>
        </dependency>
        <dependency>
            <groupId>org.assertj</groupId>
            <artifactId>assertj-core</artifactId>
            <version>2.5.0</version>
        </dependency>
        <!-- webService end -->
    </dependencies>
    <build>
        <resources>

+ 69 - 22
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/EntranceService.java

@ -7,26 +7,23 @@ import com.yihu.jw.entity.hospital.mapping.HospitalDeptMappingDO;
import com.yihu.jw.hospital.mapping.dao.HospitalDeptMappingDao;
import com.yihu.jw.hospital.prescription.service.entrance.util.ConvertUtil;
import com.yihu.jw.hospital.prescription.service.entrance.util.MqSdkUtil;
import com.yihu.jw.hospital.prescription.service.entrance.util.WebserviceUtil;
import com.yihu.jw.restmodel.hospital.prescription.WlyyHisPrescriptionVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionDiagnosisVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionInfoVO;
import com.yihu.jw.restmodel.hospital.prescription.WlyyPrescriptionVO;
import com.yihu.jw.restmodel.web.ListEnvelop;
import com.yihu.jw.util.date.DateUtil;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSON;
import net.sf.json.JSONArray;
import net.sf.json.xml.XMLSerializer;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam;
import javax.transaction.Transactional;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.*;
@ -114,22 +111,29 @@ public class EntranceService {
        if(demoFlag){
            resp=getJosnFileResullt(fid);
        }else{
            JSONObject msg=new JSONObject();
            msg.put("endNum","20000");
            msg.put("Msg", new net.sf.json.JSONArray() );
            JSONObject query=new JSONObject();
            query.put("@compy","=");
            query.put("@item","CARD_NO");
            query.put("@splice","and");
            query.put("@value",cardNo);
            msg.put("query",query);
            msg.put("startNum",1);
            List<String> stringList=new ArrayList<>();
            stringList.add(cardNo);
            //获取消息
            resp = MqSdkUtil.putReqAndGetResp(msg.toString(), fid, "1",stringList);
            //解析
            resp= MqSdkUtil.xml2jsonObject(resp);
            //先调用银医通获取下载余额到his,再查询his中卡余额
            net.sf.json.JSONObject jsonObject= callYYTServerService(cardNo);
           if(null==jsonObject && "success".equals(jsonObject.get("code").toString())){
               JSONObject msg=new JSONObject();
               msg.put("endNum","20000");
               msg.put("Msg", new net.sf.json.JSONArray() );
               JSONObject query=new JSONObject();
               query.put("@compy","=");
               query.put("@item","CARD_NO");
               query.put("@splice","and");
               query.put("@value",cardNo);
               msg.put("query",query);
               msg.put("startNum",1);
               List<String> stringList=new ArrayList<>();
               stringList.add(cardNo);
               //获取消息
               resp = MqSdkUtil.putReqAndGetResp(msg.toString(), fid, "1",stringList);
               //解析
               resp= MqSdkUtil.xml2jsonObject(resp);
           }else {
               return jsonObject;
           }
        }
        return  ConvertUtil.convertObjectEnvelopByString(resp);
    }
@ -819,4 +823,47 @@ public class EntranceService {
        return resp;
    }
    /**
     * 银医通下载
     * @param cardNo 待查询的卡号
     **/
    public net.sf.json.JSONObject callYYTServerService(String cardNo) throws Exception {
        String re = "";
        net.sf.json.JSONObject jsonObject=new net.sf.json.JSONObject();
        String action = "CallYYTServerService";
        String info_xml = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
                "<root><ip>172.16.50.40</ip><port>5516</port></root>";
        String reqmsg_xml = "<?xml version=\"1.0\" encoding=\"utf-16\"?>" +
                "<root><sick_id>" + cardNo + "</sick_id><cus_card_no>" + cardNo + "</cus_card_no>" +
                "<req_type>2001</req_type><trade_type>2001</trade_type><req_oper>8644</req_oper><req_term>192001019019</req_term><win_no>6</win_no></root>";
        Map<String, String> params = new HashMap<>();
        params.put("ServerInfo", info_xml);
        params.put("RegMsg", reqmsg_xml);
        String urlString = "http://172.16.50.40:80/ZyXmyytRequestService/ZyXmyytRequestServiceWs.dll?Handler=ZyXmyytRequestServiceWsService";
        String namespace = "zysoft";
        re = WebserviceUtil.post(urlString, namespace, action, params);
        XMLSerializer xmlSerializer = new XMLSerializer();
        JSON json = xmlSerializer.read(re);
        Object errorCode = ((net.sf.json.JSONObject) json).get("error_code");
        if ("ok".equals(errorCode)) {
            JSON json2 = xmlSerializer.read(((net.sf.json.JSONObject) json).get("response").toString());
            System.out.println("银医通下载response:" + json2.toString(1));
            jsonObject.element("code","success");
            jsonObject.element("obj",json);
        } else {
            Object errorMsg = ((net.sf.json.JSONObject) json).get("error_msg");
            jsonObject.element("code","error");
            jsonObject.element("obj","银医通下载失败," +errorMsg);
            //{"error_type":"0","error_code":"10002","error_msg":"卡号无效"}
        }
        if (StringUtils.isEmpty(re)) {
            throw new Exception("返回为空!");
        } else {
            if (re.startsWith("error")) {
                throw new Exception(re);
            }
        }
        return jsonObject;
    }
}

+ 55 - 0
business/base-service/src/main/java/com/yihu/jw/hospital/prescription/service/entrance/util/WebserviceUtil.java

@ -0,0 +1,55 @@
package com.yihu.jw.hospital.prescription.service.entrance.util;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.xml.namespace.QName;
import java.util.Map;
/**
 * Created by zdm on 2019/5/31.
 * webservice调用服务
 **/
public class WebserviceUtil {
    private static Logger logger = LoggerFactory.getLogger(WebserviceUtil.class);
   /*  * webservice 调用接口*/
    public static String post(String urlString,String namespace,String api, Map<String,String> params) throws Exception {
        try {
            Service service = new Service();
            // 通过service创建call对象
            Call call = (Call) service.createCall();
            // 设置service所在URL
            call.setTargetEndpointAddress(new java.net.URL(urlString));
            call.setOperationName(new QName(namespace, api));
            call.setUseSOAPAction(true);
            Object[] objs = null;
            if (params != null && params.size() > 0) {
                objs = new Object[params.size()];
                int i = 0;
                for (String key : params.keySet()) {
                    //接口的参数
                    call.addParameter(new QName(key), org.apache.axis.encoding.XMLType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
                    objs[i] = params.get(key);
                    i++;
                }
            }
            //设置返回类型
            call.setReturnType(org.apache.axis.encoding.XMLType.XSD_STRING);
            String ret = (String) call.invoke(objs);
            logger.info("=======>请求结果.toString():" + ret.toString());
            return ret.toString();
        } catch (Exception e) {
            logger.info("=======>CA请求报错:" + e.getMessage());
            e.printStackTrace();
            throw e;
        }
    }
}

+ 33 - 0
business/base-service/src/mqConfig/mqdata/yyt.json

@ -0,0 +1,33 @@
{
	"error_type": "2",
	"error_code": "ok",
	"error_msg": [],
	"his_log_no": "9851BE4A-FC77-4987-9A97-5383B1E0572F",
	"response": {
		"@version": "1.0",
		"ans_type": "2001",
		"ans_name": "余额下载",
		"ans_date": "20190531",
		"ans_time": "172420205",
		"ans_code": "00",
		"ans_msg": "交易成功",
		"ans_seq": "0113183",
		"req_date": "20190531",
		"req_org": "0000350211A1002",
		"req_seq": "5132388",
		"cus_guid": "f9d4fdfb-52c2-4aa3-8f77-4b629140a100",
		"cus_card_no": "DB8687139",
		"cus_acc_no": "00156000000030525052",
		"cus_acc_type": "0",
		"cus_currency": "156",
		"cus_acc_status": "000",
		"cus_acc_occupy": "1",
		"cus_occ_org": "0000350211A1002",
		"cus_bal": "60.89",
		"cus_ava_bal": "60.89",
		"cus_total_freeze": "0.00",
		"cus_totfre_count": "0",
		"cus_freeze": "0.00",
		"cus_freeze_count": "0"
	}
}

+ 14 - 0
svr/svr-internet-hospital-entrance/src/main/java/com/yihu/jw/entrance/controller/MqSdkController.java

@ -373,6 +373,20 @@ public class MqSdkController extends EnvelopRestEndpoint {
        return "";
    }
    @GetMapping(value = "/yytDown")
    @ApiOperation(value = " 银医通下载 ")
    public JSONObject yytDown(
            @ApiParam(name = "cardNo", value = "卡号", required = true)
            @RequestParam(value = "cardNo") String cardNo) {
        try {
            JSONObject  obj= entranceService.callYYTServerService(cardNo);
            return obj;
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}