查询预约时间段预约情况返回时间格式修改&查询SQL错误修改

This commit is contained in:
feng.li
2023-11-08 17:49:21 +08:00
parent f1c458a280
commit e0577b1ddc
3 changed files with 30 additions and 30 deletions

View File

@@ -572,27 +572,26 @@
<select id="getInterviewBookSituation" resultType="com.cool.store.entity.HyPartnerInterviewBookSituation"> <select id="getInterviewBookSituation" resultType="com.cool.store.entity.HyPartnerInterviewBookSituation">
SELECT t_booking_times.*, IFNULL(application_approved, 0) AS booked SELECT t_booking_times.*, IFNULL(application_approved, 0) AS booked
FROM ( FROM (
-- 查询已被预约成功的时间段 -- 查询已被预约成功的时间段
SELECT t1.start_time, t1.end_time, t1.application_approved, t1.deleted SELECT t1.start_time, t1.end_time, t1.application_approved, t1.deleted
FROM hy_partner_interview_plan t1 FROM hy_partner_interview_plan t1
LEFT JOIN hy_partner_interview t2 ON t1.id = t2.interview_plan_id LEFT JOIN hy_partner_interview t2 ON t1.id = t2.interview_plan_id
WHERE t1.interviewer = #{interviewerId} WHERE t1.interviewer = #{interviewerId}
GROUP BY start_time AND t1.deleted = 0
HAVING t1.deleted = 0 AND t1.application_approved = 1
AND t1.application_approved = 1 AND t1.start_time &gt;= #{startTime}
AND t1.start_time &gt;= #{startTime} AND t1.end_time &lt;= #{endTime}
AND t1.end_time &lt;= #{endTime}
) )
AS t_booking_success AS t_booking_success
RIGHT JOIN ( RIGHT JOIN (
-- 查询所有时间段预约人数 -- 查询所有时间段预约人数
SELECT COUNT(*) AS booking_count, start_time, end_time, deleted SELECT COUNT(*) AS booking_count, start_time, end_time, deleted
FROM hy_partner_interview_plan FROM hy_partner_interview_plan
WHERE interviewer = #{interviewerId} WHERE interviewer = #{interviewerId}
GROUP BY start_time AND deleted = 0
HAVING deleted = 0 AND start_time &gt;= #{startTime}
AND start_time &gt;= #{startTime} AND end_time &lt;= #{endTime}
AND end_time &lt;= #{endTime} GROUP BY start_time
) )
AS t_booking_times ON t_booking_times.start_time = t_booking_success.start_time AS t_booking_times ON t_booking_times.start_time = t_booking_success.start_time
</select> </select>

View File

