|
|
@@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.apache.commons.collections.map.HashedMap;
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
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;
|
|
|
@@ -19,15 +20,17 @@ 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.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import javax.transaction.Transactional;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.LocalTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -53,21 +56,33 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
|
|
|
@Resource
|
|
|
private BusMeetingRoomServiceImpl busMeetingRoomService;
|
|
|
- @Resource
|
|
|
- private BusMeetingRoomScheduleOrderDetailServiceImpl busMeetingRoomScheduleOrderDetailService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private BusMeetingRoomScheduleOrderDetailServiceImpl busMeetingRoomScheduleOrderDetailService;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @Transactional(rollbackOn = Exception.class)
|
|
|
+ @Transactional(rollbackFor = 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);
|
|
|
@@ -80,12 +95,19 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
roomSchedule.setOrderNo("HY"+sdf.format(System.currentTimeMillis()));
|
|
|
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());
|
|
|
@@ -189,7 +211,7 @@ public class BusMeetingRoomScheduleServiceImpl extends ServiceImpl<BusMeetingRoo
|
|
|
* @param busMeetingRoomSchedule
|
|
|
* @return
|
|
|
*/
|
|
|
- @org.springframework.transaction.annotation.Transactional(rollbackFor = Exception.class)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public Result settle(BusMeetingRoomSchedule busMeetingRoomSchedule) {
|
|
|
if (ObjectUtils.isEmpty(busMeetingRoomSchedule.getPaymentMethodList())) {
|
|
|
return Result.error("结算支付方式不能为空");
|