Просмотр исходного кода

新冠抗原设置数量限制

lighter 2 лет назад
Родитель
Сommit
a22dea5dcb

+ 6 - 0
src/main/java/thyyxxk/wxservice_server/controller/OrderCovidController.java

@@ -19,6 +19,12 @@ public class OrderCovidController {
         this.service = service;
     }
 
+    @GetMapping("/setCovidAntigenLimit")
+    public void setCovidAntigenLimit(@RequestParam("needCheck") Boolean needCheck,
+                                     @RequestParam("maxCount") int maxCount) {
+        service.setCovidAntigenLimit(needCheck, maxCount);
+    }
+
     @GetMapping("/hasDoneCovidAssessment")
     public ResultVo<String> hasDoneCovidAssessment(@RequestParam("patientId") String patientId) {
         return service.hasDoneCovidAssessment(patientId);

+ 7 - 3
src/main/java/thyyxxk/wxservice_server/dao/AppointmentDao.java

@@ -48,12 +48,16 @@ public interface AppointmentDao {
             "from a_employee_mi with(nolock) where code=#{code}")
     DoctorInfo selectPortraitAndIntroduction(@Param("code") String code);
 
+    @Select("select count(1) from mzy_reqrec where patient_id=#{patientId} and cancel_mark=0 " +
+            "and datediff(day, request_day, getdate())=0")
+    int regNoExist(@Param("patientId") String patientId);
+
     @Select("select count(1) from mz_yj_req with(nolock) where patient_id=#{patientId} and " +
             "order_code=#{code} and isnull(del_flag,0)=0 and datediff(day,req_date,getdate())=0")
     int reqNoExist(@Param("patientId") String patientId,
                    @Param("code") String code);
 
-    @Select("select count(1) from mzy_reqrec where patient_id=#{patientId} and cancel_mark=0 " +
-            "and datediff(day, request_day, getdate())=0")
-    int regNoExist(@Param("patientId") String patientId);
+    @Select("select count(1) from mz_yj_req with(nolock) where order_code=#{code} " +
+            "and isnull(del_flag,0)=0 and datediff(day,req_date,getdate())=0")
+    int reqCount(@Param("code") String code);
 }

+ 10 - 1
src/main/java/thyyxxk/wxservice_server/service/OrderCovidExamService.java

@@ -30,7 +30,8 @@ import java.util.Map;
 public class OrderCovidExamService {
     private final AppointmentDao dao;
     private final MultipleExamTimeLimit timeLimit = new MultipleExamTimeLimit();
-    private final SimpleDateFormat timeLimitFormat = new SimpleDateFormat("HHmm");
+    private static Boolean CHECK_MAX_COVID_ANTIGEN = true;
+    private static Integer MAX_COVID_ANTIGEN = 100;
 
     @Value("${hrgApiUrl}")
     private String hrgApiUrl;
@@ -40,6 +41,11 @@ public class OrderCovidExamService {
         this.dao = dao;
     }
 
+    public void setCovidAntigenLimit(Boolean needCheck, int maxCount) {
+        CHECK_MAX_COVID_ANTIGEN = needCheck;
+        MAX_COVID_ANTIGEN = maxCount;
+    }
+
     public ResultVo<String> hasDoneCovidAssessment(String patientId) {
         CovidQuestionnaire covid = dao.validCovidAssessment(patientId);
         if (null == covid) {
@@ -51,6 +57,9 @@ public class OrderCovidExamService {
 
     public ResultVo<String> savePrescription(String patientId, int type) {
         if (type == 2) {
+            if (CHECK_MAX_COVID_ANTIGEN && dao.reqCount("004651") >= MAX_COVID_ANTIGEN) {
+                return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "今日新冠抗原检测已售罄,无法继续下单,敬请谅解。");
+            }
             int regNoExist = dao.regNoExist(patientId);
             if (regNoExist == 0) {
                 return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您今日没有有效的挂号信息,无法继续下单,敬请谅解。");