|
@@ -20,13 +20,12 @@ import com.ruoyi.system.service.IBomanReservatConfigTimeService;
|
|
|
|
|
|
/**
|
|
|
* 预约时段配置Service业务层处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author boman
|
|
|
* @date 2023-11-02
|
|
|
*/
|
|
|
@Service
|
|
|
-public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigTimeService
|
|
|
-{
|
|
|
+public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigTimeService {
|
|
|
@Autowired
|
|
|
private BomanReservatConfigTimeMapper bomanReservatConfigTimeMapper;
|
|
|
|
|
@@ -35,75 +34,69 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
|
|
|
|
|
|
/**
|
|
|
* 查询预约时段配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param reservatConfigTimeId 预约时段配置主键
|
|
|
* @return 预约时段配置
|
|
|
*/
|
|
|
@Override
|
|
|
- public BomanReservatConfigTime selectBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId)
|
|
|
- {
|
|
|
+ public BomanReservatConfigTime selectBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId) {
|
|
|
return bomanReservatConfigTimeMapper.selectBomanReservatConfigTimeByReservatConfigTimeId(reservatConfigTimeId);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 查询预约时段配置列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param bomanReservatConfigTime 预约时段配置
|
|
|
* @return 预约时段配置
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<BomanReservatConfigTime> selectBomanReservatConfigTimeList(BomanReservatConfigTime bomanReservatConfigTime)
|
|
|
- {
|
|
|
+ public List<BomanReservatConfigTime> selectBomanReservatConfigTimeList(BomanReservatConfigTime bomanReservatConfigTime) {
|
|
|
return bomanReservatConfigTimeMapper.selectBomanReservatConfigTimeList(bomanReservatConfigTime);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增预约时段配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param bomanReservatConfigTime 预约时段配置
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime)
|
|
|
- {
|
|
|
+ public int insertBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime) {
|
|
|
bomanReservatConfigTime.setCreateTime(DateUtils.getNowDate());
|
|
|
return bomanReservatConfigTimeMapper.insertBomanReservatConfigTime(bomanReservatConfigTime);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改预约时段配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param bomanReservatConfigTime 预约时段配置
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime)
|
|
|
- {
|
|
|
+ public int updateBomanReservatConfigTime(BomanReservatConfigTime bomanReservatConfigTime) {
|
|
|
bomanReservatConfigTime.setUpdateTime(DateUtils.getNowDate());
|
|
|
return bomanReservatConfigTimeMapper.updateBomanReservatConfigTime(bomanReservatConfigTime);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 批量删除预约时段配置
|
|
|
- *
|
|
|
+ *
|
|
|
* @param reservatConfigTimeIds 需要删除的预约时段配置主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteBomanReservatConfigTimeByReservatConfigTimeIds(Long[] reservatConfigTimeIds)
|
|
|
- {
|
|
|
+ public int deleteBomanReservatConfigTimeByReservatConfigTimeIds(Long[] reservatConfigTimeIds) {
|
|
|
return bomanReservatConfigTimeMapper.deleteBomanReservatConfigTimeByReservatConfigTimeIds(reservatConfigTimeIds);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除预约时段配置信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param reservatConfigTimeId 预约时段配置主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId)
|
|
|
- {
|
|
|
+ public int deleteBomanReservatConfigTimeByReservatConfigTimeId(Long reservatConfigTimeId) {
|
|
|
return bomanReservatConfigTimeMapper.deleteBomanReservatConfigTimeByReservatConfigTimeId(reservatConfigTimeId);
|
|
|
}
|
|
|
|
|
@@ -112,62 +105,68 @@ public class BomanReservatConfigTimeServiceImpl implements IBomanReservatConfigT
|
|
|
*/
|
|
|
@Override
|
|
|
public AjaxResult getCalendar(String date) {
|
|
|
- Map<String,Object> map =new HashMap(1);
|
|
|
+ Map<String, Object> map = new HashMap(1);
|
|
|
//获取所有时段
|
|
|
List<BomanReservatConfigTime> bomanReservatConfigTimes = bomanReservatConfigTimeMapper.selectBomanReservatConfigTimeList(new BomanReservatConfigTime());
|
|
|
List<String> monthFullDay = DateUtils.getMonthFullDay(DateUtils.parseDate(date));
|
|
|
- if (monthFullDay != null && monthFullDay.size() > 0){
|
|
|
+ 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","不可约");
|
|
|
+ jsonObject.put("date", dateMonth);
|
|
|
+ jsonObject.put("title", "不可约");
|
|
|
int index = 0;
|
|
|
//去查询对应日期是否还有时段可以预约
|
|
|
- if (bomanReservatConfigTimes != null && bomanReservatConfigTimes.size() > 0){
|
|
|
+ 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)
|
|
|
- if (NumberUtils.compare(bomanReservatConfigTime.getReservatConfigNum(),(long)reservatNum) < 1){
|
|
|
- bomanReservatConfigTime.setReservatConfigStatus("N");
|
|
|
- index++;
|
|
|
+ //判断时间段结束时间是否大于当前时间
|
|
|
+ BomanReservatConfigTime bomanReservatConfigTime = new BomanReservatConfigTime();
|
|
|
+ BeanUtils.copyBeanProp(bomanReservatConfigTime, reservatConfigTime);
|
|
|
+ if (DateUtils.sameDayCompare(reservatConfigTime.getReservatConfigTimeEnd(), DateUtils.getNowDate())) {
|
|
|
+ //查询所有时段和最大人数
|
|
|
+ //去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)
|
|
|
+ if (NumberUtils.compare(bomanReservatConfigTime.getReservatConfigNum(), (long) reservatNum) < 1) {
|
|
|
+ bomanReservatConfigTime.setReservatConfigStatus("N");
|
|
|
+ index++;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- bomanReservatConfigTimeList.add(bomanReservatConfigTime);
|
|
|
- bomanReservatConfigTime.setReceptionPersonnelType("N");
|
|
|
- //去查询该时间段接待人员是否已满
|
|
|
- Object cacheObject = redisCache.getCacheObject(Constants.RESERVAT_PERSONNEL_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
|
|
|
- if (ObjectUtils.isNotEmpty(cacheObject)){
|
|
|
- bomanReservatConfigTime.setReceptionPersonnelType("Y");
|
|
|
+ bomanReservatConfigTimeList.add(bomanReservatConfigTime);
|
|
|
+ bomanReservatConfigTime.setReceptionPersonnelType("N");
|
|
|
+ //去查询该时间段接待人员是否已满
|
|
|
+ Object cacheObject = redisCache.getCacheObject(Constants.RESERVAT_PERSONNEL_NUM + dateMonth + "_" + reservatConfigTime.getReservatConfigTimeId());
|
|
|
+ if (ObjectUtils.isNotEmpty(cacheObject)) {
|
|
|
+ bomanReservatConfigTime.setReceptionPersonnelType("Y");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ bomanReservatConfigTime.setReservatConfigStatus("N");
|
|
|
+ bomanReservatConfigTimeList.add(bomanReservatConfigTime);
|
|
|
}
|
|
|
}
|
|
|
- if (index < bomanReservatConfigTimes.size()){
|
|
|
- jsonObject.put("title","可预约");
|
|
|
+ if (index < bomanReservatConfigTimes.size()) {
|
|
|
+ jsonObject.put("title", "可预约");
|
|
|
}
|
|
|
//1: AM 2: PM
|
|
|
Map<String, List<BomanReservatConfigTime>> collect = bomanReservatConfigTimeList.stream().sorted(Comparator.comparing(BomanReservatConfigTime::getReservatConfigTimeBegin)).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));
|
|
|
+ if ("1".equals(key)) {
|
|
|
+ jsonObject.put("amList", collect.get(key));
|
|
|
+ } else {
|
|
|
+ jsonObject.put("pmList", collect.get(key));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
jsonArray.add(jsonObject);
|
|
|
}
|
|
|
- map.put("signList",jsonArray);
|
|
|
+ map.put("signList", jsonArray);
|
|
|
}
|
|
|
return AjaxResult.success(map);
|
|
|
}
|