diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java index db6abec6aa..f956423f3a 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/DateUtils.java @@ -945,4 +945,127 @@ public class DateUtils { return result; } + /** + * @Description 获取工作日时间【没有排除节假日】 + * @param startDate + * @param num + * @author zxc + * @date 2022/1/7 10:51 上午 + */ + public static Date getWorkDay(Date startDate, int num) { + Date tomorrow = null; + int delay = 1; + while (delay <= num) { + tomorrow = getTomorrow(startDate); + if (!isWeekend(tomorrow)) { + delay++; + } + startDate = tomorrow; + } + return startDate; + } + + /** + * @Description 根据开始时间计算出 当前日期后n个工作日【没有排除节假日】包括今天 + * @param startDate + * @param num + * @author zxc + * @date 2022/1/7 10:20 上午 + */ + public static List getWorkDayList(Date startDate, int num) { + List result = new ArrayList<>(); + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(startDate); + rightNow.add(Calendar.DATE,-1); + startDate = rightNow.getTime(); + Date tomorrow; + Integer tag = 1; + while (tag <= num){ + tomorrow = getTomorrow(startDate); + // 返回工作日 + if (!isWeekend(tomorrow)) { + result.add(new SimpleDateFormat(DATE_PATTERN).format(tomorrow)); + tag++; + } + startDate = tomorrow; + } + return result; + } + + /** + * @Description 根据开始时间计算出 当前日期后n个周末【没有排除节假日】包括今天 + * @param startDate + * @param num + * @author zxc + * @date 2022/1/7 10:20 上午 + */ + public static List getWeekendDayList(Date startDate, int num) { + List result = new ArrayList<>(); + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(startDate); + rightNow.add(Calendar.DATE,-1); + startDate = rightNow.getTime(); + Date tomorrow; + Integer tag = 1; + while (tag <= num){ + tomorrow = getTomorrow(startDate); + // 返回周末 + if (isWeekend(tomorrow)) { + result.add(new SimpleDateFormat(DATE_PATTERN).format(tomorrow)); + tag++; + } + startDate = tomorrow; + } + return result; + } + + /** + * @Description 根据开始时间计算出 当前日期后n天【没有排除节假日】包括今天 + * @param startDate + * @param num + * @author zxc + * @date 2022/1/7 10:20 上午 + */ + public static List getEveryDayList(Date startDate, int num) { + List result = new ArrayList<>(); + Calendar rightNow = Calendar.getInstance(); + rightNow.setTime(startDate); + rightNow.add(Calendar.DATE,-1); + startDate = rightNow.getTime(); + Date tomorrow; + Integer tag = 1; + while (tag <= num){ + tomorrow = getTomorrow(startDate); + result.add(new SimpleDateFormat(DATE_PATTERN).format(tomorrow)); + tag++; + startDate = tomorrow; + } + return result; + } + + /** + * @Description 判断日期字符串是否为周末 + * @param date eg:yyyy-MM-dd + * @author zxc + * @date 2022/1/7 10:50 上午 + */ + private static boolean isWeekend(Date date) { + Calendar cal = Calendar.getInstance(); + cal.setTime(date); + return cal.get(Calendar.DAY_OF_WEEK) == Calendar.SATURDAY || cal.get(Calendar.DAY_OF_WEEK) == Calendar.SUNDAY; + } + + /** + * @Description 获取tomorrow的日期 + * @param startDate + * @author zxc + * @date 2022/1/7 10:50 上午 + */ + private static Date getTomorrow(Date startDate) { + Calendar cal = Calendar.getInstance(); + cal.setTime(startDate); + cal.add(Calendar.DAY_OF_MONTH, +1); + return cal.getTime(); + } + } diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentTimeResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentTimeResultDTO.java index b37e4e913a..017d37afae 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentTimeResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/AppointmentTimeResultDTO.java @@ -27,8 +27,11 @@ public class AppointmentTimeResultDTO implements Serializable { */ private List timeDetail; + private List dateList; + public AppointmentTimeResultDTO() { this.appointmentType = ""; this.timeDetail = new ArrayList<>(); + this.dateList = new ArrayList<>(); } } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/PartyServiceCenterConstant.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/PartyServiceCenterConstant.java index a733afaa2f..50f6baed7e 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/PartyServiceCenterConstant.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/constant/PartyServiceCenterConstant.java @@ -13,4 +13,8 @@ public interface PartyServiceCenterConstant { String APPOINTMENT_STATUS_APPOINTING = "appointing"; String APPOINTMENT_STATUS_CANCEL = "cancel"; + String APPOINTMENT_TYPE_EVERY_DAY = "everyDay"; + String APPOINTMENT_TYPE_WORK_DAY = "workDay"; + String APPOINTMENT_TYPE_WEEKEND = "weekend"; + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java index 8522e229fb..4bd7fdc3bb 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcPartyServiceCenterServiceImpl.java @@ -423,6 +423,7 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl l = new LambdaQueryWrapper<>(); l.eq(IcMatterAppointmentRecordEntity::getMatterId,formDTO.getMatterId()) .eq(IcMatterAppointmentRecordEntity::getAppointmentDate,formDTO.getDate()) @@ -487,6 +488,23 @@ public class IcPartyServiceCenterServiceImpl extends BaseServiceImpl getDateList(String type) { + List result = new ArrayList<>(); + if (type.equals(PartyServiceCenterConstant.APPOINTMENT_TYPE_EVERY_DAY)){ + result = DateUtils.getEveryDayList(new Date(),NumConstant.SEVEN); + }else if (type.equals(PartyServiceCenterConstant.APPOINTMENT_TYPE_WORK_DAY)){ + result = DateUtils.getWorkDayList(new Date(),NumConstant.SEVEN); + }else { + result = DateUtils.getWeekendDayList(new Date(),NumConstant.SEVEN); + } + return result; + } + + public static void main(String[] args) { + Date date = DateUtils.addDateDays(new Date(), 2); + + } + /** * @Description 【党群服务中心】预约记录 * @param formDTO