xiaochan 4 mesi fa
parent
commit
a12844cac1

+ 15 - 1
src/main/java/thyyxxk/webserver/config/envionment/ApiUrl.java

@@ -1,12 +1,26 @@
 package thyyxxk.webserver.config.envionment;
 
 import lombok.Data;
+import lombok.NoArgsConstructor;
 import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
 @Data
 @ConfigurationProperties(prefix = "thyy.apiurl")
 @Component
+@NoArgsConstructor
 public class ApiUrl {
-    private String socketApi;
+
+    private String socketApi = "http://172.16.30.26:20922/thyy/api/socket";
+
+    /**
+     * 第三方接口的 api
+     */
+    private String TirdpartApi;
+
+
+    /**
+     * 定时任务的api
+     */
+    private String ScheduledApi;
 }

+ 0 - 17
src/main/java/thyyxxk/webserver/config/envionment/Other.java

@@ -1,17 +0,0 @@
-package thyyxxk.webserver.config.envionment;
-
-import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.springframework.boot.context.properties.ConfigurationProperties;
-import org.springframework.stereotype.Component;
-
-@Component
-@Data
-@ConfigurationProperties(prefix = "thyy.other")
-@NoArgsConstructor
-public class Other {
-    /**
-     * socket 连接的地址
-     */
-    private String socketV2Url = "http://172.16.30.26:20922/thyy/api/socket";
-}

+ 8 - 9
src/main/java/thyyxxk/webserver/http/websocket/SocketV2.java

@@ -4,11 +4,10 @@ import cn.hutool.http.Header;
 import cn.hutool.http.HttpRequest;
 import cn.hutool.json.JSONObject;
 import cn.hutool.json.JSONUtil;
-import com.alibaba.fastjson.JSON;
 import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Component;
-import thyyxxk.webserver.config.envionment.Other;
+import thyyxxk.webserver.config.envionment.ApiUrl;
 import thyyxxk.webserver.constants.Message;
 import thyyxxk.webserver.entity.outpatient.triage.MessageForPush;
 import thyyxxk.webserver.http.websocket.dto.*;
