Explorar el Código

解决微信二维码接口超时问题

hurugang hace 3 años
padre
commit
3b0c67ac7a

+ 10 - 1
src/main/java/cn/hnthyy/thmz/Utils/HttpUtil.java

@@ -11,6 +11,7 @@ import org.apache.http.HttpEntity;
 import org.apache.http.HttpStatus;
 import org.apache.http.NameValuePair;
 import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.entity.UrlEncodedFormEntity;
 import org.apache.http.client.methods.CloseableHttpResponse;
 import org.apache.http.client.methods.HttpGet;
@@ -51,6 +52,8 @@ public class HttpUtil {
         CloseableHttpClient httpClient = HttpClients.createDefault();
         // 创建get方式请求对象
         HttpGet httpGet = new HttpGet(url);
+        RequestConfig requestConfig = RequestConfig.custom().setConnectTimeout( 3000  ).setConnectionRequestTimeout( 1000) .setSocketTimeout( 3000).build();
+        httpGet.setConfig(requestConfig);
         httpGet.addHeader("Content-type", "application/json");
         // 通过请求对象获取响应对象
         CloseableHttpResponse response = httpClient.execute(httpGet);
@@ -76,6 +79,7 @@ public class HttpUtil {
         HttpPost httpPost = new HttpPost(url);
         httpPost.addHeader("Content-Type", "application/json");
         httpPost.setEntity(new StringEntity(JSONBody));
+        httpPost.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 3000);
         CloseableHttpResponse response = httpClient.execute(httpPost);
 //		System.out.println(response.getStatusLine().getStatusCode() + "\n");
         HttpEntity entity = response.getEntity();
@@ -110,6 +114,7 @@ public class HttpUtil {
             }
         }
         httpPost.setEntity(new UrlEncodedFormEntity(params, "UTF-8"));
