浏览代码

验证挂号时段是否可选

hurugang 6 年之前
父节点
当前提交
6a6f0a7aec

+ 0 - 1
src/main/java/cn/hnthyy/thmz/Utils/DateUtil.java

@@ -55,5 +55,4 @@ public class DateUtil {
         return null;
     }
 
-
 }

+ 12 - 2
src/main/java/cn/hnthyy/thmz/common/Constants.java

@@ -30,6 +30,16 @@ public class Constants {
      * token最大有效时间 小时数
      */
     public static final int JWT_TTL = 24;
-
-
+    /**
+     * 挂号时段的上午编码
+     */
+    public static final String AM = "a";
+    /**
+     * 挂号时段的下午编码
+     */
+    public static final String PM = "p";
+    /**
+     * 挂号时段的全天编码
+     */
+    public static final String  DAY= "d";
 }

+ 44 - 3
src/main/java/cn/hnthyy/thmz/controller/MzyReqrecController.java

@@ -3,6 +3,7 @@ package cn.hnthyy.thmz.controller;
 import cn.hnthyy.thmz.Utils.JsonUtil;
 import cn.hnthyy.thmz.Utils.TokenUtil;
 import cn.hnthyy.thmz.comment.UserLoginToken;
+import cn.hnthyy.thmz.common.Constants;
 import cn.hnthyy.thmz.entity.his.*;
 import cn.hnthyy.thmz.entity.thmz.User;
 import cn.hnthyy.thmz.enums.YesNoEnum;
@@ -20,6 +21,8 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -92,6 +95,15 @@ public class MzyReqrecController {
                 resultMap.put("message", "门诊号表主键不能为空");
                 return resultMap;
             }
+            MzZdWorkTime mzZdWorkTime=mzZdWorkTimeService.queryMzZdWorkTimeByCode(mzyReqrec.getAmpm());
+            if(mzZdWorkTime==null){
+                resultMap.put("code", -1);
+                resultMap.put("message", "号段不存在");
+                return resultMap;
+            }
+            if (checkWorkTime(resultMap, mzZdWorkTime)) {
+                return resultMap;
+            }
             String token = TokenUtil.getToken(httpServletRequest);
             if (StringUtils.isBlank(token)) {
                 resultMap.put("code", -1);
@@ -118,9 +130,38 @@ public class MzyReqrecController {
         }
     }
 
-
-
-
+    /**
+     * 校验挂号时段的选择是否合理
+     * @param resultMap
+     * @param mzZdWorkTime
+     * @return
+     * @throws ParseException
+     */
+    private boolean checkWorkTime(Map<String, Object> resultMap, MzZdWorkTime mzZdWorkTime) throws ParseException {
+        SimpleDateFormat simpleDateFormat=new SimpleDateFormat("HH:mm");
+        Date now = new Date();
+        String nowStr = simpleDateFormat.format(now);
+        Date hour = simpleDateFormat.parse(nowStr);
+        long hourTs = hour.getTime();
+        Date dateStartTime=simpleDateFormat.parse(mzZdWorkTime.getStartTime());
+        long tsStartTime =dateStartTime.getTime();
+        Date dateEndTime=simpleDateFormat.parse(mzZdWorkTime.getEndTime());
+        long tsEndTime =dateEndTime.getTime();
+        if(Constants.AM.equals(mzZdWorkTime.getCode())){
+            if(hourTs<tsStartTime || hourTs>tsEndTime){
+                resultMap.put("code", -1);
+                resultMap.put("message", "挂号失败,当前挂号时间与所选时段不符,请重新选择合适的号段!");
+                return true;
+            }
+        }else if (Constants.PM.equals(mzZdWorkTime.getCode())){
+            if(hourTs>tsEndTime){
+                resultMap.put("code", -1);
+                resultMap.put("message", "挂号失败,当前挂号时间与所选时段不符,请重新选择合适的号段!");
+                return true;
+            }
+        }
+        return false;
+    }
 
 
     /**

+ 10 - 0
src/main/java/cn/hnthyy/thmz/mapper/his/MzZdWorkTimeMapper.java

@@ -1,6 +1,7 @@
 package cn.hnthyy.thmz.mapper.his;
 
 import cn.hnthyy.thmz.entity.his.MzZdWorkTime;
+import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
@@ -12,4 +13,13 @@ public interface MzZdWorkTimeMapper {
      */
     @Select("select code,rtrim(name) name,rtrim(start_time) start_time,rtrim(end_time) end_time,del_flag from mz_zd_work_time where del_flag =0")
     List<MzZdWorkTime> selectAllMzZdWorkTime();