@@ -23,11 +22,11 @@ import java.util.Objects;
 @Component
 @RequiredArgsConstructor
 public class SocketV2 {
-    private final Other other;
+    private final ApiUrl apiUrl;
     private final ThirdpartApiService thirdpartApi;
 
     public HttpRequest getPostApi(String business) {
-        return HttpRequest.post(other.getSocketV2Url() + "/send" + business)
+        return HttpRequest.post(apiUrl.getSocketApi() + "/send" + business)
                 .header(Header.CONTENT_TYPE, "application/json;charset=utf-8")
                 .header(Header.ACCEPT, "application/json");
     }
@@ -74,14 +73,14 @@ public class SocketV2 {
 
     /**
      * 向导诊台候诊大屏发送消息
-     * */
+     */
     public void sendMsgToHelpDesk(MessageForPush body) {
         if (Objects.equals(body.getAction(), 1)) {
             setSpeechUrl(body);
         }
         JSONObject json = new JSONObject();
         json.set("sid", body.getSid());
-        JSONObject msg =JSONUtil.parseObj(body);
+        JSONObject msg = JSONUtil.parseObj(body);
         json.set("msg", msg);
         getPostApi("/helpDeskScreen")
                 .body(json.toJSONString(0))
@@ -91,15 +90,15 @@ public class SocketV2 {
 
     /**
      * 向诊室候诊小屏发送消息
-     * */
+     */
     public void sendMsgToRoomScreen(MessageForPush body) {
         if (Objects.equals(body.getAction(), 1) &&
-                StringUtil.isBlank(body.getSpeechUrl())) {
+            StringUtil.isBlank(body.getSpeechUrl())) {
             setSpeechUrl(body);
         }
         JSONObject json = new JSONObject();
         json.set("sid", body.getSid());
-        JSONObject msg =JSONUtil.parseObj(body);
+        JSONObject msg = JSONUtil.parseObj(body);
         json.set("msg", msg);
         getPostApi("/roomScreen")
                 .body(json.toJSONString(0))

+ 11 - 15
src/main/java/thyyxxk/webserver/service/TokenService.java

@@ -1,52 +1,48 @@
 package thyyxxk.webserver.service;
 
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Value;
+import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
+import thyyxxk.webserver.config.envionment.ApiUrl;
 
 /**
  * @author dj
  */
 @Service("TokenService")
+@RequiredArgsConstructor
 public class TokenService {
-    @Value(value = "${scheduledApi}")
-    private String scheduledApi;
     private final RestTemplate template;
+    private final ApiUrl apiUrl;
 
-    @Autowired
-    public TokenService(RestTemplate template) {
-        this.template = template;
-    }
 
     public String getWeComAddressBookToken() {
-        String url = scheduledApi + "/accessToken/get?key=corpwxBookAddressToken";
+        String url = apiUrl.getScheduledApi() + "/accessToken/get?key=corpwxBookAddressToken";
         return template.getForObject(url, String.class);
     }
 
     public String getWeComSendMsgToken() {
-        String url = scheduledApi + "/accessToken/get?key=corpwxUrgentMsgToken";
+        String url = apiUrl.getScheduledApi() + "/accessToken/get?key=corpwxUrgentMsgToken";
         return template.getForObject(url, String.class);
     }
 
     public String getWeComSendFileToken() {
-        String url = scheduledApi + "/accessToken/get?key=corpwxFilePushToken";
+        String url = apiUrl.getScheduledApi() + "/accessToken/get?key=corpwxFilePushToken";
         return template.getForObject(url, String.class);
     }
 
     public String[] getLisDockSign() {
-        String url = scheduledApi + "/accessToken/getLisDockSign";
+        String url = apiUrl.getScheduledApi() + "/accessToken/getLisDockSign";
         return template.getForObject(url, String[].class);
     }
 
     public void setLisDockSign(String[] sign) {
-        String url = scheduledApi + "/accessToken/setLisDockSign?"
-                + "s1="+sign[0]+"&s2="+sign[1];
+        String url = apiUrl.getScheduledApi() + "/accessToken/setLisDockSign?"
+                     + "s1=" + sign[0] + "&s2=" + sign[1];
         template.getForObject(url, String.class);
     }
 
     public String getThmzToken() {
-        String url = scheduledApi + "/accessToken/get?key=thmzToken";
+        String url = apiUrl.getScheduledApi() + "/accessToken/get?key=thmzToken";
         return template.getForObject(url, String.class);
     }
 

+ 22 - 19
src/main/java/thyyxxk/webserver/service/examinations/InspectionsService.java

@@ -1,5 +1,6 @@
 package thyyxxk.webserver.service.examinations;
 
+import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -8,6 +9,7 @@ import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpMethod;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
+import thyyxxk.webserver.config.envionment.ApiUrl;
 import thyyxxk.webserver.config.exception.BizException;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.dao.his.examinations.InspectionsDao;
@@ -27,24 +29,20 @@ import java.util.Objects;
  */
 @Service
 @Slf4j
+@RequiredArgsConstructor
 public class InspectionsService {
-    @Value(value = "${thirdpartApi}")
-    private String thirdpartApi;
     private final InspectionsDao dao;
     private final RestTemplate template;
+    private final ApiUrl apiUrl;
 
-    @Autowired
-    public InspectionsService(InspectionsDao dao, RestTemplate template) {
-        this.dao = dao;
-        this.template = template;
-    }
 
     public List<JyIndexResponse> queryJyIndex(ReportIndexInquiry inquiry) {
-        String url = thirdpartApi + "/inspection/queryJyIndex";
+        String url = apiUrl.getTirdpartApi() + "/inspection/queryJyIndex";
 
         ResultVo<List<JyIndexResponse>> response = template.exchange(
                 url, HttpMethod.POST, new HttpEntity<>(inquiry),
-                new ParameterizedTypeReference<ResultVo<List<JyIndexResponse>>>() {}
+                new ParameterizedTypeReference<ResultVo<List<JyIndexResponse>>>() {
+                }
         ).getBody();
 
         if (null == response) {
@@ -59,11 +57,12 @@ public class InspectionsService {
     public JyDetailResponse queryJyDetail(String reportId) {
         ReportDetailInquiry inquiry = new ReportDetailInquiry();
         inquiry.setReportId(reportId);
-        String url = thirdpartApi + "/inspection/queryJyDetail";
+        String url = apiUrl.getTirdpartApi() + "/inspection/queryJyDetail";
 
         ResultVo<JyDetailResponse> response = template.exchange(
                 url, HttpMethod.POST, new HttpEntity<>(inquiry),
-                new ParameterizedTypeReference<ResultVo<JyDetailResponse>>() {}
+                new ParameterizedTypeReference<ResultVo<JyDetailResponse>>() {
+                }
         ).getBody();
 
         if (null == response) {
@@ -76,10 +75,11 @@ public class InspectionsService {
     }
 
     public List<TestReport> checkTestIndex(ReportIndexInquiry inquiry) {
-        String url = thirdpartApi + "/inspection/queryJcIndex";
+        String url = apiUrl.getTirdpartApi() + "/inspection/queryJcIndex";
         ResultVo<List<TestReport>> response = template.exchange(
                 url, HttpMethod.POST, new HttpEntity<>(inquiry),
-                new ParameterizedTypeReference<ResultVo<List<TestReport>>>() {}
+                new ParameterizedTypeReference<ResultVo<List<TestReport>>>() {
+                }
         ).getBody();
         if (null == response) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);
@@ -94,10 +94,11 @@ public class InspectionsService {
         if (StringUtil.isBlank(request.getReportId())) {
             throw new BizException(ExceptionEnum.NULL_POINTER, "报告ID不能为空!");
         }
-        String url = thirdpartApi + "/inspection/queryJcDetail";
+        String url = apiUrl.getTirdpartApi() + "/inspection/queryJcDetail";
         ResultVo<TestReport> response = template.exchange(
                 url, HttpMethod.POST, new HttpEntity<>(request),
-                new ParameterizedTypeReference<ResultVo<TestReport>>() {}
+                new ParameterizedTypeReference<ResultVo<TestReport>>() {
+                }
         ).getBody();
         if (null == response) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);
@@ -109,11 +110,12 @@ public class InspectionsService {
     }
 
     public List<PathologyIndex> checkPathologyIndex(ReportIndexInquiry request) {
-        String url = thirdpartApi + "/inspection/queryBlIndex";
+        String url = apiUrl.getTirdpartApi() + "/inspection/queryBlIndex";
         request.setSocialNo(getPatSocialNo(request.getPatType(), request.getPatNo()));
         ResultVo<List<PathologyIndex>> response = template.exchange(
                 url, HttpMethod.POST, new HttpEntity<>(request),
-                new ParameterizedTypeReference<ResultVo<List<PathologyIndex>>>() {}
+                new ParameterizedTypeReference<ResultVo<List<PathologyIndex>>>() {
+                }
         ).getBody();
         if (null == response) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);
@@ -127,11 +129,12 @@ public class InspectionsService {
     }
 
     public List<ElectroIndex> checkElectroIndex(ReportIndexInquiry request) {
-        String url = thirdpartApi + "/inspection/queryXdIndex";
+        String url = apiUrl.getTirdpartApi() + "/inspection/queryXdIndex";
         request.setSocialNo(getPatSocialNo(request.getPatType(), request.getPatNo()));
         ResultVo<List<ElectroIndex>> response = template.exchange(
                 url, HttpMethod.POST, new HttpEntity<>(request),
-                new ParameterizedTypeReference<ResultVo<List<ElectroIndex>>>() {}
+                new ParameterizedTypeReference<ResultVo<List<ElectroIndex>>>() {
+                }
         ).getBody();
         if (null == response) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);

+ 7 - 9
src/main/java/thyyxxk/webserver/service/externalhttp/ThirdpartApiService.java

@@ -1,6 +1,7 @@
 package thyyxxk.webserver.service.externalhttp;
 
 import com.alibaba.fastjson.JSONObject;
+import lombok.RequiredArgsConstructor;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.core.ParameterizedTypeReference;
@@ -8,29 +9,26 @@ import org.springframework.http.HttpEntity;
 import org.springframework.http.HttpMethod;
 import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
+import thyyxxk.webserver.config.envionment.ApiUrl;
 import thyyxxk.webserver.config.exception.BizException;
 import thyyxxk.webserver.config.exception.ExceptionEnum;
 import thyyxxk.webserver.entity.ResultVo;
 
 @Service
+@RequiredArgsConstructor
 public class ThirdpartApiService {
-    @Value(value = "${thirdpartApi}")
-    private String api;
     private final RestTemplate template;
-
-    @Autowired
-    public ThirdpartApiService(RestTemplate template) {
-        this.template = template;
-    }
+    private final ApiUrl apiUrl;
 
     public String getSpeechUrl(String text, String id) {
-        String url = api + "/ttsApi/textToSpeech";
+        String url = apiUrl.getTirdpartApi() + "/ttsApi/textToSpeech";
         JSONObject body = new JSONObject();
         body.put("text", text);
         body.put("id", id);
         ResultVo<String> response = template.exchange(
                 url, HttpMethod.POST, new HttpEntity<>(body),
-                new ParameterizedTypeReference<ResultVo<String>>() {}
+                new ParameterizedTypeReference<ResultVo<String>>() {
+                }
         ).getBody();
         if (null == response) {
             throw new BizException(ExceptionEnum.NETWORK_ERROR);

+ 0 - 1
src/main/java/thyyxxk/webserver/service/jcptmobile/JcptMobileService.java

@@ -8,7 +8,6 @@ import com.dtflys.forest.http.ForestRequest;
 import com.dtflys.forest.utils.ForestDataType;
 import org.springframework.stereotype.Service;
 import thyyxxk.webserver.config.envionment.JcptMobile;
-import thyyxxk.webserver.config.envionment.Other;
 import thyyxxk.webserver.utils.TokenUtil;
 
 

+ 4 - 2
src/main/resources/application-dev.yml

@@ -150,8 +150,6 @@ si-injury-systm-url: http://172.16.30.26:2000/siInjury
 thmz-api-url: http://172.16.30.119:8089/thmz
 rmHkUserApi: http://172.16.30.66:20923/thyy/api/haikang/door/destructionUser
 
-thirdpartApi: http://172.16.30.26:21701/thyy/thirdpart/api
-scheduledApi: http://172.16.30.26:21702/thyy/scheduled/api
 
 thyy:
   ca:
@@ -174,6 +172,10 @@ thyy:
       api-secret: "00000000"
       url: http://47.100.199.230:8080/pdfsign_hw
       return-url: "https://emr.hnthyy.cn:9222/caTest/thyyca/hBoardSignReturnUrl"
+  apiurl:
+    socket-api: http://localhost:20922/thyy/api/socket
+    scheduled-api: http://localhost:21702/thyy/scheduled/api
+    tirdpart-api: http://localhost:21701/thyy/thirdpart/api
   archive:
     path: "Z:\\"
     archive-url: "http://172.16.32.167:20921/thyy/api/archive"

+ 4 - 2
src/main/resources/application-prod.yml

@@ -156,8 +156,10 @@ thyy:
   archive:
     path: "/mnt/archive"
     archive-url: http://172.16.32.167:20921/thyy/api/archive
-  other:
-    socket-v2-url: "http://172.16.32.160:20922/thyy/api/socket"
+  apiurl:
+    socket-api: http://172.16.32.160:20922/thyy/api/socket
+    scheduled-api: http://localhost:21702/thyy/scheduled/api
+    tirdpart-api: http://localhost:21701/thyy/thirdpart/api
   jcptmobile:
     address: "https://emr.hnthyy.cn:8080"
     agentid: 1000050