+        httpPost.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 3000);
         /** HttpResponse */
         CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
         try {
@@ -139,12 +144,16 @@ public class HttpUtil {
     public static String httpPost(String url, String param, String contentType) {
         try {
             HttpClient client = new HttpClient();
+//            client.setConnectionTimeout(30000 );
+//            client.setTimeout(30000);
+            client.getHttpConnectionManager().getParams().setConnectionTimeout(3000);
+            client.getHttpConnectionManager().getParams().setSoTimeout(3000);
             PostMethod post = new PostMethod(url);
             RequestEntity entity = new StringRequestEntity(param, contentType, "UTF-8");
             post.setRequestEntity(entity);
             post.setRequestHeader("Content-Type", contentType);
             post.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler());
-            post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 5000);
+            post.getParams().setParameter(HttpMethodParams.SO_TIMEOUT, 3000);
             client.executeMethod(post);
             InputStream in = post.getResponseBodyAsStream();
             BufferedReader reader = new BufferedReader(new InputStreamReader(in, StandardCharsets.UTF_8));

+ 24 - 14
src/main/resources/static/js/mz/clinic.js

@@ -593,6 +593,8 @@ function clearUser() {
     $("#patientAge").html("");
     $("#patientGender").html("");
     $("#patientId").val(null);
+    $("#editUser").css("display","none");
+    $("#clearUser").css("display","none");
     $("#patientPhone").html("");
     $("#patientPhoneLabel").hide();
     $("#patientResponseType").html("");
@@ -1002,6 +1004,8 @@ function setMzPatientInfo(mzPatientMi) {
     $("#patientAge").html(mzPatientMi.age);
     $("#patientGender").html(mzPatientMi.gender);
     $("#patientId").val(mzPatientMi.patientId);
+    $("#editUser").css("display","inline-block");
+    $("#clearUser").css("display","inline-block");
     if (mzPatientMi.phoneNo != null && mzPatientMi.phoneNo != '') {
         $("#patientPhone").html(mzPatientMi.phoneNo);
         $("#patientPhoneLabel").show();
@@ -1313,7 +1317,7 @@ function editPrescription(jsonData) {
     }
     $("#healthEducation").val(jsonData.mzBlRecord.emrJkjy);
     var mzChargeDetailList = jsonData.mzChargeDetailList;
-    var mzZyReq=jsonData.mzZyReq;
+    var mzZyReq = jsonData.mzZyReq;
     //中药的公共参数是否已经设置了
     var hadSetZyFullParams = false;
     //西药,成药,医材,麻精,中药,诊疗
@@ -1389,7 +1393,7 @@ function editPrescription(jsonData) {
         }
     }
     //入院证
-    if(mzZyReq!=null && mzZyReq.reqDept!=null){
+    if (mzZyReq != null && mzZyReq.reqDept != null) {
         $("#inpatientWardBeHospitalized").selectpicker('val', mzZyReq.reqDept);
         $('#inpatientWardBeHospitalized').selectpicker('refresh');
         initSmallDeptByDept();
@@ -1399,7 +1403,7 @@ function editPrescription(jsonData) {
             $("#smallWardBeHospitalized").selectpicker('val', mzZyReq.smallDept);
             $('#smallWardBeHospitalized').selectpicker('refresh');
             saveZyReq(false);
-        },500);
+        }, 500);
     }
     //设置总金额
     calculateTotalAmount();
@@ -1620,7 +1624,7 @@ function initResponceTypeSelect() {
                     var html = '<option value="' + item.code + '">' + item.name + '</option>';
                     $('#patientsNature').append(html);
                     $('#editUserPatientsNature').append(html);
-                   // $('#responeTypeBeHospitalized').append(html);
+                    // $('#responeTypeBeHospitalized').append(html);
                 });
                 $('#patientsNature').selectpicker('refresh');
                 $('#editUserPatientsNature').selectpicker('refresh');
@@ -5998,11 +6002,15 @@ function prescriptionDetailCommon(patientId, times, clnicId, payMark, type) {
                     }
                 }
                 if (type == 0) {
-                    $("#printPrescription").removeClass("hide").addClass("in");
                     $("#callPrescription").removeClass("in").addClass("hide");
-                    $("#printPrescription").off("click").on("click", function (t) {
-                        printPrescription(patientId, times, clnicId, payMark);
-                    });
+                    if ((jsonData.mzChargeDetailList == null || jsonData.mzChargeDetailList.length == 0) && (jsonData.mzYjReqList == null || jsonData.mzYjReqList.length == 0)) {
+                        $("#printPrescription").removeClass("in").addClass("hide");
+                    } else {
+                        $("#printPrescription").removeClass("hide").addClass("in");
+                        $("#printPrescription").off("click").on("click", function (t) {
+                            printPrescription(patientId, times, clnicId, payMark);
+                        });
+                    }
                     if (jsonData.mzYjReqList == null || jsonData.mzYjReqList.length == 0) {
                         $("#printYjReq").removeClass("in").addClass("hide");
                         $("#printYjReq").off("click");
@@ -6035,10 +6043,14 @@ function prescriptionDetailCommon(patientId, times, clnicId, payMark, type) {
                 if (oriPayMark == 1) {
                     $("#printPrescription").removeClass("in").addClass("hide");
                 } else {
-                    $("#printPrescription").removeClass("hide").addClass("in");
-                    $("#printPrescription").off("click").on("click", function (t) {
-                        printPrescription(patientId, times, clnicId, payMark);
-                    });
+                    if ((jsonData.mzChargeDetailList == null || jsonData.mzChargeDetailList.length == 0) && (jsonData.mzYjReqList == null || jsonData.mzYjReqList.length == 0)) {
+                        $("#printPrescription").removeClass("in").addClass("hide");
+                    } else {
+                        $("#printPrescription").removeClass("hide").addClass("in");
+                        $("#printPrescription").off("click").on("click", function (t) {
+                            printPrescription(patientId, times, clnicId, payMark);
+                        });
+                    }
                 }
             } else {
                 errorMesage(res);
@@ -6706,8 +6718,6 @@ function printBlRecord(patientId, times) {
 }
 
 
-
-
 /**
  * 打印入院通知单
  * @param patientId

+ 5 - 5
src/main/resources/templates/mz/clinic.html

@@ -315,7 +315,7 @@
             </div>
         </form>
     </div>
-    <div style="margin-top: 10px;border-left: 1px solid #ddd;border-right: 1px solid #ddd;width: calc(100% - 360px);float: left;height: calc(100% - 10px);">
+    <div style="margin-top: 10px;border-left: 1px solid #ddd;border-right: 1px solid #ddd;width: calc(100% - 370px);float: left;height: calc(100% - 10px);">
         <div style="height: calc(100% - 60px);overflow-y: auto;border-bottom: 1px solid #ddd;">
             <div class="col-md-12 col-sm-12 col-xs-12">
                 <div class="item form-group">
@@ -334,7 +334,7 @@
                     </div>
                 </div>
             </div>
-            <div class="col-md-12 col-sm-12 col-xs-12">
+            <div class="col-md-12 col-sm-12 col-xs-12" style="height: 40px;">
                 <div style="background-color: #E0E0D9;height: 30px;line-height: 30px;">
                     <div class="col-md-8 col-sm-8 col-xs-12">
                         <span>姓名:</span> <label><span id="patientName"></span></label>&nbsp;&nbsp;
@@ -352,11 +352,11 @@
                        <!-- <a style="cursor: pointer;font-size: 14px;color: #2e69eb!important;margin-right: 10px;"
                            onclick="beHospitalized()"><i
                                 class="fa fa-sign-in">&nbsp;&nbsp;入院处理</i></a>-->
-                        <a style="cursor: pointer;font-size: 14px;color: #2e69eb!important;margin-right: 10px;"
-                           onclick="editUserModal()"><i
+                        <a style="cursor: pointer;font-size: 14px;color: #2e69eb!important;margin-right: 10px;display: none"
+                           onclick="editUserModal()" id="editUser"><i
                                 class="fa fa-edit">&nbsp;&nbsp;编辑</i></a>
                         <a onclick="clearUser()"
-                           style="cursor: pointer;font-size: 14px;color: #2e69eb!important;"><i
+                           style="cursor: pointer;font-size: 14px;color: #2e69eb!important;display: none" id="clearUser"><i
                                 class="fa fa-trash">&nbsp;&nbsp;清空</i></a>
                     </div>
                 </div>