|
|
|
@ -3,6 +3,7 @@ package com.gcc.communityHall.controller; |
|
|
|
import com.gcc.communityHall.dto.saveEbDetailsAndDamage; |
|
|
|
import com.gcc.communityHall.entity.*; |
|
|
|
import com.gcc.communityHall.others.UserSession; |
|
|
|
import com.gcc.communityHall.service.CalendarService; |
|
|
|
import com.gcc.communityHall.service.Impl.BookingServiceImpl; |
|
|
|
import com.gcc.communityHall.service.Impl.HallDetailServiceImpl; |
|
|
|
import com.gcc.communityHall.service.Impl.UserServiceImpl; |
|
|
|
@ -16,8 +17,11 @@ import org.springframework.web.bind.annotation.*; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
import org.springframework.web.multipart.MultipartHttpServletRequest; |
|
|
|
|
|
|
|
import java.time.LocalDate; |
|
|
|
import java.time.format.DateTimeFormatter; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/api/test") |
|
|
|
public class TestController { |
|
|
|
@ -34,6 +38,9 @@ public class TestController { |
|
|
|
@Autowired |
|
|
|
ReasonMasterService reasonMasterService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
CalendarService calendarService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private UserSession userSession; |
|
|
|
|
|
|
|
@ -190,6 +197,24 @@ public ResponseEntity<?> saveTheBookingDetails(HttpServletRequest request) { |
|
|
|
return ResponseEntity.ok(""); |
|
|
|
} |
|
|
|
|
|
|
|
@GetMapping(path = "/saveEbDetails") |
|
|
|
public ResponseEntity<?> saveEbDetails(@RequestParam int bookingId,@RequestParam double startingReading) { |
|
|
|
BookingDetails bd =bookingService.getBookingsById(bookingId); |
|
|
|
if(bd!=null){ |
|
|
|
if(bd.getEbDetails()==null){ |
|
|
|
EbDetails eb = new EbDetails(); |
|
|
|
eb.setCdate(new Date()); |
|
|
|
eb.setStartingReading(startingReading); |
|
|
|
bd.setEbDetails(eb); |
|
|
|
ResponseEntity.ok(bookingService.updateBookingDetails(bd)); |
|
|
|
} |
|
|
|
System.out.println(bd.getEbDetails()); |
|
|
|
} |
|
|
|
|
|
|
|
return ResponseEntity.ok(""); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String,Object> splitFormData(MultipartHttpServletRequest multipartRequest){ |
|
|
|
Map<String, Object> formData = new HashMap<>(); |
|
|
|
@ -218,4 +243,123 @@ public ResponseEntity<?> saveTheBookingDetails(HttpServletRequest request) { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/checkAvail") |
|
|
|
public List<HallDetails> checkAvail(@RequestParam("fromDate") String fromDate, |
|
|
|
@RequestParam("toDate") String toDate, |
|
|
|
@RequestParam("starting") String starting, |
|
|
|
@RequestParam("ending") String ending, |
|
|
|
@RequestParam(name = "hallId",required = false) String hallId){ |
|
|
|
List<BookingCalendar> data = new ArrayList<>(); |
|
|
|
HashSet<Integer> removeHallId = new HashSet<Integer>(); |
|
|
|
int hallIdd=0; |
|
|
|
if(hallId != null && !hallId.equals("")){ |
|
|
|
hallIdd = Integer.parseInt(hallId); |
|
|
|
} |
|
|
|
if(!fromDate.equals(toDate) && (starting.equals(ending) || starting.equals("evening") && ending.equals("morning"))){ |
|
|
|
Map<String,String> mp =incrementAndDecrementAndDaysCount(fromDate,toDate); |
|
|
|
long noOfDays= Long.parseLong(mp.get("NoOfDays").toString()); |
|
|
|
if(noOfDays>2){ |
|
|
|
data = calendarService.getCalendarByDateAndHallIdAndSlot(mp.get("fromDate"),mp.get("toDate"),starting,ending,hallIdd); |
|
|
|
for(int i=0;i<data.size();i++){ |
|
|
|
removeHallId.add(data.get(i).getHallId()); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
data=calendarService.getCalendarByDateAndHallIdAndSlot(fromDate,toDate,starting,ending,hallIdd); |
|
|
|
System.out.println("data size :-"+data.size()); |
|
|
|
|
|
|
|
if(starting!=null && ending != null ) { |
|
|
|
boolean checkAvail =false; |
|
|
|
int checkHallId=0; |
|
|
|
for(int i=0;i<data.size();i++) { |
|
|
|
|
|
|
|
if((starting.equals("evening") || ending.equals("morning")) && fromDate.equals(data.get(i).getBdate().toString()) && toDate.equals(fromDate)) { |
|
|
|
if(data.get(i).isEveningSlot()==false) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
else if(data.get(i).isMorningSlot()==false) { |
|
|
|
continue; |
|
|
|
} |
|
|
|
} else if ((starting.equals(ending) || starting.equals("evening") && ending.equals("morning")) && !toDate.equals(fromDate)) { |
|
|
|
if(checkHallId==0 || checkHallId != data.get(i).getHallId()){ |
|
|
|
checkHallId = data.get(i).getHallId(); |
|
|
|
checkAvail=false; |
|
|
|
} |
|
|
|
|
|
|
|
if(starting.equals("morning") && ending.equals("morning") ) { |
|
|
|
if(fromDate.equals(data.get(i).getBdate().toString()) && data.get(i).isMorningSlot()==false){ |
|
|
|
if(checkHallId == data.get(i).getHallId()){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(toDate.equals(data.get(i).getBdate().toString()) && data.get(i).isMorningSlot()==false){ |
|
|
|
if(checkHallId == data.get(i).getHallId() && checkAvail==false){ |
|
|
|
checkHallId=data.get(i).getHallId(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(starting.equals("evening") && ending.equals("morning") ) { |
|
|
|
|
|
|
|
if(fromDate.equals(data.get(i).getBdate().toString()) && data.get(i).isEveningSlot()==false){ |
|
|
|
if(checkHallId == data.get(i).getHallId()){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else if(toDate.equals(data.get(i).getBdate().toString()) && data.get(i).isMorningSlot()==false){ |
|
|
|
if(checkHallId == data.get(i).getHallId() && checkAvail==false){ |
|
|
|
checkHallId=data.get(i).getHallId(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(starting.equals("evening") && ending.equals("evening") ) { |
|
|
|
if(fromDate.equals(data.get(i).getBdate().toString()) && data.get(i).isEveningSlot()==false){ |
|
|
|
if(checkHallId == data.get(i).getHallId()){ |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(toDate.equals(data.get(i).getBdate().toString()) && data.get(i).isEveningSlot()==false){ |
|
|
|
if(checkHallId == data.get(i).getHallId() && checkAvail==false){ |
|
|
|
checkHallId=data.get(i).getHallId(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else{ |
|
|
|
if(checkHallId == data.get(i).getHallId()) { |
|
|
|
checkAvail = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
removeHallId.add(data.get(i).getHallId()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
List<HallDetails> removeHallByid = hallDetailService.removeHallById(removeHallId); |
|
|
|
return removeHallByid; |
|
|
|
} |
|
|
|
|
|
|
|
Map<String,String> incrementAndDecrementAndDaysCount(String fromdate, String todate){ |
|
|
|
Map mp = new HashMap<>(); |
|
|
|
LocalDate increasement = LocalDate.parse(fromdate); |
|
|
|
LocalDate decrement = LocalDate.parse(todate); |
|
|
|
|
|
|
|
LocalDate outputDateFrom =increasement; |
|
|
|
LocalDate outputDateToday = decrement; |
|
|
|
|
|
|
|
long daysDifference = increasement.until(decrement).getDays(); |
|
|
|
daysDifference = Math.abs(daysDifference); |
|
|
|
|
|
|
|
if(fromdate!=todate) { |
|
|
|
outputDateFrom = increasement.plusDays(1); |
|
|
|
outputDateToday = decrement.minusDays(1); |
|
|
|
} |
|
|
|
|
|
|
|
mp.put("fromDate", outputDateFrom.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
mp.put("toDate",outputDateToday.format(DateTimeFormatter.ofPattern("yyyy-MM-dd"))); |
|
|
|
mp.put("NoOfDays",daysDifference+""); |
|
|
|
return mp; |
|
|
|
} |
|
|
|
|
|
|
|
} |