|
@@ -10,12 +10,9 @@ import thyyxxk.wxservice_server.dao.CovidVaccinateAppointmentDao;
|
|
|
import thyyxxk.wxservice_server.entity.ResultVo;
|
|
|
import thyyxxk.wxservice_server.entity.covidvaccinate.CovidVaccinate;
|
|
|
import thyyxxk.wxservice_server.entity.covidvaccinate.ZdCovidVaccinate;
|
|
|
-import thyyxxk.wxservice_server.entity.covidvaccinate.ZdVaccinateFactory;
|
|
|
-import thyyxxk.wxservice_server.entity.wxapi.PushMessageParam;
|
|
|
import thyyxxk.wxservice_server.utils.DateUtil;
|
|
|
import thyyxxk.wxservice_server.utils.IdCardUtil;
|
|
|
import thyyxxk.wxservice_server.utils.ResultVoUtil;
|
|
|
-import thyyxxk.wxservice_server.utils.StringUtil;
|
|
|
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
@@ -36,17 +33,24 @@ public class CovidVaccinateAppointmentService {
|
|
|
}
|
|
|
|
|
|
public ResultVo<List<ZdCovidVaccinate>> selectVaccinates() {
|
|
|
- return ResultVoUtil.success(dao.selectVaccinates());
|
|
|
- }
|
|
|
-
|
|
|
- public ResultVo<ZdCovidVaccinate> getVaccinateFactories(Integer id) {
|
|
|
- ZdCovidVaccinate vaccinate = dao.selectVaccinatesById(id);
|
|
|
- List<ZdVaccinateFactory> factories = dao.selectFactories(id);
|
|
|
- vaccinate.setFactories(factories);
|
|
|
- if (null != factories && factories.size() == 1) {
|
|
|
- vaccinate.setFactory(factories.get(0));
|
|
|
+ List<ZdCovidVaccinate> list = dao.selectVaccinates();
|
|
|
+ if (null != list && list.size() > 0) {
|
|
|
+ String[] nextSevenDate = DateUtil.getDatesInOneWeek();
|
|
|
+ list.forEach(item -> {
|
|
|
+ for (String date : nextSevenDate) {
|
|
|
+ Integer max = dao.selectThresholdByDateAndCode(date, item.getVaccinateCode());
|
|
|
+ max = null == max ? 0 : max;
|
|
|
+ Integer count = dao.selectTotalCountByDateAndCode(date, item.getVaccinateCode());
|
|
|
+ count = null == count ? 0 : count;
|
|
|
+ int offset = max - count;
|
|
|
+ item.setMinLeftNum(offset);
|
|
|
+ if (offset > 0) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
- return ResultVoUtil.success(vaccinate);
|
|
|
+ return ResultVoUtil.success(list);
|
|
|
}
|
|
|
|
|
|
public ResultVo<CovidVaccinate> getPatientInfoAndJobCategories(String patientId) {
|
|
@@ -73,6 +77,20 @@ public class CovidVaccinateAppointmentService {
|
|
|
return ResultVoUtil.success(info);
|
|
|
}
|
|
|
|
|
|
+ public ResultVo<int[]> getNextSevenDaysSources(int code) {
|
|
|
+ int[] result = new int[7];
|
|
|
+ String[] nextSevenDate = DateUtil.getDatesInOneWeek();
|
|
|
+ for (int i = 0; i < nextSevenDate.length; i++) {
|
|
|
+ String date = nextSevenDate[i];
|
|
|
+ Integer max = dao.selectThresholdByDateAndCode(date, code);
|
|
|
+ max = null == max ? 0 : max;
|
|
|
+ Integer count = dao.selectTotalCountByDateAndCode(date, code);
|
|
|
+ count = null == count ? 0 : count;
|
|
|
+ result[i] = max - count;
|
|
|
+ }
|
|
|
+ return ResultVoUtil.success(result);
|
|
|
+ }
|
|
|
+
|
|
|
public ResultVo<String> submitVaccinateAppointment(CovidVaccinate param) {
|
|
|
param.setCreateDatetime(new Date());
|
|
|
int age = IdCardUtil.calAgeBySocialNo(param.getSocialNo());
|
|
@@ -90,32 +108,33 @@ public class CovidVaccinateAppointmentService {
|
|
|
if (dao.selectValidAppointment(param.getSocialNo(), param.getExecuteDate()) > 0) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "您在【" + dateFormatted + "】已存在有效的预约,请勿重复预约。");
|
|
|
}
|
|
|
- Integer threshold = dao.selectThresholdByDateAndCode(param.getExecuteDate(), param.getVaccinateCode());
|
|
|
+ Integer threshold = dao.selectThresholdByDateAndCode2(param.getExecuteDate(), param.getVaccinateCode());
|
|
|
if (null == threshold) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【" + dateFormatted + "】没有可预约的疫苗,请选择其他预约日期。");
|
|
|
}
|
|
|
- int count = dao.selectTotalCountByDateAndCode(param.getExecuteDate(), param.getVaccinateCode());
|
|
|
+ Integer count = dao.selectTotalCountByDateAndCode2(param.getExecuteDate(), param.getVaccinateCode());
|
|
|
+ count = null == count ? 0 : count;
|
|
|
if (count >= threshold) {
|
|
|
return ResultVoUtil.fail(ExceptionEnum.LOGICAL_ERROR, "【" + dateFormatted + "】的预约名额已满,请选择其他预约日期。");
|
|
|
}
|
|
|
dao.insertNewAppointment(param);
|
|
|
- if (StringUtil.notBlank(param.getPatientId())) {
|
|
|
- dao.updatePhoneAndSocialNo(param.getPatientId(), param.getSocialNo(), param.getPhone());
|
|
|
- String msgContent = "{\"touser\":\"\",\"data\":" +
|
|
|
- "{\"keyword2\":{\"color\":\"#173177\",\"value\":\"" + dateFormatted + "\"}," +
|
|
|
- "\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + param.getName() + "\"}," +
|
|
|
- "\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + (++count) + "\"}," +
|
|
|
- "\"remark\":{\"color\":\"#FF0000\",\"value\":\"感谢您的使用,祝您健康!\"}," +
|
|
|
- "\"first\":{\"color\":\"#FF0000\",\"value\":\"您已成功预约新冠疫苗接种服务。" +
|
|
|
- "请于【" + dateFormatted + "】凭本人身份证在【泰和医院门诊大楼五楼体检中心】接种新冠疫苗。\"}}," +
|
|
|
- "\"template_id\":\"zVSzbYLmdqq_h1IcTPSwi6X4qFm0j9aTVeLZPxR03Bs\"," +
|
|
|
- "\"url\":\"\"}";
|
|
|
- PushMessageParam pojo = new PushMessageParam();
|
|
|
- pojo.setCardNo(param.getPatientId());
|
|
|
- pojo.setCardNoPatientId(true);
|
|
|
- pojo.setMsgContext(JSONObject.parseObject(msgContent));
|
|
|
- wxApiService.pushMessage(pojo);
|
|
|
- }
|
|
|
+// if (StringUtil.notBlank(param.getPatientId())) {
|
|
|
+// dao.updatePhoneAndSocialNo(param.getPatientId(), param.getSocialNo(), param.getPhone());
|
|
|
+// String msgContent = "{\"touser\":\"\",\"data\":" +
|
|
|
+// "{\"keyword2\":{\"color\":\"#173177\",\"value\":\"" + dateFormatted + "\"}," +
|
|
|
+// "\"keyword1\":{\"color\":\"#173177\",\"value\":\"" + param.getName() + "\"}," +
|
|
|
+// "\"keyword3\":{\"color\":\"#173177\",\"value\":\"" + (++count) + "\"}," +
|
|
|
+// "\"remark\":{\"color\":\"#FF0000\",\"value\":\"感谢您的使用,祝您健康!\"}," +
|
|
|
+// "\"first\":{\"color\":\"#FF0000\",\"value\":\"您已成功预约新冠疫苗接种服务。" +
|
|
|
+// "请于【" + dateFormatted + "】凭本人身份证在【泰和医院门诊大楼五楼体检中心】接种新冠疫苗。\"}}," +
|
|
|
+// "\"template_id\":\"zVSzbYLmdqq_h1IcTPSwi6X4qFm0j9aTVeLZPxR03Bs\"," +
|
|
|
+// "\"url\":\"\"}";
|
|
|
+// PushMessageParam pojo = new PushMessageParam();
|
|
|
+// pojo.setCardNo(param.getPatientId());
|
|
|
+// pojo.setCardNoPatientId(true);
|
|
|
+// pojo.setMsgContext(JSONObject.parseObject(msgContent));
|
|
|
+// wxApiService.pushMessage(pojo);
|
|
|
+// }
|
|
|
log.info("预约新冠疫苗接种:{}", JSONObject.toJSONStringWithDateFormat(param, "yyyy-MM-dd HH:mm:ss"));
|
|
|
return ResultVoUtil.success("您已成功预约新冠疫苗接种服务。请于【" + dateFormatted + "】" +
|
|
|
"凭本人身份证在【泰和医院门诊大楼五楼体检中心】接种新冠疫苗。");
|