|
@@ -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);
|
|
|
}
|
|
|
|
|
|
}
|