Selaa lähdekoodia

混检开放时间动态获取。

lighter 2 vuotta sitten
vanhempi
commit
158a736c1b

+ 1 - 1
pom.xml

@@ -10,7 +10,7 @@
     </parent>
     <groupId>thyyxxk</groupId>
     <artifactId>wxservice-server</artifactId>
-    <version>8.5</version>
+    <version>8.6</version>
     <name>wxservice-server</name>
     <description>server for wxservice-web</description>
 

+ 9 - 4
src/main/java/thyyxxk/wxservice_server/controller/OrderCovidController.java

@@ -3,6 +3,7 @@ package thyyxxk.wxservice_server.controller;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 import thyyxxk.wxservice_server.entity.ResultVo;
+import thyyxxk.wxservice_server.entity.covid.MultipleExamTimeLimit;
 import thyyxxk.wxservice_server.service.OrderCovidExamService;
 
 /**
@@ -28,9 +29,13 @@ public class OrderCovidController {
         return service.savePrescription(patientId, type);
     }
 
-    @GetMapping("/updateIdCard")
-    public ResultVo<String> updateIdCard(@RequestParam("patientId") String patientId,
-                                         @RequestParam("socialNo") String socialNo) {
-        return service.updateIdCard(patientId, socialNo);
+    @GetMapping("/getMultipleExamTimeLimit")
+    public ResultVo<MultipleExamTimeLimit> getMultipleExamTimeLimit() {
+        return service.getMultipleExamTimeLimit();
+    }
+
+    @GetMapping("/timeLimitChanged")
+    public String timeLimitChanged() {
+        return service.timeLimitChanged();
     }
 }

+ 0 - 8
src/main/java/thyyxxk/wxservice_server/dao/AppointmentDao.java

@@ -44,14 +44,6 @@ public interface AppointmentDao {
     @Select("select rtrim(mz_class) from zd_unit_code with(nolock) where code=#{code}")
     String selectMzClass(@Param("code") String code);
 
-    @Update("update mz_patient_mi set social_no=#{socialNo} where patient_id=#{patientId}")
-    void updateMzPatientMiSocialNo(@Param("patientId") String patientId,
-                               @Param("socialNo") String socialNo);
-
-    @Update("update t_wechat_patient_bind set social_no=#{socialNo} where patient_id=#{patientId}")
-    void updateWxBindSocialNo(@Param("patientId") String patientId,
-                               @Param("socialNo") String socialNo);
-
     @Select("select isnull(portrait,'') as portrait,isnull(introduction,'') as introduction " +
             "from a_employee_mi with(nolock) where code=#{code}")
     DoctorInfo selectPortraitAndIntroduction(@Param("code") String code);

+ 12 - 0
src/main/java/thyyxxk/wxservice_server/entity/covid/MultipleExamTimeLimit.java

@@ -0,0 +1,12 @@
+package thyyxxk.wxservice_server.entity.covid;
+
+import lombok.Data;
+
+@Data
+public class MultipleExamTimeLimit {
+    private String limitValue;
+    private String limitValueForDisplay = "08:00 - 24:00";
+
+    private Integer beginLimit = 800;
+    private Integer endLimit = 2400;
+}

+ 53 - 8
src/main/java/thyyxxk/wxservice_server/service/OrderCovidExamService.java

@@ -1,5 +1,6 @@
 package thyyxxk.wxservice_server.service;
 
+import com.alibaba.fastjson.JSONObject;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -9,10 +10,16 @@ import thyyxxk.wxservice_server.config.exception.ExceptionEnum;
 import thyyxxk.wxservice_server.dao.AppointmentDao;
 import thyyxxk.wxservice_server.entity.ResultVo;
 import thyyxxk.wxservice_server.entity.assessment.CovidQuestionnaire;
+import thyyxxk.wxservice_server.entity.covid.MultipleExamTimeLimit;
 import thyyxxk.wxservice_server.entity.hrgresponse.SaveMzFeeResponse;
+import thyyxxk.wxservice_server.utils.CastUtil;
 import thyyxxk.wxservice_server.utils.ResultVoUtil;
+import thyyxxk.wxservice_server.utils.StringUtil;
 
-import java.util.Calendar;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
 
 /**
  * @author dj
@@ -22,6 +29,9 @@ import java.util.Calendar;
 public class OrderCovidExamService {
     private final AppointmentDao dao;
 
+    private final MultipleExamTimeLimit timeLimit = new MultipleExamTimeLimit();
+    private final SimpleDateFormat timeLimitFormat = new SimpleDateFormat("HHmm");
+
     @Value("${hrgApiUrl}")
     private String hrgApiUrl;
 
@@ -40,8 +50,15 @@ public class OrderCovidExamService {
     }
 
     public ResultVo<String> savePrescription(String patientId, int type) {
-        if (type == 2 && Calendar.getInstance().get(Calendar.HOUR_OF_DAY) < 8) {
-            return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "混检仅在 8:00 - 24:00 开放。");
+        if (StringUtil.isBlank(timeLimit.getLimitValue())) {
+            timeLimitChanged();
+        }
+        if (type == 2) {
+            int nowtime = Integer.parseInt(timeLimitFormat.format(new Date()));
+            if (nowtime < timeLimit.getBeginLimit() || nowtime > timeLimit.getEndLimit()) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "混检仅在 " +
+                        timeLimit.getLimitValueForDisplay() + " 开放。");
+            }
         }
         String urlTail = type == 1 ? "/nucleicAcidApplication?patientId=" : "/hybridTestApplication?patientId=";
         RestTemplate restTemplate = new RestTemplate();
@@ -58,11 +75,39 @@ public class OrderCovidExamService {
         return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, hrgResponse.getResultMessage());
     }
 
-    public ResultVo<String> updateIdCard(String patientId, String socialNo) {
-        log.info("更新身份证:{},{}", patientId, socialNo);
-        dao.updateMzPatientMiSocialNo(patientId, socialNo);
-        dao.updateWxBindSocialNo(patientId, socialNo);
-        return ResultVoUtil.success("更新身份证成功。");
+    public ResultVo<MultipleExamTimeLimit> getMultipleExamTimeLimit() {
+        if (StringUtil.isBlank(timeLimit.getLimitValue())) {
+            timeLimitChanged();
+        }
+        return ResultVoUtil.success(timeLimit);
+    }
+
+    public String timeLimitChanged() {
+        log.info("重新获取混检开放时间。");
+        String url = hrgApiUrl + "/getHyBirdTime";
+        RestTemplate template = new RestTemplate();
+        Map<String, Object> result = template.getForObject(url, HashMap.class);
+        if (null == result) {
+            String msg = "获取混检开放时间失败,接口返回空。";
+            log.info(msg);
+            return msg;
+        }
+        if ((int) result.get("code") != 0) {
+            String msg = result.get("message").toString();
+            log.info("获取混检开放时间失败:{}", msg);
+            return msg;
+        }
+
+        Map<String, String> data = CastUtil.cast(result.get("data"));
+        String value = data.get("configValue");
+        String[] valuesArr = value.replaceAll(":", "").split("-");
+
+        timeLimit.setLimitValue(value);
+        timeLimit.setLimitValueForDisplay(value.replace("-", " - "));
+        timeLimit.setBeginLimit(Integer.parseInt(valuesArr[0]));
+        timeLimit.setEndLimit(Integer.parseInt(valuesArr[1]));
+
+        return JSONObject.toJSONString(timeLimit);
     }
 
 }

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

@@ -9,8 +9,8 @@ spring:
     cache: false
   datasource:
     driver-class-name: com.microsoft.sqlserver.jdbc.SQLServerDriver
-#    url: jdbc:sqlserver://172.16.32.179:1433;databaseName=thxyhisdb
-    url: jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb
+    url: jdbc:sqlserver://172.16.32.179:1433;databaseName=thxyhisdb
+#    url: jdbc:sqlserver://172.16.32.168:1433;databaseName=thxyhisdb
     hikari:
       username: sa
       password: