|
@@ -1,7 +1,18 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
|
+import com.ruoyi.common.constant.Constants;
|
|
|
+import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.redis.RedisCache;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.ruoyi.system.mapper.BomanReservatConfigTimeMapper;
|
|
@@ -20,6 +31,9 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
|
|
|
@Autowired
|
|
|
private BomanReservatConfigTimeMapper bomanReservatConfigTimeMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private RedisCache redisCache;
|
|
|
+
|
|
|
/**
|
|
|
* 查询预约时段配置
|
|
|
*
|
|
@@ -93,4 +107,58 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
|
|
|
{
|
|
|
return bomanReservatConfigTimeMapper.deleteBomanReservatConfigTimeByReservatConfigTimeId(reservatConfigTimeId);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * H5时段信息 日历
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public AjaxResult getCalendar(String date) {
|
|
|
+ Map map =new HashMap();
|
|
|
+ //获取所有时段
|
|
|
+ List<BomanReservatConfigTime> bomanReservatConfigTimes = bomanReservatConfigTimeMapper.selectBomanReservatConfigTimeList(new BomanReservatConfigTime());
|
|
|
+
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ List<String> monthFullDay = DateUtils.getMonthFullDay(DateUtils.parseDate(date));
|
|
|
+ if (monthFullDay != null && monthFullDay.size() > 0){
|
|
|
+ for (String dateMonth : monthFullDay) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("date",dateMonth);
|
|
|
+ jsonObject.put("title","不可约");
|
|
|
+ int index = 0;
|
|
|
+ //去查询对应日期是否还有时段可以预约
|
|
|
+ if (bomanReservatConfigTimes != null && bomanReservatConfigTimes.size() > 0){
|
|
|
+ for (BomanReservatConfigTime reservatConfigTime : bomanReservatConfigTimes) {
|
|
|
+ //查询所有时段和最大人数
|
|
|
+ //去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
|
|
|
+ //已经预约人数
|
|
|
+ Object reservatNum= redisCache.getCacheObject(Constants.RESERVAT_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
|
|
|
+ if (ObjectUtils.isNotEmpty(reservatNum)){
|
|
|
+ //判断人数是否大于可预约人数
|
|
|
+ //如果 x==y 返回0;x<y 返回负数(-1);x>y 返回正数(1)
|
|
|
+ reservatConfigTime.setReservatConfigStatus("N");
|
|
|
+ if (NumberUtils.compare(reservatConfigTime.getReservatConfigNum(),(long)reservatNum) < 0){
|
|
|
+ reservatConfigTime.setReservatConfigStatus("Y");
|
|
|
+ index++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (index < bomanReservatConfigTimes.size()){
|
|
|
+ jsonObject.put("title","可预约");
|
|
|
+ }
|
|
|
+ //1: AM 2: PM
|
|
|
+ Map<String, List<BomanReservatConfigTime>> collect = bomanReservatConfigTimes.stream().collect(Collectors.groupingBy(BomanReservatConfigTime::getReservatConfigType));
|
|
|
+ for (String key : collect.keySet()) {
|
|
|
+ if ("1".equals(key)){
|
|
|
+ jsonObject.put("amList",collect.get(key));
|
|
|
+ }else {
|
|
|
+ jsonObject.put("pmList",collect.get(key));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ jsonArray.add(jsonObject);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ map.put("signList",jsonArray);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
}
|