|
|
@@ -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;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
/**
|