|
@@ -1,25 +1,37 @@
|
|
|
package org.jeecg.modules.business.service.impl;
|
|
package org.jeecg.modules.business.service.impl;
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
|
|
+import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
import org.jeecg.common.util.TokenUtils;
|
|
import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.modules.business.dto.BusMeetingRoomScheduleDetailDto;
|
|
import org.jeecg.modules.business.dto.BusMeetingRoomScheduleDetailDto;
|
|
|
import org.jeecg.modules.business.dto.BusMeetingRoomScheduleDto;
|
|
import org.jeecg.modules.business.dto.BusMeetingRoomScheduleDto;
|
|
|
|
|
+import org.jeecg.modules.business.entity.BusMeetingRoom;
|
|
|
import org.jeecg.modules.business.entity.BusMeetingRoomSchedule;
|
|
import org.jeecg.modules.business.entity.BusMeetingRoomSchedule;
|
|
|
import org.jeecg.modules.business.entity.BusMeetingRoomScheduleDetail;
|
|
import org.jeecg.modules.business.entity.BusMeetingRoomScheduleDetail;
|
|
|
|
|
+import org.jeecg.modules.business.enums.CouponsKeyEnum;
|
|
|
import org.jeecg.modules.business.mapper.BusMeetingRoomScheduleDetailMapper;
|
|
import org.jeecg.modules.business.mapper.BusMeetingRoomScheduleDetailMapper;
|
|
|
import org.jeecg.modules.business.mapper.BusMeetingRoomScheduleMapper;
|
|
import org.jeecg.modules.business.mapper.BusMeetingRoomScheduleMapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
|
+import org.jeecg.modules.business.vo.BusMeetingKeyValueVo;
|
|
|
|
|
+import org.jeecg.modules.business.vo.BusMeetingRoomScheduleDetailVo;
|
|
|
|
|
+import org.jeecg.modules.business.vo.BusMeetingRoomScheduleVo;
|
|
|
|
|
+import org.jeecg.modules.business.vo.MeetingRoomScheduleDetailVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
import javax.transaction.Transactional;
|
|
import javax.transaction.Transactional;
|
|
|
import java.time.LocalDate;
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.Optional;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* <p>
|
|
* <p>
|
|
@@ -37,6 +49,10 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
@Resource
|
|
@Resource
|
|
|
private BusMeetingRoomScheduleDetailServiceImpl meetingRoomScheduleDetailService;
|
|
private BusMeetingRoomScheduleDetailServiceImpl meetingRoomScheduleDetailService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private BusMeetingRoomServiceImpl busMeetingRoomService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
* @return
|
|
* @return
|
|
@@ -69,15 +85,94 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
detail.setHotelId(hotelId);
|
|
detail.setHotelId(hotelId);
|
|
|
details.add(detail);
|
|
details.add(detail);
|
|
|
});
|
|
});
|
|
|
- meetingRoomScheduleDetailService.saveBatch(details);
|
|
|
|
|
|
|
+ meetingRoomScheduleDetailService.saveBatchDetail(details);
|
|
|
|
|
|
|
|
return Result.ok("创建成功!");
|
|
return Result.ok("创建成功!");
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询 创建数据
|
|
|
|
|
+ * @param startDate
|
|
|
|
|
+ * @param endDate
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public Result fetch(String startDate,String endDate,String hotelId){
|
|
|
|
|
+ List<BusMeetingRoomScheduleVo> vos = new ArrayList<>();
|
|
|
|
|
|
|
|
- public Result fetch(){
|
|
|
|
|
|
|
+ DateTimeFormatter struct = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ LocalDateTime startTime = LocalDate.parse(startDate,struct).atStartOfDay();
|
|
|
|
|
+ LocalDate endLocalDate = LocalDate.parse(endDate,struct);
|
|
|
|
|
+ LocalDateTime endTime = LocalDateTime.of(endLocalDate, LocalTime.of(23,59,59));;
|
|
|
|
|
|
|
|
- return Result.ok("");
|
|
|
|
|
|
|
+ DateTimeFormatter struct1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ List<BusMeetingRoom> busMeetingRooms = busMeetingRoomService.fetch(hotelId);
|
|
|
|
|
+ if(CollectionUtil.isEmpty(busMeetingRooms)) return Result.ok(vos);
|
|
|
|
|
+ List<String> meetingIds = busMeetingRooms.stream().map(v -> v.getId()).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ List<BusMeetingRoomScheduleDetail> scheduleDetails = meetingRoomScheduleDetailService.fetchByDateRange(startTime,endTime, hotelId,meetingIds);
|
|
|
|
|
+
|
|
|
|
|
+ List<String> scheduleIds = scheduleDetails.stream().map(v -> v.getMeetingRoomScheduleId()).collect(Collectors.toList());
|
|
|
|
|
+ List<BusMeetingRoomSchedule> schedules = new ArrayList<>();
|
|
|
|
|
+ if(!CollectionUtil.isEmpty(scheduleIds)){
|
|
|
|
|
+ schedules = meetingRoomScheduleMapper.selectBatchIds(scheduleIds);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<BusMeetingRoomSchedule> finalSchedules = schedules;
|
|
|
|
|
+ busMeetingRooms.forEach(v -> {
|
|
|
|
|
+ BusMeetingRoomScheduleVo vo = new BusMeetingRoomScheduleVo();
|
|
|
|
|
+ vo.setMeetingRoomName(v.getName());
|
|
|
|
|
+ vo.setId(v.getId());
|
|
|
|
|
+ List<BusMeetingRoomScheduleDetailVo> schedule = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ //获取当前会议室下的所有 预定详情数据
|
|
|
|
|
+ List<BusMeetingRoomScheduleDetail> details = scheduleDetails.stream().filter(schedul -> schedul.getMeetingRoomId().equals(v.getId())).collect(Collectors.toList());
|
|
|
|
|
+ for (int key = 1; key <= CouponsKeyEnum.getDictList().size(); key++) {
|
|
|
|
|
+ //第二层 上午下午中午
|
|
|
|
|
+ BusMeetingRoomScheduleDetailVo detailVo = new BusMeetingRoomScheduleDetailVo();
|
|
|
|
|
+ detailVo.setTimePeriod(CouponsKeyEnum.val(key).getTitle());
|
|
|
|
|
+
|
|
|
|
|
+ List<BusMeetingKeyValueVo> dataCh = new ArrayList<>();
|
|
|
|
|
+ //第二层结束
|
|
|
|
|
+ Map<String, List<MeetingRoomScheduleDetailVo>> map = new HashedMap();
|
|
|
|
|
+ //查询详情数据
|
|
|
|
|
+ int finalKey = key;
|
|
|
|
|
+ List<BusMeetingRoomScheduleDetail> value = details.stream().filter(detail -> detail.getTimeSpan().intValue() == finalKey).collect(Collectors.toList());
|
|
|
|
|
+ if (!CollectionUtil.isEmpty(value)) {
|
|
|
|
|
+ //第三层开始 eg: 上午 : 上午的所有数据
|
|
|
|
|
+ value.forEach(vl -> {
|
|
|
|
|
+ MeetingRoomScheduleDetailVo scheduleDetailVo = new MeetingRoomScheduleDetailVo();
|
|
|
|
|
+ //生成key
|
|
|
|
|
+ String value_key = vl.getMeetingDate().format(struct1);
|
|
|
|
|
+ List<MeetingRoomScheduleDetailVo> scheduleDetailVos = new ArrayList<>();
|
|
|
|
|
+ //如果存在这个key
|
|
|
|
|
+ if (map.containsKey(value_key)) {
|
|
|
|
|
+ scheduleDetailVos = map.get(value_key);
|
|
|
|
|
+ }
|
|
|
|
|
+ Optional<BusMeetingRoomSchedule> scheduleOptional = finalSchedules.stream().filter(sc -> sc.getId().equals(vl.getMeetingRoomScheduleId())).findFirst();
|
|
|
|
|
+ if (!scheduleOptional.isPresent()) return;
|
|
|
|
|
+ BusMeetingRoomSchedule vl_schedule = scheduleOptional.get();
|
|
|
|
|
+ //生成数据
|
|
|
|
|
+ scheduleDetailVo.setTheme(vl_schedule.getTheme());
|
|
|
|
|
+ scheduleDetailVo.setDetail(vl);
|
|
|
|
|
+ scheduleDetailVo.setRoomSchedule(vl_schedule);
|
|
|
|
|
+ scheduleDetailVos.add(scheduleDetailVo);
|
|
|
|
|
+ map.put(value_key, scheduleDetailVos);
|
|
|
|
|
+ });
|
|
|
|
|
+ map.forEach((map_k, map_v) -> {
|
|
|
|
|
+ BusMeetingKeyValueVo valueVo = new BusMeetingKeyValueVo();
|
|
|
|
|
+ valueVo.setKey(map_k);
|
|
|
|
|
+ valueVo.setValue(map_v);
|
|
|
|
|
+ dataCh.add(valueVo);
|
|
|
|
|
+ });
|
|
|
|
|
+ detailVo.setSchedule(dataCh);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ detailVo.setSchedule(new ArrayList<>());
|
|
|
|
|
+ }
|
|
|
|
|
+ schedule.add(detailVo);
|
|
|
|
|
+ }
|
|
|
|
|
+ vo.setChild(schedule);
|
|
|
|
|
+ vos.add(vo);
|
|
|
|
|
+ });
|
|
|
|
|
+ return Result.ok(vos);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|