|
|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.common.exception.JeecgBootException;
|
|
|
import org.jeecg.common.util.TokenUtils;
|
|
|
import org.jeecg.modules.business.dto.BusMeetingRoomScheduleDetailDto;
|
|
|
import org.jeecg.modules.business.dto.BusMeetingRoomScheduleDto;
|
|
|
@@ -26,10 +27,7 @@ import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
@@ -51,19 +49,28 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
@Resource
|
|
|
private BusMeetingRoomServiceImpl busMeetingRoomService;
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackOn = Exception.class)
|
|
|
public Result create(BusMeetingRoomScheduleDto dto){
|
|
|
+ DateTimeFormatter struct = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
String tenantId = TokenUtils.currentTenantId();
|
|
|
String hotelId = dto.getHotelId();
|
|
|
+
|
|
|
+ //查询数据库是否有相同的数据
|
|
|
+ List<BusMeetingRoomScheduleDetailDto> detailList = dto.getDetailList();
|
|
|
+ List<LocalDateTime> dataRange = detailList.stream().map(v -> LocalDate.parse(v.getMeetingDate(),struct).atStartOfDay()).collect(Collectors.toList());
|
|
|
+ dataRange.sort(Comparator.naturalOrder());
|
|
|
+ LocalDateTime min = dataRange.get(0);
|
|
|
+ LocalDateTime max = dataRange.get(dataRange.size() -1);
|
|
|
+ max = LocalDateTime.of(max.toLocalDate(), LocalTime.of(23,59,59));;
|
|
|
+ List<String> roomIds = detailList.stream().map(v -> v.getMeetingRoomId()).collect(Collectors.toList());
|
|
|
+ List<BusMeetingRoomScheduleDetail> detailsList = meetingRoomScheduleDetailService.fetchByDateRange(min,max, hotelId, roomIds);
|
|
|
/**
|
|
|
* 创建主表
|
|
|
*/
|
|
|
-
|
|
|
BusMeetingRoomSchedule roomSchedule = new BusMeetingRoomSchedule();
|
|
|
|
|
|
BeanUtil.copyProperties(dto,roomSchedule);
|
|
|
@@ -71,12 +78,19 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
roomSchedule.setCreateTime(LocalDateTime.now());
|
|
|
meetingRoomScheduleMapper.insert(roomSchedule);
|
|
|
|
|
|
- List<BusMeetingRoomScheduleDetailDto> detailList = dto.getDetailList();
|
|
|
List<BusMeetingRoomScheduleDetail> details = new ArrayList<>();
|
|
|
- DateTimeFormatter struct = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+
|
|
|
detailList.forEach(v -> {
|
|
|
- BusMeetingRoomScheduleDetail detail= new BusMeetingRoomScheduleDetail();
|
|
|
LocalDateTime meetingDate = LocalDate.parse(v.getMeetingDate(),struct).atStartOfDay();
|
|
|
+ List<BusMeetingRoomScheduleDetail> list = detailsList.stream().filter(f ->{
|
|
|
+ if(f.getMeetingRoomId().equals(v.getMeetingRoomId()) && f.getTimeSpan().intValue() == v.getTimeSpan().intValue() && f.getMeetingDate().compareTo(meetingDate) == 0){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if(!CollectionUtil.isEmpty(list)) throw new JeecgBootException("数据重复!");
|
|
|
+ BusMeetingRoomScheduleDetail detail= new BusMeetingRoomScheduleDetail();
|
|
|
+
|
|
|
detail.setMeetingRoomId(v.getMeetingRoomId());
|
|
|
detail.setMeetingDate(meetingDate);
|
|
|
detail.setTimeSpan(v.getTimeSpan().intValue());
|