|
@@ -1,17 +1,24 @@
|
|
|
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.bean.copier.CopyOptions;
|
|
|
|
|
|
|
+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;
|
|
@@ -22,6 +29,9 @@ 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>
|
|
@@ -39,6 +49,10 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
@Resource
|
|
@Resource
|
|
|
private BusMeetingRoomScheduleDetailServiceImpl meetingRoomScheduleDetailService;
|
|
private BusMeetingRoomScheduleDetailServiceImpl meetingRoomScheduleDetailService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private BusMeetingRoomServiceImpl busMeetingRoomService;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
*
|
|
*
|
|
|
* @return
|
|
* @return
|
|
@@ -52,7 +66,7 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
*/
|
|
*/
|
|
|
BusMeetingRoomSchedule roomSchedule = new BusMeetingRoomSchedule();
|
|
BusMeetingRoomSchedule roomSchedule = new BusMeetingRoomSchedule();
|
|
|
|
|
|
|
|
- BeanUtil.copyProperties(dto,roomSchedule, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
|
|
|
|
|
|
|
+ BeanUtil.copyProperties(dto,roomSchedule);
|
|
|
roomSchedule.setTenantId(tenantId);
|
|
roomSchedule.setTenantId(tenantId);
|
|
|
roomSchedule.setCreateTime(LocalDateTime.now());
|
|
roomSchedule.setCreateTime(LocalDateTime.now());
|
|
|
meetingRoomScheduleMapper.insert(roomSchedule);
|
|
meetingRoomScheduleMapper.insert(roomSchedule);
|
|
@@ -81,18 +95,80 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
* 查询 创建数据
|
|
* 查询 创建数据
|
|
|
* @param startDate
|
|
* @param startDate
|
|
|
* @param endDate
|
|
* @param endDate
|
|
|
- * @param viewType
|
|
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public Result fetch(String startDate,String endDate, Integer viewType,String hotelId){
|
|
|
|
|
|
|
+ public Result fetch(String startDate,String endDate,String hotelId){
|
|
|
DateTimeFormatter struct = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter struct = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
LocalDateTime startTime = LocalDate.parse(startDate,struct).atStartOfDay();
|
|
LocalDateTime startTime = LocalDate.parse(startDate,struct).atStartOfDay();
|
|
|
LocalDate endLocalDate = LocalDate.parse(endDate,struct);
|
|
LocalDate endLocalDate = LocalDate.parse(endDate,struct);
|
|
|
LocalDateTime endTime = LocalDateTime.of(endLocalDate, LocalTime.of(23,59,59));;
|
|
LocalDateTime endTime = LocalDateTime.of(endLocalDate, LocalTime.of(23,59,59));;
|
|
|
|
|
|
|
|
-// List<>meetingRoomScheduleDetailService.fetchByDateRange(startTime,endTime, hotelId);
|
|
|
|
|
|
|
+ DateTimeFormatter struct1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
|
|
+ List<BusMeetingRoom> busMeetingRooms = busMeetingRoomService.fetch(hotelId);
|
|
|
|
|
+ if(CollectionUtil.isEmpty(busMeetingRooms)) return Result.ok(new ArrayList<>());
|
|
|
|
|
+ List<String> meetingIds = busMeetingRooms.stream().map(v -> v.getId()).collect(Collectors.toList());
|
|
|
|
|
+
|
|
|
|
|
+ List<BusMeetingRoomScheduleDetail> scheduleDetails = meetingRoomScheduleDetailService.fetchByDateRange(startTime,endTime, hotelId,meetingIds);
|
|
|
|
|
+ if(CollectionUtil.isEmpty(scheduleDetails)) return Result.ok(new ArrayList<>());
|
|
|
|
|
|
|
|
|
|
+ List<String> scheduleIds = scheduleDetails.stream().map(v -> v.getMeetingRoomScheduleId()).collect(Collectors.toList());
|
|
|
|
|
+ List<BusMeetingRoomSchedule> schedules = meetingRoomScheduleMapper.selectBatchIds(scheduleIds);
|
|
|
|
|
+ if(CollectionUtil.isEmpty(schedules)) return Result.ok(new ArrayList<>());
|
|
|
|
|
|
|
|
- return Result.ok("");
|
|
|
|
|
|
|
+ List<BusMeetingRoomScheduleVo> vos = new ArrayList<>();
|
|
|
|
|
+ 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());
|
|
|
|
|
+ //固定三条数据
|
|
|
|
|
+ Map<Integer,List<BusMeetingRoomScheduleDetail>> groupData = details.stream().collect(Collectors.groupingBy(BusMeetingRoomScheduleDetail::getTimeSpan));
|
|
|
|
|
+ groupData.forEach((key,value)-> {
|
|
|
|
|
+ //第二层 上午下午中午
|
|
|
|
|
+ BusMeetingRoomScheduleDetailVo detailVo = new BusMeetingRoomScheduleDetailVo();
|
|
|
|
|
+
|
|
|
|
|
+ detailVo.setTimePeriod(CouponsKeyEnum.val(key).getTitle());
|
|
|
|
|
+
|
|
|
|
|
+ List<BusMeetingKeyValueVo> dataCh = new ArrayList<>();
|
|
|
|
|
+ //第二层结束
|
|
|
|
|
+ Map<String,List<MeetingRoomScheduleDetailVo>> map = new HashedMap();
|
|
|
|
|
+ Map<List<String>, List<MeetingRoomScheduleDetailVo>> result = new HashedMap();
|
|
|
|
|
+ //第三层开始 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 = schedules.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);
|
|
|
|
|
+ schedule.add(detailVo);
|
|
|
|
|
+ });
|
|
|
|
|
+ vo.setChild(schedule);
|
|
|
|
|
+ vos.add(vo);
|
|
|
|
|
+ });
|
|
|
|
|
+ return Result.ok(vos);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|