From fe29cd6bd14453452f245b2e02da873870d95a75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E6=81=92?= <3226558941@qq.com> Date: Thu, 21 Sep 2023 17:23:23 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=8A=A4=E7=90=86?= =?UTF-8?q?=E6=9C=BA=E6=9E=84=E4=BB=A3=E7=A0=81=E7=A7=BB=E6=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/enums/AppointmentStatusEnum.java | 30 ++ .../com/xinelu/common/utils/StringUtils.java | 15 + .../appletlogin/AppletLoginController.java | 53 ++- .../NurseAppLoginController.java | 69 ++++ .../nurseapplogin/NurseAppLoginMapper.java | 23 ++ .../appletlogin/AppletLoginService.java | 18 + .../impl/AppletLoginServiceImpl.java | 311 ++++++++++++++++++ .../nurseapplogin/NurseAppLoginService.java | 28 ++ .../impl/NurseAppLoginServiceImpl.java | 141 ++++++++ .../applet/utils/AppointmentTimeUtil.java | 218 ++++++++++++ .../vo/nurseapplogin/GoodsOrderCount.java | 37 +++ .../nurseapplogin/NurseAppInformationVO.java | 48 +++ .../vo/nurseapplogin/NurseAppLoginVO.java | 54 +++ .../vo/nurseapplogin/PatientAndDiseaseVO.java | 156 +++++++++ .../vo/nurseapplogin/PatientDiseaseVO.java | 31 ++ .../nurseapplogin/NurseAppLoginMapper.xml | 67 ++++ 16 files changed, 1292 insertions(+), 7 deletions(-) create mode 100644 xinelu-common/src/main/java/com/xinelu/common/enums/AppointmentStatusEnum.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/utils/AppointmentTimeUtil.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/GoodsOrderCount.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppInformationVO.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppLoginVO.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java create mode 100644 xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientDiseaseVO.java create mode 100644 xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml diff --git a/xinelu-common/src/main/java/com/xinelu/common/enums/AppointmentStatusEnum.java b/xinelu-common/src/main/java/com/xinelu/common/enums/AppointmentStatusEnum.java new file mode 100644 index 0000000..05c90b3 --- /dev/null +++ b/xinelu-common/src/main/java/com/xinelu/common/enums/AppointmentStatusEnum.java @@ -0,0 +1,30 @@ +package com.xinelu.common.enums; + +import lombok.Getter; + +/** + * @author 纪寒 + * @version 1.0 + * @description 预约状态枚举 + * @date 2022-09-06 14:39:00 + */ +@Getter +public enum AppointmentStatusEnum { + + /** + * 可预约 + */ + APPOINTMENT_YES(0), + + /** + * 不可预约 + */ + APPOINTMENT_NO(1), + + ; + final private Integer value; + + AppointmentStatusEnum(Integer value) { + this.value = value; + } +} diff --git a/xinelu-common/src/main/java/com/xinelu/common/utils/StringUtils.java b/xinelu-common/src/main/java/com/xinelu/common/utils/StringUtils.java index b6dbc95..c038115 100644 --- a/xinelu-common/src/main/java/com/xinelu/common/utils/StringUtils.java +++ b/xinelu-common/src/main/java/com/xinelu/common/utils/StringUtils.java @@ -495,4 +495,19 @@ public class StringUtils extends org.apache.commons.lang3.StringUtils { } return sb.toString(); } + + /** + * 补0公共方法 + * + * @param patientId 被护理人id + * @param length 指定长度 + * @return 部位长度 + */ + public static String fillZeroByPatientId(Long patientId, int length) { + String fillStr = String.valueOf(patientId); + if (org.apache.commons.lang3.StringUtils.length(fillStr) < length) { + fillStr = String.format("%0" + length + "d", patientId); + } + return fillStr; + } } \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletlogin/AppletLoginController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletlogin/AppletLoginController.java index d044856..10f862e 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletlogin/AppletLoginController.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/appletlogin/AppletLoginController.java @@ -1,17 +1,24 @@ package com.xinelu.applet.controller.appletlogin; +import com.xinelu.applet.dto.appletlogin.AppointmentInfoDTO; +import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; import com.xinelu.applet.service.appletlogin.AppletLoginService; import com.xinelu.common.annotation.MobileRequestAuthorization; +import com.xinelu.common.annotation.RepeatSubmit; import com.xinelu.common.config.XinELuConfig; import com.xinelu.common.core.controller.BaseController; import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.custominterface.Insert; +import com.xinelu.common.custominterface.Query; +import com.xinelu.common.exception.ServiceException; import com.xinelu.common.utils.regex.RegexUtil; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.Objects; /** @@ -26,10 +33,6 @@ public class AppletLoginController extends BaseController { @Resource private AppletLoginService appletLoginService; - @Resource - private RegexUtil regexUtil; - @Resource - private XinELuConfig xinYiLuConfig; /** * 根据用户Id获取用户的登录信息 @@ -45,4 +48,40 @@ public class AppletLoginController extends BaseController { } return appletLoginService.getPatientInfoByPatientId(patientId); } + + /** + * 根据护理站id和护理站项目id查询对应的护理项目信息及项目海报(护理项目详情app小程序公用,0203修改) + * + * @param itemInfoDTO 输入参数 + * @return 护理站项目信息集合 + */ + @GetMapping("/getStationItemInfo") + public AjaxResult getStationItemAndConsumableInfo(@Validated(Query.class) StationItemInfoDTO itemInfoDTO) { + if (Objects.isNull(itemInfoDTO)) { + return AjaxResult.error("护理站信息不能为空!"); + } + return appletLoginService.getStationItemAndConsumableInfo(itemInfoDTO); + } + + /** + * 预约提交方法(微信小程序和手机App共用) + * + * @param dto 输入参数 + * @return 预约结果 + */ + @MobileRequestAuthorization + @RepeatSubmit + @PostMapping("/appointment") + public AjaxResult nurseAppointment(@Validated(Insert.class) @RequestBody AppointmentInfoDTO dto, BindingResult bindingResult) { + if (bindingResult.hasErrors()) { + throw new ServiceException(bindingResult.getAllErrors().get(0).getDefaultMessage()); + } + if (Objects.isNull(dto)) { + return AjaxResult.error("预约信息不能为空!"); + } + if (Objects.nonNull(dto.getTotalPrice()) && dto.getTotalPrice().compareTo(BigDecimal.ZERO) <= 0) { + return AjaxResult.error("订单金额不能为负数,请输入正确的订单金额!"); + } + return appletLoginService.nurseAppointment(dto); + } } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java new file mode 100644 index 0000000..3e0450a --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/controller/nurseapplogin/NurseAppLoginController.java @@ -0,0 +1,69 @@ +package com.xinelu.applet.controller.nurseapplogin; + +import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; +import com.xinelu.applet.service.nurseapplogin.NurseAppLoginService; +import com.xinelu.common.annotation.MobileRequestAuthorization; +import com.xinelu.common.core.controller.BaseController; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.custominterface.Query; +import com.xinelu.common.exception.ServiceException; +import com.xinelu.common.utils.regex.RegexUtil; +import org.springframework.validation.BindingResult; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import javax.annotation.Resource; +import java.util.Objects; + +; + +/** + * @Description APP登录注册控制器 + * @Author zh + * @Date 2022-10-12 + */ +@RestController +@RequestMapping("/nurseApp/login") +public class NurseAppLoginController extends BaseController { + + @Resource + private RegexUtil regexUtil; + @Resource + private NurseAppLoginService nurseAppLoginService; + + /** + * 查询护理人列表信息(会员小程序和App共用) + * + * @param patientId 用户id + * @return 护理人列表集合 + */ + @MobileRequestAuthorization + @GetMapping("/getAppPatientList") + public AjaxResult getPatientList(Long patientId) { + if (Objects.isNull(patientId)) { + return AjaxResult.error("用户信息不能为空!"); + } + return nurseAppLoginService.getPatientVOList(patientId); + } + + /** + * 根据护理站id和护理站项目id查询对应的护理项目信息(会员App和小程序共用) + * + * @param itemInfoDTO 输入参数 + * @return 护理站项目信息集合 + */ + @MobileRequestAuthorization + @GetMapping("/getAppStationItemInfo") + public AjaxResult getStationItemAndConsumableInfo(@Validated(Query.class) StationItemInfoDTO itemInfoDTO, BindingResult bindingResult) { + if (bindingResult.hasErrors()) { + throw new ServiceException(bindingResult.getAllErrors().get(0).getDefaultMessage()); + } + if (Objects.isNull(itemInfoDTO)) { + return AjaxResult.error("护理站信息不能为空!"); + } + return nurseAppLoginService.getAppStationItemAndConsumableInfo(itemInfoDTO); + } +} + diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java new file mode 100644 index 0000000..15ed9e6 --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/mapper/nurseapplogin/NurseAppLoginMapper.java @@ -0,0 +1,23 @@ +package com.xinelu.applet.mapper.nurseapplogin; + + +import com.xinelu.applet.vo.nurseapplogin.PatientAndDiseaseVO; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @Description + * @Author zh + * @Date 2022-10-12 + */ +public interface NurseAppLoginMapper { + + /** + * 个人中心查询 + * + * @param patientId 用户id + * @return PatientDiseaseInfo + */ + PatientAndDiseaseVO getPatientDiseaseByPatientId(@Param("patientId") Long patientId); +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/AppletLoginService.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/AppletLoginService.java index 352a12c..7cf24d6 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/AppletLoginService.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/AppletLoginService.java @@ -1,5 +1,7 @@ package com.xinelu.applet.service.appletlogin; +import com.xinelu.applet.dto.appletlogin.AppointmentInfoDTO; +import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; import com.xinelu.common.core.domain.AjaxResult; /** @@ -17,4 +19,20 @@ public interface AppletLoginService { * @return 个人信息 */ AjaxResult getPatientInfoByPatientId(Long patientId); + + /** + * 根据护理站id和护理站项目id查询对应的护理项目信息 + * + * @param itemInfoDTO 输入参数 + * @return 护理项目信息集合 + */ + AjaxResult getStationItemAndConsumableInfo(StationItemInfoDTO itemInfoDTO); + + /** + * 预约提交方法 + * + * @param dto 输入参数 + * @return 预约结果 + */ + AjaxResult nurseAppointment(AppointmentInfoDTO dto); } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java index 01debe5..0d114d7 100644 --- a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/appletlogin/impl/AppletLoginServiceImpl.java @@ -1,15 +1,49 @@ package com.xinelu.applet.service.appletlogin.impl; +import com.xinelu.applet.dto.appletlogin.AppointmentConsumableDTO; +import com.xinelu.applet.dto.appletlogin.AppointmentInfoDTO; +import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; import com.xinelu.applet.mapper.appletlogin.AppletLoginMapper; import com.xinelu.applet.service.appletlogin.AppletLoginService; +import com.xinelu.applet.vo.appletlogin.NurserStationItemConsumableVO; +import com.xinelu.applet.vo.appletlogin.NurserStationItemInfoVO; +import com.xinelu.applet.vo.nearbynursingstation.PoserInfoHomeVO; +import com.xinelu.common.constant.Constants; import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.enums.*; +import com.xinelu.common.exception.ServiceException; +import com.xinelu.common.utils.DateUtils; +import com.xinelu.common.utils.StringUtils; +import com.xinelu.common.utils.bean.BeanUtils; +import com.xinelu.manage.domain.appointmentorder.AppointmentOrder; +import com.xinelu.manage.domain.appointmentorderdetails.AppointmentOrderDetails; +import com.xinelu.manage.domain.appointmentorderprocessrecord.AppointmentOrderProcessRecord; import com.xinelu.manage.domain.patientinfo.PatientInfo; +import com.xinelu.manage.mapper.appointmentorder.AppointmentOrderMapper; +import com.xinelu.manage.mapper.appointmentorderdetails.AppointmentOrderDetailsMapper; +import com.xinelu.manage.mapper.appointmentorderprocessrecord.AppointmentOrderProcessRecordMapper; +import com.xinelu.manage.mapper.patientinfo.PatientInfoMapper; +import com.xinelu.manage.vo.patientinfo.PatientInfoVO; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.BooleanUtils; + +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.support.atomic.RedisAtomicLong; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.Arrays; +import java.util.List; import java.util.Objects; +import java.util.stream.Collectors; /** * @Description 微信小程序登录注册业务层实现类 @@ -23,6 +57,26 @@ public class AppletLoginServiceImpl implements AppletLoginService { @Resource private AppletLoginMapper appletLoginMapper; + @Resource + private PatientInfoMapper patientInfoMapper; + @Resource + private RedisTemplate redisTemplate; + @Resource + private AppointmentOrderMapper appointmentOrderMapper; + @Resource + private AppointmentOrderDetailsMapper appointmentOrderDetailsMapper; + @Resource + private AppointmentOrderProcessRecordMapper appointmentOrderProcessRecordMapper; + + /** + * 提前预约时间半天标识 + */ + private static final String HALF_DAY = "HALF_DAY"; + + /** + * 提前预约时间一天标识 + */ + private static final String ONE_DAY = "ONE_DAY"; /** * 根据微信用户的patientId查询用户是否注册 @@ -38,4 +92,261 @@ public class AppletLoginServiceImpl implements AppletLoginService { } return AjaxResult.success(patientInfo); } + + /** + * 根据护理站id和护理站项目id查询对应的护理项目信息 + * + * @param itemInfoDTO 输入参数 + * @return 护理站项目集合 + */ + @Override + public AjaxResult getStationItemAndConsumableInfo(StationItemInfoDTO itemInfoDTO) { + //查询护理站项目信息 + NurserStationItemInfoVO nurserStationItemInfo = appletLoginMapper.getNurserStationItemAndPoser(itemInfoDTO.getStationId(), itemInfoDTO.getStationItemId(), itemInfoDTO.getStationItemPriceId()); + if (Objects.isNull(nurserStationItemInfo)) { + return AjaxResult.error("未查询到当前护理项目信息!"); + } + //筛选出护理项目的海报 + List poserInfoList = nurserStationItemInfo.getPoserInfoList().stream().filter(Objects::nonNull).filter(item -> StringUtils.isNotBlank(item.getModuleType()) && item.getModuleType().equals(PoserModuleTypeEnum.NURSE_ITEM_MODULE.getInfo())).collect(Collectors.toList()); + nurserStationItemInfo.setPoserInfoList(poserInfoList); + //护理耗材总价格 + BigDecimal consumableTotalPrice = BigDecimal.ZERO; + //查询护理站项目耗材信息 + List itemConsumableList = appletLoginMapper.getItemConsumableList(itemInfoDTO.getStationId(), itemInfoDTO.getStationItemId()); + if (CollectionUtils.isNotEmpty(itemConsumableList)) { + //计算护理项目价格 = 数量 * 单价 + itemConsumableList.forEach(item -> { + if (Objects.nonNull(item.getConsumablePrice()) && Objects.nonNull(item.getConsumableCount())) { + item.setConsumablePrice(item.getConsumablePrice().multiply(BigDecimal.valueOf(item.getConsumableCount())).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + }); + consumableTotalPrice = itemConsumableList.stream().filter(item -> Objects.nonNull(item.getConsumablePrice())).map(NurserStationItemConsumableVO::getConsumablePrice).reduce(BigDecimal.ZERO, BigDecimal::add); + nurserStationItemInfo.setItemConsumableList(itemConsumableList); + } + //耗材总价格 + nurserStationItemInfo.setConsumableTotalPrice(consumableTotalPrice); + //应付总金额 = 护理项目价格 + 耗材总价格 + BigDecimal nurseItemPrice = Objects.isNull(nurserStationItemInfo.getNurseItemPrice()) ? BigDecimal.ZERO : nurserStationItemInfo.getNurseItemPrice(); + nurserStationItemInfo.setTotalPrice(nurseItemPrice.add(consumableTotalPrice).setScale(2, BigDecimal.ROUND_HALF_UP)); + return AjaxResult.success(nurserStationItemInfo); + } + + /** + * 预约提交方法 + * + * @param dto 输入参数 + * @return 预约结果 + */ + @Transactional(rollbackFor = Exception.class) + @Override + public AjaxResult nurseAppointment(AppointmentInfoDTO dto) { + //判断当前用户新是否存在 + PatientInfoVO patientInfoById = patientInfoMapper.getPatientInfoById(dto.getPatientId()); + if (Objects.isNull(patientInfoById)) { + return AjaxResult.error("当前用户信息不存在,无法预约!"); + } + //校验预约服务时间 + AjaxResult appointmentTimeResult = checkAppointmentTime(dto); + if (Objects.nonNull(appointmentTimeResult)) { + return appointmentTimeResult; + } + //更新人员表的失能情况 + patientInfoMapper.updatePatientDisabling(dto.getPatientId(), dto.getDisablingCondition(), StringUtils.isBlank(dto.getDisablingReason()) ? " " : dto.getDisablingReason()); + //校验当前预约时间点是否已经达到预约人数上限 + if (Objects.nonNull(dto.getAppointmentLimitCount())) { + //获取当前护理项目预约剩余次数 + RedisAtomicLong remainingAppointmentCount = getAppointmentLimitCount(dto); + if (remainingAppointmentCount.get() <= 0L) { + return AjaxResult.error("当前预约时间已达到今日预约人数上限,无法进行预约!"); + } + try { + //预约次数减一 + long appointCount = remainingAppointmentCount.decrementAndGet(); + if (appointCount < 0L) { + return AjaxResult.error("当前预约时间已达到今日预约人数上限,无法进行预约!"); + } + //新增预约订单主表信息 + String orderNo = StringUtils.fillZeroByPatientId(dto.getPatientId(), 5) + System.nanoTime(); + this.addAppointmentOrderInfo(dto, orderNo); + //新增预约订单明细表信息 + this.addAppointOrderDetailsAndConsumableInfo(dto, orderNo); + return AjaxResult.success(appointmentOrderMapper.getAppointmentOrderByOrderNo(orderNo)); + } catch (Exception exception) { + log.error("预约订单接口异常,护理站id:{},护理项目id:{},预约次数:{}, 预约时间:{}", dto.getStationId(), dto.getStationItemId(), remainingAppointmentCount.get(), dto.getServiceDate() + "_" + dto.getServiceStartTime()); + //预约次数加一 + remainingAppointmentCount.incrementAndGet(); + throw exception; + } + } + //新增预约订单主表信息 + String orderNo = StringUtils.fillZeroByPatientId(dto.getPatientId(), 5) + System.nanoTime(); + this.addAppointmentOrderInfo(dto, orderNo); + //新增预约订单明细表信息 + this.addAppointOrderDetailsAndConsumableInfo(dto, orderNo); + return AjaxResult.success(appointmentOrderMapper.getAppointmentOrderByOrderNo(orderNo)); + } + + /** + * 校验预约服务时间 + * + * @param appointmentInfo 预约信息 + * @return com.xinyilu.common.core.domain.AjaxResult 校验结果 + */ + private AjaxResult checkAppointmentTime(AppointmentInfoDTO appointmentInfo) { + //当前时间点和预约时间点 + LocalTime nowTime = LocalTime.parse(DateTimeFormatter.ofPattern("HH:mm").format(LocalTime.now())); + LocalTime appointmentTime = appointmentInfo.getServiceStartTime(); + //每天零点时间 + LocalTime zeroTime = LocalTime.parse("00:00"); + //判断当前护理站是否营业 + boolean checkStartTime = appointmentTime.isAfter(appointmentInfo.getMorningOpenStartTime()) && appointmentTime.isBefore(appointmentInfo.getMorningOpenEndTime()); + boolean checkEndTime = appointmentTime.isAfter(appointmentInfo.getAfternoonOpenStartTime()) && appointmentTime.isBefore(appointmentInfo.getAfternoonOpenEndTime()); + boolean morningStartTime = appointmentTime.equals(appointmentInfo.getMorningOpenStartTime()); + boolean afternoonStartTime = appointmentTime.equals(appointmentInfo.getAfternoonOpenStartTime()); + if (BooleanUtils.isFalse(checkStartTime) && BooleanUtils.isFalse(checkEndTime) && !morningStartTime && !afternoonStartTime) { + return AjaxResult.error("当前预约时间护理站暂未营业,无法进行预约!"); + } + //当前预约项目时长是提前半天,那么上午的时间都不可预约 + if (StringUtils.isNotBlank(appointmentInfo.getAdvanceAppointDuration()) && HALF_DAY.equals(appointmentInfo.getAdvanceAppointDuration())) { + if (nowTime.equals(appointmentInfo.getMorningOpenStartTime()) || (nowTime.isAfter(zeroTime) && nowTime.isBefore(appointmentInfo.getMorningOpenEndTime()))) { + boolean beforeData = appointmentInfo.getServiceDate().isEqual(LocalDate.now()) || appointmentInfo.getServiceDate().isBefore(LocalDate.now()); + boolean beforeTime = appointmentInfo.getServiceStartTime().isBefore(appointmentInfo.getAfternoonOpenStartTime()); + if (BooleanUtils.isTrue(beforeData) && BooleanUtils.isTrue(beforeTime)) { + return AjaxResult.error("当前护理项目需要提前半天预约,现在是上午时间,只能预约下午以后的时间!"); + } + } + if (nowTime.equals(appointmentInfo.getAfternoonOpenStartTime()) || (nowTime.isAfter(appointmentInfo.getMorningOpenEndTime()) && nowTime.isBefore(appointmentInfo.getAfternoonOpenEndTime()))) { + //说明当前时间处于下午营业时间,那么当前时间以及之前的时间都不可预约,只能预约明天的时间 + if (appointmentInfo.getServiceDate().isEqual(LocalDate.now()) || appointmentInfo.getServiceDate().isBefore(LocalDate.now())) { + return AjaxResult.error("当前护理项目需要提前半天预约,现在是下午时间,只能预约明天以后的时间!"); + } + } + } + //当前预约项目时长是提前一天,那么当天的所有时间点都不可预约 + if (StringUtils.isNotBlank(appointmentInfo.getAdvanceAppointDuration()) && ONE_DAY.equals(appointmentInfo.getAdvanceAppointDuration())) { + if (appointmentInfo.getServiceDate().isEqual(LocalDate.now()) || appointmentInfo.getServiceDate().isBefore(LocalDate.now())) { + return AjaxResult.error("当前护理项目需要提前一天预约,无法进行预约!"); + } + } + //判断预约时间是否是今天之前的时间,比如当前时间是:2023-02-20 17:00,而预约时间选择的是17:00之前的时间,不可以预约 + if (appointmentInfo.getServiceDate().isEqual(LocalDate.now()) && appointmentInfo.getServiceStartTime().isBefore(nowTime)) { + return AjaxResult.error("预约时间不能选择当前时间之前的时间,请选择'" + nowTime + "'之后的时间!"); + } + return null; + } + + /** + * 获取当前预约服务项目可预约的剩余次数 + * + * @param appointmentInfo 预约信息 + * @return com.xinyilu.common.core.domain.AjaxResult 预约剩余次数 + */ + private RedisAtomicLong getAppointmentLimitCount(AppointmentInfoDTO appointmentInfo) { + RedisAtomicLong appointLimitCount; + String appointLimitCountKey = Constants.PRE_APPOINTMENT_LIMIT_COUNT_KEY + appointmentInfo.getStationItemId() + "_" + appointmentInfo.getServiceDate() + "_" + appointmentInfo.getServiceStartTime(); + //根据预约时间点查询当前项目的预约订单的数量,并将其放入Redis中进行缓存 + if (!Objects.equals(Boolean.TRUE, redisTemplate.hasKey(appointLimitCountKey))) { + //当前Redis中没有该时间点的预约数量限制,将其放入到Redis中 + appointLimitCount = new RedisAtomicLong(appointLimitCountKey, Objects.requireNonNull(redisTemplate.getConnectionFactory())); + //统计当前护理项目当前预约时间点的预约订单数量 + List orderStatusList = Arrays.asList(OrderStatusEnum.WAIT_PAY.getInfo(), OrderStatusEnum.PAY.getInfo(), + OrderStatusEnum.WAIT_DISPATCH.getInfo(), OrderStatusEnum.NOT_FINISH.getInfo(), OrderStatusEnum.COMPLETE.getInfo(), + OrderStatusEnum.WAIT_REFUND.getInfo(), OrderStatusEnum.EVALUATED.getInfo()); + Integer appointOrderCount = appletLoginMapper.getAppointOrderCountByIdAndTime(appointmentInfo.getStationItemId(), appointmentInfo.getServiceDate(), appointmentInfo.getServiceStartTime(), orderStatusList); + if (Objects.isNull(appointOrderCount)) { + appointOrderCount = 0; + } + //将领取数量放入Redis中 + if (appointLimitCount.compareAndSet(0, appointmentInfo.getAppointmentLimitCount() - appointOrderCount)) { + //过期时间,在当前时间的基础上在增加24小时,因为存在24小时未支付的订单需要处理Redis中的预约订单次数 + LocalDateTime expireTime = appointmentInfo.getServiceDate().atTime(23, 59, 59).plusHours(24); + appointLimitCount.expireAt(DateUtils.localDateTimeToDate(expireTime)); + } + } else { + appointLimitCount = new RedisAtomicLong(appointLimitCountKey, Objects.requireNonNull(redisTemplate.getConnectionFactory())); + } + return appointLimitCount; + } + + /** + * 新增预约订单主表信息 + * + * @param dto 输入参数 + * @param orderNo 订单编号 + */ + private void addAppointmentOrderInfo(AppointmentInfoDTO dto, String orderNo) { + //新增预约订单主表信息 + AppointmentOrder appointmentOrder = new AppointmentOrder(); + appointmentOrder.setPatientId(dto.getPatientId()); + appointmentOrder.setOrderNo(orderNo); + appointmentOrder.setTotalPrice(dto.getTotalPrice()); + appointmentOrder.setOrderStatus(OrderStatusEnum.WAIT_PAY.getInfo()); + appointmentOrder.setRemark(StringUtils.isBlank(dto.getRemark()) ? "" : dto.getRemark()); + appointmentOrder.setDelFlag(0); + appointmentOrder.setOrderType(AppointmentOrderTypeEnum.OTHER.getInfo()); + appointmentOrder.setOrderChannel(dto.getOrderChannel()); + appointmentOrder.setCreateTime(LocalDateTime.now()); + appointmentOrder.setOrderCommissionAmount(Objects.isNull(dto.getOrderCommissionAmount()) ? null : dto.getOrderCommissionAmount()); + int insertOrderCount = appointmentOrderMapper.insertAppointmentOrder(appointmentOrder); + if (insertOrderCount <= 0) { + log.info("新增预约订单主表失败,失败原因:[{}]", appointmentOrder); + throw new ServiceException("预约护理信息失败,请联系管理员!"); + } + //新增预约订单流程记录信息表 + AppointmentOrderProcessRecord appointment = new AppointmentOrderProcessRecord(); + appointment.setOperatePersonId(dto.getPatientId()); + appointment.setAppointmentOrderId(appointmentOrder.getId()); + appointment.setAppointmentOrderNo(orderNo); + appointment.setOperateTime(LocalDateTime.now()); + appointment.setOperateType(OrderProcessOperateTypeEnum.PLACE_ORDER.getInfo()); + appointment.setOperateDetails("预约订单下单操作"); + appointment.setCreateTime(LocalDateTime.now()); + int count = appointmentOrderProcessRecordMapper.insertAppointmentOrderProcessRecord(appointment); + if (count <= 0) { + throw new ServiceException("预约订单流程记录失败,请联系管理员!"); + } + } + + /** + * 新增预约订单明细表和耗材包表信息 + * + * @param dto 输入参数 + * @param orderNo 订单编号 + */ + private void addAppointOrderDetailsAndConsumableInfo(AppointmentInfoDTO dto, String orderNo) { + AppointmentOrderDetails orderDetails = new AppointmentOrderDetails(); + BeanUtils.copyProperties(dto, orderDetails); + orderDetails.setNurseStationItemId(dto.getStationItemId()); + orderDetails.setNurseStationItemPriceId(Objects.isNull(dto.getStationItemPriceId()) ? null : dto.getStationItemPriceId()); + orderDetails.setOrderNo(orderNo); + orderDetails.setOrderStatus(OrderStatusEnum.WAIT_PAY.getInfo()); + orderDetails.setAppointmentStatus(AppointmentStatusEnum.APPOINTMENT_YES.getValue()); + orderDetails.setItemServeDurationUnit(dto.getServeDurationUnit()); + orderDetails.setDelFlag(0); + orderDetails.setCreateTime(LocalDateTime.now()); + //计算耗材包总价格 + if (CollectionUtils.isNotEmpty(dto.getOrderConsumableList())) { + BigDecimal consumableTotalPrice = dto.getOrderConsumableList().stream().filter(item -> Objects.nonNull(item.getConsumablePrice())) + .map(AppointmentConsumableDTO::getConsumablePrice).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP); + orderDetails.setConsumableTotalPrice(consumableTotalPrice); + } + int insertOrderDetailsCount = appointmentOrderDetailsMapper.insertAppointmentOrderDetails(orderDetails); + if (insertOrderDetailsCount <= 0) { + log.info("新增预约订明细表失败,失败原因:[{}]", orderDetails); + throw new ServiceException("预约护理信息失败,请联系管理员!"); + } + //新增预约订单耗材包表信息 + if (CollectionUtils.isNotEmpty(dto.getOrderConsumableList())) { + List orderConsumableList = dto.getOrderConsumableList(); + orderConsumableList.forEach(item -> item.setAppointOrderDetailsId(orderDetails.getId())); + int orderConsumableCount = appletLoginMapper.insertBatchOrderConsumable(orderConsumableList); + if (orderConsumableCount <= 0) { + log.info("新增预约订单耗材信息表失败,失败原因:[{}]", dto.getOrderConsumableList()); + throw new ServiceException("预约护理信息失败,请联系管理员!"); + } + } + } + + + } diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java new file mode 100644 index 0000000..71d0cc3 --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/NurseAppLoginService.java @@ -0,0 +1,28 @@ +package com.xinelu.applet.service.nurseapplogin; + +import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; +import com.xinelu.common.core.domain.AjaxResult; + +/** + * @Description APP登录注册业务层 + * @Author zh + * @Date 2022-10-12 + */ +public interface NurseAppLoginService { + + /** + * 查询护理人列表信息 + * + * @param patientId 用户id + * @return 护理人列表集合 + */ + AjaxResult getPatientVOList(Long patientId); + + /** + * 根据护理站id和护理站项目id查询对应的护理项目信息 + * + * @param itemInfoDTO 输入参数 + * @return 护理项目信息集合 + */ + AjaxResult getAppStationItemAndConsumableInfo(StationItemInfoDTO itemInfoDTO); +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java new file mode 100644 index 0000000..3a4f01a --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/service/nurseapplogin/impl/NurseAppLoginServiceImpl.java @@ -0,0 +1,141 @@ +package com.xinelu.applet.service.nurseapplogin.impl; + +import com.xinelu.applet.dto.appletlogin.StationItemInfoDTO; +import com.xinelu.applet.mapper.appletlogin.AppletLoginMapper; +import com.xinelu.applet.mapper.nurseapplogin.NurseAppLoginMapper; +import com.xinelu.applet.service.nurseapplogin.NurseAppLoginService; +import com.xinelu.applet.utils.AppointmentTimeUtil; +import com.xinelu.applet.vo.appletlogin.NurserStationItemConsumableVO; +import com.xinelu.applet.vo.appletlogin.NurserStationItemInfoVO; +import com.xinelu.applet.vo.nurseapplogin.PatientAndDiseaseVO; +import com.xinelu.applet.vo.specialdisease.WeekDaysVO; +import com.xinelu.common.core.domain.AjaxResult; +import com.xinelu.common.enums.AppointmentTimeIntervalEnum; +import com.xinelu.manage.mapper.sysarea.SysAreaMapper; +import com.xinelu.manage.vo.sysarea.SysAreaVO; +import com.xinelu.system.domain.SysConfig; +import com.xinelu.system.mapper.SysConfigMapper; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.time.LocalTime; +import java.util.Arrays; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.stream.Collectors; + +/** + * @Description APP登录注册业务层实现类 + * @Author ZH + * @Date 2022-10-12 + */ +@Service +@Slf4j +public class NurseAppLoginServiceImpl implements NurseAppLoginService { + + @Resource + private NurseAppLoginMapper nurseAppLoginMapper; + @Resource + private SysAreaMapper sysAreaMapper; + @Resource + private AppletLoginMapper appletLoginMapper; + @Resource + private SysConfigMapper sysConfigMapper; + @Resource + private AppointmentTimeUtil appointmentTimeUtil; + + /** + * 查询护理人列表信息 + * + * @param patientId 用户id + * @return 护理人列表信息集合 + */ + @Override + public AjaxResult getPatientVOList(Long patientId) { + PatientAndDiseaseVO patientVOList = nurseAppLoginMapper.getPatientDiseaseByPatientId(patientId); + if (StringUtils.isBlank(patientVOList.getAreaCode())) { + return AjaxResult.success(patientVOList); + } + // 获取本护理站的区域信息 + if (StringUtils.isNotBlank(patientVOList.getAreaCode())) { + SysAreaVO nurseStationAreaByList = sysAreaMapper.getNurseStationAreaByCode(patientVOList.getAreaCode()); + if (Objects.isNull(nurseStationAreaByList)) { + return AjaxResult.success(patientVOList); + } + String provinceName = StringUtils.isBlank(nurseStationAreaByList.getProvinceName()) ? "" : nurseStationAreaByList.getProvinceName(); + String cityName = StringUtils.isBlank(nurseStationAreaByList.getCityName()) ? "" : nurseStationAreaByList.getCityName(); + String regionName = StringUtils.isBlank(nurseStationAreaByList.getRegionName()) ? "" : nurseStationAreaByList.getRegionName(); + String streetName = StringUtils.isBlank(nurseStationAreaByList.getStreetName()) ? "" : nurseStationAreaByList.getStreetName(); + patientVOList.setAreaName(provinceName + cityName + regionName + streetName); + } else { + patientVOList.setAreaName(""); + } + return AjaxResult.success(patientVOList); + } + + /** + * app根据护理站id和护理站项目id查询对应的护理项目信息 + * + * @param itemInfoDTO 输入参数 + * @return 护理站项目集合 + */ + @Override + public AjaxResult getAppStationItemAndConsumableInfo(StationItemInfoDTO itemInfoDTO) { + //查询护理站项目信息 + NurserStationItemInfoVO itemInfo = appletLoginMapper.getNurserStationItemInfo(itemInfoDTO.getStationId(), itemInfoDTO.getStationItemId(), itemInfoDTO.getStationItemPriceId()); + if (Objects.isNull(itemInfo)) { + return AjaxResult.error("当前护理项目信息不存在!"); + } + itemInfo.setAdvanceAppointDuration(StringUtils.isBlank(itemInfo.getAdvanceAppointDuration()) ? "" : itemInfo.getAdvanceAppointDuration()); + //护理耗材总价格 + BigDecimal consumableTotalPrice = BigDecimal.ZERO; + //查询护理站项目耗材信息 + List itemConsumableList = appletLoginMapper.getItemConsumableList(itemInfoDTO.getStationId(), itemInfoDTO.getStationItemId()); + if (CollectionUtils.isNotEmpty(itemConsumableList)) { + //计算护理项目价格 = 数量 * 单价 + itemConsumableList.forEach(item -> { + if (Objects.nonNull(item.getConsumablePrice()) && Objects.nonNull(item.getConsumableCount())) { + item.setConsumablePrice(item.getConsumablePrice().multiply(BigDecimal.valueOf(item.getConsumableCount())).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + }); + consumableTotalPrice = itemConsumableList.stream().map(NurserStationItemConsumableVO::getConsumablePrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); + itemInfo.setItemConsumableList(itemConsumableList); + } + //耗材总价格 + itemInfo.setConsumableTotalPrice(consumableTotalPrice); + //应付总金额 = 护理项目价格 + 耗材总价格 + BigDecimal nurseItemPrice = Objects.isNull(itemInfo.getNurseItemPrice()) ? BigDecimal.ZERO : itemInfo.getNurseItemPrice(); + itemInfo.setTotalPrice(nurseItemPrice.add(consumableTotalPrice).setScale(2, BigDecimal.ROUND_HALF_UP)); + //获取近七天的预约时间点 + List keyList = Arrays.asList("MORNING_START_TIME", "MORNING_END_TIME", + "AFTERNOON_START_TIME", "AFTERNOON_END_TIME", AppointmentTimeIntervalEnum.HALF_HOUR.getValue()); + Map keysMap = sysConfigMapper.getSystemConfigByKeys(keyList).stream() + .filter(item -> StringUtils.isNotBlank(item.getConfigKey()) && StringUtils.isNotBlank(item.getConfigValue())) + .collect(Collectors.toMap(SysConfig::getConfigKey, SysConfig::getConfigValue)); + if (keysMap.isEmpty()) { + keysMap.put("HALF_HOUR", "HALF_HOUR"); + keysMap.put("MORNING_START_TIME", "08:00:00"); + keysMap.put("MORNING_END_TIME", "12:00:00"); + keysMap.put("AFTERNOON_START_TIME", "13:30:00"); + keysMap.put("AFTERNOON_END_TIME", "18:00:00"); + } + String timeInterval = StringUtils.isBlank(itemInfo.getAppointmentTimeInterval()) ? keysMap.getOrDefault("HALF_HOUR", AppointmentTimeIntervalEnum.HALF_HOUR.getValue()) : itemInfo.getAppointmentTimeInterval(); + itemInfo.setAppointmentTimeInterval(timeInterval); + LocalTime morningOpenStartTime = Objects.isNull(itemInfo.getMorningOpenStartTime()) ? LocalTime.parse(keysMap.getOrDefault("MORNING_START_TIME", "08:00:00")) : itemInfo.getMorningOpenStartTime(); + itemInfo.setMorningOpenStartTime(morningOpenStartTime); + LocalTime morningOpenEndTime = Objects.isNull(itemInfo.getMorningOpenEndTime()) ? LocalTime.parse(keysMap.getOrDefault("MORNING_END_TIME", "12:00:00")) : itemInfo.getMorningOpenEndTime(); + itemInfo.setMorningOpenEndTime(morningOpenEndTime); + LocalTime afternoonOpenStartTime = Objects.isNull(itemInfo.getAfternoonOpenStartTime()) ? LocalTime.parse(keysMap.getOrDefault("AFTERNOON_START_TIME", "13:30:00")) : itemInfo.getAfternoonOpenStartTime(); + itemInfo.setAfternoonOpenStartTime(afternoonOpenStartTime); + LocalTime afternoonOpenEndTime = Objects.isNull(itemInfo.getAfternoonOpenEndTime()) ? LocalTime.parse(keysMap.getOrDefault("AFTERNOON_END_TIME", "18:00:00")) : itemInfo.getAfternoonOpenEndTime(); + itemInfo.setAfternoonOpenEndTime(afternoonOpenEndTime); + List appointmentTimeList = appointmentTimeUtil.getAppointmentTimeList(timeInterval, morningOpenStartTime, morningOpenEndTime, afternoonOpenStartTime, afternoonOpenEndTime); + itemInfo.setAppointmentTimeList(appointmentTimeList); + return AjaxResult.success(itemInfo); + } +} \ No newline at end of file diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/utils/AppointmentTimeUtil.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/utils/AppointmentTimeUtil.java new file mode 100644 index 0000000..ca552d5 --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/utils/AppointmentTimeUtil.java @@ -0,0 +1,218 @@ +package com.xinelu.applet.utils; + + +import com.xinelu.applet.vo.specialdisease.WeekDaysVO; +import com.xinelu.common.enums.AppointmentTimeIntervalEnum; +import com.xinelu.common.exception.ServiceException; +import org.apache.commons.compress.utils.Lists; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Component; + +import java.time.LocalDate; +import java.time.LocalTime; +import java.time.format.DateTimeFormatter; +import java.util.List; +import java.util.Objects; + +/** + * @Description 提前预约时间近七天时间点动态生成工具类 + * @Author 纪寒 + * @Date 2023-02-15 09:31:50 + * @Version 1.0 + */ +@Component +public class AppointmentTimeUtil { + + /** + * 近一周的时间点循环标识 + */ + private static final int DAYS = 6; + /** + * 周一 + */ + private static final String MONDAY = "MONDAY"; + /** + * 周二 + */ + private static final String TUESDAY = "TUESDAY"; + /** + * 周三 + */ + private static final String WEDNESDAY = "WEDNESDAY"; + /** + * 周四 + */ + private static final String THURSDAY = "THURSDAY"; + /** + * 周五 + */ + private static final String FRIDAY = "FRIDAY"; + /** + * 周六 + */ + private static final String SATURDAY = "SATURDAY"; + /** + * 周天 + */ + private static final String SUNDAY = "SUNDAY"; + + /** + * 根据预约时间间隔个营业开始时间和解释时间动态生成近七天的日期间隔时间点 + * + * @param timeInterval 预约时间间隔 + * @param morningOpenStartTime 上午营业开始时间 + * @param morningOpenEndTime 上午营业结束时间 + * @param afternoonOpenStartTime 下午营业开始时间 + * @param afternoonOpenEndTime 下午营业结束时间 + * @return List 近七天的营业时间点 + */ + public List getAppointmentTimeList(String timeInterval, LocalTime morningOpenStartTime, + LocalTime morningOpenEndTime, LocalTime afternoonOpenStartTime, + LocalTime afternoonOpenEndTime) { + if (StringUtils.isEmpty(timeInterval)) { + throw new ServiceException("预约时间间隔不能为空!"); + } + if (Objects.isNull(morningOpenStartTime) || Objects.isNull(morningOpenEndTime)) { + throw new ServiceException("上午营业开始时间和结束时间不能为空!"); + } + if (Objects.isNull(afternoonOpenStartTime) || Objects.isNull(afternoonOpenEndTime)) { + throw new ServiceException("下午营业开始时间和结束时间不能为空!"); + } + LocalDate nowTime = LocalDate.now(); + //近七天的预约时间点数据集合 + List weekDaysList = Lists.newArrayList(); + this.setWeekDayAndWeekDate(nowTime, weekDaysList); + //格式化营业时间 + morningOpenStartTime = formatTime(morningOpenStartTime); + morningOpenEndTime = formatTime(morningOpenEndTime); + afternoonOpenStartTime = formatTime(afternoonOpenStartTime); + afternoonOpenEndTime = formatTime(afternoonOpenEndTime); + //获取时间间隔分钟 + long interval = getInterval(StringUtils.trim(timeInterval)); + //上午时间点集合 + List morningTimeList = Lists.newArrayList(); + //下午时间点集合 + List afternoonTimeList = Lists.newArrayList(); + if (interval > 0) { + //生成上午时间点 + LocalTime morningInitTime = morningOpenStartTime; + morningTimeList.add(morningOpenStartTime.toString()); + while (morningInitTime.isBefore(morningOpenEndTime)) { + LocalTime localTime = morningInitTime.plusMinutes(interval); + if (localTime.isBefore(morningOpenEndTime)) { + morningTimeList.add(formatTime(localTime).toString()); + } + morningInitTime = morningInitTime.plusMinutes(interval); + } + //生成下午时间点 + LocalTime afternoonInitTime = afternoonOpenStartTime; + afternoonTimeList.add(afternoonOpenStartTime.toString()); + while (afternoonInitTime.isBefore(afternoonOpenEndTime)) { + LocalTime localTime = afternoonInitTime.plusMinutes(interval); + if (localTime.isBefore(afternoonOpenEndTime)) { + afternoonTimeList.add(formatTime(localTime).toString()); + } + afternoonInitTime = afternoonInitTime.plusMinutes(interval); + } + } + //组装数据 + for (WeekDaysVO weekDaysVO : weekDaysList) { + weekDaysVO.setMorningList(morningTimeList); + weekDaysVO.setAfternoonList(afternoonTimeList); + } + return weekDaysList; + } + + /** + * 生成近七天的时间和周几 + * + * @param nowTime 当前时间 + * @param weekDaysList 日期集合 + */ + public void setWeekDayAndWeekDate(LocalDate nowTime, List weekDaysList) { + for (int i = 0; i <= DAYS; i++) { + //每天的日期值,例如:2023-02-15 + LocalDate weekDate = nowTime.plusDays(i); + //日期对应的周几,例如:MONDAY + String week = weekDate.getDayOfWeek().toString(); + //日期对应的周几,例如:周一 + String weekDay = getWeekDay(nowTime, weekDate, week); + WeekDaysVO weekDaysVO = new WeekDaysVO(); + weekDaysVO.setDate(weekDate.toString()); + weekDaysVO.setWeek(weekDay); + weekDaysVO.setHealthConsultationDate(weekDate); + weekDaysList.add(weekDaysVO); + } + } + + /** + * 获取近七天日期对应得周几的值 + * + * @param nowTime 当前日期 + * @param weekDate 近七天中每天的日期值 + * @param week 近七天中每天日期对应的周几 + * @return String 周几 + */ + public String getWeekDay(LocalDate nowTime, LocalDate weekDate, String week) { + String weekDay; + switch (week) { + case MONDAY: + weekDay = weekDate.isEqual(nowTime) ? "今天" : "周一"; + break; + case TUESDAY: + weekDay = weekDate.isEqual(nowTime) ? "今天" : "周二"; + break; + case WEDNESDAY: + weekDay = weekDate.isEqual(nowTime) ? "今天" : "周三"; + break; + case THURSDAY: + weekDay = weekDate.isEqual(nowTime) ? "今天" : "周四"; + break; + case FRIDAY: + weekDay = weekDate.isEqual(nowTime) ? "今天" : "周五"; + break; + case SATURDAY: + weekDay = weekDate.isEqual(nowTime) ? "今天" : "周六"; + break; + case SUNDAY: + weekDay = weekDate.isEqual(nowTime) ? "今天" : "周天"; + break; + default: + weekDay = ""; + break; + } + return weekDay; + } + + /** + * 根据时间间隔获取对应得时间间隔分钟 + * + * @param timeInterval 时间间隔 + * @return 时间间隔分钟 + */ + private long getInterval(String timeInterval) { + long interval = 0; + if (AppointmentTimeIntervalEnum.HALF_HOUR.getValue().equals(timeInterval)) { + interval = 30; + } + if (AppointmentTimeIntervalEnum.ONE_HOUR.getValue().equals(timeInterval)) { + interval = 60; + } + if (AppointmentTimeIntervalEnum.NINETY_MINUTES.getValue().equals(timeInterval)) { + interval = 90; + } + if (AppointmentTimeIntervalEnum.TWO_HOUR.getValue().equals(timeInterval)) { + interval = 120; + } + return interval; + } + + /** + * 格式化时间格式 + * + * @param localTime 时间值 + */ + private LocalTime formatTime(LocalTime localTime) { + return LocalTime.parse(DateTimeFormatter.ofPattern("HH:mm").format(localTime)); + } +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/GoodsOrderCount.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/GoodsOrderCount.java new file mode 100644 index 0000000..9fdc6d8 --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/GoodsOrderCount.java @@ -0,0 +1,37 @@ +package com.xinelu.applet.vo.nurseapplogin; + + +import lombok.Data; + +import java.io.Serializable; + +/** + * 小程序及APP商品订单数量统计VO + * + * @author zhangheng + * @date 2022-12—30 + */ +@Data +public class GoodsOrderCount implements Serializable { + private static final long serialVersionUID = 7252143440949966703L; + + /** + * 代付款订单数量 + */ + private Long waitPayCount; + + /** + * 待收货订单数量 + */ + private Long waitReceivedGoodsCount; + + /** + * 待评价订单数量 + */ + private Long receivedGoodsCount; + + /** + * 已完成订单数量 + */ + private Long evaluatedCount; +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppInformationVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppInformationVO.java new file mode 100644 index 0000000..7905caf --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppInformationVO.java @@ -0,0 +1,48 @@ +package com.xinelu.applet.vo.nurseapplogin; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDate; + +/** + * App预约订单明细查询用户服务信息VO + * + * @author zhangheng + * @date 2022-10-31 + */ +@Data +public class NurseAppInformationVO implements Serializable { + private static final long serialVersionUID = -8859325675737604096L; + /** + * 订单id主键 + */ + private Long appointmentOrderId; + + /** + * 用户姓名 + */ + private String patientName; + + /** + * 手机号码 + */ + private String phone; + + /** + * 备注信息 + */ + private String remark; + + /** + * 服务地址 + */ + private String serviceAddress; + + /** + * 服务时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate serviceDate; +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppLoginVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppLoginVO.java new file mode 100644 index 0000000..d50e23d --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/NurseAppLoginVO.java @@ -0,0 +1,54 @@ +package com.xinelu.applet.vo.nurseapplogin; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.xinelu.common.custominterface.Insert; +import lombok.Data; +import net.sf.jsqlparser.statement.update.Update; +import org.hibernate.validator.constraints.Length; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.time.LocalDateTime; + +/** + * 注册信息Controller + * + * @author zhangheng + * @date 2022-10-12 + */ +@Data +public class NurseAppLoginVO implements Serializable { + private static final long serialVersionUID = 4595042189710626431L; + + /** + * 用户名称 + */ + @Length(max = 10, message = "用户名称不能超过10位!", groups = {Insert.class, Update.class}) + @NotBlank(message = "用户名称不能为空!", groups = {Insert.class, Update.class}) + private String patientName; + + /** + * 所属区域编码 + */ + private String areaCode; + + /** + * 手机号码 + */ + @Length(max = 11, message = "手机号码不能超过11位!", groups = {Insert.class, Update.class}) + @NotBlank(message = "手机号码不能为空!", groups = {Insert.class, Update.class}) + private String phone; + + /** + * 登录密码 + */ + @Length(min = 6, max = 10, message = "密码不能超过10位!", groups = {Insert.class}) + @NotBlank(message = "密码不能为空!", groups = {Insert.class, Update.class}) + private String password; + + /** + * 创建时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime createTime; +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java new file mode 100644 index 0000000..503ca73 --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientAndDiseaseVO.java @@ -0,0 +1,156 @@ +package com.xinelu.applet.vo.nurseapplogin; + +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.io.Serializable; +import java.time.LocalDate; +import java.util.List; + +/** + * 个人中心返回实体 + * + * @author zhangheng + * @date 2022-10-12 + */ +@Data +public class PatientAndDiseaseVO implements Serializable { + private static final long serialVersionUID = 695364456232491661L; + /** + * 被护理人基本信息表id + */ + private Long patientId; + + /** + * 用户姓名 + */ + private String patientName; + + /** + * 手机号码 + */ + private String phone; + + /** + * 身份证号 + */ + private String cardNo; + + /** + * 居住地址 + */ + private String address; + + /** + * 会员积分 + */ + private Integer integral; + + /** + * 个人头像地址 + */ + private String headPictureUrl; + + /** + * 所属区域编码 + */ + private String areaCode; + + /** + * 主键id + */ + private String provinceName; + + + /** + * 主键id区 + */ + private String regionName; + + /** + * 主键id + */ + private String streetName; + + /** + * 主键id + */ + private String cityName; + + /** + * 住址经度 + */ + private String homeLongitude; + + /** + * 住址纬度 + */ + private String homeLatitude; + + /** + * 所在位置名称 + */ + private String locationName; + + /** + * 所在位置区域名称 + */ + private String areaName; + + /** + * 性别,MALE:男,FEMALE:女 + */ + private String sex; + + /** + * 出生日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + private LocalDate birthDate; + + /** + * 代付款订单数量 + */ + private Long waitPayCount; + + /** + * 待收货订单数量 + */ + private Long waitReceivedGoodsCount; + + /** + * 待评价订单数量 + */ + private Long receivedGoodsCount; + + /** + * 已完成订单数量 + */ + private Long evaluatedCount; + + /** + * 优惠券数 + */ + private Integer patientCouponCount; + + /** + * 年龄 + */ + private Long age; + + /** + * 疾病信息集合 + */ + private List patientDiseaseInfoList; + + /** + * 失能情况,NOT_DISABLED:未失能,DISABLED:已失能 + */ + private String disablingCondition; + + /** + * 失能原因 + */ + private String disablingReason; + +} diff --git a/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientDiseaseVO.java b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientDiseaseVO.java new file mode 100644 index 0000000..2e73261 --- /dev/null +++ b/xinelu-nurse-applet/src/main/java/com/xinelu/applet/vo/nurseapplogin/PatientDiseaseVO.java @@ -0,0 +1,31 @@ +package com.xinelu.applet.vo.nurseapplogin; + +import lombok.Data; + +import java.io.Serializable; + +/** + * 个人中心返回实体 + * + * @author zhangheng + * @date 2022-10-27 + */ +@Data +public class PatientDiseaseVO implements Serializable { + private static final long serialVersionUID = -4942450801242475565L; + + /** + * 患者疾病信息表主键id + */ + private Long patientDiseaseId; + + /** + * 疾病表id + */ + private Long diseaseId; + + /** + * 疾病名称 + */ + private String diseaseName; +} diff --git a/xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml b/xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml new file mode 100644 index 0000000..94e45b9 --- /dev/null +++ b/xinelu-nurse-applet/src/main/resources/mapper/applet/nurseapplogin/NurseAppLoginMapper.xml @@ -0,0 +1,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +