Browse Source

代码测试

hurugang 5 years ago
parent
commit
97ac6ccc92

+ 13 - 89
src/main/java/cn/hnthyy/thmz/controller/api/MedicalViewApiController.java

@@ -1,8 +1,9 @@
 package cn.hnthyy.thmz.controller.api;
 
 
-import cn.hnthyy.thmz.comment.UserLoginToken;
 import cn.hnthyy.thmz.common.Constants;
+import cn.hnthyy.thmz.entity.haici.HaiciCharge;
+import cn.hnthyy.thmz.entity.haici.Haicipat;
 import cn.hnthyy.thmz.entity.his.MzChargeDetail;
 import cn.hnthyy.thmz.entity.his.MzDepositFile;
 import cn.hnthyy.thmz.entity.his.MzPatientMi;
@@ -12,14 +13,11 @@ import cn.hnthyy.thmz.service.his.MzChargeDetailService;
 import cn.hnthyy.thmz.service.his.MzDepositFileService;
 import cn.hnthyy.thmz.service.his.MzPatientMiService;
 import cn.hnthyy.thmz.vo.MzDepositFileVo;
-import com.fasterxml.jackson.annotation.JsonFormat;
-import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.dao.DataIntegrityViolationException;
-import org.springframework.format.annotation.DateTimeFormat;
-import org.springframework.web.bind.annotation.PathVariable;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
@@ -56,9 +54,8 @@ public class MedicalViewApiController {
      * @param haicipat
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/queryPatientInfo",method = {RequestMethod.POST})
-    public Map<String,Object> queryPatientInfo(Haicipat haicipat) {
+    public Map<String,Object> queryPatientInfo(@RequestBody Haicipat haicipat) {
         Map<String,Object> results = new HashMap<>();
         if(StringUtils.isBlank(haicipat.getPatIdType())){
             results.put("resultCode",-1);
@@ -101,9 +98,8 @@ public class MedicalViewApiController {
      * @param haicipat
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/savePatientInfo",method = {RequestMethod.POST})
-    public Map<String,Object> savePatientInfo(Haicipat haicipat) {
+    public Map<String,Object> savePatientInfo(@RequestBody Haicipat haicipat) {
         Map<String,Object> results = new HashMap<>();
         if(haicipat==null){
             results.put("resultCode",-1);
@@ -222,9 +218,8 @@ public class MedicalViewApiController {
      * @param haicipat
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/boundPatCardNoInfo",method = {RequestMethod.POST})
-    public Map<String,Object> boundPatCardNoInfo(Haicipat haicipat) {
+    public Map<String,Object> boundPatCardNoInfo(@RequestBody Haicipat haicipat) {
         Map<String,Object> results = new HashMap<>();
         if(haicipat==null){
             results.put("resultCode",-1);
@@ -321,9 +316,8 @@ public class MedicalViewApiController {
      * @param haicipat
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/cancelBoundPatCardNoInfo",method = {RequestMethod.POST})
-    public Map<String,Object> cancelBoundPatCardNoInfo(Haicipat haicipat) {
+    public Map<String,Object> cancelBoundPatCardNoInfo(@RequestBody Haicipat haicipat) {
         Map<String,Object> results = new HashMap<>();
         if(haicipat==null){
             results.put("resultCode",-1);
@@ -416,9 +410,8 @@ public class MedicalViewApiController {
      * @param haicipat
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/getMzChargeDetailForUnPaid",method = {RequestMethod.POST})
-    public Map<String,Object> getMzChargeDetailForUnPaid(Haicipat haicipat) {
+    public Map<String,Object> getMzChargeDetailForUnPaid(@RequestBody Haicipat haicipat) {
         Map<String,Object> results = new HashMap<>();
         if(haicipat==null){
             results.put("resultCode",-1);
@@ -485,9 +478,8 @@ public class MedicalViewApiController {
      * @param haiciCharge
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/getChargeDetailByHisOrdNum",method = {RequestMethod.POST})
-    public Map<String,Object> getChargeDetailByHisOrdNum(HaiciCharge haiciCharge) {
+    public Map<String,Object> getChargeDetailByHisOrdNum(@RequestBody HaiciCharge haiciCharge) {
         Map<String,Object> results = new HashMap<>();
         if(haiciCharge==null){
             results.put("resultCode",-1);
@@ -556,9 +548,8 @@ public class MedicalViewApiController {
      * @param haiciCharge
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/payChargeDetailFormHaiCi",method = {RequestMethod.POST})
-    public Map<String,Object> payChargeDetailFormHaiCi(HaiciCharge haiciCharge) {
+    public Map<String,Object> payChargeDetailFormHaiCi(@RequestBody HaiciCharge haiciCharge) {
         Map<String,Object> results = new HashMap<>();
         if(haiciCharge==null){
             results.put("resultCode",-1);
@@ -653,9 +644,8 @@ public class MedicalViewApiController {
      * @param haiciCharge
      * @return
      */
-    //@UserLoginToken
     @RequestMapping(value="/getPayStatus",method = {RequestMethod.POST})
-    public Map<String,Object> getPayStatus(HaiciCharge haiciCharge) {
+    public Map<String,Object> getPayStatus(@RequestBody HaiciCharge haiciCharge) {
         Map<String,Object> results = new HashMap<>();
         if(haiciCharge==null){
             results.put("resultCode",-1);
@@ -724,76 +714,10 @@ public class MedicalViewApiController {
 
 
 
-    /**
-     * 海慈参数类
-     */
-    @Data
-    private class Haicipat{
-        //患者类型 1:成人 2:儿童
-        private String patType;
-        //姓名
-        private String patName;
-        //性别 M:男,F:女
-        private String patSex;
-        //年龄
-        private Integer patAge;
-        //出生日期
-        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
-        private Date patBirth;
-        //地址
-        private String patAddress;
-        //电话
-        private String patMobile;
-        //证件类型 1:二代身份证 2:港澳居民身份证 3:台湾居民身份证 4:护照 患者类型为“2”儿童时,该项允许为空
-        private String patIdType;
-        //证件号码 患者类型为“2”儿童时,该项允许为空
-        private String patIdNo;
-        //监护人姓名 患者类型为“2”儿童时,该项必输
-        private String guardName;
-        // 监护人证件类型  患者类型为“2”儿童时,该项必输
-        private String guardIdType;
-        //监护人证件号码 患者类型为“2”儿童时,该项必输
-        private String guardIdNo;
-        //诊疗卡类型  1:院内诊疗卡 2:社保卡 3:医保卡 4:区域健康卡
-        private Integer patCardType;
-        //诊疗卡号码
-        private String patCardNo;
-        //绑定渠道类型  WX:微信公众服务号 ZFB:支付宝钱包服务窗
-        private String channelType;
-        //渠道用户 ID 唯一标识微信公众服务号或者支付宝钱包 服务窗用户的 id,医院如需存储,需要保留 200 位的字段
-        private String openId;
-    }
 
 
-    /**
-     * 海慈缴费参数类
-     */
-    @Data
-    private class HaiciCharge{
-        //诊疗卡类型  1:院内诊疗卡 2:社保卡 3:医保卡 4:区域健康卡
-        private Integer patCardType;
-        //诊疗卡号码
-        private String patCardNo;
-        //绑定渠道类型  WX:微信公众服务号 ZFB:支付宝钱包服务窗
-        private String channelType;
-        //渠道用户 ID 唯一标识微信公众服务号或者支付宝钱包 服务窗用户的 id,医院如需存储,需要保留 200 位的字段
-        private String openId;
-        //医院订单号
-        private String hisOrdNum;
-        //平台订单号
-        private String psOrdNum;
-        //支付方式
-        private String payMode;
-        //支付金额
-        private BigDecimal payAmt;
-        //支付机构流水号
-        private String agtOrdNum;
-        //支付时间
-        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
-        private Date payTime;
-    }
+
+
 
 
 }

+ 37 - 0
src/main/java/cn/hnthyy/thmz/entity/haici/HaiciCharge.java

@@ -0,0 +1,37 @@
+package cn.hnthyy.thmz.entity.haici;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+     * 海慈缴费参数类
+     */
+    @Data
+    public class HaiciCharge{
+        //诊疗卡类型  1:院内诊疗卡 2:社保卡 3:医保卡 4:区域健康卡
+        private Integer patCardType;
+        //诊疗卡号码
+        private String patCardNo;
+        //绑定渠道类型  WX:微信公众服务号 ZFB:支付宝钱包服务窗
+        private String channelType;
+        //渠道用户 ID 唯一标识微信公众服务号或者支付宝钱包 服务窗用户的 id,医院如需存储,需要保留 200 位的字段
+        private String openId;
+        //医院订单号
+        private String hisOrdNum;
+        //平台订单号
+        private String psOrdNum;
+        //支付方式
+        private String payMode;
+        //支付金额
+        private BigDecimal payAmt;
+        //支付机构流水号
+        private String agtOrdNum;
+        //支付时间
+        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+        private Date payTime;
+    }

+ 48 - 0
src/main/java/cn/hnthyy/thmz/entity/haici/Haicipat.java

@@ -0,0 +1,48 @@
+package cn.hnthyy.thmz.entity.haici;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+     * 海慈参数类
+     */
+    @Data
+    public class Haicipat{
+        //患者类型 1:成人 2:儿童
+        private String patType;
+        //姓名
+        private String patName;
+        //性别 M:男,F:女
+        private String patSex;
+        //年龄
+        private Integer patAge;
+        //出生日期
+        @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone="GMT+8")
+        private Date patBirth;
+        //地址
+        private String patAddress;
+        //电话
+        private String patMobile;
+        //证件类型 1:二代身份证 2:港澳居民身份证 3:台湾居民身份证 4:护照 患者类型为“2”儿童时,该项允许为空
+        private String patIdType;
+        //证件号码 患者类型为“2”儿童时,该项允许为空
+        private String patIdNo;
+        //监护人姓名 患者类型为“2”儿童时,该项必输
+        private String guardName;
+        // 监护人证件类型  患者类型为“2”儿童时,该项必输
+        private String guardIdType;
+        //监护人证件号码 患者类型为“2”儿童时,该项必输
+        private String guardIdNo;
+        //诊疗卡类型  1:院内诊疗卡 2:社保卡 3:医保卡 4:区域健康卡
+        private Integer patCardType;
+        //诊疗卡号码
+        private String patCardNo;
+        //绑定渠道类型  WX:微信公众服务号 ZFB:支付宝钱包服务窗
+        private String channelType;
+        //渠道用户 ID 唯一标识微信公众服务号或者支付宝钱包 服务窗用户的 id,医院如需存储,需要保留 200 位的字段
+        private String openId;
+    }

+ 56 - 16
src/test/java/cn/hnthyy/thmz/ThmzApiTests.java

@@ -1,6 +1,15 @@
 package cn.hnthyy.thmz;
 
 
+import org.apache.http.HttpEntity;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+import org.apache.http.util.EntityUtils;
+import org.json.JSONException;
+import org.json.JSONObject;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -13,23 +22,54 @@ import java.util.Map;
 @RunWith(SpringRunner.class)
 @SpringBootTest
 public class ThmzApiTests {
-    private String url = "https://172.16.30.33/thmz/api/v1";
-    private String charset = "utf-8";
-    private HttpClientUtil httpClientUtil = null;
-
-    @Test
-    public String testQueryUserInfo(){
-        String httpOrgCreateTest = url + "httpOrg/create";
-        Map<String,String> createMap = new HashMap<>();
-        createMap.put("authuser","*****");
-        createMap.put("authpass","*****");
-        createMap.put("orgkey","****");
-        createMap.put("orgname","****");
-        String httpOrgCreateTestRtn = httpClientUtil.doPost(httpOrgCreateTest,createMap,charset);
-        System.out.println("result:"+httpOrgCreateTestRtn);
-    }
+//    private String url = "https://localhost:8089/thmz/api/v1";
+//    private String charset = "utf-8";
+//    private HttpClientUtil httpClientUtil = new HttpClientUtil();
+//
+//    @Test
+//    public void testQueryUserInfo(){
+//        String httpOrgCreateTest = url + "/queryPatientInfo";
+//        Map<String,String> createMap = new HashMap<>();
+//        createMap.put("patIdType","11");
+//        createMap.put("patIdNo","4301181199608207363");
+//        String httpOrgCreateTestRtn = httpClientUtil.doPost(httpOrgCreateTest,createMap,charset);
+//        System.out.println("result:"+httpOrgCreateTestRtn);
+//    }
 
+    /**
+     * 定义所需的变量
+     */
+    private static HttpClient httpClient = new DefaultHttpClient();
+    private static HttpPost httppost;
+    private static HttpResponse response;
+    private HttpEntity entity;
+    private String postResult = null;
 
+    public static void main(String[] args) throws JSONException {
+
+        String loginURL = "https://172.16.30.33:8089/thmz/api/v1";
+        // 创建一个httppost请求
+        httppost = new HttpPost(loginURL);
+        JSONObject jsonParam = new JSONObject();
+        jsonParam.put("patIdType", "11");
+        jsonParam.put("patIdNo","4301181199608207363");
+
+        try {
+
+            StringEntity entity = new StringEntity(jsonParam.toString(), "utf-8");// 解决中文乱码问题
+            entity.setContentEncoding("UTF-8");
+            entity.setContentType("application/json");
+            httppost.setEntity(entity);
+            response = httpClient.execute(httppost);
+            String strResult = EntityUtils.toString(response.getEntity());
+            System.out.println("查看返回的结果:" + strResult);
 
-}
 
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        httppost.releaseConnection();
+    }
+
+}