optimize codes
This commit is contained in:
@@ -18,13 +18,7 @@ import jakarta.annotation.Resource;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
@Service
|
||||
public class RoomCalendarService {
|
||||
@@ -107,6 +101,18 @@ public class RoomCalendarService {
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isNotBlank(visibility.otherProperty) && StringUtils.isNotBlank(visibility.otherRoomType)) {
|
||||
try {
|
||||
HttpResponseResult response = mgmApiService.invokeRequestRoomCalendar(
|
||||
playerId, visibility.otherProperty, visibility.otherRoomType, startDate, endDate, 0);
|
||||
if (response.getStatusCode() == 200) {
|
||||
allRecords.addAll(parseRoomCalendarResponse(response.getResponseContent()));
|
||||
anySuccess = true;
|
||||
}
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
if (!anySuccess) {
|
||||
result.setSuccess(false);
|
||||
result.setMessage("RequestRoomCalendar failed");
|
||||
@@ -147,11 +153,15 @@ public class RoomCalendarService {
|
||||
String operaRoomType = "";
|
||||
String daylightProperty = "";
|
||||
String daylightRoomType = "";
|
||||
String otherProperty = "";
|
||||
String otherRoomType = "";
|
||||
|
||||
List<String> operaIds = new ArrayList<>();
|
||||
List<String> operaCodes = new ArrayList<>();
|
||||
List<String> daylightIds = new ArrayList<>();
|
||||
List<String> daylightCodes = new ArrayList<>();
|
||||
List<String> otherIds = new ArrayList<>();
|
||||
List<String> otherCodes = new ArrayList<>();
|
||||
for (CfgProperties cfgProperty : visibleProperties) {
|
||||
String category = cfgProperty.getCategory();
|
||||
if (StringUtils.equalsIgnoreCase(category, "OPERA")) {
|
||||
@@ -160,6 +170,9 @@ public class RoomCalendarService {
|
||||
} else if (StringUtils.equalsIgnoreCase(category, "DAYLIGHT")) {
|
||||
daylightIds.add(String.valueOf(cfgProperty.getId()));
|
||||
daylightCodes.add(cfgProperty.getCode());
|
||||
} else if (StringUtils.equalsIgnoreCase(category, "OTHER")) {
|
||||
otherIds.add(String.valueOf(cfgProperty.getId()));
|
||||
otherCodes.add(cfgProperty.getCode());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,11 +192,21 @@ public class RoomCalendarService {
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(operaRoomType) && StringUtils.isBlank(daylightRoomType)) {
|
||||
if (!otherIds.isEmpty()) {
|
||||
List<String> visibleOtherRoomTypes = filterVisibleRoomTypes(roomTypeNames, rooms, otherIds);
|
||||
if (!visibleOtherRoomTypes.isEmpty()) {
|
||||
otherProperty = StringUtils.join(otherCodes, ",");
|
||||
otherRoomType = StringUtils.join(visibleOtherRoomTypes, ",");
|
||||
}
|
||||
}
|
||||
|
||||
if (StringUtils.isBlank(operaRoomType) && StringUtils.isBlank(daylightRoomType)
|
||||
&& StringUtils.isBlank(otherRoomType)) {
|
||||
return CalendarVisibilityCheck.failure("ROOMTYPENOSHOW", "Room type no show in calendar");
|
||||
}
|
||||
|
||||
return CalendarVisibilityCheck.success(operaProperty, operaRoomType, daylightProperty, daylightRoomType);
|
||||
return CalendarVisibilityCheck.success(operaProperty, operaRoomType,
|
||||
daylightProperty, daylightRoomType, otherProperty, otherRoomType);
|
||||
}
|
||||
|
||||
public GetPropertyRoomTypeListResponse getPropertyRoomType() {
|
||||
@@ -441,25 +464,32 @@ public class RoomCalendarService {
|
||||
private final String operaRoomType;
|
||||
private final String daylightProperty;
|
||||
private final String daylightRoomType;
|
||||
private final String otherProperty;
|
||||
private final String otherRoomType;
|
||||
|
||||
private CalendarVisibilityCheck(String errorCode, String errorMessage,
|
||||
String operaProperty, String operaRoomType,
|
||||
String daylightProperty, String daylightRoomType) {
|
||||
String daylightProperty, String daylightRoomType,
|
||||
String otherProperty, String otherRoomType) {
|
||||
this.errorCode = errorCode;
|
||||
this.errorMessage = errorMessage;
|
||||
this.operaProperty = operaProperty;
|
||||
this.operaRoomType = operaRoomType;
|
||||
this.daylightProperty = daylightProperty;
|
||||
this.daylightRoomType = daylightRoomType;
|
||||
this.otherProperty = otherProperty;
|
||||
this.otherRoomType = otherRoomType;
|
||||
}
|
||||
|
||||
private static CalendarVisibilityCheck success(String operaProperty, String operaRoomType,
|
||||
String daylightProperty, String daylightRoomType) {
|
||||
return new CalendarVisibilityCheck(null, null, operaProperty, operaRoomType, daylightProperty, daylightRoomType);
|
||||
String daylightProperty, String daylightRoomType,
|
||||
String otherProperty, String otherRoomType) {
|
||||
return new CalendarVisibilityCheck(null, null, operaProperty, operaRoomType,
|
||||
daylightProperty, daylightRoomType, otherProperty, otherRoomType);
|
||||
}
|
||||
|
||||
private static CalendarVisibilityCheck failure(String errorCode, String errorMessage) {
|
||||
return new CalendarVisibilityCheck(errorCode, errorMessage, null, null, null, null);
|
||||
return new CalendarVisibilityCheck(errorCode, errorMessage, null, null, null, null, null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user