|
@@ -1,5 +1,6 @@
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -11,6 +12,7 @@ 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 com.ruoyi.common.utils.bean.BeanUtils;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.apache.commons.lang3.math.NumberUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -113,14 +115,15 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult getCalendar(String date) {
|
|
|
- Map map =new HashMap();
|
|
|
+ Map<String,Object> map =new HashMap(1);
|
|
|
//获取所有时段
|
|
|
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){
|
|
|
+ JSONArray jsonArray = new JSONArray();
|
|
|
+ List<BomanReservatConfigTime> bomanReservatConfigTimeList = new ArrayList<>();
|
|
|
for (String dateMonth : monthFullDay) {
|
|
|
+ bomanReservatConfigTimeList.clear();
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
jsonObject.put("date",dateMonth);
|
|
|
jsonObject.put("title","不可约");
|
|
@@ -128,25 +131,29 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
|
|
|
//去查询对应日期是否还有时段可以预约
|
|
|
if (bomanReservatConfigTimes != null && bomanReservatConfigTimes.size() > 0){
|
|
|
for (BomanReservatConfigTime reservatConfigTime : bomanReservatConfigTimes) {
|
|
|
+ BomanReservatConfigTime bomanReservatConfigTime = new BomanReservatConfigTime();
|
|
|
+ BeanUtils.copyBeanProp(bomanReservatConfigTime,reservatConfigTime);
|
|
|
//查询所有时段和最大人数
|
|
|
//去redis找对应日期,对应时段id的预约数量 reservat_num:2023-10-10_1
|
|
|
//已经预约人数
|
|
|
Object reservatNum= redisCache.getCacheObject(Constants.RESERVAT_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
|
|
|
+ bomanReservatConfigTime.setReservatConfigStatus("Y");
|
|
|
if (ObjectUtils.isNotEmpty(reservatNum)){
|
|
|
//判断人数是否大于可预约人数
|
|
|
//如果 x==y 返回0;x<y 返回负数(-1);x>y 返回正数(1)
|
|
|
- reservatConfigTime.setReservatConfigStatus("N");
|
|
|
- if (NumberUtils.compare(reservatConfigTime.getReservatConfigNum(),(long)reservatNum) < 1){
|
|
|
- reservatConfigTime.setReservatConfigStatus("Y");
|
|
|
+ if (NumberUtils.compare(bomanReservatConfigTime.getReservatConfigNum(),(long)reservatNum) < 1){
|
|
|
+ bomanReservatConfigTime.setReservatConfigStatus("N");
|
|
|
index++;
|
|
|
}
|
|
|
}
|
|
|
+ bomanReservatConfigTimeList.add(bomanReservatConfigTime);
|
|
|
}
|
|
|
if (index < bomanReservatConfigTimes.size()){
|
|
|
jsonObject.put("title","可预约");
|
|
|
}
|
|
|
//1: AM 2: PM
|
|
|
- Map<String, List<BomanReservatConfigTime>> collect = bomanReservatConfigTimes.stream().collect(Collectors.groupingBy(BomanReservatConfigTime::getReservatConfigType));
|
|
|
+ Map<String, List<BomanReservatConfigTime>> collect = bomanReservatConfigTimeList.stream().collect(Collectors.groupingBy(BomanReservatConfigTime::getReservatConfigType));
|
|
|
+
|
|
|
for (String key : collect.keySet()) {
|
|
|
if ("1".equals(key)){
|
|
|
jsonObject.put("amList",collect.get(key));
|
|
@@ -157,8 +164,8 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
|
|
|
}
|
|
|
jsonArray.add(jsonObject);
|
|
|
}
|
|
|
+ map.put("signList",jsonArray);
|
|
|
}
|
|
|
- map.put("signList",jsonArray);
|
|
|
return AjaxResult.success(map);
|
|
|
}
|
|
|
}
|