@@ -753,14 +753,15 @@ public class InterviewServiceImpl implements InterviewService {
List<FreeBusyInfo> freeBusyList = daySlot.getFreeBusyList(); List<FreeBusyInfo> freeBusyList = daySlot.getFreeBusyList();
for (FreeBusyInfo freeBusyInfo : freeBusyList) { for (FreeBusyInfo freeBusyInfo : freeBusyList) {
//把日期和时间拼接成yyyy-MM-dd HH:mm格式 //把日期和时间拼接成yyyy-MM-dd HH:mm格式
String startStr = daySlot.getDateStr() + " " + freeBusyInfo.getStartTime(); String startStr = daySlot.getDateStr() + " " + freeBusyInfo.getStartTime() + ":00";
String endStr = daySlot.getDateStr() + " " + freeBusyInfo.getEndTime(); String endStr = daySlot.getDateStr() + " " + freeBusyInfo.getEndTime() + ":00";
for (HyPartnerInterviewBookSituation bookSituation : bookSituations) { for (HyPartnerInterviewBookSituation bookSituation : bookSituations) {
//比较两个时间段是否有重叠,重叠的就 set 数据进去 //比较两个时间段是否有重叠,重叠的就 set 数据进去
if (startStr.compareTo(bookSituation.getStartTime()) >= 0 && endStr.compareTo(bookSituation.getEndTime()) <= 0) { if (startStr.compareTo(bookSituation.getStartTime()) >= 0 && endStr.compareTo(bookSituation.getEndTime()) <= 0) {
freeBusyInfo.setFree(Boolean.FALSE); freeBusyInfo.setFree(Boolean.FALSE);
freeBusyInfo.setBooked(Boolean.TRUE); freeBusyInfo.setBooked(Boolean.TRUE);
freeBusyInfo.setAppointmentCount(bookSituation.getBookingCount()); freeBusyInfo.setAppointmentCount(bookSituation.getBookingCount());
bookSituations.remove(bookSituation);
break; break;
} }
} }

View File

@@ -86,8 +86,8 @@ public class TimeSlotGenerator {
List<FreeBusyInfo> hourSlots = new ArrayList<>(); List<FreeBusyInfo> hourSlots = new ArrayList<>();
for (int hour = 10; hour < 17; hour++) { for (int hour = 10; hour < 17; hour++) {
String startTime = String.format("%02d:00:00", hour); String startTime = String.format("%02d:00", hour);
String endTime = String.format("%02d:00:00", hour + 1); String endTime = String.format("%02d:00", hour + 1);
//默认空闲 //默认空闲
FreeBusyInfo hourSlot = new FreeBusyInfo(startTime, endTime, true, 0, false); FreeBusyInfo hourSlot = new FreeBusyInfo(startTime, endTime, true, 0, false);
hourSlots.add(hourSlot); hourSlots.add(hourSlot);
@@ -104,14 +104,14 @@ public class TimeSlotGenerator {
if(hour == 12){ if(hour == 12){
continue; continue;
} }
String startTime = String.format("%02d:00:00", hour); String startTime = String.format("%02d:00", hour);
String endTime = String.format("%02d:30:00", hour); String endTime = String.format("%02d:30", hour);
//默认空闲 //默认空闲
FreeBusyInfo hourSlot = new FreeBusyInfo(startTime, endTime, true, 0, false); FreeBusyInfo hourSlot = new FreeBusyInfo(startTime, endTime, true, 0, false);
hourSlots.add(hourSlot); hourSlots.add(hourSlot);
String startTime2 = String.format("%02d:30:00", hour); String startTime2 = String.format("%02d:30", hour);
String endTime2 = String.format("%02d:00:00", hour + 1); String endTime2 = String.format("%02d:00", hour + 1);
//默认空闲 //默认空闲
FreeBusyInfo hourSlot2 = new FreeBusyInfo(startTime2, endTime2, true, 0, false); FreeBusyInfo hourSlot2 = new FreeBusyInfo(startTime2, endTime2, true, 0, false);
hourSlots.add(hourSlot2); hourSlots.add(hourSlot2);
@@ -124,14 +124,14 @@ public class TimeSlotGenerator {
//循环打印半小时的时间段 //循环打印半小时的时间段
for (int hour = 8; hour < 24; hour++) { for (int hour = 8; hour < 24; hour++) {
String startTime = String.format("%02d:00:00", hour); String startTime = String.format("%02d:00", hour);
String endTime = String.format("%02d:30:00", hour); String endTime = String.format("%02d:30", hour);
//默认空闲 //默认空闲
FreeBusyInfo hourSlot = new FreeBusyInfo(startTime, endTime, true, 0, false); FreeBusyInfo hourSlot = new FreeBusyInfo(startTime, endTime, true, 0, false);
hourSlots.add(hourSlot); hourSlots.add(hourSlot);
String startTime2 = String.format("%02d:30:00", hour); String startTime2 = String.format("%02d:30", hour);
String endTime2 = String.format("%02d:00:00", hour + 1); String endTime2 = String.format("%02d:00", hour + 1);
//默认空闲,预约人数为 0 //默认空闲,预约人数为 0
FreeBusyInfo hourSlot2 = new FreeBusyInfo(startTime2, endTime2, true, 0, false); FreeBusyInfo hourSlot2 = new FreeBusyInfo(startTime2, endTime2, true, 0, false);
hourSlots.add(hourSlot2); hourSlots.add(hourSlot2);