+
+    /**
+     * 查询所有在使用中的时间区间
+     * @param code
+     * @return
+     */
+    @Select("select code,rtrim(name) name,rtrim(start_time) start_time,rtrim(end_time) end_time,del_flag from mz_zd_work_time where code =#{code} and del_flag =0 ")
+    MzZdWorkTime selectMzZdWorkTimeByCode(@Param("code")String code);
+
 }

+ 7 - 0
src/main/java/cn/hnthyy/thmz/service/his/MzZdWorkTimeService.java

@@ -10,4 +10,11 @@ public interface MzZdWorkTimeService {
      * @return
      */
     List<MzZdWorkTime> queryAllMzZdWorkTime();
+
+    /**
+     * 查询所有在使用中的时间区间
+     * @param code
+     * @return
+     */
+    MzZdWorkTime queryMzZdWorkTimeByCode(String code);
 }

+ 5 - 0
src/main/java/cn/hnthyy/thmz/service/impl/his/MzZdWorkTimeServiceImpl.java

@@ -16,4 +16,9 @@ public class MzZdWorkTimeServiceImpl implements MzZdWorkTimeService {
     public List<MzZdWorkTime> queryAllMzZdWorkTime() {
         return mzZdWorkTimeMapper.selectAllMzZdWorkTime();
     }
+
+    @Override
+    public MzZdWorkTime queryMzZdWorkTimeByCode(String code) {
+        return mzZdWorkTimeMapper.selectMzZdWorkTimeByCode(code);
+    }
 }

+ 2 - 1
src/main/resources/static/js/registration.js

@@ -356,7 +356,7 @@ function initEmployee() {
             var flag = false;
             $.each(res.data, function (commentIndex, comment) {
                 html += '<option value="' + comment.employee.employeeCode + '" data-chargeType="' + comment.chargeType + '"  data-checkFee="' + comment.checkFee + '" data-mzyRequestId="' + comment.mzyRequestId + '">' + comment.employee.employeeName + '</option>';
-                if (comment.employeeCode == -1) {
+                if (comment.employee.employeeCode == -1) {
                     flag = true;
                 }
             });
@@ -469,6 +469,7 @@ function fitFee() {
             $("#amountMoneyConfirm").text(checkFee);
             $("#realMoney").val(checkFee);
             $("#cash").val(checkFee);
+            validator.checkAll($("#regi_form"));
         }
     });
 }

+ 3 - 2
src/main/resources/templates/registration.html

@@ -239,10 +239,11 @@
                     </div>
                 </div>
                 <div class="col-md-6 col-sm-6 col-xs-12 item">
-                    <label class="control-label col-md-4 col-sm-4 col-xs-12" for="doctor">医生
+                    <label class="control-label col-md-4 col-sm-4 col-xs-12" for="doctor">医生 <span
+                            class="required">*</span>
                     </label>
                     <div class="col-md-8 col-sm-8 col-xs-12">
-                        <select class="form-control selectpicker show-tick" title="请选择" onchange="fitFee()"
+                        <select class="form-control selectpicker show-tick" required="required"  title="请选择" onchange="fitFee()"
                                 id="doctor">
                         </select>
                     </div>